aboutsummaryrefslogblamecommitdiffstats
path: root/data/themes/edc/clock.edc
blob: 730861c001140f04859e9a86790917a25c0baf8a (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815





































































































































































































































































































































































































































                                                                           
                                     











                                           

                               

























































































































































































































































































































































































                                                                                                                     
                                  


                                     
                            
























































                                                               
                                  


                                      
                            








                                            
                                   


                                           
                                  









                                                         
                                    


                                           
                            
















































































                                                   
                                  
















                                                              
                                  



































































































































































                                                                      
group { name: "e/modules/clock/digital";
   min: 64 16;
   max: 512 128;
   images.image: "digit_na.png" COMP;
   images.image: "digit_nm.png" COMP;
   images.image: "digit_0.png" COMP;
   images.image: "digit_1.png" COMP;
   images.image: "digit_2.png" COMP;
   images.image: "digit_3.png" COMP;
   images.image: "digit_4.png" COMP;
   images.image: "digit_5.png" COMP;
   images.image: "digit_6.png" COMP;
   images.image: "digit_7.png" COMP;
   images.image: "digit_8.png" COMP;
   images.image: "digit_9.png" COMP;
   images.image: "digit_am.png" COMP;
   images.image: "digit_pm.png" COMP;
   images.image: "hole_tiny.png" COMP;
   script {
      public do_seconds, do_24h, do_date, tick_timer;

      evalsize() {
         new do24h, dosec, v[14], i, tot, mul;
         new parts[] = {
            PART:"hours1", PART:"hours1",
            PART:"hours2", PART:"hours2",
            PART:"mins1", PART:"mins1",
            PART:"mins2", PART:"mins2",
            PART:"secs1", PART:"secs1",
            PART:"secs2", PART:"secs2",
            PART:"ampm", PART:"ampm"
         };
         
         mul = 4;
         if (get_int(do_date)) {
            mul = 3;
         }
         
         for (i = 0; i < 14; i += 2) {
            custom_state(parts[i], "default", 0.0);
         }
         v[0] = 0; v[1] = 2; v[2] = 2; v[3] = 4; // hrs
         v[4] = 5; v[5] = 7; v[6] = 7; v[7] = 9; // mins
         tot = 9;
         
         dosec = get_int(do_seconds);
         do24h = get_int(do_24h);
         if ((dosec) && (!do24h)) { // sec + ampm
            tot += 7;
            v[8] = 10; v[9] = 12; v[10] = 12; v[11] = 14;
            v[12] = 14; v[13] = 16;
         }
         else if ((dosec) && (do24h)) { // sec + -
            tot += 5;
            v[8] = 10; v[9] = 12; v[10] = 12; v[11] = 14;
            v[12] = 0; v[13] = 0;
         }
         else if ((!dosec) && (!do24h)) { // - + ampm
            tot += 2;
            v[8] = 0; v[9] = 0; v[10] = 0; v[11] = 0;
            v[12] = 9; v[13] = 11;
         }
         else if ((!dosec) && (do24h)) { // - + -
            tot += 0;
            v[8] = 0; v[9] = 0; v[10] = 0; v[11] = 0;
            v[12] = 0; v[13] = 0;
         }
         for (i = 0; i < 14; i += 2) {
            set_state_val(parts[i], STATE_REL1,
                          float(v[i]) / float(tot), 0.0);
            set_state_val(parts[i + 1], STATE_REL2,
                          float(v[i + 1]) / float(tot), 1.0);
         }
         for (i = 0; i < 14; i += 2) {
            set_state(parts[i], "custom", 0.0);
         }
         set_min_size(tot * mul, 16);
         set_max_size(tot * 8 * mul, 128);
         emit("e,state,sizing,changed", "");
      }
      reset() {
         new tim;
         
         evalsize();
         tim = get_int(tick_timer);
         if (tim) {
            cancel_timer(tim);
            set_int(tick_timer, 0);
         }
         clock_cb(0);
      }
      valset(name[], v) {
         new buf[20], i;
         
         for (i = 0; i < 10; i++) {
            if (i == v) {
               snprintf(buf, 20, "show,%s-%i", name, i);
            }
            else {
               snprintf(buf, 20, "hide,%s-%i", name, i);
            }
            emit(buf, "c");
         }
      }
      apvalset(id, pm) {
         if (pm) set_state(id, "active", 0.0);
         else set_state(id, "default", 0.0);
      }
      public clock_cb(val) {
         new year, month, day, yearday, weekday, hour, minute;
         new Float:second;
         new v, dosec, do24h, tim;
         
         date(year, month, day, yearday, weekday, hour, minute, second);
         dosec = get_int(do_seconds);
         if (dosec) {
            v = round(second);
            tim = timer(1.0 - (second - v), "clock_cb", 1);
            // set seconds to v
            valset("s0", v / 10);
            valset("s1", v % 10);
         }
         else {
            tim = timer(60.0 - (second), "clock_cb", 1);
         }
         set_int(tick_timer, tim);
         
         // set minutes to minute
         valset("m0", minute / 10);
         valset("m1", minute % 10);
         
         // set hours to hour
         do24h = get_int(do_24h);
         if (do24h) {
            valset("h0", hour / 10);
            valset("h1", hour % 10);
         }
         else {
            new pm;
            
            // if 12 or later, its pm
            if (hour >= 12) {
               pm = 1;
               // if we are after 12 (1, 2, 3 etc.) then mod by 12
               if (hour > 12) hour = hour % 12;
            }
            else {
               pm = 0;
               // make after midnight be 12:XX AM :)
               if (hour == 0) hour = 12;
            }
            valset("h0", hour / 10);
            valset("h1", hour % 10);
            apvalset(PART:"ap", pm);
         }
      }
   }
   parts {
      part { name: "secclip"; type: RECT;
         description { state: "default" 0.0;
         }
         description { state: "hidden" 0.0;
            visible: 0;
         }
      }
      part { name: "ampmclip"; type: RECT;
         description { state: "default" 0.0;
         }
         description { state: "hidden" 0.0;
            visible: 0;
         }
      }
      // XXX: hours1/2, mins1/2, secs1/2 and ampm SHOULD be spacers... but
      // if they are calculations go weird. this shouldnt happen, but does.
      part { name: "timearea"; type: RECT;
         description { state: "default" 0.0;
            visible: 0;
         }
         description { state: "date" 0.0;
            inherit: "default" 0.0;
            rel2.relative: 1.0 0.0;
            rel2.offset: -1 4;
            rel2.to_y: "e.text.today";
         }
      }
      part { name: "hours1"; type: RECT;
         description { state: "default" 0.0;
            rel1.relative: (0/16) 0.0;
            rel2.relative: (2/16) 1.0;
            rel1.to: "timearea";
            rel2.to: "timearea";
            visible: 0;
         }
      }
      part { name: "hours2"; type: RECT;
         description { state: "default" 0.0;
            rel1.relative: (2/16) 0.0;
            rel2.relative: (4/16) 1.0;
            rel1.to: "timearea";
            rel2.to: "timearea";
            visible: 0;
         }
      }
      part { name: "mins1"; type: RECT;
         description { state: "default" 0.0;
            rel1.relative: (5/16) 0.0;
            rel2.relative: (7/16) 1.0;
            rel1.to: "timearea";
            rel2.to: "timearea";
            visible: 0;
         }
      }
      part { name: "mins2"; type: RECT;
         description { state: "default" 0.0;
            rel1.relative: (7/16) 0.0;
            rel2.relative: (9/16) 1.0;
            rel1.to: "timearea";
            rel2.to: "timearea";
            visible: 0;
         }
      }
      part { name: "secs1"; type: RECT;
         description { state: "default" 0.0;
            rel1.relative: (10/16) 0.0;
            rel2.relative: (12/16) 1.0;
            rel1.to: "timearea";
            rel2.to: "timearea";
            visible: 0;
         }
      }
      part { name: "secs2"; type: RECT;
         description { state: "default" 0.0;
            rel1.relative: (12/16) 0.0;
            rel2.relative: (14/16) 1.0;
            rel1.to: "timearea";
            rel2.to: "timearea";
            visible: 0;
         }
      }
      part { name: "ampm"; type: RECT;
         description { state: "default" 0.0;
            rel1.relative: (14/16) 0.0;
            rel2.relative: (16/16) 1.0;
            rel1.to: "timearea";
            rel2.to: "timearea";
            visible: 0;
         }
      }
      part { name: "c00";
         description { state: "default" 0.0;
            rel1.to: "hours2";
            rel1.relative: 1.0 0.5;
            rel1.offset: 0 -2;
            rel2.to: "mins1";
            rel2.relative: 0.0 0.5;
            rel2.offset: 0 -2;
            align: 0.5 1.0;
            FIXED_SIZE(4, 4)
            image.normal: "hole_tiny.png";
         }
      }
      part { name: "c01";
         description { state: "default" 0.0;
            rel1.to: "hours2";
            rel1.relative: 1.0 0.5;
            rel1.offset: 0 1;
            rel2.to: "mins1";
            rel2.relative: 0.0 0.5;
            rel2.offset: 0 1;
            align: 0.5 0.0;
            FIXED_SIZE(4, 4)
            image.normal: "hole_tiny.png";
         }
      }
      part { name: "c10";
         clip_to: "secclip";
         description { state: "default" 0.0;
            rel1.to: "mins2";
            rel1.relative: 1.0 0.5;
            rel1.offset: 0 -2;
            rel2.to: "secs1";
            rel2.relative: 0.0 0.5;
            rel2.offset: 0 -2;
            align: 0.5 1.0;
            FIXED_SIZE(4, 4)
            image.normal: "hole_tiny.png";
         }
      }
      part { name: "c11";
         clip_to: "secclip";
         description { state: "default" 0.0;
            rel1.to: "mins2";
            rel1.relative: 1.0 0.5;
            rel1.offset: 0 1;
            rel2.to: "secs1";
            rel2.relative: 0.0 0.5;
            rel2.offset: 0 1;
            align: 0.5 0.0;
            FIXED_SIZE(4, 4)
            image.normal: "hole_tiny.png";
         }
      }
#define ELEM(_NAME, _TO, _DIGIT) \
   part { name: _NAME; \
      description { state: "default" 0.0; \
         rel1.to: _TO; rel2.to: _TO; \
         aspect: (52/72) (52/72); aspect_preference: BOTH; \
         image.normal: "digit_"_DIGIT".png"; \
         visible: 0; \
         color: 255 255 255 0; \
      } \
      description { state: "active" 0.0; \
         inherit: "default" 0.0; \
         visible: 1; \
         color: 255 255 255 255; \
      } \
   }
#define DIGIT(_NAME, _TO) \
   ELEM(_NAME"-0", _TO, "0") \
   ELEM(_NAME"-1", _TO, "1") \
   ELEM(_NAME"-2", _TO, "2") \
   ELEM(_NAME"-3", _TO, "3") \
   ELEM(_NAME"-4", _TO, "4") \
   ELEM(_NAME"-5", _TO, "5") \
   ELEM(_NAME"-6", _TO, "6") \
   ELEM(_NAME"-7", _TO, "7") \
   ELEM(_NAME"-8", _TO, "8") \
   ELEM(_NAME"-9", _TO, "9")
#define ELEMC(_NAME, _TO, _DIGIT, _CLIP) \
   part { name: _NAME; \
      clip_to: _CLIP; \
      description { state: "default" 0.0; \
         rel1.to: _TO; rel2.to: _TO; \
         aspect: (52/72) (52/72); aspect_preference: BOTH; \
         image.normal: "digit_"_DIGIT".png"; \
         visible: 0; \
         color: 255 255 255 0; \
      } \
      description { state: "active" 0.0; \
         inherit: "default" 0.0; \
         visible: 1; \
         color: 255 255 255 255; \
      } \
   }
#define DIGITC(_NAME, _TO, _CLIP) \
   ELEMC(_NAME"-0", _TO, "0", _CLIP) \
   ELEMC(_NAME"-1", _TO, "1", _CLIP) \
   ELEMC(_NAME"-2", _TO, "2", _CLIP) \
   ELEMC(_NAME"-3", _TO, "3", _CLIP) \
   ELEMC(_NAME"-4", _TO, "4", _CLIP) \
   ELEMC(_NAME"-5", _TO, "5", _CLIP) \
   ELEMC(_NAME"-6", _TO, "6", _CLIP) \
   ELEMC(_NAME"-7", _TO, "7", _CLIP) \
   ELEMC(_NAME"-8", _TO, "8", _CLIP) \
   ELEMC(_NAME"-9", _TO, "9", _CLIP)
      
#define TAG(_NAME, _TO, _CLIP) \
   part { name: _NAME; \
      clip_to: _CLIP; \
      description { state: "default" 0.0; \
         rel1.to: _TO; rel2.to: _TO; \
         aspect: (48/31) (48/31); aspect_preference: BOTH; \
         image.normal: "digit_am.png"; \
      } \
      description { state: "active" 0.0; \
         inherit: "default" 0.0; \
         image.normal: "digit_pm.png"; \
      } \
   }
#define BASE(_NAME, _BASE, _IMG) \
   part { name: _NAME; \
      description { state: "default" 0.0; \
         rel1.to: _BASE; \
         rel2.to: _BASE; \
         image.normal: _IMG; \
         color: 255 255 255 128; \
      } \
   }
#define BASEC(_NAME, _CLIP, _BASE, _IMG) \
   part { name: _NAME; \
      clip_to: _CLIP; \
      description { state: "default" 0.0; \
         rel1.to: _BASE; \
         rel2.to: _BASE; \
         image.normal: _IMG; \
         color: 255 255 255 128; \
      } \
   }
      
      BASE ("ha", "h0-0", "digit_na.png")
      BASE ("hb", "h1-0", "digit_na.png")
      BASE ("ma", "m0-0", "digit_na.png")
      BASE ("mb", "m1-0", "digit_na.png")
              
      BASEC("sa", "secclip", "s0-0", "digit_na.png")
      BASEC("sb", "secclip", "s1-0", "digit_na.png")
      BASEC("aa", "ampmclip", "ap", "digit_nm.png")
        
      DIGIT ("h0", "hours1")
      DIGIT ("h1", "hours2")
      DIGIT ("m0", "mins1")
      DIGIT ("m1", "mins2")
      DIGITC("s0", "secs1", "secclip")
      DIGITC("s1", "secs2", "secclip")
      TAG("ap", "ampm", "ampmclip")
#undef TAG
#undef TAG
#undef ELEM
#undef ELEMC
#undef BASE
#undef BASEC
#undef DIGIT
#undef DIGITC

       part { name: "e.text.today"; type: TEXT;
          effect: GLOW;
          scale: 1;
          description { state: "default" 0.0;
             rel1.relative: 0.0 1.0;
             rel1.offset: 0 1;
             rel2.offset: -1 1;
             align: 0.5 1.0;
             color: FN_COL_HIGHLIGHT;
             text { font: FN; size: 8;
                text_class: "module_small";
                align: 0.5 0.5;
                min: 0 1;
             }
             fixed: 0 1;
             visible: 0;
          }
          description { state: "date" 0.0;
             inherit: "default" 0.0;
             visible: 1;
             fixed: 1 1;
             text.min: 1 1;
             text.ellipsis: -1;
          }
       }
                       
       part { name: "event"; type: RECT;
          description { state: "default" 0.0;
             color: 0 0 0 0;
          }
       }
   }
   programs {
      program {
         signal: "load"; source: "";
         script {
            reset();
         }
      }
      program {
         signal: "e,state,date,on"; source: "e";
         script {
            set_int(do_date, 1);
            set_state(PART:"timearea", "date", 0.0);
            set_state(PART:"e.text.today", "date", 0.0);
            reset();
         }
      }
      program {
         signal: "e,state,date,off"; source: "e";
         script {
            set_int(do_date, 0);
            set_state(PART:"timearea", "default", 0.0);
            set_state(PART:"e.text.today", "default", 0.0);
            reset();
         }
      }
      program {
         signal: "e,state,seconds,on"; source: "e";
         script {
            set_int(do_seconds, 1);
            set_state(PART:"secclip", "default", 0.0);
            reset();
         }
      }
      program {
         signal: "e,state,seconds,off"; source: "e";
         script {
            set_int(do_seconds, 0);
            set_state(PART:"secclip", "hidden", 0.0);
            reset();
         }
      }
      program {
         signal: "e,state,24h,on"; source: "e";
         script {
            set_int(do_24h, 1);
            set_state(PART:"ampmclip", "hidden", 0.0);
            reset();
         }
      }
      program {
         signal: "e,state,24h,off"; source: "e";
         script {
            set_int(do_24h, 0);
            set_state(PART:"ampmclip", "default", 0.0);
            reset();
         }
      }
#define DIGPRG(_NAME) \
      program { \
         signal: "show,"_NAME; source: "c"; \
         action: STATE_SET "active" 0.0; \
         transition: BOUNCE 0.3 0.5 2; \
         target: _NAME; \
      } \
      program { \
         signal: "hide,"_NAME; source: "c"; \
         action: STATE_SET "default" 0.0; \
         transition: DECELERATE 0.3; \
         target: _NAME; \
      }
#define DIGPRGS(_NAME) \
      DIGPRG(_NAME"-0") \
      DIGPRG(_NAME"-1") \
      DIGPRG(_NAME"-2") \
      DIGPRG(_NAME"-3") \
      DIGPRG(_NAME"-4") \
      DIGPRG(_NAME"-5") \
      DIGPRG(_NAME"-6") \
      DIGPRG(_NAME"-7") \
      DIGPRG(_NAME"-8") \
      DIGPRG(_NAME"-9")

      DIGPRGS("h0")
      DIGPRGS("h1")
      DIGPRGS("m0")
      DIGPRGS("m1")
      DIGPRGS("s0")
      DIGPRGS("s1")
#undef DIGPRG
#undef DIGPRGS
   }
}

group { name: "e/modules/clock/main";
   images.image: "clock_base.png" COMP;
   images.image: "inset_round_hilight.png" COMP;
   images.image: "inset_round_shadow.png" COMP;
   images.image: "inset_round_shading.png" COMP;
   set { name: "tacho_hand_big";
      image { image: "tacho_hand_big.png" COMP; size: 73 73 99999 99999; }
      image { image: "tacho_hand_big2.png" COMP; size: 37 37 72 72; }
      image { image: "tacho_hand_big3.png" COMP; size: 19 19 36 36; }
      image { image: "tacho_hand_big4.png" COMP; size: 0 0 18 18; }
   }
   images.image: "tacho_hand_big_shadow.png" COMP;
   set { name: "tacho_hand_small_min";
      image { image: "tacho_hand_small_min.png" COMP; size: 73 73 99999 99999; }
      image { image: "tacho_hand_small_min2.png" COMP; size: 37 37 72 72; }
      image { image: "tacho_hand_small_min3.png" COMP; size: 19 19 36 36; }
      image { image: "tacho_hand_small_min4.png" COMP; size: 0 0 18 18; }
   }
   set { name: "knob";
      image { image: "knob_sz_24.png"  COMP; size: 31 31 32 32; }
      image { image: "knob_sz_22.png"  COMP; size: 29 29 30 30; }
      image { image: "knob_sz_20.png"  COMP; size: 27 27 28 28; }
      image { image: "knob_sz_18.png"  COMP; size: 25 25 26 26; }
      image { image: "knob_sz_16.png"  COMP; size: 23 23 24 24; }
      image { image: "knob_sz_14.png"  COMP; size: 21 21 22 22; }
      image { image: "knob_sz_12.png"  COMP; size: 19 19 20 20; }
      image { image: "knob_sz_10.png"  COMP; size: 17 17 18 18; }
      image { image: "knob_sz_08.png"  COMP; size: 15 15 16 16; }
      image { image: "knob_sz_06.png"  COMP; size: 13 13 14 14; }
      image { image: "knob_sz_04.png"  COMP; size:  0  0 12 12; }
   }
   min: 16 16;
   max: 160 160;
   script {
      public do_seconds, tick_timer;
      
         public clock_cb(val) {
            new year, month, day, yearday, weekday, hour, minute;
            new Float:second;
            new v, dosec, tim;
            
            date(year, month, day, yearday, weekday, hour, minute, second);
            dosec = get_int(do_seconds);
            if (dosec) {
               v = round(second);
               tim = timer(1.0 - (second - v), "clock_cb", 1);
               
               custom_state(PART:"seconds", "default", 0.0);
               set_state_val(PART:"seconds", STATE_MAP_ROT_Z, (v * 360.0) / 60.0);
               set_state(PART:"seconds", "custom", 0.0);
               
               custom_state(PART:"seconds-sh", "default", 0.0);
               set_state_val(PART:"seconds-sh", STATE_MAP_ROT_Z, (v * 360.0) / 60.0);
               set_state(PART:"seconds-sh", "custom", 0.0);
            }
            else {
               tim = timer(60.0 - (second), "clock_cb", 1);
            }
            set_int(tick_timer, tim);
            
            custom_state(PART:"minutes", "default", 0.0);
            set_state_val(PART:"minutes", STATE_MAP_ROT_Z, (float(minute) * 360.0) / 60.0);
            set_state(PART:"minutes", "custom", 0.0);
            
            custom_state(PART:"minutes-sh", "default", 0.0);
            set_state_val(PART:"minutes-sh", STATE_MAP_ROT_Z, (float(minute) * 360.0) / 60.0);
            set_state(PART:"minutes-sh", "custom", 0.0);
            
            custom_state(PART:"hours", "default", 0.0);
            set_state_val(PART:"hours", STATE_MAP_ROT_Z, ((float(hour) + (float(minute) / 60.0)) * 360.0) / 12.0);
            set_state(PART:"hours", "custom", 0.0);
            
            custom_state(PART:"hours-sh", "default", 0.0);
            set_state_val(PART:"hours-sh", STATE_MAP_ROT_Z, ((float(hour) + (float(minute) / 60.0)) * 360.0) / 12.0);
            set_state(PART:"hours-sh", "custom", 0.0);
         }
   }
   parts {   
      part { name: "event"; type: RECT;
         description { state: "default" 0.0;
            color: 0 0 0 0;
         }
      }
      part { name: "base-sh";
         description { state: "default" 0.0;
            rel1.to: "base";
            rel1.offset: 0 -1;
            rel2.to: "base";
            rel2.offset: -1 -2;
            image.normal: "inset_round_shadow.png";
         }
      }
      part { name: "base-hi";
         description { state: "default" 0.0;
            rel1.to: "base";
            rel1.offset: 0 1;
            rel2.to: "base";
            rel2.offset: -1 0;
            image.normal: "inset_round_hilight.png";
         }
      }
      part { name: "base";
         description { state: "default" 0.0;
            rel1.relative: (25/380) (25/380);
            rel2.relative: (365/380) (365/380);
            aspect: 1.0 1.0; aspect_preference: BOTH;
            image.normal: "clock_base.png";
         }
      }
      part { name: "seconds-sh"; mouse_events: 0;
         description { state: "default" 0.0;
            image.normal: "tacho_hand_big_shadow.png";
            rel1.to: "hours-sh";
            rel2.to: "hours-sh";
            map {
               on: 1;
               rotation.center: "seconds-sh";
            }
         }
         description { state: "hidden" 0.0;
            inherit: "default" 0.0;
            visible: 0;
         }
      }
      part { name: "seconds"; mouse_events: 0;
         description { state: "default" 0.0;
            image.normal: "tacho_hand_big";
            color: 255 0 0 255;
            rel1.to: "base";
            rel2.to: "base";
            map {
               on: 1;
               rotation.center: "base";
            }
         }
         description { state: "hidden" 0.0;
            inherit: "default" 0.0;
            visible: 0;
         }
      }
      part { name: "minutes-sh"; mouse_events: 0;
         description { state: "default" 0.0;
            image.normal: "tacho_hand_big_shadow.png";
            rel1.to: "hours-sh";
            rel2.to: "hours-sh";
            map {
               on: 1;
               rotation.center: "minutes-sh";
            }
         }
      }
      part { name: "minutes"; mouse_events: 0;
         description { state: "default" 0.0000;
            color: 255 255 255 255;
            image.normal: "tacho_hand_big";
            rel1.to: "base";
            rel2.to: "base";
            map {
               on: 1;
               rotation.center: "base";
            }
         }
      }
      part { name: "hours-sh"; mouse_events: 0;
         description { state: "default" 0.0;
            image.normal: "tacho_hand_small_shadow.png";
            rel1.to: "hours";
            rel1.relative: 0.0 (15/380);
            rel1.offset: 0 1;
            rel2.to: "hours";
            rel2.relative: 1.0 (395/380);
            rel2.offset: -1 0;
            map {
               on: 1;
               rotation.center: "hours-sh";
            }
         }
      }
      part { name: "hours"; mouse_events: 0;
         description { state: "default" 0.0;
            image.normal: "tacho_hand_small_min";
            color: 255 255 255 255;
            rel1.to: "base";
            rel2.to: "base";
            map {
               on: 1;
               rotation.center: "base";
            }
         }
      }
      part { name: "over"; mouse_events: 0;
         description { state: "default" 0.0;
            rel1.to: "base";
            rel2.to: "base";
            image.normal: "inset_round_shading.png";
         }
      }
      part { name: "knob"; type: SPACER;
         description { state: "default" 0.0;
            rel1.relative: (140/340) (140/340);
            rel1.to: "base";
            rel2.relative: (205/340) (205/340);
            rel2.to: "base";
            min: 4 4;
            step: 2 2;
            max: 24 24;
         }
      }
      part { name: "knob2";
         description { state: "default" 0.0;
            rel1.offset: -4 -4;
            rel1.to: "knob";
            rel2.offset: 3 3;
            rel2.to: "knob";
            min: 12 12;
            max: 32 32;
            image.normal: "knob";
         }
      }
   }
   programs {
      program {
         signal: "load"; source: "";
         script {
            clock_cb(0);
         }
      }
      program {
         signal: "e,state,seconds,on"; source: "e";
         action: STATE_SET "default" 0.0;
         target: "seconds";
         target: "seconds-sh";
         after: "sec2";
      }
      program { name: "sec2";
         script {
            new tim;
            
            set_int(do_seconds, 1);
            tim = get_int(tick_timer);
            if (tim) {
               cancel_timer(tim);
               set_int(tick_timer, 0);
            }
            clock_cb(0);
         }
      }
      program {
         signal: "e,state,seconds,off"; source: "e";
         action: STATE_SET "hidden" 0.0;
         target: "seconds";
         target: "seconds-sh";
         after: "sec3";
      }
      program { name: "sec3";
         script {
            new tim;
            
            set_int(do_seconds, 0);
            tim = get_int(tick_timer);
            if (tim) {
               cancel_timer(tim);
               set_int(tick_timer, 0);
            }
            clock_cb(0);
         }
      }
   }
}

group { name: "e/modules/clock/calendar/dayname";
   parts {
      part { name: "e.text.label"; type: TEXT; mouse_events: 0;
         effect: SHADOW BOTTOM;
         scale: 1;
         description { state: "default" 0.0;
            color: FN_COL_DISABLE;
            text { font: FN; size: 8;
               text: "WWe";
               min: 1 1;
               ellipsis: -1;
               align: 0.5 0.5;
               text_class: "module_small";
            }
         }
         description { state: "weekend" 0.0;
            inherit: "default" 0.0;
            color: 48 48 48 255;
         }
      }
   }
   programs {
      program {
         signal: "e,state,weekend"; source: "e";
         action: STATE_SET "weekend" 0.0;
         target: "e.text.label";
      }
      program {
         signal: "e,state,weekday"; source: "e";
         action: STATE_SET "default" 0.0;
         target: "e.text.label";
      }
   }
}

group { name: "e/modules/clock/calendar/day";
   script {
      public day_state = 0;
      evalstate() {
         new vv = get_int(day_state);
         
         if (vv & 2)
           {
              set_state(PART:"e.text.label", "today", 0.0);
              set_state(PART:"label2", "today", 0.0);
           }
         else if (vv & 4)
           {
              set_state(PART:"e.text.label", "hidden", 0.0);
              set_state(PART:"label2", "default", 0.0);
           }
         else if (vv & 1)
           {
              set_state(PART:"e.text.label", "weekend", 0.0);
              set_state(PART:"label2", "default", 0.0);
           }
         else
           {
              set_state(PART:"e.text.label", "default", 0.0);
              set_state(PART:"label2", "default", 0.0);
           }
      }
   }
   parts {
      part { name: "e.text.label"; type: TEXT; mouse_events: 0;
         effect: SHADOW BOTTOM;
         scale: 1;
         description { state: "default" 0.0;
            color: FN_COL_DEFAULT;
            text { font: FN; size: 10;
               text: "00";
               min: 1 1;
               ellipsis: -1;
               align: 0.5 0.5;
            }
         }
         description { state: "today" 0.0;
            inherit: "default" 0.0;
            visible: 0;
         }
         description { state: "weekend" 0.0;
            inherit: "default" 0.0;
            color: FN_COL_MID_GREY;
         }
         description { state: "hidden" 0.0;
            inherit: "default" 0.0;
            color: FN_COL_DISABLE;
         }
      }
      part { name: "label2"; type: TEXT; mouse_events: 0;
         effect: GLOW;
         scale: 1;
         description { state: "default" 0.0;
            rel1.offset: -3 -3;
            rel1.to: "e.text.label";
            rel2.offset: 2 1;
            rel2.to: "e.text.label";
            color: FN_COL_HIGHLIGHT;
            text { font: FN; size: 10;
               text_source: "e.text.label";
               min: 1 1;
               ellipsis: -1;
               align: 0.5 0.5;
            }
            visible: 0;
         }
         description { state: "today" 0.0;
            inherit: "default" 0.0;
            visible: 1;
         }
      }
   }
   programs {
      program {
         signal: "e,state,weekend"; source: "e";
         script {
            new vv = get_int(day_state);
            set_int(day_state, vv | 1);
            evalstate();
         }
      }
      program {
         signal: "e,state,weekday"; source: "e";
         script {
            new vv = get_int(day_state);
            set_int(day_state, vv & (~1));
            evalstate();
         }
      }
      
      program {
         signal: "e,state,today"; source: "e";
         script {
            new vv = get_int(day_state);
            set_int(day_state, vv | 2);
            evalstate();
         }
      }
      program {
         signal: "e,state,someday"; source: "e";
         script {
            new vv = get_int(day_state);
            set_int(day_state, vv & (~2));
            evalstate();
         }
      }
      
      program {
         signal: "e,state,hidden"; source: "e";
         script {
            new vv = get_int(day_state);
            set_int(day_state, vv | 4);
            evalstate();
         }
      }
      program {
         signal: "e,state,visible"; source: "e";
         script {
            new vv = get_int(day_state);
            set_int(day_state, vv & (~4));
            evalstate();
         }
      }
   }
}

group { name: "e/modules/clock/calendar";
   images.image: "separator_horiz.png" COMP;
   images.image: "sym_left_light_normal.png" COMP;
   images.image: "sym_right_light_normal.png" COMP;
   images.image: "sym_left_glow_normal.png" COMP;
   images.image: "sym_right_glow_normal.png" COMP;
   parts {
      part { name: "e.text.month"; type: TEXT;
         effect: SHADOW BOTTOM;
         mouse_events: 1;
         scale: 1;
         description { state: "default" 0.0;
            fixed: 0 1;
            align: 0.0 0.0;
            rel1.to_x: "prev";
            rel1.relative: 1.0 0.0;
            rel2.relative: 1.0 0.0;
            color: FN_COL_DEFAULT;
            text { font: FNBD; size: 10;
               text: "000000000000";
               align: 0.0 0.5;
               min: 0 1;
               text_class: "module_normal";
            }
         }
      }
      part { name: "e.text.year"; type: TEXT; mouse_events: 0;
         effect: SHADOW BOTTOM;
         scale: 1;
         description { state: "default" 0.0;
            fixed: 0 1;
            align: 1.0 0.0;
            rel1.relative: 0.0 0.0;
            rel2.to_x: "next";
            rel2.relative: 0.0 0.0;
            color: FN_COL_DEFAULT;
            text { font: FNBD; size: 10;
               text: "0000";
               align: 1.0 0.5;
               min: 0 1;
               text_class: "module_normal";
            }
         }
      }
      part { name: "previm"; mouse_events: 0;
         description { state: "default" 0.0;
            min: 15 15;
            max: 15 15;
            rel1.to: "prev";
            rel2.to: "prev";
            image.normal: "sym_left_light_normal.png";
         }
         description { state: "pressed" 0.0;
            inherit: "default" 0.0;
            image.normal: "sym_left_glow_normal.png";
         }
      }
      part { name: "prev"; type: RECT;
         description { state: "default" 0.0;
            align: 0.0 0.5;
            color: 0 0 0 0;
            aspect: 1.0 1.0; aspect_preference: VERTICAL;
            rel1.to_y: "e.text.month";
            rel1.relative: 0.0 0.0;
            rel2.to_y: "e.text.month";
            rel2.relative: 0.0 1.0;
         }
         program { name: "prev_down";
            signal: "mouse,down,1*"; source: "prev";
            action: STATE_SET "pressed" 0.0;
            target: "previm";
         }
         program { name: "prev_up";
            signal: "mouse,up,1"; source: "prev";
            action: STATE_SET "default" 0.0;
            target: "previm";
         }
         program { name: "prev_clicked";
            signal: "mouse,clicked,1*"; source: "prev";
            action: SIGNAL_EMIT "e,action,prev" "";
         }
      }
      part { name: "nextim"; mouse_events: 0;
         description { state: "default" 0.0;
            min: 15 15;
            max: 15 15;
            rel1.to: "next";
            rel2.to: "next";
            image.normal: "sym_right_light_normal.png";
         }
         description { state: "pressed" 0.0;
            inherit: "default" 0.0;
            image.normal: "sym_right_glow_normal.png";
         }
      }
      part { name: "next"; type: RECT;
         description { state: "default" 0.0;
            align: 1.0 0.5;
            color: 0 0 0 0;
            aspect: 1.0 1.0; aspect_preference: VERTICAL;
            rel1.to_y: "e.text.month";
            rel1.relative: 1.0 0.0;
            rel2.to_y: "e.text.month";
            rel2.relative: 1.0 1.0;
         }
         program { name: "next_down";
            signal: "mouse,down,1"; source: "next";
            action: STATE_SET "pressed" 0.0;
            target: "nextim";
         }
         program { name: "next_up";
            signal: "mouse,up,1"; source: "next";
            action: STATE_SET "default" 0.0;
            target: "nextim";
         }
         program { name: "next_clicked";
            signal: "mouse,clicked,1"; source: "next";
            action: SIGNAL_EMIT "e,action,next" "";
         }
      }
      part { name: "sel";
         description { state: "default" 0.0;
            image.normal: "separator_horiz.png";
            rel1.relative: 0.0 1.0;
            rel1.offset: 0 0;
            rel1.to: "e.table.daynames";
            rel2.offset: -1 1;
            rel2.to: "e.table.daynames";
            min: 0 2;
            fill.smooth: 0;
         }
      }
      
      part { name: "e.table.daynames"; type: TABLE;
         description { state: "default" 0.0;
            fixed: 0 1;
            align: 0.5 0.0;
            rel1.to_y: "e.text.month";
            rel1.relative: 0.0 1.0;
            rel1.offset: 2 2;
            rel2.to_y: "e.text.month";
            rel2.relative: 1.0 1.0;
            rel2.offset: -3 2;
            step: 7 1;
            table { homogeneous: TABLE;
               padding: 1 1;
               align: 0.5 0.5;
               min: 1 1;
            }
         }
         table {
            items {
#define D(x) \
item { \
   position: x 0; \
   span: 1 1; \
   source: "e/modules/clock/calendar/dayname"; \
   weight: 1.0 1.0; \
   align: -1.0 -1.0; \
}
               D(0) D(1) D(2) D(3) D(4) D(5) D(6)
#undef D                 
            }
         }
      }
      part { name: "e.table.days"; type: TABLE;
         description { state: "default" 0.0;
            rel1.to_y: "e.table.daynames";
            rel1.relative: 0.0 1.0;
            rel1.offset: 2 2;
            rel2.offset: -3 -3;
            step: 7 5;
            table { homogeneous: TABLE;
               padding: 1 1;
               align: 0.5 0.5;
               min: 1 1;
            }
         }
         table {
            items {
#define D(x, y) \
item { \
   position: x y; \
   span: 1 1; \
   source: "e/modules/clock/calendar/day"; \
   weight: 1.0 1.0; \
   align: -1.0 -1.0; \
}
               D(0, 0) D(1, 0) D(2, 0) D(3, 0) D(4, 0) D(5, 0) D(6, 0)
               D(0, 1) D(1, 1) D(2, 1) D(3, 1) D(4, 1) D(5, 1) D(6, 1)
               D(0, 2) D(1, 2) D(2, 2) D(3, 2) D(4, 2) D(5, 2) D(6, 2)
               D(0, 3) D(1, 3) D(2, 3) D(3, 3) D(4, 3) D(5, 3) D(6, 3)
               D(0, 4) D(1, 4) D(2, 4) D(3, 4) D(4, 4) D(5, 4) D(6, 4)
               D(0, 5) D(1, 5) D(2, 5) D(3, 5) D(4, 5) D(5, 5) D(6, 5)
#undef D
            }
         }
      }
   }
}