Browse Source

New Floating Window additions.

v1.2.4
Abhishek Banthia 9 years ago
parent
commit
598ce58677
  1. 119
      Clocker/Appearance Tab/en.lproj/CLAppearanceView.xib
  2. 2
      Clocker/ApplicationDelegate.h
  3. 26
      Clocker/ApplicationDelegate.m
  4. 332
      Clocker/Floating Window/CLFloatingWindowController.m

119
Clocker/Appearance Tab/en.lproj/CLAppearanceView.xib

@ -15,11 +15,11 @@
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView id="Hz6-mo-xeY">
<rect key="frame" x="0.0" y="0.0" width="439" height="463"/>
<rect key="frame" x="0.0" y="0.0" width="439" height="524"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" preferredMaxLayoutWidth="60" translatesAutoresizingMaskIntoConstraints="NO" id="iVw-cq-zLz">
<rect key="frame" x="188" y="349" width="64" height="18"/>
<rect key="frame" x="188" y="410" width="64" height="18"/>
<constraints>
<constraint firstAttribute="height" constant="18" id="2DP-wK-Ga8"/>
<constraint firstAttribute="width" constant="60" id="KEa-ei-G2i"/>
@ -31,7 +31,7 @@
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" preferredMaxLayoutWidth="100" translatesAutoresizingMaskIntoConstraints="NO" id="5TC-RQ-gzI">
<rect key="frame" x="168" y="411" width="104" height="18"/>
<rect key="frame" x="168" y="472" width="104" height="18"/>
<constraints>
<constraint firstAttribute="height" constant="18" id="gWc-u4-D8E"/>
<constraint firstAttribute="width" constant="100" id="nh0-5K-Aa0"/>
@ -43,15 +43,15 @@
</textFieldCell>
</textField>
<segmentedControl toolTip="Choose a theme for the main panel!" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="5tI-fU-0lZ">
<rect key="frame" x="158" y="318" width="124" height="24"/>
<rect key="frame" x="147" y="379" width="147" height="24"/>
<constraints>
<constraint firstAttribute="width" constant="120" id="dW5-vG-EwD"/>
<constraint firstAttribute="width" constant="143" id="dW5-vG-EwD"/>
</constraints>
<segmentedCell key="cell" borderStyle="border" alignment="left" style="rounded" trackingMode="selectOne" id="3ED-rf-SN8">
<font key="font" size="12" name="SFUIDisplay-Light"/>
<segments>
<segment label="Default"/>
<segment label="Black" toolTip="Customize the timezone panel by selecting a theme!" selected="YES" tag="1"/>
<segment label="Default" width="70"/>
<segment label="Black" toolTip="Customize the timezone panel by selecting a theme!" width="70" selected="YES" tag="1"/>
</segments>
</segmentedCell>
<connections>
@ -60,7 +60,7 @@
</connections>
</segmentedControl>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" preferredMaxLayoutWidth="150" translatesAutoresizingMaskIntoConstraints="NO" id="YQi-x8-6f8">
<rect key="frame" x="143" y="287" width="154" height="18"/>
<rect key="frame" x="143" y="348" width="154" height="18"/>
<constraints>
<constraint firstAttribute="height" constant="18" id="eY8-bV-QLM"/>
<constraint firstAttribute="width" constant="150" id="n8S-fR-UtY"/>
@ -72,7 +72,7 @@
</textFieldCell>
</textField>
<segmentedControl toolTip="Select a time-format!" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="OrL-Ix-fmY">
<rect key="frame" x="102" y="380" width="236" height="24"/>
<rect key="frame" x="102" y="441" width="236" height="24"/>
<constraints>
<constraint firstAttribute="width" constant="232" id="uOJ-Mi-Fin"/>
</constraints>
@ -88,8 +88,8 @@
<binding destination="WGI-5h-l6M" name="selectedIndex" keyPath="values.is24HourFormatSelected" id="UsS-ER-9M9"/>
</connections>
</segmentedControl>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="3d9-qg-dNb">
<rect key="frame" x="130" y="172" width="179" height="18"/>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" preferredMaxLayoutWidth="175" translatesAutoresizingMaskIntoConstraints="NO" id="3d9-qg-dNb">
<rect key="frame" x="130" y="175" width="179" height="18"/>
<constraints>
<constraint firstAttribute="height" constant="18" id="MdL-Dh-02n"/>
<constraint firstAttribute="width" constant="175" id="hHO-Wa-gmc"/>
@ -100,8 +100,8 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="pqa-Qg-U8Y">
<rect key="frame" x="130" y="144" width="179" height="19"/>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" preferredMaxLayoutWidth="175" translatesAutoresizingMaskIntoConstraints="NO" id="pqa-Qg-U8Y">
<rect key="frame" x="130" y="147" width="179" height="19"/>
<constraints>
<constraint firstAttribute="width" constant="175" id="B2I-0j-0W0"/>
</constraints>
@ -115,7 +115,7 @@
</connections>
</textField>
<segmentedControl verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="atA-2r-FXV">
<rect key="frame" x="179" y="116" width="84" height="24"/>
<rect key="frame" x="179" y="119" width="84" height="24"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="BqM-4F-6Ta"/>
<constraint firstAttribute="width" constant="80" id="ZeK-lO-tUa"/>
@ -123,8 +123,8 @@
<segmentedCell key="cell" borderStyle="border" alignment="left" style="rounded" trackingMode="selectOne" id="rIg-AP-wGG">
<font key="font" size="12" name="SFUIDisplay-Light"/>
<segments>
<segment label="Yes" selected="YES"/>
<segment label="No" tag="1"/>
<segment label="Yes" width="38" selected="YES"/>
<segment label="No" width="38" tag="1"/>
</segments>
</segmentedCell>
<connections>
@ -132,8 +132,8 @@
<binding destination="WGI-5h-l6M" name="selectedIndex" keyPath="values.showDate" id="Qee-Dc-Piu"/>
</connections>
</segmentedControl>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="kEn-QZ-niZ">
<rect key="frame" x="130" y="95" width="179" height="18"/>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" preferredMaxLayoutWidth="175" translatesAutoresizingMaskIntoConstraints="NO" id="kEn-QZ-niZ">
<rect key="frame" x="130" y="98" width="179" height="18"/>
<constraints>
<constraint firstAttribute="height" constant="18" id="2fd-f6-8cD"/>
<constraint firstAttribute="width" constant="175" id="D0w-xz-gkw"/>
@ -148,7 +148,7 @@
</connections>
</textField>
<segmentedControl verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="XwV-hy-YiP">
<rect key="frame" x="178" y="67" width="84" height="24"/>
<rect key="frame" x="178" y="70" width="84" height="24"/>
<constraints>
<constraint firstAttribute="width" constant="80" id="dBz-ZQ-BF1"/>
<constraint firstAttribute="height" constant="21" id="y8c-hZ-MtI"/>
@ -156,8 +156,8 @@
<segmentedCell key="cell" borderStyle="border" alignment="left" style="rounded" trackingMode="selectOne" id="18N-XQ-ANm">
<font key="font" size="12" name="SFUIDisplay-Light"/>
<segments>
<segment label="Yes"/>
<segment label="No" selected="YES" tag="1"/>
<segment label="Yes" width="38"/>
<segment label="No" width="38" selected="YES" tag="1"/>
</segments>
</segmentedCell>
<connections>
@ -166,23 +166,24 @@
</connections>
</segmentedControl>
<segmentedControl verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="72r-oi-X0f">
<rect key="frame" x="184" y="201" width="71" height="24"/>
<rect key="frame" x="180" y="262" width="79" height="24"/>
<constraints>
<constraint firstAttribute="width" constant="67" id="H8w-wg-vel"/>
<constraint firstAttribute="width" constant="75" id="H8w-wg-vel"/>
</constraints>
<segmentedCell key="cell" borderStyle="border" alignment="left" style="rounded" trackingMode="selectOne" id="FMr-PO-czs">
<font key="font" size="12" name="SFUIDisplay-Light"/>
<segments>
<segment label="Yes" width="32"/>
<segment label="No" width="32" selected="YES" tag="1"/>
<segment label="Yes" width="36"/>
<segment label="No" width="36" selected="YES" tag="1"/>
</segments>
</segmentedCell>
<connections>
<action selector="showFutureSlider:" target="-2" id="n4K-kX-aaz"/>
<binding destination="WGI-5h-l6M" name="selectedIndex" keyPath="values.displayFutureSlider" id="zRQ-mQ-qBp"/>
</connections>
</segmentedControl>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" preferredMaxLayoutWidth="120" translatesAutoresizingMaskIntoConstraints="NO" id="HTZ-1V-qZb">
<rect key="frame" x="158" y="232" width="124" height="19"/>
<rect key="frame" x="158" y="293" width="124" height="19"/>
<constraints>
<constraint firstAttribute="width" constant="120" id="1Lv-wC-hEM"/>
</constraints>
@ -192,14 +193,25 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" preferredMaxLayoutWidth="120" translatesAutoresizingMaskIntoConstraints="NO" id="76h-05-go1">
<rect key="frame" x="158" y="237" width="124" height="19"/>
<constraints>
<constraint firstAttribute="width" constant="120" id="Odw-mb-nT5"/>
</constraints>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" title="Clocker should be" id="ahg-YF-MX8">
<font key="font" size="13" name="SFUIDisplay-Light"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<box verticalHuggingPriority="750" title="Box" boxType="separator" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="MHe-dB-GZr">
<rect key="frame" x="0.0" y="192" width="439" height="5"/>
<rect key="frame" x="0.0" y="195" width="439" height="5"/>
<color key="borderColor" white="0.0" alpha="0.41999999999999998" colorSpace="calibratedWhite"/>
<color key="fillColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<font key="titleFont" metaFont="system"/>
</box>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="LC1-Sx-uav">
<rect key="frame" x="130" y="43" width="179" height="18"/>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" preferredMaxLayoutWidth="175" translatesAutoresizingMaskIntoConstraints="NO" id="LC1-Sx-uav">
<rect key="frame" x="130" y="46" width="179" height="18"/>
<constraints>
<constraint firstAttribute="width" constant="175" id="Pdc-78-vzv"/>
<constraint firstAttribute="height" constant="18" id="hsh-i8-ULY"/>
@ -214,7 +226,7 @@
</connections>
</textField>
<segmentedControl verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="JR8-v7-K0w">
<rect key="frame" x="178" y="15" width="84" height="24"/>
<rect key="frame" x="178" y="18" width="84" height="24"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="Xof-eY-ZUl"/>
<constraint firstAttribute="width" constant="80" id="msH-Xd-mrp"/>
@ -222,8 +234,8 @@
<segmentedCell key="cell" borderStyle="border" alignment="left" style="rounded" trackingMode="selectOne" id="SLe-HO-6so">
<font key="font" size="12" name="SFUIDisplay-Light"/>
<segments>
<segment label="Yes"/>
<segment label="No" selected="YES" tag="1"/>
<segment label="Yes" width="38"/>
<segment label="No" width="38" selected="YES" tag="1"/>
</segments>
</segmentedCell>
<connections>
@ -231,8 +243,8 @@
<binding destination="WGI-5h-l6M" name="selectedIndex" keyPath="values.showPlaceName" id="374-hG-giL"/>
</connections>
</segmentedControl>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="X5s-Mc-Yfo">
<rect key="frame" x="130" y="437" width="179" height="18"/>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" preferredMaxLayoutWidth="175" translatesAutoresizingMaskIntoConstraints="NO" id="X5s-Mc-Yfo">
<rect key="frame" x="130" y="498" width="179" height="18"/>
<constraints>
<constraint firstAttribute="width" constant="175" id="YaE-Og-A4W"/>
<constraint firstAttribute="height" constant="18" id="bTT-ve-oW9"/>
@ -244,15 +256,15 @@
</textFieldCell>
</textField>
<segmentedControl verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="1eh-BT-2fK">
<rect key="frame" x="155" y="256" width="129" height="24"/>
<rect key="frame" x="155" y="317" width="129" height="24"/>
<constraints>
<constraint firstAttribute="width" constant="125" id="u9T-ks-rqA"/>
</constraints>
<segmentedCell key="cell" borderStyle="border" alignment="left" style="rounded" trackingMode="selectOne" id="ZV9-ih-faz">
<font key="font" size="12" name="SFUIDisplay-Light"/>
<segments>
<segment label="Relative"/>
<segment label="Actual" selected="YES" tag="1"/>
<segment label="Relative" width="60"/>
<segment label="Actual" width="60" selected="YES" tag="1"/>
</segments>
</segmentedCell>
<connections>
@ -261,7 +273,7 @@
</connections>
</segmentedControl>
<visualEffectView wantsLayer="YES" appearanceType="vibrantLight" alphaValue="0.90000000000000002" blendingMode="withinWindow" state="followsWindowActiveState" translatesAutoresizingMaskIntoConstraints="NO" id="kHi-mx-HdE">
<rect key="frame" x="0.0" y="0.0" width="439" height="195"/>
<rect key="frame" x="0.0" y="0.0" width="439" height="198"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="WDP-d4-eNj">
<rect key="frame" x="57" y="85" width="324" height="39"/>
@ -280,8 +292,8 @@
</textField>
</subviews>
<constraints>
<constraint firstAttribute="height" constant="195" id="JD3-oH-lbP"/>
<constraint firstItem="WDP-d4-eNj" firstAttribute="centerY" secondItem="kHi-mx-HdE" secondAttribute="centerY" constant="-7" id="YZN-MB-zQ8"/>
<constraint firstAttribute="height" constant="198" id="JD3-oH-lbP"/>
<constraint firstItem="WDP-d4-eNj" firstAttribute="centerY" secondItem="kHi-mx-HdE" secondAttribute="centerY" constant="-5.5" id="YZN-MB-zQ8"/>
<constraint firstItem="WDP-d4-eNj" firstAttribute="centerX" secondItem="kHi-mx-HdE" secondAttribute="centerX" id="xlO-Y9-7Dn"/>
</constraints>
<shadow key="shadow" blurRadius="10">
@ -291,17 +303,35 @@
<binding destination="-2" name="hidden" keyPath="self.enableOptions" id="4El-Z9-rMM"/>
</connections>
</visualEffectView>
<segmentedControl verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="SbG-Qh-ziy">
<rect key="frame" x="53" y="206" width="334" height="24"/>
<constraints>
<constraint firstAttribute="width" constant="330" id="T2D-fB-93g"/>
</constraints>
<segmentedCell key="cell" borderStyle="border" alignment="left" style="rounded" trackingMode="selectOne" id="zOl-EY-gEX">
<font key="font" size="12" name="SFUIDisplay-Light"/>
<segments>
<segment label="Attached to the menu-bar" width="164"/>
<segment label="In Floating mode" width="163" selected="YES" tag="1"/>
</segments>
</segmentedCell>
<connections>
<action selector="displayModeChanged:" target="-2" id="qVM-K8-rRO"/>
<binding destination="WGI-5h-l6M" name="selectedIndex" keyPath="values.displayAppAsForegroundApp" id="Fuh-BG-SYM"/>
</connections>
</segmentedControl>
</subviews>
<constraints>
<constraint firstItem="5TC-RQ-gzI" firstAttribute="top" secondItem="X5s-Mc-Yfo" secondAttribute="bottom" constant="8" id="1Wi-S2-cSq"/>
<constraint firstItem="72r-oi-X0f" firstAttribute="top" secondItem="HTZ-1V-qZb" secondAttribute="bottom" constant="8" id="23z-Z7-vpe"/>
<constraint firstItem="LC1-Sx-uav" firstAttribute="centerX" secondItem="Hz6-mo-xeY" secondAttribute="centerX" id="2M5-Z9-HrL"/>
<constraint firstItem="MHe-dB-GZr" firstAttribute="top" secondItem="72r-oi-X0f" secondAttribute="bottom" constant="8" id="3Lr-IT-EsF"/>
<constraint firstItem="SbG-Qh-ziy" firstAttribute="top" secondItem="76h-05-go1" secondAttribute="bottom" constant="8" id="4dL-4I-aA9"/>
<constraint firstItem="YQi-x8-6f8" firstAttribute="centerX" secondItem="Hz6-mo-xeY" secondAttribute="centerX" id="6LU-d8-lKX"/>
<constraint firstItem="3d9-qg-dNb" firstAttribute="top" secondItem="MHe-dB-GZr" secondAttribute="bottom" constant="4" id="BZ1-zf-1At"/>
<constraint firstItem="3d9-qg-dNb" firstAttribute="centerX" secondItem="Hz6-mo-xeY" secondAttribute="centerX" id="FBj-0N-ltc"/>
<constraint firstAttribute="bottom" secondItem="kHi-mx-HdE" secondAttribute="bottom" id="GqC-hp-yU9"/>
<constraint firstItem="OrL-Ix-fmY" firstAttribute="centerX" secondItem="Hz6-mo-xeY" secondAttribute="centerX" id="JtZ-ra-RaC"/>
<constraint firstItem="SbG-Qh-ziy" firstAttribute="centerX" secondItem="Hz6-mo-xeY" secondAttribute="centerX" id="MAr-WP-e6V"/>
<constraint firstItem="kEn-QZ-niZ" firstAttribute="top" secondItem="atA-2r-FXV" secondAttribute="bottom" constant="5" id="O8m-uk-Ppx"/>
<constraint firstItem="kHi-mx-HdE" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" id="Oan-Iw-Pp1"/>
<constraint firstItem="X5s-Mc-Yfo" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" constant="8" id="OeD-4K-q6Y"/>
@ -315,13 +345,16 @@
<constraint firstItem="atA-2r-FXV" firstAttribute="top" secondItem="pqa-Qg-U8Y" secondAttribute="bottom" constant="5" id="RdE-wy-6vH"/>
<constraint firstItem="MHe-dB-GZr" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" id="TyR-gg-RLi"/>
<constraint firstItem="pqa-Qg-U8Y" firstAttribute="top" secondItem="3d9-qg-dNb" secondAttribute="bottom" constant="9" id="Uc0-mI-ciF"/>
<constraint firstItem="5tI-fU-0lZ" firstAttribute="centerX" secondItem="Hz6-mo-xeY" secondAttribute="centerX" id="Vkb-QV-unN"/>
<constraint firstItem="5tI-fU-0lZ" firstAttribute="centerX" secondItem="Hz6-mo-xeY" secondAttribute="centerX" constant="1" id="Vkb-QV-unN"/>
<constraint firstItem="HTZ-1V-qZb" firstAttribute="centerX" secondItem="Hz6-mo-xeY" secondAttribute="centerX" id="Wet-hO-O6U"/>
<constraint firstItem="YQi-x8-6f8" firstAttribute="top" secondItem="5tI-fU-0lZ" secondAttribute="bottom" constant="15" id="WoY-W4-XuS"/>
<constraint firstItem="JR8-v7-K0w" firstAttribute="centerX" secondItem="Hz6-mo-xeY" secondAttribute="centerX" id="Wye-84-JgC"/>
<constraint firstItem="76h-05-go1" firstAttribute="centerX" secondItem="Hz6-mo-xeY" secondAttribute="centerX" id="XcN-rp-Cxq"/>
<constraint firstItem="iVw-cq-zLz" firstAttribute="top" secondItem="OrL-Ix-fmY" secondAttribute="bottom" constant="15" id="XgM-Wl-Xap"/>
<constraint firstItem="MHe-dB-GZr" firstAttribute="top" secondItem="SbG-Qh-ziy" secondAttribute="bottom" constant="10" id="Xmd-cX-Eic"/>
<constraint firstItem="iVw-cq-zLz" firstAttribute="centerX" secondItem="Hz6-mo-xeY" secondAttribute="centerX" id="Zh8-Vn-VxM"/>
<constraint firstItem="5tI-fU-0lZ" firstAttribute="top" secondItem="iVw-cq-zLz" secondAttribute="bottom" constant="8" id="bo6-s2-Vfj"/>
<constraint firstItem="76h-05-go1" firstAttribute="top" secondItem="72r-oi-X0f" secondAttribute="bottom" constant="8" id="cgM-DZ-Mzt"/>
<constraint firstItem="kEn-QZ-niZ" firstAttribute="centerX" secondItem="Hz6-mo-xeY" secondAttribute="centerX" id="eU3-c4-cnM"/>
<constraint firstItem="1eh-BT-2fK" firstAttribute="centerX" secondItem="Hz6-mo-xeY" secondAttribute="centerX" id="fvI-By-5Ef"/>
<constraint firstAttribute="trailing" secondItem="MHe-dB-GZr" secondAttribute="trailing" id="jL7-Cv-YuY"/>
@ -332,7 +365,7 @@
<constraint firstItem="XwV-hy-YiP" firstAttribute="centerX" secondItem="Hz6-mo-xeY" secondAttribute="centerX" id="x6a-GW-bOn"/>
<constraint firstItem="LC1-Sx-uav" firstAttribute="top" secondItem="XwV-hy-YiP" secondAttribute="bottom" constant="8" id="xFV-GA-ozB"/>
</constraints>
<point key="canvasLocation" x="186.5" y="314.5"/>
<point key="canvasLocation" x="186.5" y="269"/>
</customView>
<userDefaultsController representsSharedInstance="YES" id="WGI-5h-l6M"/>
</objects>

