class EE::UI::UISceneNode¶
Overview¶
#include <uiscenenode.hpp> class UISceneNode: public EE::Scene::SceneNode { public: // typedefs typedef std::function<void()> KeyBindingCommand; // construction virtual ~UISceneNode(); // methods static UISceneNode* New(EE::Window::Window* window = NULL); virtual Node* setSize(const Sizef& size); virtual Node* setSize(const Float& Width, const Float& Height); UISceneNode* setPixelsSize(const Sizef& size); UISceneNode* setPixelsSize(const Float& x, const Float& y); virtual const Sizef& getSize() const; virtual void update(const Time& elapsed); void setTranslator(Translator translator); void setTranslator(Translator&& translator); const Translator& getTranslator() const; Translator& getTranslator(); String getTranslatorString(const std::string& str); String getTranslatorString(const std::string& str, const String& defaultValue); String getTranslatorStringFromKey(const std::string& key, const String& defaultValue); String i18n(const std::string& key, const String& defaultValue); UIWidget* loadLayoutNodes(pugi::xml_node node, Node* parent, const Uint32& marker); UIWidget* loadLayoutFromFile(const std::string& layoutPath, Node* parent = NULL, const Uint32& marker = 0); UIWidget* loadLayoutFromString(const std::string& layoutString, Node* parent = NULL, const Uint32& marker = 0); UIWidget* loadLayoutFromString(const char* layoutString, Node* parent = NULL, const Uint32& marker = 0); UIWidget* loadLayoutFromMemory(const void* buffer, Int32 bufferSize, Node* parent = NULL, const Uint32& marker = 0); UIWidget* loadLayoutFromStream(IOStream& stream, Node* parent = NULL, const Uint32& marker = 0); UIWidget* loadLayoutFromPack(Pack* pack, const std::string& FilePackPath, Node* parent = NULL); void setStyleSheet(const CSS::StyleSheet& styleSheet, bool loadStyle = true); void setStyleSheet(const std::string& inlineStyleSheet); void combineStyleSheet(const CSS::StyleSheet& styleSheet, bool forceReloadStyle = true); void combineStyleSheet(const std::string& inlineStyleSheet, bool forceReloadStyle = true, const Uint32& marker = 0); CSS::StyleSheet& getStyleSheet(); bool hasStyleSheet(); bool isLoading() const; UIThemeManager* getUIThemeManager() const; UIWidget* getRoot() const; void invalidateStyle(UIWidget* widget, bool tryReinsert = false); void invalidateStyleState(UIWidget* widget, bool disableCSSAnimations = false, bool tryReinsert = false); void invalidateLayout(UILayout* widget); void setIsLoading(bool isLoading); void updateDirtyLayouts(); void updateDirtyStyles(); void updateDirtyStyleStates(); bool isUpdatingLayouts() const; UIIconThemeManager* getUIIconThemeManager() const; UIIcon* findIcon(const std::string& iconName); Drawable* findIconDrawable(const std::string& iconName, const size_t& drawableSize); KeyBindings& getKeyBindings(); void setKeyBindings(const KeyBindings& keyBindings); void addKeyBindingString(const std::string& shortcut, const std::string& command); void addKeyBinding(const KeyBindings::Shortcut& shortcut, const std::string& command); void replaceKeyBindingString(const std::string& shortcut, const std::string& command); void replaceKeyBinding(const KeyBindings::Shortcut& shortcut, const std::string& command); void addKeyBindsString(const std::map<std::string, std::string>& binds); void addKeyBinds(const std::map<KeyBindings::Shortcut, std::string>& binds); void setKeyBindingCommand(const std::string& command, KeyBindingCommand func); void executeKeyBindingCommand(const std::string& command); UIEventDispatcher* getUIEventDispatcher() const; ColorSchemePreference getColorSchemePreference() const; void setColorSchemePreference(const ColorSchemeExtPreference& colorSchemePreference); void setColorSchemePreference(const ColorSchemePreference& colorSchemePreference); const Uint32& getMaxInvalidationDepth() const; void setMaxInvalidationDepth(const Uint32& maxInvalidationDepth); virtual void nodeToWorldTranslation(Vector2f& Pos) const; void reloadStyle(bool disableAnimations = false, bool forceReApplyProperties = false, bool resetPropertiesCache = false); bool hasThreadPool() const; std::shared_ptr<ThreadPool> getThreadPool(); void setThreadPool(const std::shared_ptr<ThreadPool>& threadPool); void setTheme(UITheme* theme); CSS::MediaFeatures getMediaFeatures() const; std::vector<UIWidget*> loadNode(pugi::xml_node node, Node* parent, const Uint32& marker = 0); };
Inherited Members¶
public: // typedefs typedef std::function<void(const Event*)> EventCallback; // methods virtual void setPosition(const Vector2f& position); virtual void setRotation(float angle); virtual void setScale(float factorX, float factorY); virtual void setScale(const Vector2f& factors); virtual void setScaleOrigin(float x, float y); virtual void setScaleOrigin(const Vector2f& origin); virtual void setRotationOrigin(float x, float y); virtual void setRotationOrigin(const Vector2f& origin); virtual const Vector2f& getRotationOrigin() const; virtual const Vector2f& getPosition() const; virtual const float& getRotation() const; virtual const Vector2f& getScale() const; virtual const Vector2f& getScaleOrigin() const; void move(float offsetX, float offsetY); void move(const Vector2f& offset); void rotate(float angle); void scale(float factorX, float factorY); void scale(const Vector2f& factor); const Transform& getTransform() const; const Transform& getInverseTransform() const; static Node* New(); virtual void worldToNodeTranslation(Vector2f& position) const; virtual void nodeToWorldTranslation(Vector2f& position) const; virtual void worldToNode(Vector2i& pos) const; virtual void nodeToWorld(Vector2i& pos) const; virtual void worldToNode(Vector2f& pos) const; virtual void nodeToWorld(Vector2f& pos) const; virtual Uint32 getType() const; virtual bool isType(const Uint32& type) const; void messagePost(const NodeMessage* Msg); virtual void setPosition(const Vector2f& Pos); virtual Node* setPosition(const Float& x, const Float& y); virtual Node* setSize(const Sizef& size); Node* setSize(const Float& Width, const Float& Height); virtual const Sizef& getSize() const; const Sizef& getPixelsSize() const; Node* setVisible(const bool& visible, bool emitEventNotification = true); Node* setChildrenVisibility(bool visible, bool emitEventNotification = true); bool isVisible() const; bool hasVisibility() const; Node* setEnabled(const bool& enabled); bool isEnabled() const; bool isDisabled() const; Node* getParent() const; Node* setParent(Node* parent); virtual void close(); virtual void draw(); virtual void update(const Time& time); virtual void scheduledUpdate(const Time& time); Node* getNextNode() const; Node* getPrevNode() const; Node* getNextNodeLoop() const; Node* setData(const UintPtr& data); const UintPtr& getData() const; Node* setBlendMode(const BlendMode& blend); const BlendMode& getBlendMode() const; Node* toFront(); Node* toBack(); void toPosition(const Uint32& position); const Uint32& getNodeFlags() const; void setNodeFlags(const Uint32& flags); bool isSceneNode() const; bool isUISceneNode() const; bool isUINode() const; bool isWidget() const; bool isWindow() const; bool isLayout() const; bool isClipped() const; bool isRotated() const; bool isScaled() const; bool isFrameBuffer() const; bool isMouseOver() const; bool isMouseOverMeOrChildren() const; bool isMeOrParentTreeVisible() const; bool isMeOrParentTreeRotated() const; bool isMeOrParentTreeScaled() const; bool isMeOrParentTreeScaledOrRotated() const; bool isMeOrParentTreeScaledOrRotatedOrFrameBuffer() const; Uint32 addEventListener(const Uint32& eventType, const EventCallback& callback); Uint32 on(const Uint32& eventType, const EventCallback& callback); Uint32 onClick(const std::function<void(const MouseEvent*)>& callback, const MouseButton& button = MouseButton::EE_BUTTON_LEFT); Uint32 onDoubleClick(const std::function<void(const MouseEvent*)>& callback, const MouseButton& button = MouseButton::EE_BUTTON_LEFT); void removeEventsOfType(const Uint32& eventType); void removeEventListener(const Uint32& callbackId); void removeEventListener(const std::vector<Uint32>& callbacksIds); void clearEventListener(); Node* getFirstChild() const; Node* getLastChild() const; const Polygon2f& getWorldPolygon(); const Rectf& getWorldBounds(); bool isParentOf(const Node* node) const; void sendEvent(const Event* Event); void sendMouseEvent(const Uint32& Event, const Vector2i& position, const Uint32& flags); void sendCommonEvent(const Uint32& Event); void sendTextEvent(const Uint32& event, const std::string& text); void closeAllChildren(); const std::string& getId() const; virtual Node* setId(const std::string& id); const String::HashType& getIdHash() const; Node* find(const std::string& id) const; Node* hasChild(const std::string& id) const; template <typename T> T* find(const std::string& id) const; template <typename T> T* bind(const std::string& id, T*& node); template <typename T> T* asType(); template <typename T> const T* asConstType() const; Node* findByType(const Uint32& type) const; template <typename T> T* findByType(const Uint32& type) const; template <typename T> T* bindByType(const Uint32& type, T*& node); std::vector<Node*> findAllByType(const Uint32& type) const; template <typename T> std::vector<T*> findAllByType(const Uint32& type) const; bool inNodeTree(Node* node) const; bool isReverseDraw() const; void setReverseDraw(bool reverseDraw); void invalidateDraw(); virtual void setRotation(float angle); void setRotation(const Float& angle, const OriginPoint& center); const OriginPoint& getRotationOriginPoint() const; void setRotationOriginPoint(const OriginPoint& center); void setRotationOriginPointPixels(const OriginPoint& center); void setRotationOriginPointX(const std::string& xEq); void setRotationOriginPointY(const std::string& yEq); Vector2f getRotationCenter() const; void setScale(const Float& scale); virtual void setScale(const Vector2f& scale); void setScale(const Vector2f& scale, const OriginPoint& center); void setScale(const Float& scale, const OriginPoint& center); const OriginPoint& getScaleOriginPoint() const; void setScaleOriginPoint(const OriginPoint& center); void setScaleOriginPointPixels(const OriginPoint& center); void setScaleOriginPointX(const std::string& xEq); void setScaleOriginPointY(const std::string& yEq); Vector2f getScaleCenter() const; virtual void setScale(float factorX, float factorY); virtual void setScaleOrigin(float x, float y); virtual void setRotationOrigin(float x, float y); const Float& getAlpha() const; virtual void setAlpha(const Float& alpha); virtual void setChildrenAlpha(const Float& alpha); ActionManager* getActionManager() const; Node* runAction(Action* action); bool removeAction(Action* action); bool removeActions(const std::vector<Action*>& actions); bool removeActionsByTag(const Action::UniqueID& tag); std::vector<Action*> getActions(); std::vector<Action*> getActionsByTag(const Action::UniqueID& tag); void clearActions(); Transform getLocalTransform() const; Transform getGlobalTransform() const; Transform getNodeToWorldTransform() const; Transform getWorldToNodeTransform() const; Vector2f convertToNodeSpace(const Vector2f& worldPoint) const; Vector2f convertToWorldSpace(const Vector2f& nodePoint) const; Rectf getLocalBounds() const; bool hasFocus() const; bool hasFocusWithin() const; virtual Node* setFocus(NodeFocusReason reason = NodeFocusReason::Unknown); Node* getFirstWidget() const; Node* getParentWidget() const; void enableReportSizeChangeToChildren(); void disableReportSizeChangeToChildren(); bool reportSizeChangeToChildren() const; Node* centerHorizontal(); Node* centerVertical(); Node* center(); Node* clipEnable(); Node* clipDisable(); void writeNodeFlag(const Uint32& Flag, const Uint32& Val); SceneNode* getSceneNode() const; EventDispatcher* getEventDispatcher() const; virtual bool isDrawInvalidator() const; bool invalidated() const; virtual void invalidate(Node* invalidator); Uint32 getChildCount() const; Uint32 getChildOfTypeCount(const Uint32& type) const; Node* getChildAt(Uint32 index) const; Uint32 getNodeIndex() const; Uint32 getNodeOfTypeIndex() const; void runOnMainThread(Actions::Runnable::RunnableFunc runnable, const Time& delay = Seconds(0), const Action::UniqueID& uniqueIdentifier = 0); bool ensureMainThread(Actions::Runnable::RunnableFunc runnable, const Action::UniqueID& uniqueIdentifier = 0); void setTimeout(Actions::Runnable::RunnableFunc runnable, const Time& delay = Seconds(0), const Action::UniqueID& uniqueIdentifier = 0); void setInterval(Actions::Runnable::RunnableFunc runnable, const Time& interval, const Action::UniqueID& uniqueIdentifier = 0); void debounce(Actions::Runnable::RunnableFunc runnable, const Time& delay, const Action::UniqueID& uniqueIdentifier); bool isChild(Node* child) const; bool inParentTreeOf(Node* child) const; bool inParentTreeOfType(Uint32 type) const; Node* getParentOfType(Uint32 type) const; void setLoadingState(bool loading); bool isLoadingState() const; virtual void onIdChange(); bool isClosing() const; bool isClosingChildren() const; virtual Node* overFind(const Vector2f& Point); void detach(); void forEachNode(std::function<void(Node*)> func); void forEachChild(std::function<void(Node*)> func); virtual void nodeDraw(); Uint32 forceKeyDown(const KeyEvent& event); Uint32 foceKeyUp(const KeyEvent& event); Uint32 forceTextInput(const TextInputEvent& Event); const Vector2f& getScreenPos() const; Rectf getScreenRect() const; bool hasEventsOfType(const Uint32& eventType) const; static SceneNode* New(EE::Window::Window* window = NULL); void enableFrameBuffer(); void disableFrameBuffer(); bool ownsFrameBuffer() const; virtual void draw(); virtual void update(const Time& elapsed); void enableDrawInvalidation(); void disableDrawInvalidation(); EE::Window::Window* getWindow(); FrameBuffer* getFrameBuffer() const; void setEventDispatcher(EventDispatcher* eventDispatcher); EventDispatcher* getEventDispatcher() const; void setDrawDebugData(bool debug); bool getDrawDebugData() const; void setDrawBoxes(bool draw); bool getDrawBoxes() const; void setHighlightOver(bool Highlight); bool getHighlightOver() const; void setHighlightFocus(bool Highlight); bool getHighlightFocus() const; void setHighlightInvalidation(bool Highlight); bool getHighlightInvalidation() const; void setHighlightOverColor(const Color& Color); const Color& getHighlightOverColor() const; void setHighlightFocusColor(const Color& Color); const Color& getHighlightFocusColor() const; void setHighlightInvalidationColor(const Color& Color); const Color& getHighlightInvalidationColor() const; const Time& getElapsed() const; bool usesInvalidation() const; void setUseGlobalCursors(bool use); bool getUseGlobalCursors(); void setCursor(Cursor::Type cursor); virtual bool isDrawInvalidator() const; ActionManager* getActionManager() const; void subscribeScheduledUpdate(Node* node); void unsubscribeScheduledUpdate(Node* node); bool isSubscribedForScheduledUpdate(Node* node); void addMouseOverNode(Node* node); void removeMouseOverNode(Node* node); bool getUpdateAllChildren() const; void setUpdateAllChildren(bool updateAllChildren); const Float& getDPI() const; bool getVerbose() const; void setVerbose(bool verbose);
Detailed Documentation¶
Construction¶
virtual ~UISceneNode()
Destroys the UISceneNode and cleans up resources.
Deletes theme managers, icon theme manager, font faces, and event dispatcher. Also calls childDeleteAll() to ensure proper cleanup order (before thread pool).
Methods¶
static UISceneNode* New(EE::Window::Window* window = NULL)
Creates a new UISceneNode instance.
This is the factory method for creating UISceneNode instances.
Parameters:
window |
Pointer to the window to associate with this UI scene node. If NULL, uses the current window from Engine. |
Returns:
Pointer to the newly created UISceneNode instance.
virtual Node* setSize(const Sizef& size)
Sets the size in density-independent pixels (dp).
Override of SceneNode::setSize to also update dp size and trigger media changes.
Parameters:
size |
The new size in dp. |
Returns:
Pointer to this node for method chaining.
virtual Node* setSize(const Float& Width, const Float& Height)
Sets the size in density-independent pixels (dp).
Override of SceneNode::setSize with individual dimensions.
Parameters:
Width |
The width in dp. |
Height |
The height in dp. |
Returns:
Pointer to this node for method chaining.
UISceneNode* setPixelsSize(const Sizef& size)
Sets the size in actual screen pixels.
Sets the pixel size directly and updates the dp size accordingly.
Parameters:
size |
The new size in pixels. |
Returns:
Pointer to this node for method chaining.
UISceneNode* setPixelsSize(const Float& x, const Float& y)
Sets the size in actual screen pixels.
Sets the pixel size using individual dimensions.
Parameters:
x |
The width in pixels. |
y |
The height in pixels. |
Returns:
Pointer to this node for method chaining.
virtual const Sizef& getSize() const
Gets the size in density-independent pixels (dp).
Returns:
The size as a const Sizef reference in dp.
virtual void update(const Time& elapsed)
Updates the UISceneNode.
Override that adds UI-specific update logic including:
Updating dirty styles, style states, and layouts
Handling multiple invalidation passes if needed
Processing scheduled updates
Parameters:
elapsed |
The time elapsed since the last update. |
void setTranslator(Translator translator)
Sets the translator for internationalization.
The translator is used to translate strings throughout the UI.
Parameters:
translator |
The Translator object to set. |
void setTranslator(Translator&& translator)
Sets the translator for internationalization.
The translator is used to translate strings throughout the UI.
Parameters:
translator |
The Translator object to set. |
const Translator& getTranslator() const
Gets the translator as a const reference.
Returns:
The const Translator reference.
Translator& getTranslator()
Gets the translator as a non-const reference.
Returns:
The Translator reference for modification.
String getTranslatorString(const std::string& str)
Gets a translated string.
Translates the given string using the translator. Supports special @string syntax for lookups and function-style expressions.
Parameters:
str |
The string to translate. |
Returns:
The translated string, or the original if no translation found.
String getTranslatorString(const std::string& str, const String& defaultValue)
Gets a translated string with default value.
Similar to getTranslatorString() but returns defaultValue if translation is not found.
Parameters:
str |
The string to translate. |
defaultValue |
The default value to use if translation fails. |
Returns:
The translated string or default value.
String getTranslatorStringFromKey(const std::string& key, const String& defaultValue)
Gets a translated string from a translation key.
Looks up the translation using the specified key.
Parameters:
key |
The translation key to look up. |
defaultValue |
The default value if key not found. |
Returns:
The translated string or default value.
String i18n(const std::string& key, const String& defaultValue)
Translates a string (internationalization shorthand).
Convenience method equivalent to getTranslatorStringFromKey().
Parameters:
key |
The translation key. |
defaultValue |
The default value if translation not found. |
Returns:
The translated string or default value.
UIWidget* loadLayoutNodes(pugi::xml_node node, Node* parent, const Uint32& marker)
Loads UI layout from an XML node.
Parses the XML node and creates UIWidgets accordingly.
Parameters:
node |
The XML node to load from. |
parent |
The parent node to attach widgets to (default: this). |
marker |
A marker value to associate with loaded styles. |
Returns:
The root UIWidget created, or NULL if none.
UIWidget* loadLayoutFromFile(const std::string& layoutPath, Node* parent = NULL, const Uint32& marker = 0)
Loads a UI layout from a file.
Parses an XML layout file and creates the UI hierarchy.
Parameters:
layoutPath |
Path to the layout file. |
parent |
Parent node for the layout (default: this). |
marker |
Marker for style association. |
Returns:
The root widget, or NULL if loading failed.
UIWidget* loadLayoutFromString(const std::string& layoutString, Node* parent = NULL, const Uint32& marker = 0)
Loads a UI layout from a string.
Parses an XML string and creates the UI hierarchy.
Parameters:
layoutString |
The XML layout string. |
parent |
Parent node for the layout (default: this). |
marker |
Marker for style association. |
Returns:
The root widget, or NULL if parsing failed.
UIWidget* loadLayoutFromString(const char* layoutString, Node* parent = NULL, const Uint32& marker = 0)
Loads a UI layout from a C string.
Parses an XML C-string and creates the UI hierarchy.
Parameters:
layoutString |
The XML layout C-string. |
parent |
Parent node for the layout (default: this). |
marker |
Marker for style association. |
Returns:
The root widget, or NULL if parsing failed.
UIWidget* loadLayoutFromMemory(const void* buffer, Int32 bufferSize, Node* parent = NULL, const Uint32& marker = 0)
Loads a UI layout from a memory buffer.
Parses XML from a memory buffer and creates the UI hierarchy.
Parameters:
buffer |
Pointer to the XML data in memory. |
bufferSize |
Size of the buffer in bytes. |
parent |
Parent node for the layout (default: this). |
marker |
Marker for style association. |
Returns:
The root widget, or NULL if parsing failed.
UIWidget* loadLayoutFromStream(IOStream& stream, Node* parent = NULL, const Uint32& marker = 0)
Loads a UI layout from an I/O stream.
Reads XML from an IOStream and creates the UI hierarchy.
Parameters:
stream |
The input stream to read from. |
parent |
Parent node for the layout (default: this). |
marker |
Marker for style association. |
Returns:
The root widget, or NULL if reading or parsing failed.
UIWidget* loadLayoutFromPack(Pack* pack, const std::string& FilePackPath, Node* parent = NULL)
Loads a UI layout from a pack file.
Extracts XML from a pack (archive) and creates the UI hierarchy.
Parameters:
pack |
Pointer to the Pack to read from. |
FilePackPath |
Path within the pack to the layout file. |
parent |
Parent node for the layout (default: this). |
Returns:
The root widget, or NULL if extraction or parsing failed.
void setStyleSheet(const CSS::StyleSheet& styleSheet, bool loadStyle = true)
Sets the stylesheet for this UISceneNode.
Replaces the current stylesheet with a new one and optionally loads the styles immediately.
Parameters:
styleSheet |
The CSS StyleSheet to set. |
loadStyle |
If true, applies the styles immediately (default: true). |
void setStyleSheet(const std::string& inlineStyleSheet)
Sets the stylesheet from an inline CSS string.
Parses the CSS string and sets it as the stylesheet.
Parameters:
inlineStyleSheet |
The CSS stylesheet as a string. |
void combineStyleSheet(const CSS::StyleSheet& styleSheet, bool forceReloadStyle = true)
Combines a stylesheet with the existing one.
Merges the given stylesheet into the current stylesheet.
Parameters:
styleSheet |
The CSS StyleSheet to combine. |
forceReloadStyle |
If true, forces immediate style reload (default: true). |
void combineStyleSheet(const std::string& inlineStyleSheet, bool forceReloadStyle = true, const Uint32& marker = 0)
Combines an inline stylesheet with the existing one.
Parses the CSS string and merges it with the current stylesheet.
Parameters:
inlineStyleSheet |
The CSS stylesheet as a string. |
forceReloadStyle |
If true, forces immediate style reload (default: true). |
marker |
Marker to associate with the new styles. |
CSS::StyleSheet& getStyleSheet()
Gets the reference to the current stylesheet.
Returns:
Reference to the CSS StyleSheet.
bool hasStyleSheet()
Checks if a stylesheet is set.
Returns:
True if a non-empty stylesheet exists, false otherwise.
bool isLoading() const
Checks if the UISceneNode is currently loading.
This flag is set during layout loading operations.
Returns:
Const reference to the loading state boolean.
UIThemeManager* getUIThemeManager() const
Gets the UIThemeManager.
The theme manager is responsible for loading and providing UI themes.
Returns:
Pointer to the UIThemeManager.
UIWidget* getRoot() const
Gets the root widget of this UISceneNode.
The root is a UIRoot widget that contains all other UI widgets.
Returns:
Pointer to the root UIWidget.
void invalidateStyle(UIWidget* widget, bool tryReinsert = false)
Invalidates the style of a widget.
Marks the widget’s style as needing to be reloaded. The widget will have its CSS re-applied during the next update cycle.
Parameters:
widget |
Pointer to the UIWidget to invalidate. |
tryReinsert |
If true, attempts to reposition the widget in the dirty set. |
void invalidateStyleState(UIWidget* widget, bool disableCSSAnimations = false, bool tryReinsert = false)
Invalidates the style state of a widget.
Marks the widget’s style state (pseudo-classes) as needing to be re-evaluated and re-applied.
Parameters:
widget |
Pointer to the UIWidget to invalidate. |
disableCSSAnimations |
If true, disables CSS animations during the update. |
tryReinsert |
If true, attempts to reposition the widget in the dirty set. |
void invalidateLayout(UILayout* widget)
Invalidates the layout of a UILayout widget.
Marks the layout as needing to be recalculated. The layout will be updated during the next update cycle.
Parameters:
widget |
Pointer to the UILayout to invalidate. |
void setIsLoading(bool isLoading)
Sets the loading state flag.
This is typically managed internally but can be set manually if needed.
Parameters:
isLoading |
The loading state to set. |
void updateDirtyLayouts()
Updates all dirty layouts.
Processes the mDirtyLayouts set and calls updateLayoutTree() on each layout that needs recalculation.
void updateDirtyStyles()
Updates all dirty styles.
Processes the mDirtyStyle set and calls reloadStyle() on each widget that needs its CSS style re-applied.
void updateDirtyStyleStates()
Updates all dirty style states.
Processes the mDirtyStyleState set and calls reportStyleStateChangeRecursive() on each widget that needs its pseudo-class state re-evaluated.
bool isUpdatingLayouts() const
Checks if dirty layouts are currently being updated.
Useful to avoid re-entrancy or to check if layout updates are in progress.
Returns:
Const reference to the boolean indicating layout update status.
UIIconThemeManager* getUIIconThemeManager() const
Gets the UIIconThemeManager.
The icon theme manager handles lookups of icon drawables by name.
Returns:
Pointer to the UIIconThemeManager.
UIIcon* findIcon(const std::string& iconName)
Finds an icon by name.
Searches the icon theme manager for an icon with the specified name.
Parameters:
iconName |
The name of the icon to find. |
Returns:
Pointer to the UIIcon, or nullptr if not found.
Drawable* findIconDrawable(const std::string& iconName, const size_t& drawableSize)
Finds an icon drawable by name and size.
Convenience method that gets an icon and then retrieves a drawable of the specified size.
Parameters:
iconName |
The name of the icon to find. |
drawableSize |
The desired size of the drawable in pixels. |
Returns:
Pointer to the Drawable, or nullptr if not found.
KeyBindings& getKeyBindings()
Gets the keybindings manager.
The keybindings system maps keyboard shortcuts to commands.
Returns:
Reference to the KeyBindings object.
void setKeyBindings(const KeyBindings& keyBindings)
Sets the keybindings.
Replaces the current keybindings with a new set.
Parameters:
keyBindings |
The KeyBindings object to set. |
void addKeyBindingString(const std::string& shortcut, const std::string& command)
Adds a keybinding from string shortcut to command.
Shortcut format is typically like “Ctrl+S” or “Alt+Enter”.
Parameters:
shortcut |
The string representation of the shortcut. |
command |
The command to execute when shortcut is pressed. |
void addKeyBinding(const KeyBindings::Shortcut& shortcut, const std::string& command)
Adds a keybinding from Shortcut to command.
Parameters:
shortcut |
The KeyBindings::Shortcut structure. |
command |
The command to execute when shortcut is pressed. |
void replaceKeyBindingString(const std::string& shortcut, const std::string& command)
Replaces a keybinding using string shortcut.
If the shortcut already exists, it is replaced; otherwise it is added.
Parameters:
shortcut |
The string representation of the shortcut. |
command |
The command to execute. |
void replaceKeyBinding(const KeyBindings::Shortcut& shortcut, const std::string& command)
Replaces a keybinding using Shortcut.
If the shortcut already exists, it is replaced; otherwise it is added.
Parameters:
shortcut |
The KeyBindings::Shortcut structure. |
command |
The command to execute. |
void addKeyBindsString(const std::map<std::string, std::string>& binds)
Adds multiple keybindings from string map.
Parameters:
binds |
Map of shortcut strings to command strings. |
void addKeyBinds(const std::map<KeyBindings::Shortcut, std::string>& binds)
Adds multiple keybindings from Shortcut map.
Parameters:
binds |
Map of KeyBindings::Shortcut to command strings. |
void setKeyBindingCommand(const std::string& command, KeyBindingCommand func)
Sets a function to execute for a command.
Associates a command string with a callable function. This allows keybindings to trigger custom code.
Parameters:
command |
The command string. |
func |
The function to call when the command is executed. |
void executeKeyBindingCommand(const std::string& command)
Executes a keybinding command.
Triggers the function associated with the given command string.
Parameters:
command |
The command string to execute. |
UIEventDispatcher* getUIEventDispatcher() const
Gets the UI-specific event dispatcher.
Casts the generic event dispatcher to a UIEventDispatcher.
Returns:
Pointer to the UIEventDispatcher, or nullptr if not set.
ColorSchemePreference getColorSchemePreference() const
Gets the current color scheme preference.
Returns:
The ColorSchemePreference (Light or Dark).
void setColorSchemePreference(const ColorSchemeExtPreference& colorSchemePreference)
Sets the color scheme preference from extended preference.
Converts extended preference (Light/Dark/System) to standard preference. For System, detects OS preference automatically.
Parameters:
colorSchemePreference |
The extended ColorSchemeExtPreference. |
void setColorSchemePreference(const ColorSchemePreference& colorSchemePreference)
Sets the color scheme preference directly.
Controls whether the UI uses light or dark color scheme by default.
Parameters:
colorSchemePreference |
The ColorSchemePreference. |
const Uint32& getMaxInvalidationDepth() const
Gets the maximum invalidation depth.
This controls how many times the update cycle will re-process dirty states to ensure all cascading style/layout changes are applied.
Returns:
Const reference to max invalidation depth.
void setMaxInvalidationDepth(const Uint32& maxInvalidationDepth)
Sets the maximum invalidation depth.
Parameters:
maxInvalidationDepth |
The maximum number of invalidation passes. |
virtual void nodeToWorldTranslation(Vector2f& Pos) const
Transforms node-local coordinates to world coordinates.
Override that uses dp (density-independent pixels) positions.
Parameters:
Pos |
Reference to the position to transform (modified in place). |
void reloadStyle(bool disableAnimations = false, bool forceReApplyProperties = false, bool resetPropertiesCache = false)
Reloads the UI styles.
Forces all widgets to re-apply their CSS styles, optionally disabling animations, forcing re-application, or resetting property caches.
Parameters:
disableAnimations |
If true, CSS animations are disabled during reload. |
forceReApplyProperties |
If true, all properties are re-applied even if unchanged. |
resetPropertiesCache |
If true, property cache is cleared. |
bool hasThreadPool() const
Checks if a thread pool is available.
Returns:
True if a thread pool has been set, false otherwise.
std::shared_ptr<ThreadPool> getThreadPool()
Gets the thread pool.
Returns:
Shared pointer to the ThreadPool, or nullptr if none set.
void setThreadPool(const std::shared_ptr<ThreadPool>& threadPool)
Sets the thread pool for background tasks.
Parameters:
threadPool |
Shared pointer to the ThreadPool to use. |
void setTheme(UITheme* theme)
Sets the theme for the entire UI scene.
Applies the theme to the root widget and all children.
Parameters:
theme |
Pointer to the UITheme to set. |
CSS::MediaFeatures getMediaFeatures() const
Gets the current media features.
Returns information about the current media environment (screen size, resolution, color scheme, etc.) for CSS media queries.
Returns:
CSS::MediaFeatures structure with current media values.
std::vector<UIWidget*> loadNode(pugi::xml_node node, Node* parent, const Uint32& marker = 0)
Loads UI nodes from XML.
Core method that parses XML and creates widget hierarchy.
Parameters:
node |
The XML node to parse. |
parent |
The parent to attach widgets to. |
marker |
Marker for style association. |
Returns:
Vector of root widgets created.