diff options
| author | Jonathan Bradley <jcb@pikum.xyz> | 2025-12-01 15:24:52 -0500 |
|---|---|---|
| committer | Jonathan Bradley <jcb@pikum.xyz> | 2025-12-01 15:24:52 -0500 |
| commit | 89b0e2f2133f9889d8ee51c29f34d16ddc1c4400 (patch) | |
| tree | 58f99b0f9788b408d88731beb489b7d7881986c9 | |
| parent | ac221b7a9629931b05c551225c3d65c75cff2f49 (diff) | |
pke-editor: add FontGlyphChar details table
| -rw-r--r-- | editor/editor-types.hpp | 5 | ||||
| -rw-r--r-- | editor/editor.cpp | 68 |
2 files changed, 73 insertions, 0 deletions
diff --git a/editor/editor-types.hpp b/editor/editor-types.hpp index f84b7d3..36c9fd1 100644 --- a/editor/editor-types.hpp +++ b/editor/editor-types.hpp @@ -1,6 +1,7 @@ #ifndef PKE_EDITOR_EDITOR_TYPES_HPP #define PKE_EDITOR_EDITOR_TYPES_HPP +#include "font.hpp" #include "scene-types.hpp" #include "pk.h" @@ -10,6 +11,10 @@ struct editor_master { pk_str target_scene_path = {}; bool shouldLoadScene = false; bool shouldSaveScene = false; + struct editor_master_runtime { + FontType *selected_font_type = nullptr; + bool show_font_glyphs = false; + } rt; }; extern struct editor_master editor_mstr; diff --git a/editor/editor.cpp b/editor/editor.cpp index 7245e22..d3363f6 100644 --- a/editor/editor.cpp +++ b/editor/editor.cpp @@ -1221,6 +1221,12 @@ void RecordImGuiFont() { ImGuiTableFlags_RowBg }; + ImGui::Text("Selected Font: %s", editor_mstr.rt.selected_font_type != nullptr ? editor_mstr.rt.selected_font_type->title.val : nullptr); + if (ImGui::Button("Clear")) { + editor_mstr.rt.selected_font_type = nullptr; + editor_mstr.rt.show_font_glyphs = false; + } + pk_bkt_arr_t<FontType> &fonts_base = *static_cast<pk_bkt_arr_t<FontType>*>(FontType_GetFonts()); if (ImGui::BeginTable("Font list", 3, tableFlags)) { @@ -1232,6 +1238,11 @@ void RecordImGuiFont() { while(b) { ImGui::TableNextRow(); ImGui::TableSetColumnIndex(0); + if (ImGui::Button("select")) { + editor_mstr.rt.selected_font_type = (FontType*)iter_ft.data; + editor_mstr.rt.show_font_glyphs = true; + } + ImGui::SameLine(); ImGui::Text("Title: %s", iter_ft->title.val); ImGui::TableSetColumnIndex(1); ImGui::Text("minimum_scale: %f", iter_ft->msdf_settings.minimum_scale); @@ -1251,6 +1262,60 @@ void RecordImGuiFont() { ImGui::End(); } +void RecordImGuiFontGlyphs() { + uint32_t u; + FontGlyphChar *fgc = nullptr; + if (!ImGui::Begin("FontGlyphs", &editor_mstr.rt.show_font_glyphs)) { + ImGui::End(); + return; + } + if (editor_mstr.rt.show_font_glyphs == false || editor_mstr.rt.selected_font_type == nullptr) { + editor_mstr.rt.selected_font_type = nullptr; + editor_mstr.rt.show_font_glyphs = false; + ImGui::End(); + return; + } + static ImGuiTableFlags tableFlags{ + ImGuiTableFlags_Borders | + ImGuiTableFlags_Resizable | + ImGuiTableFlags_RowBg + }; + + if (ImGui::BeginTable("Font list", 5, tableFlags)) { + ImGui::TableSetupColumn("unicode"); + ImGui::TableSetupColumn("advance"); + ImGui::TableSetupColumn("plane bounds"); + ImGui::TableSetupColumn("sprite region"); + ImGui::TableSetupColumn("flags"); + ImGui::TableHeadersRow(); + for (u = 0; u < editor_mstr.rt.selected_font_type->n_glyphs; ++u) { + fgc = &editor_mstr.rt.selected_font_type->glyphs[u]; + ImGui::TableNextRow(); + ImGui::TableSetColumnIndex(0); + ImGui::Text("%u", fgc->unicode); + ImGui::TableSetColumnIndex(1); + ImGui::Text("%f", fgc->advance); + ImGui::TableSetColumnIndex(2); + ImGui::Text("%f", fgc->plane_bounds.x); + ImGui::Text("%f", fgc->plane_bounds.y); + ImGui::Text("%f", fgc->plane_bounds.z); + ImGui::Text("%f", fgc->plane_bounds.w); + ImGui::TableSetColumnIndex(3); + ImGui::Text("min.x: %f", fgc->sprite_region_min.x); + ImGui::Text("min.y: %f", fgc->sprite_region_min.y); + ImGui::Text("max.x: %f", fgc->sprite_region_max.x); + ImGui::Text("max.y: %f", fgc->sprite_region_max.y); + ImGui::TableSetColumnIndex(4); + ImGui::Text("CONTROL: %i", PK_HAS_FLAG(fgc->flags, FONT_GLYPH_CHAR_FLAGS_CONTROL)); + ImGui::Text("WHITESPACE: %i", PK_HAS_FLAG(fgc->flags, FONT_GLYPH_CHAR_FLAGS_WHITESPACE)); + ImGui::Text("ALIGN_ADVANCE: %i", PK_HAS_FLAG(fgc->flags, FONT_GLYPH_CHAR_FLAGS_ALIGN_ADVANCE)); + ImGui::Text("NEW_LINE: %i", PK_HAS_FLAG(fgc->flags, FONT_GLYPH_CHAR_FLAGS_NEW_LINE)); + } + ImGui::EndTable(); + } + ImGui::End(); +} + void RecordImGuiCameras() { bool b; pk_bkt_arr *bkt_arr_cams; @@ -2292,6 +2357,9 @@ void PkeEditor_RecordImGui() { RecordImGuiAssets(); RecordImGuiPlayerInput(); RecordImGuiFont(); + if (editor_mstr.rt.show_font_glyphs) { + RecordImGuiFontGlyphs(); + } } } |
