WindowTabs Class

Apps › Core

#include <vortex/vshell.h>

Public Functions

WindowTabs(VApp & app)
void add(const std::string & tab_path, const std::string & pane_path, const std::string & state_name)
bool remove(const std::string & tab_path)
void activate(std::string tab_path)
const std::string & active()
const std::string & previous()
bool has(const std::string & tab_path)

Detailed Description

Controller that keeps one window tab active and shows only that tab's pane.

wire_main_window_shell() creates one for the titlebar's App and Settings tabs and returns it. An app adds the tabs that it creates at runtime to the same controller, so that they share one selection with the built-in tabs: activating an app tab deselects Settings, and the other way around.

Activating a tab moves the highlight state onto it from the tab that was active, shows its pane, and hides every other pane. Tabs and panes are named by their node paths, and each tab names its own highlight state, since tab templates differ:

std::shared_ptr<WindowTabs> tabs = wire_main_window_shell(app);
const std::string tab = "App/Main Window/Titlebar/Left Tabs/Notes Tab";

tabs->add(tab, "App/Main Window/Notes Pane", "Selected");
tabs->activate(tab);

Several tabs can share one pane, like document tabs that all show the same editor, and the pane stays shown while any of them is active.

Activating flips a tab's highlight state rather than setting it, so a tab's highlight must start off and be left to this controller.

Member Function Documentation

WindowTabs(VApp & app)

Creates a controller with no tabs, for the nodes of app.

app must outlive the controller, since it keeps a reference.

void add(const std::string & tab_path, const std::string & pane_path, const std::string & state_name)

Adds a tab without activating it.

Adding a tab again replaces its pane and highlight state.

bool remove(const std::string & tab_path)

Removes a tab and hides its pane, unless the active tab shares that pane.

Removing the active tab also turns off its highlight and leaves no tab active, so the caller activates another one next. Returns true when the tab was active.

void activate(std::string tab_path)

Makes tab_path the active tab.

Does nothing when the tab is already active or was never added. activate(previous()) is safe, since the argument is a copy.

const std::string & active()

Returns the active tab's path, or an empty string when no tab is active.

bool has(const std::string & tab_path)

Returns whether tab_path is one of this controller's tabs.

› Documentation
Appearance
Theme
—