Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ struct Benchmarks {
}

@MainActor
func updateNode<V: View>(_ node: ViewGraphNode<V, DummyBackend>, _ size: SIMD2<Int>) {
_ = node.update(proposedSize: size, environment: environment, dryRun: true)
_ = node.update(proposedSize: size, environment: environment, dryRun: false)
func updateNode<V: View>(_ node: ViewGraphNode<V, DummyBackend>, _ size: ProposedViewSize) {
_ = node.computeLayout(proposedSize: size, environment: environment)
_ = node.commit()
}

#if BENCHMARK_VIZ
var benchmarkVisualizations: [(name: String, main: () -> Never)] = []
#endif

@MainActor
func benchmarkLayout<V: TestCaseView>(of viewType: V.Type, _ size: SIMD2<Int>, _ label: String) {
func benchmarkLayout<V: TestCaseView>(of viewType: V.Type, _ size: ProposedViewSize, _ label: String) {
#if BENCHMARK_VIZ
benchmarkVisualizations.append((
label,
Expand All @@ -62,8 +62,8 @@ struct Benchmarks {
}

// Register benchmarks
benchmarkLayout(of: GridView.self, SIMD2(800, 800), "grid")
benchmarkLayout(of: ScrollableMessageListView.self, SIMD2(800, 800), "message list")
benchmarkLayout(of: GridView.self, ProposedViewSize(800, 800), "grid")
benchmarkLayout(of: ScrollableMessageListView.self, ProposedViewSize(800, 800), "message list")

#if BENCHMARK_VIZ
let names = benchmarkVisualizations.map(\.name).joined(separator: " | ")
Expand Down
2 changes: 2 additions & 0 deletions Examples/Sources/WindowingExample/WindowingApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ struct WindowingApp: App {
}

Image(Bundle.module.bundleURL.appendingPathComponent("Banner.png"))
.resizable()
.aspectRatio(contentMode: .fit)

Divider()

Expand Down
6 changes: 4 additions & 2 deletions Sources/AppKitBackend/AppKitBackend.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ public final class AppKitBackend: AppBackend {
// We assume that all scrollers have their controlSize set to `.regular` by default.
// The internet seems to indicate that this is true regardless of any system wide
// preferences etc.
Int(
let result = Int(
NSScroller.scrollerWidth(
for: .regular,
scrollerStyle: NSScroller.preferredScrollerStyle
).rounded(.awayFromZero)
)
print(result)
return result
}

private let appDelegate = NSCustomApplicationDelegate()
Expand Down Expand Up @@ -528,7 +530,7 @@ public final class AppKitBackend: AppBackend {
) -> SIMD2<Int> {
if let proposedFrame, proposedFrame.x == 0 {
// We want the text to have the same height as it would have if it were
// one pixel wide so that the layout doesn't suddely jump when the text
// one pixel wide so that the layout doesn't suddenly jump when the text
// reaches zero width.
let size = size(
of: text,
Expand Down
Loading
Loading