25#ifndef INCLUDED_IGUIOBJECT
26#define INCLUDED_IGUIOBJECT
37#include <js/RootingAPI.h>
38#include <js/TypeDecls.h>
39#include <js/ValueArray.h>
51namespace JS {
class HandleValueArray; }
53#define GUI_OBJECT(obj) \
55 static std::unique_ptr<IGUIObject> ConstructObject(CGUI& pGUI) \
56 { return std::make_unique<obj>(pGUI); }
175 void PlaySound(
const CStrW& soundPath)
const;
263 template<
typename... Args>
268 if (isRestricted && (this->*isRestricted)())
271 (this->*callbackFunction)(args...);
275 obj->RecurseObject(isRestricted, callbackFunction, args...);
401 const JS::HandleValueArray& paramData = JS::HandleValueArray::empty());
469 static void Trace(JSTracer* trc,
void* data)
EGUIMessageType
Message types.
Definition: SGUIMessage.h:29
Definition: Canvas2D.h:36
Manages a hotkey setting for a GUI object.
Definition: CGUIHotkey.h:33
Definition: GUIObjectEventBroadcaster.h:57
void Set(T value, bool sendMessage)
'Uglified' operator=, so that SendMessage is explicit.
Definition: CGUISetting.h:119
The main object that represents a whole GUI page.
Definition: CGUI.h:80
Rectangle class used for screen rectangles.
Definition: Rect.h:31
GUI object such as a button or an input-box.
Definition: IGUIObject.h:63
CGUISimpleSetting< bool > m_Ghost
Definition: IGUIObject.h:538
CGUIHotkey m_Hotkey
Definition: IGUIObject.h:535
void UnsetScriptHandler(const CStr &eventName)
Deletes an event handler assigned to the given name, if such a handler exists.
Definition: IGUIObject.cpp:373
bool ApplyStyle(const CStr &StyleName)
Applies the given style to the object.
Definition: IGUIObject.cpp:288
Input::Reaction SendEvent(EGUIMessageType type, const CStr &eventName)
Send event to this GUI object (HandleMessage and ScriptEvent)
Definition: IGUIObject.cpp:396
virtual void Tick()
Called on every GUI tick unless the object or one of its parent is hidden/ghost.
Definition: IGUIObject.h:248
bool SetSettingFromString(const CStr &Setting, const CStrW &Value, const bool SendMessage)
Set a setting by string, regardless of what type it is.
Definition: IGUIObject.cpp:126
IGUIObject * GetParent() const
NOTE! This will not just return m_pParent, when that is need use it! There is one exception to it,...
Definition: IGUIObject.cpp:230
virtual float GetBufferedZ() const
Returns not the Z value, but the actual buffered Z value, i.e.
Definition: IGUIObject.cpp:313
bool IsRootObject() const
Returns whether this object is a child of the base object.
Definition: IGUIObject.cpp:543
virtual void AdditionalChildrenHandled()
Allow the GUI object to process after all child items were handled.
Definition: IGUIObject.h:389
CGUISimpleSetting< CStr > m_Style
Definition: IGUIObject.h:534
virtual void DrawInArea(CCanvas2D &canvas, CRect &area)
Definition: IGUIObject.cpp:556
const CStr & GetName() const
Get object name, name is unique.
Definition: IGUIObject.h:112
CGUISimpleSetting< bool > m_Enabled
Definition: IGUIObject.h:531
bool IsBaseObject() const
Returns whether this is the object all other objects are descendants of.
Definition: IGUIObject.cpp:538
bool m_CachedActualSizeDirty
Whether m_CacheActualSize is not up-to-date and will have to be recomputed when accessing it the next...
Definition: IGUIObject.h:529
void SetFocus()
Take focus!
Definition: IGUIObject.cpp:523
virtual void ResetStates()
Reset internal state of this object.
Definition: IGUIObject.cpp:240
CGUI & GetGUI()
Definition: IGUIObject.h:342
CGUISimpleSetting< float > m_Z
Definition: IGUIObject.h:536
CRect m_CachedActualSize
The actual size (usually) depends on the size of the parent.
Definition: IGUIObject.h:523
void UnregisterChild(IGUIObject *child)
Remove an object from the hierarchy.
Definition: IGUIObject.cpp:94
static void Trace(JSTracer *trc, void *data)
Definition: IGUIObject.h:469
std::map< CStr, IGUISetting * > m_Settings
Settings pool, all an object's settings are located here.
Definition: IGUIObject.h:503
std::vector< IGUIObject * > m_Children
Definition: IGUIObject.h:486
IGUIObject & operator=(IGUIObject &&)=delete
virtual Input::Reaction PreemptEvent(const SDL_Event &)
Some objects need to be able to pre-emptively process SDL_Event.
Definition: IGUIObject.cpp:577
void TraceMember(JSTracer *trc)
Definition: IGUIObject.cpp:548
bool IsEnabled() const
Returns whether this object is set to be hidden or ghost.
Definition: IGUIObject.cpp:489
virtual Input::Reaction ManuallyHandleKeys(const SDL_Event &)
Some objects need to handle the text-related SDL_Event manually.
Definition: IGUIObject.cpp:582
static const CStr EventNameMouseMove
Definition: IGUIObject.h:479
void ReleaseFocus()
Release focus.
Definition: IGUIObject.cpp:528
void SettingChanged(const CStr &Setting, const bool SendMessage)
Updates some internal data depending on the setting changed.
Definition: IGUIObject.cpp:138
std::map< CStr, JS::Heap< JSObject * > > m_ScriptHandlers
Definition: IGUIObject.h:509
static const CStr EventNameMouseLeave
Definition: IGUIObject.h:480
virtual const CRect & GetActualSize() const
Get the size of the object.
Definition: IGUIObject.cpp:251
void SetScriptHandler(const CStr &eventName, JS::HandleObject Function)
Assigns a JS function to the event name.
Definition: IGUIObject.cpp:362
Input::Reaction SendMouseEvent(EGUIMessageType type, const CStr &eventName)
Same as SendEvent, but passes mouse coordinates and button state as an argument.
Definition: IGUIObject.cpp:410
virtual void HandleSizeChanged()
All sizes are relative to resolution, and the calculation is not wanted in real time,...
Definition: IGUIObject.cpp:246
CRect m_VisibleArea
Definition: IGUIObject.h:514
bool IsHiddenOrGhostOrOutOfBoundaries() const
Definition: IGUIObject.cpp:573
void UpdateMouseOver(IGUIObject *const &pMouseOver)
Inputes the object that is currently hovered, this function updates this object accordingly (i....
Definition: IGUIObject.cpp:189
bool SettingExists(const CStr &Setting) const
Returns whether there is a setting with the given name registered.
Definition: IGUIObject.cpp:121
virtual const CStr & GetTooltipStyle() const
Definition: IGUIObject.h:205
virtual bool IsMouseHovering() const
This function returns true if the mouse is hovering over this GUI object and if this GUI object is th...
Definition: IGUIObject.h:104
void SetHidden(bool hidden)
Definition: IGUIObject.h:165
bool IsFocused() const
Check if object is focused.
Definition: IGUIObject.cpp:533
virtual void Draw(CCanvas2D &canvas)=0
Draws the object.
CGUISimpleSetting< CStrW > m_Tooltip
Definition: IGUIObject.h:540
CStr GetPresentableName() const
Definition: IGUIObject.cpp:510
virtual const CStrW & GetTooltipText() const
Definition: IGUIObject.h:204
void SetParent(IGUIObject *pParent)
Set parent of this object.
Definition: IGUIObject.h:338
static const CStr EventNameMouseEnter
Definition: IGUIObject.h:478
void RecurseObject(bool(IGUIObject::*isRestricted)() const, void(IGUIObject::*callbackFunction)(Args... args), Args &&... args)
Calls an IGUIObject member function recursively on this object and its children.
Definition: IGUIObject.h:264
void PlaySound(const CStrW &soundPath) const
Retrieves the configured sound filename from the given setting name and plays that once.
Definition: IGUIObject.cpp:504
CGUISimpleSetting< CGUISize > m_Size
Definition: IGUIObject.h:533
JSObject * GetJSObject()
Retrieves the JSObject representing this GUI object.
Definition: IGUIObject.cpp:479
virtual void RecalculateActualSize() const
Recompute the actual (absolute) size from scratch again and cache it.
Definition: IGUIObject.cpp:259
double m_LastClickTime[6]
Definition: IGUIObject.h:492
void RegisterSetting(const CStr &Name, IGUISetting *setting)
Registers the given setting with the GUI object.
Definition: IGUIObject.cpp:104
CGUISimpleSetting< bool > m_Hidden
Definition: IGUIObject.h:532
CGUISimpleSetting< bool > m_Absolute
Definition: IGUIObject.h:537
virtual void CreateJSObject()
Creates the JS object representing this page upon first use.
std::unique_ptr< IGUIProxyObject > m_JSObject
Definition: IGUIObject.h:512
void SetName(const CStr &Name)
Get object name.
Definition: IGUIObject.h:115
const CGUI & GetGUI() const
Definition: IGUIObject.h:343
virtual const std::vector< IGUIObject * > & GetVisibleChildren() const
Definition: IGUIObject.h:226
bool ScriptEvent(const CStr &eventName, const JS::HandleValueArray ¶mData=JS::HandleValueArray::empty())
Execute the script for a particular action.
Definition: IGUIObject.cpp:458
void RegisterChild(IGUIObject *child)
Add an object to the hierarchy.
Definition: IGUIObject.cpp:88
bool IsHiddenOrGhost() const
Returns whether this object is set to be hidden or ghost.
Definition: IGUIObject.cpp:499
IGUIObject(IGUIObject &&)=delete
CGUI & m_pGUI
Definition: IGUIObject.h:506
void SetIsInsideBoundaries(bool &isInsideBoundaries)
Definition: IGUIObject.h:227
void RegisterScriptHandler(const CStr &eventName, const CStr &Code, CGUI &pGUI)
Set the script handler for a particular object-specific action.
Definition: IGUIObject.cpp:327
IGUIObject * m_pParent
Definition: IGUIObject.h:489
void ChooseMouseOverAndClosest(IGUIObject *&pObject)
Inputs a reference pointer, checks if the new inputted object if hovered, if so, then check if this's...
Definition: IGUIObject.cpp:210
CGUISimpleSetting< CStr > m_TooltipStyle
Definition: IGUIObject.h:541
virtual bool IsMouseOver() const
This function checks if the mouse is hovering the rectangle that the base setting "size" makes.
Definition: IGUIObject.cpp:181
CStr m_Name
Definition: IGUIObject.h:483
void ReregisterSetting(const CStr &Name, IGUISetting *setting)
Definition: IGUIObject.cpp:112
bool m_MouseHovering
This variable is true if the mouse is hovering this object and this object is the topmost object show...
Definition: IGUIObject.h:498
const std::vector< IGUIObject * > & GetChildren() const
Return all child objects of the current object.
Definition: IGUIObject.h:124
virtual void HandleMessage(SGUIMessage &)
This function is called with different messages for instance when the mouse enters the object.
Definition: IGUIObject.h:256
bool m_IsInsideBoundaries
Definition: IGUIObject.h:515
virtual bool HandleAdditionalChildren(const XMBData &, const XMBElement &)
Handle additional children to the <object>-tag.
Definition: IGUIObject.h:380
virtual ~IGUIObject()
Definition: IGUIObject.cpp:80
bool IsHidden() const
Returns whether this is object is set to be hidden.
Definition: IGUIObject.cpp:494
CGUISimpleSetting< float > m_AspectRatio
Definition: IGUIObject.h:539
JS GUI proxies need to store some private data.
Definition: JSInterface_GUIProxy.h:57
This setting interface allows GUI objects to call setting function functions without having to know t...
Definition: CGUISetting.h:37
Handles the js interface with C++ GUI objects.
Definition: JSInterface_GUIProxy.h:132
Definition: XMBData.h:135
Message send to IGUIObject::HandleMessage() in order to give life to Objects manually with a derived ...
Definition: SGUIMessage.h:73