diff --git a/Clocker/Clocker/en.lproj/Panel.xib b/Clocker/Clocker/en.lproj/Panel.xib index 37bca5f..6aacd4b 100755 --- a/Clocker/Clocker/en.lproj/Panel.xib +++ b/Clocker/Clocker/en.lproj/Panel.xib @@ -315,11 +315,11 @@ - + - + diff --git a/Clocker/Overall App/Themer.swift b/Clocker/Overall App/Themer.swift index 6fa75e4..e141317 100644 --- a/Clocker/Overall App/Themer.swift +++ b/Clocker/Overall App/Themer.swift @@ -187,8 +187,8 @@ extension Themer { return themeIndex == .light - ? NSImage(named: NSImage.Name("Settings"))! - : NSImage(named: NSImage.Name("Settings-White"))! + ? NSImage(named: NSImage.Name("Settings"))! + : NSImage(named: NSImage.Name("Settings-White"))! } func pinImage() -> NSImage { diff --git a/Clocker/Panel/Rate Controller/UpcomingEventView.swift b/Clocker/Panel/Rate Controller/UpcomingEventView.swift index 36aba0d..40fcf89 100644 --- a/Clocker/Panel/Rate Controller/UpcomingEventView.swift +++ b/Clocker/Panel/Rate Controller/UpcomingEventView.swift @@ -85,3 +85,67 @@ class ThinScroller: NSScroller { path.fill() } } + +class DraggableClipView: NSClipView { + private var clickPoint: NSPoint! + private var originalOrigin: NSPoint! + private var trackingArea: NSTrackingArea? + + override func mouseDown(with event: NSEvent) { + print("2") + super.mouseDown(with: event) + clickPoint = event.locationInWindow + originalOrigin = bounds.origin + print("Click point \(clickPoint!)") + + let keepOn = true + while keepOn { + let newEvent = window?.nextEvent(matching: [.leftMouseDragged, .leftMouseUp]) + switch newEvent?.type { + case .leftMouseDragged: + print("Hello 1") + let scale = (superview as? NSScrollView)?.magnification ?? 1.0 + let newPoint = event.locationInWindow + let newOrigin = NSPoint(x: originalOrigin.x + (clickPoint.x - newPoint.x) / scale, + y: originalOrigin.y + (clickPoint.y - newPoint.y) / scale) + let constrainedRect = constrainBoundsRect(NSRect(origin: newOrigin, size: bounds.size)) + scroll(to: constrainedRect.origin) + superview?.reflectScrolledClipView(self) + return + default: + print("Hello2") + } + } + } + + override func mouseDragged(with event: NSEvent) { + print("1") + super.mouseDragged(with: event) + // Account for a magnified parent scrollview. + let scale = (superview as? NSScrollView)?.magnification ?? 1.0 + let newPoint = event.locationInWindow + let newOrigin = NSPoint(x: originalOrigin.x + (clickPoint.x - newPoint.x) / scale, + y: originalOrigin.y + (clickPoint.y - newPoint.y) / scale) + let constrainedRect = constrainBoundsRect(NSRect(origin: newOrigin, size: bounds.size)) + scroll(to: constrainedRect.origin) + superview?.reflectScrolledClipView(self) + } + + override func mouseUp(with event: NSEvent) { + print("3") + super.mouseUp(with: event) + clickPoint = nil + } + + override func updateTrackingAreas() { + super.updateTrackingAreas() + + if let trackingArea = self.trackingArea { + removeTrackingArea(trackingArea) + } + + let options: NSTrackingArea.Options = [.mouseEnteredAndExited, .activeAlways, .enabledDuringMouseDrag, .inVisibleRect, .activeInKeyWindow] + let trackingArea = NSTrackingArea(rect: bounds, options: options, owner: self, userInfo: nil) + addTrackingArea(trackingArea) + } +}