openshot-audio  0.1.7
Classes | Public Types | Public Member Functions | Friends | List of all members
TreeView Class Reference

#include <juce_TreeView.h>

Inheritance diagram for TreeView:
DragAndDropTarget FileTreeComponent

Classes

class  ContentComponent
 
struct  InsertPoint
 
class  InsertPointHighlight
 
struct  LookAndFeelMethods
 
class  TargetGroupHighlight
 
class  TreeViewport
 

Public Types

enum  ColourIds { backgroundColourId = 0x1000500, linesColourId = 0x1000501, dragAndDropIndicatorColourId = 0x1000502, selectedItemBackgroundColourId = 0x1000503 }
 

Public Member Functions

 TreeView (const String &componentName=String::empty)
 
 ~TreeView ()
 
void setRootItem (TreeViewItem *newRootItem)
 
TreeViewItemgetRootItem () const noexcept
 
void deleteRootItem ()
 
void setRootItemVisible (bool shouldBeVisible)
 
bool isRootItemVisible () const noexcept
 
void setDefaultOpenness (bool isOpenByDefault)
 
bool areItemsOpenByDefault () const noexcept
 
void setMultiSelectEnabled (bool canMultiSelect)
 
bool isMultiSelectEnabled () const noexcept
 
void setOpenCloseButtonsVisible (bool shouldBeVisible)
 
bool areOpenCloseButtonsVisible () const noexcept
 
void clearSelectedItems ()
 
int getNumSelectedItems (int maximumDepthToSearchTo=-1) const noexcept
 
TreeViewItemgetSelectedItem (int index) const noexcept
 
void moveSelectedRow (int deltaRows)
 
int getNumRowsInTree () const
 
TreeViewItemgetItemOnRow (int index) const
 
TreeViewItemgetItemAt (int yPosition) const noexcept
 
void scrollToKeepItemVisible (TreeViewItem *item)
 
ViewportgetViewport () const noexcept
 
int getIndentSize () noexcept
 
void setIndentSize (int newIndentSize)
 
TreeViewItemfindItemFromIdentifierString (const String &identifierString) const
 
XmlElementgetOpennessState (bool alsoIncludeScrollPosition) const
 
void restoreOpennessState (const XmlElement &newState, bool restoreStoredSelection)
 
void paint (Graphics &) override
 
void resized () override
 
bool keyPressed (const KeyPress &) override
 
void colourChanged () override
 
void enablementChanged () override
 
bool isInterestedInFileDrag (const StringArray &files) override
 
void fileDragEnter (const StringArray &files, int x, int y) override
 
void fileDragMove (const StringArray &files, int x, int y) override
 
void fileDragExit (const StringArray &files) override
 
void filesDropped (const StringArray &files, int x, int y) override
 
bool isInterestedInDragSource (const SourceDetails &) override
 
void itemDragEnter (const SourceDetails &) override
 
void itemDragMove (const SourceDetails &) override
 
void itemDragExit (const SourceDetails &) override
 
void itemDropped (const SourceDetails &) override
 
- Public Member Functions inherited from DragAndDropTarget
virtual ~DragAndDropTarget ()
 
virtual bool shouldDrawDragImageWhenOver ()
 

Friends

class TreeViewItem
 
class ContentComponent
 
struct ContainerDeletePolicy< TreeViewport >
 
struct ContainerDeletePolicy< InsertPointHighlight >
 
struct ContainerDeletePolicy< TargetGroupHighlight >
 

Detailed Description

A tree-view component.

Use one of these to hold and display a structure of TreeViewItem objects.

Member Enumeration Documentation

A set of colour IDs to use to change the colour of various aspects of the treeview.

These constants can be used either via the Component::setColour(), or LookAndFeel::setColour() methods.

See Also
Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour
Enumerator
backgroundColourId 

A background colour to fill the component with.

linesColourId 

The colour to draw the lines with.

dragAndDropIndicatorColourId 

The colour to use for the drag-and-drop target position indicator.

selectedItemBackgroundColourId 

The colour to use to fill the background of any selected items.

Constructor & Destructor Documentation

TreeView::TreeView ( const String componentName = String::empty)

Creates an empty treeview.

Once you've got a treeview component, you'll need to give it something to display, using the setRootItem() method.

TreeView::~TreeView ( )

Destructor.

Member Function Documentation

bool TreeView::areItemsOpenByDefault ( ) const
inlinenoexcept

