GuiCanvas

Engine/source/gui/core/guiCanvas.h

More...

Classes:

class

Accelerator key map.

Rendering methods

renderFrame(bool preRenderOnly, bool bufferSwap)

Repaints the dirty regions of the canvas.

Repaints the canvas by calling the platform window display event.

repaint(U32 elapsedMS)

Repaints the canvas skipping rendering if the target time has not yet elapsed.

Adds a dirty area to the canvas so it will be updated on the next frame.

Resets the update regions so that the next call to renderFrame will repaint the whole canvas.

Resizes the content control to match the canvas size.

buildUpdateUnion(RectI * updateUnion)

This builds a rectangle which encompasses all of the dirty regions to be repainted.

This will swap the buffers at the end of renderFrame.

Signal< void(bool beginFrame)>
GuiCanvasFrameSignal 

This signal is triggered at the beginning and end of each render frame.

Mouse Input

bool

Processes keyboard input events.

bool

Processes mouse input events.

bool

Processes gamepad input events.

All mouse events will go to this ctrl only.

the control the mouse was last seen in unless some other one captured it

bool

whether the current ctrl has been clicked - used by helpctrl

this determines how long the mouse has been in the same control

bool

Flag to determine if the button is depressed.

bool

bool to determine if the right button is depressed

bool

Middle button flag.

Cursor commands

A cursor can be on, but not be shown.

If a cursor is not on, than it does not process input.

setCursor(GuiCursor * cursor)

Sets the cursor for the canvas.

bool

Returns true if the cursor is on.

setForceMouseToGUI(bool onOff)

Sets if mouse events should be passed to the GUI even if the cursor is off.

Sets if the Torque cursor should be clamped to the window.

bool

Returns if the Torque cursor is clamped to the window.

setCursorON(bool onOff)

Turns the cursor on or off.

Sets the position of the cursor.

Returns the point, in screenspace, at which the cursor is located.

Returns the point, in local coordinates, at which the cursor is located.

showCursor(bool state)

Enable/disable rendering of the cursor.

bool

Returns true if the cursor is being rendered.

cursorClick(S32 buttonId, bool isDown)

Canvas Content Management

This returns the PlatformWindow owned by this Canvas.

This sets the content control to something different.

Returns the content control.

pushDialogControl(GuiControl * gui, S32 layer, bool center)

Adds a dialog control onto the stack of dialogs.

Removes a specific layer of dialogs.

Removes a specific dialog control.

Input Processing

bool

Processes an input event.

Mouse Methods

mouseLock(GuiControl * lockingControl)

When a control gets the mouse lock this means that that control gets ALL mouse input and no other control receives any input.

mouseUnlock(GuiControl * lockingControl)

Unlocks the mouse from a control.

Returns the control which the mouse is over.

Returns the control which the mouse is locked to if any.

bool

Returns true if the left mouse button is down.

bool

Returns true if the right mouse button is down.

Mouse input methods

These events process the events before passing them down to the controls they effect.

This allows for things such as the input locking and such.

Each of these methods corresponds to the action in it's method name and processes the GuiEvent passed as a parameter

Keyboard input methods

First responders

A first responder is a the GuiControl which responds first to input events before passing them off for further processing.

bool

Moves the first responder to the next tabable controle.

bool

Moves the first responder to the previous tabable control.

addAcceleratorKey(GuiControl * ctrl, U32 index, U32 keyCode, U32 modifier)

Setups a keyboard accelerator which maps to a GuiControl.

setFirstResponder(GuiControl * firstResponder)

Sets the first responder.

This is used to toggle processing of native OS accelerators, not to be confused with the Torque accelerator key system, to keep them from swallowing up keystrokes.

Protected Types

Parent 

Private Static Attributes

The maximum number of supported gamepads.

Protected Static Functions

bool
setProtectedNumFences(void * object, const char * index, const char * data)

Public Functions

DECLARE_CATEGORY("Gui Core" )

used by the tooltip resource

bool

Called when this object is added to the scene.

Called when this object is removed.

setRenderFront(bool front)

This turns on/off front-buffer rendering.

setWindowTitle(const char * newTitle)

Detailed Description

Rendering methods

renderFrame(bool preRenderOnly, bool bufferSwap)

Repaints the dirty regions of the canvas.

Parameters:

preRenderOnly

If set to true, only the onPreRender methods of all the GuiControls will be called

bufferSwap

If set to true, it will swap buffers at the end. This is to support canvas-subclassing.

Reimplemented by: GuiOffscreenCanvas

paint()

Repaints the canvas by calling the platform window display event.

repaint(U32 elapsedMS)

Repaints the canvas skipping rendering if the target time has not yet elapsed.

Parameters:

elapsedMS

The time since the last frame.

addUpdateRegion(Point2I pos, Point2I ext)

Adds a dirty area to the canvas so it will be updated on the next frame.

Parameters:

pos

Screen-coordinates of the upper-left hand corner of the dirty area

ext

Width/height of the dirty area

resetUpdateRegions()

