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.

143 lines
5.7KB

  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_EDITORCANVAS_H_EF886D17__
  19. #define __JUCER_EDITORCANVAS_H_EF886D17__
  20. #include "../../utility/jucer_MarkerListBase.h"
  21. class EditorPanelBase;
  22. //==============================================================================
  23. class EditorCanvasBase : public Component,
  24. public ValueTree::Listener,
  25. public AsyncUpdater
  26. {
  27. public:
  28. //==============================================================================
  29. EditorCanvasBase();
  30. ~EditorCanvasBase();
  31. void initialise();
  32. void shutdown();
  33. //==============================================================================
  34. typedef SelectedItemSet<String> SelectedItems;
  35. //==============================================================================
  36. void paint (Graphics& g);
  37. void resized();
  38. const Rectangle<int> getContentArea() const;
  39. void drawXAxis (Graphics& g, const Rectangle<int>& r);
  40. void drawYAxis (Graphics& g, const Rectangle<int>& r);
  41. //==============================================================================
  42. void valueTreePropertyChanged (ValueTree&, const Identifier&) { triggerAsyncUpdate(); }
  43. void valueTreeChildrenChanged (ValueTree& treeWhoseChildHasChanged) { triggerAsyncUpdate(); }
  44. void valueTreeParentChanged (ValueTree& treeWhoseParentHasChanged) {}
  45. //==============================================================================
  46. void showSizeGuides();
  47. void hideSizeGuides();
  48. //==============================================================================
  49. virtual void updateComponents() = 0;
  50. virtual int getCanvasWidth() = 0;
  51. virtual int getCanvasHeight() = 0;
  52. virtual void setCanvasWidth (int w) = 0;
  53. virtual void setCanvasHeight (int h) = 0;
  54. virtual MarkerListBase& getMarkerList (bool isX) = 0;
  55. virtual const SelectedItems::ItemType findObjectIdAt (const Point<int>& position) = 0;
  56. virtual void showPopupMenu (bool isClickOnSelectedObject) = 0;
  57. virtual void objectDoubleClicked (const MouseEvent& e, const ValueTree& state) = 0;
  58. virtual const ValueTree getObjectState (const String& objectId) = 0;
  59. virtual const Rectangle<int> getObjectPosition (const ValueTree& state) = 0;
  60. virtual RelativeRectangle getObjectCoords (const ValueTree& state) = 0;
  61. virtual SelectedItems& getSelection() = 0;
  62. virtual UndoManager& getUndoManager() = 0;
  63. virtual void deselectNonDraggableObjects() = 0;
  64. virtual void findLassoItemsInArea (Array <SelectedItems::ItemType>& itemsFound, const Rectangle<int>& area) = 0;
  65. virtual Component* createComponentHolder() = 0;
  66. class DragOperation
  67. {
  68. public:
  69. DragOperation() {}
  70. virtual ~DragOperation() {}
  71. virtual void drag (const MouseEvent& e) = 0;
  72. virtual bool dragItem (ValueTree& v, const Point<int>& distance, const Rectangle<float>& originalPos) = 0;
  73. };
  74. virtual DragOperation* createDragOperation (const MouseEvent& e,
  75. Component* snapGuideParentComponent,
  76. const ResizableBorderComponent::Zone& zone) = 0;
  77. void beginDrag (const MouseEvent& e, const ResizableBorderComponent::Zone& zone);
  78. void continueDrag (const MouseEvent& e);
  79. void endDrag (const MouseEvent& e);
  80. //==============================================================================
  81. Component* getComponentHolder() const { return componentHolder; }
  82. EditorPanelBase* getPanel() const;
  83. //==============================================================================
  84. class OverlayItemComponent : public Component
  85. {
  86. public:
  87. OverlayItemComponent (EditorCanvasBase* canvas_);
  88. ~OverlayItemComponent();
  89. void setBoundsInTargetSpace (const Rectangle<int>& r);
  90. protected:
  91. EditorCanvasBase* canvas;
  92. };
  93. private:
  94. //==============================================================================
  95. const BorderSize border;
  96. friend class OverlayItemComponent;
  97. class ResizeFrame;
  98. class MarkerComponent;
  99. class DocumentResizeFrame;
  100. class OverlayComponent;
  101. //==============================================================================
  102. Component* componentHolder;
  103. OverlayComponent* overlay;
  104. DocumentResizeFrame* resizeFrame;
  105. ScopedPointer<DragOperation> dragger;
  106. void handleAsyncUpdate();
  107. };
  108. #endif // __JUCER_EDITORCANVAS_H_EF886D17__