Pyrogenesis  trunk
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | List of all members
CGUI Class Reference

The main object that represents a whole GUI page. More...

#include <CGUI.h>

Collaboration diagram for CGUI:
Collaboration graph
[legend]

Public Member Functions

 CGUI (const std::shared_ptr< ScriptContext > &context)
 
 ~CGUI ()
 
void AddObjectTypes ()
 Informs the GUI page which GUI object types may be constructed from XML. More...
 
void TickObjects ()
 Performs processing that should happen every frame (including sending the "Tick" event to scripts) More...
 
void SendEventToAll (const CStr &eventName)
 Sends a specified script event to every object. More...
 
void SendEventToAll (const CStr &eventName, const JS::HandleValueArray &paramData)
 Sends a specified script event to every object. More...
 
void Draw (CCanvas2D &canvas)
 Displays the whole GUI. More...
 
void DrawSprite (const CGUISpriteInstance &Sprite, CCanvas2D &canvas, const CRect &Rect, const CRect &Clipping=CRect())
 Draw GUI Sprite. More...
 
InReaction HandleEvent (const SDL_Event_ *ev)
 The replacement of Process(), handles an SDL_Event_. More...
 
void LoadXmlFile (const VfsPath &Filename, std::unordered_set< VfsPath > &Paths)
 Load a GUI XML file into the GUI. More...
 
void LoadedXmlFiles ()
 Called after all XML files linked in the page file were loaded. More...
 
void SetObjectHotkey (IGUIObject *pObject, const CStr &hotkeyTag)
 Allows the JS side to modify the hotkey setting assigned to a GUI object. More...
 
void UnsetObjectHotkey (IGUIObject *pObject, const CStr &hotkeyTag)
 
void SetObjectStyle (IGUIObject *pObject, const CStr &styleName)
 Allows the JS side to modify the style setting assigned to a GUI object. More...
 
void UnsetObjectStyle (IGUIObject *pObject)
 
void SetGlobalHotkey (const CStr &hotkeyTag, const CStr &eventName, JS::HandleValue function)
 Allows the JS side to add or remove global hotkeys. More...
 
void UnsetGlobalHotkey (const CStr &hotkeyTag, const CStr &eventName)
 
IGUIObjectGetBaseObject ()
 Return the object which is an ancestor of every other GUI object. More...
 
bool ObjectExists (const CStr &Name) const
 Checks if object exists and return true or false accordingly. More...
 
IGUIObjectFindObjectByName (const CStr &Name) const
 Returns the GUI object with the desired name, or nullptr if no match is found,. More...
 
IGUIObjectFindObjectUnderMouse ()
 Returns the GUI object under the mouse, or nullptr if none. More...
 
const CVector2DGetMousePos () const
 Returns the current screen coordinates of the cursor. More...
 
const unsigned int & GetMouseButtons ()
 Returns the currently pressed mouse buttons. More...
 
const SGUIScrollBarStyleGetScrollBarStyle (const CStr &style) const
 
CSize2D GetWindowSize () const
 Returns the current GUI window size. More...
 
void AddObjectType (const CStr &str, ConstructObjectFunction pFunc)
 The GUI needs to have all object types inputted and their constructors. More...
 
void UpdateResolution ()
 Update Resolution, should be called every time the resolution of the OpenGL screen has been changed, this is because it needs to re-cache all its actual sizes. More...
 
bool HasIcon (const CStr &name) const
 Check if an icon exists. More...
 
const SGUIIconGetIcon (const CStr &name) const
 Get Icon (a const reference, can never be changed) More...
 
bool HasStyle (const CStr &name) const
 Check if a style exists. More...
 
const SGUIStyleGetStyle (const CStr &name) const
 Get Style if it exists, otherwise throws an exception. More...
 
bool HasPreDefinedColor (const CStr &name) const
 Check if a predefined color of that name exists. More...
 
const CGUIColorGetPreDefinedColor (const CStr &name) const
 Resolve the predefined color if it exists, otherwise throws an exception. More...
 
GUIProxyPropsGetProxyData (const js::BaseProxyHandler *ptr)
 
std::shared_ptr< ScriptInterfaceGetScriptInterface ()
 
IGUIObjectGetFocusedObject ()
 Get Focused Object. More...
 
void SetFocusedObject (IGUIObject *pObject)
 Change focus to new object. More...
 
void SendFocusMessage (EGUIMessageType msg)
 Alert the focussed object of this GUIPage that the focus of the page has changed. More...
 
template<>
bool ParseString (const CGUI *pGUI, const CStrW &Value, bool &Output)
 
