C# Class AntTweakBar.Tw

A low-level wrapper to the AntTweakBar API.
显示文件 Open project: TomCrypto/AntTweakBar.NET Class Usage Examples

Public Methods

Method Description
AddButton ( IntPtr bar, String name, ButtonCallback callback, IntPtr clientData, String def ) : void

This function adds a button entry to a tweak bar. When the button is clicked by a user, the callback function provided to this function is called.

AddSeparator ( IntPtr bar, String name, String def ) : void

This function adds a horizontal separator line to a tweak bar. It may be useful if one wants to separate several sets of variables inside a same group.

AddVarCB ( IntPtr bar, String name, VariableType type, SetVarCallback setCallback, GetVarCallback getCallback, IntPtr clientData, String def ) : void

This function adds a new variable to a tweak bar by providing CallBack (CB) functions to access it.

AddVarRO ( IntPtr bar, String name, VariableType type, IntPtr var, String def ) : void

This function adds a new variable to a tweak bar by specifying the variable’s pointer. The variable is declared Read-Only (RO), so it could not be modified interactively by the user.

AddVarRW ( IntPtr bar, String name, VariableType type, IntPtr var, String def ) : void

This function adds a new variable to a tweak bar by specifying the variable’s pointer. The variable is declared Read-Write (RW), so it could be modified interactively by the user.

Define ( String def ) : void

This function defines optional parameters for tweak bars and variables. For instance, it allows you to change the color of a tweak bar, to set a min and a max value for a variable, to add an help message that inform users of the meaning of a variable, and so on...

DefineEnum ( String name, String>.IDictionary labels ) : VariableType

This function creates a new variable type corresponding to an enum.

DefineEnumFromString ( String name, String enumString ) : VariableType

This function creates a new variable type corresponding to an enum.

DefineStruct ( String name, StructMemberInfo>.IDictionary structMembers, int structSize, Tw callback, IntPtr clientData ) : VariableType

This function creates a new AntTweakBar.Tw.VariableType corresponding to a structure.

DeleteAllBars ( ) : void

Delete all bars previously created by AntTweakBar.Tw.NewBar.

DeleteBar ( IntPtr bar ) : void

This function deletes a tweak bar previously created by AntTweakBar.Tw.NewBar.

Draw ( ) : void

Draws all the created tweak bars. This function must be called once per frame, after all the other drawing calls and just before the application presents (swaps) the frame buffer.

EventSDL ( IntPtr sdlEvent, byte majorVersion, byte minorVersion ) : bool

The SDL event handler.

EventSFML ( IntPtr sfmlEvent, byte majorVersion, byte minorVersion ) : bool

The SFML event handler.

EventWin ( IntPtr wnd, int msg, IntPtr wParam, IntPtr lParam ) : bool

The Windows event handler.

EventX11 ( IntPtr xEvent ) : bool

The X11 event handler.

GetBarByIndex ( int barIndex ) : IntPtr

Returns the bar of a given index.

GetBarByName ( String barName ) : IntPtr

Returns the bar of a given name.

GetBarCount ( ) : int

Returns the number of created bars.

GetBarName ( IntPtr bar ) : String

Returns the name of a given tweak bar.

GetBooleanParam ( IntPtr bar, String varName, String paramName ) : System.Boolean

This function returns the current value of a bar or variable parameter.

GetBottomBar ( ) : IntPtr

Returns the identifier of the current background bar (the bar displayed behind the others).

GetColorParam ( IntPtr bar, String varName, String paramName ) : Color

This function returns the current value of a bar or variable parameter.

GetCurrentWindow ( ) : int

Returns the current window context identifier previously set by AntTweakBar.Tw.SetCurrentWindow.

GetDoubleParam ( IntPtr bar, String varName, String paramName, int paramCount ) : Double[]

This function returns the current value of a bar or variable parameter.

GetIntParam ( IntPtr bar, String varName, String paramName, int paramCount ) : System.Int32[]

