diff options
author | Kevin Ferrare <kevin@rockbox.org> | 2007-08-04 03:01:46 +0000 |
---|---|---|
committer | Kevin Ferrare <kevin@rockbox.org> | 2007-08-04 03:01:46 +0000 |
commit | 93b2f9fd447b73fff736d71826880ef9ac64bd94 (patch) | |
tree | 1a4f54016c312738d66fb9dd2348ea0ef14f1255 /apps/plugins/clock/clock_draw.c | |
parent | ffbbc60f38ddc8aeadc9cea1102077e22ca84a1a (diff) | |
download | rockbox-93b2f9fd447b73fff736d71826880ef9ac64bd94.tar.gz rockbox-93b2f9fd447b73fff736d71826880ef9ac64bd94.zip |
Rewrote the clock plugin in a cleaner and more modular way so that it can scale on remote screens. Use left-right keys to change the type of clock displayed (analogic, digital, binary) and up/downto change the look of the clock
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14174 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/clock/clock_draw.c')
-rw-r--r-- | apps/plugins/clock/clock_draw.c | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/apps/plugins/clock/clock_draw.c b/apps/plugins/clock/clock_draw.c new file mode 100644 index 0000000000..daf19f7363 --- /dev/null +++ b/apps/plugins/clock/clock_draw.c | |||
@@ -0,0 +1,103 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: jackpot.c 14034 2007-07-28 05:42:55Z kevin $ | ||
9 | * | ||
10 | * Copyright (C) 2007 Copyright Kévin Ferrare | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #include "clock.h" | ||
21 | #include "clock_draw.h" | ||
22 | #include "clock_draw_digital.h" | ||
23 | #include "clock_draw_analog.h" | ||
24 | #include "clock_draw_binary.h" | ||
25 | #include "clock_settings.h" | ||
26 | |||
27 | void black_background(struct screen* display){ | ||
28 | #if (LCD_DEPTH > 1) || (defined(LCD_REMOTE_DEPTH) && (LCD_REMOTE_DEPTH > 1)) | ||
29 | if(display->depth>1){ | ||
30 | display->set_background(LCD_BLACK); | ||
31 | display->clear_display(); | ||
32 | }else | ||
33 | #endif | ||
34 | { | ||
35 | display->clear_display(); | ||
36 | display->fillrect(0,0,display->width,display->height); | ||
37 | } | ||
38 | } | ||
39 | |||
40 | void white_background(struct screen* display){ | ||
41 | #if (LCD_DEPTH > 1) || (defined(LCD_REMOTE_DEPTH) && (LCD_REMOTE_DEPTH > 1)) | ||
42 | if(display->depth>1){ | ||
43 | #if defined(HAVE_LCD_COLOR) | ||
44 | if(display->is_color)/* restore to the bitmap's background */ | ||
45 | display->set_background(LCD_RGBPACK(180,200,230)); | ||
46 | else | ||
47 | #endif | ||
48 | display->set_background(LCD_WHITE); | ||
49 | } | ||
50 | #endif | ||
51 | display->clear_display(); | ||
52 | } | ||
53 | |||
54 | bool skin_require_black_background(int mode, int skin){ | ||
55 | return((mode==BINARY && skin==2) || (mode==DIGITAL && skin==1 )); | ||
56 | } | ||
57 | |||
58 | void skin_set_background(struct screen* display, int mode, int skin){ | ||
59 | if(skin_require_black_background(mode, skin) ) | ||
60 | black_background(display); | ||
61 | else | ||
62 | white_background(display); | ||
63 | } | ||
64 | |||
65 | void skin_restore_background(struct screen* display, int mode, int skin){ | ||
66 | if(skin_require_black_background(mode, skin) ) | ||
67 | white_background(display); | ||
68 | } | ||
69 | |||
70 | void clock_draw_set_colors(void){ | ||
71 | int i; | ||
72 | FOR_NB_SCREENS(i) | ||
73 | skin_set_background(rb->screens[i], | ||
74 | clock_settings.mode, | ||
75 | clock_settings.skin[clock_settings.mode]); | ||
76 | } | ||
77 | |||
78 | void clock_draw_restore_colors(void){ | ||
79 | int i; | ||
80 | FOR_NB_SCREENS(i){ | ||
81 | skin_restore_background(rb->screens[i], | ||
82 | clock_settings.mode, | ||
83 | clock_settings.skin[clock_settings.mode]); | ||
84 | rb->screens[i]->update(); | ||
85 | } | ||
86 | } | ||
87 | |||
88 | void clock_draw(struct screen* display, struct time* time, | ||
89 | struct counter* counter){ | ||
90 | if(!clock_settings.general.show_counter) | ||
91 | counter=0; | ||
92 | int skin=clock_settings.skin[clock_settings.mode]; | ||
93 | skin_set_background(display, clock_settings.mode, skin); | ||
94 | if(clock_settings.mode == ANALOG) | ||
95 | analog_clock_draw(display, time, &clock_settings, counter, skin); | ||
96 | |||
97 | else if(clock_settings.mode == DIGITAL) | ||
98 | digital_clock_draw(display, time, &clock_settings, counter, skin); | ||
99 | |||
100 | else if(clock_settings.mode == BINARY) | ||
101 | binary_clock_draw(display, time, skin); | ||
102 | display->update(); | ||
103 | } | ||