BsScriptGUIEnumField.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsScriptEditorPrerequisites.h"
  5. #include "BsScriptGUIElement.h"
  6. namespace BansheeEngine
  7. {
  8. /**
  9. * @brief Interop class between C++ & CLR for GUIListBoxField, with some specific functionality
  10. * meant for displaying managed enumeration values.
  11. */
  12. class BS_SCR_BED_EXPORT ScriptGUIEnumField : public TScriptGUIElement<ScriptGUIEnumField>
  13. {
  14. public:
  15. SCRIPT_OBJ(EDITOR_ASSEMBLY, "BansheeEditor", "GUIEnumField")
  16. private:
  17. /**
  18. * @brief Triggered when the value in the native list box selection changes.
  19. *
  20. * @param instance Managed GUIEnumField instance.
  21. * @param newIndex Index of the selected element.
  22. * @param enabled Determines whether the element at the selection index was enabled or disabled.
  23. */
  24. static void onSelectionChanged(MonoObject* instance, UINT64 newIndex, bool enabled);
  25. ScriptGUIEnumField(MonoObject* instance, GUIListBoxField* listBoxField, const Vector<UINT64>& values);
  26. Vector<UINT64> mValues;
  27. /************************************************************************/
  28. /* CLR HOOKS */
  29. /************************************************************************/
  30. static void internal_createInstance(MonoObject* instance, MonoArray* names, MonoArray* values, bool multiselect,
  31. MonoObject* title, UINT32 titleWidth, MonoString* style, MonoArray* guiOptions, bool withTitle);
  32. static UINT64 internal_getValue(ScriptGUIEnumField* nativeInstance);
  33. static void internal_setValue(ScriptGUIEnumField* nativeInstance, UINT64 value);
  34. static void internal_setTint(ScriptGUIEnumField* nativeInstance, Color* color);
  35. static void internal_selectElement(ScriptGUIEnumField* nativeInstance, int idx);
  36. static void internal_deselectElement(ScriptGUIEnumField* nativeInstance, int idx);
  37. static MonoArray* internal_getElementStates(ScriptGUIEnumField* nativeInstance);
  38. static void internal_setElementStates(ScriptGUIEnumField* nativeInstance, MonoArray* states);
  39. typedef void(__stdcall *OnSelectionChangedThunkDef) (MonoObject*, UINT64, MonoException**);
  40. static OnSelectionChangedThunkDef onSelectionChangedThunk;
  41. };
  42. }