This function returns the current value of a bar or variable parameter.

GetLastError ( ) : String

Returns the last error that has occured during a previous AntTweakBar function call.

GetPointParam ( IntPtr bar, String varName, String paramName ) : Point

This function returns the current value of a bar or variable parameter.

GetSingleParam ( IntPtr bar, String varName, String paramName, int paramCount ) : System.Single[]

This function returns the current value of a bar or variable parameter.

GetSizeParam ( IntPtr bar, String varName, String paramName ) : Size

This function returns the current value of a bar or variable parameter.

GetStringParam ( IntPtr bar, String varName, String paramName ) : String

This function returns the current value of a bar or variable parameter.

GetTopBar ( ) : IntPtr

Returns the identifier of the current foreground bar (the bar displayed on top of the others).

Init ( GraphicsAPI graphicsAPI, IntPtr device ) : void

This function initializes the AntTweakBar library. It must be called once at the beginning of the program, just after graphic mode is initialized.

KeyPressed ( Tw key, KeyModifiers modifiers ) : bool

Call this function to inform AntTweakBar when a keyboard event occurs.

KeyPressed ( char key, KeyModifiers modifiers ) : bool

Call this function to inform AntTweakBar when a keyboard event occurs.

KeyTest ( Tw key, KeyModifiers modifiers ) : bool

This function checks if a key event would be processed but without processing it. This could be helpful to prevent bad handling report.

KeyTest ( char key, KeyModifiers modifiers ) : bool

This function checks if a key event would be processed but without processing it. This could be helpful to prevent bad handling report.

MouseClick ( MouseAction action, MouseButton button ) : bool

Call this function to inform AntTweakBar that a mouse button is pressed.

MouseMotion ( int mouseX, int mouseY ) : bool

Call this function to inform AntTweakBar that the mouse has moved.

MouseWheel ( int pos ) : bool

Call this function to inform AntTweakBar that the mouse wheel has been used.

NewBar ( string barName ) : IntPtr

Creates a new tweak bar.

RefreshBar ( IntPtr bar ) : void

Forces bar content to be updated. By default bar content is periodically refreshed when AntTweakBar.Tw.Draw is called (the update frequency is defined by the bar parameter refresh).

RemoveAllVars ( IntPtr bar ) : void

This function removes all the variables, buttons and separators previously added to a tweak bar.

RemoveVar ( IntPtr bar, String name ) : void

This function removes a variable, button or separator from a tweak bar.

SetBottomBar ( IntPtr bar ) : void

Set the specified bar as the background bar. It will be displayed behind the other bars.

SetCurrentWindow ( int windowID ) : void

This function is intended to be used by applications with multiple graphical windows. It tells AntTweakBar to switch its current context to the context associated to the identifier windowID.

SetParam ( IntPtr bar, String varName, String paramName ) : void

This function modifies the value(s) of a bar or variable parameter.

SetParam ( IntPtr bar, String varName, String paramName, System.Boolean boolean ) : void

This function modifies the value(s) of a bar or variable parameter.

SetParam ( IntPtr bar, String varName, String paramName, Color color ) : void

This function modifies the value(s) of a bar or variable parameter.

SetParam ( IntPtr bar, String varName, String paramName, Point point ) : void

This function modifies the value(s) of a bar or variable parameter.

SetParam ( IntPtr bar, String varName, String paramName, Size size ) : void

This function modifies the value(s) of a bar or variable parameter.

SetParam ( IntPtr bar, String varName, String paramName, String value ) : void

This function modifies the value(s) of a bar or variable parameter.

SetTopBar ( IntPtr bar ) : void

Set the specified bar as the foreground bar. It will be displayed on top of the other bars.

Terminate ( ) : void

Uninitialize the AntTweakBar API. Must be called at the end of the program, before terminating the graphics API.

WindowExists ( int windowID ) : bool

Check if a window context associated to the identifier windowID exists. A window context exists if it has previously been created by AntTweakBar.Tw.SetCurrentWindow.

