yaze 0.2.0
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
style.cc
Go to the documentation of this file.
1#include "style.h"
2
3#include "imgui/imgui.h"
4#include "imgui/imgui_internal.h"
5
6namespace yaze {
7namespace app {
8namespace gui {
9
10// TODO: Add more display settings to popup windows.
11void BeginWindowWithDisplaySettings(const char* id, bool* active,
12 const ImVec2& size,
13 ImGuiWindowFlags flags) {
14 ImGuiStyle* ref = &ImGui::GetStyle();
15 static float childBgOpacity = 0.75f;
16 auto color = ref->Colors[ImGuiCol_WindowBg];
17
18 ImGui::PushStyleColor(ImGuiCol_WindowBg, color);
19 ImGui::PushStyleColor(ImGuiCol_ChildBg, color);
20 ImGui::PushStyleColor(ImGuiCol_Border, color);
21
22 ImGui::Begin(id, active, flags | ImGuiWindowFlags_MenuBar);
23 ImGui::BeginMenuBar();
24 if (ImGui::BeginMenu("Display Settings")) {
25 ImGui::SliderFloat("Child Background Opacity", &childBgOpacity, 0.0f, 1.0f);
26 ImGui::EndMenu();
27 }
28 ImGui::EndMenuBar();
29}
30
32 ImGui::End();
33 ImGui::PopStyleColor(3);
34}
35
36void BeginPadding(int i) {
37 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(i, i));
38 ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(i, i));
39}
41
43 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0));
44 ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
45}
46void EndNoPadding() { ImGui::PopStyleVar(2); }
47
48void BeginChildWithScrollbar(const char* str_id) {
49 ImGui::BeginChild(str_id, ImGui::GetContentRegionAvail(), true,
50 ImGuiWindowFlags_AlwaysVerticalScrollbar);
51}
52
54 ImGuiID child_id = ImGui::GetID((void*)(intptr_t)id);
55 ImGui::BeginChild(child_id, ImGui::GetContentRegionAvail(), true,
56 ImGuiWindowFlags_AlwaysVerticalScrollbar |
57 ImGuiWindowFlags_AlwaysHorizontalScrollbar);
58}
59
60void DrawDisplaySettings(ImGuiStyle* ref) {
61 // You can pass in a reference ImGuiStyle structure to compare to, revert to
62 // and save to (without a reference style pointer, we will use one compared
63 // locally as a reference)
64 ImGuiStyle& style = ImGui::GetStyle();
65 static ImGuiStyle ref_saved_style;
66
67 // Default to using internal storage as reference
68 static bool init = true;
69 if (init && ref == NULL) ref_saved_style = style;
70 init = false;
71 if (ref == NULL) ref = &ref_saved_style;
72
73 ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.50f);
74
75 if (ImGui::ShowStyleSelector("Colors##Selector")) ref_saved_style = style;
76 ImGui::ShowFontSelector("Fonts##Selector");
77
78 // Simplified Settings (expose floating-pointer border sizes as boolean
79 // representing 0.0f or 1.0f)
80 if (ImGui::SliderFloat("FrameRounding", &style.FrameRounding, 0.0f, 12.0f,
81 "%.0f"))
82 style.GrabRounding = style.FrameRounding; // Make GrabRounding always the
83 // same value as FrameRounding
84 {
85 bool border = (style.WindowBorderSize > 0.0f);
86 if (ImGui::Checkbox("WindowBorder", &border)) {
87 style.WindowBorderSize = border ? 1.0f : 0.0f;
88 }
89 }
90 ImGui::SameLine();
91 {
92 bool border = (style.FrameBorderSize > 0.0f);
93 if (ImGui::Checkbox("FrameBorder", &border)) {
94 style.FrameBorderSize = border ? 1.0f : 0.0f;
95 }
96 }
97 ImGui::SameLine();
98 {
99 bool border = (style.PopupBorderSize > 0.0f);
100 if (ImGui::Checkbox("PopupBorder", &border)) {
101 style.PopupBorderSize = border ? 1.0f : 0.0f;
102 }
103 }
104
105 // Save/Revert button
106 if (ImGui::Button("Save Ref")) *ref = ref_saved_style = style;
107 ImGui::SameLine();
108 if (ImGui::Button("Revert Ref")) style = *ref;
109 ImGui::SameLine();
110
111 ImGui::Separator();
112
113 if (ImGui::BeginTabBar("##tabs", ImGuiTabBarFlags_None)) {
114 if (ImGui::BeginTabItem("Sizes")) {
115 ImGui::SeparatorText("Main");
116 ImGui::SliderFloat2("WindowPadding", (float*)&style.WindowPadding, 0.0f,
117 20.0f, "%.0f");
118 ImGui::SliderFloat2("FramePadding", (float*)&style.FramePadding, 0.0f,
119 20.0f, "%.0f");
120 ImGui::SliderFloat2("ItemSpacing", (float*)&style.ItemSpacing, 0.0f,
121 20.0f, "%.0f");
122 ImGui::SliderFloat2("ItemInnerSpacing", (float*)&style.ItemInnerSpacing,
123 0.0f, 20.0f, "%.0f");
124 ImGui::SliderFloat2("TouchExtraPadding", (float*)&style.TouchExtraPadding,
125 0.0f, 10.0f, "%.0f");
126 ImGui::SliderFloat("IndentSpacing", &style.IndentSpacing, 0.0f, 30.0f,
127 "%.0f");
128 ImGui::SliderFloat("ScrollbarSize", &style.ScrollbarSize, 1.0f, 20.0f,
129 "%.0f");
130 ImGui::SliderFloat("GrabMinSize", &style.GrabMinSize, 1.0f, 20.0f,
131 "%.0f");
132
133 ImGui::SeparatorText("Borders");
134 ImGui::SliderFloat("WindowBorderSize", &style.WindowBorderSize, 0.0f,
135 1.0f, "%.0f");
136 ImGui::SliderFloat("ChildBorderSize", &style.ChildBorderSize, 0.0f, 1.0f,
137 "%.0f");
138 ImGui::SliderFloat("PopupBorderSize", &style.PopupBorderSize, 0.0f, 1.0f,
139 "%.0f");
140 ImGui::SliderFloat("FrameBorderSize", &style.FrameBorderSize, 0.0f, 1.0f,
141 "%.0f");
142 ImGui::SliderFloat("TabBorderSize", &style.TabBorderSize, 0.0f, 1.0f,
143 "%.0f");
144 ImGui::SliderFloat("TabBarBorderSize", &style.TabBarBorderSize, 0.0f,
145 2.0f, "%.0f");
146
147 ImGui::SeparatorText("Rounding");
148 ImGui::SliderFloat("WindowRounding", &style.WindowRounding, 0.0f, 12.0f,
149 "%.0f");
150 ImGui::SliderFloat("ChildRounding", &style.ChildRounding, 0.0f, 12.0f,
151 "%.0f");
152 ImGui::SliderFloat("FrameRounding", &style.FrameRounding, 0.0f, 12.0f,
153 "%.0f");
154 ImGui::SliderFloat("PopupRounding", &style.PopupRounding, 0.0f, 12.0f,
155 "%.0f");
156 ImGui::SliderFloat("ScrollbarRounding", &style.ScrollbarRounding, 0.0f,
157 12.0f, "%.0f");
158 ImGui::SliderFloat("GrabRounding", &style.GrabRounding, 0.0f, 12.0f,
159 "%.0f");
160 ImGui::SliderFloat("TabRounding", &style.TabRounding, 0.0f, 12.0f,
161 "%.0f");
162
163 ImGui::SeparatorText("Tables");
164 ImGui::SliderFloat2("CellPadding", (float*)&style.CellPadding, 0.0f,
165 20.0f, "%.0f");
166 ImGui::SliderAngle("TableAngledHeadersAngle",
167 &style.TableAngledHeadersAngle, -50.0f, +50.0f);
168
169 ImGui::SeparatorText("Widgets");
170 ImGui::SliderFloat2("WindowTitleAlign", (float*)&style.WindowTitleAlign,
171 0.0f, 1.0f, "%.2f");
172 ImGui::Combo("ColorButtonPosition", (int*)&style.ColorButtonPosition,
173 "Left\0Right\0");
174 ImGui::SliderFloat2("ButtonTextAlign", (float*)&style.ButtonTextAlign,
175 0.0f, 1.0f, "%.2f");
176 ImGui::SameLine();
177
178 ImGui::SliderFloat2("SelectableTextAlign",
179 (float*)&style.SelectableTextAlign, 0.0f, 1.0f,
180 "%.2f");
181 ImGui::SameLine();
182
183 ImGui::SliderFloat("SeparatorTextBorderSize",
184 &style.SeparatorTextBorderSize, 0.0f, 10.0f, "%.0f");
185 ImGui::SliderFloat2("SeparatorTextAlign",
186 (float*)&style.SeparatorTextAlign, 0.0f, 1.0f,
187 "%.2f");
188 ImGui::SliderFloat2("SeparatorTextPadding",
189 (float*)&style.SeparatorTextPadding, 0.0f, 40.0f,
190 "%.0f");
191 ImGui::SliderFloat("LogSliderDeadzone", &style.LogSliderDeadzone, 0.0f,
192 12.0f, "%.0f");
193
194 ImGui::SeparatorText("Tooltips");
195 for (int n = 0; n < 2; n++)
196 if (ImGui::TreeNodeEx(n == 0 ? "HoverFlagsForTooltipMouse"
197 : "HoverFlagsForTooltipNav")) {
198 ImGuiHoveredFlags* p = (n == 0) ? &style.HoverFlagsForTooltipMouse
199 : &style.HoverFlagsForTooltipNav;
200 ImGui::CheckboxFlags("ImGuiHoveredFlags_DelayNone", p,
201 ImGuiHoveredFlags_DelayNone);
202 ImGui::CheckboxFlags("ImGuiHoveredFlags_DelayShort", p,
203 ImGuiHoveredFlags_DelayShort);
204 ImGui::CheckboxFlags("ImGuiHoveredFlags_DelayNormal", p,
205 ImGuiHoveredFlags_DelayNormal);
206 ImGui::CheckboxFlags("ImGuiHoveredFlags_Stationary", p,
207 ImGuiHoveredFlags_Stationary);
208 ImGui::CheckboxFlags("ImGuiHoveredFlags_NoSharedDelay", p,
209 ImGuiHoveredFlags_NoSharedDelay);
210 ImGui::TreePop();
211 }
212
213 ImGui::SeparatorText("Misc");
214 ImGui::SliderFloat2("DisplaySafeAreaPadding",
215 (float*)&style.DisplaySafeAreaPadding, 0.0f, 30.0f,
216 "%.0f");
217 ImGui::SameLine();
218
219 ImGui::EndTabItem();
220 }
221
222 if (ImGui::BeginTabItem("Colors")) {
223 static int output_dest = 0;
224 static bool output_only_modified = true;
225 if (ImGui::Button("Export")) {
226 if (output_dest == 0)
227 ImGui::LogToClipboard();
228 else
229 ImGui::LogToTTY();
230 ImGui::LogText("ImVec4* colors = ImGui::GetStyle().Colors;" IM_NEWLINE);
231 for (int i = 0; i < ImGuiCol_COUNT; i++) {
232 const ImVec4& col = style.Colors[i];
233 const char* name = ImGui::GetStyleColorName(i);
234 if (!output_only_modified ||
235 memcmp(&col, &ref->Colors[i], sizeof(ImVec4)) != 0)
236 ImGui::LogText(
237 "colors[ImGuiCol_%s]%*s= ImVec4(%.2ff, %.2ff, %.2ff, "
238 "%.2ff);" IM_NEWLINE,
239 name, 23 - (int)strlen(name), "", col.x, col.y, col.z, col.w);
240 }
241 ImGui::LogFinish();
242 }
243 ImGui::SameLine();
244 ImGui::SetNextItemWidth(120);
245 ImGui::Combo("##output_type", &output_dest, "To Clipboard\0To TTY\0");
246 ImGui::SameLine();
247 ImGui::Checkbox("Only Modified Colors", &output_only_modified);
248
249 static ImGuiTextFilter filter;
250 filter.Draw("Filter colors", ImGui::GetFontSize() * 16);
251
252 static ImGuiColorEditFlags alpha_flags = 0;
253 if (ImGui::RadioButton("Opaque",
254 alpha_flags == ImGuiColorEditFlags_None)) {
255 alpha_flags = ImGuiColorEditFlags_None;
256 }
257 ImGui::SameLine();
258 if (ImGui::RadioButton("Alpha",
259 alpha_flags == ImGuiColorEditFlags_AlphaPreview)) {
260 alpha_flags = ImGuiColorEditFlags_AlphaPreview;
261 }
262 ImGui::SameLine();
263 if (ImGui::RadioButton(
264 "Both", alpha_flags == ImGuiColorEditFlags_AlphaPreviewHalf)) {
265 alpha_flags = ImGuiColorEditFlags_AlphaPreviewHalf;
266 }
267 ImGui::SameLine();
268
269 ImGui::SetNextWindowSizeConstraints(
270 ImVec2(0.0f, ImGui::GetTextLineHeightWithSpacing() * 10),
271 ImVec2(FLT_MAX, FLT_MAX));
272 ImGui::BeginChild("##colors", ImVec2(0, 0), ImGuiChildFlags_Border,
273 ImGuiWindowFlags_AlwaysVerticalScrollbar |
274 ImGuiWindowFlags_AlwaysHorizontalScrollbar |
275 ImGuiWindowFlags_NavFlattened);
276 ImGui::PushItemWidth(ImGui::GetFontSize() * -12);
277 for (int i = 0; i < ImGuiCol_COUNT; i++) {
278 const char* name = ImGui::GetStyleColorName(i);
279 if (!filter.PassFilter(name)) continue;
280 ImGui::PushID(i);
281 ImGui::ColorEdit4("##color", (float*)&style.Colors[i],
282 ImGuiColorEditFlags_AlphaBar | alpha_flags);
283 if (memcmp(&style.Colors[i], &ref->Colors[i], sizeof(ImVec4)) != 0) {
284 // Tips: in a real user application, you may want to merge and use
285 // an icon font into the main font, so instead of "Save"/"Revert"
286 // you'd use icons! Read the FAQ and docs/FONTS.md about using icon
287 // fonts. It's really easy and super convenient!
288 ImGui::SameLine(0.0f, style.ItemInnerSpacing.x);
289 if (ImGui::Button("Save")) {
290 ref->Colors[i] = style.Colors[i];
291 }
292 ImGui::SameLine(0.0f, style.ItemInnerSpacing.x);
293 if (ImGui::Button("Revert")) {
294 style.Colors[i] = ref->Colors[i];
295 }
296 }
297 ImGui::SameLine(0.0f, style.ItemInnerSpacing.x);
298 ImGui::TextUnformatted(name);
299 ImGui::PopID();
300 }
301 ImGui::PopItemWidth();
302 ImGui::EndChild();
303
304 ImGui::EndTabItem();
305 }
306
307 if (ImGui::BeginTabItem("Fonts")) {
308 ImGuiIO& io = ImGui::GetIO();
309 ImFontAtlas* atlas = io.Fonts;
310 ImGui::ShowFontAtlas(atlas);
311
312 // Post-baking font scaling. Note that this is NOT the nice way of
313 // scaling fonts, read below. (we enforce hard clamping manually as by
314 // default DragFloat/SliderFloat allows CTRL+Click text to get out of
315 // bounds).
316 const float MIN_SCALE = 0.3f;
317 const float MAX_SCALE = 2.0f;
318
319 static float window_scale = 1.0f;
320 ImGui::PushItemWidth(ImGui::GetFontSize() * 8);
321 if (ImGui::DragFloat(
322 "window scale", &window_scale, 0.005f, MIN_SCALE, MAX_SCALE,
323 "%.2f",
324 ImGuiSliderFlags_AlwaysClamp)) // Scale only this window
325 ImGui::SetWindowFontScale(window_scale);
326 ImGui::DragFloat("global scale", &io.FontGlobalScale, 0.005f, MIN_SCALE,
327 MAX_SCALE, "%.2f",
328 ImGuiSliderFlags_AlwaysClamp); // Scale everything
329 ImGui::PopItemWidth();
330
331 ImGui::EndTabItem();
332 }
333
334 if (ImGui::BeginTabItem("Rendering")) {
335 ImGui::Checkbox("Anti-aliased lines", &style.AntiAliasedLines);
336 ImGui::SameLine();
337
338 ImGui::Checkbox("Anti-aliased lines use texture",
339 &style.AntiAliasedLinesUseTex);
340 ImGui::SameLine();
341
342 ImGui::Checkbox("Anti-aliased fill", &style.AntiAliasedFill);
343 ImGui::PushItemWidth(ImGui::GetFontSize() * 8);
344 ImGui::DragFloat("Curve Tessellation Tolerance",
345 &style.CurveTessellationTol, 0.02f, 0.10f, 10.0f,
346 "%.2f");
347 if (style.CurveTessellationTol < 0.10f)
348 style.CurveTessellationTol = 0.10f;
349
350 // When editing the "Circle Segment Max Error" value, draw a preview of
351 // its effect on auto-tessellated circles.
352 ImGui::DragFloat("Circle Tessellation Max Error",
353 &style.CircleTessellationMaxError, 0.005f, 0.10f, 5.0f,
354 "%.2f", ImGuiSliderFlags_AlwaysClamp);
355 const bool show_samples = ImGui::IsItemActive();
356 if (show_samples) ImGui::SetNextWindowPos(ImGui::GetCursorScreenPos());
357 if (show_samples && ImGui::BeginTooltip()) {
358 ImGui::TextUnformatted("(R = radius, N = number of segments)");
359 ImGui::Spacing();
360 ImDrawList* draw_list = ImGui::GetWindowDrawList();
361 const float min_widget_width = ImGui::CalcTextSize("N: MMM\nR: MMM").x;
362 for (int n = 0; n < 8; n++) {
363 const float RAD_MIN = 5.0f;
364 const float RAD_MAX = 70.0f;
365 const float rad =
366 RAD_MIN + (RAD_MAX - RAD_MIN) * (float)n / (8.0f - 1.0f);
367
368 ImGui::BeginGroup();
369
370 ImGui::Text("R: %.f\nN: %d", rad,
371 draw_list->_CalcCircleAutoSegmentCount(rad));
372
373 const float canvas_width = std::max(min_widget_width, rad * 2.0f);
374 const float offset_x = floorf(canvas_width * 0.5f);
375 const float offset_y = floorf(RAD_MAX);
376
377 const ImVec2 p1 = ImGui::GetCursorScreenPos();
378 draw_list->AddCircle(ImVec2(p1.x + offset_x, p1.y + offset_y), rad,
379 ImGui::GetColorU32(ImGuiCol_Text));
380 ImGui::Dummy(ImVec2(canvas_width, RAD_MAX * 2));
381
382 /*
383 const ImVec2 p2 = ImGui::GetCursorScreenPos();
384 draw_list->AddCircleFilled(ImVec2(p2.x + offset_x, p2.y + offset_y),
385 rad, ImGui::GetColorU32(ImGuiCol_Text));
386 ImGui::Dummy(ImVec2(canvas_width, RAD_MAX * 2));
387 */
388
389 ImGui::EndGroup();
390 ImGui::SameLine();
391 }
392 ImGui::EndTooltip();
393 }
394 ImGui::SameLine();
395
396 ImGui::DragFloat("Global Alpha", &style.Alpha, 0.005f, 0.20f, 1.0f,
397 "%.2f"); // Not exposing zero here so user doesn't
398 // "lose" the UI (zero alpha clips all
399 // widgets). But application code could have a
400 // toggle to switch between zero and non-zero.
401 ImGui::DragFloat("Disabled Alpha", &style.DisabledAlpha, 0.005f, 0.0f,
402 1.0f, "%.2f");
403 ImGui::SameLine();
404
405 ImGui::PopItemWidth();
406
407 ImGui::EndTabItem();
408 }
409
410 ImGui::EndTabBar();
411 }
412
413 ImGui::PopItemWidth();
414}
415
416void TextWithSeparators(const absl::string_view& text) {
417 ImGui::Separator();
418 ImGui::Text("%s", text.data());
419 ImGui::Separator();
420}
421
422// TODO: Make the ColorsYaze style into a configuration file.
424 ImGuiStyle* style = &ImGui::GetStyle();
425 ImVec4* colors = style->Colors;
426
427 style->WindowPadding = ImVec2(10.f, 10.f);
428 style->FramePadding = ImVec2(10.f, 2.f);
429 style->CellPadding = ImVec2(4.f, 5.f);
430 style->ItemSpacing = ImVec2(10.f, 5.f);
431 style->ItemInnerSpacing = ImVec2(5.f, 5.f);
432 style->TouchExtraPadding = ImVec2(0.f, 0.f);
433 style->IndentSpacing = 20.f;
434 style->ScrollbarSize = 14.f;
435 style->GrabMinSize = 15.f;
436
437 style->WindowBorderSize = 0.f;
438 style->ChildBorderSize = 1.f;
439 style->PopupBorderSize = 1.f;
440 style->FrameBorderSize = 0.f;
441 style->TabBorderSize = 0.f;
442
443 style->WindowRounding = 0.f;
444 style->ChildRounding = 0.f;
445 style->FrameRounding = 5.f;
446 style->PopupRounding = 0.f;
447 style->ScrollbarRounding = 5.f;
448
449 auto alttpDarkGreen = ImVec4(0.18f, 0.26f, 0.18f, 1.0f);
450 auto alttpMidGreen = ImVec4(0.28f, 0.36f, 0.28f, 1.0f);
451 auto allttpLightGreen = ImVec4(0.36f, 0.45f, 0.36f, 1.0f);
452 auto allttpLightestGreen = ImVec4(0.49f, 0.57f, 0.49f, 1.0f);
453
454 colors[ImGuiCol_MenuBarBg] = alttpDarkGreen;
455 colors[ImGuiCol_TitleBg] = alttpMidGreen;
456
457 colors[ImGuiCol_Header] = alttpDarkGreen;
458 colors[ImGuiCol_HeaderHovered] = allttpLightGreen;
459 colors[ImGuiCol_HeaderActive] = alttpMidGreen;
460
461 colors[ImGuiCol_TitleBgActive] = alttpDarkGreen;
462 colors[ImGuiCol_TitleBgCollapsed] = alttpMidGreen;
463
464 colors[ImGuiCol_Tab] = alttpDarkGreen;
465 colors[ImGuiCol_TabHovered] = alttpMidGreen;
466 colors[ImGuiCol_TabActive] = ImVec4(0.347f, 0.466f, 0.347f, 1.000f);
467
468 colors[ImGuiCol_Button] = alttpMidGreen;
469 colors[ImGuiCol_ButtonHovered] = allttpLightestGreen;
470 colors[ImGuiCol_ButtonActive] = allttpLightGreen;
471
472 colors[ImGuiCol_ScrollbarBg] = ImVec4(0.36f, 0.45f, 0.36f, 0.60f);
473 colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.36f, 0.45f, 0.36f, 0.30f);
474 colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.36f, 0.45f, 0.36f, 0.40f);
475 colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.36f, 0.45f, 0.36f, 0.60f);
476
477 colors[ImGuiCol_Text] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f);
478 colors[ImGuiCol_TextDisabled] = ImVec4(0.60f, 0.60f, 0.60f, 1.00f);
479 colors[ImGuiCol_WindowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.85f);
480 colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
481 colors[ImGuiCol_PopupBg] = ImVec4(0.11f, 0.11f, 0.14f, 0.92f);
482 colors[ImGuiCol_Border] = allttpLightGreen;
483 colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
484
485 colors[ImGuiCol_FrameBg] = ImVec4(0.43f, 0.43f, 0.43f, 0.39f);
486 colors[ImGuiCol_FrameBgHovered] = ImVec4(0.28f, 0.36f, 0.28f, 0.40f);
487 colors[ImGuiCol_FrameBgActive] = ImVec4(0.28f, 0.36f, 0.28f, 0.69f);
488
489 colors[ImGuiCol_CheckMark] = ImVec4(0.90f, 0.90f, 0.90f, 0.50f);
490 colors[ImGuiCol_SliderGrab] = ImVec4(1.00f, 1.00f, 1.00f, 0.30f);
491 colors[ImGuiCol_SliderGrabActive] = ImVec4(0.36f, 0.45f, 0.36f, 0.60f);
492
493 colors[ImGuiCol_Separator] = ImVec4(0.50f, 0.50f, 0.50f, 0.60f);
494 colors[ImGuiCol_SeparatorHovered] = ImVec4(0.60f, 0.60f, 0.70f, 1.00f);
495 colors[ImGuiCol_SeparatorActive] = ImVec4(0.70f, 0.70f, 0.90f, 1.00f);
496 colors[ImGuiCol_ResizeGrip] = ImVec4(1.00f, 1.00f, 1.00f, 0.10f);
497 colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.78f, 0.82f, 1.00f, 0.60f);
498 colors[ImGuiCol_ResizeGripActive] = ImVec4(0.78f, 0.82f, 1.00f, 0.90f);
499
500 colors[ImGuiCol_TabUnfocused] =
501 ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f);
502 colors[ImGuiCol_TabUnfocusedActive] =
503 ImLerp(colors[ImGuiCol_TabActive], colors[ImGuiCol_TitleBg], 0.40f);
504 colors[ImGuiCol_PlotLines] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
505 colors[ImGuiCol_PlotLinesHovered] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
506 colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
507 colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f);
508 colors[ImGuiCol_TableHeaderBg] = alttpDarkGreen;
509 colors[ImGuiCol_TableBorderStrong] = alttpMidGreen;
510 colors[ImGuiCol_TableBorderLight] =
511 ImVec4(0.26f, 0.26f, 0.28f, 1.00f); // Prefer using Alpha=1.0 here
512 colors[ImGuiCol_TableRowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
513 colors[ImGuiCol_TableRowBgAlt] = ImVec4(1.00f, 1.00f, 1.00f, 0.07f);
514 colors[ImGuiCol_TextSelectedBg] = ImVec4(0.00f, 0.00f, 1.00f, 0.35f);
515 colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f);
516 colors[ImGuiCol_NavHighlight] = colors[ImGuiCol_HeaderHovered];
517 colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f);
518 colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f);
519 colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.35f);
520}
521
522// ============================================================================
523// 65816 LanguageDefinition
524// ============================================================================
525
526static const char* const kKeywords[] = {
527 "ADC", "AND", "ASL", "BCC", "BCS", "BEQ", "BIT", "BMI", "BNE",
528 "BPL", "BRA", "BRL", "BVC", "BVS", "CLC", "CLD", "CLI", "CLV",
529 "CMP", "CPX", "CPY", "DEC", "DEX", "DEY", "EOR", "INC", "INX",
530 "INY", "JMP", "JSR", "JSL", "LDA", "LDX", "LDY", "LSR", "MVN",
531 "NOP", "ORA", "PEA", "PER", "PHA", "PHB", "PHD", "PHP", "PHX",
532 "PHY", "PLA", "PLB", "PLD", "PLP", "PLX", "PLY", "REP", "ROL",
533 "ROR", "RTI", "RTL", "RTS", "SBC", "SEC", "SEI", "SEP", "STA",
534 "STP", "STX", "STY", "STZ", "TAX", "TAY", "TCD", "TCS", "TDC",
535 "TRB", "TSB", "TSC", "TSX", "TXA", "TXS", "TXY", "TYA", "TYX",
536 "WAI", "WDM", "XBA", "XCE", "ORG", "LOROM", "HIROM", "NAMESPACE", "DB"};
537
538static const char* const kIdentifiers[] = {
539 "abort", "abs", "acos", "asin", "atan", "atexit",
540 "atof", "atoi", "atol", "ceil", "clock", "cosh",
541 "ctime", "div", "exit", "fabs", "floor", "fmod",
542 "getchar", "getenv", "isalnum", "isalpha", "isdigit", "isgraph",
543 "ispunct", "isspace", "isupper", "kbhit", "log10", "log2",
544 "log", "memcmp", "modf", "pow", "putchar", "putenv",
545 "puts", "rand", "remove", "rename", "sinh", "sqrt",
546 "srand", "strcat", "strcmp", "strerror", "time", "tolower",
547 "toupper"};
548
549TextEditor::LanguageDefinition GetAssemblyLanguageDef() {
550 TextEditor::LanguageDefinition language_65816;
551 for (auto& k : kKeywords) language_65816.mKeywords.emplace(k);
552
553 for (auto& k : kIdentifiers) {
554 TextEditor::Identifier id;
555 id.mDeclaration = "Built-in function";
556 language_65816.mIdentifiers.insert(std::make_pair(std::string(k), id));
557 }
558
559 language_65816.mTokenRegexStrings.push_back(
560 std::make_pair<std::string, TextEditor::PaletteIndex>(
561 "[ \\t]*#[ \\t]*[a-zA-Z_]+", TextEditor::PaletteIndex::Preprocessor));
562 language_65816.mTokenRegexStrings.push_back(
563 std::make_pair<std::string, TextEditor::PaletteIndex>(
564 "L?\\\"(\\\\.|[^\\\"])*\\\"", TextEditor::PaletteIndex::String));
565 language_65816.mTokenRegexStrings.push_back(
566 std::make_pair<std::string, TextEditor::PaletteIndex>(
567 "\\'\\\\?[^\\']\\'", TextEditor::PaletteIndex::CharLiteral));
568 language_65816.mTokenRegexStrings.push_back(
569 std::make_pair<std::string, TextEditor::PaletteIndex>(
570 "[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)([eE][+-]?[0-9]+)?[fF]?",
571 TextEditor::PaletteIndex::Number));
572 language_65816.mTokenRegexStrings.push_back(
573 std::make_pair<std::string, TextEditor::PaletteIndex>(
574 "[+-]?[0-9]+[Uu]?[lL]?[lL]?", TextEditor::PaletteIndex::Number));
575 language_65816.mTokenRegexStrings.push_back(
576 std::make_pair<std::string, TextEditor::PaletteIndex>(
577 "0[0-7]+[Uu]?[lL]?[lL]?", TextEditor::PaletteIndex::Number));
578 language_65816.mTokenRegexStrings.push_back(
579 std::make_pair<std::string, TextEditor::PaletteIndex>(
580 "0[xX][0-9a-fA-F]+[uU]?[lL]?[lL]?",
581 TextEditor::PaletteIndex::Number));
582 language_65816.mTokenRegexStrings.push_back(
583 std::make_pair<std::string, TextEditor::PaletteIndex>(
584 "[a-zA-Z_][a-zA-Z0-9_]*", TextEditor::PaletteIndex::Identifier));
585 language_65816.mTokenRegexStrings.push_back(
586 std::make_pair<std::string, TextEditor::PaletteIndex>(
587 "[\\[\\]\\{\\}\\!\\%\\^\\&\\*\\(\\)\\-\\+\\=\\~\\|\\<\\>\\?\\/"
588 "\\;\\,\\.]",
589 TextEditor::PaletteIndex::Punctuation));
590
591 language_65816.mCommentStart = "/*";
592 language_65816.mCommentEnd = "*/";
593 language_65816.mSingleLineComment = ";";
594
595 language_65816.mCaseSensitive = false;
596 language_65816.mAutoIndentation = true;
597
598 language_65816.mName = "65816";
599
600 return language_65816;
601}
602
603} // namespace gui
604} // namespace app
605} // namespace yaze
void DrawDisplaySettings(ImGuiStyle *ref)
Definition style.cc:60
TextEditor::LanguageDefinition GetAssemblyLanguageDef()
Definition style.cc:549
void EndPadding()
Definition style.cc:40
void BeginChildWithScrollbar(const char *str_id)
Definition style.cc:48
void BeginPadding(int i)
Definition style.cc:36
void BeginWindowWithDisplaySettings(const char *id, bool *active, const ImVec2 &size, ImGuiWindowFlags flags)
Definition style.cc:11
void BeginChildBothScrollbars(int id)
Definition style.cc:53
void ColorsYaze()
Definition style.cc:423
void EndNoPadding()
Definition style.cc:46
void TextWithSeparators(const absl::string_view &text)
Definition style.cc:416
void BeginNoPadding()
Definition style.cc:42
void EndWindowWithDisplaySettings()
Definition style.cc:31
Definition common.cc:21