Skip to content

Commit

Permalink
toolbar(visionOS): move toolbar to top of window
Browse files Browse the repository at this point in the history
  • Loading branch information
osy committed Dec 10, 2023
1 parent 163a903 commit 5f47ae0
Showing 1 changed file with 11 additions and 21 deletions.
32 changes: 11 additions & 21 deletions Platform/visionOS/VMToolbarOrnamentModifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ struct VMToolbarOrnamentModifier: ViewModifier {
@EnvironmentObject private var session: VMSessionState

func body(content: Content) -> some View {
content.toolbar {
ToolbarItem(placement: .bottomOrnament) {
content.ornament(attachmentAnchor: .scene(.top)) {
HStack {
Button {
if session.vm.state == .started {
state.alert = .powerDown
Expand All @@ -33,28 +33,20 @@ struct VMToolbarOrnamentModifier: ViewModifier {
Label(state.isRunning ? "Power Off" : "Quit", systemImage: state.isRunning ? "power" : "xmark")
}
.disabled(state.isBusy)
}
ToolbarItem(placement: .bottomOrnament) {
Button {
session.pauseResume()
} label: {
Label(state.isRunning ? "Pause" : "Play", systemImage: state.isRunning ? "pause" : "play")
}
.disabled(state.isBusy)
}
ToolbarItem(placement: .bottomOrnament) {
Button {
state.alert = .restart
} label: {
Label("Restart", systemImage: "restart")
}
.disabled(state.isBusy)
}
ToolbarItem(placement: .bottomOrnament) {
Divider()
}
if case .serial(_, _) = state.device {
ToolbarItem(placement: .bottomOrnament) {
if case .serial(_, _) = state.device {
Button {
let template = session.qemuConfig.serials[state.device!.configIndex].terminal?.resizeCommand
state.toggleDisplayResize(command: template)
Expand All @@ -63,31 +55,29 @@ struct VMToolbarOrnamentModifier: ViewModifier {
}
.disabled(state.isBusy)
}
}
#if !WITH_QEMU_TCI
ToolbarItem(placement: .bottomOrnament) {
#if !WITH_QEMU_TCI
if session.vm.hasUsbRedirection {
VMToolbarUSBMenuView()
.disabled(state.isBusy)
}
}
#endif
ToolbarItem(placement: .bottomOrnament) {
#endif
VMToolbarDriveMenuView(config: session.qemuConfig)
.disabled(state.isBusy)
}
ToolbarItem(placement: .bottomOrnament) {
VMToolbarDisplayMenuView(state: $state)
.disabled(state.isBusy)
}
ToolbarItem(placement: .bottomOrnament) {
Button {
state.isKeyboardRequested = true
} label: {
Label("Keyboard", systemImage: "keyboard")
}
.disabled(state.isBusy)
}
// the following was suggested by Apple via Feedback to look close to .toolbar() with .bottomOrnament
.buttonBorderShape(.capsule)
.buttonStyle(.borderless)
.labelStyle(.iconOnly)
.padding(12)
.glassBackgroundEffect()
}
}
}

0 comments on commit 5f47ae0

Please sign in to comment.