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.

118 lines
5.2KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #ifndef __JUCER_PROJECTTREEVIEWBASE_JUCEHEADER__
  18. #define __JUCER_PROJECTTREEVIEWBASE_JUCEHEADER__
  19. #include "../jucer_Headers.h"
  20. #include "../Utility/jucer_JucerTreeViewBase.h"
  21. #include "jucer_Project.h"
  22. //==============================================================================
  23. class ProjectTreeViewBase : public JucerTreeViewBase,
  24. public ValueTree::Listener
  25. {
  26. protected:
  27. //==============================================================================
  28. ProjectTreeViewBase (const Project::Item& item);
  29. ~ProjectTreeViewBase();
  30. public:
  31. //==============================================================================
  32. virtual bool isRoot() const { return false; }
  33. virtual bool acceptsFileDrop (const StringArray& files) const = 0;
  34. virtual bool acceptsDragItems (const OwnedArray <Project::Item>& selectedNodes) = 0;
  35. //==============================================================================
  36. virtual String getDisplayName() const;
  37. virtual String getRenamingName() const { return getDisplayName(); }
  38. virtual void setName (const String& newName);
  39. virtual bool isMissing() { return isFileMissing; }
  40. virtual File getFile() const;
  41. virtual void deleteItem();
  42. virtual void deleteAllSelectedItems();
  43. virtual void revealInFinder() const;
  44. virtual void browseToAddExistingFiles();
  45. virtual void checkFileStatus(); // (recursive)
  46. virtual void addFiles (const StringArray& files, int insertIndex);
  47. virtual void moveSelectedItemsTo (OwnedArray <Project::Item>& selectedNodes, int insertIndex);
  48. virtual void showMultiSelectionPopupMenu();
  49. virtual ProjectTreeViewBase* findTreeViewItem (const Project::Item& itemToFind);
  50. //==============================================================================
  51. void valueTreePropertyChanged (ValueTree& tree, const Identifier& property);
  52. void valueTreeChildAdded (ValueTree& parentTree, ValueTree& childWhichHasBeenAdded);
  53. void valueTreeChildRemoved (ValueTree& parentTree, ValueTree& childWhichHasBeenRemoved);
  54. void valueTreeChildOrderChanged (ValueTree& parentTree);
  55. void valueTreeParentChanged (ValueTree& tree);
  56. //==============================================================================
  57. bool mightContainSubItems();
  58. String getUniqueName() const;
  59. void itemOpennessChanged (bool isNowOpen);
  60. bool canBeSelected() const { return true; }
  61. String getTooltip();
  62. var getDragSourceDescription();
  63. void addSubItems();
  64. //==============================================================================
  65. // Drag-and-drop stuff..
  66. bool isInterestedInFileDrag (const StringArray& files);
  67. void filesDropped (const StringArray& files, int insertIndex);
  68. bool isInterestedInDragSource (const DragAndDropTarget::SourceDetails& dragSourceDetails);
  69. void itemDropped (const DragAndDropTarget::SourceDetails& dragSourceDetails, int insertIndex);
  70. int getMillisecsAllowedForDragGesture();
  71. static void getAllSelectedNodesInTree (Component* componentInTree, OwnedArray <Project::Item>& selectedNodes);
  72. File getDraggableFile() const { return getFile(); }
  73. //==============================================================================
  74. Project::Item item;
  75. protected:
  76. bool isFileMissing;
  77. //==============================================================================
  78. void treeChildrenChanged (const ValueTree& parentTree);
  79. virtual ProjectTreeViewBase* createSubItem (const Project::Item& node) = 0;
  80. Icon getIcon() const { return item.getIcon().withContrastingColourTo (getBackgroundColour()); }
  81. bool isIconCrossedOut() const { return item.isIconCrossedOut(); }
  82. //==============================================================================
  83. void triggerAsyncRename (const Project::Item& itemToRename);
  84. static void moveItems (OwnedArray <Project::Item>& selectedNodes,
  85. Project::Item destNode, int insertIndex);
  86. ProjectTreeViewBase* getParentProjectItem() const;
  87. };
  88. #endif // __JUCER_PROJECTTREEVIEWBASE_JUCEHEADER__