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.

125 lines
4.7KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-9 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_COMPONENTEDITORCANVAS_H_37C33B56__
  19. #define __JUCER_COMPONENTEDITORCANVAS_H_37C33B56__
  20. #include "../../model/jucer_ComponentDocument.h"
  21. #include "../jucer_DocumentEditorComponent.h"
  22. class ComponentEditor;
  23. //==============================================================================
  24. class ComponentEditorCanvas : public Component,
  25. public ValueTree::Listener,
  26. public Timer
  27. {
  28. public:
  29. //==============================================================================
  30. ComponentEditorCanvas (ComponentEditor& editor_);
  31. ~ComponentEditorCanvas();
  32. //==============================================================================
  33. ComponentEditor& getEditor();
  34. ComponentDocument& getDocument();
  35. typedef SelectedItemSet<String> SelectedItems;
  36. SelectedItems& getSelection();
  37. class ComponentHolder;
  38. ComponentHolder* getComponentHolder() const;
  39. //==============================================================================
  40. void timerCallback();
  41. void paint (Graphics& g);
  42. void resized();
  43. void updateComponents();
  44. const Rectangle<int> getContentArea() const;
  45. void drawXAxis (Graphics& g, const Rectangle<int>& r);
  46. void drawYAxis (Graphics& g, const Rectangle<int>& r);
  47. //==============================================================================
  48. void valueTreePropertyChanged (ValueTree&, const var::identifier&) { updateComponents(); }
  49. void valueTreeChildrenChanged (ValueTree& treeWhoseChildHasChanged) { updateComponents(); }
  50. void valueTreeParentChanged (ValueTree& treeWhoseParentHasChanged) {}
  51. //==============================================================================
  52. const StringArray getSelectedIds() const;
  53. void getSelectedItemProperties (Array <PropertyComponent*>& props);
  54. void deleteSelection();
  55. void deselectNonComponents();
  56. void selectionToFront();
  57. void selectionToBack();
  58. //==============================================================================
  59. void showSizeGuides();
  60. void hideSizeGuides();
  61. //==============================================================================
  62. class DragOperation;
  63. void beginDrag (const MouseEvent& e, const ResizableBorderComponent::Zone& zone);
  64. void continueDrag (const MouseEvent& e);
  65. void endDrag (const MouseEvent& e);
  66. private:
  67. ComponentEditor& editor;
  68. const BorderSize border;
  69. ScopedPointer <DragOperation> dragger;
  70. //==============================================================================
  71. class OverlayItemComponent : public Component
  72. {
  73. public:
  74. OverlayItemComponent (ComponentEditorCanvas& canvas_);
  75. void setBoundsInTargetSpace (const Rectangle<int>& r);
  76. ComponentDocument& getDocument() { return canvas.getDocument(); }
  77. protected:
  78. ComponentEditorCanvas& canvas;
  79. };
  80. friend class OverlayItemComponent;
  81. class ComponentResizeFrame;
  82. class MarkerComponent;
  83. class WholeComponentResizer;
  84. class OverlayComponent;
  85. //==============================================================================
  86. ComponentHolder* componentHolder;
  87. OverlayComponent* overlay;
  88. WholeComponentResizer* resizeFrame;
  89. SelectedItems selection;
  90. const Array<Component*> getSelectedComps() const;
  91. const Array<Component*> getUnselectedComps() const;
  92. };
  93. #endif // __JUCER_COMPONENTEDITORCANVAS_H_37C33B56__