Skip to content

Conversation

@nchapman
Copy link
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings December 10, 2025 23:33
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the UI layout system to perform calculations in pixel space rather than display point (DP) space, eliminating rounding accumulation that was causing row overlap bugs. The core change is in UI_initLayout() which now calculates optimal row count and pill height directly in pixels, then stores both pixel values (for exact positioning) and DP values (for proportional calculations) in the UI_Layout struct. This approach ensures that repeated layout arithmetic (e.g., y = edge_padding_px + row * pill_height_px) uses exact integer pixel values without intermediate DP conversions that round and accumulate error.

Key Changes:

  • Introduced pixel-accurate row fitting algorithm that works entirely in pixel space to prevent rounding drift
  • Added *_px fields to UI_Layout struct (pill_height_px, edge_padding_px, option_size_px) for exact layout positioning
  • Updated all UI rendering code to use pre-calculated *_px fields instead of repeatedly calling DP() on intermediate calculations

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
workspace/all/common/api.h Added comprehensive documentation explaining the distinction between DP values (for proportional calculations) and pixel values (for exact positioning), plus usage examples. Added new *_px fields to UI_Layout struct.
workspace/all/common/api.c Rewrote UI_initLayout() to calculate row count and pill size entirely in pixel space. Updated initialization code to populate both DP and pixel fields. Modified asset scaling and text centering to use pre-calculated pixel values.
workspace/all/utils/shui/ui_list.c Replaced DP(ui.edge_padding), DP(ui.pill_height), and DP(ui.option_size) calls with pre-calculated pixel values for exact positioning.
workspace/all/utils/shui/ui_keyboard.c Updated layout calculations to use ui.pill_height_px and ui.edge_padding_px for pixel-perfect positioning.
workspace/all/minui/minui.c Converted vertical positioning calculations to use ui.edge_padding_px + (j * ui.pill_height_px) pattern for pixel-accurate row placement.
workspace/all/minarch/minarch_menu.c Updated pill positioning to use ui.edge_padding_px and ui.pill_height_px for consistent pixel-perfect layout.
workspace/all/minarch/minarch.c Converted option row positioning to use ui.option_size_px and updated initialization to use pre-calculated pixel values throughout.
tests/unit/all/common/test_ui_layout.c Removed deprecated ui.text_baseline field and associated test, reflecting its removal from the actual implementation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@nchapman nchapman force-pushed the feature/pixel-perfect-rows branch from c607c71 to 4b7f3ac Compare December 10, 2025 23:40
@nchapman nchapman merged commit 89624fe into develop Dec 10, 2025
4 checks passed
@nchapman nchapman deleted the feature/pixel-perfect-rows branch December 10, 2025 23:54
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.

2 participants