template<>
bool ParseString (const CGUI *pGUI, const CStrW &Value, int &Output)
 
template<>
bool ParseString (const CGUI *pGUI, const CStrW &Value, u32 &Output)
 
template<>
bool ParseString (const CGUI *pGUI, const CStrW &Value, float &Output)
 
template<>
bool ParseString (const CGUI *pGUI, const CStrW &Value, CRect &Output)
 
template<>
bool ParseString (const CGUI *pGUI, const CStrW &Value, CGUISize &Output)
 
template<>
bool ParseString (const CGUI *pGUI, const CStrW &Value, CGUIColor &Output)
 
template<>
bool ParseString (const CGUI *pGUI, const CStrW &Value, CSize2D &Output)
 
template<>
bool ParseString (const CGUI *pGUI, const CStrW &Value, CVector2D &Output)
 
template<>
bool ParseString (const CGUI *pGUI, const CStrW &Value, EAlign &Output)
 
template<>
bool ParseString (const CGUI *pGUI, const CStrW &Value, EVAlign &Output)
 
template<>
bool ParseString (const CGUI *pGUI, const CStrW &Value, CGUIString &Output)
 
template<>
bool ParseString (const CGUI *pGUI, const CStrW &Value, CStr &Output)
 
template<>
bool ParseString (const CGUI *pGUI, const CStrW &Value, CStrW &Output)
 
template<>
bool ParseString (const CGUI *pGUI, const CStrW &Value, CGUISpriteInstance &Output)
 
template<>
bool ParseString (const CGUI *pGUI, const CStrW &Value, CGUISeries &Output)
 
template<>
bool ParseString (const CGUI *pGUI, const CStrW &Value, CGUIList &Output)
 

Static Public Member Functions

template<typename T >
static bool ParseString (const CGUI *pGUI, const CStrW &Value, T &tOutput)
 Reads a string value and modifies the given value of type T if successful. More...
 

Private Types

using ConstructObjectFunction = IGUIObject *(*)(CGUI &)
 

Private Member Functions

 NONCOPYABLE (CGUI)
 
bool AddObject (IGUIObject &parent, IGUIObject &child)
 The CGUI takes ownership of the child object and links the parent with the child. More...
 
IGUIObjectConstructObject (const CStr &str)
 You input the name of the object type, and let's say you input "button", then it will construct a CGUIObjet* as a CButton. More...
 
XML Reading Xeromyces specific subroutines

These does not throw! Because when reading in XML files, it won't be fatal if an error occurs, perhaps one particular object fails, but it'll still continue reading in the next.

All Error are reported with ReportParseError

void Xeromyces_ReadRootObjects (const XMBData &xmb, XMBElement element, std::unordered_set< VfsPath > &Paths)
 Reads in the root element <objects> (the DOMElement). More...
 
void Xeromyces_ReadRootSprites (const XMBData &xmb, XMBElement element)
 Reads in the root element <sprites> (the DOMElement). More...
 
void Xeromyces_ReadRootStyles (const XMBData &xmb, XMBElement element)
 Reads in the root element <styles> (the DOMElement). More...
 
void Xeromyces_ReadRootSetup (const XMBData &xmb, XMBElement element)
 Reads in the root element <setup> (the DOMElement). More...
 
IGUIObjectXeromyces_ReadObject (const XMBData &xmb, XMBElement element, IGUIObject *pParent, std::vector< std::pair< CStr, CStr > > &NameSubst, std::unordered_set< VfsPath > &Paths, u32 nesting_depth)
 Notice! Recursive function! More...
 
void Xeromyces_ReadRepeat (const XMBData &xmb, XMBElement element, IGUIObject *pParent, std::vector< std::pair< CStr, CStr > > &NameSubst, std::unordered_set< VfsPath > &Paths, u32 nesting_depth)
 Reads in the element <repeat>, which repeats its child <object>s 'count' times, replacing the string "[n]" (or the value of the attribute 'var' enclosed in square brackets) in its descendants' names with "[0]", "[1]", etc. More...
 
void Xeromyces_ReadScript (const XMBData &xmb, XMBElement element, std::unordered_set< VfsPath > &Paths)
 Reads in the element <script> (the XMBElement) and executes the script's code. More...
 
void Xeromyces_ReadSprite (const XMBData &xmb, XMBElement element)
 Reads in the element <sprite> (the XMBElement) and stores the result in a new CGUISprite. More...
 
void Xeromyces_ReadImage (const XMBData &xmb, XMBElement element, CGUISprite &parent)
 Reads in the element <image> (the XMBElement) and stores the result within the CGUISprite. More...
 
