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.

108 lines
3.6KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2022 - Raw Material Software Limited
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 7 End-User License
  8. Agreement and JUCE Privacy Policy.
  9. End User License Agreement: www.juce.com/juce-7-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. #pragma once
  19. #include "../jucer_JucerDocument.h"
  20. #include "jucer_ComponentLayoutEditor.h"
  21. #include "jucer_PaintRoutineEditor.h"
  22. #include "jucer_ComponentLayoutPanel.h"
  23. //==============================================================================
  24. class JucerDocumentEditor : public Component,
  25. public ApplicationCommandTarget,
  26. private ChangeListener
  27. {
  28. public:
  29. //==============================================================================
  30. JucerDocumentEditor (JucerDocument* const document);
  31. ~JucerDocumentEditor() override;
  32. JucerDocument* getDocument() const noexcept { return document.get(); }
  33. void refreshPropertiesPanel() const;
  34. void updateTabs();
  35. void showLayout();
  36. void showGraphics (PaintRoutine* routine);
  37. void setViewportToLastPos (Viewport* vp, EditingPanelBase& editor);
  38. void storeLastViewportPos (Viewport* vp, EditingPanelBase& editor);
  39. Image createComponentLayerSnapshot() const;
  40. //==============================================================================
  41. void paint (Graphics& g) override;
  42. void resized() override;
  43. bool keyPressed (const KeyPress&) override;
  44. //==============================================================================
  45. ApplicationCommandTarget* getNextCommandTarget() override;
  46. void getAllCommands (Array<CommandID>&) override;
  47. void getCommandInfo (CommandID, ApplicationCommandInfo&) override;
  48. bool perform (const InvocationInfo&) override;
  49. static JucerDocumentEditor* getActiveDocumentHolder();
  50. private:
  51. void handleResize();
  52. void handleChange();
  53. void changeListenerCallback (ChangeBroadcaster*) override;
  54. std::unique_ptr<JucerDocument> document;
  55. ComponentLayoutPanel* compLayoutPanel = nullptr;
  56. struct JucerDocumentTabs : public TabbedComponent
  57. {
  58. JucerDocumentTabs (JucerDocument* d) : TabbedComponent (TabbedButtonBar::TabsAtTop), document (d) {}
  59. void currentTabChanged (int, const String&) override { document->refreshCustomCodeFromDocument(); }
  60. JucerDocument* document;
  61. };
  62. JucerDocumentTabs tabbedComponent;
  63. int lastViewportX = 0, lastViewportY = 0;
  64. double currentZoomLevel = 1.0;
  65. void saveLastSelectedTab() const;
  66. void restoreLastSelectedTab();
  67. bool isSomethingSelected() const;
  68. bool areMultipleThingsSelected() const;
  69. // only non-zero if a layout tab is selected
  70. ComponentLayout* getCurrentLayout() const;
  71. // only non-zero if a graphics tab is selected
  72. PaintRoutine* getCurrentPaintRoutine() const;
  73. void setZoom (double scale);
  74. double getZoom() const;
  75. void addElement (int index);
  76. void addComponent (int index);
  77. };