class GUITreeView

GUI element that displays some contents in a tree-view where elements are placed vertically above/beneath each other, and different elements may be nested within other elements.

Elements may be selected, renamed, dragged and re-parented.

This class is abstract and meant to be extended by an implementation specific to some content type (for example scene object hierarchy).

Public

Methods

staticGetGuiTypeName

static const String &GetGuiTypeName()

Returns type name of the GUI element used for finding GUI element styles.

DeleteSelection

void DeleteSelection()

Deletes all currently selected elements.

DuplicateSelection

virtual void DuplicateSelection()

Duplicates the currently selected entries.

CopySelection

virtual void CopySelection()

Marks the current selection for copying.

CutSelection

virtual void CutSelection()

Marks the current selection for cutting.

Paste

virtual void Paste()

Pastes a set of entries previously marked for cut or copy.

RenameSelected

void RenameSelected()

Starts rename operation on the currently selected element.

Internal

Methods

UpdateInternal

void UpdateInternal()

Updates tree view if dirty, among other operations.

Must be called every frame.

Protected

Constructors

GUITreeView

GUITreeView(const GUISizeConstraints &sizeConstraints)

Methods

~GUITreeView

virtual ~GUITreeView() noexcept

CalculateUnconstrainedOptimalSize

GUILogicalSize CalculateUnconstrainedOptimalSize() const override

Calculates the optimal size for the GUI element, ignoring size constraints.

UpdateLayoutForChildren

void UpdateLayoutForChildren() override

Calculates sizes and relative positions for all child elements.

Should be preceded with a call to UpdateOptimalLayoutSizes().

UpdateAbsoluteCoordinates

void UpdateAbsoluteCoordinates(const GUIPhysicalPointF &parentOrigin, float parentScale, const GUIPhysicalAreaF &parentVisibleArea) override

Updates the absolute coordinates of the GUI element using the currently assigned relative coordinates and the provided .

Also calculates the visible area clip rectangle and marks culled elements if they have no visible area. This should be called after updating the layout (as layout update calculates the needed relative coordinates). This may also be called independently of layout update, which is useful for scroll areas that then do not require a full layout pass to scroll their children.

parentOrigin
Absolute origin to add to the relative coordinates, in order to determine the absolute element coordinates.
parentScale
Scale of the parent GUI element.
parentVisibleArea
Absolute visible (clipped) area though which this element may be seen. This will be used for culling and clipping.

DoOnMouseEvent

bool DoOnMouseEvent(const GUIMouseEvent &ev) override

Called when a mouse event is received on any GUI element the mouse is interacting with.

Return true if you have processed the event and don't want other elements to process it.

DoOnCommandEvent

bool DoOnCommandEvent(const GUICommandEvent &ev) override

Called when a command event is triggered.

Return true if you have processed the event and don't want other elements to process it.

FindElementUnderCoord

const InteractableElement *FindElementUnderCoord(const GUIPhysicalPoint &coord) const

Attempts to find an interactable element under the specified coordinates.

Returns null if one cannot be found.

coord
Coordinates relative to parent GUI widget.

GetTopMostSelectedElement

TreeElement *GetTopMostSelectedElement() const

Returns the top-most selected tree element if selection is active, null otherwise.

GetBottomMostSelectedElement

TreeElement *GetBottomMostSelectedElement() const

Returns the bottom-most selected tree element if selection is active, null otherwise.

EnableEdit

void EnableEdit(TreeElement *element)

Starts rename operation on the specified tree element, spawning an input box.

DisableEdit

void DisableEdit(bool acceptChanges)

Ends rename operation if one is currently active.

acceptChanges
Should the new name be accepted or discarded.

ElementToggled

void ElementToggled(TreeElement *element, bool toggled)

Triggered when the Foldout button for a tree element was been toggled (something was expanded or collapsed).

GetRootElement

virtual TreeElement &GetRootElement() = 0

Returns the top level TreeElement.

GetRootElementConst

virtual const TreeElement &GetRootElementConst() const = 0

Returns the top level TreeElement that cannot be modified.

UpdateTreeElementHierarchy

virtual void UpdateTreeElementHierarchy() = 0

Checks if the hierarchy needs any updates and performs those updates if needed.

RenameTreeElement

virtual void RenameTreeElement(TreeElement *element, const String &name) = 0

Changes the name of the content associated with the provided tree element.

DeleteTreeElement

virtual void DeleteTreeElement(TreeElement *element) = 0

Deletes the content associated with the provided tree element.

