Skip to content

Commit

Permalink
Refactors dimStartFromChange and dimFadeToChange
Browse files Browse the repository at this point in the history
  • Loading branch information
valeriyvan committed Nov 18, 2018
1 parent e084ad5 commit 54d1ae9
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions Aerial/Source/Controllers/PreferencesWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1222,19 +1222,17 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo
}

@IBAction func dimStartFromChange(_ sender: NSSliderCell) {
let timeManagement = TimeManagement.sharedInstance
guard let event = NSApplication.shared.currentEvent else {
return
}
guard let event = NSApplication.shared.currentEvent else { return }

if event.type != .leftMouseUp && event.type != .leftMouseDown && event.type != .leftMouseDragged {
guard [.leftMouseUp, .leftMouseDown, .leftMouseDragged].contains(event.type) else {
//warnLog("Unexepected event type \(event.type)")
return
}

let timeManagement = TimeManagement.sharedInstance
if event.type == .leftMouseUp {
if savedBrightness != nil {
timeManagement.setBrightness(level: savedBrightness!)
if let brightness = savedBrightness {
timeManagement.setBrightness(level: brightness)
savedBrightness = nil
}
preferences.startDim = sender.doubleValue
Expand All @@ -1248,18 +1246,16 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo
}

@IBAction func dimFadeToChange(_ sender: NSSliderCell) {
let timeManagement = TimeManagement.sharedInstance
guard let event = NSApplication.shared.currentEvent else {
return
}
guard let event = NSApplication.shared.currentEvent else { return }

if event.type != .leftMouseUp && event.type != .leftMouseDown && event.type != .leftMouseDragged {
if ![.leftMouseUp, .leftMouseDown, .leftMouseDragged].contains(event.type) {
//warnLog("Unexepected event type \(event.type)")
}

let timeManagement = TimeManagement.sharedInstance
if event.type == .leftMouseUp {
if savedBrightness != nil {
timeManagement.setBrightness(level: savedBrightness!)
if let brightness = savedBrightness {
timeManagement.setBrightness(level: brightness)
savedBrightness = nil
}
preferences.endDim = sender.doubleValue
Expand Down

0 comments on commit 54d1ae9

Please sign in to comment.