Browse Source

Added method FileTreeComponent::setItemHeight().

tags/2021-05-28
jules 12 years ago
parent
commit
b075af5e6c
3 changed files with 25 additions and 9 deletions
  1. +15
    -3
      modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp
  2. +8
    -1
      modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.h
  3. +2
    -5
      modules/juce_gui_basics/widgets/juce_TreeView.h

+ 15
- 3
modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.cpp View File

@@ -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();
}
}

+ 8
- 1
modules/juce_gui_basics/filebrowser/juce_FileTreeComponent.h View File

@@ -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)
};


+ 2
- 5
modules/juce_gui_basics/widgets/juce_TreeView.h View File

@@ -836,11 +836,8 @@ private:
ScopedPointer<InsertPointHighlight> dragInsertPointHighlight;
ScopedPointer<TargetGroupHighlight> 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();


Loading…
Cancel
Save