Browse Source

tags/2021-05-28
jules 18 years ago
parent
commit
2012b7b112
3 changed files with 46 additions and 7 deletions
  1. +29
    -5
      src/juce_appframework/gui/components/controls/juce_TreeView.cpp
  2. +6
    -1
      src/juce_appframework/gui/components/filebrowser/juce_FileTreeComponent.cpp
  3. +11
    -1
      src/juce_appframework/gui/components/filebrowser/juce_FileTreeComponent.h

+ 29
- 5
src/juce_appframework/gui/components/controls/juce_TreeView.cpp View File

@@ -263,13 +263,37 @@ private:
TreeViewContentComponent (const TreeViewContentComponent&);
const TreeViewContentComponent& operator= (const TreeViewContentComponent&);
static void selectBasedOnModifiers (TreeViewItem* const item, const ModifierKeys& modifiers)
void selectBasedOnModifiers (TreeViewItem* const item, const ModifierKeys& modifiers)
{
const bool shft = modifiers.isShiftDown();
const bool cmd = modifiers.isCommandDown();
TreeViewItem* firstSelected = 0;
item->setSelected (shft || (! cmd) || (cmd && ! item->isSelected()),
! (shft || cmd));
if (modifiers.isShiftDown() && ((firstSelected = owner->getSelectedItem (0)) != 0))
{
TreeViewItem* const lastSelected = owner->getSelectedItem (owner->getNumSelectedItems() - 1);
jassert (lastSelected != 0);
int rowStart = firstSelected->getRowNumberInTree();
int rowEnd = lastSelected->getRowNumberInTree();
if (rowStart > rowEnd)
swapVariables (rowStart, rowEnd);
int ourRow = item->getRowNumberInTree();
int otherEnd = ourRow < rowEnd ? (ourRow < rowStart ? (rowStart - 1)
: rowStart)
: (rowEnd + 1);
if (ourRow > otherEnd)
swapVariables (ourRow, otherEnd);
for (int i = ourRow; i <= otherEnd; ++i)
owner->getItemOnRow (i)->setSelected (true, false);
}
else
{
const bool cmd = modifiers.isCommandDown();
item->setSelected ((! cmd) || (! item->isSelected()), ! cmd);
}
}
};


+ 6
- 1
src/juce_appframework/gui/components/filebrowser/juce_FileTreeComponent.cpp View File

@@ -253,7 +253,12 @@ FileTreeComponent::~FileTreeComponent()
//==============================================================================
const File FileTreeComponent::getSelectedFile() const
{
const FileListTreeItem* const item = dynamic_cast <const FileListTreeItem*> (getSelectedItem (0));
return getSelectedFile (0);
}
const File FileTreeComponent::getSelectedFile (const int index) const throw()
{
const FileListTreeItem* const item = dynamic_cast <const FileListTreeItem*> (getSelectedItem (index));
if (item != 0)
return item->file;


+ 11
- 1
src/juce_appframework/gui/components/filebrowser/juce_FileTreeComponent.h View File

@@ -61,7 +61,17 @@ public:
~FileTreeComponent();
//==============================================================================
/** Returns the file that the user has currently selected.
/** Returns the number of selected files in the tree.
*/
int getNumSelectedFiles() const throw() { return TreeView::getNumSelectedItems(); }
/** Returns one of the files that the user has currently selected.
Returns File::nonexistent if none is selected.
*/
const File getSelectedFile (int index) const throw();
/** Returns the first of the files that the user has currently selected.
Returns File::nonexistent if none is selected.
*/


Loading…
Cancel
Save