WindowSize ( int width, int height ) : void

Call this function to inform AntTweakBar of the size of the application graphics window, or to restore AntTweakBar graphics resources (after a fullscreen switch for instance).

Private Methods

Method Description
AlreadyUnpacked ( String path, String checksum ) : bool
Tw ( ) : System

Initializes the AntTweakBar.NET wrapper.

UnpackDLL ( ) : void

Method Details

AddButton() public static method

This function adds a button entry to a tweak bar. When the button is clicked by a user, the callback function provided to this function is called.
public static AddButton ( IntPtr bar, String name, ButtonCallback callback, IntPtr clientData, String def ) : void
bar System.IntPtr The tweak bar to which adding a new variable.
name String The name of the button. It will be displayed in the tweak bar if no label is specified for this button. It will also be used to refer to this button in other functions.
callback ButtonCallback The callback function that will be called by AntTweakBar when the button is clicked.
clientData System.IntPtr For your convenience, this is a supplementary pointer that will be passed to the callback function when it is called.
def String An optional definition string used to modify the behavior of this new entry.
return void

AddSeparator() public static method

This function adds a horizontal separator line to a tweak bar. It may be useful if one wants to separate several sets of variables inside a same group.
public static AddSeparator ( IntPtr bar, String name, String def ) : void
bar System.IntPtr The tweak bar to which adding the separator.
name String The name of the separator. It is optional, this parameter can be set to NULL.
def String An optional definition string used to modify the behavior of this new entry.
return void

AddVarCB() public static method

This function adds a new variable to a tweak bar by providing CallBack (CB) functions to access it.
public static AddVarCB ( IntPtr bar, String name, VariableType type, SetVarCallback setCallback, GetVarCallback getCallback, IntPtr clientData, String def ) : void
bar System.IntPtr The tweak bar to which adding a new variable.
name String The name of the variable. It will be displayed in the tweak bar if no label is specified for this variable. It will also be used to refer to this variable in other functions.
type VariableType Type of the variable. It must be one of the constants or a user defined type.
setCallback SetVarCallback The callback function that will be called by AntTweakBar to change the variable’s value.
getCallback GetVarCallback The callback function that will be called by AntTweakBar to get the variable’s value.
clientData System.IntPtr For your convenience, this is a supplementary pointer that will be passed to the callback functions when they are called.
def String An optional definition string used to modify the behavior of this new entry.
return void

AddVarRO() public static method

This function adds a new variable to a tweak bar by specifying the variable’s pointer. The variable is declared Read-Only (RO), so it could not be modified interactively by the user.
public static AddVarRO ( IntPtr bar, String name, VariableType type, IntPtr var, String def ) : void
bar System.IntPtr The tweak bar to which adding a new variable.
name String The name of the variable. It will be displayed in the tweak bar if no label is specified for this variable. It will also be used to refer to this variable in other functions.
type VariableType Type of the variable. It must be one of the constants or a user defined type.
var System.IntPtr Pointer to the variable linked to this entry.
def String An optional definition string used to modify the behavior of this new entry.
return void

AddVarRW() public static method

This function adds a new variable to a tweak bar by specifying the variable’s pointer. The variable is declared Read-Write (RW), so it could be modified interactively by the user.
public static AddVarRW ( IntPtr bar, String name, VariableType type, IntPtr var, String def ) : void
bar System.IntPtr The tweak bar to which adding a new variable.
name String The name of the variable. It will be displayed in the tweak bar if no label is specified for this variable. It will also be used to refer to this variable in other functions.
type VariableType Type of the variable. It must be one of the constants or a user defined type.
var System.IntPtr Pointer to the variable linked to this entry.
def String An optional definition string used to modify the behavior of this new entry.
return void

Define() public static method

This function defines optional parameters for tweak bars and variables. For instance, it allows you to change the color of a tweak bar, to set a min and a max value for a variable, to add an help message that inform users of the meaning of a variable, and so on...
public static Define ( String def ) : void
def String A string containing one or more parameter assignments (separated by newlines).
return void

