Skip to content

Commit

Permalink
feat(*): Remove gesture info stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
dgurkaynak committed May 21, 2018
1 parent 38bde9a commit 0891990
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 204 deletions.
1 change: 0 additions & 1 deletion Penc/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, GestureOverlayWindowDelegate
self.activationHandler.activationModifierKey = preferences.activationModifierKey
self.activationHandler.activationTimeout = Double(preferences.activationSensitivity)
self.gestureOverlayWindow.swipeThreshold = preferences.swipeThreshold
self.placeholderWindowViewController.changeMode(preferences.showGestureInfo ? .MOVE : .NONE)
}

func onActivated(activationHandler: ActivationHandler) {
Expand Down
21 changes: 0 additions & 21 deletions Penc/Assets.xcassets/drag.imageset/Contents.json

This file was deleted.

Binary file removed Penc/Assets.xcassets/drag.imageset/drag@2x.png
Binary file not shown.
21 changes: 0 additions & 21 deletions Penc/Assets.xcassets/pinch.imageset/Contents.json

This file was deleted.

Binary file removed Penc/Assets.xcassets/pinch.imageset/pinch@2x.png
Binary file not shown.
82 changes: 10 additions & 72 deletions Penc/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

61 changes: 1 addition & 60 deletions Penc/PlaceholderWindowViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,73 +8,14 @@

import Cocoa

enum PlaceholderWindowInfoMode {
case NONE
case MOVE
}

class PlaceholderWindowViewController: NSViewController, NSWindowDelegate {
@IBOutlet var box: NSBox!
@IBOutlet var dragImage: NSImageView!
@IBOutlet var dragLabel1: NSTextField!
@IBOutlet var dragLabel2: NSTextField!
@IBOutlet var pinchImage: NSImageView!
@IBOutlet var pinchLabel: NSTextField!
var mode = PlaceholderWindowInfoMode.MOVE


override func viewDidLoad() {
super.viewDidLoad()
// Do view setup here.

}

func changeMode(_ mode: PlaceholderWindowInfoMode) {
if mode == .MOVE {
self.mode = .MOVE
self.box.fillColor = NSColor(calibratedRed: 0, green: 0, blue: 0, alpha: 0.5)
self.dragLabel1.stringValue = "Two finger drag to move"
self.dragLabel2.stringValue = "Two finger swipe to snap"
self.dragLabel2.alphaValue = 1
self.showInfoIfApplicable()
} else {
self.mode = PlaceholderWindowInfoMode.NONE
self.box.fillColor = NSColor(calibratedRed: 0, green: 0, blue: 0, alpha: 0.25)
self.hideInfo()
}
}

func hideInfo() {
self.dragImage.alphaValue = 0
self.dragLabel1.alphaValue = 0
self.dragLabel2.alphaValue = 0
self.pinchImage.alphaValue = 0
self.pinchLabel.alphaValue = 0
}

func showInfo() {
self.box.fillColor = NSColor(calibratedRed: 0, green: 0, blue: 0, alpha: 0.5)
self.dragImage.alphaValue = 1
self.dragLabel1.alphaValue = 1
self.dragLabel2.alphaValue = 1
self.pinchImage.alphaValue = 1
self.pinchLabel.alphaValue = 1
}

func showInfoIfApplicable() {
if let window = self.view.window {
let show = window.frame.height > 300 && window.frame.width > 500
if show {
self.showInfo()
} else {
self.hideInfo()
}
}
}

func windowDidResize(_ notification: Notification) {
guard self.mode != .NONE else { return }
self.showInfoIfApplicable()
// self.box.fillColor = NSColor(calibratedRed: 0, green: 0, blue: 0, alpha: 0.5)
}
}

Expand Down
17 changes: 0 additions & 17 deletions Penc/Preferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ final class Preferences {
private static let key_activationModifierKey = "activationModifierKey"
private static let key_activationSensitivity = "activationSensitivity"
private static let key_swipeThreshold = "swipeThreshold"
private static let key_showGestureInfo = "showGestureInfo"
private static let key_disabledApps = "disabledApps"

weak var delegate: PreferencesDelegate?
Expand All @@ -46,13 +45,6 @@ final class Preferences {
}
}

var showGestureInfo: Bool {
didSet {
UserDefaults.standard.set(self.showGestureInfo, forKey: Preferences.key_showGestureInfo)
self.delegate?.onPreferencesChanged(preferences: self)
}
}

var disabledApps: [String] {
didSet {
UserDefaults.standard.set(self.disabledApps, forKey: Preferences.key_disabledApps)
Expand Down Expand Up @@ -95,14 +87,6 @@ final class Preferences {
self.swipeThreshold = swipeThreshold!
}

let showGestureInfo = defaults.object(forKey: Preferences.key_showGestureInfo) as? Bool
if showGestureInfo == nil {
self.showGestureInfo = true
UserDefaults.standard.set(self.showGestureInfo, forKey: Preferences.key_showGestureInfo)
} else {
self.showGestureInfo = showGestureInfo!
}

let disabledApps = defaults.object(forKey: Preferences.key_disabledApps) as? [String]
if disabledApps == nil {
self.disabledApps = []
Expand All @@ -121,7 +105,6 @@ final class Preferences {
self.activationModifierKey = .command
self.activationSensitivity = 0.3
self.swipeThreshold = 25.0
self.showGestureInfo = true
self.disabledApps = []
}

Expand Down
12 changes: 0 additions & 12 deletions Penc/PreferencesViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class PreferencesViewController: NSViewController {
@IBOutlet var launchAtLoginCheckbox: NSButton!
@IBOutlet var resetDefaultsButton: NSButton!
@IBOutlet var modifierKeyPopUpButton: NSPopUpButton!
@IBOutlet var showGestureInfoCheckbox: NSButton!

override func viewDidLoad() {
super.viewDidLoad()
Expand All @@ -38,9 +37,6 @@ class PreferencesViewController: NSViewController {
self.swipeSensitivitySlider.target = self
self.swipeSensitivitySlider.action = #selector(onSwipeSensitivitySliderChange)

self.showGestureInfoCheckbox.target = self
self.showGestureInfoCheckbox.action = #selector(onShowGestureInfoCheckboxChange)

self.launchAtLoginCheckbox.target = self
self.launchAtLoginCheckbox.action = #selector(onLaunchAtLoginCheckboxChange)

Expand Down Expand Up @@ -74,9 +70,6 @@ class PreferencesViewController: NSViewController {
self.swipeSensitivitySlider.floatValue = sliderValue
self.swipeSensitivityLabel.stringValue = String(format: "%.2f", sliderValue)

self.showGestureInfoCheckbox.state = Preferences.shared.showGestureInfo ? .on : .off
self.showGestureInfoCheckbox.state = Preferences.shared.showGestureInfo ? .on : .off

self.launchAtLoginCheckbox.state = Preferences.shared.launchAtLogin ? .on : .off
}

Expand Down Expand Up @@ -112,11 +105,6 @@ class PreferencesViewController: NSViewController {
log.info("Set swipe threshold \(Preferences.shared.swipeThreshold)")
}

@objc private func onShowGestureInfoCheckboxChange() {
Preferences.shared.showGestureInfo = self.showGestureInfoCheckbox.state == .on
log.info("Set showing display gesture info to \(Preferences.shared.showGestureInfo)")
}

@objc private func onLaunchAtLoginCheckboxChange() {
log.info("Setting launch at login to \(self.launchAtLoginCheckbox.state == .on)")
if !Preferences.shared.setLaunchAtLogin(self.launchAtLoginCheckbox.state == .on) {
Expand Down

0 comments on commit 0891990

Please # to comment.