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
1 change: 1 addition & 0 deletions ACCEPTANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Run on macOS 14+ with the released `Howler.dmg` (or `Howler.zip`). Mark each ite
- [ ] 中文输入法:可正常输入拼音选词;选词过程中按 Esc 只取消组字,不关闭信纸
- [ ] ⌘V / ⌘C / ⌘A / ⌘Z 在输入框中可用
- [ ] Esc 或右下角火焰烧掉信纸并立即清空;火焰不遮挡页脚或正文;点击纸外或阴影只交出焦点,回答继续;其他应用中的 Esc 不影响信纸
- [ ] 连续呼出信纸并按 Esc 至少三次。每次燃烧开始时,纸边、火漆印和正文都留在原位。
- [ ] 燃烧中再按 ⌥H:立即出现一张新的空白信纸
- [ ] 从菜单或火漆印打开 Settings:信纸直接收起并保留会话;从菜单打开信纸只唤回,不反向收起
- [ ] 多显示器:在鼠标所在屏幕上弹出
Expand Down
3 changes: 2 additions & 1 deletion Sources/Howler/HowlerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ struct HowlerView: View {
.padding(.bottom, 8).padding(.trailing, 8)
}
}
// 让展开动画的图层包含透明留白,保证燃烧快照沿用窗口原点。
.padding(margins)
.scaleEffect(unfolded ? 1 : 0.97, anchor: .top)
.rotation3DEffect(.degrees(unfolded ? 0 : 10), axis: (x: 1, y: 0, z: 0), anchor: .top, perspective: 0.5)
.opacity(unfolded ? 1 : 0)
.padding(margins)
.environment(\.parchment, parchment)
.environment(\.copyText, viewModel.copyText)
.onAppear {
Expand Down
47 changes: 47 additions & 0 deletions Tests/HowlerAppTests/LetterLifecycleTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,53 @@ final class LetterLifecycleTests: XCTestCase {
XCTAssertEqual(settings.screenshotHotKey, .screenshot)
}

func testOpeningBurnFrameKeepsTheWaxSealInPlace() async throws {
try XCTSkipIf(NSWorkspace.shared.accessibilityDisplayShouldReduceMotion)
_ = NSApplication.shared
let defaults = try XCTUnwrap(DemoDefaults(suiteName: "HowlerTests.BurnPosition"))
let settings = AppSettings(defaults: defaults, keys: MemoryKeys().access)
settings.useDemoService(.anthropic)
let controller = PanelController(settings: settings, openSettings: {})
defer { controller.conceal() }
for cycle in 1...3 {
controller.show()
try await Task.sleep(nanoseconds: 650_000_000)
let originalFrame = controller.panel.frame
let liveSeal = try waxSealCenter(in: controller.panel)

controller.panel.cancelOperation(nil)

XCTAssertTrue(controller.isVisible, "应显示燃烧动画")
XCTAssertEqual(controller.panel.frame, originalFrame, "第 \(cycle) 次燃烧")
let burningSeal = try waxSealCenter(in: controller.panel)
XCTAssertEqual(burningSeal.x, liveSeal.x, accuracy: 2, "第 \(cycle) 次燃烧")
XCTAssertEqual(burningSeal.y, liveSeal.y, accuracy: 2, "第 \(cycle) 次燃烧")
try await waitUntil("燃烧结束后窗口应隐藏") { !controller.isVisible }
}
}

private func waxSealCenter(in panel: NSPanel) throws -> CGPoint {
let content = try XCTUnwrap(panel.contentView)
content.layoutSubtreeIfNeeded()
let bitmap = try XCTUnwrap(content.bitmapImageRepForCachingDisplay(in: content.bounds))
content.cacheDisplay(in: content.bounds, to: bitmap)
let scale = CGFloat(bitmap.pixelsWide) / content.bounds.width
var count = 0
var sum = CGPoint.zero
for y in 0..<Int(100 * scale) {
for x in 0..<Int(125 * scale) {
guard let color = bitmap.colorAt(x: x, y: y)?.usingColorSpace(.deviceRGB),
color.alphaComponent > 0.9, color.redComponent > color.greenComponent * 2,
color.redComponent > color.blueComponent * 2 else { continue }
sum.x += CGFloat(x)
sum.y += CGFloat(y)
count += 1
}
}
let sampleCount = try XCTUnwrap(count > 0 ? count : nil, "应能在纸张左上角找到火漆印")
return CGPoint(x: sum.x / CGFloat(sampleCount) / scale, y: sum.y / CGFloat(sampleCount) / scale)
}

func testBurningSnapshotDoesNotLeaveShadowOrScorchInMargins() throws {
_ = NSApplication.shared
let margins = EdgeInsets(
Expand Down
Loading