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.

76 lines
2.3KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 6 technical preview.
  4. Copyright (c) 2017 - ROLI Ltd.
  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. //==============================================================================
  15. struct ProjectTreeItemBase : public JucerTreeViewBase,
  16. public ValueTree::Listener
  17. {
  18. ProjectTreeItemBase() {}
  19. void showSettingsPage (Component* content)
  20. {
  21. content->setComponentID (getUniqueName());
  22. std::unique_ptr<Component> comp (content);
  23. if (ProjectContentComponent* pcc = getProjectContentComponent())
  24. pcc->setEditorComponent (comp.release(), nullptr);
  25. }
  26. void closeSettingsPage()
  27. {
  28. if (auto* pcc = getProjectContentComponent())
  29. if (auto* content = pcc->getEditorComponentContent())
  30. if (content->getComponentID() == getUniqueName())
  31. pcc->hideEditor();
  32. }
  33. void deleteAllSelectedItems() override
  34. {
  35. auto* tree = getOwnerView();
  36. jassert (tree->getNumSelectedItems() <= 1); // multi-select should be disabled
  37. if (auto* s = dynamic_cast<ProjectTreeItemBase*> (tree->getSelectedItem (0)))
  38. s->deleteItem();
  39. }
  40. void itemOpennessChanged (bool isNowOpen) override
  41. {
  42. if (isNowOpen)
  43. refreshSubItems();
  44. }
  45. virtual bool isProjectSettings() const { return false; }
  46. virtual bool isModulesList() const { return false; }
  47. static void updateSize (Component& comp, PropertyGroupComponent& group)
  48. {
  49. auto width = jmax (550, comp.getParentWidth() - 12);
  50. auto y = 0;
  51. y += group.updateSize (12, y, width - 12);
  52. y = jmax (comp.getParentHeight(), y);
  53. comp.setSize (width, y);
  54. }
  55. };