Blender4iOS/Sources/UI/ToolSidebar.swift
2026-04-10 21:34:23 -07:00

60 lines
1.8 KiB
Swift

// ToolSidebar.swift
// Vertical tool strip on the left edge, matching Blender's T-panel.
import SwiftUI
struct ToolSidebar: View {
@Binding var activeTool: ViewportTool
var body: some View {
VStack(spacing: 4) {
ForEach(ViewportTool.allCases) { tool in
Button {
activeTool = tool
} label: {
Image(systemName: tool.icon)
.font(.system(size: 16))
.frame(width: 36, height: 36)
.background(
activeTool == tool
? Color.accentColor.opacity(0.25)
: Color.clear,
in: RoundedRectangle(cornerRadius: 6)
)
}
.tint(activeTool == tool ? .orange : .secondary)
.accessibilityLabel(tool.rawValue)
}
Spacer()
}
.padding(.vertical, 8)
.padding(.horizontal, 4)
.background(.ultraThinMaterial)
}
}
// MARK: - Tools
enum ViewportTool: String, CaseIterable, Identifiable {
case cursor = "Cursor"
case move = "Move"
case rotate = "Rotate"
case scale = "Scale"
case box = "Box Select"
case measure = "Measure"
case annotate = "Annotate"
var id: String { rawValue }
var icon: String {
switch self {
case .cursor: "target"
case .move: "arrow.up.and.down.and.arrow.left.and.right"
case .rotate: "arrow.triangle.2.circlepath"
case .scale: "arrow.up.left.and.arrow.down.right.and.sparkle"
case .box: "rectangle.dashed"
case .measure: "ruler"
case .annotate: "pencil.tip"
}
}
}