guiCanvas.cpp
Engine/source/gui/core/guiCanvas.cpp
Public Variables
_popDialog1 ("@brief Removes a specific dialog control\n\n" "@param ctrl Dialog to pop\n" "@tsexample\n" "Canvas.popDialog(RecordingsDlg);\n" "@endtsexample\n\n", "GuiCanvas", "void popDialog( GuiControl ctrl);")
_popDialog2 ("@brief Removes a dialog at the front most layer\n\n" "@tsexample\n" "// Pops whatever is on layer 0\n" "Canvas.popDialog();\n" "@endtsexample\n\n", "GuiCanvas", "void popDialog();")
_popLayer1 ("@brief Removes the top most layer of dialogs\n\n" "@tsexample\n" "Canvas.popLayer();\n" "@endtsexample\n\n", "GuiCanvas", "void popLayer();")
_popLayer2 ("@brief Removes a specified layer of dialogs\n\n" "@param layer Number of the layer to pop\n\n" "@tsexample\n" "Canvas.popLayer(1);\n" "@endtsexample\n\n", "GuiCanvas", "void popLayer(S32 layer);")
_pushDialog ("@brief Adds a dialog control onto the stack of dialogs\n\n" "@param ctrl Dialog to add\n" "@param layer Layer to put dialog on (optional)\n" "@param center True to center dialog on canvas (optional)\n\n" "@tsexample\n" "Canvas.pushDialog(RecordingsDlg);\n" "@endtsexample\n\n", "GuiCanvas", "void pushDialog( GuiControl ctrl, int layer=0, bool center=false);")
bool
gCanvasClearColor (255, 0, 255)
For GFX->clear.
Public Functions
_setCursorPos1("@brief Sets the position of the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">cursor\n\n</a>" "@param pos Point, in screenspace <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the cursor. Formatted as(\"x y\")\n\n" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "Canvas.setCursorPos(\"0 0\");\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" , "GuiCanvas" , "bool setCursorPos( <a href="/coding/class/classpoint2i/">Point2I</a> pos );" )
_setCursorPos2("@brief Sets the position of the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">cursor\n\n</a>" "@param posX X- coordinate, in screenspace <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">cursor.\n</a>" " @param posY Y- coordinate, in screenspace <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">cursor.\n\n</a>" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "Canvas.setCursorPos(0, 0);\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" , "GuiCanvas" , "bool setCursorPos( <a href="/coding/file/types_8h/#types_8h_1a841d3674577a1e86afdc2f4845f46c4b">F32</a> posX, <a href="/coding/file/types_8h/#types_8h_1a841d3674577a1e86afdc2f4845f46c4b">F32</a> posY);" )
ConsoleDocClass(GuiCanvas , "@brief A canvas on which rendering <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">occurs.\n\n</a>" "@section GuiCanvas_contents What <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> GUICanvas Can <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Contain...\n\n</a>" "@subsection GuiCanvas_content_contentcontrol Content <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Control\n</a>" "A content <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> is the top level <a href="/coding/class/classguicontrol/">GuiControl</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> screen. This <a href="/coding/class/classguicontrol/">GuiControl</a> " "will be the parent <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> all other GuiControls on that particular " "<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">screen.\n\n</a>" "@subsection GuiCanvas_content_dialogs <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Dialogs\n\n</a>" "A dialog is essentially another screen, only it gets overlaid on top of the " "current content control, and all input goes <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the dialog. This is most akin " "<a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the \"Open File\" dialog box found in most operating systems. When you " "choose <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> open <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> file, and the \"Open File\" dialog pops up, you can no longer " "send input <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the application, and must complete or cancel the open <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a702945180aa732857b380a007a7e2a21">file</a> " "request. Torque keeps track of layers of dialogs. The dialog with the highest " "layer is on top and will get all the input, unless the dialog is " " modeless, which is <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> profile <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">option.\n\n</a>" " @see <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">GuiControlProfile\n\n</a>" " @section GuiCanvas_dirty Dirty <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Rectangles\n\n</a>" "The <a href="/coding/class/classguicanvas/">GuiCanvas</a> is based on dirty regions. " "Every frame the canvas paints only the areas of the canvas that are 'dirty' " "or need updating. In most cases, this only is the area under the mouse cursor. " "This is why <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> you look in guiCanvas.cc the call <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> glClear is commented out. " "What you will see is <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> black screen, except in the dirty regions, where the " "screen will be painted normally. If you are making an animated <a href="/coding/class/classguicontrol/">GuiControl</a> " "you need <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> add your <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the dirty areas of the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">canvas.\n\n</a>" " @see <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">GuiControl\n\n</a>" " @ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">GuiCore\n</a>" )
DefineEngineFunction(excludeOtherInstance , bool , (const char *appIdentifer) , "@brief Used <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> exclude/prevent all other instances using the same identifier <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">specified\n\n</a>" "@note Not used on OSX, Xbox , or in Win debug <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">builds\n\n</a>" " @param appIdentifier Name of the app set up <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> exclusive <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">use.\n</a>" " @return False <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> another app is running that specified the same <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">appIdentifier\n\n</a>" " @ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Platform\n</a>" " @ingroup GuiCore" )
DefineEngineMethod(GuiCanvas , clientToScreen , Point2I , (Point2I coordinate) , "Translate <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> coordinate from canvas window-space <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> screen-<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">space.\n</a>" "@param coordinate The coordinate in window-<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">space.\n</a>" "@return The given coordinate translated <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> screen-space." )
DefineEngineMethod(GuiCanvas , cursorClick , void , (S32 buttonId, bool isDown) , "" )
DefineEngineMethod(GuiCanvas , cursorNudge , void , (F32 x, F32 y) , "" )
DefineEngineMethod(GuiCanvas , cursorOff , void , () , "@brief Turns on the mouse <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">off.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "Canvas.cursorOff();\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" )
DefineEngineMethod(GuiCanvas , cursorOn , void , () , "@brief Turns on the mouse <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">cursor.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "Canvas.cursorOn();\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" )
DefineEngineMethod(GuiCanvas , findFirstMatchingMonitor , S32 , (const char *name) , "@brief Find the first monitor index that matches the given <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">name.\n\n</a>" "The actual match algorithm depends on the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">implementation.\n</a>" "@param name The name <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> search <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">for.\n\n</a>" "@return The number of monitors attached <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the system, including the default monoitor." )
DefineEngineMethod(GuiCanvas , getContent , S32 , () , "@brief Get the <a href="/coding/class/classguicontrol/">GuiControl</a> which is being used as the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">content.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "Canvas.getContent();\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" "@return ID of current content <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a>" )
DefineEngineMethod(GuiCanvas , getCursorPos , Point2I , () , "@brief Get the current position of the <a href="/coding/file/sdlcursorcontroller_8cpp/#sdlcursorcontroller_8cpp_1a06e8dd1f849973ccc456f8553601e8b9">cursor</a> in screen-space. Note that this position" " might be outside the Torque window. If you want <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> get the position within the Canvas, " " call screenToClient on the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">result.\n\n</a>" " @see Canvas::screenToClient()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" " @param param <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Description\n\n</a>" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "% cursorPos, in format \"X Y\"" )
DefineEngineMethod(GuiCanvas , getExtent , Point2I , () , "@brief Returns the dimensions of the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">canvas\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "% extent)
DefineEngineMethod(GuiCanvas , getMode , const char * , (S32 modeId) , "@brief Gets information on the specified <a href="/coding/file/zipobject_8cpp/#zipobject_8cpp_1ac6c3dfb4c3a68f849f32cbfb21da4e77">mode</a> of this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n\n</a>" "@param modeId Index of the <a href="/coding/file/zipobject_8cpp/#zipobject_8cpp_1ac6c3dfb4c3a68f849f32cbfb21da4e77">mode</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> get data <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">from.\n</a>" "@return A video <a href="/coding/file/zipobject_8cpp/#zipobject_8cpp_1ac6c3dfb4c3a68f849f32cbfb21da4e77">mode</a> string given an adapter and <a href="/coding/file/zipobject_8cpp/#zipobject_8cpp_1ac6c3dfb4c3a68f849f32cbfb21da4e77">mode</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">index.\n\n</a>" "@see GuiCanvas::getVideoMode()" )
DefineEngineMethod(GuiCanvas , getModeCount , S32 , () )
DefineEngineMethod(GuiCanvas , getMonitorCount , S32 , () , "@brief Gets the number of monitors attached <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">system.\n\n</a>" "@return The number of monitors attached <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the system, including the default monoitor." )
DefineEngineMethod(GuiCanvas , getMonitorDesktopMode , const char * , (S32 monitorIndex) , (0) , "Gets the current desktop <a href="/coding/file/zipobject_8cpp/#zipobject_8cpp_1ac6c3dfb4c3a68f849f32cbfb21da4e77">mode</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the selected <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">monitor.\n\n</a>" )
DefineEngineMethod(GuiCanvas , getMonitorMode , const char * , (S32 monitorIndex, S32 modeIndex) , (0) , "Gets <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> video <a href="/coding/file/zipobject_8cpp/#zipobject_8cpp_1ac6c3dfb4c3a68f849f32cbfb21da4e77">mode</a> string from the selected <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">monitor.\n\n</a>" )
DefineEngineMethod(GuiCanvas , getMonitorModeCount , S32 , (S32 monitorIndex) , (0) , "Gets the number of video modes available on the selected <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">monitor.\n\n</a>" )
DefineEngineMethod(GuiCanvas , getMonitorName , const char * , (S32 index) , "@brief Gets the name of the requested <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">monitor.\n\n</a>" "@param index The monitor <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">index.\n\n</a>" "@return The name of the requested monitor." )
DefineEngineMethod(GuiCanvas , getMonitorRect , RectI , (S32 index) , "@brief Gets the region of the requested <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">monitor.\n\n</a>" "@param index The monitor <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">index.\n\n</a>" "@return The rectangular region of the requested monitor." )
DefineEngineMethod(GuiCanvas , getMonitorUsableRect , RectI , (S32 index) , "@brief Use this function <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> get the usable desktop area represented by <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> display, with the primary display located at 0, 0.\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "This is the same area as Canvas.getMonitorRect() reports, but with portions reserved by the system removed. " "For example, on Apple Mac OS X, this subtracts the area occupied by the menu bar and <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">dock.\n</a>" "Setting <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> window <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> be fullscreen generally bypasses these unusable areas, so these are good guidelines <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> " "the maximum space available <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> non - fullscreen window." " @param index The monitor <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">index.\n\n</a>" " @return The rectangular region of the requested monitor." )
DefineEngineMethod(GuiCanvas , getMouseControl , S32 , () , "@brief Gets the gui <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> under the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">mouse.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "% underMouse, <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> one was found. <a href="/coding/file/typesx86unix_8h/#typesx86unix_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a> otherwise" )
DefineEngineMethod(GuiCanvas , getVideoMode , const char * , () , "@brief Gets the current screen <a href="/coding/file/zipobject_8cpp/#zipobject_8cpp_1ac6c3dfb4c3a68f849f32cbfb21da4e77">mode</a> as <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">string.\n\n</a>" "The return string will contain 5 values (width, height, fullscreen, bitdepth, refreshRate). " "You will need <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> parse out each one <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> individual <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">use.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "% screenWidth, screen height, screen mode, bit depth, and refresh rate." )
DefineEngineMethod(GuiCanvas , getWindowPosition , Point2I , () , "Get the current position of the platform window associated with the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">canvas.\n</a>" "@return The window position of the canvas in screen-space." )
DefineEngineMethod(GuiCanvas , hideCursor , void , () , "@brief Disable rendering of the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">cursor.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "Canvas.hideCursor();\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" )
DefineEngineMethod(GuiCanvas , hideWindow , void , () , "" )
DefineEngineMethod(GuiCanvas , isCursorOn , bool , () , "@brief Determines <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> mouse <a href="/coding/file/sdlcursorcontroller_8cpp/#sdlcursorcontroller_8cpp_1a06e8dd1f849973ccc456f8553601e8b9">cursor</a> is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">enabled.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "// Is <a href="/coding/file/sdlcursorcontroller_8cpp/#sdlcursorcontroller_8cpp_1a06e8dd1f849973ccc456f8553601e8b9">cursor</a> on?\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "<a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a>(Canvas.isCursorOn())\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " <a href="/coding/file/ggendoflinefix_8txt/#ggendoflinefix_8txt_1a7f8fee038817022b75b8865e5da4eba3">echo</a>(\"Canvas <a href="/coding/file/sdlcursorcontroller_8cpp/#sdlcursorcontroller_8cpp_1a06e8dd1f849973ccc456f8553601e8b9">cursor</a> is on\");\n" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" "@return Returns true <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> the <a href="/coding/file/sdlcursorcontroller_8cpp/#sdlcursorcontroller_8cpp_1a06e8dd1f849973ccc456f8553601e8b9">cursor</a> is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">on.\n\n</a>" )
DefineEngineMethod(GuiCanvas , isCursorShown , bool , () , "@brief Determines <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> mouse <a href="/coding/file/sdlcursorcontroller_8cpp/#sdlcursorcontroller_8cpp_1a06e8dd1f849973ccc456f8553601e8b9">cursor</a> is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">rendering.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "// Is <a href="/coding/file/sdlcursorcontroller_8cpp/#sdlcursorcontroller_8cpp_1a06e8dd1f849973ccc456f8553601e8b9">cursor</a> rendering?\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "<a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a>(Canvas.isCursorShown())\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " <a href="/coding/file/ggendoflinefix_8txt/#ggendoflinefix_8txt_1a7f8fee038817022b75b8865e5da4eba3">echo</a>(\"Canvas <a href="/coding/file/sdlcursorcontroller_8cpp/#sdlcursorcontroller_8cpp_1a06e8dd1f849973ccc456f8553601e8b9">cursor</a> is rendering\");\n" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" "@return Returns true <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> the <a href="/coding/file/sdlcursorcontroller_8cpp/#sdlcursorcontroller_8cpp_1a06e8dd1f849973ccc456f8553601e8b9">cursor</a> is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">rendering.\n\n</a>" )
DefineEngineMethod(GuiCanvas , isFullscreen , bool , () , "() - Is this canvas currently fullscreen?" )
DefineEngineMethod(GuiCanvas , isMaximized , bool , () , "()" )
DefineEngineMethod(GuiCanvas , isMinimized , bool , () , "()" )
DefineEngineMethod(GuiCanvas , maximizeWindow , void , () , "() - maximize this canvas' window." )
DefineEngineMethod(GuiCanvas , minimizeWindow , void , () , "() - minimize this canvas' window." )
DefineEngineMethod(GuiCanvas , popDialog , void , (GuiControl *gui) , (nullAsType< GuiControl * >()) , "(GuiControl ctrl=<a href="/coding/file/typesx86unix_8h/#typesx86unix_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)" "@hide" )
DefineEngineMethod(GuiCanvas , popLayer , void , (S32 layer) , (0) , "(int layer)" "@hide" )
DefineEngineMethod(GuiCanvas , pushDialog , void , (const char *ctrlName, S32 layer, bool center) , (0, false) , "(GuiControl ctrl, int layer=0, bool center=false)" "@hide" )
DefineEngineMethod(GuiCanvas , renderFront , void , (bool enable) , "@brief This turns on/off front-buffer <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">rendering.\n\n</a>" "@param enable True <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> all rendering should be done <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the front <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">buffer\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "Canvas.renderFront(false);\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" )
DefineEngineMethod(GuiCanvas , repaint , void , (S32 elapsedMS) , (0) , "@brief Force canvas <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">redraw.\n</a>" "If the elapsed time is greater than the time since the last paint " "then the repaint will be <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">skipped.\n</a>" "@param elapsedMS The optional elapsed time in <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">milliseconds.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "Canvas.repaint();\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" )
DefineEngineMethod(GuiCanvas , reset , void , () , "@brief Reset the update regions <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">canvas.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "Canvas.reset();\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" )
DefineEngineMethod(GuiCanvas , resetVideoMode , void , () , "" )
DefineEngineMethod(GuiCanvas , restoreWindow , void , () , "() - restore this canvas' window." )
DefineEngineMethod(GuiCanvas , screenToClient , Point2I , (Point2I coordinate) , "Translate <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> coordinate from screen-space <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> canvas window-<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">space.\n</a>" "@param coordinate The coordinate in screen-<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">space.\n</a>" "@return The given coordinate translated <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> window-space." )
DefineEngineMethod(GuiCanvas , setContent , void , (GuiControl *ctrl) , "@brief Set the content of the canvas <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> specified <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">control.\n\n</a>" "@param ctrl ID or name of <a href="/coding/class/classguicontrol/">GuiControl</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> set content <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">to\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "Canvas.setContent(PlayGui);\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" )
DefineEngineMethod(GuiCanvas , setCursor , void , (GuiCursor *cursor) , "@brief Sets the <a href="/coding/file/sdlcursorcontroller_8cpp/#sdlcursorcontroller_8cpp_1a06e8dd1f849973ccc456f8553601e8b9">cursor</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">canvas.\n\n</a>" "@param <a href="/coding/file/sdlcursorcontroller_8cpp/#sdlcursorcontroller_8cpp_1a06e8dd1f849973ccc456f8553601e8b9">cursor</a> Name of the <a href="/coding/class/classguicursor/">GuiCursor</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">use\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "Canvas.setCursor(\"DefaultCursor\");\n" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" )
DefineEngineMethod(GuiCanvas , setCursorPos , void , (Point2I pos) , "(Point2I pos)" "@hide" )
DefineEngineMethod(GuiCanvas , setFocus , void , () , "() - Claim OS input focus <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this canvas' window." )
DefineEngineMethod(GuiCanvas , setMenuBar , void , (GuiControl *menu) , "Translate <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> coordinate from canvas window-space <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> screen-<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">space.\n</a>" "@param coordinate The coordinate in window-<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">space.\n</a>" "@return The given coordinate translated <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> screen-space." )
DefineEngineMethod(GuiCanvas , setWindowPosition , void , (Point2I position) , "Set the position of the platform window associated with the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">canvas.\n</a>" "@param position The <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> position of the window in screen-space." )
DefineEngineMethod(GuiCanvas , setWindowTitle , void , (const char *newTitle) , "@brief Change the title of the OS <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">window.\n\n</a>" "@param newTitle <a href="/coding/class/classstring/">String</a> containing the <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">name\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "Canvas.setWindowTitle(\"Documentation Rocks!\");\n" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" )
DefineEngineMethod(GuiCanvas , showCursor , void , () , "@brief Enable rendering of the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">cursor.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "Canvas.showCursor();\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" )
DefineEngineMethod(GuiCanvas , showWindow , void , () , "" )
DefineEngineMethod(GuiCanvas , toggleFullscreen , void , () , "@brief toggle canvas from fullscreen <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> windowed <a href="/coding/file/zipobject_8cpp/#zipobject_8cpp_1ac6c3dfb4c3a68f849f32cbfb21da4e77">mode</a> or <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">back.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "// If we are in windowed mode, the following will put is in <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">fullscreen\n</a>" "Canvas.toggleFullscreen();" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" )
Detailed Description
Public Variables
ConsoleDocFragment _popDialog1 ("@brief Removes a specific dialog control\n\n" "@param ctrl Dialog to pop\n" "@tsexample\n" "Canvas.popDialog(RecordingsDlg);\n" "@endtsexample\n\n", "GuiCanvas", "void popDialog( GuiControl ctrl);")
ConsoleDocFragment _popDialog2 ("@brief Removes a dialog at the front most layer\n\n" "@tsexample\n" "// Pops whatever is on layer 0\n" "Canvas.popDialog();\n" "@endtsexample\n\n", "GuiCanvas", "void popDialog();")
ConsoleDocFragment _popLayer1 ("@brief Removes the top most layer of dialogs\n\n" "@tsexample\n" "Canvas.popLayer();\n" "@endtsexample\n\n", "GuiCanvas", "void popLayer();")
ConsoleDocFragment _popLayer2 ("@brief Removes a specified layer of dialogs\n\n" "@param layer Number of the layer to pop\n\n" "@tsexample\n" "Canvas.popLayer(1);\n" "@endtsexample\n\n", "GuiCanvas", "void popLayer(S32 layer);")
ConsoleDocFragment _pushDialog ("@brief Adds a dialog control onto the stack of dialogs\n\n" "@param ctrl Dialog to add\n" "@param layer Layer to put dialog on (optional)\n" "@param center True to center dialog on canvas (optional)\n\n" "@tsexample\n" "Canvas.pushDialog(RecordingsDlg);\n" "@endtsexample\n\n", "GuiCanvas", "void pushDialog( GuiControl ctrl, int layer=0, bool center=false);")
bool AFX_forceVideoReset
ColorI gCanvasClearColor (255, 0, 255)
For GFX->clear.
Public Functions
_setCursorPos1("@brief Sets the position of the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">cursor\n\n</a>" "@param pos Point, in screenspace <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the cursor. Formatted as(\"x y\")\n\n" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "Canvas.setCursorPos(\"0 0\");\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" , "GuiCanvas" , "bool setCursorPos( <a href="/coding/class/classpoint2i/">Point2I</a> pos );" )
_setCursorPos2("@brief Sets the position of the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">cursor\n\n</a>" "@param posX X- coordinate, in screenspace <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">cursor.\n</a>" " @param posY Y- coordinate, in screenspace <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">cursor.\n\n</a>" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "Canvas.setCursorPos(0, 0);\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" , "GuiCanvas" , "bool setCursorPos( <a href="/coding/file/types_8h/#types_8h_1a841d3674577a1e86afdc2f4845f46c4b">F32</a> posX, <a href="/coding/file/types_8h/#types_8h_1a841d3674577a1e86afdc2f4845f46c4b">F32</a> posY);" )
ConsoleDocClass(GuiCanvas , "@brief A canvas on which rendering <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">occurs.\n\n</a>" "@section GuiCanvas_contents What <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> GUICanvas Can <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Contain...\n\n</a>" "@subsection GuiCanvas_content_contentcontrol Content <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Control\n</a>" "A content <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> is the top level <a href="/coding/class/classguicontrol/">GuiControl</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> screen. This <a href="/coding/class/classguicontrol/">GuiControl</a> " "will be the parent <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> all other GuiControls on that particular " "<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">screen.\n\n</a>" "@subsection GuiCanvas_content_dialogs <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Dialogs\n\n</a>" "A dialog is essentially another screen, only it gets overlaid on top of the " "current content control, and all input goes <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the dialog. This is most akin " "<a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the \"Open File\" dialog box found in most operating systems. When you " "choose <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> open <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> file, and the \"Open File\" dialog pops up, you can no longer " "send input <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the application, and must complete or cancel the open <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a702945180aa732857b380a007a7e2a21">file</a> " "request. Torque keeps track of layers of dialogs. The dialog with the highest " "layer is on top and will get all the input, unless the dialog is " " modeless, which is <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> profile <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">option.\n\n</a>" " @see <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">GuiControlProfile\n\n</a>" " @section GuiCanvas_dirty Dirty <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Rectangles\n\n</a>" "The <a href="/coding/class/classguicanvas/">GuiCanvas</a> is based on dirty regions. " "Every frame the canvas paints only the areas of the canvas that are 'dirty' " "or need updating. In most cases, this only is the area under the mouse cursor. " "This is why <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> you look in guiCanvas.cc the call <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> glClear is commented out. " "What you will see is <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> black screen, except in the dirty regions, where the " "screen will be painted normally. If you are making an animated <a href="/coding/class/classguicontrol/">GuiControl</a> " "you need <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> add your <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the dirty areas of the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">canvas.\n\n</a>" " @see <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">GuiControl\n\n</a>" " @ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">GuiCore\n</a>" )
convertModifierBits(const U32 in)
DefineEngineFunction(excludeOtherInstance , bool , (const char *appIdentifer) , "@brief Used <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> exclude/prevent all other instances using the same identifier <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">specified\n\n</a>" "@note Not used on OSX, Xbox , or in Win debug <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">builds\n\n</a>" " @param appIdentifier Name of the app set up <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> exclusive <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">use.\n</a>" " @return False <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> another app is running that specified the same <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">appIdentifier\n\n</a>" " @ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Platform\n</a>" " @ingroup GuiCore" )
DefineEngineMethod(GuiCanvas , clientToScreen , Point2I , (Point2I coordinate) , "Translate <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> coordinate from canvas window-space <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> screen-<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">space.\n</a>" "@param coordinate The coordinate in window-<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">space.\n</a>" "@return The given coordinate translated <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> screen-space." )
DefineEngineMethod(GuiCanvas , cursorClick , void , (S32 buttonId, bool isDown) , "" )
DefineEngineMethod(GuiCanvas , cursorNudge , void , (F32 x, F32 y) , "" )
DefineEngineMethod(GuiCanvas , cursorOff , void , () , "@brief Turns on the mouse <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">off.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "Canvas.cursorOff();\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" )
DefineEngineMethod(GuiCanvas , cursorOn , void , () , "@brief Turns on the mouse <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">cursor.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "Canvas.cursorOn();\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" )
DefineEngineMethod(GuiCanvas , findFirstMatchingMonitor , S32 , (const char *name) , "@brief Find the first monitor index that matches the given <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">name.\n\n</a>" "The actual match algorithm depends on the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">implementation.\n</a>" "@param name The name <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> search <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">for.\n\n</a>" "@return The number of monitors attached <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the system, including the default monoitor." )
DefineEngineMethod(GuiCanvas , getContent , S32 , () , "@brief Get the <a href="/coding/class/classguicontrol/">GuiControl</a> which is being used as the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">content.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "Canvas.getContent();\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" "@return ID of current content <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a>" )
DefineEngineMethod(GuiCanvas , getCursorPos , Point2I , () , "@brief Get the current position of the <a href="/coding/file/sdlcursorcontroller_8cpp/#sdlcursorcontroller_8cpp_1a06e8dd1f849973ccc456f8553601e8b9">cursor</a> in screen-space. Note that this position" " might be outside the Torque window. If you want <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> get the position within the Canvas, " " call screenToClient on the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">result.\n\n</a>" " @see Canvas::screenToClient()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" " @param param <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Description\n\n</a>" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "% cursorPos, in format \"X Y\"" )
DefineEngineMethod(GuiCanvas , getExtent , Point2I , () , "@brief Returns the dimensions of the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">canvas\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "% extent)
DefineEngineMethod(GuiCanvas , getMode , const char * , (S32 modeId) , "@brief Gets information on the specified <a href="/coding/file/zipobject_8cpp/#zipobject_8cpp_1ac6c3dfb4c3a68f849f32cbfb21da4e77">mode</a> of this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">device.\n\n</a>" "@param modeId Index of the <a href="/coding/file/zipobject_8cpp/#zipobject_8cpp_1ac6c3dfb4c3a68f849f32cbfb21da4e77">mode</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> get data <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">from.\n</a>" "@return A video <a href="/coding/file/zipobject_8cpp/#zipobject_8cpp_1ac6c3dfb4c3a68f849f32cbfb21da4e77">mode</a> string given an adapter and <a href="/coding/file/zipobject_8cpp/#zipobject_8cpp_1ac6c3dfb4c3a68f849f32cbfb21da4e77">mode</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">index.\n\n</a>" "@see GuiCanvas::getVideoMode()" )
DefineEngineMethod(GuiCanvas , getModeCount , S32 , () )
DefineEngineMethod(GuiCanvas , getMonitorCount , S32 , () , "@brief Gets the number of monitors attached <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">system.\n\n</a>" "@return The number of monitors attached <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the system, including the default monoitor." )
DefineEngineMethod(GuiCanvas , getMonitorDesktopMode , const char * , (S32 monitorIndex) , (0) , "Gets the current desktop <a href="/coding/file/zipobject_8cpp/#zipobject_8cpp_1ac6c3dfb4c3a68f849f32cbfb21da4e77">mode</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the selected <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">monitor.\n\n</a>" )
DefineEngineMethod(GuiCanvas , getMonitorMode , const char * , (S32 monitorIndex, S32 modeIndex) , (0) , "Gets <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> video <a href="/coding/file/zipobject_8cpp/#zipobject_8cpp_1ac6c3dfb4c3a68f849f32cbfb21da4e77">mode</a> string from the selected <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">monitor.\n\n</a>" )
DefineEngineMethod(GuiCanvas , getMonitorModeCount , S32 , (S32 monitorIndex) , (0) , "Gets the number of video modes available on the selected <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">monitor.\n\n</a>" )
DefineEngineMethod(GuiCanvas , getMonitorName , const char * , (S32 index) , "@brief Gets the name of the requested <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">monitor.\n\n</a>" "@param index The monitor <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">index.\n\n</a>" "@return The name of the requested monitor." )
DefineEngineMethod(GuiCanvas , getMonitorRect , RectI , (S32 index) , "@brief Gets the region of the requested <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">monitor.\n\n</a>" "@param index The monitor <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">index.\n\n</a>" "@return The rectangular region of the requested monitor." )
DefineEngineMethod(GuiCanvas , getMonitorUsableRect , RectI , (S32 index) , "@brief Use this function <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> get the usable desktop area represented by <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> display, with the primary display located at 0, 0.\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "This is the same area as Canvas.getMonitorRect() reports, but with portions reserved by the system removed. " "For example, on Apple Mac OS X, this subtracts the area occupied by the menu bar and <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">dock.\n</a>" "Setting <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> window <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> be fullscreen generally bypasses these unusable areas, so these are good guidelines <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> " "the maximum space available <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> non - fullscreen window." " @param index The monitor <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">index.\n\n</a>" " @return The rectangular region of the requested monitor." )
DefineEngineMethod(GuiCanvas , getMouseControl , S32 , () , "@brief Gets the gui <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> under the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">mouse.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "% underMouse, <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> one was found. <a href="/coding/file/typesx86unix_8h/#typesx86unix_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a> otherwise" )
DefineEngineMethod(GuiCanvas , getVideoMode , const char * , () , "@brief Gets the current screen <a href="/coding/file/zipobject_8cpp/#zipobject_8cpp_1ac6c3dfb4c3a68f849f32cbfb21da4e77">mode</a> as <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">string.\n\n</a>" "The return string will contain 5 values (width, height, fullscreen, bitdepth, refreshRate). " "You will need <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> parse out each one <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> individual <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">use.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "% screenWidth, screen height, screen mode, bit depth, and refresh rate." )
DefineEngineMethod(GuiCanvas , getWindowPosition , Point2I , () , "Get the current position of the platform window associated with the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">canvas.\n</a>" "@return The window position of the canvas in screen-space." )
DefineEngineMethod(GuiCanvas , hideCursor , void , () , "@brief Disable rendering of the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">cursor.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "Canvas.hideCursor();\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" )
DefineEngineMethod(GuiCanvas , hideWindow , void , () , "" )
DefineEngineMethod(GuiCanvas , isCursorOn , bool , () , "@brief Determines <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> mouse <a href="/coding/file/sdlcursorcontroller_8cpp/#sdlcursorcontroller_8cpp_1a06e8dd1f849973ccc456f8553601e8b9">cursor</a> is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">enabled.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "// Is <a href="/coding/file/sdlcursorcontroller_8cpp/#sdlcursorcontroller_8cpp_1a06e8dd1f849973ccc456f8553601e8b9">cursor</a> on?\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "<a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a>(Canvas.isCursorOn())\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " <a href="/coding/file/ggendoflinefix_8txt/#ggendoflinefix_8txt_1a7f8fee038817022b75b8865e5da4eba3">echo</a>(\"Canvas <a href="/coding/file/sdlcursorcontroller_8cpp/#sdlcursorcontroller_8cpp_1a06e8dd1f849973ccc456f8553601e8b9">cursor</a> is on\");\n" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" "@return Returns true <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> the <a href="/coding/file/sdlcursorcontroller_8cpp/#sdlcursorcontroller_8cpp_1a06e8dd1f849973ccc456f8553601e8b9">cursor</a> is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">on.\n\n</a>" )
DefineEngineMethod(GuiCanvas , isCursorShown , bool , () , "@brief Determines <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> mouse <a href="/coding/file/sdlcursorcontroller_8cpp/#sdlcursorcontroller_8cpp_1a06e8dd1f849973ccc456f8553601e8b9">cursor</a> is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">rendering.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "// Is <a href="/coding/file/sdlcursorcontroller_8cpp/#sdlcursorcontroller_8cpp_1a06e8dd1f849973ccc456f8553601e8b9">cursor</a> rendering?\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "<a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a>(Canvas.isCursorShown())\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " <a href="/coding/file/ggendoflinefix_8txt/#ggendoflinefix_8txt_1a7f8fee038817022b75b8865e5da4eba3">echo</a>(\"Canvas <a href="/coding/file/sdlcursorcontroller_8cpp/#sdlcursorcontroller_8cpp_1a06e8dd1f849973ccc456f8553601e8b9">cursor</a> is rendering\");\n" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" "@return Returns true <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> the <a href="/coding/file/sdlcursorcontroller_8cpp/#sdlcursorcontroller_8cpp_1a06e8dd1f849973ccc456f8553601e8b9">cursor</a> is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">rendering.\n\n</a>" )
DefineEngineMethod(GuiCanvas , isFullscreen , bool , () , "() - Is this canvas currently fullscreen?" )
DefineEngineMethod(GuiCanvas , isMaximized , bool , () , "()" )
DefineEngineMethod(GuiCanvas , isMinimized , bool , () , "()" )
DefineEngineMethod(GuiCanvas , maximizeWindow , void , () , "() - maximize this canvas' window." )
DefineEngineMethod(GuiCanvas , minimizeWindow , void , () , "() - minimize this canvas' window." )
DefineEngineMethod(GuiCanvas , popDialog , void , (GuiControl *gui) , (nullAsType< GuiControl * >()) , "(GuiControl ctrl=<a href="/coding/file/typesx86unix_8h/#typesx86unix_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)" "@hide" )
DefineEngineMethod(GuiCanvas , popLayer , void , (S32 layer) , (0) , "(int layer)" "@hide" )
DefineEngineMethod(GuiCanvas , pushDialog , void , (const char *ctrlName, S32 layer, bool center) , (0, false) , "(GuiControl ctrl, int layer=0, bool center=false)" "@hide" )
DefineEngineMethod(GuiCanvas , renderFront , void , (bool enable) , "@brief This turns on/off front-buffer <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">rendering.\n\n</a>" "@param enable True <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> all rendering should be done <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the front <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">buffer\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "Canvas.renderFront(false);\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" )
DefineEngineMethod(GuiCanvas , repaint , void , (S32 elapsedMS) , (0) , "@brief Force canvas <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">redraw.\n</a>" "If the elapsed time is greater than the time since the last paint " "then the repaint will be <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">skipped.\n</a>" "@param elapsedMS The optional elapsed time in <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">milliseconds.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "Canvas.repaint();\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" )
DefineEngineMethod(GuiCanvas , reset , void , () , "@brief Reset the update regions <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">canvas.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "Canvas.reset();\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" )
DefineEngineMethod(GuiCanvas , resetVideoMode , void , () , "" )
DefineEngineMethod(GuiCanvas , restoreWindow , void , () , "() - restore this canvas' window." )
DefineEngineMethod(GuiCanvas , screenToClient , Point2I , (Point2I coordinate) , "Translate <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> coordinate from screen-space <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> canvas window-<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">space.\n</a>" "@param coordinate The coordinate in screen-<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">space.\n</a>" "@return The given coordinate translated <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> window-space." )
DefineEngineMethod(GuiCanvas , setContent , void , (GuiControl *ctrl) , "@brief Set the content of the canvas <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> specified <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">control.\n\n</a>" "@param ctrl ID or name of <a href="/coding/class/classguicontrol/">GuiControl</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> set content <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">to\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "Canvas.setContent(PlayGui);\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" )
DefineEngineMethod(GuiCanvas , setCursor , void , (GuiCursor *cursor) , "@brief Sets the <a href="/coding/file/sdlcursorcontroller_8cpp/#sdlcursorcontroller_8cpp_1a06e8dd1f849973ccc456f8553601e8b9">cursor</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">canvas.\n\n</a>" "@param <a href="/coding/file/sdlcursorcontroller_8cpp/#sdlcursorcontroller_8cpp_1a06e8dd1f849973ccc456f8553601e8b9">cursor</a> Name of the <a href="/coding/class/classguicursor/">GuiCursor</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">use\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "Canvas.setCursor(\"DefaultCursor\");\n" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" )
DefineEngineMethod(GuiCanvas , setCursorPos , void , (Point2I pos) , "(Point2I pos)" "@hide" )
DefineEngineMethod(GuiCanvas , setFocus , void , () , "() - Claim OS input focus <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this canvas' window." )
DefineEngineMethod(GuiCanvas , setMenuBar , void , (GuiControl *menu) , "Translate <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> coordinate from canvas window-space <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> screen-<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">space.\n</a>" "@param coordinate The coordinate in window-<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">space.\n</a>" "@return The given coordinate translated <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> screen-space." )
DefineEngineMethod(GuiCanvas , setVideoMode , void , (U32 width, U32 height, bool fullscreen, U32 bitDepth, U32 refreshRate, U32 antialiasLevel) , (false, 0, 0, 0) )
DefineEngineMethod(GuiCanvas , setWindowPosition , void , (Point2I position) , "Set the position of the platform window associated with the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">canvas.\n</a>" "@param position The <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> position of the window in screen-space." )
DefineEngineMethod(GuiCanvas , setWindowTitle , void , (const char *newTitle) , "@brief Change the title of the OS <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">window.\n\n</a>" "@param newTitle <a href="/coding/class/classstring/">String</a> containing the <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">name\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "Canvas.setWindowTitle(\"Documentation Rocks!\");\n" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" )
DefineEngineMethod(GuiCanvas , showCursor , void , () , "@brief Enable rendering of the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">cursor.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "Canvas.showCursor();\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" )
DefineEngineMethod(GuiCanvas , showWindow , void , () , "" )
DefineEngineMethod(GuiCanvas , toggleFullscreen , void , () , "@brief toggle canvas from fullscreen <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> windowed <a href="/coding/file/zipobject_8cpp/#zipobject_8cpp_1ac6c3dfb4c3a68f849f32cbfb21da4e77">mode</a> or <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">back.\n\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "// If we are in windowed mode, the following will put is in <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">fullscreen\n</a>" "Canvas.toggleFullscreen();" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" )
IMPLEMENT_CONOBJECT(GuiCanvas )
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23 24//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// 25// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames 26// Copyright (C) 2015 Faust Logic, Inc. 27//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// 28 29#include "platform/platform.h" 30#include "gui/core/guiCanvas.h" 31 32#include "console/console.h" 33#include "console/engineAPI.h" 34#include "platform/profiler.h" 35#include "gfx/gfxDevice.h" 36#include "gfx/gfxDrawUtil.h" 37#include "gui/core/guiTypes.h" 38#include "gui/core/guiControl.h" 39#include "gui/editor/guiMenuBar.h" 40#include "console/consoleTypes.h" 41#include "gfx/screenshot.h" 42#include "gfx/video/videoCapture.h" 43#include "lighting/lightManager.h" 44#include "core/strings/stringUnit.h" 45#include "gui/core/guiOffscreenCanvas.h" 46 47#ifndef TORQUE_TGB_ONLY 48#include "scene/sceneObject.h" 49#endif 50 51#include "gfx/gfxInit.h" 52#include "core/util/journal/process.h" 53 54#ifdef TORQUE_GFX_STATE_DEBUG 55#include "gfx/gfxDebugStateTracker.h" 56#endif 57 58IMPLEMENT_CONOBJECT(GuiCanvas); 59 60ConsoleDocClass( GuiCanvas, 61 "@brief A canvas on which rendering occurs.\n\n" 62 63 "@section GuiCanvas_contents What a GUICanvas Can Contain...\n\n" 64 65 "@subsection GuiCanvas_content_contentcontrol Content Control\n" 66 "A content control is the top level GuiControl for a screen. This GuiControl " 67 "will be the parent control for all other GuiControls on that particular " 68 "screen.\n\n" 69 70 "@subsection GuiCanvas_content_dialogs Dialogs\n\n" 71 72 "A dialog is essentially another screen, only it gets overlaid on top of the " 73 "current content control, and all input goes to the dialog. This is most akin " 74 "to the \"Open File\" dialog box found in most operating systems. When you " 75 "choose to open a file, and the \"Open File\" dialog pops up, you can no longer " 76 "send input to the application, and must complete or cancel the open file " 77 "request. Torque keeps track of layers of dialogs. The dialog with the highest " 78 "layer is on top and will get all the input, unless the dialog is " 79 "modeless, which is a profile option.\n\n" 80 81 "@see GuiControlProfile\n\n" 82 83 "@section GuiCanvas_dirty Dirty Rectangles\n\n" 84 85 "The GuiCanvas is based on dirty regions. " 86 "Every frame the canvas paints only the areas of the canvas that are 'dirty' " 87 "or need updating. In most cases, this only is the area under the mouse cursor. " 88 "This is why if you look in guiCanvas.cc the call to glClear is commented out. " 89 90 "What you will see is a black screen, except in the dirty regions, where the " 91 "screen will be painted normally. If you are making an animated GuiControl " 92 "you need to add your control to the dirty areas of the canvas.\n\n" 93 94 "@see GuiControl\n\n" 95 96 "@ingroup GuiCore\n"); 97 98ColorI gCanvasClearColor( 255, 0, 255 ); ///< For GFX->clear 99 100extern InputModifiers convertModifierBits(const U32 in); 101 102//----------------------------------------------------------------------------- 103 104GuiCanvas::GuiCanvas(): GuiControl(), 105 mCurUpdateRect(0, 0, 0, 0), 106 mCursorEnabled(true), 107 mForceMouseToGUI(false), 108 mAlwaysHandleMouseButtons(false), 109 mShowCursor(true), 110 mClampTorqueCursor(true), 111 mCursorChanged(0), 112 mLastCursorEnabled(false), 113 mMouseCapturedControl(NULL), 114 mMouseControl(NULL), 115 mMouseControlClicked(false), 116 mMouseButtonDown(false), 117 mMouseRightButtonDown(false), 118 mDefaultCursor(NULL), 119 mMouseMiddleButtonDown(false), 120 mCursorPt(0,0), 121 mLastCursorPt(0,0), 122 mLastCursor(NULL), 123 mLastMouseClickCount(0), 124 mRenderFront(false), 125 mPrevMouseTime(0), 126 mLastMouseDownTime(0), 127 mHoverControl(NULL), 128 mHoverPositionSet(false), 129 mLeftMouseLast(false), 130 mHoverLeftControlTime(0), 131 mMiddleMouseLast(false), 132 mRightMouseLast(false), 133 mMouseDownPoint(0.0f,0.0f), 134 mLastRenderMs(0), 135 mPlatformWindow(NULL), 136 mDisplayWindow(true), 137 mMenuBarCtrl(nullptr), 138 mMenuBackground(nullptr) 139{ 140 setBounds(0, 0, 640, 480); 141 mAwake = true; 142 143 mHoverControlStart = Platform::getRealMilliseconds(); 144 mHoverPosition = getCursorPos(); 145 146 mFences = NULL; 147 mNextFenceIdx = -1; 148 149#ifndef _XBOX 150 mNumFences = Con::getIntVariable( "$pref::Video::defaultFenceCount", 0 ); 151#else 152 mNumFences = 0; 153#endif 154 mConsumeLastInputEvent = false; 155} 156 157GuiCanvas::~GuiCanvas() 158{ 159 SAFE_DELETE(mPlatformWindow); 160 SAFE_DELETE_ARRAY( mFences ); 161} 162 163//------------------------------------------------------------------------------ 164 165bool GuiCanvas::setProtectedNumFences( void *object, const char *index, const char *data) 166{ 167 GuiCanvas *canvas = reinterpret_cast<GuiCanvas *>( object ); 168 canvas->mNumFences = dAtoi( data ); 169 canvas->setupFences(); 170 171 return false; 172} 173 174void GuiCanvas::initPersistFields() 175{ 176 addGroup("Mouse Handling"); 177 addField("alwaysHandleMouseButtons", TypeBool, Offset(mAlwaysHandleMouseButtons, GuiCanvas), 178 "Deal with mouse buttons, even if the cursor is hidden." ); 179 endGroup("Mouse Handling"); 180 181 addGroup("Canvas Rendering"); 182 addProtectedField( "numFences", TypeS32, Offset( mNumFences, GuiCanvas ), &setProtectedNumFences, &defaultProtectedGetFn, "The number of GFX fences to use." ); 183 184 addField("displayWindow", TypeBool, Offset(mDisplayWindow, GuiCanvas), "Controls if the canvas window is rendered or not." ); 185 endGroup("Canvas Rendering"); 186 187 Parent::initPersistFields(); 188} 189 190//------------------------------------------------------------------------------ 191 192bool GuiCanvas::onAdd() 193{ 194 // ensure that we have a cursor 195 setCursor(dynamic_cast<GuiCursor*>(Sim::findObject("DefaultCursor"))); 196 197 // Enumerate things for GFX before we have an active device. 198 GFXInit::enumerateAdapters(); 199 200 // Create a device. 201 GFXAdapter *a = GFXInit::getBestAdapterChoice(); 202 203 // Do we have a global device already? (This is the site if you want 204 // to start rendering to multiple devices simultaneously) 205 GFXDevice *newDevice = GFX; 206 if(newDevice == NULL) 207 newDevice = GFXInit::createDevice(a); 208 209 newDevice->setAllowRender( false ); 210 211 // Disable starting a new journal recording or playback from here on 212 Journal::Disable(); 213 214 // Initialize the window... 215 GFXVideoMode vm = GFXInit::getInitialVideoMode(); 216 217 //If we're recording, store the intial video resolution 218 if (Journal::IsRecording()) 219 { 220 Journal::Write(vm.resolution.x); 221 Journal::Write(vm.resolution.y); 222 Journal::Write(vm.fullScreen); 223 } 224 225 //If we're playing, read the intial video resolution from the journal 226 if (Journal::IsPlaying()) 227 { 228 Journal::Read(&vm.resolution.x); 229 Journal::Read(&vm.resolution.y); 230 Journal::Read(&vm.fullScreen); 231 } 232 233 if (a && a->mType != NullDevice) 234 { 235 mPlatformWindow = WindowManager->createWindow(newDevice, vm); 236 237 //Disable window resizing if recording ir playing a journal 238 if (Journal::IsRecording() || Journal::IsPlaying()) 239 mPlatformWindow->lockSize(true); 240 241 // Set a minimum on the window size so people can't break us by resizing tiny. 242 mPlatformWindow->setMinimumWindowSize(Point2I(Con::getIntVariable("$Video::minimumXResolution", 1024), 243 Con::getIntVariable("$Video::minimumYResolution", 720))); 244 245 // Now, we have to hook in our event callbacks so we'll get 246 // appropriate events from the window. 247 mPlatformWindow->resizeEvent .notify(this, &GuiCanvas::handleResize); 248 mPlatformWindow->appEvent .notify(this, &GuiCanvas::handleAppEvent); 249 mPlatformWindow->displayEvent.notify(this, &GuiCanvas::handlePaintEvent); 250 mPlatformWindow->setInputController( dynamic_cast<IProcessInput*>(this) ); 251 } 252 253 // Need to get painted, too! :) 254 Process::notify(this, &GuiCanvas::paint, PROCESS_RENDER_ORDER); 255 256 // Set up the fences 257 setupFences(); 258 259 // Make sure we're able to render. 260 newDevice->setAllowRender( true ); 261 262 if(mDisplayWindow) 263 { 264 getPlatformWindow()->show(); 265 WindowManager->setDisplayWindow(true); 266 getPlatformWindow()->setDisplayWindow(true); 267 } 268 else 269 { 270 getPlatformWindow()->hide(); 271 WindowManager->setDisplayWindow(false); 272 getPlatformWindow()->setDisplayWindow(false); 273 } 274 275 // Propagate add to parents. 276 // CodeReview - if GuiCanvas fails to add for whatever reason, what happens to 277 // all the event registration above? 278 bool parentRet = Parent::onAdd(); 279 280 // Define the menu bar for this canvas (if any) 281 Con::executef(this, "onCreateMenu"); 282 283 return parentRet; 284} 285 286void GuiCanvas::onRemove() 287{ 288 // And the process list 289 Process::remove(this, &GuiCanvas::paint); 290 291 // Destroy the menu bar for this canvas (if any) 292 Con::executef(this, "onDestroyMenu"); 293 294 Parent::onRemove(); 295} 296 297void GuiCanvas::setMenuBar(SimObject *obj) 298{ 299 GuiControl *oldMenuBar = mMenuBarCtrl; 300 mMenuBarCtrl = dynamic_cast<GuiControl*>(obj); 301 302 //remove old menubar 303 if (oldMenuBar) 304 { 305 Parent::removeObject(oldMenuBar); 306 Parent::removeObject(mMenuBackground); //also remove the modeless wrapper 307 } 308 309 // set new menubar 310 if (mMenuBarCtrl) 311 { 312 //Add a wrapper control so that the menubar sizes correctly 313 GuiControlProfile* profile; 314 Sim::findObject("GuiModelessDialogProfile", profile); 315 316 if (!profile) 317 { 318 Con::errorf("GuiCanvas::setMenuBar: Unable to find the GuiModelessDialogProfile profile!"); 319 return; 320 } 321 322 if (mMenuBackground == nullptr) 323 { 324 mMenuBackground = new GuiControl(); 325 mMenuBackground->registerObject(); 326 327 mMenuBackground->setControlProfile(profile); 328 } 329 330 mMenuBackground->addObject(mMenuBarCtrl); 331 332 Parent::addObject(mMenuBackground); 333 } 334 335 // update window accelerator keys 336 if( oldMenuBar != mMenuBarCtrl ) 337 { 338 GuiMenuBar* oldMenu = dynamic_cast<GuiMenuBar*>(oldMenuBar); 339 GuiMenuBar* newMenu = dynamic_cast<GuiMenuBar*>(mMenuBarCtrl); 340 341 if(oldMenu) 342 oldMenu->removeWindowAcceleratorMap(*getPlatformWindow()->getInputGenerator()); 343 344 if(newMenu) 345 newMenu->buildWindowAcceleratorMap(*getPlatformWindow()->getInputGenerator()); 346 } 347} 348 349void GuiCanvas::setWindowTitle(const char *newTitle) 350{ 351 if (mPlatformWindow) 352 mPlatformWindow->setCaption(newTitle); 353} 354 355CanvasSizeChangeSignal GuiCanvas::smCanvasSizeChangeSignal; 356 357void GuiCanvas::handleResize( WindowId did, S32 width, S32 height ) 358{ 359 getCanvasSizeChangeSignal().trigger(this); 360 if (Journal::IsPlaying() && mPlatformWindow) 361 { 362 mPlatformWindow->lockSize(false); 363 mPlatformWindow->setSize(Point2I(width, height)); 364 mPlatformWindow->lockSize(true); 365 } 366 367 // Notify the scripts 368 if ( isMethod( "onResize" ) ) 369 Con::executef( this, "onResize", Con::getIntArg( width ), Con::getIntArg( height ) ); 370} 371 372void GuiCanvas::handlePaintEvent(WindowId did) 373{ 374 bool canRender = mPlatformWindow->isVisible() && GFX->allowRender() && !GFX->canCurrentlyRender(); 375 376 // Do the screenshot first. 377 if ( gScreenShot != NULL && gScreenShot->isPending() && canRender ) 378 gScreenShot->capture( this ); 379 380 // If the video capture is waiting for a canvas, start the capture 381 if ( VIDCAP->isWaitingForCanvas() && canRender ) 382 VIDCAP->begin( this ); 383 384 // Now capture the video 385 if ( VIDCAP->isRecording() && canRender ) 386 VIDCAP->capture(); 387 388 renderFrame(false); 389} 390 391void GuiCanvas::handleAppEvent( WindowId did, S32 event ) 392{ 393 // Notify script if we gain or lose focus. 394 if(event == LoseFocus) 395 { 396 if(isMethod("onLoseFocus")) 397 Con::executef(this, "onLoseFocus"); 398 } 399 400 if(event == GainFocus) 401 { 402 if(isMethod("onGainFocus")) 403 Con::executef(this, "onGainFocus"); 404 } 405 406 if(event == WindowClose || event == WindowDestroy) 407 { 408 409 if(isMethod("onWindowClose")) 410 { 411 // First see if there is a method on this window to handle 412 // it's closure 413 Con::executef(this,"onWindowClose"); 414 } 415 else if(Con::isFunction("onWindowClose")) 416 { 417 // otherwise check to see if there is a global function handling it 418 Con::executef("onWindowClose", getIdString()); 419 } 420 else 421 { 422 // Else just shutdown 423 Process::requestShutdown(); 424 } 425 } 426} 427 428Point2I GuiCanvas::getWindowSize() 429{ 430 // CodeReview Asserting on this breaks previous logic 431 // and code assumptions. It seems logical that we would 432 // handle this and return an error value rather than implementing 433 // if(!mPlatformWindow) whenever we need to call getWindowSize. 434 // This should help keep our API error free and easy to use, while 435 // cutting down on code duplication for sanity checking. [5/5/2007 justind] 436 if( !mPlatformWindow ) 437 return Point2I(-1,-1); 438 439 return mPlatformWindow->getClientExtent(); 440} 441 442void GuiCanvas::enableKeyboardTranslation() 443{ 444 AssertISV(mPlatformWindow, "GuiCanvas::enableKeyboardTranslation - no window present!"); 445 mPlatformWindow->setKeyboardTranslation(true); 446} 447 448void GuiCanvas::disableKeyboardTranslation() 449{ 450 AssertISV(mPlatformWindow, "GuiCanvas::disableKeyboardTranslation - no window present!"); 451 mPlatformWindow->setKeyboardTranslation(false); 452} 453 454void GuiCanvas::setNativeAcceleratorsEnabled( bool enabled ) 455{ 456 AssertISV(mPlatformWindow, "GuiCanvas::setNativeAcceleratorsEnabled - no window present!"); 457 mPlatformWindow->setAcceleratorsEnabled( enabled ); 458} 459 460void GuiCanvas::setForceMouseToGUI(bool onOff) 461{ 462 mForceMouseToGUI = onOff; 463} 464 465void GuiCanvas::setClampTorqueCursor(bool onOff) 466{ 467 mClampTorqueCursor = onOff; 468} 469 470void GuiCanvas::setCursor(GuiCursor *curs) 471{ 472 mDefaultCursor = curs; 473} 474 475void GuiCanvas::setCursorON(bool onOff) 476{ 477 mCursorEnabled = onOff; 478 if(!mCursorEnabled) 479 mMouseControl = NULL; 480} 481 482Point2I GuiCanvas::getCursorPos() 483{ 484 Point2I p( 0, 0 ); 485 486 if( mPlatformWindow ) 487 mPlatformWindow->getCursorPosition( p ); 488 489 return p; 490} 491 492void GuiCanvas::setCursorPos(const Point2I &pt) 493{ 494 AssertISV(mPlatformWindow, "GuiCanvas::setCursorPos - no window present!"); 495 496 if ( mPlatformWindow->isMouseLocked() ) 497 { 498 mCursorPt.x = F32( pt.x ); 499 mCursorPt.y = F32( pt.y ); 500 } 501 else 502 { 503 Point2I screenPt( mPlatformWindow->clientToScreen( pt ) ); 504 mPlatformWindow->setCursorPosition( screenPt.x, screenPt.y ); 505 } 506} 507 508void GuiCanvas::showCursor(bool state) 509{ 510 mShowCursor = state; 511 mPlatformWindow->setCursorVisible( state ); 512} 513 514bool GuiCanvas::isCursorShown() 515{ 516 if ( !mPlatformWindow->getCursorController() ) 517 { 518 return mShowCursor; 519 } 520 521 return mPlatformWindow->isCursorVisible(); 522} 523 524void GuiCanvas::cursorClick(S32 buttonId, bool isDown) 525{ 526 InputEventInfo inputEvent; 527 inputEvent.deviceType = MouseDeviceType; 528 inputEvent.deviceInst = 0; 529 inputEvent.objType = SI_BUTTON; 530 inputEvent.objInst = (InputObjectInstances)(KEY_BUTTON0 + buttonId); 531 inputEvent.modifier = (InputModifiers)0; 532 inputEvent.ascii = 0; 533 inputEvent.action = isDown ? SI_MAKE : SI_BREAK; 534 inputEvent.fValue = isDown ? 1.0 : 0.0; 535 536 processMouseEvent(inputEvent); 537} 538 539void GuiCanvas::cursorNudge(F32 x, F32 y) 540{ 541 // Generate a base Movement along and Axis event 542 InputEventInfo inputEvent; 543 inputEvent.deviceType = MouseDeviceType; 544 inputEvent.deviceInst = 0; 545 inputEvent.objType = SI_AXIS; 546 inputEvent.modifier = (InputModifiers)0; 547 inputEvent.ascii = 0; 548 549 // Generate delta movement along each axis 550 Point2F cursDelta(x, y); 551 552 // If X axis changed, generate a relative event 553 if(mFabs(cursDelta.x) > 0.1) 554 { 555 inputEvent.objInst = SI_XAXIS; 556 inputEvent.action = SI_MOVE; 557 inputEvent.fValue = cursDelta.x; 558 processMouseEvent(inputEvent); 559 } 560 561 // If Y axis changed, generate a relative event 562 if(mFabs(cursDelta.y) > 0.1) 563 { 564 inputEvent.objInst = SI_YAXIS; 565 inputEvent.action = SI_MOVE; 566 inputEvent.fValue = cursDelta.y; 567 processMouseEvent(inputEvent); 568 } 569 570 processMouseEvent(inputEvent); 571} 572 573void GuiCanvas::addAcceleratorKey(GuiControl *ctrl, U32 index, U32 keyCode, U32 modifier) 574{ 575 if (keyCode > 0 && ctrl) 576 { 577 AccKeyMap newMap; 578 newMap.ctrl = ctrl; 579 newMap.index = index; 580 newMap.keyCode = keyCode; 581 newMap.modifier = modifier; 582 mAcceleratorMap.push_back(newMap); 583 } 584} 585 586bool GuiCanvas::tabNext(void) 587{ 588 GuiControl *ctrl = static_cast<GuiControl *>(last()); 589 if (ctrl) 590 { 591 //save the old 592 GuiControl *oldResponder = mFirstResponder; 593 594 GuiControl* newResponder = ctrl->findNextTabable(mFirstResponder); 595 if ( !newResponder ) 596 newResponder = ctrl->findFirstTabable(); 597 598 if ( newResponder && newResponder != oldResponder ) 599 { 600 newResponder->setFirstResponder(); 601 602 // CodeReview Can this get killed? Note tabPrev code. BJG - 3/25/07 603// if ( oldResponder ) 604// oldResponder->onLoseFirstResponder(); 605 return true; 606 } 607 } 608 return false; 609} 610 611bool GuiCanvas::tabPrev(void) 612{ 613 GuiControl *ctrl = static_cast<GuiControl *>(last()); 614 if (ctrl) 615 { 616 //save the old 617 GuiControl *oldResponder = mFirstResponder; 618 619 GuiControl* newResponder = ctrl->findPrevTabable(mFirstResponder); 620 if ( !newResponder ) 621 newResponder = ctrl->findLastTabable(); 622 623 if ( newResponder && newResponder != oldResponder ) 624 { 625 newResponder->setFirstResponder(); 626 627 // CodeReview As with tabNext() above, looks like this can now go. DAW - 7/05/09 628 //if ( oldResponder ) 629 // oldResponder->onLoseFirstResponder(); 630 631 return true; 632 } 633 } 634 return false; 635} 636 637bool GuiCanvas::processInputEvent(InputEventInfo &inputEvent) 638{ 639 mConsumeLastInputEvent = true; 640 // First call the general input handler (on the extremely off-chance that it will be handled): 641 if (mFirstResponder && mFirstResponder->onInputEvent(inputEvent)) 642 { 643 return mConsumeLastInputEvent; 644 } 645 646 switch (inputEvent.deviceType) 647 { 648 case KeyboardDeviceType: 649 return processKeyboardEvent(inputEvent); 650 break; 651 652 case GamepadDeviceType: 653 return processGamepadEvent(inputEvent); 654 break; 655 656 case MouseDeviceType: 657 if (mCursorEnabled || mForceMouseToGUI || 658 (mAlwaysHandleMouseButtons && inputEvent.objType == SI_BUTTON) ) 659 { 660 return processMouseEvent(inputEvent); 661 } 662 break; 663 default: 664 break; 665 } 666 667 return false; 668} 669 670bool GuiCanvas::processKeyboardEvent(InputEventInfo &inputEvent) 671{ 672 mLastEvent.ascii = inputEvent.ascii; 673 mLastEvent.modifier = inputEvent.modifier; 674 mLastEvent.keyCode = inputEvent.objInst; 675 676 // Combine left/right shift bits - if one shift modifier key 677 // bit is set, then set the other one. This way we can simplify 678 // our processing logic by treating the keys identically. 679 U32 eventModifier = inputEvent.modifier; 680 if(eventModifier & SI_SHIFT) 681 { 682 eventModifier |= SI_SHIFT; 683 } 684 if(eventModifier & SI_CTRL) 685 { 686 eventModifier |= SI_CTRL; 687 } 688 if(eventModifier & SI_ALT) 689 { 690 eventModifier |= SI_ALT; 691 } 692 693 if (inputEvent.action == SI_MAKE) 694 { 695 //see if we should now pass the event to the first responder 696 if (mFirstResponder) 697 { 698 if(mFirstResponder->onKeyDown(mLastEvent)) 699 return mConsumeLastInputEvent; 700 } 701 702 //see if we should tab next/prev 703 if ( isCursorON() && ( inputEvent.objInst == KEY_TAB ) ) 704 { 705 if (size() > 0) 706 { 707 if (inputEvent.modifier & SI_SHIFT) 708 { 709 if(tabPrev()) 710 return mConsumeLastInputEvent; 711 } 712 else if (inputEvent.modifier == 0) 713 { 714 if(tabNext()) 715 return mConsumeLastInputEvent; 716 } 717 } 718 } 719 720 //if not handled, search for an accelerator 721 for (U32 i = 0; i < mAcceleratorMap.size(); i++) 722 { 723 if ((U32)mAcceleratorMap[i].keyCode == (U32)inputEvent.objInst && (U32)mAcceleratorMap[i].modifier == eventModifier) 724 { 725 mAcceleratorMap[i].ctrl->acceleratorKeyPress(mAcceleratorMap[i].index); 726 return mConsumeLastInputEvent; 727 } 728 } 729 } 730 else if(inputEvent.action == SI_BREAK) 731 { 732 if(mFirstResponder && mFirstResponder->onKeyUp(mLastEvent)) 733 return mConsumeLastInputEvent; 734 735 //see if there's an accelerator 736 for (U32 i = 0; i < mAcceleratorMap.size(); i++) 737 { 738 if ((U32)mAcceleratorMap[i].keyCode == (U32)inputEvent.objInst && (U32)mAcceleratorMap[i].modifier == eventModifier) 739 { 740 mAcceleratorMap[i].ctrl->acceleratorKeyRelease(mAcceleratorMap[i].index); 741 return mConsumeLastInputEvent; 742 } 743 } 744 } 745 else if(inputEvent.action == SI_REPEAT) 746 { 747 //if not handled, search for an accelerator 748 for (U32 i = 0; i < mAcceleratorMap.size(); i++) 749 { 750 if ((U32)mAcceleratorMap[i].keyCode == (U32)inputEvent.objInst && (U32)mAcceleratorMap[i].modifier == eventModifier) 751 { 752 mAcceleratorMap[i].ctrl->acceleratorKeyPress(mAcceleratorMap[i].index); 753 return mConsumeLastInputEvent; 754 } 755 } 756 757 if(mFirstResponder) 758 { 759 bool ret = mFirstResponder->onKeyRepeat(mLastEvent); 760 return ret && mConsumeLastInputEvent; 761 } 762 } 763 return false; 764} 765 766bool GuiCanvas::processMouseEvent(InputEventInfo &inputEvent) 767{ 768 // [rene 09/09/10] This custom mouse cursor tracking that is happening here is bad. It will frequently 769 // get ouf of step with where the cursor actually is. We really should *not* track the cursor; it's 770 // just another thing that can/will go wrong. Let the input system pass us absolute screen coordinates 771 // for every mouse event instead and work off that. 772 // 773 // 'mCursorPt' basically is an accumulation of errors and the number of bugs that have cropped up with 774 // the GUI clicking stuff where it is not supposed to are probably all to blame on this. 775 776 S32 mouseDoubleClickWidth = 12; 777 S32 mouseDoubleClickHeight = 12; 778 U32 mouseDoubleClickTime = 500; 779 780 // Query platform for mouse info if its available 781 PlatformCursorController *pController = mPlatformWindow ? mPlatformWindow->getCursorController() : NULL; 782 if (pController) 783 { 784 mouseDoubleClickWidth = pController->getDoubleClickWidth(); 785 mouseDoubleClickHeight = pController->getDoubleClickHeight(); 786 mouseDoubleClickTime = pController->getDoubleClickTime(); 787 } 788 789 //copy the modifier into the new event 790 mLastEvent.modifier = inputEvent.modifier; 791 792 if(inputEvent.objType == SI_AXIS && 793 (inputEvent.objInst == SI_XAXIS || inputEvent.objInst == SI_YAXIS)) 794 { 795 796 // Set the absolute position if we get an SI_MAKE on an axis 797 if( inputEvent.objInst == SI_XAXIS ) 798 { 799 if( inputEvent.action == SI_MAKE ) 800 mCursorPt.x = (S32)inputEvent.fValue; 801 else if( inputEvent.action == SI_MOVE ) 802 mCursorPt.x += (S32)inputEvent.fValue; 803 mCursorPt.x = getMax(0, getMin((S32)mCursorPt.x, getBounds().extent.x - 1)); 804 } 805 else if( inputEvent.objInst == SI_YAXIS ) 806 { 807 if( inputEvent.action == SI_MAKE ) 808 mCursorPt.y = (S32)inputEvent.fValue; 809 else if( inputEvent.action == SI_MOVE ) 810 mCursorPt.y += (S32)inputEvent.fValue; 811 mCursorPt.y = getMax(0, getMin((S32)mCursorPt.y, getBounds().extent.y - 1)); 812 } 813 814 // Store new cursor position. 815 mLastEvent.mousePoint.x = S32(mCursorPt.x); 816 mLastEvent.mousePoint.y = S32(mCursorPt.y); 817 818 // See if we need to invalidate a possible dbl click due to the cursor 819 // moving too much. 820 Point2F movement = mMouseDownPoint - mCursorPt; 821 822 if ((mAbs((S32)movement.x) > mouseDoubleClickWidth) || (mAbs((S32)movement.y) > mouseDoubleClickHeight ) ) 823 { 824 mLeftMouseLast = false; 825 mMiddleMouseLast = false; 826 mRightMouseLast = false; 827 } 828 829 if (mMouseButtonDown) 830 rootMouseDragged(mLastEvent); 831 else if (mMouseRightButtonDown) 832 rootRightMouseDragged(mLastEvent); 833 else if(mMouseMiddleButtonDown) 834 rootMiddleMouseDragged(mLastEvent); 835 else 836 rootMouseMove(mLastEvent); 837 return mConsumeLastInputEvent; 838 } 839 else if ( inputEvent.objInst == SI_ZAXIS 840 || inputEvent.objInst == SI_RZAXIS ) 841 { 842 mLastEvent.mousePoint.x = S32( mCursorPt.x ); 843 mLastEvent.mousePoint.y = S32( mCursorPt.y ); 844 mLastEvent.fval = inputEvent.fValue; 845 846 if( inputEvent.objInst == SI_ZAXIS ) 847 mLastEvent.mouseAxis = 1; 848 else 849 mLastEvent.mouseAxis = 0; 850 851 if ( inputEvent.fValue < 0.0f ) 852 return rootMouseWheelDown( mLastEvent ); 853 else 854 return rootMouseWheelUp( mLastEvent ); 855 } 856 else if(inputEvent.objType == SI_BUTTON) 857 { 858 //copy the cursor point into the event 859 mLastEvent.mousePoint.x = S32(mCursorPt.x); 860 mLastEvent.mousePoint.y = S32(mCursorPt.y); 861 mMouseDownPoint = mCursorPt; 862 863 if(inputEvent.objInst == KEY_BUTTON0) // left button 864 { 865 //see if button was pressed 866 if (inputEvent.action == SI_MAKE) 867 { 868 U32 curTime = Platform::getVirtualMilliseconds(); 869 870 //if the last button pressed was the left... 871 if (mLeftMouseLast) 872 { 873 //if it was within the double click time count the clicks 874 if (curTime - mLastMouseDownTime <= mouseDoubleClickTime) 875 mLastMouseClickCount++; 876 else 877 mLastMouseClickCount = 1; 878 } 879 else 880 { 881 mLeftMouseLast = true; 882 mLastMouseClickCount = 1; 883 } 884 885 mLastMouseDownTime = curTime; 886 mLastEvent.mouseClickCount = mLastMouseClickCount; 887 888 rootMouseDown(mLastEvent); 889 } 890 //else button was released 891 else 892 { 893 rootMouseUp(mLastEvent); 894 } 895 896 return mConsumeLastInputEvent; 897 } 898 else if(inputEvent.objInst == KEY_BUTTON1) // right button 899 { 900 if(inputEvent.action == SI_MAKE) 901 { 902 U32 curTime = Platform::getVirtualMilliseconds(); 903 904 //if the last button pressed was the right... 905 if (mRightMouseLast) 906 { 907 //if it was within the double click time count the clicks 908 if (curTime - mLastMouseDownTime <= mouseDoubleClickTime) 909 mLastMouseClickCount++; 910 else 911 mLastMouseClickCount = 1; 912 } 913 else 914 { 915 mRightMouseLast = true; 916 mLastMouseClickCount = 1; 917 } 918 919 mLastMouseDownTime = curTime; 920 mLastEvent.mouseClickCount = mLastMouseClickCount; 921 922 rootRightMouseDown(mLastEvent); 923 } 924 else // it was a mouse up 925 rootRightMouseUp(mLastEvent); 926 927 return mConsumeLastInputEvent; 928 } 929 else if(inputEvent.objInst == KEY_BUTTON2) // middle button 930 { 931 if(inputEvent.action == SI_MAKE) 932 { 933 U32 curTime = Platform::getVirtualMilliseconds(); 934 935 //if the last button pressed was the right... 936 if (mMiddleMouseLast) 937 { 938 //if it was within the double click time count the clicks 939 if (curTime - mLastMouseDownTime <= mouseDoubleClickTime) 940 mLastMouseClickCount++; 941 else 942 mLastMouseClickCount = 1; 943 } 944 else 945 { 946 mMiddleMouseLast = true; 947 mLastMouseClickCount = 1; 948 } 949 950 mLastMouseDownTime = curTime; 951 mLastEvent.mouseClickCount = mLastMouseClickCount; 952 953 rootMiddleMouseDown(mLastEvent); 954 } 955 else // it was a mouse up 956 rootMiddleMouseUp(mLastEvent); 957 958 return mConsumeLastInputEvent; 959 } 960 } 961 return false; 962} 963 964bool GuiCanvas::processGamepadEvent(InputEventInfo &inputEvent) 965{ 966 if (! mFirstResponder) 967 { 968 // early out, no first responder to receive gamepad input 969 return false; 970 } 971 972 if (inputEvent.deviceInst >= MAX_GAMEPADS) 973 { 974 // early out, we only support the first MAX_GAMEPADS gamepads 975 return false; 976 } 977 978 mLastEvent.keyCode = inputEvent.objInst; 979 980 if (inputEvent.objType == SI_BUTTON) 981 { 982 switch (inputEvent.action) 983 { 984 case SI_MAKE: 985 switch (inputEvent.objInst) 986 { 987 case SI_UPOV: 988 return mFirstResponder->onGamepadAxisUp(mLastEvent); 989 990 case SI_DPOV: 991 return mFirstResponder->onGamepadAxisDown(mLastEvent); 992 993 case SI_LPOV: 994 return mFirstResponder->onGamepadAxisLeft(mLastEvent); 995 996 case SI_RPOV: 997 return mFirstResponder->onGamepadAxisRight(mLastEvent); 998 999 default: 1000 return mFirstResponder->onGamepadButtonDown(mLastEvent); 1001 } 1002 break; 1003 1004 case SI_BREAK: 1005 return mFirstResponder->onGamepadButtonUp(mLastEvent); 1006 1007 default: 1008 return false; 1009 } 1010 } 1011 else if (inputEvent.objType == SI_AXIS) 1012 { 1013 F32 incomingValue = mFabs(inputEvent.fValue); 1014 static const F32 DEAD_ZONE = 0.5f; 1015 static const F32 MIN_CLICK_TIME = 500.0f; 1016 static const F32 MAX_CLICK_TIME = 1000.0f; 1017 static F32 xDecay [] = {1.0f, 1.0f, 1.0f, 1.0f}; 1018 static F32 yDecay [] = {1.0f, 1.0f, 1.0f, 1.0f}; 1019 static F32 zDecay [] = {1.0f, 1.0f, 1.0f, 1.0f}; 1020 static U32 xLastClickTime [] = {0, 0, 0, 0}; 1021 static U32 yLastClickTime [] = {0, 0, 0, 0}; 1022 static U32 zLastClickTime [] = {0, 0, 0, 0}; 1023 U32 curTime = Platform::getRealMilliseconds(); 1024 F32 *decay; 1025 U32 *lastClickTime; 1026 1027 switch (inputEvent.objInst) 1028 { 1029 case SI_ZAXIS: 1030 case XI_LEFT_TRIGGER: 1031 case XI_RIGHT_TRIGGER: 1032 decay = &zDecay[inputEvent.deviceInst]; 1033 lastClickTime = &zLastClickTime[inputEvent.deviceInst]; 1034 break; 1035 1036 case SI_YAXIS: 1037 case XI_THUMBLY: 1038 case XI_THUMBRY: 1039 decay = &yDecay[inputEvent.deviceInst]; 1040 lastClickTime = &yLastClickTime[inputEvent.deviceInst]; 1041 break; 1042 1043 case SI_XAXIS: 1044 case XI_THUMBLX: 1045 case XI_THUMBRX: 1046 default: 1047 decay = &xDecay[inputEvent.deviceInst]; 1048 lastClickTime = &xLastClickTime[inputEvent.deviceInst]; 1049 break; 1050 } 1051 1052 if (incomingValue < DEAD_ZONE) 1053 { 1054 // early out, control movement is within the deadzone 1055 *decay = 1.0f; 1056 *lastClickTime = 0; 1057 return false; 1058 } 1059 1060 // Rescales the input between 0.0 and 1.0 1061 incomingValue = (incomingValue - DEAD_ZONE) * (1.0f / (1.0f - DEAD_ZONE)); 1062 1063 F32 clickTime = MIN_CLICK_TIME + (MAX_CLICK_TIME - MIN_CLICK_TIME) * (1.0f - incomingValue); 1064 clickTime *= *decay; 1065 1066 if (clickTime < (curTime - *lastClickTime)) 1067 { 1068 *decay *= 0.9f; 1069 if (*decay < 0.2f) 1070 { 1071 *decay = 0.2f; 1072 } 1073 1074 *lastClickTime = curTime; 1075 1076 bool negative = (inputEvent.fValue < 0.0f); 1077 1078 switch (inputEvent.objInst) 1079 { 1080 case SI_ZAXIS: 1081 case SI_RZAXIS: 1082 return mFirstResponder->onGamepadTrigger(mLastEvent); 1083 1084 case SI_YAXIS: 1085 case SI_RYAXIS: 1086 if (!negative) 1087 { 1088 return mFirstResponder->onGamepadAxisDown(mLastEvent); 1089 } 1090 else 1091 { 1092 return mFirstResponder->onGamepadAxisUp(mLastEvent); 1093 } 1094 1095 case SI_XAXIS: 1096 case SI_RXAXIS: 1097 default: 1098 if (negative) 1099 { 1100 return mFirstResponder->onGamepadAxisLeft(mLastEvent); 1101 } 1102 else 1103 { 1104 return mFirstResponder->onGamepadAxisRight(mLastEvent); 1105 } 1106 } 1107 } 1108 } 1109 return false; 1110} 1111 1112void GuiCanvas::rootMouseDown(const GuiEvent &event) 1113{ 1114 mPrevMouseTime = Platform::getVirtualMilliseconds(); 1115 mMouseButtonDown = true; 1116 1117 //pass the event to the mouse locked control 1118 if (bool(mMouseCapturedControl)) 1119 mMouseCapturedControl->onMouseDown(event); 1120 else 1121 { 1122 //else pass it to whoever is underneath the cursor 1123 iterator i; 1124 i = end(); 1125 while (i != begin()) 1126 { 1127 i--; 1128 GuiControl *ctrl = static_cast<GuiControl *>(*i); 1129 GuiControl *controlHit = ctrl->findHitControl( event.mousePoint - ctrl->getPosition() ); 1130 1131 //see if the controlHit is a modeless dialog... 1132 if( !controlHit->getControlProfile()->mModal ) 1133 continue; 1134 else 1135 { 1136 controlHit->onMouseDown(event); 1137 break; 1138 } 1139 } 1140 } 1141 1142 if (bool(mMouseControl)) 1143 mMouseControlClicked = true; 1144} 1145 1146void GuiCanvas::findMouseControl(const GuiEvent &event) 1147{ 1148 // Any children at all? 1149 if(size() == 0) 1150 { 1151 mMouseControl = NULL; 1152 return; 1153 } 1154 1155 // Otherwise, check the point and find the overlapped control. 1156 GuiControl *controlHit = findHitControl(event.mousePoint); 1157 if(controlHit != static_cast<GuiControl*>(mMouseControl)) 1158 { 1159 if(bool(mMouseControl)) 1160 mMouseControl->onMouseLeave(event); 1161 mMouseControl = controlHit; 1162 mMouseControl->onMouseEnter(event); 1163 } 1164} 1165 1166void GuiCanvas::refreshMouseControl() 1167{ 1168 GuiEvent evt; 1169 evt.mousePoint.x = S32(mCursorPt.x); 1170 evt.mousePoint.y = S32(mCursorPt.y); 1171 findMouseControl(evt); 1172} 1173 1174void GuiCanvas::checkLockMouseMove( const GuiEvent& event ) 1175{ 1176 GuiControl* controlHit = findHitControl( event.mousePoint ); 1177 if( controlHit != mMouseControl ) 1178 { 1179 if( mMouseControl == mMouseCapturedControl ) 1180 mMouseCapturedControl->onMouseLeave( event ); 1181 else if( controlHit == mMouseCapturedControl ) 1182 mMouseCapturedControl->onMouseEnter( event ); 1183 1184 mMouseControl = controlHit; 1185 } 1186} 1187 1188void GuiCanvas::rootMouseUp(const GuiEvent &event) 1189{ 1190 mPrevMouseTime = Platform::getVirtualMilliseconds(); 1191 mMouseButtonDown = false; 1192 1193 // pass the event to the mouse locked control 1194 if (bool(mMouseCapturedControl)) 1195 { 1196 checkLockMouseMove( event ); 1197 mMouseCapturedControl->onMouseUp(event); 1198 } 1199 else 1200 { 1201 findMouseControl(event); 1202 if(bool(mMouseControl)) 1203 mMouseControl->onMouseUp(event); 1204 } 1205} 1206 1207void GuiCanvas::rootMouseDragged(const GuiEvent &event) 1208{ 1209 //pass the event to the mouse locked control 1210 if (bool(mMouseCapturedControl)) 1211 { 1212 checkLockMouseMove( event ); 1213 mMouseCapturedControl->onMouseDragged(event); 1214 } 1215 else 1216 { 1217 findMouseControl(event); 1218 if(bool(mMouseControl)) 1219 mMouseControl->onMouseDragged(event); 1220 } 1221} 1222 1223void GuiCanvas::rootMouseMove(const GuiEvent &event) 1224{ 1225 if (bool(mMouseCapturedControl)) 1226 { 1227 mMouseCapturedControl->onMouseMove(event); 1228 } 1229 else 1230 { 1231 findMouseControl(event); 1232 if(bool(mMouseControl)) 1233 mMouseControl->onMouseMove(event); 1234 } 1235} 1236 1237void GuiCanvas::rootRightMouseDown(const GuiEvent &event) 1238{ 1239 mPrevMouseTime = Platform::getVirtualMilliseconds(); 1240 mMouseRightButtonDown = true; 1241 1242 if (bool(mMouseCapturedControl)) 1243 { 1244 checkLockMouseMove( event ); 1245 mMouseCapturedControl->onRightMouseDown(event); 1246 } 1247 else 1248 { 1249 findMouseControl(event); 1250 1251 if(bool(mMouseControl)) 1252 { 1253 mMouseControl->onRightMouseDown(event); 1254 } 1255 } 1256} 1257 1258void GuiCanvas::rootRightMouseUp(const GuiEvent &event) 1259{ 1260 mPrevMouseTime = Platform::getVirtualMilliseconds(); 1261 mMouseRightButtonDown = false; 1262 1263 if (bool(mMouseCapturedControl)) 1264 mMouseCapturedControl->onRightMouseUp(event); 1265 else 1266 { 1267 findMouseControl(event); 1268 1269 if(bool(mMouseControl)) 1270 mMouseControl->onRightMouseUp(event); 1271 } 1272} 1273 1274void GuiCanvas::rootRightMouseDragged(const GuiEvent &event) 1275{ 1276 mPrevMouseTime = Platform::getVirtualMilliseconds(); 1277 1278 if (bool(mMouseCapturedControl)) 1279 { 1280 mMouseCapturedControl->onRightMouseDragged(event); 1281 } 1282 else 1283 { 1284 findMouseControl(event); 1285 1286 if(bool(mMouseControl)) 1287 mMouseControl->onRightMouseDragged(event); 1288 } 1289} 1290 1291void GuiCanvas::rootMiddleMouseDown(const GuiEvent &event) 1292{ 1293 mPrevMouseTime = Platform::getVirtualMilliseconds(); 1294 mMouseMiddleButtonDown = true; 1295 1296 if (bool(mMouseCapturedControl)) 1297 mMouseCapturedControl->onMiddleMouseDown(event); 1298 else 1299 { 1300 findMouseControl(event); 1301 1302 if(bool(mMouseControl)) 1303 { 1304 mMouseControl->onMiddleMouseDown(event); 1305 } 1306 } 1307} 1308 1309void GuiCanvas::rootMiddleMouseUp(const GuiEvent &event) 1310{ 1311 mPrevMouseTime = Platform::getVirtualMilliseconds(); 1312 mMouseMiddleButtonDown = false; 1313 1314 if (bool(mMouseCapturedControl)) 1315 mMouseCapturedControl->onMiddleMouseUp(event); 1316 else 1317 { 1318 findMouseControl(event); 1319 1320 if(bool(mMouseControl)) 1321 mMouseControl->onMiddleMouseUp(event); 1322 } 1323} 1324 1325void GuiCanvas::rootMiddleMouseDragged(const GuiEvent &event) 1326{ 1327 mPrevMouseTime = Platform::getVirtualMilliseconds(); 1328 1329 if (bool(mMouseCapturedControl)) 1330 { 1331 checkLockMouseMove( event ); 1332 mMouseCapturedControl->onMiddleMouseDragged(event); 1333 } 1334 else 1335 { 1336 findMouseControl(event); 1337 1338 if(bool(mMouseControl)) 1339 mMouseControl->onMiddleMouseDragged(event); 1340 } 1341} 1342 1343bool GuiCanvas::rootMouseWheelUp(const GuiEvent &event) 1344{ 1345 if (bool(mMouseCapturedControl)) 1346 return mMouseCapturedControl->onMouseWheelUp(event); 1347 else 1348 { 1349 findMouseControl(event); 1350 1351 if (bool(mMouseControl)) 1352 return mMouseControl->onMouseWheelUp(event); 1353 } 1354 1355 return false; 1356} 1357 1358bool GuiCanvas::rootMouseWheelDown(const GuiEvent &event) 1359{ 1360 if (bool(mMouseCapturedControl)) 1361 return mMouseCapturedControl->onMouseWheelDown(event); 1362 else 1363 { 1364 findMouseControl(event); 1365 1366 if (bool(mMouseControl)) 1367 return mMouseControl->onMouseWheelDown(event); 1368 } 1369 1370 return false; 1371} 1372 1373void GuiCanvas::setContentControl(GuiControl *gui) 1374{ 1375 // Skip out if we got passed NULL (why would that happen?) 1376 if(!gui) 1377 return; 1378 1379 GuiControl *oldContent = getContentControl(); 1380 if(oldContent) 1381 Con::executef(oldContent, "onUnsetContent", Con::getIntArg(gui->getId())); 1382 1383 //remove all dialogs on layer 0 1384 U32 index = 0; 1385 while (size() > index) 1386 { 1387 GuiControl *ctrl = static_cast<GuiControl*>((*this)[index]); 1388 if (ctrl == gui || ctrl->mLayer != 0) 1389 index++; 1390 1391 Sim::getGuiGroup()->addObject( ctrl ); 1392 } 1393 1394 // set current menu bar 1395 setMenuBar( mMenuBarCtrl ); 1396 1397 // lose the first responder from the old GUI 1398 GuiControl* responder = gui->findFirstTabable(); 1399 if(responder) 1400 responder->setFirstResponder(); 1401 1402 //add the gui to the front 1403 if(!size() || gui != (*this)[0]) 1404 { 1405 // automatically wakes objects in GuiControl::onWake 1406 addObject(gui); 1407 if (size() >= 2) 1408 reOrder(gui, *begin()); 1409 } 1410 //refresh the entire gui 1411 resetUpdateRegions(); 1412 1413 //rebuild the accelerator map 1414 mAcceleratorMap.clear(); 1415 1416 for(iterator i = end(); i != begin() ; ) 1417 { 1418 i--; 1419 GuiControl *ctrl = static_cast<GuiControl *>(*i); 1420 ctrl->buildAcceleratorMap(); 1421 1422 if (ctrl->getControlProfile()->mModal) 1423 break; 1424 } 1425 refreshMouseControl(); 1426 1427 // Force the canvas to update the sizing of the new content control 1428 maintainSizing(); 1429 1430 // Do this last so onWake gets called first 1431 Con::executef(gui, "onSetContent", Con::getIntArg(oldContent ? oldContent->getId() : 0)); 1432} 1433 1434GuiControl *GuiCanvas::getContentControl() 1435{ 1436 if(size() > 0) 1437 return (GuiControl *) first(); 1438 return NULL; 1439} 1440 1441void GuiCanvas::pushDialogControl(GuiControl *gui, S32 layer, bool center) 1442{ 1443 if( center ) 1444 gui->setPosition( getExtent().x / 2 - gui->getExtent().x / 2, 1445 getExtent().y / 2 - gui->getExtent().y / 2 ); 1446 1447 //add the gui 1448 gui->mLayer = layer; 1449 1450 // GuiControl::addObject wakes the object 1451 addObject(gui); 1452 1453 //reorder it to the correct layer 1454 iterator i; 1455 for (i = begin(); i != end(); i++) 1456 { 1457 GuiControl *ctrl = static_cast<GuiControl*>(*i); 1458 if (ctrl->mLayer > gui->mLayer) 1459 { 1460 reOrder(gui, ctrl); 1461 break; 1462 } 1463 } 1464 1465 //call the dialog push method 1466 gui->onDialogPush(); 1467 1468 //find the first responder 1469 GuiControl* responder = gui->findFirstTabable(); 1470 if(responder) 1471 responder->setFirstResponder(); 1472 1473 // call the 'onWake' method? 1474 //if(wakedGui) 1475 // Con::executef(gui, 1, "onWake"); 1476 1477 //refresh the entire gui 1478 resetUpdateRegions(); 1479 1480 //rebuild the accelerator map 1481 mAcceleratorMap.clear(); 1482 if (size() > 0) 1483 { 1484 GuiControl *ctrl = static_cast<GuiControl*>(last()); 1485 ctrl->buildAcceleratorMap(); 1486 } 1487 1488 refreshMouseControl(); 1489 1490 // I don't see the purpose of this, and it's causing issues when showing, for instance the 1491 // metrics dialog while in a 3d scene, causing the cursor to be shown even when the mouse 1492 // is locked [4/25/2007 justind] 1493 //if(gui->mProfile && gui->mProfile->mModal) 1494 // mPlatformWindow->getCursorController()->pushCursor(PlatformCursorController::curArrow); 1495} 1496 1497void GuiCanvas::popDialogControl(GuiControl *gui) 1498{ 1499 if (size() < 1) 1500 return; 1501 1502 //first, find the dialog, and call the "onDialogPop()" method 1503 GuiControl *ctrl = NULL; 1504 if (gui) 1505 { 1506 //make sure the gui really exists on the stack 1507 iterator i; 1508 bool found = false; 1509 for(i = begin(); i != end(); i++) 1510 { 1511 GuiControl *check = static_cast<GuiControl *>(*i); 1512 if (check == gui) 1513 { 1514 ctrl = check; 1515 found = true; 1516 } 1517 } 1518 1519 if (!found) 1520 return; 1521 } 1522 else 1523 ctrl = static_cast<GuiControl*>(last()); 1524 1525 //call the "on pop" function 1526 ctrl->onDialogPop(); 1527 1528 //now pop the last child (will sleep if awake) 1529 Sim::getGuiGroup()->addObject(ctrl); 1530 1531 if (size() > 0) 1532 { 1533 GuiControl *lastCtrl = static_cast<GuiControl *>(last()); 1534 if(lastCtrl->getFirstResponder() ) 1535 lastCtrl->getFirstResponder()->setFirstResponder(); 1536 } 1537 else 1538 { 1539 setFirstResponder(NULL); 1540 } 1541 1542 //refresh the entire gui 1543 resetUpdateRegions(); 1544 1545 //rebuild the accelerator map 1546 mAcceleratorMap.clear(); 1547 1548 if (size() > 0) 1549 { 1550 GuiControl *lastCtrl = static_cast<GuiControl*>(last()); 1551 lastCtrl->buildAcceleratorMap(); 1552 } 1553 refreshMouseControl(); 1554} 1555 1556void GuiCanvas::popDialogControl(S32 layer) 1557{ 1558 if (size() < 1) 1559 return; 1560 1561 GuiControl *ctrl = NULL; 1562 iterator i = end(); // find in z order (last to first) 1563 while (i != begin()) 1564 { 1565 i--; 1566 ctrl = static_cast<GuiControl*>(*i); 1567 if (ctrl->mLayer == layer) 1568 break; 1569 } 1570 if (ctrl) 1571 popDialogControl(ctrl); 1572} 1573 1574void GuiCanvas::mouseLock(GuiControl *lockingControl) 1575{ 1576 if (bool(mMouseCapturedControl)) 1577 return; 1578 1579 mMouseCapturedControl = lockingControl; 1580 1581 if(mMouseControl && mMouseControl != mMouseCapturedControl) 1582 { 1583 GuiEvent evt; 1584 evt.mousePoint.x = S32(mCursorPt.x); 1585 evt.mousePoint.y = S32(mCursorPt.y); 1586 1587 mMouseControl->onMouseLeave(evt); 1588 } 1589} 1590 1591void GuiCanvas::mouseUnlock(GuiControl *lockingControl) 1592{ 1593 if (static_cast<GuiControl*>(mMouseCapturedControl) != lockingControl) 1594 return; 1595 1596 GuiEvent evt; 1597 evt.mousePoint.x = S32(mCursorPt.x); 1598 evt.mousePoint.y = S32(mCursorPt.y); 1599 1600 GuiControl * controlHit = findHitControl(evt.mousePoint); 1601 if(controlHit != mMouseCapturedControl) 1602 { 1603 mMouseControl = controlHit; 1604 mMouseControlClicked = false; 1605 if(bool(mMouseControl)) 1606 mMouseControl->onMouseEnter(evt); 1607 } 1608 mMouseCapturedControl = NULL; 1609} 1610 1611void GuiCanvas::paint() 1612{ 1613 resetUpdateRegions(); 1614 1615 // inhibit explicit refreshes in the case we're swapped out 1616 if( mPlatformWindow && mPlatformWindow->isVisible() && GFX->allowRender()) 1617 mPlatformWindow->displayEvent.trigger(mPlatformWindow->getWindowId()); 1618} 1619 1620void GuiCanvas::repaint(U32 elapsedMS) 1621{ 1622 // Make sure we have a window. 1623 if ( !mPlatformWindow ) 1624 return; 1625 1626 // Has enough time elapsed? 1627 U32 elapsed = Platform::getRealMilliseconds() - mLastRenderMs; 1628 if (elapsed < elapsedMS) 1629 return; 1630 1631 // Do the render. 1632 resetUpdateRegions(); 1633 handlePaintEvent(mPlatformWindow->getWindowId()); 1634} 1635 1636void GuiCanvas::maintainSizing() 1637{ 1638 Point2I size = getWindowSize(); 1639 1640 if(size.x == -1 || size.y == -1) 1641 return; 1642 1643 RectI screenRect(0, 0, size.x, size.y); 1644 setBounds(screenRect); 1645 1646 // all bottom level controls should be the same dimensions as the canvas 1647 // this is necessary for passing mouse events accurately 1648 iterator i; 1649 for (i = begin(); i != end(); i++) 1650 { 1651 AssertFatal(static_cast<GuiControl*>((*i))->isAwake(), "GuiCanvas::maintainSizing - ctrl is not awake"); 1652 GuiControl *ctrl = static_cast<GuiControl*>(*i); 1653 Point2I ext = ctrl->getExtent(); 1654 Point2I pos = ctrl->getPosition(); 1655 Point2I newExt = screenRect.extent; 1656 Point2I newPos = screenRect.point; 1657 1658 // if menubar is active displace content gui control 1659 if (mMenuBarCtrl && (ctrl == getContentControl())) 1660 { 1661 /*const SimObject *menu = mMenuBarCtrl->findObjectByInternalName( StringTable->insert("menubar"), true); 1662 1663 if( !menu ) 1664 continue; 1665 1666 AssertFatal( dynamic_cast<const GuiControl*>(menu), "");*/ 1667 1668 const U32 yOffset = static_cast<const GuiMenuBar*>(mMenuBarCtrl)->mMenubarHeight; 1669 newPos.y += yOffset; 1670 newExt.y -= yOffset; 1671 } 1672 1673 if (pos != newPos || ext != newExt) 1674 { 1675 ctrl->resize(newPos, newExt); 1676 resetUpdateRegions(); 1677 } 1678 } 1679} 1680 1681void GuiCanvas::setupFences() 1682{ 1683 // Destroy old fences 1684 SAFE_DELETE_ARRAY( mFences ); 1685 1686 // Now create the new ones 1687 if( mNumFences > 0 ) 1688 { 1689 mFences = new GFXFence*[mNumFences]; 1690 1691 // Allocate the new fences 1692 for( S32 i = 0; i < mNumFences; i++ ) 1693 mFences[i] = GFX->createFence(); 1694 } 1695 1696 // Reset state 1697 mNextFenceIdx = 0; 1698} 1699 1700void GuiCanvas::renderFrame(bool preRenderOnly, bool bufferSwap /* = true */) 1701{ 1702 AssertISV(mPlatformWindow, "GuiCanvas::renderFrame - no window present!"); 1703 if(!mPlatformWindow->isVisible() || !GFX->allowRender() || GFX->canCurrentlyRender()) 1704 return; 1705 1706 PROFILE_START(CanvasPreRender); 1707 1708 // Set our window as the current render target so we can see outputs. 1709 GFX->setActiveRenderTarget(mPlatformWindow->getGFXTarget()); 1710 1711 if (!GFX->getActiveRenderTarget()) 1712 { 1713 PROFILE_END(); 1714 return; 1715 } 1716 1717#ifdef TORQUE_GFX_STATE_DEBUG 1718 GFX->getDebugStateManager()->startFrame(); 1719#endif 1720 1721 GFXTarget* renderTarget = GFX->getActiveRenderTarget(); 1722 if (renderTarget == NULL) 1723 { 1724 PROFILE_END(); 1725 return; 1726 } 1727 1728 // Make sure the root control is the size of the canvas. 1729 Point2I size = renderTarget->getSize(); 1730 1731 if(size.x == 0 || size.y == 0) 1732 { 1733 PROFILE_END(); 1734 return; 1735 } 1736 1737 RectI screenRect(0, 0, size.x, size.y); 1738 1739 maintainSizing(); 1740 1741 //preRender (recursive) all controls 1742 preRender(); 1743 1744 PROFILE_END(); 1745 1746 // Are we just doing pre-render? 1747 if(preRenderOnly) 1748 return; 1749 1750 // Signal the interested parties. 1751 GuiCanvas::getGuiCanvasFrameSignal().trigger(true); 1752 1753 // Gross hack to make sure we don't end up with advanced lighting and msaa 1754 // at the same time, which causes artifacts. At the same time we don't 1755 // want to just throw the settings the user has chosen if the light manager 1756 // changes at a later time. 1757 1758 GFXVideoMode mode = mPlatformWindow->getVideoMode(); 1759 if ( dStricmp( LIGHTMGR->getId(), "ADVLM" ) == 0 && mode.antialiasLevel > 0 ) 1760 { 1761 const char *pref = Con::getVariable( "$pref::Video::mode" ); 1762 mode.parseFromString( pref ); 1763 mode.antialiasLevel = 0; 1764 mPlatformWindow->setVideoMode(mode); 1765 1766 Con::printf( "AntiAliasing has been disabled; it is not compatible with AdvancedLighting." ); 1767 } 1768 else if ( dStricmp( LIGHTMGR->getId(), "BLM" ) == 0) 1769 { 1770 const char *pref = Con::getVariable( "$pref::Video::mode" ); 1771 1772 U32 prefAA = dAtoi( StringUnit::getUnit(pref, 5, " ") ); 1773 if ( prefAA != mode.antialiasLevel ) 1774 { 1775 mode.parseFromString( pref ); 1776 mPlatformWindow->setVideoMode(mode); 1777 1778 Con::printf( "AntiAliasing has been enabled while running BasicLighting." ); 1779 } 1780 } 1781 1782 // for now, just always reset the update regions - this is a 1783 // fix for FSAA on ATI cards 1784 resetUpdateRegions(); 1785 1786 PROFILE_START(CanvasRenderControls); 1787 1788 // Draw the mouse 1789 GuiCursor *mouseCursor = NULL; 1790 bool cursorVisible = true; 1791 1792 if(bool(mMouseCapturedControl)) 1793 mMouseCapturedControl->getCursor(mouseCursor, cursorVisible, mLastEvent); 1794 else if(bool(mMouseControl)) 1795 mMouseControl->getCursor(mouseCursor, cursorVisible, mLastEvent); 1796 1797 Point2I cursorPos((S32)mCursorPt.x, (S32)mCursorPt.y); 1798 if(!mouseCursor) 1799 mouseCursor = mDefaultCursor; 1800 1801 if(mLastCursorEnabled && mLastCursor) 1802 { 1803 Point2I spot = mLastCursor->getHotSpot(); 1804 Point2I cext = mLastCursor->getExtent(); 1805 Point2I pos = mLastCursorPt - spot; 1806 addUpdateRegion(pos - Point2I(2, 2), Point2I(cext.x + 4, cext.y + 4)); 1807 } 1808 1809 if(cursorVisible && mouseCursor) 1810 { 1811 Point2I spot = mouseCursor->getHotSpot(); 1812 Point2I cext = mouseCursor->getExtent(); 1813 Point2I pos = cursorPos - spot; 1814 1815 addUpdateRegion(pos - Point2I(2, 2), Point2I(cext.x + 4, cext.y + 4)); 1816 } 1817 1818 mLastCursorEnabled = cursorVisible; 1819 mLastCursor = mouseCursor; 1820 mLastCursorPt = cursorPos; 1821 1822 // Begin GFX 1823 PROFILE_START(GFXBeginScene); 1824 1825 bool beginSceneRes = GFX->beginScene(); 1826 1827 PROFILE_END(); 1828 1829 // Render all offscreen canvas objects here since we may need them in the render loop 1830 if (GuiOffscreenCanvas::sList.size() != 0) 1831 { 1832 // Reset the entire state since oculus shit will have barfed it. 1833 1834 GFX->updateStates(true); 1835 1836 for (Vector<GuiOffscreenCanvas*>::iterator itr = GuiOffscreenCanvas::sList.begin(); itr != GuiOffscreenCanvas::sList.end(); itr++) 1837 { 1838 (*itr)->renderFrame(false, false); 1839 } 1840 1841 GFX->setActiveRenderTarget(renderTarget); 1842 } 1843 1844 // Can't render if waiting for device to reset. 1845 if ( !beginSceneRes ) 1846 { 1847 PROFILE_END(); // CanvasRenderControls 1848 1849 // Since we already triggered the signal once for begin-of-frame, 1850 // we should be consistent and trigger it again for end-of-frame. 1851 GuiCanvas::getGuiCanvasFrameSignal().trigger(false); 1852 1853 return; 1854 } 1855 1856 // Clear the current viewport area 1857 GFX->setViewport( screenRect ); 1858 GFX->clear( GFXClearZBuffer | GFXClearStencil | GFXClearTarget, gCanvasClearColor, 1.0f, 0 ); 1859 1860 resetUpdateRegions(); 1861 1862 // Make sure we have a clean matrix state 1863 // before we start rendering anything! 1864 GFX->setWorldMatrix( MatrixF::Identity ); 1865 GFX->setViewMatrix( MatrixF::Identity ); 1866 GFX->setProjectionMatrix( MatrixF::Identity ); 1867 1868 // If we're taking a screenshot then let it have 1869 // a chance at altering the view matrix. 1870 if ( gScreenShot && gScreenShot->isPending() ) 1871 gScreenShot->tileGui( size ); 1872 1873 RectI updateUnion; 1874 buildUpdateUnion(&updateUnion); 1875 if (updateUnion.intersect(screenRect)) 1876 { 1877 // Render active GUI Dialogs 1878 for(iterator i = begin(); i != end(); i++) 1879 { 1880 // Get the control 1881 GuiControl *contentCtrl = static_cast<GuiControl*>(*i); 1882 1883 GFX->setClipRect( updateUnion ); 1884 GFX->setStateBlock(mDefaultGuiSB); 1885 1886 contentCtrl->onRender(contentCtrl->getPosition(), updateUnion); 1887 } 1888 1889 // Fill Black if no Dialogs 1890 if(this->size() == 0) 1891 GFX->clear( GFXClearTarget, ColorI(0,0,0,0), 1.0f, 0 ); 1892 1893 // Tooltip resource 1894 if(bool(mMouseControl)) 1895 { 1896 U32 curTime = Platform::getRealMilliseconds(); 1897 if(mHoverControl == mMouseControl) 1898 { 1899 if(mHoverPositionSet || (curTime - mHoverControlStart) >= mHoverControl->mTipHoverTime || (curTime - mHoverLeftControlTime) <= mHoverControl->mTipHoverTime) 1900 { 1901 if(!mHoverPositionSet) 1902 { 1903 mHoverPosition = cursorPos; 1904 } 1905 mHoverPositionSet = mMouseControl->mRenderTooltipDelegate( mHoverPosition, cursorPos, NULL ); 1906 } 1907 1908 } 1909 else 1910 { 1911 if(mHoverPositionSet) 1912 { 1913 mHoverLeftControlTime = curTime; 1914 mHoverPositionSet = false; 1915 } 1916 mHoverControl = mMouseControl; 1917 mHoverControlStart = curTime; 1918 } 1919 } 1920 1921 GFX->setClipRect( updateUnion ); 1922 1923 // Draw an ugly box if we don't have a cursor available... 1924 //if (mCursorEnabled && mShowCursor && !mouseCursor) 1925 //{ 1926 // GFX->drawRectFill( RectI( mCursorPt.x, mCursorPt.y, mCursorPt.x + 2, mCursorPt.y + 2 ), ColorI( 255, 0, 0 ) ); 1927 //} 1928 1929 1930 // CodeReview - Make sure our bitmap modulation is clear or else there's a black modulation 1931 // that ruins rendering of textures at startup.. This was done in mouseCursor 1932 // onRender and so at startup when it wasn't called the modulation was black, ruining 1933 // the loading screen display. This fixes the issue, but is it only masking a deeper issue 1934 // in GFX with regard to gui rendering? [5/3/2007 justind] 1935 GFX->getDrawUtil()->clearBitmapModulation(); 1936 1937 // Really draw the cursor. :) 1938 // Only if the platform cursor controller is missing or the platform cursor 1939 // isn't visible. 1940 if (!mPlatformWindow->getCursorController() || (mCursorEnabled && mouseCursor && mShowCursor && 1941 !mPlatformWindow->getCursorController()->isCursorVisible())) 1942 { 1943 Point2I pos((S32)mCursorPt.x, (S32)mCursorPt.y); 1944 Point2I spot = mouseCursor->getHotSpot(); 1945 1946 pos -= spot; 1947 mouseCursor->render(pos); 1948 } 1949 } 1950 1951 // Render all RTT end of frame updates HERE 1952 //DynamicTexture::updateScreenTextures(); 1953 //DynamicTexture::updateEndOfFrameTextures(); 1954 // mPending is set when the console function "screenShot()" is called 1955 // this situation is necessary because it needs to take the screenshot 1956 // before the buffers swap 1957 1958 PROFILE_END(); 1959 1960 // Fence logic here, because this is where endScene is called. 1961 if( mNumFences > 0 ) 1962 { 1963 // Issue next fence 1964 mFences[mNextFenceIdx]->issue(); 1965 1966 mNextFenceIdx++; 1967 1968 // Wrap the next fence around to first if we're maxxed 1969 if( mNextFenceIdx >= mNumFences ) 1970 mNextFenceIdx = 0; 1971 1972 // Block on previous fence 1973 mFences[mNextFenceIdx]->block(); 1974 } 1975 1976 PROFILE_START(GFXEndScene); 1977 GFX->endScene(); 1978 PROFILE_END(); 1979 1980 GFX->getDeviceEventSignal().trigger( GFXDevice::dePostFrame ); 1981 swapBuffers(); 1982 1983 GuiCanvas::getGuiCanvasFrameSignal().trigger(false); 1984 1985#ifdef TORQUE_GFX_STATE_DEBUG 1986 GFX->getDebugStateManager()->endFrame(); 1987#endif 1988 1989 // Keep track of the last time we rendered. 1990 mLastRenderMs = Platform::getRealMilliseconds(); 1991} 1992 1993GuiCanvas::GuiCanvasFrameSignal& GuiCanvas::getGuiCanvasFrameSignal() 1994{ 1995 static GuiCanvasFrameSignal theSignal; 1996 return theSignal; 1997} 1998 1999void GuiCanvas::swapBuffers() 2000{ 2001 AssertISV(mPlatformWindow, "GuiCanvas::swapBuffers - no window present!"); 2002 if(!mPlatformWindow->isVisible()) 2003 return; 2004 2005 PROFILE_START(SwapBuffers); 2006 mPlatformWindow->getGFXTarget()->present(); 2007 PROFILE_END(); 2008} 2009 2010void GuiCanvas::buildUpdateUnion(RectI *updateUnion) 2011{ 2012 *updateUnion = mOldUpdateRects[0]; 2013 2014 //the update region should encompass the oldUpdateRects, and the curUpdateRect 2015 Point2I upperL; 2016 Point2I lowerR; 2017 2018 upperL.x = getMin(mOldUpdateRects[0].point.x, mOldUpdateRects[1].point.x); 2019 upperL.x = getMin(upperL.x, mCurUpdateRect.point.x); 2020 2021 upperL.y = getMin(mOldUpdateRects[0].point.y, mOldUpdateRects[1].point.y); 2022 upperL.y = getMin(upperL.y, mCurUpdateRect.point.y); 2023 2024 lowerR.x = getMax(mOldUpdateRects[0].point.x + mOldUpdateRects[0].extent.x, mOldUpdateRects[1].point.x + mOldUpdateRects[1].extent.x); 2025 lowerR.x = getMax(lowerR.x, mCurUpdateRect.point.x + mCurUpdateRect.extent.x); 2026 2027 lowerR.y = getMax(mOldUpdateRects[0].point.y + mOldUpdateRects[0].extent.y, mOldUpdateRects[1].point.y + mOldUpdateRects[1].extent.y); 2028 lowerR.y = getMax(lowerR.y, mCurUpdateRect.point.y + mCurUpdateRect.extent.y); 2029 2030 updateUnion->point = upperL; 2031 updateUnion->extent = lowerR - upperL; 2032 2033 //shift the oldUpdateRects 2034 mOldUpdateRects[0] = mOldUpdateRects[1]; 2035 mOldUpdateRects[1] = mCurUpdateRect; 2036 2037 mCurUpdateRect.point.set(0,0); 2038 mCurUpdateRect.extent.set(0,0); 2039} 2040 2041void GuiCanvas::addUpdateRegion(Point2I pos, Point2I ext) 2042{ 2043 if(mCurUpdateRect.extent.x == 0) 2044 { 2045 mCurUpdateRect.point = pos; 2046 mCurUpdateRect.extent = ext; 2047 } 2048 else 2049 { 2050 Point2I upperL; 2051 upperL.x = getMin(mCurUpdateRect.point.x, pos.x); 2052 upperL.y = getMin(mCurUpdateRect.point.y, pos.y); 2053 Point2I lowerR; 2054 lowerR.x = getMax(mCurUpdateRect.point.x + mCurUpdateRect.extent.x, pos.x + ext.x); 2055 lowerR.y = getMax(mCurUpdateRect.point.y + mCurUpdateRect.extent.y, pos.y + ext.y); 2056 mCurUpdateRect.point = upperL; 2057 mCurUpdateRect.extent = lowerR - upperL; 2058 } 2059} 2060 2061void GuiCanvas::resetUpdateRegions() 2062{ 2063 //DEBUG - get surface width and height 2064 mOldUpdateRects[0] = getBounds(); 2065 mOldUpdateRects[1] = mOldUpdateRects[0]; 2066 mCurUpdateRect = mOldUpdateRects[0]; 2067} 2068 2069void GuiCanvas::setFirstResponder( GuiControl* newResponder ) 2070{ 2071 GuiControl* oldResponder = mFirstResponder; 2072 Parent::setFirstResponder( newResponder ); 2073 2074 if( oldResponder == mFirstResponder ) 2075 return; 2076 2077 if( oldResponder && ( oldResponder != newResponder ) ) 2078 oldResponder->onLoseFirstResponder(); 2079 2080 if( newResponder && ( newResponder != oldResponder ) ) 2081 newResponder->onGainFirstResponder(); 2082} 2083 2084DefineEngineMethod( GuiCanvas, getContent, S32, (),, 2085 "@brief Get the GuiControl which is being used as the content.\n\n" 2086 2087 "@tsexample\n" 2088 "Canvas.getContent();\n" 2089 "@endtsexample\n\n" 2090 2091 "@return ID of current content control") 2092{ 2093 GuiControl *ctrl = object->getContentControl(); 2094 if(ctrl) 2095 return ctrl->getId(); 2096 return -1; 2097} 2098 2099DefineEngineMethod( GuiCanvas, setContent, void, (GuiControl* ctrl),, 2100 "@brief Set the content of the canvas to a specified control.\n\n" 2101 2102 "@param ctrl ID or name of GuiControl to set content to\n\n" 2103 2104 "@tsexample\n" 2105 "Canvas.setContent(PlayGui);\n" 2106 "@endtsexample\n\n") 2107{ 2108 // Not using old error reporting until we modify the engineAPI - mperry 2109 2110 //GuiControl *gui = NULL; 2111 // if(argv[2][0]) 2112 // { 2113 // if (!Sim::findObject(argv[2], gui)) 2114 // { 2115 // Con::printf("%s(): Invalid control: %s", argv[0], argv[2]); 2116 // return; 2117 // } 2118 // } 2119 2120 if(!ctrl) 2121 { 2122 Con::errorf("GuiCanvas::setContent - Invalid control specified')"); 2123 return; 2124 } 2125 2126 //set the new content control 2127 object->setContentControl(ctrl); 2128} 2129 2130ConsoleDocFragment _pushDialog( 2131 "@brief Adds a dialog control onto the stack of dialogs\n\n" 2132 "@param ctrl Dialog to add\n" 2133 "@param layer Layer to put dialog on (optional)\n" 2134 "@param center True to center dialog on canvas (optional)\n\n" 2135 "@tsexample\n" 2136 "Canvas.pushDialog(RecordingsDlg);\n" 2137 "@endtsexample\n\n", 2138 "GuiCanvas", 2139 "void pushDialog( GuiControl ctrl, int layer=0, bool center=false);" 2140); 2141 2142DefineEngineMethod( GuiCanvas, pushDialog, void, (const char * ctrlName, S32 layer, bool center), ( 0, false), "(GuiControl ctrl, int layer=0, bool center=false)" 2143 "@hide") 2144{ 2145 GuiControl *gui; 2146 2147 if (! Sim::findObject(ctrlName, gui)) 2148 { 2149 Con::printf("pushDialog(): Invalid control: %s", ctrlName); 2150 return; 2151 } 2152 2153 //find the layer 2154 2155 //set the new content control 2156 object->pushDialogControl(gui, layer, center); 2157} 2158 2159ConsoleDocFragment _popDialog1( 2160 "@brief Removes a specific dialog control\n\n" 2161 "@param ctrl Dialog to pop\n" 2162 "@tsexample\n" 2163 "Canvas.popDialog(RecordingsDlg);\n" 2164 "@endtsexample\n\n", 2165 "GuiCanvas", 2166 "void popDialog( GuiControl ctrl);" 2167); 2168 2169ConsoleDocFragment _popDialog2( 2170 "@brief Removes a dialog at the front most layer\n\n" 2171 "@tsexample\n" 2172 "// Pops whatever is on layer 0\n" 2173 "Canvas.popDialog();\n" 2174 "@endtsexample\n\n", 2175 "GuiCanvas", 2176 "void popDialog();" 2177); 2178 2179DefineEngineMethod( GuiCanvas, popDialog, void, (GuiControl * gui), (nullAsType<GuiControl*>()), "(GuiControl ctrl=NULL)" 2180 "@hide") 2181{ 2182 if (gui) 2183 object->popDialogControl(gui); 2184 else 2185 object->popDialogControl(); 2186} 2187 2188ConsoleDocFragment _popLayer1( 2189 "@brief Removes the top most layer of dialogs\n\n" 2190 "@tsexample\n" 2191 "Canvas.popLayer();\n" 2192 "@endtsexample\n\n", 2193 "GuiCanvas", 2194 "void popLayer();" 2195); 2196 2197ConsoleDocFragment _popLayer2( 2198 "@brief Removes a specified layer of dialogs\n\n" 2199 "@param layer Number of the layer to pop\n\n" 2200 "@tsexample\n" 2201 "Canvas.popLayer(1);\n" 2202 "@endtsexample\n\n", 2203 "GuiCanvas", 2204 "void popLayer(S32 layer);" 2205); 2206 2207DefineEngineMethod( GuiCanvas, popLayer, void, (S32 layer), (0), "(int layer)" 2208 "@hide") 2209{ 2210 2211 object->popDialogControl(layer); 2212} 2213 2214DefineEngineMethod( GuiCanvas, cursorOn, void, (),, 2215 "@brief Turns on the mouse cursor.\n\n" 2216 "@tsexample\n" 2217 "Canvas.cursorOn();\n" 2218 "@endtsexample\n\n") 2219{ 2220 object->setCursorON(true); 2221} 2222 2223DefineEngineMethod( GuiCanvas, cursorOff, void, (),, 2224 "@brief Turns on the mouse off.\n\n" 2225 "@tsexample\n" 2226 "Canvas.cursorOff();\n" 2227 "@endtsexample\n\n") 2228{ 2229 object->setCursorON(false); 2230} 2231 2232 2233DefineEngineMethod( GuiCanvas, setCursor, void, (GuiCursor* cursor),, 2234 "@brief Sets the cursor for the canvas.\n\n" 2235 2236 "@param cursor Name of the GuiCursor to use\n\n" 2237 2238 "@tsexample\n" 2239 "Canvas.setCursor(\"DefaultCursor\");\n" 2240 "@endtsexample\n\n") 2241{ 2242 if(!cursor) 2243 { 2244 Con::errorf("GuiCanvas::setCursor - Invalid GuiCursor name or ID"); 2245 return; 2246 } 2247 object->setCursor(cursor); 2248} 2249 2250DefineEngineMethod( GuiCanvas, renderFront, void, ( bool enable ),, 2251 "@brief This turns on/off front-buffer rendering.\n\n" 2252 2253 "@param enable True if all rendering should be done to the front buffer\n\n" 2254 2255 "@tsexample\n" 2256 "Canvas.renderFront(false);\n" 2257 "@endtsexample\n\n") 2258{ 2259 object->setRenderFront(enable); 2260} 2261 2262DefineEngineMethod( GuiCanvas, showCursor, void, (),, 2263 "@brief Enable rendering of the cursor.\n\n" 2264 2265 "@tsexample\n" 2266 "Canvas.showCursor();\n" 2267 "@endtsexample\n\n") 2268{ 2269 object->showCursor(true); 2270} 2271 2272DefineEngineMethod( GuiCanvas, hideCursor, void, (),, 2273 "@brief Disable rendering of the cursor.\n\n" 2274 2275 "@tsexample\n" 2276 "Canvas.hideCursor();\n" 2277 "@endtsexample\n\n") 2278{ 2279 object->showCursor(false); 2280} 2281 2282DefineEngineMethod( GuiCanvas, isCursorOn, bool, (),, 2283 "@brief Determines if mouse cursor is enabled.\n\n" 2284 2285 "@tsexample\n" 2286 "// Is cursor on?\n" 2287 "if(Canvas.isCursorOn())\n" 2288 " echo(\"Canvas cursor is on\");\n" 2289 "@endtsexample\n\n" 2290 "@return Returns true if the cursor is on.\n\n") 2291{ 2292 return object->isCursorON(); 2293} 2294 2295DefineEngineMethod( GuiCanvas, isCursorShown, bool, (),, 2296 "@brief Determines if mouse cursor is rendering.\n\n" 2297 2298 "@tsexample\n" 2299 "// Is cursor rendering?\n" 2300 "if(Canvas.isCursorShown())\n" 2301 " echo(\"Canvas cursor is rendering\");\n" 2302 "@endtsexample\n\n" 2303 "@return Returns true if the cursor is rendering.\n\n") 2304{ 2305 return object->isCursorShown(); 2306} 2307 2308DefineEngineMethod( GuiCanvas, repaint, void, ( S32 elapsedMS ), (0), 2309 "@brief Force canvas to redraw.\n" 2310 "If the elapsed time is greater than the time since the last paint " 2311 "then the repaint will be skipped.\n" 2312 "@param elapsedMS The optional elapsed time in milliseconds.\n\n" 2313 2314 "@tsexample\n" 2315 "Canvas.repaint();\n" 2316 "@endtsexample\n\n") 2317{ 2318 object->repaint(elapsedMS < 0 ? 0 : elapsedMS); 2319} 2320 2321DefineEngineMethod( GuiCanvas, reset, void, (),, 2322 "@brief Reset the update regions for the canvas.\n\n" 2323 2324 "@tsexample\n" 2325 "Canvas.reset();\n" 2326 "@endtsexample\n\n") 2327{ 2328 object->resetUpdateRegions(); 2329} 2330 2331DefineEngineMethod( GuiCanvas, getCursorPos, Point2I, (),, 2332 "@brief Get the current position of the cursor in screen-space. Note that this position" 2333 " might be outside the Torque window. If you want to get the position within the Canvas," 2334 " call screenToClient on the result.\n\n" 2335 "@see Canvas::screenToClient()\n\n" 2336 "@param param Description\n\n" 2337 "@tsexample\n" 2338 "%cursorPos = Canvas.getCursorPos();\n" 2339 "@endtsexample\n\n" 2340 "@return Screen coordinates of mouse cursor, in format \"X Y\"") 2341{ 2342 return object->getCursorPos(); 2343} 2344 2345ConsoleDocFragment _setCursorPos1( 2346 "@brief Sets the position of the cursor\n\n" 2347 "@param pos Point, in screenspace for the cursor. Formatted as (\"x y\")\n\n" 2348 "@tsexample\n" 2349 "Canvas.setCursorPos(\"0 0\");\n" 2350 "@endtsexample\n\n", 2351 "GuiCanvas", 2352 "bool setCursorPos( Point2I pos );" 2353); 2354ConsoleDocFragment _setCursorPos2( 2355 "@brief Sets the position of the cursor\n\n" 2356 "@param posX X-coordinate, in screenspace for the cursor.\n" 2357 "@param posY Y-coordinate, in screenspace for the cursor.\n\n" 2358 "@tsexample\n" 2359 "Canvas.setCursorPos(0,0);\n" 2360 "@endtsexample\n\n", 2361 "GuiCanvas", 2362 "bool setCursorPos( F32 posX, F32 posY);" 2363); 2364 2365DefineEngineMethod( GuiCanvas, setCursorPos, void, (Point2I pos), , "(Point2I pos)" 2366 "@hide") 2367{ 2368 2369 object->setCursorPos(pos); 2370} 2371 2372DefineEngineMethod( GuiCanvas, getMouseControl, S32, (),, 2373 "@brief Gets the gui control under the mouse.\n\n" 2374 "@tsexample\n" 2375 "%underMouse = Canvas.getMouseControl();\n" 2376 "@endtsexample\n\n" 2377 2378 "@return ID of the gui control, if one was found. NULL otherwise") 2379{ 2380 GuiControl* control = object->getMouseControl(); 2381 if (control) 2382 return control->getId(); 2383 2384 return NULL; 2385} 2386 2387DefineEngineFunction(excludeOtherInstance, bool, (const char* appIdentifer),, 2388 "@brief Used to exclude/prevent all other instances using the same identifier specified\n\n" 2389 2390 "@note Not used on OSX, Xbox, or in Win debug builds\n\n" 2391 2392 "@param appIdentifier Name of the app set up for exclusive use.\n" 2393 2394 "@return False if another app is running that specified the same appIdentifier\n\n" 2395 2396 "@ingroup Platform\n" 2397 "@ingroup GuiCore") 2398{ 2399 // mac can only run one instance in general. 2400#if !defined(TORQUE_OS_MAC) && !defined(TORQUE_DEBUG) && !defined(TORQUE_OS_LINUX) 2401 return Platform::excludeOtherInstances(appIdentifer); 2402#else 2403 // We can just return true if we get here. 2404 return true; 2405#endif 2406} 2407 2408DefineEngineMethod( GuiCanvas, getExtent, Point2I, (),, 2409 "@brief Returns the dimensions of the canvas\n\n" 2410 2411 "@tsexample\n" 2412 "%extent = Canvas.getExtent();\n" 2413 "@endtsexample\n\n" 2414 2415 "@return Width and height of canvas. Formatted as numerical values in a single string \"# #\"") 2416{ 2417 return object->getExtent(); 2418} 2419 2420 2421DefineEngineMethod( GuiCanvas, setWindowTitle, void, ( const char* newTitle),, 2422 "@brief Change the title of the OS window.\n\n" 2423 2424 "@param newTitle String containing the new name\n\n" 2425 2426 "@tsexample\n" 2427 "Canvas.setWindowTitle(\"Documentation Rocks!\");\n" 2428 "@endtsexample\n\n") 2429{ 2430 object->setWindowTitle(newTitle); 2431} 2432 2433 2434DefineEngineMethod( GuiCanvas, findFirstMatchingMonitor, S32, (const char* name),, 2435 "@brief Find the first monitor index that matches the given name.\n\n" 2436 "The actual match algorithm depends on the implementation.\n" 2437 "@param name The name to search for.\n\n" 2438 "@return The number of monitors attached to the system, including the default monoitor.") 2439{ 2440 return PlatformWindowManager::get()->findFirstMatchingMonitor(name); 2441} 2442 2443DefineEngineMethod( GuiCanvas, getMonitorCount, S32, (),, 2444 "@brief Gets the number of monitors attached to the system.\n\n" 2445 2446 "@return The number of monitors attached to the system, including the default monoitor.") 2447{ 2448 return PlatformWindowManager::get()->getMonitorCount(); 2449} 2450 2451DefineEngineMethod( GuiCanvas, getMonitorName, const char*, (S32 index),, 2452 "@brief Gets the name of the requested monitor.\n\n" 2453 "@param index The monitor index.\n\n" 2454 "@return The name of the requested monitor.") 2455{ 2456 return PlatformWindowManager::get()->getMonitorName(index); 2457} 2458 2459DefineEngineMethod( GuiCanvas, getMonitorRect, RectI, (S32 index),, 2460 "@brief Gets the region of the requested monitor.\n\n" 2461 "@param index The monitor index.\n\n" 2462 "@return The rectangular region of the requested monitor.") 2463{ 2464 return PlatformWindowManager::get()->getMonitorRect(index); 2465} 2466 2467DefineEngineMethod( GuiCanvas, getMonitorUsableRect, RectI, (S32 index),, 2468 "@brief Use this function to get the usable desktop area represented by a display, with the primary display located at 0,0.\n\n" 2469 "This is the same area as Canvas.getMonitorRect() reports, but with portions reserved by the system removed. " 2470 "For example, on Apple Mac OS X, this subtracts the area occupied by the menu bar and dock.\n" 2471 "Setting a window to be fullscreen generally bypasses these unusable areas, so these are good guidelines for " 2472 "the maximum space available to a non - fullscreen window." 2473 "@param index The monitor index.\n\n" 2474 "@return The rectangular region of the requested monitor.") 2475{ 2476 return PlatformWindowManager::get()->getMonitorUsableRect(index); 2477} 2478 2479DefineEngineMethod(GuiCanvas, getMonitorModeCount, S32, (S32 monitorIndex), (0), 2480 "Gets the number of video modes available on the selected monitor.\n\n") 2481{ 2482 return PlatformWindowManager::get()->getMonitorModeCount(monitorIndex); 2483} 2484DefineEngineMethod(GuiCanvas, getMonitorMode, const char*, (S32 monitorIndex, S32 modeIndex), (0), 2485 "Gets a video mode string from the selected monitor.\n\n") 2486{ 2487 char* buf = Con::getReturnBuffer(PlatformWindowManager::get()->getMonitorMode(monitorIndex, modeIndex)); 2488 return buf; 2489} 2490DefineEngineMethod(GuiCanvas, getMonitorDesktopMode, const char*, (S32 monitorIndex), (0), 2491 "Gets the current desktop mode for the selected monitor.\n\n") 2492{ 2493 char* buf = Con::getReturnBuffer(PlatformWindowManager::get()->getMonitorDesktopMode(monitorIndex)); 2494 return buf; 2495} 2496 2497DefineEngineMethod( GuiCanvas, getVideoMode, const char*, (),, 2498 "@brief Gets the current screen mode as a string.\n\n" 2499 2500 "The return string will contain 5 values (width, height, fullscreen, bitdepth, refreshRate). " 2501 "You will need to parse out each one for individual use.\n\n" 2502 2503 "@tsexample\n" 2504 "%screenWidth = getWord(Canvas.getVideoMode(), 0);\n" 2505 "%screenHeight = getWord(Canvas.getVideoMode(), 1);\n" 2506 "%isFullscreen = getWord(Canvas.getVideoMode(), 2);\n" 2507 "%bitdepth = getWord(Canvas.getVideoMode(), 3);\n" 2508 "%refreshRate = getWord(Canvas.getVideoMode(), 4);\n" 2509 "@endtsexample\n\n" 2510 2511 "@return String formatted with screen width, screen height, screen mode, bit depth, and refresh rate.") 2512{ 2513 // Grab the video mode. 2514 if (!object->getPlatformWindow()) 2515 return ""; 2516 2517 GFXVideoMode vm = object->getPlatformWindow()->getVideoMode(); 2518 char* buf = Con::getReturnBuffer(vm.toString()); 2519 return buf; 2520} 2521 2522 2523DefineEngineMethod( GuiCanvas, getModeCount, S32, (),, 2524 "@brief Gets the number of modes available on this device.\n\n" 2525 2526 "@param param Description\n\n" 2527 2528 "@tsexample\n" 2529 "%modeCount = Canvas.getModeCount()\n" 2530 "@endtsexample\n\n" 2531 2532 "@return The number of video modes supported by the device") 2533{ 2534 if (!object->getPlatformWindow()) 2535 return 0; 2536 2537 // Grab the available mode list from the device. 2538 const Vector<GFXVideoMode>* const modeList = 2539 object->getPlatformWindow()->getGFXDevice()->getVideoModeList(); 2540 2541 // Return the number of resolutions. 2542 return modeList->size(); 2543} 2544 2545DefineEngineMethod( GuiCanvas, getMode, const char*, (S32 modeId),, 2546 "@brief Gets information on the specified mode of this device.\n\n" 2547 "@param modeId Index of the mode to get data from.\n" 2548 "@return A video mode string given an adapter and mode index.\n\n" 2549 "@see GuiCanvas::getVideoMode()") 2550{ 2551 if (!object->getPlatformWindow()) 2552 return 0; 2553 2554 // Grab the available mode list from the device. 2555 const Vector<GFXVideoMode>* const modeList = 2556 object->getPlatformWindow()->getGFXDevice()->getVideoModeList(); 2557 2558 // Get the desired index and confirm it's valid. 2559 S32 idx = modeId; 2560 if((idx < 0) || (idx >= modeList->size())) 2561 { 2562 Con::errorf("GuiCanvas::getResolution - You requested an out of range index of %d. Please specify an index in the range [0, %d).", idx, modeList->size()); 2563 return ""; 2564 } 2565 2566 // Great - we got something valid, so convert the videomode into a 2567 // string and return to the user. 2568 GFXVideoMode vm = (*modeList)[idx]; 2569 2570 char *retString = Con::getReturnBuffer(vm.toString()); 2571 return retString; 2572} 2573 2574 2575DefineEngineMethod( GuiCanvas, toggleFullscreen, void, (),, 2576 "@brief toggle canvas from fullscreen to windowed mode or back.\n\n" 2577 2578 "@tsexample\n" 2579 "// If we are in windowed mode, the following will put is in fullscreen\n" 2580 "Canvas.toggleFullscreen();" 2581 "@endtsexample\n\n") 2582{ 2583 if (Platform::getWebDeployment()) 2584 return; 2585 2586 if (!object->getPlatformWindow()) 2587 return; 2588 2589 if (Journal::IsRecording() || Journal::IsPlaying()) 2590 return; 2591 2592 // Get the window's video mode. 2593 GFXVideoMode origMode = object->getPlatformWindow()->getVideoMode(); 2594 2595 // And grab the device its using. 2596 GFXDevice *device = object->getPlatformWindow()->getGFXDevice(); 2597 2598 // Toggle the fullscreen bit. 2599 GFXVideoMode newMode = origMode; 2600 newMode.fullScreen = !origMode.fullScreen; 2601 2602 // CodeReview Toggling might be better served by reading the fullscreen 2603 // or windowed video mode pref and setting that instead [bjg 5/2/07] 2604 2605 if(newMode.fullScreen == true) 2606 { 2607 // Are we going to fullscreen? If so find the first matching resolution that 2608 // is equal to or bigger in size, and has same BPP - windows 2609 // are often strangely sized and will need to be adjusted to a viable 2610 // fullscreen res. 2611 2612 for(S32 i=0; i<device->getVideoModeList()->size(); i++) 2613 { 2614 const GFXVideoMode &newVm = (*(device->getVideoModeList()))[i]; 2615 2616 if(newMode.resolution.x > newVm.resolution.x) 2617 continue; 2618 2619 if(newMode.resolution.y > newVm.resolution.y) 2620 continue; 2621 2622 if(newMode.bitDepth != newVm.bitDepth) 2623 continue; 2624 2625 // Great - got a match. 2626 newMode = newVm; 2627 newMode.fullScreen = true; 2628 break; 2629 } 2630 } 2631 2632 // Ok, we have new video mode. Set it! 2633 object->getPlatformWindow()->setVideoMode(newMode); 2634} 2635 2636 2637DefineEngineMethod( GuiCanvas, clientToScreen, Point2I, ( Point2I coordinate ),, 2638 "Translate a coordinate from canvas window-space to screen-space.\n" 2639 "@param coordinate The coordinate in window-space.\n" 2640 "@return The given coordinate translated to screen-space." ) 2641{ 2642 if( !object->getPlatformWindow() ) 2643 return coordinate; 2644 2645 return object->getPlatformWindow()->clientToScreen( coordinate ); 2646} 2647 2648DefineEngineMethod( GuiCanvas, screenToClient, Point2I, ( Point2I coordinate ),, 2649 "Translate a coordinate from screen-space to canvas window-space.\n" 2650 "@param coordinate The coordinate in screen-space.\n" 2651 "@return The given coordinate translated to window-space." ) 2652{ 2653 if( !object->getPlatformWindow() ) 2654 return coordinate; 2655 2656 return object->getPlatformWindow()->screenToClient( coordinate ); 2657} 2658 2659DefineEngineMethod( GuiCanvas, getWindowPosition, Point2I, (),, 2660 "Get the current position of the platform window associated with the canvas.\n" 2661 "@return The window position of the canvas in screen-space." ) 2662{ 2663 if( !object->getPlatformWindow() ) 2664 return Point2I( 0, 0 ); 2665 2666 return object->getPlatformWindow()->getPosition(); 2667} 2668 2669DefineEngineMethod( GuiCanvas, setWindowPosition, void, ( Point2I position ),, 2670 "Set the position of the platform window associated with the canvas.\n" 2671 "@param position The new position of the window in screen-space." ) 2672{ 2673 if( !object->getPlatformWindow() ) 2674 return; 2675 2676 object->getPlatformWindow()->setPosition( position ); 2677} 2678 2679DefineEngineMethod( GuiCanvas, isFullscreen, bool, (), , "() - Is this canvas currently fullscreen?" ) 2680{ 2681 if (Platform::getWebDeployment()) 2682 return false; 2683 2684 if (!object->getPlatformWindow()) 2685 return false; 2686 2687 return object->getPlatformWindow()->getVideoMode().fullScreen; 2688} 2689 2690DefineEngineMethod( GuiCanvas, minimizeWindow, void, (), , "() - minimize this canvas' window." ) 2691{ 2692 PlatformWindow* window = object->getPlatformWindow(); 2693 if ( window ) 2694 window->minimize(); 2695} 2696 2697DefineEngineMethod( GuiCanvas, isMinimized, bool, (), , "()" ) 2698{ 2699 PlatformWindow* window = object->getPlatformWindow(); 2700 if ( window ) 2701 return window->isMinimized(); 2702 2703 return false; 2704} 2705 2706DefineEngineMethod( GuiCanvas, isMaximized, bool, (), , "()" ) 2707{ 2708 PlatformWindow* window = object->getPlatformWindow(); 2709 if ( window ) 2710 return window->isMaximized(); 2711 2712 return false; 2713} 2714 2715DefineEngineMethod( GuiCanvas, maximizeWindow, void, (), , "() - maximize this canvas' window." ) 2716{ 2717 PlatformWindow* window = object->getPlatformWindow(); 2718 if ( window ) 2719 window->maximize(); 2720} 2721 2722DefineEngineMethod( GuiCanvas, restoreWindow, void, (), , "() - restore this canvas' window." ) 2723{ 2724 PlatformWindow* window = object->getPlatformWindow(); 2725 if( window ) 2726 window->restore(); 2727} 2728 2729DefineEngineMethod( GuiCanvas, setFocus, void, (), , "() - Claim OS input focus for this canvas' window.") 2730{ 2731 PlatformWindow* window = object->getPlatformWindow(); 2732 if (window) 2733 { 2734 window->setFocus(); 2735 window->appEvent.trigger(window->getWindowId(), GainFocus); 2736 } 2737} 2738 2739DefineEngineMethod( GuiCanvas, setMenuBar, void, ( GuiControl* menu ),, 2740 "Translate a coordinate from canvas window-space to screen-space.\n" 2741 "@param coordinate The coordinate in window-space.\n" 2742 "@return The given coordinate translated to screen-space." ) 2743{ 2744 return object->setMenuBar( menu ); 2745} 2746 2747DefineEngineMethod( GuiCanvas, setVideoMode, void, 2748 (U32 width, U32 height, bool fullscreen, U32 bitDepth, U32 refreshRate, U32 antialiasLevel), 2749 ( false, 0, 0, 0), 2750 "(int width, int height, bool fullscreen, [int bitDepth], [int refreshRate], [int antialiasLevel] )\n" 2751 "Change the video mode of this canvas. This method has the side effect of setting the $pref::Video::mode to the new values.\n\n" 2752 "\\param width The screen width to set.\n" 2753 "\\param height The screen height to set.\n" 2754 "\\param fullscreen Specify true to run fullscreen or false to run in a window\n" 2755 "\\param bitDepth [optional] The desired bit-depth. Defaults to the current setting. This parameter is ignored if you are running in a window.\n" 2756 "\\param refreshRate [optional] The desired refresh rate. Defaults to the current setting. This parameter is ignored if you are running in a window" 2757 "\\param antialiasLevel [optional] The level of anti-aliasing to apply 0 = none" ) 2758{ 2759 if (!object->getPlatformWindow()) 2760 return; 2761 2762 if (Journal::IsRecording() || Journal::IsPlaying()) 2763 return; 2764 2765 // Update the video mode and tell the window to reset. 2766 GFXVideoMode vm = object->getPlatformWindow()->getVideoMode(); 2767 2768 2769 bool changed = false; 2770 if (width == 0 && height > 0) 2771 { 2772 // Our width is 0 but our height isn't... 2773 // Try to find a matching width 2774 for(S32 i=0; i<object->getPlatformWindow()->getGFXDevice()->getVideoModeList()->size(); i++) 2775 { 2776 const GFXVideoMode &newVm = (*(object->getPlatformWindow()->getGFXDevice()->getVideoModeList()))[i]; 2777 2778 if(newVm.resolution.y == height) 2779 { 2780 width = newVm.resolution.x; 2781 changed = true; 2782 break; 2783 } 2784 } 2785 } 2786 else if (height == 0 && width > 0) 2787 { 2788 // Our height is 0 but our width isn't... 2789 // Try to find a matching height 2790 for(S32 i=0; i<object->getPlatformWindow()->getGFXDevice()->getVideoModeList()->size(); i++) 2791 { 2792 const GFXVideoMode &newVm = (*(object->getPlatformWindow()->getGFXDevice()->getVideoModeList()))[i]; 2793 2794 if(newVm.resolution.x == width) 2795 { 2796 height = newVm.resolution.y; 2797 changed = true; 2798 break; 2799 } 2800 } 2801 } 2802 2803 if (width == 0 || height == 0) 2804 { 2805 // Got a bad size for both of our dimensions or one of our dimensions and 2806 // didn't get a match for the other default back to our current resolution 2807 width = vm.resolution.x; 2808 height = vm.resolution.y; 2809 2810 changed = true; 2811 } 2812 2813 if (changed) 2814 { 2815 Con::errorf("GuiCanvas::setVideoMode(): Error - Invalid resolution of (%d, %d) - attempting (%d, %d)", width, height, width, height); 2816 } 2817 2818 vm.resolution = Point2I(width, height); 2819 vm.fullScreen = fullscreen; 2820 2821 if (Platform::getWebDeployment()) 2822 vm.fullScreen = false; 2823 2824 // These optional params are set to default at construction of vm. If they 2825 // aren't specified, just leave them at whatever they were set to. 2826 if (bitDepth > 0) 2827 { 2828 vm.bitDepth = bitDepth; 2829 } 2830 2831 if (refreshRate > 0) 2832 { 2833 vm.refreshRate = refreshRate; 2834 } 2835 2836 if (antialiasLevel > 0) 2837 { 2838 vm.antialiasLevel = antialiasLevel; 2839 } 2840 2841 object->getPlatformWindow()->setVideoMode(vm); 2842 2843 // Store the new mode into a pref. 2844 Con::setVariable( "$pref::Video::mode", vm.toString() ); 2845} 2846 2847DefineEngineMethod(GuiCanvas, showWindow, void, (),, "") 2848{ 2849 if (!object->getPlatformWindow()) 2850 return; 2851 2852 object->getPlatformWindow()->show(); 2853 WindowManager->setDisplayWindow(true); 2854 object->getPlatformWindow()->setDisplayWindow(true); 2855} 2856 2857DefineEngineMethod(GuiCanvas, hideWindow, void, (),, "") 2858{ 2859 if (!object->getPlatformWindow()) 2860 return; 2861 2862 object->getPlatformWindow()->hide(); 2863 WindowManager->setDisplayWindow(false); 2864 object->getPlatformWindow()->setDisplayWindow(false); 2865} 2866 2867DefineEngineMethod(GuiCanvas, cursorClick, void, (S32 buttonId, bool isDown), , "") 2868{ 2869 object->cursorClick(buttonId, isDown); 2870} 2871 2872DefineEngineMethod(GuiCanvas, cursorNudge, void, (F32 x, F32 y), , "") 2873{ 2874 object->cursorNudge(x, y); 2875} 2876 2877// This function allows resetting of the video-mode from script. It was motivated by 2878// the need to temporarily disable vsync during datablock cache load to avoid a 2879// significant slowdown. 2880bool AFX_forceVideoReset = false; 2881 2882 2883DefineEngineMethod(GuiCanvas, resetVideoMode, void, (), , "") 2884{ 2885 PlatformWindow* window = object->getPlatformWindow(); 2886 if (window) 2887 { 2888 GFXWindowTarget* gfx_target = window->getGFXTarget(); 2889 if (gfx_target) 2890 { 2891 AFX_forceVideoReset = true; 2892 gfx_target->resetMode(); 2893 AFX_forceVideoReset = false; 2894 } 2895 } 2896} 2897 2898