UI.pkg 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. $#include "UI.h"
  2. /// %UI subsystem. Manages the graphical user interface.
  3. class UI : public Object
  4. {
  5. public:
  6. /// Set cursor UI element.
  7. void SetCursor(Cursor* cursor);
  8. /// Set focused UI element.
  9. void SetFocusElement(UIElement* element);
  10. /// Set modal element. Until all the modal elements are dismissed, all the inputs and events are only sent to them. Return true when successful.
  11. /// Only the modal element can clear its modal status or when it is being destructed.
  12. /// UI subystem auto-removes modal element when an ESC key is pressed, however if this is not desirable, setting a user-defined variable "NoAutoRemove" in the modal element would prevent this.
  13. /// In that case, the modal element will only have its modal flag reset and reparented back to its original parent.
  14. bool SetModalElement(UIElement* modalElement, bool enable);
  15. /// Clear the UI (excluding the cursor.)
  16. void Clear();
  17. /// Update the UI logic. Called by HandlePostUpdate().
  18. void Update(float timeStep);
  19. /// Update the UI for rendering. Called by HandleRenderUpdate().
  20. void RenderUpdate();
  21. /// Render the UI.
  22. void Render();
  23. /// Debug draw a UI element.
  24. void DebugDraw(UIElement* element);
  25. /// Save a UI layout to an XML file. Return true if successful.
  26. bool SaveLayout(Serializer& dest, UIElement* element);
  27. /// Set clipboard text.
  28. void SetClipBoardText(const String& text);
  29. /// Set mouse wheel handling flag.
  30. void SetNonFocusedMouseWheel(bool nonFocusedMouseWheel);
  31. /// Return root UI element.
  32. UIElement* GetRoot() const { return rootElement_; }
  33. /// Return root modal element.
  34. UIElement* GetRootModalElement() const { return rootModalElement_; }
  35. /// Return cursor.
  36. Cursor* GetCursor() const { return cursor_; }
  37. /// Return UI element at screen coordinates.
  38. UIElement* GetElementAt(const IntVector2& position, bool enabledOnly = true);
  39. /// Return UI element at screen coordinates.
  40. UIElement* GetElementAt(int x, int y, bool enabledOnly = true);
  41. /// Return focused element.
  42. UIElement* GetFocusElement() const { return focusElement_; }
  43. /// Return topmost enabled root-level non-modal element.
  44. UIElement* GetFrontElement() const;
  45. /// Return cursor position.
  46. IntVector2 GetCursorPosition() const;
  47. /// Return clipboard text.
  48. const String& GetClipBoardText() const { return clipBoard_; }
  49. /// Return mouse wheel handling flag.
  50. bool IsNonFocusedMouseWheel() const { return nonFocusedMouseWheel_; }
  51. /// Return true when UI has modal element(s).
  52. bool HasModalElement() const;
  53. };