Resets the update regions so that the next call to renderFrame will repaint the whole canvas.

maintainSizing()

Resizes the content control to match the canvas size.

buildUpdateUnion(RectI * updateUnion)

This builds a rectangle which encompasses all of the dirty regions to be repainted.

Parameters:

updateUnion

(out) Rectangle which surrounds all dirty areas

swapBuffers()

This will swap the buffers at the end of renderFrame.

It was added for canvas sub-classes in case they wanted to do some custom code before the buffer flip occured.

getGuiCanvasFrameSignal()

typedef Signal< void(bool beginFrame)> GuiCanvasFrameSignal 

This signal is triggered at the beginning and end of each render frame.

Parameters:

beginFrame

true at the beginning of the frame, false at the end

Rendering

RectI mOldUpdateRects [2]
RectI mCurUpdateRect 
U32 mLastRenderMs 

Cursor Properties

bool mCursorEnabled 
bool mShowCursor 
bool mRenderFront 
Point2F mCursorPt 

Current cursor position in local coordinates.

Point2I mLastCursorPt 
GuiCursor * mDefaultCursor 
GuiCursor * mLastCursor 
bool mLastCursorEnabled 
bool mForceMouseToGUI 
bool mClampTorqueCursor 
bool mAlwaysHandleMouseButtons 
bool mDisplayWindow 

Mouse Input

processKeyboardEvent(InputEventInfo & inputEvent)

Processes keyboard input events.

Helper method for processInputEvent

Parameters:

inputEvent

Information on the input even to be processed.

return:

True if the event was handled or false if it was not.

processMouseEvent(InputEventInfo & inputEvent)

Processes mouse input events.

Helper method for processInputEvent

Parameters:

inputEvent

Information on the input even to be processed.

return:

True if the event was handled or false if it was not.

processGamepadEvent(InputEventInfo & inputEvent)

Processes gamepad input events.

Helper method for processInputEvent

Parameters:

inputEvent

Information on the input even to be processed.

return:

True if the event was handled or false if it was not.

findMouseControl(const GuiEvent & event)

refreshMouseControl()

SimObjectPtr< GuiControl > mMouseCapturedControl 

All mouse events will go to this ctrl only.

SimObjectPtr< GuiControl > mMouseControl 

the control the mouse was last seen in unless some other one captured it

bool mMouseControlClicked 

whether the current ctrl has been clicked - used by helpctrl

U32 mPrevMouseTime 

this determines how long the mouse has been in the same control

bool mMouseButtonDown 

Flag to determine if the button is depressed.

bool mMouseRightButtonDown 

bool to determine if the right button is depressed

bool mMouseMiddleButtonDown 

Middle button flag.

GuiEvent mLastEvent 
U8 mLastMouseClickCount 
S32 mLastMouseDownTime 
bool mLeftMouseLast 
bool mMiddleMouseLast 
bool mRightMouseLast 
Point2F mMouseDownPoint 

Keyboard Input

Vector< AccKeyMap > mAcceleratorMap 
U32 mHoverControlStart 
GuiControl * mHoverControl 
Point2I mHoverPosition 
bool mHoverPositionSet 
U32 mHoverLeftControlTime 

Cursor commands

A cursor can be on, but not be shown.

If a cursor is not on, than it does not process input.

setCursor(GuiCursor * cursor)

Sets the cursor for the canvas.

Parameters:

cursor

New cursor to use.

isCursorON()

Returns true if the cursor is on.

setForceMouseToGUI(bool onOff)

Sets if mouse events should be passed to the GUI even if the cursor is off.

Parameters:

onOff

True if events should be passed to the GUI if the cursor is off

setClampTorqueCursor(bool onOff)

Sets if the Torque cursor should be clamped to the window.

Parameters:

onOff

True if the Torque cursor should be clamped against the window

getClampTorqueCursor()

Returns if the Torque cursor is clamped to the window.

setCursorON(bool onOff)

Turns the cursor on or off.

Parameters:

onOff

True if the cursor should be on.

setCursorPos(const Point2I & pt)

Sets the position of the cursor.

Parameters:

pt

Point, in screenspace for the cursor

Reimplemented by: GuiOffscreenCanvas

getCursorPos()

Returns the point, in screenspace, at which the cursor is located.

Reimplemented by: GuiOffscreenCanvas

getCursorPosLocal()

Returns the point, in local coordinates, at which the cursor is located.

showCursor(bool state)

Enable/disable rendering of the cursor.

Parameters:

state

True if we should render cursor

Reimplemented by: GuiOffscreenCanvas

isCursorShown()

Returns true if the cursor is being rendered.

Reimplemented by: GuiOffscreenCanvas

cursorClick(S32 buttonId, bool isDown)

cursorNudge(F32 x, F32 y)

S32 mCursorChanged 

Canvas Content Management

getPlatformWindow()

This returns the PlatformWindow owned by this Canvas.

setContentControl(GuiControl * gui)

This sets the content control to something different.

Parameters:

gui

New content control

getContentControl()

Returns the content control.

