Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Center CheatSheet vertically #1985

Merged
merged 44 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
d882192
application: Center cheatsheet vertically
Ni-g-3l Feb 13, 2025
5c41137
application: Center CheatSheet around text
Ni-g-3l Feb 15, 2025
cc30a1e
application: ensure clang format
Ni-g-3l Feb 15, 2025
c669192
application: remove trailing whitespace
Ni-g-3l Feb 15, 2025
f1ed71f
application: Remove useless line
Ni-g-3l Feb 17, 2025
5873ee7
tests: update interaction cheatsheet baselines
Ni-g-3l Feb 17, 2025
3e0acfd
Merge branch 'master' into fix-center-cheatsheet
Ni-g-3l Feb 17, 2025
cfdbec0
application: Center cheatsheet vertically
Ni-g-3l Feb 13, 2025
7cbf2b0
application: Center CheatSheet around text
Ni-g-3l Feb 15, 2025
72446bb
application: ensure clang format
Ni-g-3l Feb 15, 2025
933f48c
application: remove trailing whitespace
Ni-g-3l Feb 15, 2025
e8ebff6
application: Remove useless line
Ni-g-3l Feb 17, 2025
babedd9
tests: update interaction cheatsheet baselines
Ni-g-3l Feb 17, 2025
69607ec
Merge branch 'fix-center-cheatsheet' of github.com:Ni-g-3l/f3d into f…
Ni-g-3l Feb 18, 2025
91785cd
application: Use SeparatorTextPadding to get right height of cheatsheet
Ni-g-3l Feb 18, 2025
d202993
baselines: Update Centered CheatSheet baselines
Ni-g-3l Feb 18, 2025
85e000e
Merge branch 'master' into fix-center-cheatsheet
Ni-g-3l Feb 18, 2025
73aa2b5
baselines: Update baseline with marginTop
Ni-g-3l Feb 18, 2025
3f0491c
application: format ImGUI actor
Ni-g-3l Feb 18, 2025
3ad0137
application: Center cheatsheet vertically
Ni-g-3l Feb 13, 2025
baa0cdc
application: Center CheatSheet around text
Ni-g-3l Feb 15, 2025
7d9da1a
application: ensure clang format
Ni-g-3l Feb 15, 2025
91fe33b
application: remove trailing whitespace
Ni-g-3l Feb 15, 2025
ad03ab2
application: Remove useless line
Ni-g-3l Feb 17, 2025
3cafd01
tests: update interaction cheatsheet baselines
Ni-g-3l Feb 17, 2025
6486607
application: Center cheatsheet vertically
Ni-g-3l Feb 13, 2025
00c8b8a
application: Center CheatSheet around text
Ni-g-3l Feb 15, 2025
058de65
application: ensure clang format
Ni-g-3l Feb 15, 2025
bffd405
application: remove trailing whitespace
Ni-g-3l Feb 15, 2025
c8f84b4
application: Remove useless line
Ni-g-3l Feb 17, 2025
4b3581b
application: Use SeparatorTextPadding to get right height of cheatsheet
Ni-g-3l Feb 18, 2025
2095c36
baselines: Update Centered CheatSheet baselines
Ni-g-3l Feb 18, 2025
bd1f0bf
baselines: Update baseline with marginTop
Ni-g-3l Feb 18, 2025
fbe1656
application: format ImGUI actor
Ni-g-3l Feb 18, 2025
99e0ae3
Merge branch 'fix-center-cheatsheet' of github.com:Ni-g-3l/f3d into f…
Ni-g-3l Feb 19, 2025
2c56281
baselines: Revert all baselines changes
Ni-g-3l Feb 22, 2025
6911771
baselines: Update Cheatsheet baselines
Ni-g-3l Feb 22, 2025
5358eb4
application: Add margin top and botton to cheatsheet
Ni-g-3l Feb 22, 2025
10334c6
baselines: Update cheatsheet baseline with margin bottom
Ni-g-3l Feb 22, 2025
29cb354
application: Make cheatsheet winTop margin const
Ni-g-3l Feb 23, 2025
baf4365
test: Add test to ensure Cheatsheet is always centered
Ni-g-3l Feb 23, 2025
01d8b26
applications: Remove useless padding adding on cheatsheet text height
Ni-g-3l Feb 24, 2025
8d85a0d
test: Add centered cheatsheet test only when raytracing is disabled
Ni-g-3l Feb 24, 2025
68f5b53
applications: Restore missing textHeight on CheatSheet pre render com…
Ni-g-3l Feb 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions application/testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ f3d_test(NAME TestInteractionSimpleExit DATA cow.vtp REGEXP "Interactor has been
# Cheatsheet test with minimal resolution to avoid repeated change of baselines
f3d_test(NAME TestInteractionCheatsheetWhiteBG DATA cow.vtp ARGS --background-color=1,1,1 INTERACTION UI) #H
f3d_test(NAME TestInteractionCheatsheetBlackBG DATA cow.vtp ARGS --background-color=0,0,0 INTERACTION UI) #H
f3d_test(NAME TestInteractionCheatsheetCentered DATA cow.vtp ARGS --resolution=500,1500 INTERACTION UI LONG_TIMEOUT) #H
f3d_test(NAME TestInteractionCheatsheetNoFile INTERACTION UI NO_DATA_FORCE_RENDER) #HXM
f3d_test(NAME TestInteractionCheatsheetScalars DATA dragon.vtu ARGS --scalar-coloring --coloring-component=-2 INTERACTION UI LONG_TIMEOUT) #HSSS
f3d_test(NAME TestInteractionCheatsheetOpacity DATA cow.vtp INTERACTION UI ARGS --opacity=0.5 RESOLUTION 300,700) #H;ScrollDown
Expand Down
4 changes: 2 additions & 2 deletions testing/baselines/TestInteractionCheatsheetAnimationName.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions testing/baselines/TestInteractionCheatsheetBlackBG.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions testing/baselines/TestInteractionCheatsheetCentered.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions testing/baselines/TestInteractionCheatsheetConfigFile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions testing/baselines/TestInteractionCheatsheetNoFile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions testing/baselines/TestInteractionCheatsheetOpacity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions testing/baselines/TestInteractionCheatsheetScalars.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions testing/baselines/TestInteractionCheatsheetWhiteBG.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions testing/recordings/TestInteractionCheatsheetCentered.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# StreamVersion 1.1
ExposeEvent 0 599 0 0 0 0
RenderEvent 0 599 0 0 0 0
KeyPressEvent 738 539 0 104 1 h
CharEvent 738 539 0 104 1 h
KeyReleaseEvent 738 539 0 104 1 h
14 changes: 12 additions & 2 deletions vtkext/private/module/vtkF3DImguiActor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,13 @@ void vtkF3DImguiActor::RenderCheatSheet()
constexpr float marginLeft = 5.f;
constexpr float marginTopBottom = 5.f;

float textHeight = 0.f;
float winWidth = 0.f;

for (const auto& [group, content] : this->CheatSheet)
{
textHeight +=
ImGui::GetTextLineHeightWithSpacing() + 2 * ImGui::GetStyle().SeparatorTextPadding.y;
for (const auto& [bind, desc, val] : content)
{
std::string line = bind;
Expand All @@ -359,12 +363,18 @@ void vtkF3DImguiActor::RenderCheatSheet()
ImVec2 currentLine = ImGui::CalcTextSize(line.c_str());

winWidth = std::max(winWidth, currentLine.x);
textHeight += ImGui::GetTextLineHeightWithSpacing();
;
}
}

winWidth += 2.f * ImGui::GetStyle().WindowPadding.x + ImGui::GetStyle().ScrollbarSize;
textHeight += 2.f * ImGui::GetStyle().WindowPadding.y;

const float winTop = std::max(marginTopBottom, (viewport->WorkSize.y - textHeight) * 0.5f);

::SetupNextWindow(ImVec2(marginLeft, marginTopBottom),
ImVec2(winWidth, viewport->WorkSize.y - 2.f * marginTopBottom));
::SetupNextWindow(ImVec2(marginLeft, winTop),
ImVec2(winWidth, std::min(viewport->WorkSize.y - (2 * marginTopBottom), textHeight)));
ImGui::SetNextWindowBgAlpha(0.35f);

ImGuiWindowFlags flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize |
Expand Down
Loading