ttx 0.1.0
Loading...
Searching...
No Matches
layout_state.h
Go to the documentation of this file.
1#pragma once
2
3#include "di/container/vector/vector.h"
4#include "tab.h"
5#include "ttx/layout.h"
6
7namespace ttx {
9public:
10 explicit LayoutState(dius::tty::WindowSize const& size, bool hide_status_bar);
11
12 void layout(di::Optional<dius::tty::WindowSize> size = {});
13 auto set_active_tab(Tab* tab) -> bool;
14 void remove_tab(Tab& tab);
15 auto remove_pane(Tab& tab, Pane* pane) -> di::Box<Pane>;
16
17 auto add_pane(Tab& tab, CreatePaneArgs args, Direction direction, RenderThread& render_thread) -> di::Result<>;
18 auto add_tab(CreatePaneArgs args, RenderThread& render_thread) -> di::Result<>;
19
20 auto empty() const -> bool { return m_tabs.empty(); }
21 auto tabs() -> di::Vector<di::Box<Tab>>& { return m_tabs; }
22 auto active_tab() const -> di::Optional<Tab&> {
23 if (!m_active_tab) {
24 return {};
25 }
26 return *m_active_tab;
27 }
28
29 auto active_pane() const -> di::Optional<Pane&>;
30 auto size() const -> dius::tty::WindowSize { return m_size; }
31 auto hide_status_bar() const -> bool { return m_hide_status_bar; }
32
33private:
34 dius::tty::WindowSize m_size;
35 di::Vector<di::Box<Tab>> m_tabs {};
36 Tab* m_active_tab { nullptr };
37 bool m_hide_status_bar { false };
38};
39}
auto empty() const -> bool
Definition layout_state.h:20
LayoutState(dius::tty::WindowSize const &size, bool hide_status_bar)
Definition layout_state.cpp:4
auto size() const -> dius::tty::WindowSize
Definition layout_state.h:30
auto set_active_tab(Tab *tab) -> bool
Definition layout_state.cpp:25
auto add_pane(Tab &tab, CreatePaneArgs args, Direction direction, RenderThread &render_thread) -> di::Result<>
Definition layout_state.cpp:83
auto remove_pane(Tab &tab, Pane *pane) -> di::Box< Pane >
Definition layout_state.cpp:73
auto add_tab(CreatePaneArgs args, RenderThread &render_thread) -> di::Result<>
Definition layout_state.cpp:91
auto active_tab() const -> di::Optional< Tab & >
Definition layout_state.h:22
auto hide_status_bar() const -> bool
Definition layout_state.h:31
void remove_tab(Tab &tab)
Definition layout_state.cpp:45
auto tabs() -> di::Vector< di::Box< Tab > > &
Definition layout_state.h:21
auto active_pane() const -> di::Optional< Pane & >
Definition layout_state.cpp:105
Definition pane.h:29
Definition render.h:31
Definition test_layout.cpp:6
Definition cursor_style.h:5
Direction
Definition direction.h:7
@ Tab
Definition key.h:64
Definition pane.h:22
Definition tab.h:25