2
Clocker/ApplicationDelegate.h

@ -28,11 +28,13 @@
#import "MenubarController.h"
#import "PanelController.h"
#import "CLFloatingWindowController.h"
@interface ApplicationDelegate : NSObject <NSApplicationDelegate, PanelControllerDelegate>
@property (nonatomic, strong) MenubarController *menubarController;
@property (nonatomic, strong, readonly) PanelController *panelController;
@property (strong, nonatomic) CLFloatingWindowController *floatingWindow;
- (IBAction)togglePanel:(id)sender;

26
Clocker/ApplicationDelegate.m

@ -122,6 +122,11 @@ void *kContextActivePanel = &kContextActivePanel;
[[NSUserDefaults standardUserDefaults] setObject:@0 forKey:CLStartAtLogin];
}
NSNumber *displayMode = [[NSUserDefaults standardUserDefaults] objectForKey:CLShowAppInForeground];
if (displayMode == nil) {
[[NSUserDefaults standardUserDefaults] setObject:@0 forKey:CLShowAppInForeground];
}
NSString *onboarding = [[NSUserDefaults standardUserDefaults] objectForKey:@"initialLaunch"];
// Install icon into the menu bar
@ -135,7 +140,15 @@ void *kContextActivePanel = &kContextActivePanel;
[[NSUserDefaults standardUserDefaults] setObject:@"OnboardingDone" forKey:@"initialLaunch"];
[self.menubarController setInitialTimezoneData];
}
//If mode selected is 1, then show the window when the app starts
if (displayMode.integerValue == 1)
{
self.floatingWindow = [CLFloatingWindowController sharedFloatingWindow];
[self.floatingWindow showWindow:nil];
[NSApp activateIgnoringOtherApps:YES];
}
[[NSUserDefaults standardUserDefaults] registerDefaults:@{ @"NSApplicationCrashOnExceptions": @YES }];
@ -158,6 +171,17 @@ void *kContextActivePanel = &kContextActivePanel;
- (IBAction)togglePanel:(id)sender
{
NSNumber *displayMode = [[NSUserDefaults standardUserDefaults] objectForKey:CLShowAppInForeground];
if (displayMode.integerValue == 1)
{
self.floatingWindow = [CLFloatingWindowController sharedFloatingWindow];
[self.floatingWindow showWindow:nil];
[NSApp activateIgnoringOtherApps:YES];
return;
}
self.menubarController.hasActiveIcon = !self.menubarController.hasActiveIcon;
self.panelController.hasActivePanel = self.menubarController.hasActiveIcon;
}