void Xeromyces_ReadEffects (const XMBData &xmb, XMBElement element, SGUIImageEffects &effects)
 Reads in the element <effect> (the XMBElement) and stores the result within the SGUIImageEffects. More...
 
void Xeromyces_ReadStyle (const XMBData &xmb, XMBElement element)
 Reads in the element <style> (the XMBElement) and stores the result in m_Styles. More...
 
void Xeromyces_ReadScrollBarStyle (const XMBData &xmb, XMBElement element)
 Reads in the element <scrollbar> (the XMBElement) and stores the result in m_ScrollBarStyles. More...
 
void Xeromyces_ReadIcon (const XMBData &xmb, XMBElement element)
 Reads in the element <icon> (the XMBElement) and stores the result in m_Icons. More...
 
void Xeromyces_ReadTooltip (const XMBData &xmb, XMBElement element)
 Reads in the element <tooltip> (the XMBElement) and stores the result as an object with the name __tooltip_#. More...
 
void Xeromyces_ReadColor (const XMBData &xmb, XMBElement element)
 Reads in the element <color> (the XMBElement) and stores the result in m_PreDefinedColors. More...
 

Private Attributes

Miscellaneous
std::shared_ptr< ScriptInterfacem_ScriptInterface
 
CVector2D m_MousePos
 don't want to pass this around with the ChooseMouseOverAndClosest broadcast - we'd need to pack this and pNearest in a struct More...
 
unsigned int m_MouseButtons
 Indicates which buttons are pressed (bit 0 = LMB, bit 1 = RMB, bit 2 = MMB) More...
 
GUITooltip m_Tooltip
 

Objects

std::unique_ptr< IGUIObjectm_BaseObject
 Base Object, all its children are considered parentless because this is not a real object per se. More...
 
IGUIObjectm_FocusedObject
 Focused object! Say an input box that is selected. More...
 
map_pObjects m_pAllObjects
 Just pointers for fast name access, each object is really constructed within its parent for easy recursive management. More...
 
int m_InternalNameNumber
 Number of object that has been given name automatically. More...
 
std::map< CStr, ConstructObjectFunctionm_ObjectTypes
 Function pointers to functions that constructs IGUIObjects by name... More...
 
std::unordered_map< const js::BaseProxyHandler *, std::unique_ptr< GUIProxyProps > > m_ProxyData
 This is intended to store the JSFunction when accessing certain properties. More...
 
std::map< CStr, std::vector< IGUIObject * > > m_HotkeyObjects
 Map from hotkey names to objects that listen to the hotkey. More...
 
std::map< CStr, std::map< CStr, JS::PersistentRootedValue > > m_GlobalHotkeys
 Map from hotkey names to maps of eventNames to functions that are triggered when the hotkey goes through the event. More...
 
std::map< CStr, const CGUIColorm_PreDefinedColors
 
std::map< CStr, std::unique_ptr< const CGUISprite > > m_Sprites
 
std::map< CStr, const SGUIStylem_Styles
 
std::map< CStr, const SGUIScrollBarStylem_ScrollBarStyles
 
std::map< CStr, const SGUIIconm_Icons
 
static const CStr EventNameLoad = "Load"
 XML and JS can subscribe handlers to events identified by these names. More...
 
static const CStr EventNameTick = "Tick"
 
static const CStr EventNamePress = "Press"
 
static const CStr EventNameKeyDown = "KeyDown"
 
static const CStr EventNameRelease = "Release"
 
static const CStr EventNameMouseRightPress = "MouseRightPress"
 
static const CStr EventNameMouseLeftPress = "MouseLeftPress"
 
static const CStr EventNameMouseWheelDown = "MouseWheelDown"
 
static const CStr EventNameMouseWheelUp = "MouseWheelUp"
 
static const CStr EventNameMouseLeftDoubleClick = "MouseLeftDoubleClick"
 
static const CStr EventNameMouseLeftRelease = "MouseLeftRelease"
 
static const CStr EventNameMouseRightDoubleClick = "MouseRightDoubleClick"
 
static const CStr EventNameMouseRightRelease = "MouseRightRelease"
 
std::unordered_map< CStr, std::vector< IGUIObject * > > m_EventObjects
 Map from event names to object which listen to a given event. More...
 

Detailed Description

The main object that represents a whole GUI page.

Member Typedef Documentation

◆ ConstructObjectFunction

Constructor & Destructor Documentation

◆ CGUI()

CGUI::CGUI ( const std::shared_ptr< ScriptContext > &  context)

◆ ~CGUI()

CGUI::~CGUI ( )

Member Function Documentation