DefineEnum() public static method

This function creates a new variable type corresponding to an enum.
public static DefineEnum ( String name, String>.IDictionary labels ) : VariableType
name String Specify a name for the enum type (must be unique).
labels String>.IDictionary A mapping from admissible values to their labels.
return VariableType

DefineEnumFromString() public static method

This function creates a new variable type corresponding to an enum.
public static DefineEnumFromString ( String name, String enumString ) : VariableType
name String Specify a name for the enum type (must be unique).
enumString String Comma-separated list of labels.
return VariableType

DefineStruct() public static method

This function creates a new AntTweakBar.Tw.VariableType corresponding to a structure.
public static DefineStruct ( String name, StructMemberInfo>.IDictionary structMembers, int structSize, Tw callback, IntPtr clientData ) : VariableType
name String
structMembers StructMemberInfo>.IDictionary
structSize int
callback Tw
clientData System.IntPtr
return VariableType

DeleteAllBars() public static method

Delete all bars previously created by AntTweakBar.Tw.NewBar.
public static DeleteAllBars ( ) : void
return void

DeleteBar() public static method

This function deletes a tweak bar previously created by AntTweakBar.Tw.NewBar.
public static DeleteBar ( IntPtr bar ) : void
bar System.IntPtr Identifier to the tweak bar to delete.
return void

Draw() public static method

Draws all the created tweak bars. This function must be called once per frame, after all the other drawing calls and just before the application presents (swaps) the frame buffer.
public static Draw ( ) : void
return void

EventSDL() public static method

The SDL event handler.
public static EventSDL ( IntPtr sdlEvent, byte majorVersion, byte minorVersion ) : bool
sdlEvent System.IntPtr
majorVersion byte
minorVersion byte
return bool

EventSFML() public static method

The SFML event handler.
public static EventSFML ( IntPtr sfmlEvent, byte majorVersion, byte minorVersion ) : bool
sfmlEvent System.IntPtr
majorVersion byte
minorVersion byte
return bool

EventWin() public static method

The Windows event handler.
public static EventWin ( IntPtr wnd, int msg, IntPtr wParam, IntPtr lParam ) : bool
wnd System.IntPtr
msg int
wParam System.IntPtr
lParam System.IntPtr
return bool

EventX11() public static method

The X11 event handler.
public static EventX11 ( IntPtr xEvent ) : bool
xEvent System.IntPtr
return bool

GetBarByIndex() public static method

Returns the bar of a given index.
public static GetBarByIndex ( int barIndex ) : IntPtr
barIndex int Index of the requested bar.
return System.IntPtr

GetBarByName() public static method

Returns the bar of a given name.
public static GetBarByName ( String barName ) : IntPtr
barName String Name of the requested bar.
return System.IntPtr

GetBarCount() public static method

Returns the number of created bars.
public static GetBarCount ( ) : int
return int

GetBarName() public static method

Returns the name of a given tweak bar.
public static GetBarName ( IntPtr bar ) : String
bar System.IntPtr Identifier to the tweak bar.
return String

GetBooleanParam() public static method

This function returns the current value of a bar or variable parameter.
public static GetBooleanParam ( IntPtr bar, String varName, String paramName ) : System.Boolean
bar System.IntPtr
varName String
paramName String
return System.Boolean

GetBottomBar() public static method

Returns the identifier of the current background bar (the bar displayed behind the others).
public static GetBottomBar ( ) : IntPtr
return System.IntPtr

GetColorParam() public static method

This function returns the current value of a bar or variable parameter.
public static GetColorParam ( IntPtr bar, String varName, String paramName ) : Color
bar System.IntPtr
varName String
paramName String
return Color

GetCurrentWindow() public static method

Returns the current window context identifier previously set by AntTweakBar.Tw.SetCurrentWindow.
public static GetCurrentWindow ( ) : int
return int

