BsScriptGUILayout.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #pragma once
  2. #include "BsScriptEnginePrerequisites.h"
  3. #include "BsScriptGUIElement.h"
  4. namespace BansheeEngine
  5. {
  6. /**
  7. * @brief Interop class between C++ & CLR for GUILayout derived classes.
  8. */
  9. class BS_SCR_BE_EXPORT ScriptGUILayout : public TScriptGUIElementBase<ScriptGUILayout>
  10. {
  11. /**
  12. * @brief Contains information about an interop object that represents
  13. * a child of the layout.
  14. */
  15. struct ChildInfo
  16. {
  17. ScriptGUIElementBaseTBase* element;
  18. uint32_t gcHandle;
  19. };
  20. public:
  21. SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "GUILayout")
  22. /**
  23. * @brief Returns the internal wrapped GUILayout object.
  24. */
  25. GUILayout* getInternalValue() const { return mLayout; }
  26. /**
  27. * @brief Registers a new managed child GUI element and inserts it at
  28. * the end of the layout.
  29. */
  30. void addChild(ScriptGUIElementBaseTBase* element);
  31. /**
  32. * @brief Registers a new managed child GUI element and inserts it at a specific
  33. * location in the layout.
  34. */
  35. void insertChild(UINT32 index, ScriptGUIElementBaseTBase* element);
  36. /**
  37. * @brief Removes a managed GUI element from the layout.
  38. */
  39. void removeChild(ScriptGUIElementBaseTBase* element);
  40. /**
  41. * @copydoc ScriptGUIElementBaseTBase::destroy
  42. *
  43. * Destroys the layout and all of its managed children.
  44. */
  45. void destroy() override;
  46. /**
  47. * @brief Destroys all of the layout managed children.
  48. *
  49. * @note Useful if the children are managed but the layer itself is not.
  50. */
  51. void destroyChildren();
  52. /**
  53. * @brief Marks the layout as destroyed. When destroyed managed operations will be ignored
  54. * or return default values.
  55. */
  56. void markAsDestroyed();
  57. private:
  58. friend class ScriptGUIPanel;
  59. ScriptGUILayout(MonoObject* instance, GUILayout* layout);
  60. GUILayout* mLayout;
  61. Vector<ChildInfo> mChildren;
  62. bool mIsDestroyed;
  63. /************************************************************************/
  64. /* CLR HOOKS */
  65. /************************************************************************/
  66. static void internal_createInstanceX(MonoObject* instance, MonoArray* guiOptions);
  67. static void internal_createInstanceY(MonoObject* instance, MonoArray* guiOptions);
  68. static void internal_createInstancePanel(MonoObject* instance, INT16 depth, UINT16 depthRangeMin, UINT32 depthRangeMax, MonoArray* guiOptions);
  69. static void internal_addElement(ScriptGUILayout* instance, ScriptGUIElementBaseTBase* element);
  70. static void internal_insertElement(ScriptGUILayout* instance, UINT32 index, ScriptGUIElementBaseTBase* element);
  71. static UINT32 internal_getChildCount(ScriptGUILayout* instance);
  72. static MonoObject* internal_getChild(ScriptGUILayout* instance, UINT32 index);
  73. static void internal_createInstanceYFromScrollArea(MonoObject* instance, MonoObject* parentScrollArea);
  74. };
  75. /**
  76. * @brief Interop class between C++ & CLR for GUIPanel.
  77. */
  78. class BS_SCR_BE_EXPORT ScriptGUIPanel : public ScriptObject<ScriptGUIPanel>
  79. {
  80. public:
  81. SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "GUIPanel")
  82. /**
  83. * @brief Creates a new managed GUIPanel that wraps the provided native GUIPanel.
  84. */
  85. static MonoObject* createFromExisting(GUIPanel* panel);
  86. private:
  87. ScriptGUIPanel(MonoObject* instance);
  88. };
  89. }