Skip to content

Added UI Scaling support - #13

Merged
JohnGreenFC merged 7 commits into
mainfrom
PLAT-11971-Add-support-for-UI-scaling-to-CMF-Viewer
Sep 21, 2026
Merged

JohnGreenFC merged 7 commits into
mainfrom
PLAT-11971-Add-support-for-UI-scaling-to-CMF-Viewer

Conversation

@JohnGreenFC

@JohnGreenFC JohnGreenFC commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Added UI Scaling from 1x-3x
Tested scaling on custom UI
Saving scaling settings into the IMGui Config

Copilot AI lite review requested due to automatic review settings September 16, 2026 13:55
Added UI Scaling from 1x-3x
Tested scaling on custom UI
Saving scaling settings into the IMGui Config
@JohnGreenFC
JohnGreenFC force-pushed the PLAT-11971-Add-support-for-UI-scaling-to-CMF-Viewer branch from 118a549 to f272fc9 Compare September 16, 2026 13:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Critical font-resource and settings-handler issues, plus unresolved scaling and input-handling issues, block approval.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This PR adds configurable 1x–3x Dear ImGui UI scaling with runtime controls, monitor-based defaults, and persistent settings.

Changes:

  • Adds centralized scaling constants and scaled UI dimensions.
  • Rebuilds fonts and styles when scaling changes.
  • Persists UI scale through ImGui configuration.
File summaries
File Summary
src/viewer/rendering/ui/uiSettings.h Adds settings API declarations.
src/viewer/rendering/ui/uiSettings.cpp Adds configuration persistence. Critical (3 votes): initialize settings callbacks and user data. Moderate (1 vote): reject non-finite scale values.
src/viewer/rendering/ui/uiRenderer.h Declares scaling support.
src/viewer/rendering/ui/uiRenderer.cpp Applies font/style scaling. Critical (3 votes): synchronize font resource replacement across frames. Moderate (1 vote): scale fixed table dimensions.
src/viewer/rendering/ui/uiMenubar.h Adds slider state.
src/viewer/rendering/ui/uiMenubar.cpp Adds scale controls. Moderate (1 vote): handle slider deactivation when the menu closes.
src/viewer/rendering/ui/uiGeneralWindow.cpp Uses scaled button dimensions.
src/viewer/rendering/ui/uiDetailWindow.cpp Uses scaled spacing and table heights. Moderate (1 vote): scale fixed table column widths.
src/viewer/rendering/ui/uiCustomWidgets.h Adds scaled widget defaults.
src/viewer/rendering/ui/uiCustomWidgets.cpp Applies scaled widget geometry.
src/viewer/rendering/ui/uiConsts.h Defines scaling constants and accessors.
src/viewer/rendering/ui/uiConsts.cpp Stores runtime scale state.
src/viewer/rendering/ui/uiAnimationPlayback.cpp Scales playback controls.
src/viewer/appState.h Adds UI scale state.
src/viewer/appState.cpp Dispatches scale callbacks.
src/viewer/application.cpp Initializes monitor-based scaling and saves settings. Moderate (2 votes): use logical window or viewport dimensions for UI layout.
Review details

Suppressed comments (4)

src/viewer/rendering/ui/uiDetailWindow.cpp:1221

  • The new scaled height still uses fixed indexColumnWidth/columnWidth values (60/80px) for both tables below. At 2x/3x the text font and row heights grow but these columns do not, so vertex indices and coordinates can be clipped. Scale those base widths through UiConsts::Scaled before passing them to TableSetupColumn.
		const float tableHeight = std::min( (float)vertexCount * ImGui::GetTextLineHeightWithSpacing() + ImGui::GetTextLineHeightWithSpacing(), UiConsts::Scaled( 200.0f ) );

src/viewer/rendering/ui/uiMenubar.cpp:141

  • If the slider is dragged and the mouse is released outside the open menu, the slider is not submitted on that frame, so IsItemDeactivatedAfterEdit() is never observed. m_uiScaleSliderActive then remains true and the pending value is never copied to appState.uiScale; reopening the menu also skips the synchronization at lines 135-138. Handle deactivation/menu closure outside BeginMenu and explicitly commit or discard the pending value.
		m_uiScaleSliderActive = ImGui::IsItemActive();

src/viewer/rendering/ui/uiRenderer.cpp:163

  • ScaleAllSizes only scales values stored in ImGuiStyle; it does not affect explicit pixel dimensions elsewhere. For example, uiDetailWindow.cpp still passes fixed 48px/72px/80px table widths, so at 3x the text and padding grow while those columns remain 1x and can clip their headers and content. Route all fixed UI dimensions through the scaled accessors as well.
	// ScaleAllSizes is cumulative, so always start from a fresh style
	ImGuiStyle& style = ImGui::GetStyle();
	style = ImGuiStyle();
	ImGui::StyleColorsDark( &style );
	style.ScaleAllSizes( scale );

src/viewer/rendering/ui/uiSettings.cpp:101

  • strtof accepts nan, and the end check succeeds for it; std::clamp does not sanitize a NaN. A malformed UiScale=nan therefore propagates into ApplyUiScale, SizePixels, and ScaleAllSizes, which can break font construction/rendering. Reject non-finite values (and ideally trailing junk) before storing the clamped scale.
		const float uiScale = std::strtof( line + keyLength, &end );
		if( end != line + keyLength )
		{
			GetAppState( handler ).uiScale.SetValueNoCallback( std::clamp( uiScale, UiConsts::MIN_UI_SCALE, UiConsts::MAX_UI_SCALE ) );
  • Files reviewed: 16/16 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/viewer/rendering/ui/uiRenderer.cpp
Comment thread src/viewer/rendering/ui/uiSettings.cpp Outdated
Comment thread src/viewer/application.cpp
Comment thread src/viewer/rendering/ui/uiConsts.cpp Outdated
Comment thread src/viewer/rendering/ui/uiSettings.cpp Outdated
Comment thread src/viewer/rendering/ui/uiConsts.cpp Outdated
@JohnGreenFC
JohnGreenFC merged commit 56e0574 into main Sep 21, 2026
2 checks passed
@JohnGreenFC
JohnGreenFC deleted the PLAT-11971-Add-support-for-UI-scaling-to-CMF-Viewer branch September 21, 2026 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants