Browse Source

Basic functionality finished. Time and Date displayed. Added about window, dots.

Thomas Buck 9 years ago
parent
commit
903636be91

+ 6
- 0
OtaClock/Base.lproj/MainMenu.xib View File

147
                     </connections>
147
                     </connections>
148
                 </menuItem>
148
                 </menuItem>
149
                 <menuItem isSeparatorItem="YES" id="aVS-e6-OtM"/>
149
                 <menuItem isSeparatorItem="YES" id="aVS-e6-OtM"/>
150
+                <menuItem title="About OtaClock" id="Tlq-91-8IJ">
151
+                    <modifierMask key="keyEquivalentModifierMask"/>
152
+                    <connections>
153
+                        <action selector="orderFrontStandardAboutPanel:" target="-1" id="VRw-6e-aO6"/>
154
+                    </connections>
155
+                </menuItem>
150
                 <menuItem title="Quit OtaClock" keyEquivalent="q" id="BNj-pS-CpH">
156
                 <menuItem title="Quit OtaClock" keyEquivalent="q" id="BNj-pS-CpH">
151
                     <connections>
157
                     <connections>
152
                         <action selector="terminate:" target="-1" id="19f-sZ-hYK"/>
158
                         <action selector="terminate:" target="-1" id="19f-sZ-hYK"/>

+ 1
- 1
OtaClock/Images.xcassets/bubble.imageset/Contents.json View File

3
     {
3
     {
4
       "idiom" : "universal",
4
       "idiom" : "universal",
5
       "scale" : "1x",
5
       "scale" : "1x",
6
-      "filename" : "bubbleTest.png"
6
+      "filename" : "bubble.png"
7
     },
7
     },
