UI.pkg 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. $#include "UI/UI.h"
  2. enum FontHintLevel
  3. {
  4. FONT_HINT_LEVEL_NONE = 0,
  5. FONT_HINT_LEVEL_LIGHT,
  6. FONT_HINT_LEVEL_NORMAL,
  7. };
  8. class UI : public Object
  9. {
  10. void SetCursor(Cursor* cursor);
  11. void SetFocusElement(UIElement* element, bool byKey = false);
  12. bool SetModalElement(UIElement* modalElement, bool enable);
  13. void Clear();
  14. void DebugDraw(UIElement* element);
  15. tolua_outside UIElement* UILoadLayout @ LoadLayout(File* source, XMLFile* styleFile = 0);
  16. tolua_outside UIElement* UILoadLayout @ LoadLayout(const String fileName, XMLFile* styleFile = 0);
  17. tolua_outside UIElement* UILoadLayout @ LoadLayout(XMLFile* file, XMLFile* styleFile = 0);
  18. bool SaveLayout(Serializer& dest, UIElement* element);
  19. void SetClipboardText(const String text);
  20. void SetDoubleClickInterval(float interval);
  21. void SetDragBeginInterval(float interval);
  22. void SetDragBeginDistance(int pixels);
  23. void SetDefaultToolTipDelay(float delay);
  24. void SetMaxFontTextureSize(int size);
  25. void SetNonFocusedMouseWheel(bool nonFocusedMouseWheel);
  26. void SetUseSystemClipboard(bool enable);
  27. void SetUseScreenKeyboard(bool enable);
  28. void SetUseMutableGlyphs(bool enable);
  29. void SetForceAutoHint(bool enable);
  30. void SetFontHintLevel(FontHintLevel level);
  31. void SetFontSubpixelThreshold(float threshold);
  32. void SetFontOversampling(int limit);
  33. void SetScale(float scale);
  34. void SetWidth(float width);
  35. void SetHeight(float height);
  36. void SetCustomSize(const IntVector2& size);
  37. void SetCustomSize(int width, int height);
  38. UIElement* GetRoot() const;
  39. UIElement* GetRootModalElement() const;
  40. Cursor* GetCursor() const;
  41. IntVector2 GetCursorPosition() const;
  42. UIElement* GetElementAt(const IntVector2& position, bool enabledOnly = true);
  43. UIElement* GetElementAt(int x, int y, bool enabledOnly = true);
  44. UIElement* GetFocusElement() const;
  45. UIElement* GetFrontElement() const;
  46. UIElement* GetDragElement(unsigned index);
  47. const String GetClipboardText() const;
  48. float GetDoubleClickInterval() const;
  49. float GetDragBeginInterval() const;
  50. int GetDragBeginDistance() const;
  51. float GetDefaultToolTipDelay() const;
  52. int GetMaxFontTextureSize() const;
  53. bool IsNonFocusedMouseWheel() const;
  54. bool GetUseSystemClipboard() const;
  55. bool GetUseScreenKeyboard() const;
  56. bool GetUseMutableGlyphs() const;
  57. bool GetForceAutoHint() const;
  58. FontHintLevel GetFontHintLevel() const;
  59. float GetFontSubpixelThreshold() const;
  60. int GetFontOversampling() const;
  61. bool HasModalElement() const;
  62. bool IsDragging() const;
  63. float GetScale() const;
  64. const IntVector2& GetCustomSize() const;
  65. tolua_readonly tolua_property__get_set UIElement* root;
  66. tolua_readonly tolua_property__get_set UIElement* rootModalElement;
  67. tolua_property__get_set Cursor* cursor;
  68. tolua_readonly tolua_property__get_set IntVector2 cursorPosition;
  69. tolua_readonly tolua_property__get_set UIElement* focusElement;
  70. tolua_readonly tolua_property__get_set UIElement* frontElement;
  71. tolua_property__get_set String clipboardText;
  72. tolua_property__get_set float doubleClickInterval;
  73. tolua_property__get_set float dragBeginInterval;
  74. tolua_property__get_set int dragBeginDistance;
  75. tolua_property__get_set float defaultToolTipDelay;
  76. tolua_property__get_set int maxFontTextureSize;
  77. tolua_property__is_set bool nonFocusedMouseWheel;
  78. tolua_property__get_set bool useSystemClipboard;
  79. tolua_property__get_set bool useScreenKeyboard;
  80. tolua_property__get_set bool useMutableGlyphs;
  81. tolua_property__get_set bool forceAutoHint;
  82. tolua_property__get_set FontHintLevel fontHintLevel;
  83. tolua_property__get_set float fontSubpixelThreshold;
  84. tolua_property__get_set int fontOversampling;
  85. tolua_readonly tolua_property__has_set bool modalElement;
  86. tolua_property__get_set float scale;
  87. tolua_property__get_set IntVector2& customSize;
  88. };
  89. UI* GetUI();
  90. tolua_readonly tolua_property__get_set UI* ui;
  91. ${
  92. static UIElement* UILoadLayout(UI* ui, File* source, XMLFile* styleFile)
  93. {
  94. if (!source)
  95. return 0;
  96. return ui->LoadLayout(*source, styleFile).Detach();
  97. }
  98. static UIElement* UILoadLayout(UI* ui, const String& fileName, XMLFile* styleFile)
  99. {
  100. File file(ui->GetContext(), fileName, FILE_READ);
  101. if (!file.IsOpen())
  102. return 0;
  103. return ui->LoadLayout(file, styleFile).Detach();
  104. }
  105. static UIElement* UILoadLayout(UI* ui, XMLFile* source, XMLFile* styleFile)
  106. {
  107. if (!source)
  108. return 0;
  109. return ui->LoadLayout(source, styleFile).Detach();
  110. }
  111. #define TOLUA_DISABLE_tolua_UILuaAPI_GetUI00
  112. static int tolua_UILuaAPI_GetUI00(lua_State* tolua_S)
  113. {
  114. return ToluaGetSubsystem<UI>(tolua_S);
  115. }
  116. #define TOLUA_DISABLE_tolua_get_ui_ptr
  117. #define tolua_get_ui_ptr tolua_UILuaAPI_GetUI00
  118. $}