GetDoubleParam() public static method

This function returns the current value of a bar or variable parameter.
public static GetDoubleParam ( IntPtr bar, String varName, String paramName, int paramCount ) : Double[]
bar System.IntPtr
varName String
paramName String
paramCount int
return Double[]

GetIntParam() public static method

This function returns the current value of a bar or variable parameter.
public static GetIntParam ( IntPtr bar, String varName, String paramName, int paramCount ) : System.Int32[]
bar System.IntPtr
varName String
paramName String
paramCount int
return System.Int32[]

GetLastError() public static method

Returns the last error that has occured during a previous AntTweakBar function call.
public static GetLastError ( ) : String
return String

GetPointParam() public static method

This function returns the current value of a bar or variable parameter.
public static GetPointParam ( IntPtr bar, String varName, String paramName ) : Point
bar System.IntPtr
varName String
paramName String
return Point

GetSingleParam() public static method

This function returns the current value of a bar or variable parameter.
public static GetSingleParam ( IntPtr bar, String varName, String paramName, int paramCount ) : System.Single[]
bar System.IntPtr
varName String
paramName String
paramCount int
return System.Single[]

GetSizeParam() public static method

This function returns the current value of a bar or variable parameter.
public static GetSizeParam ( IntPtr bar, String varName, String paramName ) : Size
bar System.IntPtr
varName String
paramName String
return System.Drawing.Size

GetStringParam() public static method

This function returns the current value of a bar or variable parameter.
public static GetStringParam ( IntPtr bar, String varName, String paramName ) : String
bar System.IntPtr
varName String
paramName String
return String

GetTopBar() public static method

Returns the identifier of the current foreground bar (the bar displayed on top of the others).
public static GetTopBar ( ) : IntPtr
return System.IntPtr

Init() public static method

This function initializes the AntTweakBar library. It must be called once at the beginning of the program, just after graphic mode is initialized.
public static Init ( GraphicsAPI graphicsAPI, IntPtr device ) : void
graphicsAPI GraphicsAPI This parameter specifies which graphic API is used: OpenGL, OpenGL core profile (3.2 and higher), Direct3D 9, Direct3D 10 or Direct3D 11.
device System.IntPtr Pointer to the Direct3D device, or IntPtr.Zero for OpenGL.
return void

KeyPressed() public static method

Call this function to inform AntTweakBar when a keyboard event occurs.
public static KeyPressed ( Tw key, KeyModifiers modifiers ) : bool
key Tw One of the codes.
modifiers KeyModifiers One or a combination of the constants.
return bool

KeyPressed() public static method

Call this function to inform AntTweakBar when a keyboard event occurs.
public static KeyPressed ( char key, KeyModifiers modifiers ) : bool
key char The ASCII code of the pressed key.
modifiers KeyModifiers One or a combination of the constants.
return bool

KeyTest() public static method

This function checks if a key event would be processed but without processing it. This could be helpful to prevent bad handling report.
public static KeyTest ( Tw key, KeyModifiers modifiers ) : bool
key Tw One of the codes.
modifiers KeyModifiers One or a combination of the constants.
return bool

KeyTest() public static method

This function checks if a key event would be processed but without processing it. This could be helpful to prevent bad handling report.
public static KeyTest ( char key, KeyModifiers modifiers ) : bool
key char The ASCII code of the pressed key.
modifiers KeyModifiers One or a combination of the constants.
return bool

MouseClick() public static method

Call this function to inform AntTweakBar that a mouse button is pressed.
public static MouseClick ( MouseAction action, MouseButton button ) : bool
action MouseAction Tells if the button is pressed or released. It is one of the constants.
button MouseButton Tells which button is pressed. It is one of the constants.
return bool

MouseMotion() public static method

Call this function to inform AntTweakBar that the mouse has moved.
public static MouseMotion ( int mouseX, int mouseY ) : bool
mouseX int The new X position of the mouse, relative to the left border of the graphics window.
mouseY int The new Y position of the mouse, relative to the top border of the graphics window.
return bool

