The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
4.1KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-10 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. #ifndef __JUCER_DRAWABLEEDITORTOOLBAR_H_65D23CDD__
  19. #define __JUCER_DRAWABLEEDITORTOOLBAR_H_65D23CDD__
  20. //==============================================================================
  21. class DrawableEditorToolbarFactory : public ToolbarItemFactory
  22. {
  23. public:
  24. DrawableEditorToolbarFactory (DrawableEditor& editor_)
  25. : editor (editor_)
  26. {
  27. }
  28. ~DrawableEditorToolbarFactory()
  29. {
  30. }
  31. //==============================================================================
  32. enum ToolbarItemIds
  33. {
  34. createShape = 1,
  35. showInfo,
  36. showTree,
  37. showOrHideMarkers,
  38. toggleSnapping
  39. };
  40. void getAllToolbarItemIds (Array <int>& ids)
  41. {
  42. ids.add (createShape);
  43. ids.add (showInfo);
  44. ids.add (showTree);
  45. ids.add (showOrHideMarkers);
  46. ids.add (toggleSnapping);
  47. ids.add (separatorBarId);
  48. ids.add (spacerId);
  49. ids.add (flexibleSpacerId);
  50. }
  51. void getDefaultItemSet (Array <int>& ids)
  52. {
  53. ids.add (spacerId);
  54. ids.add (createShape);
  55. ids.add (flexibleSpacerId);
  56. ids.add (showOrHideMarkers);
  57. ids.add (toggleSnapping);
  58. ids.add (flexibleSpacerId);
  59. ids.add (showTree);
  60. ids.add (showInfo);
  61. ids.add (spacerId);
  62. }
  63. ToolbarItemComponent* createItem (int itemId)
  64. {
  65. String name;
  66. int commandId = 0;
  67. switch (itemId)
  68. {
  69. case createShape: return new NewShapeToolbarButton (editor, itemId);
  70. case showInfo: name = "info"; commandId = CommandIDs::showOrHideProperties; break;
  71. case showTree: name = "tree"; commandId = CommandIDs::showOrHideTree; break;
  72. case showOrHideMarkers: name = "markers"; commandId = CommandIDs::showOrHideMarkers; break;
  73. case toggleSnapping: name = "snap"; commandId = CommandIDs::toggleSnapping; break;
  74. default: jassertfalse; return 0;
  75. }
  76. JucerToolbarButton* b = new JucerToolbarButton (itemId, name);
  77. b->setCommandToTrigger (commandManager, commandId, true);
  78. return b;
  79. }
  80. //==============================================================================
  81. class NewShapeToolbarButton : public JucerToolbarButton
  82. {
  83. public:
  84. NewShapeToolbarButton (DrawableEditor& editor_, int itemId_)
  85. : JucerToolbarButton (itemId_, "create..."), editor (editor_)
  86. {
  87. setTriggeredOnMouseDown (true);
  88. }
  89. void clicked()
  90. {
  91. editor.showNewShapeMenu (this);
  92. }
  93. private:
  94. DrawableEditor& editor;
  95. };
  96. private:
  97. DrawableEditor& editor;
  98. DrawableEditorToolbarFactory (const DrawableEditorToolbarFactory&);
  99. DrawableEditorToolbarFactory& operator= (const DrawableEditorToolbarFactory&);
  100. };
  101. #endif // __JUCER_DRAWABLEEDITORTOOLBAR_H_65D23CDD__