Skip to content

Group rulers in a single window - #224

Merged
pascalpp merged 15 commits into
mainfrom
pascal/219-grouped-rulers-window
Jun 17, 2026
Merged

pascalpp merged 15 commits into
mainfrom
pascal/219-grouped-rulers-window

Conversation

@pascalpp

Copy link
Copy Markdown
Owner

Summary

  • Render grouped rulers as a single L-shaped window with horizontal and vertical ruler views inside it.
  • Keep ungrouped rulers as separate windows, and decouple H/V visibility from grouping.
  • Smooth grouped ruler cursor, mouse tick, resize handle, zero label, and border behavior.
  • Add grouped ruler snapshot generation plus unit coverage for layout, visibility, mouse ticks, and hotkeys.

Closes #219

Testing

  • xcodebuild -project "Free Ruler.xcodeproj" -scheme "Free Ruler" test -only-testing:FreeRulerTests

Notes

  • UI tests are intentionally left for follow-up after manual review.

pascalpp added 5 commits June 15, 2026 17:39
- Introduced GroupedRulerController to manage grouped ruler windows.
- Implemented logic to toggle between grouped and separate ruler modes.
- Enhanced ruler drawing to support zero ticks and improved mouse tick handling.
- Added localized string for "Grouped Rulers" window title.
- Updated UI components to reflect new grouped ruler features, including border views and visibility handling for unit labels and ticks.
- Introduced RulerVisibility struct to manage the visibility state of horizontal and vertical rulers.
- Updated ruler display logic to utilize the new visibility management, allowing for toggling and grouping of rulers.
- Enhanced GroupedRulerWindow to reflect visibility changes in the UI, including dynamic updates to border views and unit labels.
- Refactored ResizeHandleView to accommodate orientation-specific adjustments for ruler handles.
- Adjusted y and x coordinate calculations for resize handles to account for horizontal and vertical offsets, background padding, and handle lengths.
- Simplified control flow by consolidating placement logic for both top/bottom and left/right orientations, enhancing clarity and maintainability.
- Introduced functionality to suppress and unsuppress mouse tick drawing based on user interactions, improving UI responsiveness during ruler resizing and hovering.
- Updated mouse event handling in RulerController and ResizeHandleView to manage mouse tick visibility dynamically.
- Added tracking area for corner interactions in GroupedRulerContentView to enhance user experience.
- Implemented snapshot tests for grouped ruler window layout to ensure visual consistency.
- Implemented multiple tests for the GroupedRulerLayout, ensuring correct frame calculations and layout behavior for different zero corners.
- Added a test for the GroupedRulerContentView to verify layout and hit testing functionality.
- Enhanced the GroupedRulerController to manage mouse tick visibility based on the active ruler legs.
- Introduced a new snapshot image for the grouped ruler window layout to support visual regression testing.
- Updated the snapshot generation script to include the GroupedRulerWindow in the compilation process.
@pascalpp pascalpp changed the title [codex] Group rulers in a single window Group rulers in a single window Jun 16, 2026

pascalpp commented Jun 16, 2026 •

Copy link
Copy Markdown
Owner Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

pascalpp added 4 commits June 16, 2026 10:14
* Refactor grouped ruler path calculations and enhance drawing logic

- Consolidated the L-shaped border path logic into a reusable function for improved clarity and maintainability.
- Updated the drawing methods in GroupedRulerContentView to utilize the new path function, enhancing performance and readability.
- Introduced a background drawing toggle in RuleView, allowing for more flexible rendering of the horizontal and vertical rulers.
- Adjusted offset calculations in HorizontalRule and VerticalRule to ensure consistent ruler rendering.

* Enhance mouse tick management in ResizeHandleView

- Added conditional compilation to suspend and resume mouse tick updates during resizing, improving UI responsiveness.
- Updated appDelegate access to be conditional, ensuring compatibility with snapshot generation.

* Update AppStoreScreenshotPreview.swift

* Update AppStoreScreenshotPreview.swift

* Update AppStoreScreenshotPreview.swift

* Update RulerCoreTests.swift

* update store screenshots

* update test snapshots

* Update HorizontalRule.swift
@pascalpp
pascalpp marked this pull request as ready for review June 17, 2026 02:29
@pascalpp

Copy link
Copy Markdown
Owner Author

[codex reviewer]: Reviewed PR #224 at 3032cad. I focused on the main grouped-ruler implementation, not the app store screenshot generator.

Findings

  • P1: A re-shown grouped leg can keep mouse ticks disabled.
    GroupedRulerWindow.swift gates showMouseTick by current rule visibility, but setVisibleRules does not re-enable ticks when a hidden leg becomes visible again. Scenario: hide vertical, trigger suppress/unsuppress while vertical is hidden, then show vertical. drawMouseTick runs, but VerticalRule.draw still skips it because showMouseTick remains false.

  • P2: Grouped mode uses hidden standalone windows as the backing geometry/persistence store.
    AppDelegate.syncGroupedRulerFramesToRulerWindows plus GroupedRulerController.syncFrames makes invisible RulerWindows the source for future grouped layout. That works, but it is a subtle long-term contract. Also, windowDidMove can call saveFrame repeatedly during moves. I’d separate “sync in-memory frame” from “persist autosave frame”.

  • P2: Geometry rules are duplicated.
    GroupedRulerLayout has its own borderCompensation and private ZeroCorner side helpers at GroupedRulerWindow.swift:228, while ZeroCornerGeometry already owns the same concepts in Ruler.swift:76. This is exactly the kind of 1 px drift that will be painful later.

  • P2: Mouse/drag/cursor state is now duplicated between separate and grouped controllers.
    Compare RulerController.swift:82 with GroupedRulerWindow.swift:1311. The state machine is nearly identical: dragging, hovering, delayed resume, suppress/resume. This wants a small shared helper before future cursor/timer fixes have to be patched twice.

  • P3: Some AppDelegate mode logic is misleading.
    In showGroupedRulerWindow, shouldShowGroupedRuler is always true after the preceding visibility guard because it includes || rulerVisibility.hasVisibleRuler at AppDelegate.swift:405. showSeparateRulerWindows(showRulersIfNeeded:) also accepts an unused parameter. Small cleanup, but it would make the presentation state easier to trust.

  • P3: GroupedRulerWindow.swift is doing too much.
    It contains layout math, NSPanel setup, content view layout, zero-label drawing, controller behavior, key handling, and path drawing. I’d split it after this lands: GroupedRulerLayout, GroupedRulerContentView, GroupedRulerController, and maybe grouped drawing helpers.

I didn’t run the test suite; this was a review pass from the PR diff and local source.

@pascalpp
pascalpp merged commit 72dc7ab into main Jun 17, 2026
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.

Possible idea for grouped rulers

1 participant