summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2025-09-26 11:05:45 -0400
committerJonathan Bradley <jcb@pikum.xyz>2025-09-26 11:05:45 -0400
commit651d4535b0c3eaada0367b35ea666b2d3324b71a (patch)
tree3e897f4d0b33b2b7750b89e7d10d243ca86ef019 /editor
parent92fc34a739cd4375b593afcd81bc3db114420c6d (diff)
pke-editor: factor FontRenderSettings for re-use
Diffstat (limited to 'editor')
-rw-r--r--editor/editor.cpp33
1 files changed, 29 insertions, 4 deletions
diff --git a/editor/editor.cpp b/editor/editor.cpp
index 12bc9d0..2476f40 100644
--- a/editor/editor.cpp
+++ b/editor/editor.cpp
@@ -498,6 +498,33 @@ void PkeEditor_Tick(double delta) {
}
}
+bool RecordImGui_FontRenderSettings(FontRenderSettings &frs, bool allow_surface_area_edit) {
+ bool changed = false;
+
+ unsigned int flags = FONT_RENDER_SURFACE_AREA_TYPE_FLAG_T(frs.surface_area_type_flags);
+
+ changed = ImGui::ColorEdit4("color_foreground(txt)", &frs.color_foreground[0]) || changed;
+ changed = ImGui::ColorEdit4("color_background(txt)", &frs.color_background[0]) || changed;
+
+ changed = ImGui::DragFloat("char_scale", &frs.char_scale, 0.25, 0.0, 128.0) || changed;
+ changed = ImGui::DragFloat("line_height_scale", &frs.line_height_scale, 0.25, 0.0, 128.0) || changed;
+ changed = ImGui::DragFloat("char_spacing_scale", &frs.char_spacing_scale, 0.25, 0.0, 128.0) || changed;
+
+ if (allow_surface_area_edit) {
+ changed = ImGui::DragInt2("surface_area_size", &frs.surface_area_size[0], 1, 0, 4096) || changed;
+ changed = ImGui::DragInt2("surface_area_pos", &frs.surface_area_size[0], 1, 0, 4096) || changed;
+ }
+
+ changed = ImGui::CheckboxFlags("Text Center Vertical", &flags, (unsigned int)FONT_RENDER_SURFACE_AREA_TYPE_FLAGS_CENTER_VERTICAL) || changed;
+ changed = ImGui::CheckboxFlags("Text Center Horizontal", &flags, (unsigned int)FONT_RENDER_SURFACE_AREA_TYPE_FLAGS_CENTER_HORIZONTAL) || changed;
+
+ if (changed) {
+ frs.surface_area_type_flags = FONT_RENDER_SURFACE_AREA_TYPE_FLAG(flags);
+ }
+
+ return changed;
+}
+
void RecordImGui_GLM(const char *label, glm::mat4 &mat) {
float min = -1;
float max = 1;
@@ -1500,8 +1527,7 @@ void RecordImGuiUIEdit() {
}
ImGui::SameLine();
ImGui::Text("(%.4zu/%4i)", len, buffer_len);
- changed_sub = ImGui::ColorEdit4("color_foreground(txt)", &fr.settings.color_foreground[0]) || changed_sub;
- changed_sub = ImGui::ColorEdit4("color_background(txt)", &fr.settings.color_background[0]) || changed_sub;
+ changed_sub = RecordImGui_FontRenderSettings(fr.settings, false);
if (changed_sub) {
FontType_UpdateStringRender(fr.fr_handle, &fr.settings);
}
@@ -1591,8 +1617,7 @@ void RecordImGuiUIEdit() {
}
ImGui::SameLine();
ImGui::Text("(%.4zu/%4i)", len, buffer_len);
- changed_sub = ImGui::ColorEdit4("color_foreground(txt)", &fr.settings.color_foreground[0]) || changed_sub;
- changed_sub = ImGui::ColorEdit4("color_background(txt)", &fr.settings.color_background[0]) || changed_sub;
+ changed_sub = RecordImGui_FontRenderSettings(fr.settings, false);
if (changed_sub) {
FontType_UpdateStringRender(fr.fr_handle, &fr.settings);
}