8
     {
8
     {
9
       "idiom" : "universal",
9
       "idiom" : "universal",

BIN
OtaClock/Images.xcassets/bubble.imageset/bubbleTest.png → OtaClock/Images.xcassets/bubble.imageset/bubble.png View File


+ 21
- 0
OtaClock/Images.xcassets/dots_large.imageset/Contents.json View File

1
+{
2
+  "images" : [
3
+    {
4
+      "idiom" : "universal",
5
+      "scale" : "1x",
6
+      "filename" : "dots_large.png"
7
+    },
8
+    {
9
+      "idiom" : "universal",
10
+      "scale" : "2x"
11
+    },
12
+    {
13
+      "idiom" : "universal",
14
+      "scale" : "3x"
15
+    }
16
+  ],
17
+  "info" : {
18
+    "version" : 1,
19
+    "author" : "xcode"
20
+  }
21
+}

BIN
OtaClock/Images.xcassets/dots_large.imageset/dots_large.png View File


+ 21
- 0
OtaClock/Images.xcassets/dots_small.imageset/Contents.json View File

1
+{
2
+  "images" : [
3
+    {
4
+      "idiom" : "universal",
5
+      "scale" : "1x",
6
+      "filename" : "dots_small.png"
7
+    },
8
+    {
9
+      "idiom" : "universal",
10
+      "scale" : "2x"
11
+    },
12
+    {
13
+      "idiom" : "universal",
14
+      "scale" : "3x"
15
+    }
16
+  ],
17
+  "info" : {
18
+    "version" : 1,
19
+    "author" : "xcode"
20
+  }
21
+}

BIN
OtaClock/Images.xcassets/dots_small.imageset/dots_small.png View File


+ 1
- 1
OtaClock/Info.plist View File

19
 	<key>CFBundleSignature</key>
19
 	<key>CFBundleSignature</key>
20
 	<string>????</string>
20
 	<string>????</string>
21
 	<key>CFBundleVersion</key>
21
 	<key>CFBundleVersion</key>
22
-	<string>239</string>
22
+	<string>259</string>
23
 	<key>LSApplicationCategoryType</key>
23
 	<key>LSApplicationCategoryType</key>
24
 	<string>public.app-category.utilities</string>
24
 	<string>public.app-category.utilities</string>
25
 	<key>LSMinimumSystemVersion</key>
25
 	<key>LSMinimumSystemVersion</key>

+ 70
- 30
OtaClock/Render.m View File

53
 #define ALARM_X_OFFSET 5
53
 #define ALARM_X_OFFSET 5
54
 #define ALARM_Y_OFFSET 57
54
 #define ALARM_Y_OFFSET 57
55
 
55
 
56
+#define DOTS_TIME_Y_OFFSET 63
57
+#define DOTS_TIME_X0_OFFSET 18
58
+#define DOTS_TIME_X1_OFFSET 34
59
+
60
+#define DOTS_ALARM_X_OFFSET 38
61
+#define DOTS_ALARM_Y_OFFSET 57
62
+
56
 @interface Render ()
63
 @interface Render ()
57
 
64
 
58
 @property (assign) CGImageRef otaconGraphic, bubbleGraphic, alarmGraphic;
65
 @property (assign) CGImageRef otaconGraphic, bubbleGraphic, alarmGraphic;
59
-@property (assign) CGImageRef eye0, eye1, eye2, eye3, eye4;
66
+@property (assign) CGImageRef eye0, eye1, eye2, eye3, eye4, dotSmallGraphic, dotLargeGraphic;
60
 @property (assign) CGImageRef fontMonday, fontTuesday, fontWednesday, fontThursday, fontFriday, fontSaturday, fontSunday;
67
 @property (assign) CGImageRef fontMonday, fontTuesday, fontWednesday, fontThursday, fontFriday, fontSaturday, fontSunday;
61
 @property (assign) CGImageRef fontSmall1, fontSmall2, fontSmall3, fontSmall4, fontSmall5, fontSmall6, fontSmall7, fontSmall8, fontSmall9, fontSmall0;
68
 @property (assign) CGImageRef fontSmall1, fontSmall2, fontSmall3, fontSmall4, fontSmall5, fontSmall6, fontSmall7, fontSmall8, fontSmall9, fontSmall0;
62
 @property (assign) CGImageRef fontLarge1, fontLarge2, fontLarge3, fontLarge4, fontLarge5, fontLarge6, fontLarge7, fontLarge8, fontLarge9, fontLarge0;
69
 @property (assign) CGImageRef fontLarge1, fontLarge2, fontLarge3, fontLarge4, fontLarge5, fontLarge6, fontLarge7, fontLarge8, fontLarge9, fontLarge0;
65
 @property (assign) NSInteger dateDigit0, dateDigit1, dateDigit2, dateDigit3;
72
 @property (assign) NSInteger dateDigit0, dateDigit1, dateDigit2, dateDigit3;
66
 @property (assign) NSInteger alarmDigit0, alarmDigit1, alarmDigit2, alarmDigit3;
73
 @property (assign) NSInteger alarmDigit0, alarmDigit1, alarmDigit2, alarmDigit3;
67
 @property (assign) NSInteger timeDigit0, timeDigit1, timeDigit2, timeDigit3, timeDigit4, timeDigit5;
74
 @property (assign) NSInteger timeDigit0, timeDigit1, timeDigit2, timeDigit3, timeDigit4, timeDigit5;
68
-@property (assign) BOOL alarmSign;
75
+@property (assign) BOOL alarmSign, alarmDots, timeDots;
69
 
76
 
70
 @property (assign) NSSize fullSize;
77
 @property (assign) NSSize fullSize;
71
 @property (assign) CGContextRef drawContext;
78
 @property (assign) CGContextRef drawContext;
77
 @implementation Render
84
 @implementation Render
78
 
85
 
79
 @synthesize otaconGraphic, bubbleGraphic, alarmGraphic;
86
 @synthesize otaconGraphic, bubbleGraphic, alarmGraphic;
80
-@synthesize eye0, eye1, eye2, eye3, eye4;
87
+@synthesize eye0, eye1, eye2, eye3, eye4, dotSmallGraphic, dotLargeGraphic;
81
 @synthesize fontMonday, fontTuesday, fontWednesday, fontThursday, fontFriday, fontSaturday, fontSunday;
88
 @synthesize fontMonday, fontTuesday, fontWednesday, fontThursday, fontFriday, fontSaturday, fontSunday;
82
 @synthesize fontSmall1, fontSmall2, fontSmall3, fontSmall4, fontSmall5, fontSmall6, fontSmall7, fontSmall8, fontSmall9, fontSmall0;
89
 @synthesize fontSmall1, fontSmall2, fontSmall3, fontSmall4, fontSmall5, fontSmall6, fontSmall7, fontSmall8, fontSmall9, fontSmall0;
83
 @synthesize fontLarge1, fontLarge2, fontLarge3, fontLarge4, fontLarge5, fontLarge6, fontLarge7, fontLarge8, fontLarge9, fontLarge0;
90
 @synthesize fontLarge1, fontLarge2, fontLarge3, fontLarge4, fontLarge5, fontLarge6, fontLarge7, fontLarge8, fontLarge9, fontLarge0;
86
 @synthesize dateDigit0, dateDigit1, dateDigit2, dateDigit3;
93
 @synthesize dateDigit0, dateDigit1, dateDigit2, dateDigit3;
87
 @synthesize alarmDigit0, alarmDigit1, alarmDigit2, alarmDigit3;
94
 @synthesize alarmDigit0, alarmDigit1, alarmDigit2, alarmDigit3;
88
 @synthesize timeDigit0, timeDigit1, timeDigit2, timeDigit3, timeDigit4, timeDigit5;
95
 @synthesize timeDigit0, timeDigit1, timeDigit2, timeDigit3, timeDigit4, timeDigit5;
89
-@synthesize alarmSign;
96
+@synthesize alarmSign, alarmDots, timeDots;
90
 
97
 
91
 @synthesize fullSize;
98
 @synthesize fullSize;
92
 @synthesize drawContext;
99
 @synthesize drawContext;
166
     NSImage *fontSmallImage = [NSImage imageNamed:@"font_small"];
173
     NSImage *fontSmallImage = [NSImage imageNamed:@"font_small"];
167
     NSImage *fontLargeImage = [NSImage imageNamed:@"font_large"];
174
     NSImage *fontLargeImage = [NSImage imageNamed:@"font_large"];
168
     NSImage *alarmImage = [NSImage imageNamed:@"alarm"];
175
     NSImage *alarmImage = [NSImage imageNamed:@"alarm"];
176
+    NSImage *dotsSmallImage = [NSImage imageNamed:@"dots_small"];
177
+    NSImage *dotsLargeImage = [NSImage imageNamed:@"dots_large"];
169
     
178
     
170
     NSGraphicsContext *context = [NSGraphicsContext graphicsContextWithAttributes:nil];
179
     NSGraphicsContext *context = [NSGraphicsContext graphicsContextWithAttributes:nil];
171
     
180
     
172
     otaconGraphic = [otaconImage CGImageForProposedRect:nil context:context hints:nil];
181
     otaconGraphic = [otaconImage CGImageForProposedRect:nil context:context hints:nil];
173
     bubbleGraphic = [bubbleImage CGImageForProposedRect:nil context:context hints:nil];
182
     bubbleGraphic = [bubbleImage CGImageForProposedRect:nil context:context hints:nil];
174
     alarmGraphic = [alarmImage CGImageForProposedRect:nil context:context hints:nil];
183
     alarmGraphic = [alarmImage CGImageForProposedRect:nil context:context hints:nil];
184
+    dotSmallGraphic = [dotsSmallImage CGImageForProposedRect:nil context:context hints:nil];
185
+    dotLargeGraphic = [dotsLargeImage CGImageForProposedRect:nil context:context hints:nil];
175
     eye0 = [eye0Image CGImageForProposedRect:nil context:context hints:nil];
186
     eye0 = [eye0Image CGImageForProposedRect:nil context:context hints:nil];
176
     eye1 = [eye1Image CGImageForProposedRect:nil context:context hints:nil];
187
     eye1 = [eye1Image CGImageForProposedRect:nil context:context hints:nil];
177
     eye2 = [eye2Image CGImageForProposedRect:nil context:context hints:nil];
188
     eye2 = [eye2Image CGImageForProposedRect:nil context:context hints:nil];
260
     dateDigit1 = 8;
271
     dateDigit1 = 8;
261
     dateDigit2 = 8;
272
     dateDigit2 = 8;
262
     dateDigit3 = 8;
273
     dateDigit3 = 8;
263
-    alarmDigit0 = 8;
264
-    alarmDigit1 = 8;
265
-    alarmDigit2 = 8;
266
-    alarmDigit3 = 8;
267
     timeDigit0 = 8;
274
     timeDigit0 = 8;
268
     timeDigit1 = 8;
275
     timeDigit1 = 8;
269
     timeDigit2 = 8;
276
     timeDigit2 = 8;
270
     timeDigit3 = 8;
277
     timeDigit3 = 8;
271
     timeDigit4 = 8;
278
     timeDigit4 = 8;
272
     timeDigit5 = 8;
279
     timeDigit5 = 8;
273
-    alarmSign = YES;
280
+    timeDots = YES;
281
+    
282
+    alarmDigit0 = -1;
283
+    alarmDigit1 = -1;
284
+    alarmDigit2 = -1;
285
+    alarmDigit3 = -1;
286
+    alarmSign = NO;
287
+    alarmDots = NO;
274
     
288
     
275
     return self;
289
     return self;
276
 }
290
 }
