BsScriptGUILayout.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. private:
  47. friend class ScriptGUIPanel;
  48. /**
  49. * @brief Constructor.
  50. *
  51. * @param instance Managed GUILayout instance.
  52. * @param layout Native GUILayout instance.
  53. * @param ownsNative Does this object own the native instance. If it does it will destroy the
  54. * object when ::destroy() is called, otherwise it is up to the caller to destroy it.
  55. */
  56. ScriptGUILayout(MonoObject* instance, GUILayout* layout, bool ownsNative = true);
  57. GUILayout* mLayout;
  58. Vector<ChildInfo> mChildren;
  59. bool mIsDestroyed;
  60. bool mOwnsNative;
  61. /************************************************************************/
  62. /* CLR HOOKS */
  63. /************************************************************************/
  64. static void internal_createInstanceX(MonoObject* instance, MonoArray* guiOptions);
  65. static void internal_createInstanceY(MonoObject* instance, MonoArray* guiOptions);
  66. static void internal_createInstancePanel(MonoObject* instance, INT16 depth, UINT16 depthRangeMin, UINT32 depthRangeMax, MonoArray* guiOptions);
  67. static void internal_addElement(ScriptGUILayout* instance, ScriptGUIElementBaseTBase* element);
  68. static void internal_insertElement(ScriptGUILayout* instance, UINT32 index, ScriptGUIElementBaseTBase* element);
  69. static UINT32 internal_getChildCount(ScriptGUILayout* instance);
  70. static MonoObject* internal_getChild(ScriptGUILayout* instance, UINT32 index);
  71. static void internal_clear(ScriptGUILayout* instance);
  72. static void internal_createInstanceYFromScrollArea(MonoObject* instance, MonoObject* parentScrollArea);
  73. };
  74. /**
  75. * @brief Interop class between C++ & CLR for GUIPanel.
  76. */
  77. class BS_SCR_BE_EXPORT ScriptGUIPanel : public ScriptObject<ScriptGUIPanel>
  78. {
  79. public:
  80. SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "GUIPanel")
  81. /**
  82. * @brief Creates a new managed GUIPanel that wraps the provided native GUIPanel.
  83. */
  84. static MonoObject* createFromExisting(GUIPanel* panel);
  85. private:
  86. ScriptGUIPanel(MonoObject* instance);
  87. };
  88. }