1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
#pragma once
#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();
auto init() -> 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;
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;
};
}
|