diff options
-rw-r--r-- | apps/gui/quickscreen.c | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/apps/gui/quickscreen.c b/apps/gui/quickscreen.c index 3a35b24f35..87d1514d18 100644 --- a/apps/gui/quickscreen.c +++ b/apps/gui/quickscreen.c | |||
@@ -56,7 +56,7 @@ static void quickscreen_fix_viewports(struct gui_quickscreen *qs, | |||
56 | struct viewport *vp_icons) | 56 | struct viewport *vp_icons) |
57 | { | 57 | { |
58 | int char_height, width, pad = 0; | 58 | int char_height, width, pad = 0; |
59 | int left_width, right_width, vert_lines; | 59 | int left_width = 0, right_width = 0, vert_lines; |
60 | unsigned char *s; | 60 | unsigned char *s; |
61 | int nb_lines = viewport_get_nb_lines(parent); | 61 | int nb_lines = viewport_get_nb_lines(parent); |
62 | 62 | ||
@@ -65,7 +65,7 @@ static void quickscreen_fix_viewports(struct gui_quickscreen *qs, | |||
65 | */ | 65 | */ |
66 | if (nb_lines == 0) | 66 | if (nb_lines == 0) |
67 | nb_lines++; | 67 | nb_lines++; |
68 | 68 | ||
69 | char_height = parent->height/nb_lines; | 69 | char_height = parent->height/nb_lines; |
70 | 70 | ||
71 | /* center the icons VP first */ | 71 | /* center the icons VP first */ |
@@ -74,7 +74,6 @@ static void quickscreen_fix_viewports(struct gui_quickscreen *qs, | |||
74 | vp_icons->x = parent->x; | 74 | vp_icons->x = parent->x; |
75 | vp_icons->x += (parent->width-CENTER_ICONAREA_SIZE)/2; | 75 | vp_icons->x += (parent->width-CENTER_ICONAREA_SIZE)/2; |
76 | 76 | ||
77 | |||
78 | vps[QUICKSCREEN_BOTTOM] = *parent; | 77 | vps[QUICKSCREEN_BOTTOM] = *parent; |
79 | vps[QUICKSCREEN_TOP] = *parent; | 78 | vps[QUICKSCREEN_TOP] = *parent; |
80 | /* depending on the space the top/buttom items use 1 or 2 lines */ | 79 | /* depending on the space the top/buttom items use 1 or 2 lines */ |
@@ -97,14 +96,19 @@ static void quickscreen_fix_viewports(struct gui_quickscreen *qs, | |||
97 | 96 | ||
98 | vp_icons->y = vps[QUICKSCREEN_TOP].y | 97 | vp_icons->y = vps[QUICKSCREEN_TOP].y |
99 | + vps[QUICKSCREEN_TOP].height; | 98 | + vps[QUICKSCREEN_TOP].height; |
100 | vp_icons->height = parent->height - vp_icons->y; | 99 | vp_icons->height = vps[QUICKSCREEN_BOTTOM].y - vp_icons->y; |
101 | vp_icons->height -= parent->height - vps[QUICKSCREEN_BOTTOM].y; | ||
102 | 100 | ||
103 | /* adjust the left/right items widths to fit the screen nicely */ | 101 | /* adjust the left/right items widths to fit the screen nicely */ |
104 | s = P2STR(ID2P(qs->items[QUICKSCREEN_LEFT]->lang_id)); | 102 | if (qs->items[QUICKSCREEN_LEFT]) |
105 | left_width = display->getstringsize(s, NULL, NULL); | 103 | { |
106 | s = P2STR(ID2P(qs->items[QUICKSCREEN_RIGHT]->lang_id)); | 104 | s = P2STR(ID2P(qs->items[QUICKSCREEN_LEFT]->lang_id)); |
107 | right_width = display->getstringsize(s, NULL, NULL); | 105 | left_width = display->getstringsize(s, NULL, NULL); |
106 | } | ||
107 | if (qs->items[QUICKSCREEN_RIGHT]) | ||
108 | { | ||
109 | s = P2STR(ID2P(qs->items[QUICKSCREEN_RIGHT]->lang_id)); | ||
110 | right_width = display->getstringsize(s, NULL, NULL); | ||
111 | } | ||
108 | 112 | ||
109 | width = MAX(left_width, right_width); | 113 | width = MAX(left_width, right_width); |
110 | if (width*2 + vp_icons->width > parent->width) | 114 | if (width*2 + vp_icons->width > parent->width) |
@@ -126,7 +130,7 @@ static void quickscreen_fix_viewports(struct gui_quickscreen *qs, | |||
126 | vps[QUICKSCREEN_LEFT] = *parent; | 130 | vps[QUICKSCREEN_LEFT] = *parent; |
127 | vps[QUICKSCREEN_LEFT].x = parent->x + pad; | 131 | vps[QUICKSCREEN_LEFT].x = parent->x + pad; |
128 | vps[QUICKSCREEN_LEFT].width = width; | 132 | vps[QUICKSCREEN_LEFT].width = width; |
129 | 133 | ||
130 | vps[QUICKSCREEN_RIGHT] = *parent; | 134 | vps[QUICKSCREEN_RIGHT] = *parent; |
131 | vps[QUICKSCREEN_RIGHT].x = parent->x + parent->width - width - pad; | 135 | vps[QUICKSCREEN_RIGHT].x = parent->x + parent->width - width - pad; |
132 | vps[QUICKSCREEN_RIGHT].width = width; | 136 | vps[QUICKSCREEN_RIGHT].width = width; |
@@ -270,6 +274,9 @@ static bool gui_quickscreen_do_button(struct gui_quickscreen * qs, int button) | |||
270 | default: | 274 | default: |
271 | return false; | 275 | return false; |
272 | } | 276 | } |
277 | if (qs->items[item] == NULL) | ||
278 | return false; | ||
279 | |||
273 | option_select_next_val(qs->items[item], invert, true); | 280 | option_select_next_val(qs->items[item], invert, true); |
274 | talk_qs_option(qs->items[item], false); | 281 | talk_qs_option(qs->items[item], false); |
275 | return true; | 282 | return true; |
@@ -292,7 +299,7 @@ static int quickscreen_touchscreen_button(const struct viewport | |||
292 | else if (viewport_point_within_vp(&vps[QUICKSCREEN_RIGHT], x, y)) | 299 | else if (viewport_point_within_vp(&vps[QUICKSCREEN_RIGHT], x, y)) |
293 | return ACTION_QS_RIGHT; | 300 | return ACTION_QS_RIGHT; |
294 | return ACTION_STD_CANCEL; | 301 | return ACTION_STD_CANCEL; |
295 | } | 302 | } |
296 | #endif | 303 | #endif |
297 | 304 | ||
298 | static bool gui_syncquickscreen_run(struct gui_quickscreen * qs, int button_enter) | 305 | static bool gui_syncquickscreen_run(struct gui_quickscreen * qs, int button_enter) |
@@ -343,10 +350,10 @@ static bool gui_syncquickscreen_run(struct gui_quickscreen * qs, int button_ente | |||
343 | } | 350 | } |
344 | else if (button == button_enter) | 351 | else if (button == button_enter) |
345 | can_quit = true; | 352 | can_quit = true; |
346 | 353 | ||
347 | if ((button == button_enter) && can_quit) | 354 | if ((button == button_enter) && can_quit) |
348 | break; | 355 | break; |
349 | 356 | ||
350 | if (button == ACTION_STD_CANCEL) | 357 | if (button == ACTION_STD_CANCEL) |
351 | break; | 358 | break; |
352 | } | 359 | } |
@@ -357,7 +364,7 @@ static bool gui_syncquickscreen_run(struct gui_quickscreen * qs, int button_ente | |||
357 | for (j = 0; j < QUICKSCREEN_ITEM_COUNT; j++) | 364 | for (j = 0; j < QUICKSCREEN_ITEM_COUNT; j++) |
358 | screens[i].scroll_stop(&vps[i][j]); | 365 | screens[i].scroll_stop(&vps[i][j]); |
359 | } | 366 | } |
360 | 367 | ||
361 | return changed; | 368 | return changed; |
362 | } | 369 | } |
363 | 370 | ||
@@ -376,16 +383,16 @@ bool quick_screen_quick(int button_enter) | |||
376 | bool oldshuffle = global_settings.playlist_shuffle; | 383 | bool oldshuffle = global_settings.playlist_shuffle; |
377 | int oldrepeat = global_settings.repeat_mode; | 384 | int oldrepeat = global_settings.repeat_mode; |
378 | 385 | ||
379 | qs.items[QUICKSCREEN_TOP] = | 386 | qs.items[QUICKSCREEN_TOP] = |
380 | get_setting(global_settings.qs_items[QUICKSCREEN_TOP], | 387 | get_setting(global_settings.qs_items[QUICKSCREEN_TOP], |
381 | find_setting(&global_settings.party_mode, NULL)); | 388 | find_setting(&global_settings.party_mode, NULL)); |
382 | qs.items[QUICKSCREEN_LEFT] = | 389 | qs.items[QUICKSCREEN_LEFT] = |
383 | get_setting(global_settings.qs_items[QUICKSCREEN_LEFT], | 390 | get_setting(global_settings.qs_items[QUICKSCREEN_LEFT], |
384 | find_setting(&global_settings.playlist_shuffle, NULL)); | 391 | find_setting(&global_settings.playlist_shuffle, NULL)); |
385 | qs.items[QUICKSCREEN_RIGHT] = | 392 | qs.items[QUICKSCREEN_RIGHT] = |
386 | get_setting(global_settings.qs_items[QUICKSCREEN_RIGHT], | 393 | get_setting(global_settings.qs_items[QUICKSCREEN_RIGHT], |
387 | find_setting(&global_settings.repeat_mode, NULL)); | 394 | find_setting(&global_settings.repeat_mode, NULL)); |
388 | qs.items[QUICKSCREEN_BOTTOM] = | 395 | qs.items[QUICKSCREEN_BOTTOM] = |
389 | get_setting(global_settings.qs_items[QUICKSCREEN_BOTTOM], | 396 | get_setting(global_settings.qs_items[QUICKSCREEN_BOTTOM], |
390 | find_setting(&global_settings.dirfilter, NULL)); | 397 | find_setting(&global_settings.dirfilter, NULL)); |
391 | 398 | ||
@@ -466,4 +473,3 @@ void set_as_qs_item(const struct settings_list *setting, | |||
466 | 473 | ||
467 | global_settings.qs_items[item] = i; | 474 | global_settings.qs_items[item] = i; |
468 | } | 475 | } |
469 | |||