Returns true if the tree's items default to being open.

See Also
setDefaultOpenness
bool TreeView::areOpenCloseButtonsVisible ( ) const
inlinenoexcept

Returns whether open/close buttons are shown.

See Also
setOpenCloseButtonsVisible
void TreeView::clearSelectedItems ( )

Deselects any items that are currently selected.

void TreeView::colourChanged ( )
override
void TreeView::deleteRootItem ( )

This will remove and delete the current root item. It's a convenient way of deleting the item and calling setRootItem (nullptr).

void TreeView::enablementChanged ( )
override
void TreeView::fileDragEnter ( const StringArray files,
int  x,
int  y 
)
override
void TreeView::fileDragExit ( const StringArray files)
override
void TreeView::fileDragMove ( const StringArray files,
int  x,
int  y 
)
override
void TreeView::filesDropped ( const StringArray files,
int  x,
int  y 
)
override
TreeViewItem * TreeView::findItemFromIdentifierString ( const String identifierString) const

Searches the tree for an item with the specified identifier. The identifier string must have been created by calling TreeViewItem::getItemIdentifierString(). If no such item exists, this will return false. If the item is found, all of its items will be automatically opened.

int TreeView::getIndentSize ( )
noexcept

Returns the number of pixels by which each nested level of the tree is indented.

See Also
setIndentSize
TreeViewItem * TreeView::getItemAt ( int  yPosition) const
noexcept

Returns the item that contains a given y position. The y is relative to the top of the TreeView component.

TreeViewItem * TreeView::getItemOnRow ( int  index) const

Returns the item on a particular row of the tree. If the index is out of range, this will return nullptr.

See Also
getNumRowsInTree, TreeViewItem::getRowNumberInTree()
int TreeView::getNumRowsInTree ( ) const

Returns the number of rows the tree is using. This will depend on which items are open.

See Also
TreeViewItem::getRowNumberInTree()
int TreeView::getNumSelectedItems ( int  maximumDepthToSearchTo = -1) const
noexcept

Returns the number of items that are currently selected. If maximumDepthToSearchTo is >= 0, it lets you specify a maximum depth to which the tree will be recursed.

See Also
getSelectedItem, clearSelectedItems
XmlElement * TreeView::getOpennessState ( bool  alsoIncludeScrollPosition) const

Saves the current state of open/closed nodes so it can be restored later.

This takes a snapshot of which nodes have been explicitly opened or closed, and records it as XML. To identify node objects it uses the TreeViewItem::getUniqueName() method to create named paths. This means that the same state of open/closed nodes can be restored to a completely different instance of the tree, as long as it contains nodes whose unique names are the same.

The caller is responsible for deleting the object that is returned.

Parameters
alsoIncludeScrollPositionif this is true, the state will also include information about where the tree has been scrolled to vertically, so this can also be restored
See Also
restoreOpennessState
TreeViewItem* TreeView::getRootItem ( ) const
inlinenoexcept

Returns the tree's root item.

This will be the last object passed to setRootItem(), or nullptr if none has been set.

TreeViewItem * TreeView::getSelectedItem ( int  index) const
noexcept

Returns one of the selected items in the tree.

Parameters
indexthe index, 0 to (getNumSelectedItems() - 1)
Viewport * TreeView::getViewport ( ) const
noexcept

Returns the treeview's Viewport object.

bool TreeView::isInterestedInDragSource ( const SourceDetails dragSourceDetails)
overridevirtual

Callback to check whether this target is interested in the type of object being dragged.

Parameters
dragSourceDetailscontains information about the source of the drag operation.
Returns
true if this component wants to receive the other callbacks regarging this type of object; if it returns false, no other callbacks will be made.

Implements DragAndDropTarget.

bool TreeView::isInterestedInFileDrag ( const StringArray files)
override
bool TreeView::isMultiSelectEnabled ( ) const
inlinenoexcept

Returns whether multi-select has been enabled for the tree.

See Also
setMultiSelectEnabled
bool TreeView::isRootItemVisible ( ) const
inlinenoexcept

Returns true if the root item is visible.

See Also
setRootItemVisible
void TreeView::itemDragEnter ( const SourceDetails dragSourceDetails)
overridevirtual

Callback to indicate that something is being dragged over this component.

This gets called when the user moves the mouse into this component while dragging something.

Use this callback as a trigger to make your component repaint itself to give the user feedback about whether the item can be dropped here or not.