◆ AddObject()

bool CGUI::AddObject ( IGUIObject parent,
IGUIObject child 
)
private

The CGUI takes ownership of the child object and links the parent with the child.

Returns false on failure to take over ownership of the child object.

◆ AddObjectType()

void CGUI::AddObjectType ( const CStr &  str,
ConstructObjectFunction  pFunc 
)
inline

The GUI needs to have all object types inputted and their constructors.

Also it needs to associate a type by a string name of the type.

To add a type:

AddObjectType("button", &CButton::ConstructObject);
Parameters
strReference name of object type
pFuncPointer of function ConstuctObject() in the object
See also
CGUI::ConstructObject()

◆ AddObjectTypes()

void CGUI::AddObjectTypes ( )

Informs the GUI page which GUI object types may be constructed from XML.

◆ ConstructObject()

IGUIObject * CGUI::ConstructObject ( const CStr &  str)
private

You input the name of the object type, and let's say you input "button", then it will construct a CGUIObjet* as a CButton.

Parameters
strName of object type
Returns
Newly constructed IGUIObject (but constructed as a subclass)

◆ Draw()

void CGUI::Draw ( CCanvas2D canvas)

Displays the whole GUI.

◆ DrawSprite()

void CGUI::DrawSprite ( const CGUISpriteInstance Sprite,
CCanvas2D canvas,
const CRect Rect,
const CRect Clipping = CRect() 
)

Draw GUI Sprite.

Parameters
SpriteObject referring to the sprite (which also caches calculations for faster rendering)
CanvasCanvas to draw on
RectPosition and Size
ClippingThe sprite shouldn't be drawn outside this rectangle

◆ FindObjectByName()

IGUIObject * CGUI::FindObjectByName ( const CStr &  Name) const

Returns the GUI object with the desired name, or nullptr if no match is found,.

Parameters
NameString name of object
Returns
Matching object, or nullptr

◆ FindObjectUnderMouse()

IGUIObject * CGUI::FindObjectUnderMouse ( )

Returns the GUI object under the mouse, or nullptr if none.

◆ GetBaseObject()

IGUIObject * CGUI::GetBaseObject ( )

Return the object which is an ancestor of every other GUI object.

◆ GetFocusedObject()

IGUIObject* CGUI::GetFocusedObject ( )
inline

Get Focused Object.

◆ GetIcon()

const SGUIIcon& CGUI::GetIcon ( const CStr &  name) const
inline

Get Icon (a const reference, can never be changed)

◆ GetMouseButtons()

const unsigned int& CGUI::GetMouseButtons ( )
inline

Returns the currently pressed mouse buttons.

◆ GetMousePos()

const CVector2D& CGUI::GetMousePos ( ) const
inline

Returns the current screen coordinates of the cursor.

◆ GetPreDefinedColor()

const CGUIColor& CGUI::GetPreDefinedColor ( const CStr &  name) const
inline

Resolve the predefined color if it exists, otherwise throws an exception.

◆ GetProxyData()

GUIProxyProps* CGUI::GetProxyData ( const js::BaseProxyHandler *  ptr)
inline

◆ GetScriptInterface()

std::shared_ptr<ScriptInterface> CGUI::GetScriptInterface ( )
inline

◆ GetScrollBarStyle()

const SGUIScrollBarStyle * CGUI::GetScrollBarStyle ( const CStr &  style) const

◆ GetStyle()

const SGUIStyle& CGUI::GetStyle ( const CStr &  name) const
inline

Get Style if it exists, otherwise throws an exception.

◆ GetWindowSize()

CSize2D CGUI::GetWindowSize ( ) const

Returns the current GUI window size.

◆ HandleEvent()

InReaction CGUI::HandleEvent ( const SDL_Event_ ev)

The replacement of Process(), handles an SDL_Event_.

Parameters
evSDL Event, like mouse/keyboard input

◆ HasIcon()

bool CGUI::HasIcon ( const CStr &  name) const
inline

Check if an icon exists.

◆ HasPreDefinedColor()

bool CGUI::HasPreDefinedColor ( const CStr &  name) const
inline

Check if a predefined color of that name exists.

◆ HasStyle()

bool CGUI::HasStyle ( const CStr &  name) const
inline

Check if a style exists.

◆ LoadedXmlFiles()

void CGUI::LoadedXmlFiles ( )

Called after all XML files linked in the page file were loaded.

◆ LoadXmlFile()

void CGUI::LoadXmlFile ( const VfsPath Filename,
std::unordered_set< VfsPath > &  Paths 
)

Load a GUI XML file into the GUI.

