BsToolbarItemManager.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #pragma once
  2. #include "BsScriptEditorPrerequisites.h"
  3. #include "BsModule.h"
  4. namespace BansheeEngine
  5. {
  6. /**
  7. * @brief Tracks toolbar items that are registered in managed code using the ToolbarItem
  8. * attribute.
  9. */
  10. class BS_SCR_BED_EXPORT ToolbarItemManager : public Module<ToolbarItemManager>
  11. {
  12. public:
  13. ToolbarItemManager(ScriptAssemblyManager& scriptObjectManager);
  14. ~ToolbarItemManager();
  15. private:
  16. /**
  17. * @brief Removes all managed toolbar items from the main menu.
  18. */
  19. void clearToolbarItems();
  20. /**
  21. * @brief Reloads all assembly types and attempts to find uses of ToolbarItem. Old
  22. * toolbar items are cleared and new are added.
  23. */
  24. void reloadAssemblyData();
  25. /**
  26. * @brief Parse the provided method and detect whether it has a ToolbarItem attribute.
  27. * If it has extract needed data from it.
  28. *
  29. * @param method Managed method to parse.
  30. * @param name Output name defined in the ToolbarItem attribute.
  31. * @param icon Texture defined in the ToolbarItem attribute.
  32. * @param tooltip Optional tooltip defined in the ToolbarItem attribute.
  33. * @param priority Menu item priority defined in the MenuItem attribute.
  34. * @param separator Should the separator be inserted before the menu item.
  35. *
  36. * @return True if the method has a ToolbarItem attribute. If false is returned output parameters
  37. * from this method are undefined.
  38. */
  39. bool parseToolbarItemMethod(MonoMethod* method, String& name, HSpriteTexture& icon, HString& tooltip,
  40. INT32& priority, bool& separator) const;
  41. /**
  42. * @brief Triggered when one of the managed toolbar items is clicked.
  43. *
  44. * @param method Managed method that the ToolbarItem is referencing.
  45. */
  46. static void toolbarItemCallback(MonoMethod* method);
  47. ScriptAssemblyManager& mScriptObjectManager;
  48. HEvent mDomainLoadedConn;
  49. MonoClass* mToolbarItemAttribute;
  50. MonoField* mNameField;
  51. MonoField* mIconField;
  52. MonoField* mBuiltinIconField;
  53. MonoField* mTooltipField;
  54. MonoField* mPriorityField;
  55. MonoField* mSeparatorField;
  56. Vector<String> mToolbarItems;
  57. };
  58. }