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