279
     return fullSize;
293
     return fullSize;
280
 }
294
 }
281
 
295
 
296
+#define CONVERT_DECIMAL(num, ten, one) do { \
297
+    if (num >= 50) { \
298
+        ten = 5; \
299
+        one = num - 50; \
300
+    } else if (num >= 40) { \
301
+        ten = 4; \
302
+        one = num - 40; \
303
+    } else if (num >= 30) { \
304
+        ten = 3; \
305
+        one = num - 30; \
306
+    } else if (num >= 20) { \
307
+        ten = 2; \
308
+        one = num - 20; \
309
+    } else if (num >= 10) { \
310
+        ten = 1; \
311
+        one = num - 10; \
312
+    } else { \
313
+        ten = 0; \
314
+        one = num; \
315
+    } \
316
+} while (0);
317
+
282
 - (void)drawWithDate:(NSDate *)date {
318
 - (void)drawWithDate:(NSDate *)date {
283
     NSCalendarUnit comps = NSWeekdayCalendarUnit | NSDayCalendarUnit | NSMonthCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
319
     NSCalendarUnit comps = NSWeekdayCalendarUnit | NSDayCalendarUnit | NSMonthCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
284
     NSDateComponents *components = [[NSCalendar currentCalendar] components:comps fromDate:date];
320
     NSDateComponents *components = [[NSCalendar currentCalendar] components:comps fromDate:date];
285
     dayOfWeek = [components weekday] - 2; // map sun=1 to sun=-1
321
     dayOfWeek = [components weekday] - 2; // map sun=1 to sun=-1
286
     
322
     
287
-    if ([components month] >= 10) {
288
-        dateDigit0 = 1;
289
-        dateDigit1 = [components month] - 10;
290
-    } else {
291
-        dateDigit0 = 0;
292
-        dateDigit1 = [components month];
293
-    }
294
-    
295
-    if ([components day] >= 30) {
296
-        dateDigit2 = 3;
297
-        dateDigit3 = [components day] - 30;
298
-    } else if ([components day] >= 20) {
299
-        dateDigit2 = 2;
300
-        dateDigit3 = [components day] - 20;
301
-    } else if ([components day] >= 10) {
302
-        dateDigit2 = 1;
303
-        dateDigit3 = [components day] - 10;
304
-    } else {
305
-        dateDigit2 = 0;
306
-        dateDigit3 = [components day];
307
-    }
323
+    CONVERT_DECIMAL([components month], dateDigit0, dateDigit1);
324
+    CONVERT_DECIMAL([components day], dateDigit2, dateDigit3);
325
+    CONVERT_DECIMAL([components hour], timeDigit0, timeDigit1);
326
+    CONVERT_DECIMAL([components minute], timeDigit2, timeDigit3);
327
+    CONVERT_DECIMAL([components second], timeDigit4, timeDigit5);
308
 }
328
 }
