removed unwanted bar
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import CoreText
|
||||
import SwiftUI
|
||||
import AppKit
|
||||
import QuartzCore
|
||||
@@ -105,7 +106,7 @@ class DJWaveMouseView: NSView {
|
||||
}
|
||||
override func mouseDragged(with event: NSEvent) { updateDrag(convert(event.locationInWindow,from:nil).x) }
|
||||
override func mouseUp(with event: NSEvent) {
|
||||
updateDrag(convert(event.locationInWindow,from:nil).x);drag = nil;freeze?(nil);NSCursor.openHand.set()
|
||||
updateDrag(convert(event.locationInWindow,from:nil).x);player?.endScrubbing();drag = nil;freeze?(nil);NSCursor.openHand.set()
|
||||
}
|
||||
private func updateDrag(_ x: Double) {
|
||||
guard let player,let drag else { return }
|
||||
@@ -113,10 +114,10 @@ class DJWaveMouseView: NSView {
|
||||
else if drag.mode == .seek {
|
||||
if relativeSeek {
|
||||
let target = min(player.duration,max(0,initialTime-(x-initialX)*drag.secondsPerPixel))
|
||||
if abs(player.time-target) > 0.0001 { player.seek(target) }
|
||||
if abs(player.time-target) > 0.0001 { player.scrub(to:target) }
|
||||
freeze?(drag.viewport+target-initialTime)
|
||||
NSCursor.closedHand.set()
|
||||
} else { player.seek(drag.viewport+x*drag.secondsPerPixel) }
|
||||
} else { player.scrub(to:drag.viewport+x*drag.secondsPerPixel) }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -310,7 +311,25 @@ final class DJNativeSpectrumView: DJWaveMouseView {
|
||||
if image != nil { waveformTileBuildCount += 1 }
|
||||
return image
|
||||
}
|
||||
private let markerFont = CTFontCreateWithName("Menlo-Bold" as CFString,9,nil)
|
||||
private var markerLines = [String:CTLine]()
|
||||
private func text(_ value: String,at point: NSPoint,color: NSColor) {
|
||||
(value as NSString).draw(at:point,withAttributes:[.font:NSFont.monospacedSystemFont(ofSize:9,weight:.semibold),.foregroundColor:color])
|
||||
guard let context = NSGraphicsContext.current?.cgContext else { return }
|
||||
let key = value+"|"+color.description
|
||||
let line: CTLine
|
||||
if let saved = markerLines[key] { line = saved }
|
||||
else {
|
||||
let attributes: [NSAttributedString.Key:Any] = [
|
||||
NSAttributedString.Key(kCTFontAttributeName as String):markerFont,
|
||||
NSAttributedString.Key(kCTForegroundColorAttributeName as String):color.cgColor
|
||||
]
|
||||
line = CTLineCreateWithAttributedString(NSAttributedString(string:value,attributes:attributes))
|
||||
if markerLines.count >= 128 { markerLines.removeAll(keepingCapacity:true) }
|
||||
markerLines[key] = line
|
||||
}
|
||||
context.saveGState();defer { context.restoreGState() }
|
||||
context.translateBy(x:point.x,y:point.y+10);context.scaleBy(x:1,y:-1)
|
||||
context.textMatrix = .identity;context.textPosition = .zero
|
||||
CTLineDraw(line,context)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user