VERY IMPORTANT! All <styles>-files must be read before everything else!

Parameters
FilenameName of file
PathsSet of paths; all XML and JS files loaded will be added to this
Here is the call graph for this function:

◆ NONCOPYABLE()

CGUI::NONCOPYABLE ( CGUI  )
private

◆ ObjectExists()

bool CGUI::ObjectExists ( const CStr &  Name) const

Checks if object exists and return true or false accordingly.

Parameters
NameString name of object
Returns
true if object exists

◆ ParseString() [1/18]

template<>
bool CGUI::ParseString ( const CGUI pGUI,
const CStrW &  Value,
bool &  Output 
)

◆ ParseString() [2/18]

template<>
bool CGUI::ParseString ( const CGUI pGUI,
const CStrW &  Value,
int &  Output 
)

◆ ParseString() [3/18]

template<>
bool CGUI::ParseString ( const CGUI pGUI,
const CStrW &  Value,
u32 Output 
)

◆ ParseString() [4/18]

template<>
bool CGUI::ParseString ( const CGUI pGUI,
const CStrW &  Value,
float &  Output 
)

◆ ParseString() [5/18]

template<>
bool CGUI::ParseString ( const CGUI pGUI,
const CStrW &  Value,
CRect Output 
)

◆ ParseString() [6/18]

template<>
bool CGUI::ParseString ( const CGUI pGUI,
const CStrW &  Value,
CGUISize Output 
)

◆ ParseString() [7/18]

template<>
bool CGUI::ParseString ( const CGUI pGUI,
const CStrW &  Value,
CGUIColor Output 
)

◆ ParseString() [8/18]

template<>
bool CGUI::ParseString ( const CGUI pGUI,
const CStrW &  Value,
CSize2D Output 
)

◆ ParseString() [9/18]

template<>
bool CGUI::ParseString ( const CGUI pGUI,
const CStrW &  Value,
CVector2D Output 
)

◆ ParseString() [10/18]

template<>
bool CGUI::ParseString ( const CGUI pGUI,
const CStrW &  Value,
EAlign Output 
)

◆ ParseString() [11/18]

template<>
bool CGUI::ParseString ( const CGUI pGUI,
const CStrW &  Value,
EVAlign Output 
)

◆ ParseString() [12/18]

template<>
bool CGUI::ParseString ( const CGUI pGUI,
const CStrW &  Value,
CGUIString Output 
)

◆ ParseString() [13/18]

template<>
bool CGUI::ParseString ( const CGUI pGUI,
const CStrW &  Value,
CStr &  Output 
)

◆ ParseString() [14/18]

template<>
bool CGUI::ParseString ( const CGUI pGUI,
const CStrW &  Value,
CStrW &  Output 
)

◆ ParseString() [15/18]

template<>
bool CGUI::ParseString ( const CGUI pGUI,
const CStrW &  Value,
CGUISpriteInstance Output 
)

◆ ParseString() [16/18]

template<>
bool CGUI::ParseString ( const CGUI pGUI,
const CStrW &  Value,
CGUISeries Output 
)

◆ ParseString() [17/18]

template<>
bool CGUI::ParseString ( const CGUI pGUI,
const CStrW &  Value,
CGUIList Output 
)

◆ ParseString() [18/18]

template<typename T >
static bool CGUI::ParseString ( const CGUI pGUI,
const CStrW &  Value,
T tOutput 
)
static

Reads a string value and modifies the given value of type T if successful.

Does not change the value upon conversion failure.

Parameters
pGUIThe GUI page which may contain data relevant to the parsing (for example predefined colors).
ValueThe value in string form, like "0 0 100% 100%"
tOutputParsed value of type T
Returns
True at success.

◆ SendEventToAll() [1/2]

void CGUI::SendEventToAll ( const CStr &  eventName)

Sends a specified script event to every object.

Parameters
eventNameString representation of event name

◆ SendEventToAll() [2/2]

void CGUI::SendEventToAll ( const CStr &  eventName,
const JS::HandleValueArray &  paramData 
)

Sends a specified script event to every object.

Parameters
eventNameString representation of event name
paramDataJS::HandleValueArray storing the arguments passed to the event handler.

◆ SendFocusMessage()

void CGUI::SendFocusMessage ( EGUIMessageType  msg)

Alert the focussed object of this GUIPage that the focus of the page has changed.

◆ SetFocusedObject()

void CGUI::SetFocusedObject ( IGUIObject pObject)

Change focus to new object.

Will send LOST_FOCUS/GOT_FOCUS messages as appropriate. pObject can be nullptr to remove all focus.

