diff options
Diffstat (limited to 'apps/gui')
-rw-r--r-- | apps/gui/backdrop.c | 202 | ||||
-rw-r--r-- | apps/gui/backdrop.h | 28 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_buffer.c | 11 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_display.c | 4 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_engine.h | 9 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_parser.c | 113 | ||||
-rw-r--r-- | apps/gui/skin_engine/wps_internals.h | 3 | ||||
-rw-r--r-- | apps/gui/statusbar-skinned.c | 126 | ||||
-rw-r--r-- | apps/gui/statusbar-skinned.h | 10 | ||||
-rw-r--r-- | apps/gui/usb_screen.c | 32 | ||||
-rw-r--r-- | apps/gui/viewport.c | 91 | ||||
-rw-r--r-- | apps/gui/wps.c | 17 |
12 files changed, 250 insertions, 396 deletions
diff --git a/apps/gui/backdrop.c b/apps/gui/backdrop.c index 058eaa5de4..e460b87108 100644 --- a/apps/gui/backdrop.c +++ b/apps/gui/backdrop.c | |||
@@ -27,213 +27,53 @@ | |||
27 | #endif | 27 | #endif |
28 | #include "backdrop.h" | 28 | #include "backdrop.h" |
29 | 29 | ||
30 | static fb_data main_backdrop[LCD_FBHEIGHT][LCD_FBWIDTH] | 30 | bool backdrop_load(const char* filename, char *backdrop_buffer) |
31 | __attribute__ ((aligned (16))); | ||
32 | static fb_data skin_backdrop[LCD_FBHEIGHT][LCD_FBWIDTH] | ||
33 | __attribute__ ((aligned (16))); | ||
34 | |||
35 | #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 | ||
36 | static fb_remote_data | ||
37 | remote_skin_backdrop[LCD_REMOTE_FBHEIGHT][LCD_REMOTE_FBWIDTH]; | ||
38 | static bool remote_skin_backdrop_valid = false; | ||
39 | #endif | ||
40 | |||
41 | static bool main_backdrop_valid = false; | ||
42 | static bool skin_backdrop_valid = false; | ||
43 | |||
44 | /* load a backdrop into a buffer */ | ||
45 | static bool load_backdrop(const char* filename, fb_data* backdrop_buffer) | ||
46 | { | 31 | { |
47 | struct bitmap bm; | 32 | struct bitmap bm; |
48 | int ret; | 33 | int ret; |
49 | 34 | ||
50 | /* load the image */ | 35 | /* load the image */ |
51 | bm.data=(char*)backdrop_buffer; | 36 | bm.data = backdrop_buffer; |
52 | ret = read_bmp_file(filename, &bm, sizeof(main_backdrop), | 37 | ret = read_bmp_file(filename, &bm, LCD_BACKDROP_BYTES, |
53 | FORMAT_NATIVE | FORMAT_DITHER, NULL); | 38 | FORMAT_NATIVE | FORMAT_DITHER, NULL); |
54 | 39 | ||
55 | return ((ret > 0) | 40 | return ((ret > 0) |
56 | && (bm.width == LCD_WIDTH) && (bm.height == LCD_HEIGHT)); | 41 | && (bm.width == LCD_WIDTH) && (bm.height == LCD_HEIGHT)); |
57 | } | 42 | } |
58 | 43 | ||
59 | static bool load_main_backdrop(const char* filename) | 44 | |
60 | { | 45 | void backdrop_show(char *backdrop_buffer) |
61 | main_backdrop_valid = load_backdrop(filename, &main_backdrop[0][0]); | ||
62 | return main_backdrop_valid; | ||
63 | } | ||
64 | |||
65 | static inline bool load_skin_backdrop(const char* filename) | ||
66 | { | ||
67 | skin_backdrop_valid = load_backdrop(filename, &skin_backdrop[0][0]); | ||
68 | return skin_backdrop_valid; | ||
69 | } | ||
70 | |||
71 | static inline void unload_main_backdrop(void) | ||
72 | { | ||
73 | main_backdrop_valid = false; | ||
74 | } | ||
75 | |||
76 | static inline void unload_skin_backdrop(void) | ||
77 | { | 46 | { |
78 | skin_backdrop_valid = false; | 47 | lcd_set_backdrop((fb_data*)backdrop_buffer); |
79 | } | 48 | } |
49 | |||
80 | 50 | ||
81 | static inline void show_main_backdrop(void) | 51 | #if defined(HAVE_REMOTE_LCD) |
82 | { | ||
83 | lcd_set_backdrop(main_backdrop_valid ? &main_backdrop[0][0] : NULL); | ||
84 | } | ||
85 | |||
86 | static void show_skin_backdrop(void) | ||
87 | { | ||
88 | /* if no wps backdrop, fall back to main backdrop */ | ||
89 | if(skin_backdrop_valid) | ||
90 | { | ||
91 | lcd_set_backdrop(&skin_backdrop[0][0]); | ||
92 | } | ||
93 | else | ||
94 | { | ||
95 | show_main_backdrop(); | ||
96 | } | ||
97 | } | ||
98 | 52 | ||
53 | #if LCD_REMOTE_DEPTH > 1 | ||
99 | /* api functions */ | 54 | /* api functions */ |
100 | 55 | bool remote_backdrop_load(const char *filename, char* backdrop_buffer) | |
101 | bool backdrop_load(enum backdrop_type bdrop, const char* filename) | ||
102 | { | ||
103 | if (bdrop == BACKDROP_MAIN) | ||
104 | return load_main_backdrop(filename); | ||
105 | else if (bdrop == BACKDROP_SKIN_WPS) | ||
106 | return load_skin_backdrop(filename); | ||
107 | else | ||
108 | return false; | ||
109 | } | ||
110 | |||
111 | void backdrop_unload(enum backdrop_type bdrop) | ||
112 | { | ||
113 | if (bdrop == BACKDROP_MAIN) | ||
114 | unload_main_backdrop(); | ||
115 | else if (bdrop == BACKDROP_SKIN_WPS) | ||
116 | unload_skin_backdrop(); | ||
117 | } | ||
118 | |||
119 | void backdrop_show(enum backdrop_type bdrop) | ||
120 | { | ||
121 | if (bdrop == BACKDROP_MAIN) | ||
122 | show_main_backdrop(); | ||
123 | else if (bdrop == BACKDROP_SKIN_WPS) | ||
124 | show_skin_backdrop(); | ||
125 | } | ||
126 | |||
127 | void backdrop_hide(void) | ||
128 | { | ||
129 | lcd_set_backdrop(NULL); | ||
130 | } | ||
131 | |||
132 | |||
133 | |||
134 | #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 | ||
135 | |||
136 | static bool load_remote_backdrop(const char* filename, | ||
137 | fb_remote_data* backdrop_buffer) | ||
138 | { | 56 | { |
139 | struct bitmap bm; | 57 | struct bitmap bm; |
140 | int ret; | 58 | int ret; |
141 | 59 | ||
142 | /* load the image */ | 60 | /* load the image */ |
143 | bm.data=(char*)backdrop_buffer; | 61 | bm.data = backdrop_buffer; |
144 | ret = read_bmp_file(filename, &bm, sizeof(main_backdrop), | 62 | ret = read_bmp_file(filename, &bm, REMOTE_LCD_BACKDROP_BYTES, |
145 | FORMAT_NATIVE | FORMAT_DITHER | FORMAT_REMOTE, NULL); | 63 | FORMAT_NATIVE | FORMAT_DITHER | FORMAT_REMOTE, NULL); |
146 | |||
147 | return ((ret > 0) | 64 | return ((ret > 0) |
148 | && (bm.width == LCD_REMOTE_WIDTH) | 65 | && (bm.width == REMOTE_LCD_WIDTH) && (bm.height == REMOTE_LCD_HEIGHT)); |
149 | && (bm.height == LCD_REMOTE_HEIGHT)); | ||
150 | } | ||
151 | |||
152 | static inline bool load_remote_skin_backdrop(const char* filename) | ||
153 | { | ||
154 | remote_skin_backdrop_valid = | ||
155 | load_remote_backdrop(filename, &remote_skin_backdrop[0][0]); | ||
156 | return remote_skin_backdrop_valid; | ||
157 | } | ||
158 | |||
159 | static inline void unload_remote_skin_backdrop(void) | ||
160 | { | ||
161 | remote_skin_backdrop_valid = false; | ||
162 | } | ||
163 | |||
164 | static inline void show_remote_main_backdrop(void) | ||
165 | { | ||
166 | lcd_remote_set_backdrop(NULL); | ||
167 | } | ||
168 | |||
169 | static inline void show_remote_skin_backdrop(void) | ||
170 | { | ||
171 | /* if no wps backdrop, fall back to main backdrop */ | ||
172 | if(remote_skin_backdrop_valid) | ||
173 | { | ||
174 | lcd_remote_set_backdrop(&remote_skin_backdrop[0][0]); | ||
175 | } | ||
176 | else | ||
177 | { | ||
178 | show_remote_main_backdrop(); | ||
179 | } | ||
180 | } | ||
181 | |||
182 | |||
183 | /* api functions */ | ||
184 | bool remote_backdrop_load(enum backdrop_type bdrop, | ||
185 | const char *filename) | ||
186 | { | ||
187 | if (bdrop == BACKDROP_SKIN_WPS) | ||
188 | return load_remote_skin_backdrop(filename); | ||
189 | else if (bdrop == BACKDROP_MAIN) | ||
190 | return true; | ||
191 | else | ||
192 | return false; | ||
193 | } | ||
194 | |||
195 | void remote_backdrop_show(enum backdrop_type bdrop) | ||
196 | { | ||
197 | if (bdrop == BACKDROP_MAIN) | ||
198 | show_remote_main_backdrop(); | ||
199 | else if (bdrop == BACKDROP_SKIN_WPS) | ||
200 | show_remote_skin_backdrop(); | ||
201 | } | ||
202 | |||
203 | void remote_backdrop_unload(enum backdrop_type bdrop) | ||
204 | { | ||
205 | if (bdrop != BACKDROP_MAIN) | ||
206 | unload_remote_skin_backdrop(); | ||
207 | } | ||
208 | |||
209 | |||
210 | void remote_backdrop_hide(void) | ||
211 | { | ||
212 | lcd_remote_set_backdrop(NULL); | ||
213 | } | ||
214 | #else | ||
215 | /* api functions */ | ||
216 | bool remote_backdrop_load(enum backdrop_type bdrop, | ||
217 | const char *filename) | ||
218 | { | ||
219 | (void)bdrop; (void)filename; | ||
220 | return true; | ||
221 | } | 66 | } |
67 | #else /* needs stubs */ | ||
222 | 68 | ||
223 | void remote_backdrop_show(enum backdrop_type bdrop) | 69 | bool remote_backdrop_load(const char *filename, char* backdrop_buffer) |
224 | { | 70 | { |
225 | (void)bdrop; | 71 | (void)filename; (void) backdrop_buffer; |
72 | return false; | ||
226 | } | 73 | } |
227 | 74 | void remote_backdrop_show(char* backdrop_buffer) | |
228 | void remote_backdrop_unload(enum backdrop_type bdrop) | ||
229 | { | ||
230 | (void)bdrop; | ||
231 | } | ||
232 | |||
233 | |||
234 | void remote_backdrop_hide(void) | ||
235 | { | 75 | { |
76 | (void)backdrop_buffer; | ||
236 | } | 77 | } |
237 | #endif | 78 | #endif |
238 | 79 | #endif | |
239 | |||
diff --git a/apps/gui/backdrop.h b/apps/gui/backdrop.h index 3b873fd137..735a884606 100644 --- a/apps/gui/backdrop.h +++ b/apps/gui/backdrop.h | |||
@@ -22,29 +22,29 @@ | |||
22 | #ifndef _BACKDROP_H | 22 | #ifndef _BACKDROP_H |
23 | #define _BACKDROP_H | 23 | #define _BACKDROP_H |
24 | 24 | ||
25 | enum backdrop_type { | ||
26 | BACKDROP_MAIN, | ||
27 | BACKDROP_SKIN_WPS, | ||
28 | }; | ||
29 | |||
30 | #if LCD_DEPTH > 1 && !defined(__PCTOOL__) | 25 | #if LCD_DEPTH > 1 && !defined(__PCTOOL__) |
31 | 26 | ||
32 | #include "lcd.h" | 27 | #include "lcd.h" |
33 | #include "bmp.h" | 28 | #include "bmp.h" |
34 | 29 | ||
35 | bool backdrop_load(enum backdrop_type bdrop, const char*); | 30 | #define LCD_BACKDROP_BYTES (LCD_FBHEIGHT*LCD_FBWIDTH*sizeof(fb_data)) |
36 | void backdrop_unload(enum backdrop_type bdrop); | 31 | #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 |
37 | void backdrop_show(enum backdrop_type bdrop); | 32 | #define REMOTE_LCD_BACKDROP_BYTES \ |
38 | void backdrop_hide(void); | 33 | (LCD_REMOTE_FBHEIGHT*LCD_REMOTE_FBWIDTH*sizeof(fb_remote_data)) |
34 | #else | ||
35 | #define REMOTE_LCD_BACKDROP_BYTES 0 | ||
36 | #endif | ||
37 | |||
38 | bool backdrop_load(const char *filename, char* backdrop_buffer); | ||
39 | void backdrop_show(char* backdrop_buffer); | ||
39 | 40 | ||
41 | #else | ||
42 | #define LCD_BACKDROP_BYTES 0 | ||
40 | #endif | 43 | #endif |
41 | 44 | ||
42 | #if defined(HAVE_REMOTE_LCD) | 45 | #if defined(HAVE_REMOTE_LCD) |
43 | /* no main backdrop, stubs! */ | 46 | bool remote_backdrop_load(const char *filename, char* backdrop_buffer); |
44 | bool remote_backdrop_load(enum backdrop_type bdrop,const char* filename); | 47 | void remote_backdrop_show(char* backdrop_buffer); |
45 | void remote_backdrop_unload(enum backdrop_type bdrop); | ||
46 | void remote_backdrop_show(enum backdrop_type bdrop); | ||
47 | void remote_backdrop_hide(void); | ||
48 | #endif | 48 | #endif |
49 | 49 | ||
50 | #endif /* _BACKDROP_H */ | 50 | #endif /* _BACKDROP_H */ |
diff --git a/apps/gui/skin_engine/skin_buffer.c b/apps/gui/skin_engine/skin_buffer.c index e647fc3f1d..a15ad10bee 100644 --- a/apps/gui/skin_engine/skin_buffer.c +++ b/apps/gui/skin_engine/skin_buffer.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include "buffer.h" | 27 | #include "buffer.h" |
28 | #include "settings.h" | 28 | #include "settings.h" |
29 | #include "screen_access.h" | 29 | #include "screen_access.h" |
30 | #include "skin_engine.h" | ||
30 | #include "wps_internals.h" | 31 | #include "wps_internals.h" |
31 | #include "skin_tokens.h" | 32 | #include "skin_tokens.h" |
32 | #include "skin_buffer.h" | 33 | #include "skin_buffer.h" |
@@ -46,7 +47,7 @@ | |||
46 | * items with unknown sizes get allocated from the start (0->) (data) | 47 | * items with unknown sizes get allocated from the start (0->) (data) |
47 | * items with known sizes get allocated from the end (<-buf_size) (tokens) | 48 | * items with known sizes get allocated from the end (<-buf_size) (tokens) |
48 | * After loading 2 skins the buffer will look like this: | 49 | * After loading 2 skins the buffer will look like this: |
49 | * |tokens skin1|images skin2|---SPACE---|data skin2|data skin1| | 50 | * |tokens skin1|images skin1|tokens s2|images s2|---SPACE---|data skin2|data skin1| |
50 | * Make sure to never start allocating from the beginning before letting us know | 51 | * Make sure to never start allocating from the beginning before letting us know |
51 | * how much was used. and RESPECT THE buf_free RETURN VALUES! | 52 | * how much was used. and RESPECT THE buf_free RETURN VALUES! |
52 | * | 53 | * |
@@ -54,12 +55,12 @@ | |||
54 | 55 | ||
55 | 56 | ||
56 | #ifdef HAVE_LCD_BITMAP | 57 | #ifdef HAVE_LCD_BITMAP |
57 | #define MAIN_BUFFER ((LCD_HEIGHT*LCD_WIDTH*LCD_DEPTH/8) \ | 58 | #define MAIN_BUFFER ((2*LCD_HEIGHT*LCD_WIDTH*LCD_DEPTH/8) \ |
58 | + (2*LCD_HEIGHT*LCD_WIDTH/8)) | 59 | + (SKINNABLE_SCREENS_COUNT * LCD_BACKDROP_BYTES)) |
59 | 60 | ||
60 | #if (NB_SCREENS > 1) | 61 | #if (NB_SCREENS > 1) |
61 | #define REMOTE_BUFFER ((LCD_REMOTE_HEIGHT*LCD_REMOTE_WIDTH*LCD_REMOTE_DEPTH/8) \ | 62 | #define REMOTE_BUFFER (2*(LCD_REMOTE_HEIGHT*LCD_REMOTE_WIDTH*LCD_REMOTE_DEPTH/8) \ |
62 | + (2*LCD_REMOTE_HEIGHT*LCD_REMOTE_WIDTH/8)) | 63 | + (SKINNABLE_SCREENS_COUNT * REMOTE_LCD_BACKDROP_BYTES)) |
63 | #else | 64 | #else |
64 | #define REMOTE_BUFFER 0 | 65 | #define REMOTE_BUFFER 0 |
65 | #endif | 66 | #endif |
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c index e90ac4c4ce..1a056291bc 100644 --- a/apps/gui/skin_engine/skin_display.c +++ b/apps/gui/skin_engine/skin_display.c | |||
@@ -1011,6 +1011,10 @@ static bool skin_redraw(struct gui_wps *gwps, unsigned refresh_mode) | |||
1011 | { | 1011 | { |
1012 | struct skin_line *line; | 1012 | struct skin_line *line; |
1013 | struct skin_viewport *skin_viewport = find_viewport(VP_DEFAULT_LABEL, data); | 1013 | struct skin_viewport *skin_viewport = find_viewport(VP_DEFAULT_LABEL, data); |
1014 | |||
1015 | #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1) | ||
1016 | display->backdrop_show(data->backdrop); | ||
1017 | #endif | ||
1014 | 1018 | ||
1015 | if (!(skin_viewport->hidden_flags & VP_NEVER_VISIBLE)) | 1019 | if (!(skin_viewport->hidden_flags & VP_NEVER_VISIBLE)) |
1016 | { | 1020 | { |
diff --git a/apps/gui/skin_engine/skin_engine.h b/apps/gui/skin_engine/skin_engine.h index 5216e9338b..c5afe3e9f5 100644 --- a/apps/gui/skin_engine/skin_engine.h +++ b/apps/gui/skin_engine/skin_engine.h | |||
@@ -27,6 +27,15 @@ | |||
27 | 27 | ||
28 | #include "wps_internals.h" /* TODO: remove this line.. shoudlnt be needed */ | 28 | #include "wps_internals.h" /* TODO: remove this line.. shoudlnt be needed */ |
29 | 29 | ||
30 | enum skinnable_screens { | ||
31 | CUSTOM_STATUSBAR, | ||
32 | WPS, | ||
33 | |||
34 | |||
35 | SKINNABLE_SCREENS_COUNT | ||
36 | }; | ||
37 | |||
38 | |||
30 | #ifdef HAVE_TOUCHSCREEN | 39 | #ifdef HAVE_TOUCHSCREEN |
31 | int wps_get_touchaction(struct wps_data *data); | 40 | int wps_get_touchaction(struct wps_data *data); |
32 | #endif | 41 | #endif |
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index c70a9759ee..4655bf0dff 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c | |||
@@ -62,6 +62,7 @@ | |||
62 | #endif | 62 | #endif |
63 | 63 | ||
64 | #include "backdrop.h" | 64 | #include "backdrop.h" |
65 | #include "statusbar-skinned.h" | ||
65 | 66 | ||
66 | #define WPS_ERROR_INVALID_PARAM -1 | 67 | #define WPS_ERROR_INVALID_PARAM -1 |
67 | 68 | ||
@@ -92,22 +93,6 @@ static struct skin_line *curr_line; | |||
92 | 93 | ||
93 | static int follow_lang_direction = 0; | 94 | static int follow_lang_direction = 0; |
94 | 95 | ||
95 | #ifdef HAVE_LCD_BITMAP | ||
96 | |||
97 | #if LCD_DEPTH > 1 | ||
98 | #define MAX_BITMAPS (MAX_IMAGES+MAX_PROGRESSBARS+1) /* WPS images + pbar bitmap + backdrop */ | ||
99 | #else | ||
100 | #define MAX_BITMAPS (MAX_IMAGES+MAX_PROGRESSBARS) /* WPS images + pbar bitmap */ | ||
101 | #endif | ||
102 | |||
103 | #define PROGRESSBAR_BMP MAX_IMAGES | ||
104 | #define BACKDROP_BMP (MAX_BITMAPS-1) | ||
105 | |||
106 | /* pointers to the bitmap filenames in the WPS source */ | ||
107 | static const char *bmp_names[MAX_BITMAPS]; | ||
108 | |||
109 | #endif /* HAVE_LCD_BITMAP */ | ||
110 | |||
111 | #if defined(DEBUG) || defined(SIMULATOR) | 96 | #if defined(DEBUG) || defined(SIMULATOR) |
112 | /* debugging function */ | 97 | /* debugging function */ |
113 | extern void print_debug_info(struct wps_data *data, int fail, int line); | 98 | extern void print_debug_info(struct wps_data *data, int fail, int line); |
@@ -925,20 +910,29 @@ static int parse_image_special(const char *wps_bufptr, | |||
925 | (void)token; | 910 | (void)token; |
926 | const char *pos = NULL; | 911 | const char *pos = NULL; |
927 | const char *newline; | 912 | const char *newline; |
913 | bool error = false; | ||
928 | 914 | ||
929 | pos = strchr(wps_bufptr + 1, '|'); | 915 | pos = strchr(wps_bufptr + 1, '|'); |
930 | newline = strchr(wps_bufptr, '\n'); | 916 | newline = strchr(wps_bufptr, '\n'); |
917 | |||
918 | error = (pos > newline); | ||
919 | |||
931 | 920 | ||
932 | if (pos > newline) | ||
933 | return WPS_ERROR_INVALID_PARAM; | ||
934 | #if LCD_DEPTH > 1 | 921 | #if LCD_DEPTH > 1 |
935 | if (token->type == WPS_TOKEN_IMAGE_BACKDROP) | 922 | if (token->type == WPS_TOKEN_IMAGE_BACKDROP) |
936 | { | 923 | { |
937 | /* format: %X|filename.bmp| */ | 924 | /* format: %X|filename.bmp| or %Xd */ |
938 | bmp_names[BACKDROP_BMP] = wps_bufptr + 1; | 925 | if (*(wps_bufptr) == 'd') |
926 | { | ||
927 | wps_data->backdrop = NULL; | ||
928 | return skip_end_of_line(wps_bufptr); | ||
929 | } | ||
930 | else if (!error) | ||
931 | wps_data->backdrop = (char*)wps_bufptr + 1; | ||
939 | } | 932 | } |
940 | #endif | 933 | #endif |
941 | 934 | if (error) | |
935 | return WPS_ERROR_INVALID_PARAM; | ||
942 | /* Skip the rest of the line */ | 936 | /* Skip the rest of the line */ |
943 | return skip_end_of_line(wps_bufptr); | 937 | return skip_end_of_line(wps_bufptr); |
944 | } | 938 | } |
@@ -1657,6 +1651,14 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr, bool debug) | |||
1657 | return false; | 1651 | return false; |
1658 | skin_buffer_increment(max_tokens * sizeof(struct wps_token), false); | 1652 | skin_buffer_increment(max_tokens * sizeof(struct wps_token), false); |
1659 | data->num_tokens = 0; | 1653 | data->num_tokens = 0; |
1654 | |||
1655 | #if LCD_DEPTH > 1 | ||
1656 | /* Backdrop defaults to the setting unless %X is used, so set it now */ | ||
1657 | if (global_settings.backdrop_file[0]) | ||
1658 | { | ||
1659 | data->backdrop = "-"; | ||
1660 | } | ||
1661 | #endif | ||
1660 | 1662 | ||
1661 | while (*wps_bufptr && !fail) | 1663 | while (*wps_bufptr && !fail) |
1662 | { | 1664 | { |
@@ -1899,6 +1901,9 @@ static void skin_data_reset(struct wps_data *wps_data) | |||
1899 | wps_data->images = NULL; | 1901 | wps_data->images = NULL; |
1900 | wps_data->progressbars = NULL; | 1902 | wps_data->progressbars = NULL; |
1901 | #endif | 1903 | #endif |
1904 | #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 | ||
1905 | wps_data->backdrop = NULL; | ||
1906 | #endif | ||
1902 | #ifdef HAVE_TOUCHSCREEN | 1907 | #ifdef HAVE_TOUCHSCREEN |
1903 | wps_data->touchregions = NULL; | 1908 | wps_data->touchregions = NULL; |
1904 | #endif | 1909 | #endif |
@@ -1996,12 +2001,51 @@ static bool load_skin_bitmaps(struct wps_data *wps_data, char *bmpdir) | |||
1996 | } | 2001 | } |
1997 | 2002 | ||
1998 | #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)) | 2003 | #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)) |
1999 | if (bmp_names[BACKDROP_BMP]) | 2004 | /* Backdrop load scheme: |
2005 | * 1) %X|filename| | ||
2006 | * 2) load the backdrop from settings | ||
2007 | */ | ||
2008 | if (wps_data->backdrop) | ||
2000 | { | 2009 | { |
2001 | char img_path[MAX_PATH]; | 2010 | char img_path[MAX_PATH]; |
2002 | get_image_filename(bmp_names[BACKDROP_BMP], bmpdir, | 2011 | bool loaded = false; |
2003 | img_path, sizeof(img_path)); | 2012 | size_t buf_size; |
2004 | screens[curr_screen].backdrop_load(BACKDROP_SKIN_WPS, img_path); | 2013 | #if defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1) |
2014 | if (curr_screen == SCREEN_REMOTE) | ||
2015 | buf_size = REMOTE_LCD_BACKDROP_BYTES; | ||
2016 | else | ||
2017 | #endif | ||
2018 | buf_size = LCD_BACKDROP_BYTES; | ||
2019 | if (wps_data->backdrop[0] == '-') | ||
2020 | { | ||
2021 | #if NB_SCREENS > 1 | ||
2022 | if (curr_screen == SCREEN_REMOTE) | ||
2023 | { | ||
2024 | wps_data->backdrop = NULL; | ||
2025 | return true; | ||
2026 | } | ||
2027 | else | ||
2028 | #endif | ||
2029 | { | ||
2030 | if (!global_settings.backdrop_file[0]) | ||
2031 | { | ||
2032 | wps_data->backdrop = NULL; | ||
2033 | return true; | ||
2034 | } | ||
2035 | snprintf(img_path, sizeof(img_path), "%s/%s.bmp", | ||
2036 | BACKDROP_DIR, global_settings.backdrop_file); | ||
2037 | } | ||
2038 | } | ||
2039 | else | ||
2040 | { | ||
2041 | get_image_filename(wps_data->backdrop, bmpdir, | ||
2042 | img_path, sizeof(img_path)); | ||
2043 | } | ||
2044 | char *buffer = skin_buffer_alloc(buf_size); | ||
2045 | if (!buffer) | ||
2046 | return false; | ||
2047 | loaded = screens[curr_screen].backdrop_load(img_path, buffer); | ||
2048 | wps_data->backdrop = loaded ? buffer : NULL; | ||
2005 | } | 2049 | } |
2006 | #endif /* has backdrop support */ | 2050 | #endif /* has backdrop support */ |
2007 | 2051 | ||
@@ -2059,7 +2103,18 @@ bool skin_data_load(enum screen_type screen, struct wps_data *wps_data, | |||
2059 | 2103 | ||
2060 | if (!isfile) | 2104 | if (!isfile) |
2061 | { | 2105 | { |
2062 | return wps_parse(wps_data, buf, false); | 2106 | if (wps_parse(wps_data, buf, false)) |
2107 | { | ||
2108 | #ifdef HAVE_LCD_BITMAP | ||
2109 | /* load the backdrop */ | ||
2110 | if (!load_skin_bitmaps(wps_data, BACKDROP_DIR)) { | ||
2111 | skin_data_reset(wps_data); | ||
2112 | return false; | ||
2113 | } | ||
2114 | #endif | ||
2115 | return true; | ||
2116 | } | ||
2117 | return false; | ||
2063 | } | 2118 | } |
2064 | else | 2119 | else |
2065 | { | 2120 | { |
@@ -2093,11 +2148,6 @@ bool skin_data_load(enum screen_type screen, struct wps_data *wps_data, | |||
2093 | if (start <= 0) | 2148 | if (start <= 0) |
2094 | return false; | 2149 | return false; |
2095 | 2150 | ||
2096 | #ifdef HAVE_LCD_BITMAP | ||
2097 | /* Set all filename pointers to NULL */ | ||
2098 | memset(bmp_names, 0, sizeof(bmp_names)); | ||
2099 | #endif | ||
2100 | |||
2101 | /* parse the WPS source */ | 2151 | /* parse the WPS source */ |
2102 | if (!wps_parse(wps_data, wps_buffer, true)) { | 2152 | if (!wps_parse(wps_data, wps_buffer, true)) { |
2103 | skin_data_reset(wps_data); | 2153 | skin_data_reset(wps_data); |
@@ -2116,6 +2166,7 @@ bool skin_data_load(enum screen_type screen, struct wps_data *wps_data, | |||
2116 | /* load the bitmaps that were found by the parsing */ | 2166 | /* load the bitmaps that were found by the parsing */ |
2117 | if (!load_skin_bitmaps(wps_data, bmpdir)) { | 2167 | if (!load_skin_bitmaps(wps_data, bmpdir)) { |
2118 | skin_data_reset(wps_data); | 2168 | skin_data_reset(wps_data); |
2169 | wps_data->wps_loaded = false; | ||
2119 | return false; | 2170 | return false; |
2120 | } | 2171 | } |
2121 | #endif | 2172 | #endif |
diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h index 837e56eab1..e659f08d35 100644 --- a/apps/gui/skin_engine/wps_internals.h +++ b/apps/gui/skin_engine/wps_internals.h | |||
@@ -271,6 +271,9 @@ struct wps_data | |||
271 | struct skin_token_list *images; | 271 | struct skin_token_list *images; |
272 | struct skin_token_list *progressbars; | 272 | struct skin_token_list *progressbars; |
273 | #endif | 273 | #endif |
274 | #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 | ||
275 | char *backdrop; | ||
276 | #endif | ||
274 | 277 | ||
275 | #ifdef HAVE_TOUCHSCREEN | 278 | #ifdef HAVE_TOUCHSCREEN |
276 | struct skin_token_list *touchregions; | 279 | struct skin_token_list *touchregions; |
diff --git a/apps/gui/statusbar-skinned.c b/apps/gui/statusbar-skinned.c index d4a4c0e828..2631b4c4f4 100644 --- a/apps/gui/statusbar-skinned.c +++ b/apps/gui/statusbar-skinned.c | |||
@@ -41,8 +41,6 @@ static struct wps_data sb_skin_data[NB_SCREENS] = {{ .wps_loaded = 0 }}; | |||
41 | static struct wps_sync_data sb_skin_sync_data = { .do_full_update = false }; | 41 | static struct wps_sync_data sb_skin_sync_data = { .do_full_update = false }; |
42 | 42 | ||
43 | /* initial setup of wps_data */ | 43 | /* initial setup of wps_data */ |
44 | |||
45 | static bool loaded_ok[NB_SCREENS] = { false }; | ||
46 | static int update_delay = DEFAULT_UPDATE_DELAY; | 44 | static int update_delay = DEFAULT_UPDATE_DELAY; |
47 | 45 | ||
48 | 46 | ||
@@ -68,66 +66,62 @@ void sb_skin_data_load(enum screen_type screen, const char *buf, bool isfile) | |||
68 | vp->hidden_flags = VP_NEVER_VISIBLE; | 66 | vp->hidden_flags = VP_NEVER_VISIBLE; |
69 | } | 67 | } |
70 | 68 | ||
71 | loaded_ok[screen] = success; | 69 | if (!success && isfile) |
70 | sb_create_from_settings(screen); | ||
72 | } | 71 | } |
73 | 72 | ||
74 | /* temporary viewport structs while the non-skinned bar is in the build */ | ||
75 | static struct viewport inbuilt[NB_SCREENS]; | ||
76 | struct viewport *sb_skin_get_info_vp(enum screen_type screen) | 73 | struct viewport *sb_skin_get_info_vp(enum screen_type screen) |
77 | { | 74 | { |
78 | int bar_setting = statusbar_position(screen); | 75 | return &find_viewport(VP_INFO_LABEL, sb_skin[screen].data)->vp; |
79 | if (bar_setting == STATUSBAR_CUSTOM) | ||
80 | return &find_viewport(VP_INFO_LABEL, sb_skin[screen].data)->vp; | ||
81 | else if (bar_setting == STATUSBAR_OFF) | ||
82 | return NULL; | ||
83 | else | ||
84 | { | ||
85 | viewport_set_fullscreen(&inbuilt[screen], screen); | ||
86 | /* WE need to return the UI area.. NOT the statusbar area! */ | ||
87 | if (bar_setting == STATUSBAR_TOP) | ||
88 | inbuilt[screen].y = STATUSBAR_HEIGHT; | ||
89 | inbuilt[screen].height -= STATUSBAR_HEIGHT; | ||
90 | return &inbuilt[screen]; | ||
91 | } | ||
92 | } | 76 | } |
93 | 77 | ||
94 | inline bool sb_skin_get_state(enum screen_type screen) | 78 | #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1) |
79 | char* sb_get_backdrop(enum screen_type screen) | ||
95 | { | 80 | { |
96 | /* Temp fix untill the hardcoded bar is removed */ | 81 | return sb_skin[screen].data->backdrop; |
97 | int bar_setting = global_settings.statusbar; | 82 | } |
98 | #if NB_SCREENS > 1 | 83 | |
99 | if (screen == SCREEN_REMOTE) | 84 | bool sb_set_backdrop(enum screen_type screen, char* filename) |
100 | bar_setting = global_settings.remote_statusbar; | 85 | { |
101 | #endif | 86 | if (!filename) |
102 | switch (bar_setting) | ||
103 | { | 87 | { |
104 | case STATUSBAR_CUSTOM: | 88 | sb_skin[screen].data->backdrop = NULL; |
105 | return loaded_ok[screen]; | 89 | return true; |
106 | case STATUSBAR_TOP: | ||
107 | case STATUSBAR_BOTTOM: | ||
108 | return true; | ||
109 | case STATUSBAR_OFF: | ||
110 | return false; | ||
111 | } | 90 | } |
112 | return false; /* Should never actually get here */ | 91 | else if (!sb_skin[screen].data->backdrop) |
92 | { | ||
93 | /* need to make room on the buffer */ | ||
94 | size_t buf_size; | ||
95 | #if defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1) | ||
96 | if (curr_screen == SCREEN_REMOTE) | ||
97 | buf_size = REMOTE_LCD_BACKDROP_BYTES; | ||
98 | else | ||
99 | #endif | ||
100 | buf_size = LCD_BACKDROP_BYTES; | ||
101 | sb_skin[screen].data->backdrop = skin_buffer_alloc(buf_size); | ||
102 | if (!sb_skin[screen].data->backdrop) | ||
103 | return false; | ||
104 | } | ||
105 | |||
106 | if (!screens[screen].backdrop_load(filename, sb_skin[screen].data->backdrop)) | ||
107 | sb_skin[screen].data->backdrop = NULL; | ||
108 | return sb_skin[screen].data->backdrop != NULL; | ||
113 | } | 109 | } |
114 | 110 | ||
111 | #endif | ||
115 | void sb_skin_update(enum screen_type screen, bool force) | 112 | void sb_skin_update(enum screen_type screen, bool force) |
116 | { | 113 | { |
117 | static long next_update = 0; | 114 | static long next_update = 0; |
118 | int i = screen; | 115 | int i = screen; |
119 | if (TIME_AFTER(current_tick, next_update) || force) | 116 | if (TIME_AFTER(current_tick, next_update) || force) |
120 | { | 117 | { |
121 | if (sb_skin_get_state(i)) | ||
122 | { | ||
123 | #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) | 118 | #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) |
124 | /* currently, all remotes are readable without backlight | 119 | /* currently, all remotes are readable without backlight |
125 | * so still update those */ | 120 | * so still update those */ |
126 | if (lcd_active() || (i != SCREEN_MAIN)) | 121 | if (lcd_active() || (i != SCREEN_MAIN)) |
127 | #endif | 122 | #endif |
128 | skin_update(&sb_skin[i], force? | 123 | skin_update(&sb_skin[i], force? |
129 | WPS_REFRESH_ALL : WPS_REFRESH_NON_STATIC); | 124 | WPS_REFRESH_ALL : WPS_REFRESH_NON_STATIC); |
130 | } | ||
131 | next_update = current_tick + update_delay; /* don't update too often */ | 125 | next_update = current_tick + update_delay; /* don't update too often */ |
132 | sb_skin[SCREEN_MAIN].sync_data->do_full_update = false; | 126 | sb_skin[SCREEN_MAIN].sync_data->do_full_update = false; |
133 | } | 127 | } |
@@ -148,6 +142,50 @@ void sb_skin_set_update_delay(int delay) | |||
148 | update_delay = delay; | 142 | update_delay = delay; |
149 | } | 143 | } |
150 | 144 | ||
145 | /* This creates and loads a ".sbs" based on the user settings for: | ||
146 | * - regular statusbar | ||
147 | * - colours | ||
148 | * - ui viewport | ||
149 | * - backdrop | ||
150 | */ | ||
151 | void sb_create_from_settings(enum screen_type screen) | ||
152 | { | ||
153 | char buf[128], *ptr, *ptr2; | ||
154 | int len, remaining = sizeof(buf); | ||
155 | |||
156 | ptr = buf; | ||
157 | ptr[0] = '\0'; | ||
158 | |||
159 | /* %Vi viewport, colours handled by the parser */ | ||
160 | #if NB_SCREENS > 1 | ||
161 | if (screen == SCREEN_REMOTE) | ||
162 | ptr2 = global_settings.remote_ui_vp_config; | ||
163 | #endif | ||
164 | ptr2 = global_settings.ui_vp_config; | ||
165 | |||
166 | if (ptr2[0] && ptr2[0] != '-') /* from ui viewport setting */ | ||
167 | { | ||
168 | len = snprintf(ptr, remaining, "%%Vi|%s\n", ptr2); | ||
169 | while ((ptr2 = strchr(ptr, ','))) | ||
170 | *ptr2 = '|'; | ||
171 | } | ||
172 | else | ||
173 | { | ||
174 | int y = 0, height; | ||
175 | switch (statusbar_position(screen)) | ||
176 | { | ||
177 | case STATUSBAR_TOP: | ||
178 | y = STATUSBAR_HEIGHT; | ||
179 | case STATUSBAR_BOTTOM: | ||
180 | height = screens[screen].lcdheight - STATUSBAR_HEIGHT; | ||
181 | break; | ||
182 | default: | ||
183 | height = screens[screen].lcdheight; | ||
184 | } | ||
185 | len = snprintf(ptr, remaining, "%%Vi|0|%d|-|%d|1|-|-|\n", y, height); | ||
186 | } | ||
187 | sb_skin_data_load(screen, buf, false); | ||
188 | } | ||
151 | 189 | ||
152 | void sb_skin_init(void) | 190 | void sb_skin_init(void) |
153 | { | 191 | { |
diff --git a/apps/gui/statusbar-skinned.h b/apps/gui/statusbar-skinned.h index 6016c293b0..bbd4a65018 100644 --- a/apps/gui/statusbar-skinned.h +++ b/apps/gui/statusbar-skinned.h | |||
@@ -33,20 +33,24 @@ | |||
33 | 33 | ||
34 | void sb_skin_data_load(enum screen_type screen, const char *buf, bool isfile); | 34 | void sb_skin_data_load(enum screen_type screen, const char *buf, bool isfile); |
35 | 35 | ||
36 | /* probably temporary, to shut the classic statusbar up */ | 36 | void sb_create_from_settings(enum screen_type screen); |
37 | bool sb_skin_get_state(enum screen_type screen); | ||
38 | void sb_skin_init(void); | 37 | void sb_skin_init(void); |
39 | struct viewport *sb_skin_get_info_vp(enum screen_type screen); | 38 | struct viewport *sb_skin_get_info_vp(enum screen_type screen); |
40 | void sb_skin_update(enum screen_type screen, bool force); | 39 | void sb_skin_update(enum screen_type screen, bool force); |
41 | 40 | ||
42 | void sb_skin_set_update_delay(int delay); | 41 | void sb_skin_set_update_delay(int delay); |
43 | 42 | ||
43 | #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1) | ||
44 | char* sb_get_backdrop(enum screen_type screen); | ||
45 | bool sb_set_backdrop(enum screen_type screen, char* filename); | ||
46 | #endif | ||
47 | |||
44 | #else /* CHARCELL */ | 48 | #else /* CHARCELL */ |
45 | #define sb_skin_init() | 49 | #define sb_skin_init() |
46 | #define sb_skin_data_load(a,b,c) | 50 | #define sb_skin_data_load(a,b,c) |
47 | #define sb_skin_set_update_delay(a) | 51 | #define sb_skin_set_update_delay(a) |
48 | #define sb_skin_set_state(a,b) | 52 | #define sb_skin_set_state(a,b) |
49 | #define sb_skin_get_state(a) | 53 | #define sb_create_from_settings(a) |
50 | #endif | 54 | #endif |
51 | void do_sbs_update_callback(void *param); | 55 | void do_sbs_update_callback(void *param); |
52 | #endif /* __STATUSBAR_SKINNED_H__ */ | 56 | #endif /* __STATUSBAR_SKINNED_H__ */ |
diff --git a/apps/gui/usb_screen.c b/apps/gui/usb_screen.c index ac31708718..f74747fd5c 100644 --- a/apps/gui/usb_screen.c +++ b/apps/gui/usb_screen.c | |||
@@ -129,10 +129,10 @@ struct usb_screen_vps_t | |||
129 | }; | 129 | }; |
130 | 130 | ||
131 | #ifdef HAVE_LCD_BITMAP | 131 | #ifdef HAVE_LCD_BITMAP |
132 | static bool usb_screen_fix_viewports(struct screen *screen, | 132 | static void usb_screen_fix_viewports(struct screen *screen, |
133 | struct usb_screen_vps_t *usb_screen_vps) | 133 | struct usb_screen_vps_t *usb_screen_vps) |
134 | { | 134 | { |
135 | bool theme_needs_undo = false; | 135 | bool disable = true; |
136 | int logo_width, logo_height; | 136 | int logo_width, logo_height; |
137 | struct viewport *parent = &usb_screen_vps->parent; | 137 | struct viewport *parent = &usb_screen_vps->parent; |
138 | struct viewport *logo = &usb_screen_vps->logo; | 138 | struct viewport *logo = &usb_screen_vps->logo; |
@@ -151,11 +151,8 @@ static bool usb_screen_fix_viewports(struct screen *screen, | |||
151 | } | 151 | } |
152 | 152 | ||
153 | viewport_set_defaults(parent, screen->screen_type); | 153 | viewport_set_defaults(parent, screen->screen_type); |
154 | if (parent->width < logo_width || parent->height < logo_height) | 154 | disable = (parent->width < logo_width || parent->height < logo_height); |
155 | { | 155 | viewportmanager_theme_enable(screen->screen_type, !disable, parent); |
156 | theme_needs_undo = true; | ||
157 | viewportmanager_theme_enable(screen->screen_type, false, parent); | ||
158 | } | ||
159 | 156 | ||
160 | *logo = *parent; | 157 | *logo = *parent; |
161 | logo->x = parent->x + parent->width - logo_width; | 158 | logo->x = parent->x + parent->width - logo_width; |
@@ -179,18 +176,12 @@ static bool usb_screen_fix_viewports(struct screen *screen, | |||
179 | } | 176 | } |
180 | } | 177 | } |
181 | #endif | 178 | #endif |
182 | return theme_needs_undo; | ||
183 | } | 179 | } |
184 | #endif | 180 | #endif |
185 | 181 | ||
186 | static void usb_screens_draw(struct usb_screen_vps_t *usb_screen_vps_ar) | 182 | static void usb_screens_draw(struct usb_screen_vps_t *usb_screen_vps_ar) |
187 | { | 183 | { |
188 | int i; | 184 | int i; |
189 | lcd_clear_display(); | ||
190 | #ifdef HAVE_LCD_REMOTE | ||
191 | lcd_remote_clear_display(); | ||
192 | #endif | ||
193 | |||
194 | FOR_NB_SCREENS(i) | 185 | FOR_NB_SCREENS(i) |
195 | { | 186 | { |
196 | struct screen *screen = &screens[i]; | 187 | struct screen *screen = &screens[i]; |
@@ -202,11 +193,8 @@ static void usb_screens_draw(struct usb_screen_vps_t *usb_screen_vps_ar) | |||
202 | #endif | 193 | #endif |
203 | 194 | ||
204 | screen->set_viewport(parent); | 195 | screen->set_viewport(parent); |
205 | #if LCD_DEPTH > 1 | ||
206 | screen->backdrop_show(BACKDROP_MAIN); | ||
207 | #endif | ||
208 | screen->backlight_on(); | ||
209 | screen->clear_viewport(); | 196 | screen->clear_viewport(); |
197 | screen->backlight_on(); | ||
210 | 198 | ||
211 | #ifdef HAVE_LCD_BITMAP | 199 | #ifdef HAVE_LCD_BITMAP |
212 | screen->set_viewport(logo); | 200 | screen->set_viewport(logo); |
@@ -240,15 +228,14 @@ static void usb_screens_draw(struct usb_screen_vps_t *usb_screen_vps_ar) | |||
240 | status_set_usb(true); | 228 | status_set_usb(true); |
241 | #endif /* HAVE_LCD_BITMAP */ | 229 | #endif /* HAVE_LCD_BITMAP */ |
242 | 230 | ||
243 | screen->update_viewport(); | ||
244 | screen->set_viewport(NULL); | 231 | screen->set_viewport(NULL); |
232 | screen->update_viewport(); | ||
245 | } | 233 | } |
246 | } | 234 | } |
247 | 235 | ||
248 | void gui_usb_screen_run(void) | 236 | void gui_usb_screen_run(void) |
249 | { | 237 | { |
250 | int i; | 238 | int i; |
251 | bool screen_theme_needs_undo[NB_SCREENS]; | ||
252 | struct usb_screen_vps_t usb_screen_vps_ar[NB_SCREENS]; | 239 | struct usb_screen_vps_t usb_screen_vps_ar[NB_SCREENS]; |
253 | #if defined HAVE_TOUCHSCREEN | 240 | #if defined HAVE_TOUCHSCREEN |
254 | enum touchscreen_mode old_mode = touchscreen_get_mode(); | 241 | enum touchscreen_mode old_mode = touchscreen_get_mode(); |
@@ -273,7 +260,7 @@ void gui_usb_screen_run(void) | |||
273 | 260 | ||
274 | screen->set_viewport(NULL); | 261 | screen->set_viewport(NULL); |
275 | #ifdef HAVE_LCD_BITMAP | 262 | #ifdef HAVE_LCD_BITMAP |
276 | screen_theme_needs_undo[i] = usb_screen_fix_viewports(screen, &usb_screen_vps_ar[i]); | 263 | usb_screen_fix_viewports(screen, &usb_screen_vps_ar[i]); |
277 | #endif | 264 | #endif |
278 | } | 265 | } |
279 | 266 | ||
@@ -320,10 +307,7 @@ void gui_usb_screen_run(void) | |||
320 | FOR_NB_SCREENS(i) | 307 | FOR_NB_SCREENS(i) |
321 | { | 308 | { |
322 | screens[i].backlight_on(); | 309 | screens[i].backlight_on(); |
323 | if(screen_theme_needs_undo[i]) | 310 | viewportmanager_theme_undo(i, false); |
324 | { | ||
325 | viewportmanager_theme_undo(i, false); | ||
326 | } | ||
327 | } | 311 | } |
328 | 312 | ||
329 | } | 313 | } |
diff --git a/apps/gui/viewport.c b/apps/gui/viewport.c index fd38b18d75..78b6379bd7 100644 --- a/apps/gui/viewport.c +++ b/apps/gui/viewport.c | |||
@@ -109,11 +109,11 @@ static void toggle_theme(enum screen_type screen, bool force) | |||
109 | 109 | ||
110 | if (is_theme_enabled(screen)) | 110 | if (is_theme_enabled(screen)) |
111 | { | 111 | { |
112 | #if LCD_DEPTH > 1 || (defined(LCD_REMOTE_DEPTH) && LCD_REMOTE_DEPTH > 1) | ||
113 | screens[screen].backdrop_show(BACKDROP_MAIN); | ||
114 | #endif | ||
115 | /* remove the left overs from the previous screen. | 112 | /* remove the left overs from the previous screen. |
116 | * could cause a tiny flicker. Redo your screen code if that happens */ | 113 | * could cause a tiny flicker. Redo your screen code if that happens */ |
114 | #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1) | ||
115 | screens[screen].backdrop_show(sb_get_backdrop(screen)); | ||
116 | #endif | ||
117 | if (!was_enabled[screen] || force) | 117 | if (!was_enabled[screen] || force) |
118 | { | 118 | { |
119 | struct viewport deadspace, user; | 119 | struct viewport deadspace, user; |
@@ -165,7 +165,7 @@ static void toggle_theme(enum screen_type screen, bool force) | |||
165 | else | 165 | else |
166 | { | 166 | { |
167 | #if LCD_DEPTH > 1 || (defined(LCD_REMOTE_DEPTH) && LCD_REMOTE_DEPTH > 1) | 167 | #if LCD_DEPTH > 1 || (defined(LCD_REMOTE_DEPTH) && LCD_REMOTE_DEPTH > 1) |
168 | screens[screen].backdrop_hide(); | 168 | screens[screen].backdrop_show(NULL); |
169 | #endif | 169 | #endif |
170 | screens[screen].stop_scroll(); | 170 | screens[screen].stop_scroll(); |
171 | } | 171 | } |
@@ -204,11 +204,6 @@ static bool is_theme_enabled(enum screen_type screen) | |||
204 | int top = theme_stack_top[screen]; | 204 | int top = theme_stack_top[screen]; |
205 | return theme_stack[screen][top].enabled; | 205 | return theme_stack[screen][top].enabled; |
206 | } | 206 | } |
207 | |||
208 | static bool custom_vp_loaded_ok[NB_SCREENS]; | ||
209 | static struct viewport custom_vp[NB_SCREENS]; | ||
210 | |||
211 | static unsigned viewport_init_ui_vp(void); | ||
212 | #endif /* HAVE_LCD_BITMAP */ | 207 | #endif /* HAVE_LCD_BITMAP */ |
213 | 208 | ||
214 | int viewport_get_nb_lines(const struct viewport *vp) | 209 | int viewport_get_nb_lines(const struct viewport *vp) |
@@ -263,7 +258,6 @@ void viewportmanager_theme_changed(const int which) | |||
263 | #endif | 258 | #endif |
264 | if (which & THEME_UI_VIEWPORT) | 259 | if (which & THEME_UI_VIEWPORT) |
265 | { | 260 | { |
266 | viewport_init_ui_vp(); | ||
267 | } | 261 | } |
268 | if (which & THEME_LANGUAGE) | 262 | if (which & THEME_LANGUAGE) |
269 | { | 263 | { |
@@ -281,34 +275,6 @@ void viewportmanager_theme_changed(const int which) | |||
281 | send_event(GUI_EVENT_THEME_CHANGED, NULL); | 275 | send_event(GUI_EVENT_THEME_CHANGED, NULL); |
282 | } | 276 | } |
283 | 277 | ||
284 | /* | ||
285 | * (re)parse the UI vp from the settings | ||
286 | * - Returns | ||
287 | * 0 if no UI vp is used at all | ||
288 | * else the bit for the screen (1<<screen) is set | ||
289 | */ | ||
290 | static unsigned viewport_init_ui_vp(void) | ||
291 | { | ||
292 | int screen; | ||
293 | const char *ret = NULL; | ||
294 | char *setting; | ||
295 | FOR_NB_SCREENS(screen) | ||
296 | { | ||
297 | #ifdef HAVE_REMOTE_LCD | ||
298 | if ((screen == SCREEN_REMOTE)) | ||
299 | setting = global_settings.remote_ui_vp_config; | ||
300 | else | ||
301 | #endif | ||
302 | setting = global_settings.ui_vp_config; | ||
303 | |||
304 | ret = viewport_parse_viewport(&custom_vp[screen], screen, | ||
305 | setting, ','); | ||
306 | |||
307 | custom_vp_loaded_ok[screen] = (ret != NULL); | ||
308 | } | ||
309 | return true; /* meh fixme */ | ||
310 | } | ||
311 | |||
312 | #ifdef HAVE_TOUCHSCREEN | 278 | #ifdef HAVE_TOUCHSCREEN |
313 | /* check if a point (x and y coordinates) are within a viewport */ | 279 | /* check if a point (x and y coordinates) are within a viewport */ |
314 | bool viewport_point_within_vp(const struct viewport *vp, | 280 | bool viewport_point_within_vp(const struct viewport *vp, |
@@ -380,59 +346,18 @@ void viewport_set_fullscreen(struct viewport *vp, | |||
380 | void viewport_set_defaults(struct viewport *vp, | 346 | void viewport_set_defaults(struct viewport *vp, |
381 | const enum screen_type screen) | 347 | const enum screen_type screen) |
382 | { | 348 | { |
383 | /* Reposition: | ||
384 | 1) If the "ui viewport" setting is set, and a sbs is loaded which specifies a %Vi | ||
385 | return the intersection of those two viewports | ||
386 | 2) If only one of the "ui viewport" setting, or sbs %Vi is set | ||
387 | return it | ||
388 | 3) No user viewports set | ||
389 | return the full display | ||
390 | */ | ||
391 | #if defined(HAVE_LCD_BITMAP) && !defined(__PCTOOL__) | 349 | #if defined(HAVE_LCD_BITMAP) && !defined(__PCTOOL__) |
392 | 350 | ||
393 | struct viewport *sbs_area = NULL, *user_setting = NULL; | 351 | struct viewport *sbs_area = NULL; |
394 | if (!is_theme_enabled(screen)) | 352 | if (!is_theme_enabled(screen)) |
395 | { | 353 | { |
396 | viewport_set_fullscreen(vp, screen); | 354 | viewport_set_fullscreen(vp, screen); |
397 | return; | 355 | return; |
398 | } | ||
399 | /* get the two viewports */ | ||
400 | if (custom_vp_loaded_ok[screen]) | ||
401 | user_setting = &custom_vp[screen]; | ||
402 | if (sb_skin_get_state(screen)) | ||
403 | sbs_area = sb_skin_get_info_vp(screen); | ||
404 | |||
405 | /* have both? get their intersection */ | ||
406 | if (sbs_area && user_setting) | ||
407 | { | ||
408 | struct viewport *a = sbs_area, *b = user_setting; | ||
409 | /* if ui vp and info vp overlap, intersect */ | ||
410 | if (a->x < b->x + b->width && | ||
411 | a->x + a->width > b->x && | ||
412 | a->y < b->y + b->height && | ||
413 | a->y + a->height > b->y) | ||
414 | { | ||
415 | /* copy from ui vp first (for other field),fix coordinates after */ | ||
416 | *vp = *user_setting; | ||
417 | set_default_align_flags(vp); | ||
418 | vp->x = MAX(a->x, b->x); | ||
419 | vp->y = MAX(a->y, b->y); | ||
420 | vp->width = MIN(a->x + a->width, b->x + b->width) - vp->x; | ||
421 | vp->height = MIN(a->y + a->height, b->y + b->height) - vp->y; | ||
422 | return; | ||
423 | } | ||
424 | /* else (no overlap at all) fall back to info vp from sbs, that | ||
425 | * has no redraw problems */ | ||
426 | } | 356 | } |
427 | 357 | sbs_area = sb_skin_get_info_vp(screen); | |
428 | /* if only one is active use it | 358 | |
429 | * or if the above check for overlapping failed, use info vp then, because | ||
430 | * that doesn't give redraw problems */ | ||
431 | if (sbs_area) | 359 | if (sbs_area) |
432 | *vp = *sbs_area; | 360 | *vp = *sbs_area; |
433 | else if (user_setting) | ||
434 | *vp = *user_setting; | ||
435 | /* have neither so its fullscreen which was fixed at the beginning */ | ||
436 | else | 361 | else |
437 | #endif /* HAVE_LCD_BITMAP */ | 362 | #endif /* HAVE_LCD_BITMAP */ |
438 | viewport_set_fullscreen(vp, screen); | 363 | viewport_set_fullscreen(vp, screen); |
diff --git a/apps/gui/wps.c b/apps/gui/wps.c index 3c0982270e..ca74c452f4 100644 --- a/apps/gui/wps.c +++ b/apps/gui/wps.c | |||
@@ -99,10 +99,6 @@ void wps_data_load(enum screen_type screen, const char *buf, bool isfile) | |||
99 | { | 99 | { |
100 | bool loaded_ok; | 100 | bool loaded_ok; |
101 | 101 | ||
102 | #if LCD_DEPTH > 1 | ||
103 | screens[screen].backdrop_unload(BACKDROP_SKIN_WPS); | ||
104 | #endif | ||
105 | |||
106 | #ifndef __PCTOOL__ | 102 | #ifndef __PCTOOL__ |
107 | /* | 103 | /* |
108 | * Hardcode loading WPS_DEFAULTCFG to cause a reset ideally this | 104 | * Hardcode loading WPS_DEFAULTCFG to cause a reset ideally this |
@@ -129,6 +125,9 @@ void wps_data_load(enum screen_type screen, const char *buf, bool isfile) | |||
129 | { | 125 | { |
130 | char *skin_buf[NB_SCREENS] = { | 126 | char *skin_buf[NB_SCREENS] = { |
131 | #ifdef HAVE_LCD_BITMAP | 127 | #ifdef HAVE_LCD_BITMAP |
128 | #if LCD_DEPTH > 1 | ||
129 | "%Xd\n" | ||
130 | #endif | ||
132 | "%s%?it<%?in<%in. |>%it|%fn>\n" | 131 | "%s%?it<%?in<%in. |>%it|%fn>\n" |
133 | "%s%?ia<%ia|%?d2<%d2|(root)>>\n" | 132 | "%s%?ia<%ia|%?d2<%d2|(root)>>\n" |
134 | "%s%?id<%id|%?d1<%d1|(root)>> %?iy<(%iy)|>\n\n" | 133 | "%s%?id<%id|%?d1<%d1|(root)>> %?iy<(%iy)|>\n\n" |
@@ -140,6 +139,9 @@ void wps_data_load(enum screen_type screen, const char *buf, bool isfile) | |||
140 | "%pc%?ps<*|/>%pt\n", | 139 | "%pc%?ps<*|/>%pt\n", |
141 | #endif | 140 | #endif |
142 | #ifdef HAVE_REMOTE_LCD | 141 | #ifdef HAVE_REMOTE_LCD |
142 | #if LCD_REMOTE_DEPTH > 1 | ||
143 | "%Xd\n" | ||
144 | #endif | ||
143 | "%s%?ia<%ia|%?d2<%d2|(root)>>\n" | 145 | "%s%?ia<%ia|%?d2<%d2|(root)>>\n" |
144 | "%s%?it<%?in<%in. |>%it|%fn>\n" | 146 | "%s%?it<%?in<%in. |>%it|%fn>\n" |
145 | "%al%pc/%pt%ar[%pp:%pe]\n" | 147 | "%al%pc/%pt%ar[%pp:%pe]\n" |
@@ -563,9 +565,6 @@ static void gwps_leave_wps(void) | |||
563 | FOR_NB_SCREENS(i) | 565 | FOR_NB_SCREENS(i) |
564 | { | 566 | { |
565 | gui_wps[i].display->stop_scroll(); | 567 | gui_wps[i].display->stop_scroll(); |
566 | #if LCD_DEPTH > 1 | ||
567 | gui_wps[i].display->backdrop_show(BACKDROP_MAIN); | ||
568 | #endif | ||
569 | 568 | ||
570 | #ifdef HAVE_LCD_BITMAP | 569 | #ifdef HAVE_LCD_BITMAP |
571 | bool draw = false; | 570 | bool draw = false; |
@@ -614,7 +613,6 @@ static void gwps_enter_wps(void) | |||
614 | vp->fg_pattern = display->get_foreground(); | 613 | vp->fg_pattern = display->get_foreground(); |
615 | vp->bg_pattern = display->get_background(); | 614 | vp->bg_pattern = display->get_background(); |
616 | } | 615 | } |
617 | display->backdrop_show(BACKDROP_SKIN_WPS); | ||
618 | #endif | 616 | #endif |
619 | /* make the backdrop actually take effect */ | 617 | /* make the backdrop actually take effect */ |
620 | display->clear_display(); | 618 | display->clear_display(); |
@@ -1298,9 +1296,6 @@ void gui_sync_wps_init(void) | |||
1298 | /* Currently no seperate wps_state needed/possible | 1296 | /* Currently no seperate wps_state needed/possible |
1299 | so use the only available ( "global" ) one */ | 1297 | so use the only available ( "global" ) one */ |
1300 | gui_wps[i].state = &wps_state; | 1298 | gui_wps[i].state = &wps_state; |
1301 | #if LCD_DEPTH > 1 | ||
1302 | gui_wps[i].display->backdrop_unload(BACKDROP_SKIN_WPS); | ||
1303 | #endif | ||
1304 | /* must point to the same struct for both screens */ | 1299 | /* must point to the same struct for both screens */ |
1305 | gui_wps[i].sync_data = &wps_sync_data; | 1300 | gui_wps[i].sync_data = &wps_sync_data; |
1306 | } | 1301 | } |