Monorepo for Aesthetic.Computer aesthetic.computer
4
fork

Configure Feed

Select the types of activity you want to include in your feed.

Remove floating palette full-surface dragging

authored by

Esteban Uribe and committed by
prompt.ac/@jeffrey
2e7b1067 efbbac34

-51
-51
slab/menuband/Sources/MenuBand/FloatingPlayPalette.swift
··· 294 294 private let closeSize: CGFloat = 18 295 295 private let hintHeight: CGFloat = 42 296 296 private var waveformHeightConstraint: NSLayoutConstraint? 297 - private var paletteDragStartMouse: NSPoint? 298 - private var paletteDragStartWindowOrigin: NSPoint? 299 - private var paletteDragActive = false 300 297 301 298 init(menuBand: MenuBandController) { 302 299 self.menuBand = menuBand ··· 308 305 self.pianoView = FloatingPianoView(menuBand: menuBand, pianoScale: pianoScale) 309 306 super.init(frame: NSRect(origin: .zero, size: .zero)) 310 307 wantsLayer = true 311 - let dragRecognizer = NSPanGestureRecognizer(target: self, action: #selector(handlePalettePan(_:))) 312 - addGestureRecognizer(dragRecognizer) 313 308 314 309 waveformView.menuBand = menuBand 315 310 waveformView.translatesAutoresizingMaskIntoConstraints = false ··· 595 590 596 591 @objc private func closeClicked(_ sender: NSButton) { 597 592 onClose?() 598 - } 599 - 600 - @objc private func handlePalettePan(_ recognizer: NSPanGestureRecognizer) { 601 - let location = recognizer.location(in: self) 602 - switch recognizer.state { 603 - case .began: 604 - guard shouldBeginPaletteDrag(at: location) else { 605 - paletteDragActive = false 606 - return 607 - } 608 - paletteDragStartMouse = NSEvent.mouseLocation 609 - paletteDragStartWindowOrigin = window?.frame.origin 610 - paletteDragActive = true 611 - NSCursor.closedHand.set() 612 - case .changed: 613 - guard paletteDragActive, 614 - let window, 615 - let startMouse = paletteDragStartMouse, 616 - let startOrigin = paletteDragStartWindowOrigin else { return } 617 - let mouse = NSEvent.mouseLocation 618 - let nextOrigin = NSPoint( 619 - x: startOrigin.x + mouse.x - startMouse.x, 620 - y: startOrigin.y + mouse.y - startMouse.y 621 - ) 622 - NSAnimationContext.runAnimationGroup { context in 623 - context.duration = 0 624 - context.allowsImplicitAnimation = false 625 - window.setFrameOrigin(nextOrigin) 626 - } 627 - case .ended, .cancelled, .failed: 628 - if paletteDragActive { 629 - NSCursor.openHand.set() 630 - } 631 - paletteDragStartMouse = nil 632 - paletteDragStartWindowOrigin = nil 633 - paletteDragActive = false 634 - default: 635 - break 636 - } 637 - } 638 - 639 - private func shouldBeginPaletteDrag(at location: NSPoint) -> Bool { 640 - if closeButton.frame.contains(location) || pianoView.frame.contains(location) { 641 - return false 642 - } 643 - return true 644 593 } 645 594 } 646 595