◆ SetGlobalHotkey()

void CGUI::SetGlobalHotkey ( const CStr &  hotkeyTag,
const CStr &  eventName,
JS::HandleValue  function 
)

Allows the JS side to add or remove global hotkeys.

◆ SetObjectHotkey()

void CGUI::SetObjectHotkey ( IGUIObject pObject,
const CStr &  hotkeyTag 
)

Allows the JS side to modify the hotkey setting assigned to a GUI object.

◆ SetObjectStyle()

void CGUI::SetObjectStyle ( IGUIObject pObject,
const CStr &  styleName 
)

Allows the JS side to modify the style setting assigned to a GUI object.

◆ TickObjects()

void CGUI::TickObjects ( )

Performs processing that should happen every frame (including sending the "Tick" event to scripts)

◆ UnsetGlobalHotkey()

void CGUI::UnsetGlobalHotkey ( const CStr &  hotkeyTag,
const CStr &  eventName 
)

◆ UnsetObjectHotkey()

void CGUI::UnsetObjectHotkey ( IGUIObject pObject,
const CStr &  hotkeyTag 
)

◆ UnsetObjectStyle()

void CGUI::UnsetObjectStyle ( IGUIObject pObject)

◆ UpdateResolution()

void CGUI::UpdateResolution ( )

Update Resolution, should be called every time the resolution of the OpenGL screen has been changed, this is because it needs to re-cache all its actual sizes.

Needs no input since screen resolution is global.

See also
IGUIObject::UpdateCachedSize()

◆ Xeromyces_ReadColor()

void CGUI::Xeromyces_ReadColor ( const XMBData xmb,
XMBElement  element 
)
private

Reads in the element <color> (the XMBElement) and stores the result in m_PreDefinedColors.

Parameters
ElementThe Xeromyces object that represents the scrollbar-tag.
pFileThe Xeromyces object for the file being read
See also
LoadXmlFile()

◆ Xeromyces_ReadEffects()

void CGUI::Xeromyces_ReadEffects ( const XMBData xmb,
XMBElement  element,
SGUIImageEffects effects 
)
private

Reads in the element <effect> (the XMBElement) and stores the result within the SGUIImageEffects.

Parameters
ElementThe Xeromyces object that represents the image-tag.
pFileThe Xeromyces object for the file being read
effectsEffects object to add this effect to.
See also
LoadXmlFile()

◆ Xeromyces_ReadIcon()

void CGUI::Xeromyces_ReadIcon ( const XMBData xmb,
XMBElement  element 
)
private

Reads in the element <icon> (the XMBElement) and stores the result in m_Icons.

Parameters
ElementThe Xeromyces object that represents the scrollbar-tag.
pFileThe Xeromyces object for the file being read
See also
LoadXmlFile()

◆ Xeromyces_ReadImage()

void CGUI::Xeromyces_ReadImage ( const XMBData xmb,
XMBElement  element,
CGUISprite parent 
)
private

Reads in the element <image> (the XMBElement) and stores the result within the CGUISprite.

Parameters
ElementThe Xeromyces object that represents the image-tag.
pFileThe Xeromyces object for the file being read
parentParent sprite.
See also
LoadXmlFile()

◆ Xeromyces_ReadObject()

IGUIObject * CGUI::Xeromyces_ReadObject ( const XMBData xmb,
XMBElement  element,
IGUIObject pParent,
std::vector< std::pair< CStr, CStr > > &  NameSubst,
std::unordered_set< VfsPath > &  Paths,
u32  nesting_depth 
)
private

Notice! Recursive function!

Read in an <object> (the XMBElement) and stores it as a child in the pParent.

It will also check the object's children and call this function on them too. Also it will call all other functions that reads in other stuff that can be found within an object. Check the tree in the beginning of this class' Xeromyces_* section.

Parameters
ElementThe Xeromyces object that represents the object-tag.
pFileThe Xeromyces object for the file being read
pParentParent to add this object as child in.
NameSubstA set of substitution strings that will be applied to all object names within this object.
PathsOutput set of file paths that this GUI object relies on.
See also
LoadXmlFile()

◆ Xeromyces_ReadRepeat()

void CGUI::Xeromyces_ReadRepeat ( const XMBData xmb,
XMBElement  element,
IGUIObject pParent,
std::vector< std::pair< CStr, CStr > > &  NameSubst,
std::unordered_set< VfsPath > &  Paths,
u32  nesting_depth 
)
private

Reads in the element <repeat>, which repeats its child <object>s 'count' times, replacing the string "[n]" (or the value of the attribute 'var' enclosed in square brackets) in its descendants' names with "[0]", "[1]", etc.

