A card window toolbar control shows and hides the trailing sidebar — View ▸ Show Sidebar joins Edit Body, Raw Source and Add Attachment
The card window's trailing attributes sidebar has always been unconditional since m6; this adds View ▸ Show Sidebar (a checkmark toggle, ShowComments' shape) and a matching toolbar item on the customizable card toolbar (NSToolbar/WindowToolbarController), a fourth default beside Edit Body, Raw Source and Add Attachment. sidebar.right for the trailing pane; one shared animated write path (AppPreferences.setShowCardSidebar) both faces call, structural-voice reflow with a trailing slide-and-fade transition (Motion.cardSidebarTransition), Reduce Motion respected throughout. CardWindowMetrics.minimumSize gains a sidebar: Bool = true parameter so a hidden sidebar shrinks the window's floor, composing with the existing commentsColumn parameter. The toolbar item's read/write are injectable closures (defaulted to the real UserDefaults-backed pair) so its plumbing is testable without touching the developer's own preferences domain. WindowToolbarController's observation tracking only sees @Observable reads, so a small HostedWindowController.revalidateToolbar() plus an onChange nudge keeps the toolbar button's on-state in step with the View-menu row's write. Scope held narrowly to visibility, per the card: no sidebar section reordering, no action-moving. Claude-Session: https://claude.ai/code/session_014PtZdPwqZuqEDLc6wZMtEy
This commit is contained in:
@@ -178,6 +178,33 @@ struct CardWindowMetricsTests {
|
||||
#expect(CardWindowMetrics.minimumSize(bodyPointSize: size).height > 0)
|
||||
}
|
||||
|
||||
@Test("Hiding the sidebar shrinks the window's minimum by exactly its width")
|
||||
func hidingTheSidebarShrinksTheMinimum() {
|
||||
// View ▸ Show Sidebar's own mirror of the comments column's own rule
|
||||
// (`CommentsWindowMinimumTests.theMinimumGrowsOnlyBeside`): a pane costs the window no width
|
||||
// while it is not shown.
|
||||
let size: CGFloat = 13
|
||||
let shown = CardWindowMetrics.minimumSize(bodyPointSize: size)
|
||||
let hidden = CardWindowMetrics.minimumSize(bodyPointSize: size, sidebar: false)
|
||||
|
||||
#expect(shown.width == hidden.width + CardWindowMetrics.sidebarWidth(bodyPointSize: size))
|
||||
#expect(hidden.width == CardWindowMetrics.bodyMinimumWidth(bodyPointSize: size))
|
||||
#expect(hidden.height == shown.height, "hiding the sidebar costs width, never height")
|
||||
}
|
||||
|
||||
@Test("Hiding the sidebar composes with the comments column's own minimum")
|
||||
func hidingTheSidebarComposesWithTheCommentsColumn() {
|
||||
let size: CGFloat = 13
|
||||
let minimum = CardWindowMetrics.minimumSize(bodyPointSize: size, sidebar: false, commentsColumn: true)
|
||||
|
||||
#expect(
|
||||
minimum.width
|
||||
== CardWindowMetrics.bodyMinimumWidth(bodyPointSize: size)
|
||||
+ CardWindowMetrics.commentsMinimumWidth(bodyPointSize: size),
|
||||
"sidebar hidden and comments beside: the minimum is the body's floor plus the comments floor, nothing else"
|
||||
)
|
||||
}
|
||||
|
||||
@Test("A first card window opens larger than the minimum")
|
||||
func theDefaultSizeIsRoomier() {
|
||||
let size: CGFloat = 13
|
||||
|
||||
Reference in New Issue
Block a user