diff --git a/cpp/apps/primitives_gallery/main.cpp b/cpp/apps/primitives_gallery/main.cpp index d2c513b0..c831e7d9 100644 --- a/cpp/apps/primitives_gallery/main.cpp +++ b/cpp/apps/primitives_gallery/main.cpp @@ -20,6 +20,7 @@ #include "demo.h" #include "capture.h" +#include #include #include #include @@ -154,6 +155,20 @@ static void render() { ImGui::BeginChild("##gallery_content", ImVec2(0, 0), ImGuiChildFlags_Borders, ImGuiWindowFlags_HorizontalScrollbar); + // Cuando cambia el tamaño de fuente (Settings > Size), el contenido + // del child crece/encoge pero la posicion de scroll en pixeles + // no — efecto: lo visible "se baja". Escalamos scroll_y por el + // ratio de fuentes para mantener la misma linea logica arriba. + { + static float s_prev_font_size = 0.0f; + float cur_font_size = ImGui::GetStyle().FontSizeBase; + if (s_prev_font_size > 0.0f && + std::fabs(s_prev_font_size - cur_font_size) > 0.01f) { + ImGui::SetScrollY(ImGui::GetScrollY() * + (cur_font_size / s_prev_font_size)); + } + s_prev_font_size = cur_font_size; + } const DemoEntry* d = find_demo(g_selected_id); if (d && d->fn) d->fn(); ImGui::EndChild();