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 +=
91 absl::StrFormat(" style.ItemInnerSpacing = ImVec2(%.1ff, %.1ff);\n\n",
93
94 code += " // Rounding\n";
95 code += absl::StrFormat(" style.WindowRounding = %.1ff;\n", window_rounding);
96 code += absl::StrFormat(" style.ChildRounding = %.1ff;\n", child_rounding);
97 code += absl::StrFormat(" style.FrameRounding = %.1ff;\n", frame_rounding);
98 code += absl::StrFormat(" style.PopupRounding = %.1ff;\n", popup_rounding);
99 code += absl::StrFormat(" style.ScrollbarRounding = %.1ff;\n",
101 code += absl::StrFormat(" style.GrabRounding = %.1ff;\n", grab_rounding);
102 code += absl::StrFormat(" style.TabRounding = %.1ff;\n\n", tab_rounding);
103
104 code += " // Borders\n";
105 code += absl::StrFormat(" style.WindowBorderSize = %.1ff;\n",
107 code +=
108 absl::StrFormat(" style.ChildBorderSize = %.1ff;\n", child_border_size);
109 code +=
110 absl::StrFormat(" style.PopupBorderSize = %.1ff;\n", popup_border_size);
111 code +=
112 absl::StrFormat(" style.FrameBorderSize = %.1ff;\n", frame_border_size);
113 code +=
114 absl::StrFormat(" style.TabBorderSize = %.1ff;\n\n", tab_border_size);
115
116 code += " // Sizes\n";
117 code += absl::StrFormat(" style.IndentSpacing = %.1ff;\n", indent_spacing);
118 code += absl::StrFormat(" style.ScrollbarSize = %.1ff;\n", scrollbar_size);
119 code += absl::StrFormat(" style.GrabMinSize = %.1ff;\n", grab_min_size);
120
121 code += "}\n";
122
123 return code;
124}
125
126// ============================================================================
127// ThemePropertiesPanel Implementation
128// ============================================================================
129
131 bool modified = false;
132
133 ImGui::Text(ICON_MD_PALETTE " Theme Properties");
134 ImGui::TextDisabled("Configure visual styling");
135 ImGui::Separator();
136
137 if (ImGui::Button("Load from Current")) {
138 properties.LoadFromCurrent();
139 modified = true;
140 }
141 ImGui::SameLine();
142 if (ImGui::Button("Apply to App")) {
143 properties.Apply();
144 }
145 ImGui::SameLine();
146 if (ImGui::Button("Reset")) {
147 properties.Reset();
148 modified = true;
149 }
150
151 ImGui::Spacing();
152 ImGui::Separator();
153
154 // Sections
155 DrawPaddingSection(properties);
156 DrawRoundingSection(properties);
157 DrawBordersSection(properties);
158 DrawSizesSection(properties);
159
160 return modified;
161}
162
164 if (ImGui::CollapsingHeader(
165 ICON_MD_SPACE_BAR " Padding",
166 show_padding_ ? ImGuiTreeNodeFlags_DefaultOpen : 0)) {
167 ImGui::SliderFloat2("Window Padding", &properties.window_padding.x, 0.0f,
168 20.0f, "%.0f");
169 ImGui::SliderFloat2("Frame Padding", &properties.frame_padding.x, 0.0f,
170 20.0f, "%.0f");
171 ImGui::SliderFloat2("Cell Padding", &properties.cell_padding.x, 0.0f, 20.0f,
172 "%.0f");
173 ImGui::SliderFloat2("Item Spacing", &properties.item_spacing.x, 0.0f, 20.0f,
174 "%.0f");
175 ImGui::SliderFloat2("Item Inner Spacing", &properties.item_inner_spacing.x,
176 0.0f, 20.0f, "%.0f");
177 }
178}
179
181 if (ImGui::CollapsingHeader(
182 ICON_MD_ROUNDED_CORNER " Rounding",
183 show_rounding_ ? ImGuiTreeNodeFlags_DefaultOpen : 0)) {
184 ImGui::SliderFloat("Window Rounding", &properties.window_rounding, 0.0f,
185 12.0f, "%.0f");
186 ImGui::SliderFloat("Child Rounding", &properties.child_rounding, 0.0f,
187 12.0f, "%.0f");
188 ImGui::SliderFloat("Frame Rounding", &properties.frame_rounding, 0.0f,
189 12.0f, "%.0f");
190 ImGui::SliderFloat("Popup Rounding", &properties.popup_rounding, 0.0f,
191 12.0f, "%.0f");
192 ImGui::SliderFloat("Scrollbar Rounding", &properties.scrollbar_rounding,
193 0.0f, 12.0f, "%.0f");
194 ImGui::SliderFloat("Grab Rounding", &properties.grab_rounding, 0.0f, 12.0f,
195 "%.0f");
196 ImGui::SliderFloat("Tab Rounding", &properties.tab_rounding, 0.0f, 12.0f,
197 "%.0f");
198 }
199}
200
202 if (ImGui::CollapsingHeader(
203 ICON_MD_BORDER_ALL " Borders",
204 show_borders_ ? ImGuiTreeNodeFlags_DefaultOpen : 0)) {
205 ImGui::SliderFloat("Window Border", &properties.window_border_size, 0.0f,
206 2.0f, "%.0f");
207 ImGui::SliderFloat("Child Border", &properties.child_border_size, 0.0f,
208 2.0f, "%.0f");
209 ImGui::SliderFloat("Popup Border", &properties.popup_border_size, 0.0f,
210 2.0f, "%.0f");
211 ImGui::SliderFloat("Frame Border", &properties.frame_border_size, 0.0f,
212 2.0f, "%.0f");
213 ImGui::SliderFloat("Tab Border", &properties.tab_border_size, 0.0f, 2.0f,
214 "%.0f");
215 }
216}
217
219 if (ImGui::CollapsingHeader(
220 ICON_MD_STRAIGHTEN " Sizes",
221 show_sizes_ ? ImGuiTreeNodeFlags_DefaultOpen : 0)) {
222 ImGui::SliderFloat("Indent Spacing", &properties.indent_spacing, 0.0f,
223 30.0f, "%.0f");
224 ImGui::SliderFloat("Scrollbar Size", &properties.scrollbar_size, 1.0f,
225 20.0f, "%.0f");
226 ImGui::SliderFloat("Grab Min Size", &properties.grab_min_size, 1.0f, 20.0f,
227 "%.0f");
228 }
229}
230
231} // namespace layout_designer
232} // namespace editor
233} // namespace yaze
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.