Przeglądaj źródła

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

Thomas Buck 9 lat temu
rodzic
commit
903636be91

+ 6
- 0
OtaClock/Base.lproj/MainMenu.xib Wyświetl plik

@@ -147,6 +147,12 @@
147 147
                     </connections>
148 148
                 </menuItem>
149 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 156
                 <menuItem title="Quit OtaClock" keyEquivalent="q" id="BNj-pS-CpH">
151 157
                     <connections>
152 158
                         <action selector="terminate:" target="-1" id="19f-sZ-hYK"/>

+ 1
- 1
OtaClock/Images.xcassets/bubble.imageset/Contents.json Wyświetl plik

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

BIN
OtaClock/Images.xcassets/bubble.imageset/bubbleTest.png → OtaClock/Images.xcassets/bubble.imageset/bubble.png Wyświetl plik


+ 21
- 0
OtaClock/Images.xcassets/dots_large.imageset/Contents.json Wyświetl plik

@@ -0,0 +1,21 @@
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 Wyświetl plik


+ 21
- 0
OtaClock/Images.xcassets/dots_small.imageset/Contents.json Wyświetl plik

@@ -0,0 +1,21 @@
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 Wyświetl plik


+ 1
- 1
OtaClock/Info.plist Wyświetl plik

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

+ 70
- 30
OtaClock/Render.m Wyświetl plik

@@ -53,10 +53,17 @@
53 53
 #define ALARM_X_OFFSET 5
54 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 63
 @interface Render ()
57 64
 
58 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 67
 @property (assign) CGImageRef fontMonday, fontTuesday, fontWednesday, fontThursday, fontFriday, fontSaturday, fontSunday;
61 68
 @property (assign) CGImageRef fontSmall1, fontSmall2, fontSmall3, fontSmall4, fontSmall5, fontSmall6, fontSmall7, fontSmall8, fontSmall9, fontSmall0;
62 69
 @property (assign) CGImageRef fontLarge1, fontLarge2, fontLarge3, fontLarge4, fontLarge5, fontLarge6, fontLarge7, fontLarge8, fontLarge9, fontLarge0;
@@ -65,7 +72,7 @@
65 72
 @property (assign) NSInteger dateDigit0, dateDigit1, dateDigit2, dateDigit3;
66 73
 @property (assign) NSInteger alarmDigit0, alarmDigit1, alarmDigit2, alarmDigit3;
67 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 77
 @property (assign) NSSize fullSize;
71 78
 @property (assign) CGContextRef drawContext;
@@ -77,7 +84,7 @@
77 84
 @implementation Render
78 85
 
79 86
 @synthesize otaconGraphic, bubbleGraphic, alarmGraphic;
80
-@synthesize eye0, eye1, eye2, eye3, eye4;
87
+@synthesize eye0, eye1, eye2, eye3, eye4, dotSmallGraphic, dotLargeGraphic;
81 88
 @synthesize fontMonday, fontTuesday, fontWednesday, fontThursday, fontFriday, fontSaturday, fontSunday;
82 89
 @synthesize fontSmall1, fontSmall2, fontSmall3, fontSmall4, fontSmall5, fontSmall6, fontSmall7, fontSmall8, fontSmall9, fontSmall0;
83 90
 @synthesize fontLarge1, fontLarge2, fontLarge3, fontLarge4, fontLarge5, fontLarge6, fontLarge7, fontLarge8, fontLarge9, fontLarge0;
@@ -86,7 +93,7 @@
86 93
 @synthesize dateDigit0, dateDigit1, dateDigit2, dateDigit3;
87 94
 @synthesize alarmDigit0, alarmDigit1, alarmDigit2, alarmDigit3;
88 95
 @synthesize timeDigit0, timeDigit1, timeDigit2, timeDigit3, timeDigit4, timeDigit5;
89
-@synthesize alarmSign;
96
+@synthesize alarmSign, alarmDots, timeDots;
90 97
 
91 98
 @synthesize fullSize;
92 99
 @synthesize drawContext;
@@ -166,12 +173,16 @@
166 173
     NSImage *fontSmallImage = [NSImage imageNamed:@"font_small"];
167 174
     NSImage *fontLargeImage = [NSImage imageNamed:@"font_large"];
168 175
     NSImage *alarmImage = [NSImage imageNamed:@"alarm"];
176
+    NSImage *dotsSmallImage = [NSImage imageNamed:@"dots_small"];
177
+    NSImage *dotsLargeImage = [NSImage imageNamed:@"dots_large"];
169 178
     
170 179
     NSGraphicsContext *context = [NSGraphicsContext graphicsContextWithAttributes:nil];
171 180
     
172 181
     otaconGraphic = [otaconImage CGImageForProposedRect:nil context:context hints:nil];
173 182
     bubbleGraphic = [bubbleImage CGImageForProposedRect:nil context:context hints:nil];
174 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 186
     eye0 = [eye0Image CGImageForProposedRect:nil context:context hints:nil];
176 187
     eye1 = [eye1Image CGImageForProposedRect:nil context:context hints:nil];
177 188
     eye2 = [eye2Image CGImageForProposedRect:nil context:context hints:nil];
@@ -260,17 +271,20 @@
260 271
     dateDigit1 = 8;
261 272
     dateDigit2 = 8;
262 273
     dateDigit3 = 8;
263
-    alarmDigit0 = 8;
264
-    alarmDigit1 = 8;
265
-    alarmDigit2 = 8;
266
-    alarmDigit3 = 8;
267 274
     timeDigit0 = 8;
268 275
     timeDigit1 = 8;
269 276
     timeDigit2 = 8;
270 277
     timeDigit3 = 8;
271 278
     timeDigit4 = 8;
272 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 289
     return self;
276 290
 }
@@ -279,32 +293,38 @@
279 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 318
 - (void)drawWithDate:(NSDate *)date {
283 319
     NSCalendarUnit comps = NSWeekdayCalendarUnit | NSDayCalendarUnit | NSMonthCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
284 320
     NSDateComponents *components = [[NSCalendar currentCalendar] components:comps fromDate:date];
285 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 330
 - (void)drawWithEye:(NSInteger)eyeIndex {
@@ -382,6 +402,17 @@
382 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 416
     // Draw Alarm Graphic
386 417
     if (alarmSign == YES) {
387 418
         size.size.width = CGImageGetWidth(alarmGraphic);
@@ -391,6 +422,15 @@
391 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 434
     // Draw Alarm Time
395 435
     size.size.width = FONT_SMALL_WIDTH;
396 436
     size.size.height = FONT_SMALL_HEIGHT;

Ładowanie…
Anuluj
Zapisz