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 {
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)
return item
}

46
Clocker/Panel/Rate Controller/UpcomingEventView.swift

@ -88,53 +88,33 @@ class ThinScroller: NSScroller {
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])
var gestureInProgress = true
while gestureInProgress {
let newEvent = window?.nextEvent(matching: [.leftMouseDragged, .leftMouseUp, .leftMouseDown])
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 newPoint = newEvent?.locationInWindow
let xCoOrdinate = clickPoint.x - (newPoint?.x ?? 0)
let newOrigin = NSPoint(x: bounds.origin.x + xCoOrdinate,
y: 0)
let constrainedRect = constrainBoundsRect(NSRect(origin: newOrigin, size: bounds.size))
scroll(to: constrainedRect.origin)
superview?.reflectScrolledClipView(self)
return
case .leftMouseDown:
clickPoint = event.locationInWindow
case .leftMouseUp:
clickPoint = nil
gestureInProgress = false
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() {

3
Clocker/Panel/UI/HourMarkerViewItem.xib

@ -1,7 +1,6 @@
<?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">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="18122"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
@ -27,7 +26,7 @@
</constraints>
<point key="canvasLocation" x="-17.5" y="283"/>
</customView>
<customObject id="p0M-E4-898" customClass="HourMarkerViewItem" customModule="Clocker" customModuleProvider="target">
<customObject id="p0M-E4-898" customClass="TimeMarkerViewItem" customModule="Clocker" customModuleProvider="target">
<connections>
<outlet property="verticalLineView" destination="9oV-Ab-UG7" id="0d5-Lu-gh3"/>
<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
class HourMarkerViewItem: NSCollectionViewItem {
class TimeMarkerViewItem: NSCollectionViewItem {
static let topConstraintIdentifier = "constrainFromTop"
static let reuseIdentifier = NSUserInterfaceItemIdentifier("HourMarkerViewItem")
@IBOutlet var verticalLineView: NSView!
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
}
verticalLineView.wantsLayer = true
Loading…
Cancel
Save