BsScriptGUIEnumField.h 2.1 KB

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