ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
59.71k stars 10.16k forks source link

`InputText` not scaling with `SetWindowFontScale` #6471

Open vulcan-dev opened 1 year ago

vulcan-dev commented 1 year ago

Version/Branch of Dear ImGui: Version: 1.83 Branch: master

Back-end/Renderer/Compiler/OS Back-ends: imgui_impl_dx11.cpp Compiler: MSVC Operating System: Windows

My Issue/Question: I've got a scale slider and everything scales besides InputText, I expected it to scale as I think that's how it should work.

Screenshots/Video Scale of 2: image I'm drawing it in a child window, hence the border. I expect InputText to fill that area.

Scale of 1: image

Standalone, minimal, complete and verifiable example:

ImGui::Begin("Example Bug");
ImGui::SetWindowFontScale(2);
ImGui::InputText("##input", buf, 256); // height will be the same no matter the scale
ImGui::End();
Romop5 commented 1 year ago

@vulcan-dev It turns out that SetWindowFontScale seems to be a deprecated function in master. It looks like it's no longer possible to adjust scale per-window.

The author also gives a tutorial in the code stating what you should do instead to achieve a scalable UI:

[OBSOLETE] set font scale. Adjust IO.FontGlobalScale if you want to scale all windows. This is an old API! For correct scaling, prefer to reload font + rebuild ImFontAtlas + call style.ScaleAllSizes().

See https://github.com/ocornut/imgui/blob/7e03ae32403f85f6c86f0c884a8243e2e14e483f/imgui.h#L372

vulcan-dev commented 1 year ago

@vulcan-dev It turns out that SetWindowFontScale seems to be a deprecated function in master. It looks like it's no longer possible to adjust scale per-window.

The author also gives a tutorial in the code stating what you should do instead to achieve a scalable UI:

[OBSOLETE] set font scale. Adjust IO.FontGlobalScale if you want to scale all windows. This is an old API! For correct scaling, prefer to reload font + rebuild ImFontAtlas + call style.ScaleAllSizes().

See

https://github.com/ocornut/imgui/blob/7e03ae32403f85f6c86f0c884a8243e2e14e483f/imgui.h#L372

Perfect, I'll try that out later when I have time. Thanks for the help