fix(GUI): fix some widget alignments and font scaling issues #429
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Was supposed to only fix the watches tab, but I guess other parts of the GUI needed some tiny bits of attention too.
Fixes general alignment issues in the Console, Live View, and Watches tabs.
ImGui::GetContentRegionAvail
instead ofGetContentRegionMaxAbs
, works with scaling.Changes specific to the Live View tab
ImGui::GetFrameHeight
), so it'll just expand as 50%/50% when bringing the window back to normal size. Probably also fixes the times I get extremely thin panels, and the splitter going beyond the unreachable.Changes specific to the Watches tab
ImGuiTableFlags_NoPadOuterX
flag because it makes widgets touch the table borders.ImGui::Selectable
, as it's much simpler to use (it's a struggle to align text in a tiny button). Also used font icons for+
and-
.my buton tex no senter :(
ImGui::GetTextLineHeight
times 10 lines high to account for font scaling, instead of a fixed 200px.Fixes #420
Note
These changes were tested on Windows 10, 100% system DPI scaling, default title bar height of
31
. (Why the latter matters, I'll elaborate later at the bottom).Probably need to check if behavior changes on Windows 11 or other environments with a different window manager (Linux?), although I don't currently have access to either.
Type of change
How has this been tested?
Have GUI console enabled, and check the Console, Live View, and Watches tabs. Add two watches from any random properties. Tests done on font scale factors 2.0, 1.0, 0.4.
Checklist
Screenshots
Before/After
0.4 scale
1.0 scale
2.0 scale
Screen recording of Watches tab and Live View splitter resizing.
Warning: some flashing.
lyr_080324_J3tlcaHSxh.mp4
Notes
What do the numbers mean?
You'll often find
31
used throughout the sizes. This is Windows 10's default native title bar height (for me, at least).For some reason ImGui does not reduce its own viewport height to compensate for the native title bar. So for example my entire window's height is 793px, border to border. The ImGui viewport height (inside the window, excluding the border and title bar) will still be 793px high, but the actual visible area is only
793px - 31px = 762px
, as if the entire ImGui viewport is shifted down and the bottom 31 pixels get hidden beyond the window border.As for the numbers,
TextEditor
,watch_render_frame
-16.0f
=-8
left window margin +-8
right window margin-31.0f + -8.0f
=-31
title bar offset +-8
bottom window marginLiveView_InfoPanel
,ImGui_Splitter
,LiveView_TreeView
:-16.0f
=-8
left window margin +-8
right window margin##Search by name
viaImGui::PushItemWidth
8.0f
= spacing between text box on the left and the button on the right16.0f
=8
left window margin +8
right window marginFramePadding.x * 2.0f
= button inside padding, left and rightImGui::CalcTextSize
= text widthsplit_pane_height
ImGui::GetContentRegionAvail().y
= remaining space from current pos to bottom of ImGui viewport (beyond the window)-31.0f + -8.0f
=-31
title bar offset +-8
bottom window margin-4.0f
= height of splitter barControls
columnImGui::GetFrameHeight * 3.0f
= three square controls4.0f
= 2.0f px spacers between controls, x2Save
column:ImGui::GetFrameHeight
= one square control##history
textbox-2.0f
= right margin from column right edgeImGui::GetTextLineHeight() * 10.0f
10 text lines +ImGui::GetStyle().FramePadding.y * 2.0f
top and bottom paddingNote
Currently, the pull requests makes an assumption that the title bar-caused offset will always be 31. On the unfortunate case that the title bar is seen as less than 31px high, or even zero (on Linux maybe), the most severe effect should only be padding appearing on the bottom. This is only my assumption though, I likely don't know of edge cases where ImGui behaves in a weirder way regarding this in more specific environments.
p.s.
Pardon the overly detailed post for this small PR. Was bored and felt like doing a semi-technical document lol