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.3KB

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