diff options
| author | hachem <im@hachem.wtf> | 2026-09-21 20:55:02 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2026-09-21 20:55:02 +0200 |
| commit | ec2839ecbfc3f28b3f335489ae7611b60fba82c5 (patch) | |
| tree | 68dae417deac323eb3878a540895f1e2ff1a2807 /src/ui/ui_layer.h | |
| parent | aa9dcb5bd9210c074c530b4f6f5ffbdd32beb717 (diff) | |
feat: update ui
Diffstat (limited to 'src/ui/ui_layer.h')
| -rw-r--r-- | src/ui/ui_layer.h | 74 |
1 files changed, 53 insertions, 21 deletions
diff --git a/src/ui/ui_layer.h b/src/ui/ui_layer.h index 62b4104..eac5273 100644 --- a/src/ui/ui_layer.h +++ b/src/ui/ui_layer.h @@ -3,40 +3,65 @@ #include "workspace.h" #include "rendering/view.h" +#include <string> + +struct ImFont; + namespace Donut { + enum class Tab { Simulation, SceneEditor, Export }; + enum class Panel { Outliner, Properties, BlackHole, Settings, Export, Stats }; + inline constexpr int kTabCount = 3; + inline constexpr int kPanelCount = 6; + class UILayer { public: - UILayer() = default; + UILayer(); + + auto init() -> void; auto draw(const UIContext& ctx) -> View; private: - enum class Mode { Scene, Simulation }; - enum class Layout { Simulation, SceneEditing, Export }; + struct TabState + { + Tab id = Tab::Simulation; + const char* label = nullptr; + const char* key = nullptr; + View view = View::BlackHole; + unsigned int dock_id = 0; + std::string name[kPanelCount]; + bool allowed[kPanelCount] = {}; + bool defaults[kPanelCount] = {}; + bool show[kPanelCount] = {}; + bool reset = false; + bool appearing = false; + }; auto draw_menu_bar(const UIContext& ctx) -> void; - auto build_layout(unsigned int dockspace_id) -> void; - auto apply_layout(Layout layout) -> void; + auto draw_tab_strip() -> void; + auto draw_status_bar(const UIContext& ctx) -> void; + auto build_layout(TabState& tab) -> void; + auto request_tab(int index) -> void { m_tab_request = index; } + auto sync_persisted() -> void; - auto panel_outliner(const UIContext& ctx) -> void; - auto panel_properties(const UIContext& ctx) -> void; - auto panel_black_hole(const UIContext& ctx) -> void; - auto panel_settings(const UIContext& ctx) -> void; - auto panel_export(const UIContext& ctx) -> void; - auto panel_stats(const UIContext& ctx) -> void; + auto begin_panel(TabState& tab, Panel p) -> bool; + auto draw_panel(const UIContext& ctx, TabState& tab, Panel p) -> void; + auto panel_outliner(const UIContext& ctx, TabState& tab) -> void; + auto panel_properties(const UIContext& ctx, TabState& tab) -> void; + auto panel_black_hole(const UIContext& ctx, TabState& tab) -> void; + auto panel_settings(const UIContext& ctx, TabState& tab) -> void; + auto panel_export(const UIContext& ctx, TabState& tab) -> void; + auto panel_stats(const UIContext& ctx, TabState& tab) -> void; - Mode m_mode = Mode::Simulation; - Layout m_layout = Layout::Simulation; - bool m_rebuild_layout = false; - bool m_first_frame = true; + auto section(const char* title, bool default_open = true) -> bool; + auto caption(const char* text) -> void; + auto segmented(const char* id, const char* const* labels, int count, int& value) -> bool; - bool m_show_outliner = false; - bool m_show_properties = false; - bool m_show_black_hole = true; - bool m_show_settings = false; - bool m_show_export = false; - bool m_show_stats = true; + TabState m_tabs[kTabCount]; + int m_active_tab = 0; + int m_tab_request = -1; + bool m_first_frame = true; int m_gizmo_op = 0; @@ -45,5 +70,12 @@ namespace Donut bool m_exp_color = true, m_exp_redshift = false, m_exp_temperature = false, m_exp_impact = false; int m_exp_resolution = 1, m_exp_format = 0; int m_exp_written = 0; bool m_exp_reported = false; + + ImFont* m_font_body = nullptr; + ImFont* m_font_heading = nullptr; + + static constexpr int kFrameHist = 120; + float m_frame_hist[kFrameHist] = {}; + int m_frame_hist_i = 0; }; } |