◆ Xeromyces_ReadRootObjects()

void CGUI::Xeromyces_ReadRootObjects ( const XMBData xmb,
XMBElement  element,
std::unordered_set< VfsPath > &  Paths 
)
private

Reads in the root element <objects> (the DOMElement).

Parameters
ElementThe Xeromyces object that represents the objects-tag.
pFileThe Xeromyces object for the file being read
PathsCollects the set of all XML/JS files that are loaded
See also
LoadXmlFile()

◆ Xeromyces_ReadRootSetup()

void CGUI::Xeromyces_ReadRootSetup ( const XMBData xmb,
XMBElement  element 
)
private

Reads in the root element <setup> (the DOMElement).

Parameters
ElementThe Xeromyces object that represents the setup-tag.
pFileThe Xeromyces object for the file being read
See also
LoadXmlFile()

◆ Xeromyces_ReadRootSprites()

void CGUI::Xeromyces_ReadRootSprites ( const XMBData xmb,
XMBElement  element 
)
private

Reads in the root element <sprites> (the DOMElement).

Parameters
ElementThe Xeromyces object that represents the sprites-tag.
pFileThe Xeromyces object for the file being read
See also
LoadXmlFile()

◆ Xeromyces_ReadRootStyles()

void CGUI::Xeromyces_ReadRootStyles ( const XMBData xmb,
XMBElement  element 
)
private

Reads in the root element <styles> (the DOMElement).

Parameters
ElementThe Xeromyces object that represents the styles-tag.
pFileThe Xeromyces object for the file being read
See also
LoadXmlFile()

◆ Xeromyces_ReadScript()

void CGUI::Xeromyces_ReadScript ( const XMBData xmb,
XMBElement  element,
std::unordered_set< VfsPath > &  Paths 
)
private

Reads in the element <script> (the XMBElement) and executes the script's code.

Parameters
ElementThe Xeromyces object that represents the script-tag.
pFileThe Xeromyces object for the file being read
PathsOutput set of file paths that this script is loaded from.
See also
LoadXmlFile()

◆ Xeromyces_ReadScrollBarStyle()

void CGUI::Xeromyces_ReadScrollBarStyle ( const XMBData xmb,
XMBElement  element 
)
private

Reads in the element <scrollbar> (the XMBElement) and stores the result in m_ScrollBarStyles.

Parameters
ElementThe Xeromyces object that represents the scrollbar-tag.
pFileThe Xeromyces object for the file being read
See also
LoadXmlFile()

◆ Xeromyces_ReadSprite()

void CGUI::Xeromyces_ReadSprite ( const XMBData xmb,
XMBElement  element 
)
private

Reads in the element <sprite> (the XMBElement) and stores the result in a new CGUISprite.

Parameters
ElementThe Xeromyces object that represents the sprite-tag.
pFileThe Xeromyces object for the file being read
See also
LoadXmlFile()

◆ Xeromyces_ReadStyle()

void CGUI::Xeromyces_ReadStyle ( const XMBData xmb,
XMBElement  element 
)
private

Reads in the element <style> (the XMBElement) and stores the result in m_Styles.

Parameters
ElementThe Xeromyces object that represents the style-tag.
pFileThe Xeromyces object for the file being read
See also
LoadXmlFile()

◆ Xeromyces_ReadTooltip()

void CGUI::Xeromyces_ReadTooltip ( const XMBData xmb,
XMBElement  element 
)
private

Reads in the element <tooltip> (the XMBElement) and stores the result as an object with the name __tooltip_#.

Parameters
ElementThe Xeromyces object that represents the scrollbar-tag.
pFileThe Xeromyces object for the file being read
See also
LoadXmlFile()

Member Data Documentation

◆ EventNameKeyDown

const CStr CGUI::EventNameKeyDown = "KeyDown"
staticprivate

◆ EventNameLoad

const CStr CGUI::EventNameLoad = "Load"
staticprivate

XML and JS can subscribe handlers to events identified by these names.

Store in static const members to avoid string copies, gain compile errors when misspelling and to allow reuse in other classes.

◆ EventNameMouseLeftDoubleClick

const CStr CGUI::EventNameMouseLeftDoubleClick = "MouseLeftDoubleClick"
staticprivate

◆ EventNameMouseLeftPress

const CStr CGUI::EventNameMouseLeftPress = "MouseLeftPress"
staticprivate

◆ EventNameMouseLeftRelease

const CStr CGUI::EventNameMouseLeftRelease = "MouseLeftRelease"
staticprivate

◆ EventNameMouseRightDoubleClick