AcceptDragAndDrop

virtual bool AcceptDragAndDrop() const = 0

Checks whether the tree view can accept the currently active drag and drop operation.

DragAndDropStart

virtual void DragAndDropStart(const Vector<TreeElement *> &elements) = 0

Triggered when the user drags a tree element and starts a drag and drop operation.

DragAndDropEnded

virtual void DragAndDropEnded(TreeElement *overTreeElement) = 0

Triggered when the user ends a drag and drop operation over the tree view.

overTreeElement
TreeElement the drag operation ended over, if any.

SelectionChanged

virtual void SelectionChanged()

Triggered whenever a TreeElement gets selected or deselected.

IsSelectionActive

bool IsSelectionActive() const

Are any tree elements currently selected.

SelectElement

void SelectElement(TreeElement *element, bool triggerEvents = true)

Expands the selection to the provided TreeElement.

Doesn't clear previous selection.

UnselectElement

void UnselectElement(TreeElement *element, bool triggerEvents = true)

Unselects the provided TreeElement.

UnselectAll

void UnselectAll(bool sendEvent = true)

Unselects all selected TreeElements.

sendEvent
Determines should the external world be notified of this change.

ExpandToElement

void ExpandToElement(TreeElement *element)

Expands all parents of the provided TreeElement making it interactable.

ExpandElement

void ExpandElement(TreeElement *element, bool toggleButton = true)

Expands the provided TreeElement making its children interactable.

Set to true to change the toggle state on the toggle button itself. Set this to false if called from the toggle button callback.

CollapseElement

void CollapseElement(TreeElement *element, bool toggleButton = true)

Collapses the provided TreeElement making its children hidden and not interactable.

Set to true to change the toggle state on the toggle button itself. Set this to false if called from the toggle button callback.

UpdateElementGui

void UpdateElementGui(TreeElement *element)

Rebuilds the needed GUI elements for the provided TreeElement.

CloseTemporarilyExpandedElements

void CloseTemporarilyExpandedElements()

Close any elements that were temporarily expanded due to a drag operation hovering over them.

TemporarilyExpandElement

void TemporarilyExpandElement(const GUITreeView::InteractableElement *mouseOverElement)

Temporarily expand the provided element.

Temporarily expanded elements can be closed by calling closeTemporarilyExpandedElements().

ScrollToElement

void ScrollToElement(TreeElement *element, bool center)

Scrolls the parent GUIScrollArea (if any) so that the specified TreeElement is visible.

element
Element to scroll to.
center
If true the element will be centered in the scroll view, otherwise it will be at the top.

FindParentScrollArea

GUIScrollArea *FindParentScrollArea() const

Attempts to find the parent GUIScrollArea that the tree view is a child of.

Ping

void Ping(TreeElement *element)

Scrolls the tree view to the specified element and highlights it.

ClearPing

void ClearPing()

Clears the ping highlight on the currently highlighted element.

OnEditAccepted

void OnEditAccepted()

Triggered when the user accepts the changes during a rename operation.

OnEditCanceled

void OnEditCanceled()

Triggered when the user rejects the changes during a rename operation.

OnEditFocusLost

void OnEditFocusLost()

Triggered when the user clicks outside of the edit box during a rename operation.

Fields

mBackgroundImage

GUITexture * mBackgroundImage

mVisibleElements

Vector<InteractableElement> mVisibleElements

mIsElementSelected

bool mIsElementSelected

mSelectedElements

Vector<SelectedElement> mSelectedElements

mIsElementHighlighted

bool mIsElementHighlighted

mHighlightedElement

SelectedElement mHighlightedElement

mEditElement

TreeElement * mEditElement

mNameEditBox

GUITreeViewEditBox * mNameEditBox

mDragStartPosition

GUIPhysicalPoint mDragStartPosition

mDragPosition

GUIPhysicalPoint mDragPosition

mDragInProgress

bool mDragInProgress

mDragHighlight

GUITexture * mDragHighlight

mDragSepHighlight

GUITexture * mDragSepHighlight

mTopScrollBounds

GUIPhysicalArea mTopScrollBounds

mBottomScrollBounds

GUIPhysicalArea mBottomScrollBounds

mScrollState

ScrollState mScrollState

mLastScrollTime

float mLastScrollTime

mAutoExpandedElements

Stack<TreeElement *> mAutoExpandedElements

mMouseOverDragElement

TreeElement * mMouseOverDragElement

mMouseOverDragElementTime

float mMouseOverDragElementTime