diff options
Diffstat (limited to 'apps/gui/statusbar-skinned.c')
-rw-r--r-- | apps/gui/statusbar-skinned.c | 126 |
1 files changed, 82 insertions, 44 deletions
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 | { |