BsToolbarItemManager.h 2.3 KB

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