332
Clocker/Floating Window/CLFloatingWindowController.m

@ -0,0 +1,332 @@
//
// CLFloatingWindowController.m
// Clocker
//
// Created by Abhishek Banthia on 4/2/16.
//
//
#import "CLFloatingWindowController.h"
#import "CLRatingCellView.h"
#import "CLTimezoneData.h"
#import "CommonStrings.h"
#import "CLOneWindowController.h"
@interface CLFloatingWindowController ()
@end
static CLFloatingWindowController *sharedFloatingWindow = nil;
NSString *const CLRatingCellIdentifier = @"ratingCellView";
NSString *const CLTimezoneCellIdentifier = @"timeZoneCell";
@implementation CLFloatingWindowController
- (void)awakeFromNib
{
[super awakeFromNib];
self.futureSlider.continuous = YES;
if (!self.dateFormatter)
{
self.dateFormatter = [NSDateFormatter new];
}
if ([[[NSUserDefaults standardUserDefaults] objectForKey:CLThemeKey] isKindOfClass:[NSString class]]){
[[NSUserDefaults standardUserDefaults] setObject:@0 forKey:CLThemeKey];
}
NSPanel *panel = (id)[self window];
[panel setAcceptsMouseMovedEvents:YES];
[panel setLevel:NSPopUpMenuWindowLevel];
[panel setOpaque:NO];
NSNumber *theme = [[NSUserDefaults standardUserDefaults] objectForKey:CLThemeKey];
if (theme.integerValue == 1)
{
self.shutdownButton.image = [NSImage imageNamed:@"PowerIcon-White"];
self.preferencesButton.image = [NSImage imageNamed:@"Settings-White"];
self.window.backgroundColor = [NSColor blackColor];
[panel setBackgroundColor:[NSColor blackColor]];
}
else
{
self.shutdownButton.image = [NSImage imageNamed:@"PowerIcon"];
self.preferencesButton.image = [NSImage imageNamed:NSImageNameActionTemplate];
self.window.backgroundColor = [NSColor whiteColor];
[panel setBackgroundColor:[NSColor whiteColor]];
}
[self updateDefaultPreferences];
//Register for drag and drop
[self.mainTableview registerForDraggedTypes: [NSArray arrayWithObject:CLDragSessionKey]];
self.window.titlebarAppearsTransparent = YES;
self.window.titleVisibility = NSWindowTitleHidden;
// Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
}
+ (instancetype)sharedFloatingWindow
{
if (sharedFloatingWindow == nil)
{
/*Using a thread safe pattern*/
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedFloatingWindow = [[self alloc] initWithWindowNibName:@"CLFloatingWindow"];
});
}
return sharedFloatingWindow;
}
#pragma mark -
#pragma mark NSTableview Datasource
#pragma mark -
-(NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
{
if (self.showReviewCell) {
return self.defaultPreferences.count+1;
}
return self.defaultPreferences.count;
}
-(NSView*)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
if (self.showReviewCell && row == self.defaultPreferences.count) {
CLRatingCellView *cellView = [self.mainTableview
makeViewWithIdentifier:CLRatingCellIdentifier
owner:self];
return cellView;
}
CLTimezoneCellView *cell = [tableView makeViewWithIdentifier:CLTimezoneCellIdentifier owner:self];
CLTimezoneData *dataObject = [CLTimezoneData getCustomObject:self.defaultPreferences[row]];
NSTextView *customLabel = (NSTextView*)[cell.relativeDate.window
fieldEditor:YES
forObject:cell.relativeDate];
NSNumber *theme = [[NSUserDefaults standardUserDefaults] objectForKey:CLThemeKey];
if (theme.integerValue == 1)
{
[cell updateTextColorWithColor:[NSColor whiteColor] andCell:cell];
[self.mainTableview setBackgroundColor:[NSColor blackColor]];
self.window.alphaValue = 0.90;
[cell.customName setDrawsBackground:YES];
[cell.customName setBackgroundColor:[NSColor blackColor]];
customLabel.insertionPointColor = [NSColor whiteColor];
}
else
{
[cell updateTextColorWithColor:[NSColor blackColor] andCell:cell];
[cell.customName setDrawsBackground:NO];
[self.mainTableview setBackgroundColor:[NSColor whiteColor]];
self.window.alphaValue = 1;
customLabel.insertionPointColor = [NSColor blackColor];
}
cell.relativeDate.stringValue = [dataObject getDateForTimeZoneWithFutureSliderValue:self.futureSliderValue andDisplayType:CLPanelDisplay];
cell.time.stringValue = [dataObject getTimeForTimeZoneWithFutureSliderValue:self.futureSliderValue];
cell.rowNumber = row;
cell.customName.stringValue = [dataObject formatStringShouldContainCity:YES];
NSNumber *displayFutureSlider = [[NSUserDefaults standardUserDefaults] objectForKey:CLDisplayFutureSliderKey];
if ([displayFutureSlider isEqualToNumber:[NSNumber numberWithInteger:1]])
{
self.futureSlider.hidden = YES;
}
else
{
self.futureSlider.hidden = NO;
}
[cell setUpAutoLayoutWithCell:cell];
return cell;
}
#pragma mark -
#pragma mark NSTableview Drag and Drop
#pragma mark -
- (BOOL)tableView:(NSTableView *)tableView writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard *)pboard
{
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:rowIndexes];
[pboard declareTypes:[NSArray arrayWithObject:CLDragSessionKey] owner:self];
[pboard setData:data forType:CLDragSessionKey];
return YES;
}
-(void)tableView:(NSTableView *)tableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
if ([object isKindOfClass:[NSString class]])
{
CLTimezoneData *dataObject = self.defaultPreferences[row];
if ([dataObject.formattedAddress isEqualToString:object])
{
return;
}
dataObject.customLabel = object;
[self.defaultPreferences replaceObjectAtIndex:row withObject:dataObject];
[[NSUserDefaults standardUserDefaults] setObject:self.defaultPreferences forKey:CLDefaultPreferenceKey];
[self.mainTableview reloadData];
}
}
-(BOOL)tableView:(NSTableView *)tableView acceptDrop:(id<NSDraggingInfo>)info row:(NSInteger)row dropOperation:(NSTableViewDropOperation)dropOperation
{
if (row == self.defaultPreferences.count)
{
row -= 1;
}
NSPasteboard *pBoard = [info draggingPasteboard];
NSData *data = [pBoard dataForType:CLDragSessionKey];
NSIndexSet *rowIndexes = [NSKeyedUnarchiver unarchiveObjectWithData:data];
[self.defaultPreferences exchangeObjectAtIndex:rowIndexes.firstIndex
withObjectAtIndex:row];
[[NSUserDefaults standardUserDefaults] setObject:self.defaultPreferences
forKey:CLDefaultPreferenceKey];
[[NSApplication sharedApplication].windows enumerateObjectsUsingBlock:^(NSWindow * _Nonnull window, NSUInteger idx, BOOL * _Nonnull stop) {
if ([window.windowController isMemberOfClass:[CLOneWindowController class]]) {
CLOneWindowController *ref = (CLOneWindowController *) window.windowController;
[ref.preferencesView refereshTimezoneTableView];
}
}];
[self.mainTableview reloadData];
return YES;
}
-(NSDragOperation)tableView:(NSTableView *)tableView validateDrop:(id<NSDraggingInfo>)info proposedRow:(NSInteger)row proposedDropOperation:(NSTableViewDropOperation)dropOperation
{
return NSDragOperationEvery;
}
- (void) updateDefaultPreferences
{
[super updateDefaultPreferences];
NSRect frame = [self.window frame];
frame.size = NSMakeSize(self.window.frame.size.width, self.scrollViewHeight.constant+10);
[self.window setFrame: frame display: YES animate:YES];
[self.window setContentMaxSize:NSMakeSize(self.window.frame.size.width+50, self.scrollViewHeight.constant+100)];
[self updateTime];
}
- (void)updateTime
{
[self.mainTableview reloadData];
}
- (IBAction)sliderMoved:(id)sender
{
NSCalendar *currentCalendar = [NSCalendar autoupdatingCurrentCalendar];
NSDate *newDate = [currentCalendar dateByAddingUnit:NSCalendarUnitMinute
value:self.futureSliderValue
toDate:[NSDate date]
options:kNilOptions];
self.dateFormatter.dateStyle = kCFDateFormatterNoStyle;
self.dateFormatter.timeStyle = kCFDateFormatterShortStyle;
NSString *relativeDate = [currentCalendar isDateInToday:newDate] ? @"Today" : @"Tomorrow";
NSString *helper = [self.dateFormatter stringFromDate:newDate];
NSHelpManager *helpManager = [NSHelpManager sharedHelpManager];
NSPoint pointInScreen = [NSEvent mouseLocation];
pointInScreen.y -= 5;
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@ %@", relativeDate, helper]];
[NSHelpManager setContextHelpModeActive:YES];
[helpManager setContextHelp:attributedString forObject:self.futureSlider];
[helpManager showContextHelpForObject:self.futureSlider locationHint:pointInScreen];
[self.mainTableview reloadData];
}
- (void)removeContextHelpForSlider
{
NSEvent *newEvent = [NSEvent mouseEventWithType:NSLeftMouseDown
location:self.window.mouseLocationOutsideOfEventStream
modifierFlags:0
timestamp:0
windowNumber:self.window.windowNumber
context:self.window.graphicsContext
eventNumber:0
clickCount:1
pressure:0];
[NSApp postEvent:newEvent atStart:NO];
newEvent = [NSEvent mouseEventWithType:NSLeftMouseUp
location:self.window.mouseLocationOutsideOfEventStream
modifierFlags:0
timestamp:0
windowNumber:self.window.windowNumber
context:self.window.graphicsContext
eventNumber:0
clickCount:1
pressure:0];
[NSApp postEvent:newEvent atStart:NO];
}
- (void)updatePanelColor
{
[super updatePanelColor];
NSPanel *panel = (id)[self window];
[panel setAcceptsMouseMovedEvents:YES];
[panel setLevel:NSPopUpMenuWindowLevel];
[panel setOpaque:NO];
NSNumber *theme = [[NSUserDefaults standardUserDefaults] objectForKey:CLThemeKey];
if (theme.integerValue == 1)
{
self.shutdownButton.image = [NSImage imageNamed:@"PowerIcon-White"];
self.preferencesButton.image = [NSImage imageNamed:@"Settings-White"];
self.window.backgroundColor = [NSColor blackColor];
[panel setBackgroundColor:[NSColor blackColor]];
}
else
{
self.shutdownButton.image = [NSImage imageNamed:@"PowerIcon"];
self.preferencesButton.image = [NSImage imageNamed:NSImageNameActionTemplate];
self.window.backgroundColor = [NSColor whiteColor];
[panel setBackgroundColor:[NSColor whiteColor]];
}
}
@end
Loading…
Cancel
Save