2
0

BsScriptGUILayout.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsScriptEnginePrerequisites.h"
  5. #include "Wrappers/GUI/BsScriptGUIElement.h"
  6. namespace bs
  7. {
  8. /** @addtogroup ScriptInteropEngine
  9. * @{
  10. */
  11. /** Interop class between C++ & CLR for GUILayout derived classes. */
  12. class BS_SCR_BE_EXPORT ScriptGUILayout : public TScriptGUIElementBase<ScriptGUILayout>
  13. {
  14. protected:
  15. /** Contains information about an interop object that represents a child of the layout. */
  16. struct ChildInfo
  17. {
  18. ScriptGUIElementBaseTBase* element;
  19. uint32_t gcHandle;
  20. };
  21. public:
  22. SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "GUILayout")
  23. virtual ~ScriptGUILayout() { }
  24. /** Returns the internal wrapped GUILayout object. */
  25. GUILayout* getInternalValue() const { return mLayout; }
  26. /** Registers a new managed child GUI element and inserts it at the end of the layout. */
  27. void addChild(ScriptGUIElementBaseTBase* element);
  28. /** Registers a new managed child GUI element and inserts it at a specific location in the layout. */
  29. void insertChild(UINT32 index, ScriptGUIElementBaseTBase* element);
  30. /** Removes a managed GUI element from the layout. */
  31. void removeChild(ScriptGUIElementBaseTBase* element);
  32. /**
  33. * @copydoc ScriptGUIElementBaseTBase::destroy
  34. *
  35. * Destroys the layout and all of its managed children.
  36. */
  37. void destroy() override;
  38. protected:
  39. friend class ScriptGUIPanel;
  40. /**
  41. * Constructor.
  42. *
  43. * @param[in] instance Managed GUILayout instance.
  44. * @param[in] layout Native GUILayout instance.
  45. * @param[in] ownsNative Does this object own the native instance. If it does it will destroy the
  46. * object when destroy() is called, otherwise it is up to the caller to destroy it.
  47. */
  48. ScriptGUILayout(MonoObject* instance, GUILayout* layout, bool ownsNative = true);
  49. GUILayout* mLayout;
  50. Vector<ChildInfo> mChildren;
  51. bool mOwnsNative;
  52. private:
  53. /************************************************************************/
  54. /* CLR HOOKS */
  55. /************************************************************************/
  56. static void internal_createInstanceX(MonoObject* instance, MonoArray* guiOptions);
  57. static void internal_createInstanceY(MonoObject* instance, MonoArray* guiOptions);
  58. static void internal_createInstancePanel(MonoObject* instance, INT16 depth, UINT16 depthRangeMin, UINT32 depthRangeMax, MonoArray* guiOptions);
  59. static void internal_addElement(ScriptGUILayout* instance, ScriptGUIElementBaseTBase* element);
  60. static void internal_insertElement(ScriptGUILayout* instance, UINT32 index, ScriptGUIElementBaseTBase* element);
  61. static UINT32 internal_getChildCount(ScriptGUILayout* instance);
  62. static MonoObject* internal_getChild(ScriptGUILayout* instance, UINT32 index);
  63. static void internal_clear(ScriptGUILayout* instance);
  64. static void internal_createInstanceYFromScrollArea(MonoObject* instance, MonoObject* parentScrollArea);
  65. };
  66. /** Interop class between C++ & CLR for GUIPanel. */
  67. class BS_SCR_BE_EXPORT ScriptGUIPanel : public ScriptObject<ScriptGUIPanel>
  68. {
  69. public:
  70. SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "GUIPanel")
  71. /** Creates a new managed GUIPanel that wraps the provided native GUIPanel. */
  72. static MonoObject* createFromExisting(GUIPanel* panel);
  73. private:
  74. ScriptGUIPanel(MonoObject* instance);
  75. };
  76. /** Specialized ScriptGUILayout that is used only in GUI scroll areas. */
  77. class BS_SCR_BE_EXPORT ScriptGUIScrollAreaLayout : public ScriptGUILayout
  78. {
  79. public:
  80. /**
  81. * Constructor.
  82. *
  83. * @param[in] instance Managed GUILayout instance.
  84. * @param[in] layout Native GUILayout instance.
  85. */
  86. ScriptGUIScrollAreaLayout(MonoObject* instance, GUILayout* layout);
  87. /** @copydoc ScriptGUILayout::destroy */
  88. void destroy() override;
  89. private:
  90. friend class ScriptGUIScrollArea;
  91. ScriptGUIScrollArea* mParentScrollArea;
  92. };
  93. /** @} */
  94. }