MouseWheel() public static method

Call this function to inform AntTweakBar that the mouse wheel has been used.
public static MouseWheel ( int pos ) : bool
pos int The new position of the wheel.
return bool

NewBar() public static method

Creates a new tweak bar.
public static NewBar ( string barName ) : IntPtr
barName string Name of the new tweak bar.
return System.IntPtr

RefreshBar() public static method

Forces bar content to be updated. By default bar content is periodically refreshed when AntTweakBar.Tw.Draw is called (the update frequency is defined by the bar parameter refresh).
public static RefreshBar ( IntPtr bar ) : void
bar System.IntPtr Bar identifier.
return void

RemoveAllVars() public static method

This function removes all the variables, buttons and separators previously added to a tweak bar.
public static RemoveAllVars ( IntPtr bar ) : void
bar System.IntPtr The tweak bar from which to remove all variables.
return void

RemoveVar() public static method

This function removes a variable, button or separator from a tweak bar.
public static RemoveVar ( IntPtr bar, String name ) : void
bar System.IntPtr The tweak bar from which to remove a variable.
name String The name of the variable.
return void

SetBottomBar() public static method

Set the specified bar as the background bar. It will be displayed behind the other bars.
public static SetBottomBar ( IntPtr bar ) : void
bar System.IntPtr Bar identifier.
return void

SetCurrentWindow() public static method

This function is intended to be used by applications with multiple graphical windows. It tells AntTweakBar to switch its current context to the context associated to the identifier windowID.
public static SetCurrentWindow ( int windowID ) : void
windowID int Window context identifier. This identifier could be any integer.
return void

SetParam() public static method

This function modifies the value(s) of a bar or variable parameter.
public static SetParam ( IntPtr bar, String varName, String paramName ) : void
bar System.IntPtr
varName String
paramName String
return void

SetParam() public static method

This function modifies the value(s) of a bar or variable parameter.
public static SetParam ( IntPtr bar, String varName, String paramName, System.Boolean boolean ) : void
bar System.IntPtr
varName String
paramName String
boolean System.Boolean
return void

SetParam() public static method

This function modifies the value(s) of a bar or variable parameter.
public static SetParam ( IntPtr bar, String varName, String paramName, Color color ) : void
bar System.IntPtr
varName String
paramName String
color Color
return void

SetParam() public static method

This function modifies the value(s) of a bar or variable parameter.
public static SetParam ( IntPtr bar, String varName, String paramName, Point point ) : void
bar System.IntPtr
varName String
paramName String
point Point
return void

SetParam() public static method

This function modifies the value(s) of a bar or variable parameter.
public static SetParam ( IntPtr bar, String varName, String paramName, Size size ) : void
bar System.IntPtr
varName String
paramName String
size System.Drawing.Size
return void

SetParam() public static method

This function modifies the value(s) of a bar or variable parameter.
public static SetParam ( IntPtr bar, String varName, String paramName, String value ) : void
bar System.IntPtr
varName String
paramName String
value String
return void

SetTopBar() public static method

Set the specified bar as the foreground bar. It will be displayed on top of the other bars.
public static SetTopBar ( IntPtr bar ) : void
bar System.IntPtr Bar identifier.
return void

Terminate() public static method

Uninitialize the AntTweakBar API. Must be called at the end of the program, before terminating the graphics API.
public static Terminate ( ) : void
return void

WindowExists() public static method

Check if a window context associated to the identifier windowID exists. A window context exists if it has previously been created by AntTweakBar.Tw.SetCurrentWindow.
public static WindowExists ( int windowID ) : bool
windowID int Window context identifier.
return bool

WindowSize() public static method

Call this function to inform AntTweakBar of the size of the application graphics window, or to restore AntTweakBar graphics resources (after a fullscreen switch for instance).
public static WindowSize ( int width, int height ) : void
width int Width of the graphics window.
height int Height of the graphics window.
return void