pushDialogControl(GuiControl * gui, S32 layer, bool center)

Adds a dialog control onto the stack of dialogs.

Parameters:

gui

Dialog to add

layer

Layer to put dialog on

center

Center dialog on canvas.

popDialogControl(S32 layer)

Removes a specific layer of dialogs.

Parameters:

layer

Layer to pop off from

popDialogControl(GuiControl * gui)

Removes a specific dialog control.

Parameters:

gui

Dialog to remove from the dialog stack

Input Processing

processInputEvent(InputEventInfo & inputEvent)

Reimplemented from: IProcessInput

Mouse Methods

mouseLock(GuiControl * lockingControl)

When a control gets the mouse lock this means that that control gets ALL mouse input and no other control receives any input.

Parameters:

lockingControl

Control to lock mouse to

mouseUnlock(GuiControl * lockingControl)

Unlocks the mouse from a control.

Parameters:

lockingControl

Control to unlock from

getMouseControl()

Returns the control which the mouse is over.

getMouseLockedControl()

Returns the control which the mouse is locked to if any.

mouseButtonDown(void )

Returns true if the left mouse button is down.

mouseRightButtonDown(void )

Returns true if the right mouse button is down.

Mouse input methods

These events process the events before passing them down to the controls they effect.

This allows for things such as the input locking and such.

Each of these methods corresponds to the action in it's method name and processes the GuiEvent passed as a parameter

rootMouseUp(const GuiEvent & event)

rootMouseDown(const GuiEvent & event)

rootMouseMove(const GuiEvent & event)

rootMouseDragged(const GuiEvent & event)

rootRightMouseDown(const GuiEvent & event)

rootRightMouseUp(const GuiEvent & event)

rootRightMouseDragged(const GuiEvent & event)

rootMiddleMouseDown(const GuiEvent & event)

rootMiddleMouseUp(const GuiEvent & event)

rootMiddleMouseDragged(const GuiEvent & event)

rootMouseWheelUp(const GuiEvent & event)

rootMouseWheelDown(const GuiEvent & event)

Keyboard input methods

First responders

A first responder is a the GuiControl which responds first to input events before passing them off for further processing.

tabNext(void )

Moves the first responder to the next tabable controle.

tabPrev(void )

Moves the first responder to the previous tabable control.

addAcceleratorKey(GuiControl * ctrl, U32 index, U32 keyCode, U32 modifier)

Setups a keyboard accelerator which maps to a GuiControl.

Parameters:

ctrl

GuiControl to map to.

index

keyCode

Key code.

modifier

Shift, ctrl, etc.

setFirstResponder(GuiControl * firstResponder)

Reimplemented from: GuiControl

setNativeAcceleratorsEnabled(bool enabled)

This is used to toggle processing of native OS accelerators, not to be confused with the Torque accelerator key system, to keep them from swallowing up keystrokes.

Both GuiTextEditCtrl and GuiTextPadCtrl use this method.

Reimplemented by: OpenVROverlay

Protected Types

typedef GuiControl Parent 

Protected Attributes

bool mConsumeLastInputEvent 
GFXFence ** mFences 
GuiControl * mMenuBackground 
GuiControl * mMenuBarCtrl 
S32 mNextFenceIdx 
S32 mNumFences 
PlatformWindow * mPlatformWindow 

Protected Static Attributes

CanvasSizeChangeSignal smCanvasSizeChangeSignal 

Private Static Attributes

const U32 MAX_GAMEPADS 

The maximum number of supported gamepads.

Protected Functions

checkLockMouseMove(const GuiEvent & event)

handleAppEvent(WindowId did, S32 event)

handlePaintEvent(WindowId did)

handleResize(WindowId did, S32 width, S32 height)

setupFences()

Protected Static Functions

setProtectedNumFences(void * object, const char * index, const char * data)

Public Functions

GuiCanvas()

~GuiCanvas()

clearMouseButtonDown(void )

clearMouseRightButtonDown(void )

DECLARE_CATEGORY("Gui Core" )

DECLARE_CONOBJECT(GuiCanvas )

disableKeyboardTranslation()

Reimplemented by: OpenVROverlay

enableKeyboardTranslation()

Reimplemented by: OpenVROverlay

getCursorExtent()

used by the tooltip resource

getLastCursorPoint(Point2I & pt)

getMenuBar()

getWindowSize()

Reimplemented by: GuiOffscreenCanvas

onAdd()

Reimplemented from: GuiControl

Reimplemented by: GuiOffscreenCanvas, OpenVROverlay, VEditorWindow

onRemove()

Reimplemented from: GuiControl

Reimplemented by: GuiOffscreenCanvas, OpenVROverlay

setConsumeLastInputEvent(bool flag)

setMenuBar(SimObject * obj)

setRenderFront(bool front)

This turns on/off front-buffer rendering.

Parameters:

front

True if all rendering should be done to the front buffer

setWindowTitle(const char * newTitle)

Public Static Functions

getCanvasSizeChangeSignal()

initPersistFields()