opynsim
Unofficial C++ Documentation
Loading...
Searching...
No Matches
panel_manager.h
Go to the documentation of this file.
1#pragma once
2
5
6#include <concepts>
7#include <cstddef>
8#include <functional>
9#include <memory>
10#include <string_view>
11
12namespace osc { class Panel; }
13namespace osc { class Widget; }
14
15namespace osc
16{
17 // manages a collection of panels that may be toggled, disabled, spawned, etc.
19 public:
21 PanelManager(const PanelManager&) = delete;
26
30
31 // register a panel that can be toggled on/off
33 std::string_view base_name,
34 std::function<std::shared_ptr<Panel>(Widget*, std::string_view)> panel_constructor,
36 );
37
38 // register a panel that can spawn N copies (e.g. visualizers)
40 std::string_view base_name,
41 std::function<std::shared_ptr<Panel>(Widget*, std::string_view)> panel_constructor,
43 );
44
45 // returns the panel with the given name, or `nullptr` if not found
46 Panel* try_upd_panel_by_name(std::string_view);
49 {
51 return p ? dynamic_cast<TConcretePanel*>(p) : nullptr;
52 }
53
54 // methods for panels that are either enabled or disabled (toggleable)
55 size_t num_toggleable_panels() const;
59 void set_toggleable_panel_activated(std::string_view, bool);
60
61 // methods for dynamic panels that have been added at runtime (i.e. have been spawned)
62 size_t num_dynamic_panels() const;
65
66 // methods for spawnable panels (i.e. things that can create new dynamic panels)
67 size_t num_spawnable_panels() const;
70 std::string suggested_dynamic_panel_name(std::string_view base_name);
71 void push_dynamic_panel(std::string_view base_name, std::shared_ptr<Panel>);
72
73 void on_mount();
74 void on_unmount();
75 void on_tick();
76 void on_draw();
77
78 private:
79 class Impl;
80 std::unique_ptr<Impl> impl_;
81 };
82}
Definition c_string_view.h:12
Definition panel_manager.h:18
PanelManager(PanelManager &&) noexcept
size_t num_toggleable_panels() const
PanelManager(Widget *parent)
void register_spawnable_panel(std::string_view base_name, std::function< std::shared_ptr< Panel >(Widget *, std::string_view)> panel_constructor, size_t num_initially_opened_panels)
size_t num_spawnable_panels() const
PanelManager(const PanelManager &)=delete
void deactivate_dynamic_panel(size_t)
TConcretePanel * try_upd_panel_by_name_T(std::string_view name)
Definition panel_manager.h:48
void push_dynamic_panel(std::string_view base_name, std::shared_ptr< Panel >)
std::string suggested_dynamic_panel_name(std::string_view base_name)
void set_parent(Widget *)
CStringView dynamic_panel_name(size_t) const
CStringView toggleable_panel_name(size_t) const
bool is_toggleable_panel_activated(size_t) const
CStringView spawnable_panel_base_name(size_t) const
Panel * try_upd_panel_by_name(std::string_view)
size_t num_dynamic_panels() const
void register_toggleable_panel(std::string_view base_name, std::function< std::shared_ptr< Panel >(Widget *, std::string_view)> panel_constructor, ToggleablePanelFlags flags=ToggleablePanelFlags::Default)
const Widget * parent() const
void create_dynamic_panel(size_t)
void set_toggleable_panel_activated(size_t, bool)
void set_toggleable_panel_activated(std::string_view, bool)
Definition panel.h:13
Definition widget.h:26
Definition custom_decoration_generator.h:5
ToggleablePanelFlags
Definition toggleable_panel_flags.h:10
constexpr U to(T &&value)
Definition conversion.h:56