#pragma once #include "workspace.h" #include "rendering/view.h" #include 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(); auto init(float dpi_scale = 1.0f) -> void; auto draw(const UIContext& ctx) -> View; private: 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 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 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; 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; TabState m_tabs[kTabCount]; int m_active_tab = 0; int m_tab_request = -1; bool m_first_frame = true; float m_dpi_scale = 1.0f; int m_gizmo_op = 0; float m_ui_scale = 1.0f; 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; }; }