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.

117 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. #include "../Project Saving/jucer_ResourceFile.h"
  24. //==============================================================================
  25. class ProjectTreeViewBase : public JucerTreeViewBase,
  26. public ValueTree::Listener
  27. {
  28. protected:
  29. //==============================================================================
  30. ProjectTreeViewBase (const Project::Item& item);
  31. ~ProjectTreeViewBase();
  32. public:
  33. //==============================================================================
  34. virtual bool isRoot() const { return false; }
  35. virtual bool acceptsFileDrop (const StringArray& files) const = 0;
  36. virtual bool acceptsDragItems (const OwnedArray <Project::Item>& selectedNodes) = 0;
  37. //==============================================================================
  38. virtual String getDisplayName() const;
  39. virtual String getRenamingName() const { return getDisplayName(); }
  40. virtual void setName (const String& newName);
  41. virtual bool isMissing() { return isFileMissing; }
  42. virtual File getFile() const;
  43. virtual void deleteItem();
  44. virtual void deleteAllSelectedItems();
  45. virtual void revealInFinder() const;
  46. virtual void browseToAddExistingFiles();
  47. virtual void checkFileStatus(); // (recursive)
  48. virtual void addFiles (const StringArray& files, int insertIndex);
  49. virtual void moveSelectedItemsTo (OwnedArray <Project::Item>& selectedNodes, int insertIndex);
  50. virtual void showMultiSelectionPopupMenu();
  51. virtual ProjectTreeViewBase* findTreeViewItem (const Project::Item& itemToFind);
  52. //==============================================================================
  53. void valueTreePropertyChanged (ValueTree& tree, const Identifier& property);
  54. void valueTreeChildAdded (ValueTree& parentTree, ValueTree& childWhichHasBeenAdded);
  55. void valueTreeChildRemoved (ValueTree& parentTree, ValueTree& childWhichHasBeenRemoved);
  56. void valueTreeChildOrderChanged (ValueTree& parentTree);
  57. void valueTreeParentChanged (ValueTree& tree);
  58. //==============================================================================
  59. bool mightContainSubItems();
  60. String getUniqueName() const;
  61. void itemOpennessChanged (bool isNowOpen);
  62. bool canBeSelected() const { return true; }
  63. String getTooltip();
  64. var getDragSourceDescription();
  65. void addSubItems();
  66. //==============================================================================
  67. // Drag-and-drop stuff..
  68. bool isInterestedInFileDrag (const StringArray& files);
  69. void filesDropped (const StringArray& files, int insertIndex);
  70. bool isInterestedInDragSource (const DragAndDropTarget::SourceDetails& dragSourceDetails);
  71. void itemDropped (const DragAndDropTarget::SourceDetails& dragSourceDetails, int insertIndex);
  72. int getMillisecsAllowedForDragGesture();
  73. static void getAllSelectedNodesInTree (Component* componentInTree, OwnedArray <Project::Item>& selectedNodes);
  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__