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.

139 lines
5.4KB

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