309
 
329
 
310
 - (void)drawWithEye:(NSInteger)eyeIndex {
330
 - (void)drawWithEye:(NSInteger)eyeIndex {
382
         CGContextDrawImage(drawContext, size, [self largeHelper:timeDigit5]);
402
         CGContextDrawImage(drawContext, size, [self largeHelper:timeDigit5]);
383
     }
403
     }
384
     
404
     
405
+    // Draw dots between hours, minutes and seconds
406
+    if (timeDots == YES) {
407
+        size.size.width = CGImageGetWidth(dotLargeGraphic);
408
+        size.size.height = CGImageGetHeight(dotLargeGraphic);
409
+        size.origin.y = DOTS_TIME_Y_OFFSET;
410
+        size.origin.x = DOTS_TIME_X0_OFFSET;
411
+        CGContextDrawImage(drawContext, size, dotLargeGraphic);
412
+        size.origin.x = DOTS_TIME_X1_OFFSET;
413
+        CGContextDrawImage(drawContext, size, dotLargeGraphic);
414
+    }
415
+    
385
     // Draw Alarm Graphic
416
     // Draw Alarm Graphic
386
     if (alarmSign == YES) {
417
     if (alarmSign == YES) {
387
         size.size.width = CGImageGetWidth(alarmGraphic);
418
         size.size.width = CGImageGetWidth(alarmGraphic);
391
         CGContextDrawImage(drawContext, size, alarmGraphic);
422
         CGContextDrawImage(drawContext, size, alarmGraphic);
392
     }
423
     }
393
     
424
     
425
+    // Draw dots between alarm hours and minutes
426
+    if (alarmDots == YES) {
427
+        size.size.width = CGImageGetWidth(dotSmallGraphic);
428
+        size.size.height = CGImageGetHeight(dotSmallGraphic);
429
+        size.origin.x = DOTS_ALARM_X_OFFSET;
430
+        size.origin.y = DOTS_ALARM_Y_OFFSET;
431
+        CGContextDrawImage(drawContext, size, dotSmallGraphic);
432
+    }
433
+    
394
     // Draw Alarm Time
434
     // Draw Alarm Time
395
     size.size.width = FONT_SMALL_WIDTH;
435
     size.size.width = FONT_SMALL_WIDTH;
396
     size.size.height = FONT_SMALL_HEIGHT;
436
     size.size.height = FONT_SMALL_HEIGHT;

Loading…
Cancel
Save