BsScriptGUIEnumField.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 "Wrappers/GUI/BsScriptGUIElement.h"
  6. namespace bs
  7. {
  8. struct __GUIContentInterop;
  9. /** @addtogroup ScriptInteropEditor
  10. * @{
  11. */
  12. /**
  13. * Interop class between C++ & CLR for GUIListBoxField, with some specific functionality meant for displaying managed
  14. * enumeration values.
  15. */
  16. class BS_SCR_BED_EXPORT ScriptGUIEnumField : public TScriptGUIElement<ScriptGUIEnumField>
  17. {
  18. public:
  19. SCRIPT_OBJ(EDITOR_ASSEMBLY, EDITOR_NS, "GUIEnumField")
  20. private:
  21. /**
  22. * Triggered when the value in the native list box selection changes.
  23. *
  24. * @param[in] newIndex Index of the selected element.
  25. * @param[in] enabled Determines whether the element at the selection index was enabled or disabled.
  26. */
  27. void onSelectionChanged(UINT64 newIndex, bool enabled);
  28. ScriptGUIEnumField(MonoObject* instance, GUIListBoxField* listBoxField, const Vector<UINT64>& values);
  29. Vector<UINT64> mValues;
  30. /************************************************************************/
  31. /* CLR HOOKS */
  32. /************************************************************************/
  33. static void internal_createInstance(MonoObject* instance, MonoArray* names, MonoArray* values, bool multiselect,
  34. __GUIContentInterop* title, UINT32 titleWidth, MonoString* style, MonoArray* guiOptions, bool withTitle);
  35. static UINT64 internal_getValue(ScriptGUIEnumField* nativeInstance);
  36. static void internal_setValue(ScriptGUIEnumField* nativeInstance, UINT64 value);
  37. static void internal_setTint(ScriptGUIEnumField* nativeInstance, Color* color);
  38. static void internal_selectElement(ScriptGUIEnumField* nativeInstance, int idx);
  39. static void internal_deselectElement(ScriptGUIEnumField* nativeInstance, int idx);
  40. static MonoArray* internal_getElementStates(ScriptGUIEnumField* nativeInstance);
  41. static void internal_setElementStates(ScriptGUIEnumField* nativeInstance, MonoArray* states);
  42. typedef void(BS_THUNKCALL *OnSelectionChangedThunkDef) (MonoObject*, UINT64, MonoException**);
  43. static OnSelectionChangedThunkDef onSelectionChangedThunk;
  44. };
  45. /** @} */
  46. }