mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
This commit is contained in:
parent
1cd08a967c
commit
2012b7b112
3 changed files with 46 additions and 7 deletions
|
|
@ -263,13 +263,37 @@ private:
|
||||||
TreeViewContentComponent (const TreeViewContentComponent&);
|
TreeViewContentComponent (const TreeViewContentComponent&);
|
||||||
const TreeViewContentComponent& operator= (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();
|
TreeViewItem* firstSelected = 0;
|
||||||
const bool cmd = modifiers.isCommandDown();
|
|
||||||
|
|
||||||
item->setSelected (shft || (! cmd) || (cmd && ! item->isSelected()),
|
if (modifiers.isShiftDown() && ((firstSelected = owner->getSelectedItem (0)) != 0))
|
||||||
! (shft || cmd));
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -253,7 +253,12 @@ FileTreeComponent::~FileTreeComponent()
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
const File FileTreeComponent::getSelectedFile() const
|
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)
|
if (item != 0)
|
||||||
return item->file;
|
return item->file;
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,17 @@ public:
|
||||||
~FileTreeComponent();
|
~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.
|
Returns File::nonexistent if none is selected.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue