removed unwanted bar now with waveforms, major updates

This commit is contained in:
Mark Gregory
2026-11-06 10:42:21 +00:00
parent 15c9f5914d
commit f947308421
10 changed files with 695 additions and 105 deletions
+46 -6
View File
@@ -98,7 +98,7 @@ struct SongDragReference: Codable, Sendable {
let token = UUID(),locations = mediaLocations,cache = root.appendingPathComponent("Waveforms")
waveformJobToken = token;generatingWaveforms = true;waveformJob = .init(total:tracks.count)
waveformJobTask = Task.detached(priority:.utility) { [weak self] in
let result = WaveformBatch.run(songs:tracks,locations:locations,cache:cache,force:force,cancelled:{Task.isCancelled},progress:{ update in
let result = await WaveformBatch.runConcurrent(songs:tracks,locations:locations,cache:cache,force:force,progress:{ update in
Task { @MainActor [weak self] in guard let self,self.waveformJobToken == token else { return };self.waveformJob = update }
})
await MainActor.run { [weak self] in
@@ -578,7 +578,7 @@ private extension FocusedValues {
}
Window("Video", id: "lyrics") {
LyricsView(player: model.player).frame(minWidth: 480, minHeight: 320).preferredColorScheme(.dark)
}.defaultSize(width: 600, height: 400)
}.defaultSize(width: 1280, height: 720)
}
}
private struct ImportProgressDialog: View {
@@ -616,6 +616,22 @@ private struct ImportProgressDialog: View {
}
}
}
struct StudioSearchField: View {
let placeholder: String
@Binding var text: String
@FocusState private var focused: Bool
var body: some View {
HStack(spacing:7) {
Image(systemName:"magnifyingglass").foregroundStyle(.secondary)
TextField(placeholder,text:$text).textFieldStyle(.plain).focused($focused)
if !text.isEmpty {
Button { text = "";focused = true } label: { Image(systemName:"xmark.circle.fill").foregroundStyle(.secondary) }.buttonStyle(.plain).help("Clear search").accessibilityLabel("Clear search")
}
}.font(.system(size:12)).padding(.horizontal,9).padding(.vertical,7)
.background(Color(nsColor:.textBackgroundColor),in:RoundedRectangle(cornerRadius:7))
.overlay(RoundedRectangle(cornerRadius:7).strokeBorder(.primary.opacity(0.12)))
}
}
struct WaveformProgressCard: View {
let progress: WaveformJobProgress
let running: Bool
@@ -769,11 +785,35 @@ struct LyricsView: View {
ZStack {
Color.black
if let image = player.image {
Image(decorative: image, scale: 1).interpolation(.none).resizable().aspectRatio(contentMode: .fit).opacity(player.outputOpacity)
NativeVideoSurface(image:image,opacity:player.outputOpacity)
}
}
}
}
private struct NativeVideoSurface: NSViewRepresentable {
let image: CGImage
let opacity: Double
func makeNSView(context: Context) -> NativeVideoView { NativeVideoView() }
func updateNSView(_ view: NativeVideoView,context: Context) {
if view.image !== image { view.image = image;view.picture.contents = image }
view.picture.opacity = Float(opacity)
}
}
private final class NativeVideoView: NSView {
let picture = CALayer()
var image: CGImage?
override init(frame: NSRect) {
super.init(frame:frame);wantsLayer = true;layer?.backgroundColor = NSColor.black.cgColor
picture.contentsGravity = .resizeAspect;picture.magnificationFilter = .linear;picture.minificationFilter = .trilinear
picture.actions = ["contents":NSNull(),"bounds":NSNull(),"position":NSNull(),"opacity":NSNull()]
layer?.addSublayer(picture)
}
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
override func layout() { super.layout();picture.frame = bounds }
override func viewDidMoveToWindow() { super.viewDidMoveToWindow();updateScale() }
override func viewDidChangeBackingProperties() { super.viewDidChangeBackingProperties();updateScale() }
private func updateScale() { let scale = window?.backingScaleFactor ?? 1;layer?.contentsScale = scale;picture.contentsScale = scale;picture.frame = bounds }
}
/// This is another view of the same published CGImage used by the Video window.
/// It owns no decoder, audio player or clock, so seeking/pause/tempo stay identical.
private struct SidebarVideoMonitor: View {
@@ -882,7 +922,7 @@ struct LibraryView: View {
Text(source == "Library" ? "\(model.songs.count) songs in your collection" : model.currentVenueName).font(.callout).foregroundStyle(.secondary)
}
Spacer()
TextField("Search karaoke music",text:$search).textFieldStyle(.roundedBorder).frame(maxWidth:260)
StudioSearchField(placeholder:"Search music",text:$search).frame(maxWidth:260)
if source == "Library" {
Button { importing = true } label: { Label("Import Music",systemImage:"plus") }.buttonStyle(.bordered)
}
@@ -925,7 +965,7 @@ struct LibraryView: View {
.navigationSubtitle(model.currentVenueName)
.toolbar {
ToolbarItemGroup {
Button { studioSettingsModal = true } label: { Label("Settings",systemImage:"gearshape") }
if workspaceTab == "DJ Studio" { Button { studioSettingsModal = true } label: { Label("Settings",systemImage:"gearshape") } }
if workspaceTab == "Karaoke" {
Menu {
Button("Import Files or Folder…") { importing = true }
@@ -1490,7 +1530,7 @@ struct GoldStar: View {
}.frame(width:size,height:size).accessibilityHidden(true)
}
}
private struct GoldRating: View {
struct GoldRating: View {
@Binding var rating: Int
var body: some View {
HStack(spacing:2) { ForEach(1..<6) { value in Button { rating = rating == value ? 0 : value } label: { GoldStar(filled:value <= rating) }.buttonStyle(.plain).help("\(value) stars; click the selected rating to clear").accessibilityLabel("Set \(value) stars") } }