Parameters
dragSourceDetailscontains information about the source of the drag operation.
See Also
itemDragExit

Reimplemented from DragAndDropTarget.

void TreeView::itemDragExit ( const SourceDetails dragSourceDetails)
overridevirtual

Callback to indicate that something has been dragged off the edge of this component.

This gets called when the user moves the mouse out of this component while dragging something.

If you've used itemDragEnter() to repaint your component and give feedback, use this as a signal to repaint it in its normal state.

Parameters
dragSourceDetailscontains information about the source of the drag operation.
See Also
itemDragEnter

Reimplemented from DragAndDropTarget.

void TreeView::itemDragMove ( const SourceDetails dragSourceDetails)
overridevirtual

Callback to indicate that the user is dragging something over this component.

This gets called when the user moves the mouse over this component while dragging something. Normally overriding itemDragEnter() and itemDragExit() are enough, but this lets you know what happens in-between.

Parameters
dragSourceDetailscontains information about the source of the drag operation.

Reimplemented from DragAndDropTarget.

void TreeView::itemDropped ( const SourceDetails dragSourceDetails)
overridevirtual

Callback to indicate that the user has dropped something onto this component.

When the user drops an item this get called, and you can use the description to work out whether your object wants to deal with it or not.

Note that after this is called, the itemDragExit method may not be called, so you should clean up in here if there's anything you need to do when the drag finishes.

Parameters
dragSourceDetailscontains information about the source of the drag operation.

Implements DragAndDropTarget.

bool TreeView::keyPressed ( const KeyPress key)
override
void TreeView::moveSelectedRow ( int  deltaRows)

Moves the selected row up or down by the specified number of rows.

void TreeView::paint ( Graphics g)
override
void TreeView::resized ( )
override
void TreeView::restoreOpennessState ( const XmlElement newState,
bool  restoreStoredSelection 
)

Restores a previously saved arrangement of open/closed nodes.

This will try to restore a snapshot of the tree's state that was created by the getOpennessState() method. If any of the nodes named in the original XML aren't present in this tree, they will be ignored.

If restoreStoredSelection is true, it will also try to re-select any items that were selected in the stored state.

See Also
getOpennessState
void TreeView::scrollToKeepItemVisible ( TreeViewItem item)

Tries to scroll the tree so that this item is on-screen somewhere.

void TreeView::setDefaultOpenness ( bool  isOpenByDefault)

Sets whether items are open or closed by default.

Normally, items are closed until the user opens them, but you can use this to make them default to being open until explicitly closed.

See Also
areItemsOpenByDefault
void TreeView::setIndentSize ( int  newIndentSize)

Changes the distance by which each nested level of the tree is indented.

See Also
getIndentSize
void TreeView::setMultiSelectEnabled ( bool  canMultiSelect)

This sets a flag to indicate that the tree can be used for multi-selection.

You can always select multiple items internally by calling the TreeViewItem::setSelected() method, but this flag indicates whether the user is allowed to multi-select by clicking on the tree.

By default it is disabled.

See Also
isMultiSelectEnabled
void TreeView::setOpenCloseButtonsVisible ( bool  shouldBeVisible)

Sets a flag to indicate whether to hide the open/close buttons.

See Also
areOpenCloseButtonsVisible
void TreeView::setRootItem ( TreeViewItem newRootItem)

Sets the item that is displayed in the treeview.

A tree has a single root item which contains as many sub-items as it needs. If you want the tree to contain a number of root items, you should still use a single root item above these, but hide it using setRootItemVisible().

You can pass nullptr to this method to clear the tree and remove its current root item.

The object passed in will not be deleted by the treeview, it's up to the caller to delete it when no longer needed. BUT make absolutely sure that you don't delete this item until you've removed it from the tree, either by calling setRootItem (nullptr), or by deleting the tree first. You can also use deleteRootItem() as a quick way to delete it.

void TreeView::setRootItemVisible ( bool  shouldBeVisible)

Changes whether the tree's root item is shown or not.

If the root item is hidden, only its sub-items will be shown in the treeview - this lets you make the tree look as if it's got many root items. If it's hidden, this call will also make sure the root item is open (otherwise the treeview would look empty).

Friends And Related Function Documentation

friend struct ContainerDeletePolicy< TreeViewport >
friend
friend class ContentComponent
friend
friend class TreeViewItem
friend

The documentation for this class was generated from the following files: