Browse Source

Small updates!

pull/101/head
Abhishek 4 years ago
parent
commit
fe78d4d4db
  1. 2
      Clocker/Panel/ParentPanelController+ModernSlider.swift
  2. 46
      Clocker/Panel/Rate Controller/UpcomingEventView.swift
  3. 3
      Clocker/Panel/UI/HourMarkerViewItem.xib
  4. 4
      Clocker/Panel/UI/TimeMarkerViewItem.swift

2
Clocker/Panel/ParentPanelController+ModernSlider.swift

@ -9,7 +9,7 @@ extension ParentPanelController: NSCollectionViewDataSource {
} }
func collectionView(_ collectionView: NSCollectionView, itemForRepresentedObjectAt indexPath: IndexPath) -> NSCollectionViewItem { func collectionView(_ collectionView: NSCollectionView, itemForRepresentedObjectAt indexPath: IndexPath) -> NSCollectionViewItem {
let item = collectionView.makeItem(withIdentifier: HourMarkerViewItem.reuseIdentifier, for: indexPath) as! HourMarkerViewItem let item = collectionView.makeItem(withIdentifier: TimeMarkerViewItem.reuseIdentifier, for: indexPath) as! TimeMarkerViewItem
item.setup(with: indexPath.item) item.setup(with: indexPath.item)
return item return item
} }

46
Clocker/Panel/Rate Controller/UpcomingEventView.swift

@ -88,53 +88,33 @@ class ThinScroller: NSScroller {
class DraggableClipView: NSClipView { class DraggableClipView: NSClipView {
private var clickPoint: NSPoint! private var clickPoint: NSPoint!
private var originalOrigin: NSPoint!
private var trackingArea: NSTrackingArea? private var trackingArea: NSTrackingArea?
override func mouseDown(with event: NSEvent) { override func mouseDown(with event: NSEvent) {
print("2")
super.mouseDown(with: event) super.mouseDown(with: event)
clickPoint = event.locationInWindow clickPoint = event.locationInWindow
originalOrigin = bounds.origin
print("Click point \(clickPoint!)")
let keepOn = true var gestureInProgress = true
while keepOn { while gestureInProgress {
let newEvent = window?.nextEvent(matching: [.leftMouseDragged, .leftMouseUp]) let newEvent = window?.nextEvent(matching: [.leftMouseDragged, .leftMouseUp, .leftMouseDown])
switch newEvent?.type { switch newEvent?.type {
case .leftMouseDragged: case .leftMouseDragged:
print("Hello 1") let newPoint = newEvent?.locationInWindow
let scale = (superview as? NSScrollView)?.magnification ?? 1.0 let xCoOrdinate = clickPoint.x - (newPoint?.x ?? 0)
let newPoint = event.locationInWindow let newOrigin = NSPoint(x: bounds.origin.x + xCoOrdinate,
let newOrigin = NSPoint(x: originalOrigin.x + (clickPoint.x - newPoint.x) / scale, y: 0)
y: originalOrigin.y + (clickPoint.y - newPoint.y) / scale)
let constrainedRect = constrainBoundsRect(NSRect(origin: newOrigin, size: bounds.size)) let constrainedRect = constrainBoundsRect(NSRect(origin: newOrigin, size: bounds.size))
scroll(to: constrainedRect.origin) scroll(to: constrainedRect.origin)
superview?.reflectScrolledClipView(self) superview?.reflectScrolledClipView(self)
return case .leftMouseDown:
clickPoint = event.locationInWindow
case .leftMouseUp:
clickPoint = nil
gestureInProgress = false
default: default:
print("Hello2") print("Default case is happening \(event.type)")
}
} }
} }
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() { override func updateTrackingAreas() {

3
Clocker/Panel/UI/HourMarkerViewItem.xib

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="18122" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct"> <document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="18122" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies> <dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="18122"/> <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="18122"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies> </dependencies>
@ -27,7 +26,7 @@
</constraints> </constraints>
<point key="canvasLocation" x="-17.5" y="283"/> <point key="canvasLocation" x="-17.5" y="283"/>
</customView> </customView>
<customObject id="p0M-E4-898" customClass="HourMarkerViewItem" customModule="Clocker" customModuleProvider="target"> <customObject id="p0M-E4-898" customClass="TimeMarkerViewItem" customModule="Clocker" customModuleProvider="target">
<connections> <connections>
<outlet property="verticalLineView" destination="9oV-Ab-UG7" id="0d5-Lu-gh3"/> <outlet property="verticalLineView" destination="9oV-Ab-UG7" id="0d5-Lu-gh3"/>
<outlet property="view" destination="Hz6-mo-xeY" id="9S0-wg-csq"/> <outlet property="view" destination="Hz6-mo-xeY" id="9S0-wg-csq"/>

4
Clocker/Panel/UI/HourMarkerViewItem.swift → Clocker/Panel/UI/TimeMarkerViewItem.swift

@ -2,13 +2,13 @@
import Cocoa import Cocoa
class HourMarkerViewItem: NSCollectionViewItem { class TimeMarkerViewItem: NSCollectionViewItem {
static let topConstraintIdentifier = "constrainFromTop" static let topConstraintIdentifier = "constrainFromTop"
static let reuseIdentifier = NSUserInterfaceItemIdentifier("HourMarkerViewItem") static let reuseIdentifier = NSUserInterfaceItemIdentifier("HourMarkerViewItem")
@IBOutlet var verticalLineView: NSView! @IBOutlet var verticalLineView: NSView!
func setup(with index: Int) { func setup(with index: Int) {
for constraint in view.constraints where constraint.identifier == HourMarkerViewItem.topConstraintIdentifier { for constraint in view.constraints where constraint.identifier == TimeMarkerViewItem.topConstraintIdentifier {
constraint.constant = index % 4 == 0 ? 0 : 20 constraint.constant = index % 4 == 0 ? 0 : 20
} }
verticalLineView.wantsLayer = true verticalLineView.wantsLayer = true
Loading…
Cancel
Save