Skip to content

Commit

Permalink
Effects update
Browse files Browse the repository at this point in the history
Beginnings of an effects tab. So far we have:
- Pulse
_ Color Cycle
- Pastel Cycle
  • Loading branch information
jacquesCedric committed Sep 12, 2016
1 parent 07a9f16 commit cdf79be
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 2 deletions.
40 changes: 39 additions & 1 deletion Nyxtheia/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
<font key="font" metaFont="system"/>
<tabViewItems>
<tabViewItem label="Colours" identifier="1" id="nK8-wM-nhR">
<view key="view" ambiguous="YES" id="TKg-tC-NBh">
<view key="view" id="TKg-tC-NBh">
<rect key="frame" x="10" y="33" width="304" height="54"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
Expand Down Expand Up @@ -163,6 +163,44 @@
</subviews>
</view>
</tabViewItem>
<tabViewItem label="Effects" identifier="" id="RlK-rG-m1K">
<view key="view" ambiguous="YES" id="nH5-2k-hTf">
<rect key="frame" x="10" y="33" width="304" height="54"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="c14-HV-Dkk">
<rect key="frame" x="110" y="10" width="84" height="32"/>
<buttonCell key="cell" type="push" title="Pulse" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="2sx-JF-KVT">
<behavior key="behavior" pushIn="YES" changeContents="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="pulseButton:" target="NzV-ef-CcW" id="pQh-Al-oA2"/>
</connections>
</button>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="aU1-9K-4KN">
<rect key="frame" x="209" y="10" width="84" height="32"/>
<buttonCell key="cell" type="push" title="Pastels" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="SYc-CS-Vbi">
<behavior key="behavior" pushIn="YES" changeContents="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="pastelsButton:" target="NzV-ef-CcW" id="MRk-Ng-Qn8"/>
</connections>
</button>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="QgU-xI-Eje">
<rect key="frame" x="11" y="10" width="84" height="32"/>
<buttonCell key="cell" type="push" title="Cycle" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="8E4-4G-Kfo">
<behavior key="behavior" pushIn="YES" changeContents="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="strobeButton:" target="NzV-ef-CcW" id="4DL-Qf-5PV"/>
</connections>
</button>
</subviews>
</view>
</tabViewItem>
</tabViewItems>
</tabView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="OiN-DF-Mok">
Expand Down
2 changes: 1 addition & 1 deletion Nyxtheia/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.2</string>
<string>1.3</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>LSMinimumSystemVersion</key>
Expand Down
68 changes: 68 additions & 0 deletions Nyxtheia/StatusMenuController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,74 @@ class StatusMenuController: NSObject, PreferencesWindowDelegate {
}


// Next three functions look after our effects, each one self-describing
@IBAction func strobeButton(sender: NSButton) {
let all = client.allLightTarget()
let prevColor = all.color

let priority = DISPATCH_QUEUE_PRIORITY_DEFAULT
dispatch_async(dispatch_get_global_queue(priority, 0)) {
while sender.state == NSOnState{
for i in 0...72 {
let j = Color.color(Double(i) * 5.0, saturation: 1.0)
all.setColor(j, duration: 0.5)
print(i)
if sender.state == NSOffState{
all.setColor(prevColor, duration: 0.5)
break
}
else {
sleep(1)
}
}
}
}
}

@IBAction func pulseButton(sender: NSButton) {
let all = client.allLightTarget()
let prevBrightness = all.brightness

let priority = DISPATCH_QUEUE_PRIORITY_DEFAULT
dispatch_async(dispatch_get_global_queue(priority, 0)) {
while sender.state == NSOnState{
all.setBrightness(1.0, duration: 3.0)
all.setBrightness(0.35, duration: 3.0)
if sender.state == NSOffState{
all.setBrightness(prevBrightness, duration: 0.5)
break
}
else {
sleep(5)
}
}
}
}

@IBAction func pastelsButton(sender: NSButton) {
let all = client.allLightTarget()
let prevColor = all.color

let priority = DISPATCH_QUEUE_PRIORITY_DEFAULT
dispatch_async(dispatch_get_global_queue(priority, 0)) {
while sender.state == NSOnState{
for i in 0...72 {
let j = Color.color(Double(i) * 5.0, saturation: 0.25)
all.setColor(j, duration: 0.5)
print(i)
if sender.state == NSOffState{
all.setColor(prevColor, duration: 0.5)
break
}
else {
sleep(1)
}
}
}
}
}


// Check if our preferences changed and update our access token
func preferencesDidUpdate() {
updateToken()
Expand Down

0 comments on commit cdf79be

Please sign in to comment.