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.

82 lines
2.5KB

  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. //==============================================================================
  20. struct ProjectTreeItemBase : public JucerTreeViewBase,
  21. public ValueTree::Listener
  22. {
  23. ProjectTreeItemBase() {}
  24. void showSettingsPage (Component* content)
  25. {
  26. content->setComponentID (getUniqueName());
  27. std::unique_ptr<Component> comp (content);
  28. if (auto* pcc = getProjectContentComponent())
  29. pcc->setScrollableEditorComponent (std::move (comp));
  30. }
  31. void closeSettingsPage()
  32. {
  33. if (auto* pcc = getProjectContentComponent())
  34. if (auto* content = pcc->getEditorComponent())
  35. if (content->getComponentID() == getUniqueName())
  36. pcc->hideEditor();
  37. }
  38. void deleteAllSelectedItems() override
  39. {
  40. auto* tree = getOwnerView();
  41. jassert (tree->getNumSelectedItems() <= 1); // multi-select should be disabled
  42. if (auto* s = dynamic_cast<ProjectTreeItemBase*> (tree->getSelectedItem (0)))
  43. s->deleteItem();
  44. }
  45. void itemOpennessChanged (bool isNowOpen) override
  46. {
  47. if (isNowOpen)
  48. refreshSubItems();
  49. }
  50. virtual bool isProjectSettings() const { return false; }
  51. virtual bool isModulesList() const { return false; }
  52. static void updateSize (Component& comp, PropertyGroupComponent& group)
  53. {
  54. auto width = jmax (550, comp.getParentWidth() - 12);
  55. auto y = 0;
  56. y += group.updateSize (12, y, width - 12);
  57. y = jmax (comp.getParentHeight(), y);
  58. comp.setSize (width, y);
  59. }
  60. };