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.

127 lines
5.8KB

  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. #include "jucer_ProjectContentComponent.h"
  25. //==============================================================================
  26. class ProjectTreeViewBase : public JucerTreeViewBase,
  27. public ValueTree::Listener
  28. {
  29. protected:
  30. //==============================================================================
  31. ProjectTreeViewBase (const Project::Item& item);
  32. ~ProjectTreeViewBase();
  33. public:
  34. //==============================================================================
  35. virtual bool isRoot() const { return false; }
  36. virtual bool acceptsFileDrop (const StringArray& files) const = 0;
  37. virtual bool acceptsDragItems (const OwnedArray <Project::Item>& selectedNodes) = 0;
  38. //==============================================================================
  39. virtual String getDisplayName() const;
  40. virtual String getRenamingName() const { return getDisplayName(); }
  41. virtual void setName (const String& newName);
  42. virtual bool isMissing() { return isFileMissing; }
  43. virtual File getFile() const;
  44. virtual void deleteItem();
  45. virtual void deleteAllSelectedItems();
  46. virtual void revealInFinder() const;
  47. virtual void showDocument() = 0;
  48. virtual void browseToAddExistingFiles();
  49. virtual void checkFileStatus(); // (recursive)
  50. virtual void addFiles (const StringArray& files, int insertIndex);
  51. virtual void moveSelectedItemsTo (OwnedArray <Project::Item>& selectedNodes, int insertIndex);
  52. virtual void showMultiSelectionPopupMenu();
  53. void launchPopupMenu (PopupMenu&); // runs asynchronously, and produces a callback to handlePopupMenuResult().
  54. virtual void handlePopupMenuResult (int resultCode);
  55. void invokeShowDocument();
  56. virtual ProjectTreeViewBase* findTreeViewItem (const Project::Item& itemToFind);
  57. //==============================================================================
  58. void valueTreePropertyChanged (ValueTree& tree, const Identifier& property);
  59. void valueTreeChildAdded (ValueTree& parentTree, ValueTree& childWhichHasBeenAdded);
  60. void valueTreeChildRemoved (ValueTree& parentTree, ValueTree& childWhichHasBeenRemoved);
  61. void valueTreeChildOrderChanged (ValueTree& parentTree);
  62. void valueTreeParentChanged (ValueTree& tree);
  63. //==============================================================================
  64. // TreeViewItem stuff..
  65. bool mightContainSubItems();
  66. String getUniqueName() const;
  67. void itemOpennessChanged (bool isNowOpen);
  68. void refreshSubItems();
  69. bool canBeSelected() const { return true; }
  70. void itemDoubleClicked (const MouseEvent& e);
  71. void itemSelectionChanged (bool isNowSelected);
  72. String getTooltip();
  73. var getDragSourceDescription();
  74. //==============================================================================
  75. // Drag-and-drop stuff..
  76. bool isInterestedInFileDrag (const StringArray& files);
  77. void filesDropped (const StringArray& files, int insertIndex);
  78. bool isInterestedInDragSource (const DragAndDropTarget::SourceDetails& dragSourceDetails);
  79. void itemDropped (const DragAndDropTarget::SourceDetails& dragSourceDetails, int insertIndex);
  80. static void getAllSelectedNodesInTree (Component* componentInTree, OwnedArray <Project::Item>& selectedNodes);
  81. //==============================================================================
  82. Project::Item item;
  83. protected:
  84. bool isFileMissing;
  85. ScopedPointer<Timer> delayedSelectionTimer;
  86. //==============================================================================
  87. void treeChildrenChanged (const ValueTree& parentTree);
  88. virtual void addSubItems();
  89. virtual ProjectTreeViewBase* createSubItem (const Project::Item& node) = 0;
  90. const Drawable* getIcon() const { return item.getIcon(); }
  91. //==============================================================================
  92. void triggerAsyncRename (const Project::Item& itemToRename);
  93. static void moveItems (OwnedArray <Project::Item>& selectedNodes,
  94. Project::Item destNode, int insertIndex);
  95. ProjectContentComponent* getProjectContentComponent() const;
  96. ProjectTreeViewBase* getParentProjectItem() const;
  97. };
  98. #endif // __JUCER_PROJECTTREEVIEWBASE_JUCEHEADER__