const CStr CGUI::EventNameMouseRightDoubleClick = "MouseRightDoubleClick"
staticprivate

◆ EventNameMouseRightPress

const CStr CGUI::EventNameMouseRightPress = "MouseRightPress"
staticprivate

◆ EventNameMouseRightRelease

const CStr CGUI::EventNameMouseRightRelease = "MouseRightRelease"
staticprivate

◆ EventNameMouseWheelDown

const CStr CGUI::EventNameMouseWheelDown = "MouseWheelDown"
staticprivate

◆ EventNameMouseWheelUp

const CStr CGUI::EventNameMouseWheelUp = "MouseWheelUp"
staticprivate

◆ EventNamePress

const CStr CGUI::EventNamePress = "Press"
staticprivate

◆ EventNameRelease

const CStr CGUI::EventNameRelease = "Release"
staticprivate

◆ EventNameTick

const CStr CGUI::EventNameTick = "Tick"
staticprivate

◆ m_BaseObject

std::unique_ptr<IGUIObject> CGUI::m_BaseObject
private

Base Object, all its children are considered parentless because this is not a real object per se.

◆ m_EventObjects

std::unordered_map<CStr, std::vector<IGUIObject*> > CGUI::m_EventObjects

Map from event names to object which listen to a given event.

◆ m_FocusedObject

IGUIObject* CGUI::m_FocusedObject
private

Focused object! Say an input box that is selected.

That one is focused. There can only be one focused object.

◆ m_GlobalHotkeys

std::map<CStr, std::map<CStr, JS::PersistentRootedValue> > CGUI::m_GlobalHotkeys
private

Map from hotkey names to maps of eventNames to functions that are triggered when the hotkey goes through the event.

Contrary to object hotkeys, this allows for only one global function per hotkey name per event type.

◆ m_HotkeyObjects

std::map<CStr, std::vector<IGUIObject*> > CGUI::m_HotkeyObjects
private

Map from hotkey names to objects that listen to the hotkey.

(This is an optimisation to avoid recursing over the whole GUI tree every time a hotkey is pressed).

◆ m_Icons

std::map<CStr, const SGUIIcon> CGUI::m_Icons
private

◆ m_InternalNameNumber

int CGUI::m_InternalNameNumber
private

Number of object that has been given name automatically.

the name given will be '__internal(#)', the number (#) being this variable. When an object's name has been set as followed, the value will increment.

◆ m_MouseButtons

unsigned int CGUI::m_MouseButtons
private

Indicates which buttons are pressed (bit 0 = LMB, bit 1 = RMB, bit 2 = MMB)

◆ m_MousePos

CVector2D CGUI::m_MousePos
private

don't want to pass this around with the ChooseMouseOverAndClosest broadcast - we'd need to pack this and pNearest in a struct

◆ m_ObjectTypes

std::map<CStr, ConstructObjectFunction> CGUI::m_ObjectTypes
private

Function pointers to functions that constructs IGUIObjects by name...

For instance m_ObjectTypes["button"] is filled with a function that will "return new CButton();"

◆ m_pAllObjects

map_pObjects CGUI::m_pAllObjects
private

Just pointers for fast name access, each object is really constructed within its parent for easy recursive management.

Notice m_BaseObject won't belong here since it's not considered a real object.

◆ m_PreDefinedColors

std::map<CStr, const CGUIColor> CGUI::m_PreDefinedColors
private

◆ m_ProxyData

std::unordered_map<const js::BaseProxyHandler*, std::unique_ptr<GUIProxyProps> > CGUI::m_ProxyData
private

This is intended to store the JSFunction when accessing certain properties.

The problem is that these functions are per-scriptInterface, and proxy handlers aren't. So we know what we want to store, but we don't really have anywhere to store it. It would be simpler to recreate the functions on every JS call, but that is slower (this may or may not matter now and in the future). It's not a great solution, but I can't find a better one at the moment. An alternative would be to store these on the proxy's prototype, but that embarks a lot of un-necessary code.

◆ m_ScriptInterface

std::shared_ptr<ScriptInterface> CGUI::m_ScriptInterface
private

◆ m_ScrollBarStyles

std::map<CStr, const SGUIScrollBarStyle> CGUI::m_ScrollBarStyles
private

◆ m_Sprites

std::map<CStr, std::unique_ptr<const CGUISprite> > CGUI::m_Sprites
private

◆ m_Styles

std::map<CStr, const SGUIStyle> CGUI::m_Styles
private

◆ m_Tooltip

GUITooltip CGUI::m_Tooltip
private

The documentation for this class was generated from the following files: