diff --git a/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp b/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp index a8f2d0da6b..407b610d28 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp +++ b/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp @@ -22,7 +22,7 @@ ============================================================================== */ -Image juce_createIconForFile (const File& file); +Image juce_createIconForFile (const File&); //============================================================================== class FileListTreeItem : public TreeViewItem, @@ -68,7 +68,7 @@ public: //============================================================================== bool mightContainSubItems() override { return isDirectory; } String getUniqueName() const override { return file.getFullPathName(); } - int getItemHeight() const override { return 22; } + int getItemHeight() const override { return owner.getItemHeight(); } var getDragSourceDescription() override { return owner.getDragAndDropDescription(); } @@ -252,7 +252,8 @@ private: //============================================================================== FileTreeComponent::FileTreeComponent (DirectoryContentsList& listToShow) - : DirectoryContentsDisplayComponent (listToShow) + : DirectoryContentsDisplayComponent (listToShow), + itemHeight (22) { setRootItemVisible (false); refresh(); @@ -305,3 +306,14 @@ void FileTreeComponent::setSelectedFile (const File& target) if (! t->selectFile (target)) clearSelectedItems(); } + +void FileTreeComponent::setItemHeight (int newHeight) +{ + if (itemHeight != newHeight) + { + itemHeight = newHeight; + + if (TreeViewItem* root = getRootItem()) + root->treeHasChanged(); + } +} diff --git a/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.h b/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.h index 7e999c79eb..841498a46c 100644 --- a/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.h +++ b/modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.h @@ -87,11 +87,18 @@ public: /** Returns the last value that was set by setDragAndDropDescription(). */ - const String& getDragAndDropDescription() const noexcept { return dragAndDropDescription; } + const String& getDragAndDropDescription() const noexcept { return dragAndDropDescription; } + + /** Changes the height of the treeview items. */ + void setItemHeight (int newHeight); + + /** Returns the height of the treeview items. */ + int getItemHeight() const noexcept { return itemHeight; } private: //============================================================================== String dragAndDropDescription; + int itemHeight; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileTreeComponent) }; diff --git a/modules/juce_gui_basics/widgets/juce_TreeView.h b/modules/juce_gui_basics/widgets/juce_TreeView.h index 0087c190c2..de11cbc982 100644 --- a/modules/juce_gui_basics/widgets/juce_TreeView.h +++ b/modules/juce_gui_basics/widgets/juce_TreeView.h @@ -836,11 +836,8 @@ private: ScopedPointer dragInsertPointHighlight; ScopedPointer dragTargetGroupHighlight; int indentSize; - bool defaultOpenness : 1; - bool needsRecalculating : 1; - bool rootItemVisible : 1; - bool multiSelectEnabled : 1; - bool openCloseButtonsVisible : 1; + bool defaultOpenness, needsRecalculating, rootItemVisible; + bool multiSelectEnabled, openCloseButtonsVisible; void itemsChanged() noexcept; void recalculateIfNeeded();