Repository navigation
Qt sidebar toggle: rotate heading on vertical edges - #37
Merged
Merged
Conversation
Left and right sidebars are vertical columns, so their toggle bar's
heading now rotates 90° (book-spine, bottom-to-top) to read along the
bar's long axis instead of overflowing it. Top and bottom bars stay
horizontal, unchanged.
The orientation is not chosen inside the toggle: each PlacementEdge
owns `title_rotation_degrees()` as part of its nominal contract (0 for
horizontal strips, -90 for vertical columns). SidebarToggle reads that
one method and rebuilds its own layout to match — no isinstance or
per-edge name branches.
Changes:
- PlacementEdge protocol: add title_rotation_degrees().
- _RotatableTitle (new): ElidedLine with a rotation property. When
rotated, sizeHint/minimumSizeHint swap axes and paintEvent rotates
the painter, so the elided text still measures and lays out as a
normal QWidget.
- SidebarToggle: layout is now rebuilt by _apply_orientation() each
present, mirroring how SidebarPane rebuilds its own axis. On a
vertical edge the three children stack top-to-bottom and the bar's
cross-axis minimum moves from height to width; on a horizontal
edge the single-row layout is the old behaviour.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016gZLdupVQyBzHTmHBC9Cyn
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
SidebarTogglenow readsplacement.side.title_rotation_degrees()and reflows itself to match: vertical bars stack[arrow, rotated heading, arrow]top-to-bottom; horizontal bars keep the single-row layout._RotatableTitle(ElidedLine)paints its text rotated (book-spine, bottom-to-top) when its rotation is non-zero.sizeHint/minimumSizeHintswap axes so Qt lays it out correctly in the new orientation.PlacementEdgeprotocol gainstitle_rotation_degrees()— companion method is on toad'sSidebarEdgehierarchy (Sidebar edges own title rotation toad#1936).Why
Left and right sidebar bars are vertical columns; their heading was painted horizontally and overflowed the narrow strip. User complaint: "The labels on the bars aren't written veritably when bars are on sides".
The fix is inheritance-maximalist: the orientation lives on the edge class, not the toggle.
SidebarTogglenever branches on edge identity (no isinstance, no name checks) — it reads one polymorphic method and flips its own layout.Test plan
_RotatableTitlepaints the rotated text as a narrow vertical column (verified offscreen: text bbox goes from 46×17 horizontal to 11×46 vertical centered on the widget).SidebarToggle.present()with aLeftSidebarEdge-like placement sets_title._rotation == -90,minimumWidth == 40,minimumHeight == 0.SidebarToggle.present()with aTopSidebarEdge-like placement sets rotation back to0,minimumHeight == 40,minimumWidth == 0.🤖 Generated with Claude Code
https://claude.ai/code/session_016gZLdupVQyBzHTmHBC9Cyn