yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
theme_properties.cc
Go to the documentation of this file.
2
3#include "absl/strings/str_format.h"
5
6namespace yaze {
7namespace editor {
8namespace layout_designer {
9
11 ImGuiStyle& style = ImGui::GetStyle();
12
13 // Padding
14 style.WindowPadding = window_padding;
15 style.FramePadding = frame_padding;
16 style.CellPadding = cell_padding;
17 style.ItemSpacing = item_spacing;
18 style.ItemInnerSpacing = item_inner_spacing;
19
20 // Rounding
21 style.WindowRounding = window_rounding;
22 style.ChildRounding = child_rounding;
23 style.FrameRounding = frame_rounding;
24 style.PopupRounding = popup_rounding;
25 style.ScrollbarRounding = scrollbar_rounding;
26 style.GrabRounding = grab_rounding;
27 style.TabRounding = tab_rounding;
28
29 // Borders
30 style.WindowBorderSize = window_border_size;
31 style.ChildBorderSize = child_border_size;
32 style.PopupBorderSize = popup_border_size;
33 style.FrameBorderSize = frame_border_size;
34 style.TabBorderSize = tab_border_size;
35
36 // Sizes
37 style.IndentSpacing = indent_spacing;
38 style.ScrollbarSize = scrollbar_size;
39 style.GrabMinSize = grab_min_size;
40}
41
43 const ImGuiStyle& style = ImGui::GetStyle();
44
45 window_padding = style.WindowPadding;
46 frame_padding = style.FramePadding;
47 cell_padding = style.CellPadding;
48 item_spacing = style.ItemSpacing;
49 item_inner_spacing = style.ItemInnerSpacing;
50
51 window_rounding = style.WindowRounding;
52 child_rounding = style.ChildRounding;
53 frame_rounding = style.FrameRounding;
54 popup_rounding = style.PopupRounding;
55 scrollbar_rounding = style.ScrollbarRounding;
56 grab_rounding = style.GrabRounding;
57 tab_rounding = style.TabRounding;
58
59 window_border_size = style.WindowBorderSize;
60 child_border_size = style.ChildBorderSize;
61 popup_border_size = style.PopupBorderSize;
62 frame_border_size = style.FrameBorderSize;
63 tab_border_size = style.TabBorderSize;
64
65 indent_spacing = style.IndentSpacing;
66 scrollbar_size = style.ScrollbarSize;
67 grab_min_size = style.GrabMinSize;
68}
69
71 *this = ThemeProperties(); // Reset to default values
72}
73
75 std::string code;
76
77 code += "// Theme Configuration - Generated by Layout Designer\n";
78 code += "void ApplyTheme() {\n";
79 code += " ImGuiStyle& style = ImGui::GetStyle();\n\n";
80
81 code += " // Padding\n";
82 code += absl::StrFormat(" style.WindowPadding = ImVec2(%.1ff, %.1ff);\n",
84 code += absl::StrFormat(" style.FramePadding = ImVec2(%.1ff, %.1ff);\n",
86 code += absl::StrFormat(" style.CellPadding = ImVec2(%.1ff, %.1ff);\n",
88 code += absl::StrFormat(" style.ItemSpacing = ImVec2(%.1ff, %.1ff);\n",
90 code += absl::StrFormat(" style.ItemInnerSpacing = ImVec2(%.1ff, %.1ff);\n\n",
92
93 code += " // Rounding\n";
94 code += absl::StrFormat(" style.WindowRounding = %.1ff;\n", window_rounding);
95 code += absl::StrFormat(" style.ChildRounding = %.1ff;\n", child_rounding);
96 code += absl::StrFormat(" style.FrameRounding = %.1ff;\n", frame_rounding);
97 code += absl::StrFormat(" style.PopupRounding = %.1ff;\n", popup_rounding);
98 code += absl::StrFormat(" style.ScrollbarRounding = %.1ff;\n", scrollbar_rounding);
99 code += absl::StrFormat(" style.GrabRounding = %.1ff;\n", grab_rounding);
100 code += absl::StrFormat(" style.TabRounding = %.1ff;\n\n", tab_rounding);
101
102 code += " // Borders\n";
103 code += absl::StrFormat(" style.WindowBorderSize = %.1ff;\n", window_border_size);
104 code += absl::StrFormat(" style.ChildBorderSize = %.1ff;\n", child_border_size);
105 code += absl::StrFormat(" style.PopupBorderSize = %.1ff;\n", popup_border_size);
106 code += absl::StrFormat(" style.FrameBorderSize = %.1ff;\n", frame_border_size);
107 code += absl::StrFormat(" style.TabBorderSize = %.1ff;\n\n", tab_border_size);
108
109 code += " // Sizes\n";
110 code += absl::StrFormat(" style.IndentSpacing = %.1ff;\n", indent_spacing);
111 code += absl::StrFormat(" style.ScrollbarSize = %.1ff;\n", scrollbar_size);
112 code += absl::StrFormat(" style.GrabMinSize = %.1ff;\n", grab_min_size);
113
114 code += "}\n";
115
116 return code;
117}
118
119// ============================================================================
120// ThemePropertiesPanel Implementation
121// ============================================================================
122
124 bool modified = false;
125
126 ImGui::Text(ICON_MD_PALETTE " Theme Properties");
127 ImGui::TextDisabled("Configure visual styling");
128 ImGui::Separator();
129
130 if (ImGui::Button("Load from Current")) {
131 properties.LoadFromCurrent();
132 modified = true;
133 }
134 ImGui::SameLine();
135 if (ImGui::Button("Apply to App")) {
136 properties.Apply();
137 }
138 ImGui::SameLine();
139 if (ImGui::Button("Reset")) {
140 properties.Reset();
141 modified = true;
142 }
143
144 ImGui::Spacing();
145 ImGui::Separator();
146
147 // Sections
148 DrawPaddingSection(properties);
149 DrawRoundingSection(properties);
150 DrawBordersSection(properties);
151 DrawSizesSection(properties);
152
153 return modified;
154}
155
157 if (ImGui::CollapsingHeader(ICON_MD_SPACE_BAR " Padding",
158 show_padding_ ? ImGuiTreeNodeFlags_DefaultOpen : 0)) {
159 ImGui::SliderFloat2("Window Padding", &properties.window_padding.x, 0.0f, 20.0f, "%.0f");
160 ImGui::SliderFloat2("Frame Padding", &properties.frame_padding.x, 0.0f, 20.0f, "%.0f");
161 ImGui::SliderFloat2("Cell Padding", &properties.cell_padding.x, 0.0f, 20.0f, "%.0f");
162 ImGui::SliderFloat2("Item Spacing", &properties.item_spacing.x, 0.0f, 20.0f, "%.0f");
163 ImGui::SliderFloat2("Item Inner Spacing", &properties.item_inner_spacing.x, 0.0f, 20.0f, "%.0f");
164 }
165}
166
168 if (ImGui::CollapsingHeader(ICON_MD_ROUNDED_CORNER " Rounding",
169 show_rounding_ ? ImGuiTreeNodeFlags_DefaultOpen : 0)) {
170 ImGui::SliderFloat("Window Rounding", &properties.window_rounding, 0.0f, 12.0f, "%.0f");
171 ImGui::SliderFloat("Child Rounding", &properties.child_rounding, 0.0f, 12.0f, "%.0f");
172 ImGui::SliderFloat("Frame Rounding", &properties.frame_rounding, 0.0f, 12.0f, "%.0f");
173 ImGui::SliderFloat("Popup Rounding", &properties.popup_rounding, 0.0f, 12.0f, "%.0f");
174 ImGui::SliderFloat("Scrollbar Rounding", &properties.scrollbar_rounding, 0.0f, 12.0f, "%.0f");
175 ImGui::SliderFloat("Grab Rounding", &properties.grab_rounding, 0.0f, 12.0f, "%.0f");
176 ImGui::SliderFloat("Tab Rounding", &properties.tab_rounding, 0.0f, 12.0f, "%.0f");
177 }
178}
179
181 if (ImGui::CollapsingHeader(ICON_MD_BORDER_ALL " Borders",
182 show_borders_ ? ImGuiTreeNodeFlags_DefaultOpen : 0)) {
183 ImGui::SliderFloat("Window Border", &properties.window_border_size, 0.0f, 2.0f, "%.0f");
184 ImGui::SliderFloat("Child Border", &properties.child_border_size, 0.0f, 2.0f, "%.0f");
185 ImGui::SliderFloat("Popup Border", &properties.popup_border_size, 0.0f, 2.0f, "%.0f");
186 ImGui::SliderFloat("Frame Border", &properties.frame_border_size, 0.0f, 2.0f, "%.0f");
187 ImGui::SliderFloat("Tab Border", &properties.tab_border_size, 0.0f, 2.0f, "%.0f");
188 }
189}
190
192 if (ImGui::CollapsingHeader(ICON_MD_STRAIGHTEN " Sizes",
193 show_sizes_ ? ImGuiTreeNodeFlags_DefaultOpen : 0)) {
194 ImGui::SliderFloat("Indent Spacing", &properties.indent_spacing, 0.0f, 30.0f, "%.0f");
195 ImGui::SliderFloat("Scrollbar Size", &properties.scrollbar_size, 1.0f, 20.0f, "%.0f");
196 ImGui::SliderFloat("Grab Min Size", &properties.grab_min_size, 1.0f, 20.0f, "%.0f");
197 }
198}
199
200} // namespace layout_designer
201} // namespace editor
202} // namespace yaze
203
void DrawBordersSection(ThemeProperties &properties)
void DrawPaddingSection(ThemeProperties &properties)
bool Draw(ThemeProperties &properties)
Draw the theme properties editor.
void DrawRoundingSection(ThemeProperties &properties)
#define ICON_MD_ROUNDED_CORNER
Definition icons.h:1626
#define ICON_MD_SPACE_BAR
Definition icons.h:1807
#define ICON_MD_BORDER_ALL
Definition icons.h:292
#define ICON_MD_STRAIGHTEN
Definition icons.h:1871
#define ICON_MD_PALETTE
Definition icons.h:1370
Encapsulates ImGui style properties for visual design.