Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,13 @@ panels**, and a few responsibilities are deliberately split across the AppKit/Sw
for in-app controls and won't sample the desktop behind a window.
- **The window drags only by its header.** `isMovableByWindowBackground` is off; `WindowMoveArea`
(an `NSViewRepresentable` calling `window.performDrag`) is placed behind the header / collapsed
bar. This is what lets task rows be dragged to **reorder** without moving the window.
bar. This is what lets task rows be dragged to **reorder** without moving the window. The title is
plain text **inside** that handle, not a click target: the header row sits in the window's hidden
title-bar strip, where a title taking clicks let a double-click through to macOS's zoom. Renaming is
⋯ › Rename… (or a new list), via `NoteController.requestRename`, which swaps in a field.
- **The hover reveal is an AppKit tracking area (`HoverArea`), not `.onHover`.** SwiftUI's hover often
didn't reveal the header controls until the note had been clicked into; `HoverArea`'s `.activeAlways`
tracking area goes by geometry alone. (Synthetic `mouseMoved` events drive neither, so tests can't.)
- **Reorder uses a direct `DragGesture`, not system `.onDrag`.** System drag has a sluggish
pickup; the gesture is immediate. The dragged block (row + subtree) lifts into an overlay
(`LiftedRow`) and its head row turns into a ghost `DropPlaceholder` at the drop slot and level;
Expand All @@ -189,9 +195,21 @@ panels**, and a few responsibilities are deliberately split across the AppKit/Sw
are pure in `TaskOutline` (`dropLevels`: never adopt the row below; `levelSteps`: ~70% of an
indent step to re-nest). Safe on macOS because scrolling is the wheel/trackpad, so click-drag
doesn't fight the `ScrollView`.
- **Roll-up keeps the top edge fixed.** `NoteWindowManager.setCollapsed` resizes the panel to
`NoteLayout.collapsedHeight`, remembers the real height in `expandedHeights`, and
`scheduleFrameSave` persists the *expanded* height/origin while collapsed so nothing is lost.
- **Roll-up keeps the top edge fixed — or the bottom, near the screen's bottom.**
`NoteWindowManager.setCollapsed` resizes the panel to `NoteLayout.collapsedHeight` from the edge
`rolledFrame` picks (pure, tested) — and a bar let go near the bottom glides there too
(`NotePanel.performDrag` returns on mouse-up → `snapToBottom`) — remembers the real height in `expandedHeights`, and
`scheduleFrameSave` persists the *expanded* frame while collapsed so nothing is lost. The bar is
**frameless** (`NotePanel.setRolledUp`; it draws its own capsule) because macOS rounds a titled
window at a fixed 16pt that splits from a thin bar's fill. The bar **is** the note's top row
(`NoteHeaderView`: title + hover controls, `isRolledUp` adds the count and trims the controls), so the
roll is a pure window shade; `NoteView` drops the list only once the window is down to bar height
(`showsBar`). The roll is an `animator()` frame animation, not the blocking
`setFrame(_:display:animate:)` (SwiftUI only swapped the content after it); the system frame returns
before expanding and goes only after rolling up, since a titled window's shadow tracks a resize. The
bar has **no** shadow: a frameless window's traces the capsule with a dark rim that reads as a border. The content has `minHeight: 0` — the hosting view won't let the window be shorter than the
content's minimum (an expand jumped straight to ~150pt) — so the open note's minimum lives in
`windowWillResize`, which also locks the bar's height.
- **Theming via roles, not raw colors.** `NoteColor.color(_:on:)` resolves a role
(title/task/secondary/completed/checkbox) for a `Surface` (`.solid` uses per-theme tuned inks;
`.glass` uses adaptive `.primary`/`.secondary`). Views read a resolved `NoteTheme`, never branch
Expand Down
4 changes: 4 additions & 0 deletions Sources/Tic/Controllers/NoteController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ final class NoteController {
private(set) var pendingThumbnail: CGImage?
/// Bumped to ask the quick-add field to take the keyboard (e.g. a paste with nothing focused).
private(set) var quickAddFocusRequest = 0
/// Bumped to ask the header to start renaming the note (a brand-new list starts out that way).
private(set) var renameRequest = 0

func requestRename() { renameRequest += 1 }

/// Holds a pasted image in the quick-add, replacing any already waiting, and focuses the field.
func stageImage(_ data: Data) {
Expand Down
33 changes: 33 additions & 0 deletions Sources/Tic/Views/HoverArea.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import AppKit
import SwiftUI

/// Reports the pointer entering and leaving its frame, from an AppKit tracking area. A note's hover reveal
/// uses this, not SwiftUI's `.onHover`, which often didn't fire until the note had been clicked into (most of
/// the header row it reveals is the AppKit drag handle). A tracking area goes by geometry alone — whatever
/// view is under the pointer, key window or not, Tic active or not. It never takes a click.
struct HoverArea: NSViewRepresentable {
var onChange: (Bool) -> Void

func makeNSView(context: Context) -> TrackingView { TrackingView(onChange: onChange) }

func updateNSView(_ nsView: TrackingView, context: Context) { nsView.onChange = onChange }

final class TrackingView: NSView {
var onChange: (Bool) -> Void

init(onChange: @escaping (Bool) -> Void) {
self.onChange = onChange
super.init(frame: .zero)
addTrackingArea(NSTrackingArea(
rect: .zero, options: [.mouseEnteredAndExited, .activeAlways, .inVisibleRect], owner: self
))
}

@available(*, unavailable)
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }

override func mouseEntered(with event: NSEvent) { onChange(true) }
override func mouseExited(with event: NSEvent) { onChange(false) }
override func hitTest(_ point: NSPoint) -> NSView? { nil }
}
}
2 changes: 1 addition & 1 deletion Sources/Tic/Views/ImageViewer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct ImageViewer: View {
}
}

/// Mirrors `NoteHeaderView`: a control strip, the title, and the accent rule — and it's the drag handle.
/// Dressed like a note's header: its controls, the title, and the accent rule — and it's the drag handle.
private var header: some View {
VStack(alignment: .leading, spacing: 8) {
HStack(spacing: 10) {
Expand Down
27 changes: 22 additions & 5 deletions Sources/Tic/Views/NoteBackground.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@ import AppKit
struct NoteBackground: View {
let color: NoteColor
let material: NoteMaterial
/// The note's own corner rounding — only for a rolled-up bar, which has no system window frame to round it.
var cornerRadius: CGFloat = 0

var body: some View {
let shape = RoundedRectangle(cornerRadius: cornerRadius)
switch material {
case .solid:
color.fill
shape.fill(color.fill)
case .glass:
ZStack {
VisualEffectBackground(material: .popover, blending: .behindWindow)
color.fill.opacity(0.18) // a hint of the theme over the glass
VisualEffectBackground(material: .popover, blending: .behindWindow, cornerRadius: cornerRadius)
shape.fill(color.fill.opacity(0.18)) // a hint of the theme over the glass
}
}
}
Expand All @@ -26,18 +29,32 @@ struct NoteBackground: View {
private struct VisualEffectBackground: NSViewRepresentable {
let material: NSVisualEffectView.Material
let blending: NSVisualEffectView.BlendingMode
let cornerRadius: CGFloat

func makeNSView(context: Context) -> NSVisualEffectView {
let view = NSVisualEffectView()
view.material = material
view.blendingMode = blending
view.state = .active // keep the effect visible even when the window isn't key
updateNSView(view, context: context)
return view
}

func updateNSView(_ nsView: NSVisualEffectView, context: Context) {
nsView.material = material
nsView.blendingMode = blending
nsView.state = .active
nsView.maskImage = cornerRadius > 0 ? Self.roundedMask(radius: cornerRadius) : nil
}

/// A stretchable rounded-rect mask: the way to round a behind-window effect view (layer masks don't apply).
private static func roundedMask(radius: CGFloat) -> NSImage {
let side = radius * 2 + 1
let image = NSImage(size: NSSize(width: side, height: side), flipped: false) { rect in
NSColor.black.setFill()
NSBezierPath(roundedRect: rect, xRadius: radius, yRadius: radius).fill()
return true
}
image.capInsets = NSEdgeInsets(top: radius, left: radius, bottom: radius, right: radius)
image.resizingMode = .stretch
return image
}
}
Loading
Loading