Skip to content

Qt sidebar toggle: rotate heading on vertical edges - #37

Merged
trissim merged 1 commit into
mainfrom
fix/qt-sidebar-title-rotation
Nov 17, 2026
Merged

trissim merged 1 commit into
mainfrom
fix/qt-sidebar-title-rotation

Conversation

@trissim

@trissim trissim commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • SidebarToggle now reads placement.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.
  • New _RotatableTitle(ElidedLine) paints its text rotated (book-spine, bottom-to-top) when its rotation is non-zero. sizeHint/minimumSizeHint swap axes so Qt lays it out correctly in the new orientation.
  • PlacementEdge protocol gains title_rotation_degrees() — companion method is on toad's SidebarEdge hierarchy (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. SidebarToggle never branches on edge identity (no isinstance, no name checks) — it reads one polymorphic method and flips its own layout.

Test plan

  • _RotatableTitle paints 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 a LeftSidebarEdge-like placement sets _title._rotation == -90, minimumWidth == 40, minimumHeight == 0.
  • SidebarToggle.present() with a TopSidebarEdge-like placement sets rotation back to 0, minimumHeight == 40, minimumWidth == 0.
  • Round-trip (Left → Top → Left) rebuilds correctly.

🤖 Generated with Claude Code

https://claude.ai/code/session_016gZLdupVQyBzHTmHBC9Cyn

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
@trissim
trissim merged commit c725b55 into main Nov 17, 2026
1 of 11 checks passed
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.

1 participant