Class TreeView#

Nested Relationships#

Nested Types#

Inheritance Relationships#

Base Type#

Class Documentation#

class TreeView : public Karana::WebUI::Widget#

Widget displaying an interactable tree using hierarchical html.

Public Types

using NodeList = std::vector<Node>#

Alias for a list of nodes.

Public Functions

TreeView(Router &router, const NodeList &nodes = {}, std::function<void(Karana::Core::id_t)> on_select = {}, const Karana::Core::ks_ptr<State> &selection = nullptr)#

TreeView constructor.

Parameters:
  • router – The connection router to use

  • nodes – The initial list of nodes in the tree

  • on_select – Called when a node is selected in the UI

  • selection – Optional existing State for the selection

virtual ~TreeView()#

TreeView destructor.

void select(Karana::Core::id_t id)#

Select the node with the given id.

Note that calling this does not invoke the on_select callback passed into the constructor

Parameters:

id – The id to select

void setNodeLabel(Karana::Core::id_t id, std::string_view label)#

Update the label for the node with the given id.

Parameters:
  • id – The node id.

  • label – The new label text for the node.

void setNodes(const NodeList &nodes)#

Use a new set of nodes.

Parameters:

nodes – The new list of nodes.

Protected Functions

virtual void _onConnect(int client_id) override#

Called upon a client connecting.

This can be overridden to implement custom behavior.

Parameters:

client_id – Unique id for the client.

struct Node#

Data for a node in a TreeView.

Public Members

Karana::Core::id_t id#

Id of an object to associate the node with.

std::string label = "unnamed"#

Display name of the node.

std::optional<Karana::Core::id_t> parent = std::nullopt#

Id of the parent node, if any.

std::string category = "default"#

Style category (WIP).

std::string tooltip = ""#

Optional tooltip text.