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.

97 lines
3.3KB

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