summaryrefslogtreecommitdiff
path: root/apps/gui
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2009-08-29 14:42:03 +0000
committerThomas Martitz <kugel@rockbox.org>2009-08-29 14:42:03 +0000
commite454a3985275819d998b84bc0cf7b7b8ad9eab00 (patch)
treebae381c959526bd90df6a4675f7c3314950e8c14 /apps/gui
parent5226a89cce46e53d3c011de1e7b1c1d7b91af734 (diff)
downloadrockbox-e454a3985275819d998b84bc0cf7b7b8ad9eab00.tar.gz
rockbox-e454a3985275819d998b84bc0cf7b7b8ad9eab00.zip
Quickscreen: 4th item
This adds a 4th top item to the quickscreen. It's as configurable as the existing three items. This patch goes along with optimisations for small screens for better displaying of all four items. 14px font is very usable on a 64px height display for example. Left and Top items go through the items in the opposite direction, so that you can mirror a setting and toggle through it in both directions. Default item is party mode, as it's target independant. Flyspray: FS#9706 git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22532 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui')
-rw-r--r--apps/gui/quickscreen.c130
-rw-r--r--apps/gui/quickscreen.h3
2 files changed, 78 insertions, 55 deletions
diff --git a/apps/gui/quickscreen.c b/apps/gui/quickscreen.c
index d6d662b1f1..ab13e67a81 100644
--- a/apps/gui/quickscreen.c
+++ b/apps/gui/quickscreen.c
@@ -38,17 +38,18 @@
38#include "talk.h" 38#include "talk.h"
39#include "list.h" 39#include "list.h"
40#include "option_select.h" 40#include "option_select.h"
41#include "debug.h"
41 42
42static struct viewport vps[NB_SCREENS][QUICKSCREEN_ITEM_COUNT]; 43static struct viewport vps[NB_SCREENS][QUICKSCREEN_ITEM_COUNT];
43static struct viewport vp_icons[NB_SCREENS]; 44static struct viewport vp_icons[NB_SCREENS];
44/* vp_icons will be used like this: 45 /* 1 top, 1 bottom, 2 on either side, 1 for the icons
45 the side icons will be aligned to the top of this vp and to their sides 46 * if enough space, top and bottom have 2 lines */
46 the bottom icon will be aligned center and at the bottom of this vp */ 47#define MIN_LINES 5
47 48#define MAX_NEEDED_LINES 10
48#define MIN_LINES 4 49 /* pixels between the 2 center items minimum or between text and icons,
49#define MAX_NEEDED_LINES 8 50 * and between text and parent boundaries */
50#define CENTER_MARGIN 10 /* pixels between the 2 center items minimum */ 51#define MARGIN 10
51#define CENTER_ICONAREA_WIDTH (CENTER_MARGIN+8*2) 52#define CENTER_ICONAREA_SIZE (MARGIN+8*2)
52 53
53static void quickscreen_fix_viewports(struct gui_quickscreen *qs, 54static void quickscreen_fix_viewports(struct gui_quickscreen *qs,
54 struct screen *display, 55 struct screen *display,
@@ -59,9 +60,8 @@ static void quickscreen_fix_viewports(struct gui_quickscreen *qs,
59#else 60#else
60 const int screen = 0; 61 const int screen = 0;
61#endif 62#endif
62 63 int char_height, width, pad = 0;
63 int char_height, i, width, pad = 0; 64 int left_width, right_width, vert_lines;
64 int left_width, right_width, bottom_lines = 2;
65 unsigned char *s; 65 unsigned char *s;
66 int nb_lines = viewport_get_nb_lines(parent); 66 int nb_lines = viewport_get_nb_lines(parent);
67 67
@@ -75,43 +75,57 @@ static void quickscreen_fix_viewports(struct gui_quickscreen *qs,
75 75
76 /* center the icons VP first */ 76 /* center the icons VP first */
77 vp_icons[screen] = *parent; 77 vp_icons[screen] = *parent;
78 vp_icons[screen].width = CENTER_ICONAREA_WIDTH; /* absolute smallest allowed */ 78 vp_icons[screen].width = CENTER_ICONAREA_SIZE; /* abosulte smallest allowed */
79 vp_icons[screen].x = parent->x + (parent->width / 2 - CENTER_ICONAREA_WIDTH / 2); 79 vp_icons[screen].x = parent->x;
80 vp_icons[screen].x += (parent->width-CENTER_ICONAREA_SIZE)/2;
81
80 82
81 vps[screen][QUICKSCREEN_BOTTOM] = *parent; 83 vps[screen][QUICKSCREEN_BOTTOM] = *parent;
82 if (nb_lines <= MIN_LINES) /* make the bottom item use 1 line */ 84 vps[screen][QUICKSCREEN_TOP] = *parent;
83 bottom_lines = 1; 85 /* depending on the space the top/buttom items use 1 or 2 lines */
86 if (nb_lines < MIN_LINES)
87 vert_lines = 1;
84 else 88 else
85 bottom_lines = 2; 89 vert_lines = 2;
86 vps[screen][QUICKSCREEN_BOTTOM].height = bottom_lines*char_height; 90 vps[screen][QUICKSCREEN_TOP].y = parent->y;
87 vps[screen][QUICKSCREEN_BOTTOM].y = 91 vps[screen][QUICKSCREEN_TOP].height = vps[screen][QUICKSCREEN_BOTTOM].height
88 parent->y + parent->height - bottom_lines*char_height; 92 = vert_lines*char_height;
93 vps[screen][QUICKSCREEN_BOTTOM].y
94 = parent->y + parent->height - vps[screen][QUICKSCREEN_BOTTOM].height;
95
96 /* enough space vertically, so put a nice margin */
89 if (nb_lines >= MAX_NEEDED_LINES) 97 if (nb_lines >= MAX_NEEDED_LINES)
90 { 98 {
91 vps[screen][QUICKSCREEN_BOTTOM].y -= char_height; 99 vps[screen][QUICKSCREEN_TOP].y += MARGIN;
100 vps[screen][QUICKSCREEN_BOTTOM].y -= MARGIN;
92 } 101 }
93 102
103 vp_icons[screen].y = vps[screen][QUICKSCREEN_TOP].y
104 + vps[screen][QUICKSCREEN_TOP].height;
105 vp_icons[screen].height = parent->height - vp_icons[screen].y;
106 vp_icons[screen].height -= parent->height - vps[screen][QUICKSCREEN_BOTTOM].y;
107
94 /* adjust the left/right items widths to fit the screen nicely */ 108 /* adjust the left/right items widths to fit the screen nicely */
95 s = P2STR(ID2P(qs->items[QUICKSCREEN_LEFT]->lang_id)); 109 s = P2STR(ID2P(qs->items[QUICKSCREEN_LEFT]->lang_id));
96 left_width = display->getstringsize(s, NULL, NULL); 110 left_width = display->getstringsize(s, NULL, NULL);
97 s = P2STR(ID2P(qs->items[QUICKSCREEN_RIGHT]->lang_id)); 111 s = P2STR(ID2P(qs->items[QUICKSCREEN_RIGHT]->lang_id));
98 right_width = display->getstringsize(s, NULL, NULL); 112 right_width = display->getstringsize(s, NULL, NULL);
99 nb_lines -= bottom_lines; 113
100
101 width = MAX(left_width, right_width); 114 width = MAX(left_width, right_width);
102 if (width*2 + vp_icons[screen].width > display->lcdwidth) 115 if (width*2 + vp_icons[screen].width > display->lcdwidth)
103 width = (display->lcdwidth - vp_icons[screen].width)/2; 116 width = (display->lcdwidth - vp_icons[screen].width)/2;
104 else /* add more gap in icons vp */ 117 else /* add more gap in icons vp */
105 { 118 {
106 int excess = display->lcdwidth - vp_icons[screen].width - width*2; 119 int excess = display->lcdwidth - vp_icons[screen].width - width*2;
107 if (excess > CENTER_MARGIN*4) 120 if (excess > MARGIN*4)
108 { 121 {
109 pad = CENTER_MARGIN; 122 pad = MARGIN;
110 excess -= CENTER_MARGIN*2; 123 excess -= MARGIN*2;
111 } 124 }
112 vp_icons[screen].x -= excess/2; 125 vp_icons[screen].x -= excess/2;
113 vp_icons[screen].width += excess; 126 vp_icons[screen].width += excess;
114 } 127 }
128
115 vps[screen][QUICKSCREEN_LEFT] = *parent; 129 vps[screen][QUICKSCREEN_LEFT] = *parent;
116 vps[screen][QUICKSCREEN_LEFT].x = parent->x + pad; 130 vps[screen][QUICKSCREEN_LEFT].x = parent->x + pad;
117 vps[screen][QUICKSCREEN_LEFT].width = width; 131 vps[screen][QUICKSCREEN_LEFT].width = width;
@@ -119,32 +133,25 @@ static void quickscreen_fix_viewports(struct gui_quickscreen *qs,
119 vps[screen][QUICKSCREEN_RIGHT] = *parent; 133 vps[screen][QUICKSCREEN_RIGHT] = *parent;
120 vps[screen][QUICKSCREEN_RIGHT].x = parent->x + parent->width - width - pad; 134 vps[screen][QUICKSCREEN_RIGHT].x = parent->x + parent->width - width - pad;
121 vps[screen][QUICKSCREEN_RIGHT].width = width; 135 vps[screen][QUICKSCREEN_RIGHT].width = width;
122 136
137 vps[screen][QUICKSCREEN_LEFT].height = vps[screen][QUICKSCREEN_RIGHT].height
138 = 2*char_height;
139
140 vps[screen][QUICKSCREEN_LEFT].y = vps[screen][QUICKSCREEN_RIGHT].y
141 = parent->y + (parent->height/2) - char_height;
142
123 /* shrink the icons vp by a few pixels if there is room so the arrows 143 /* shrink the icons vp by a few pixels if there is room so the arrows
124 aren't drawn right next to the text */ 144 aren't drawn right next to the text */
125 if (vp_icons[screen].width > CENTER_ICONAREA_WIDTH+8) 145 if (vp_icons[screen].width > CENTER_ICONAREA_SIZE*2)
126 { 146 {
127 vp_icons[screen].width -= 8; 147 vp_icons[screen].width -= CENTER_ICONAREA_SIZE*2/3;
128 vp_icons[screen].x += 4; 148 vp_icons[screen].x += CENTER_ICONAREA_SIZE*2/6;
149 }
150 if (vp_icons[screen].height > CENTER_ICONAREA_SIZE*2)
151 {
152 vp_icons[screen].height -= CENTER_ICONAREA_SIZE*2/3;
153 vp_icons[screen].y += CENTER_ICONAREA_SIZE*2/6;
129 } 154 }
130
131
132 if (nb_lines <= MIN_LINES)
133 i = 0;
134 else
135 i = nb_lines/2;
136 vps[screen][QUICKSCREEN_LEFT].y = parent->y + (i*char_height);
137 vps[screen][QUICKSCREEN_RIGHT].y = parent->y + (i*char_height);
138 if (nb_lines >= 3)
139 i = 3*char_height;
140 else
141 i = nb_lines*char_height;
142
143 vps[screen][QUICKSCREEN_LEFT].height = i;
144 vps[screen][QUICKSCREEN_RIGHT].height = i;
145 vp_icons[screen].y = vps[screen][QUICKSCREEN_LEFT].y + (char_height/2);
146 vp_icons[screen].height =
147 vps[screen][QUICKSCREEN_BOTTOM].y - vp_icons[screen].y;
148} 155}
149 156
150static void quickscreen_draw_text(const char *s, int item, bool title, 157static void quickscreen_draw_text(const char *s, int item, bool title,
@@ -158,6 +165,7 @@ static void quickscreen_draw_text(const char *s, int item, bool title,
158 line = 1; 165 line = 1;
159 switch (item) 166 switch (item)
160 { 167 {
168 case QUICKSCREEN_TOP:
161 case QUICKSCREEN_BOTTOM: 169 case QUICKSCREEN_BOTTOM:
162 x = (vp->width - w)/2; 170 x = (vp->width - w)/2;
163 break; 171 break;
@@ -219,13 +227,18 @@ static void gui_quickscreen_draw(struct gui_quickscreen *qs,
219 } 227 }
220 /* draw the icons */ 228 /* draw the icons */
221 display->set_viewport(&vp_icons[screen]); 229 display->set_viewport(&vp_icons[screen]);
230
231 display->mono_bitmap(bitmap_icons_7x8[Icon_UpArrow],
232 (vp_icons[screen].width/2) - 4, 0, 7, 8);
222 display->mono_bitmap(bitmap_icons_7x8[Icon_FastForward], 233 display->mono_bitmap(bitmap_icons_7x8[Icon_FastForward],
223 vp_icons[screen].width - 8, 0, 7, 8); 234 vp_icons[screen].width - 8,
224 display->mono_bitmap(bitmap_icons_7x8[Icon_FastBackward], 0, 0, 7, 8); 235 (vp_icons[screen].height/2) - 4, 7, 8);
236 display->mono_bitmap(bitmap_icons_7x8[Icon_FastBackward], 0,
237 (vp_icons[screen].height/2) - 4, 7, 8);
238
225 display->mono_bitmap(bitmap_icons_7x8[Icon_DownArrow], 239 display->mono_bitmap(bitmap_icons_7x8[Icon_DownArrow],
226 (vp_icons[screen].width/2) - 4, 240 (vp_icons[screen].width/2) - 4,
227 vp_icons[screen].height - 7, 7, 8); 241 vp_icons[screen].height - 8, 7, 8);
228 display->update_viewport();
229 242
230 display->set_viewport(parent); 243 display->set_viewport(parent);
231 display->update_viewport(); 244 display->update_viewport();
@@ -254,12 +267,15 @@ static bool gui_quickscreen_do_button(struct gui_quickscreen * qs, int button)
254 bool invert = false; 267 bool invert = false;
255 switch(button) 268 switch(button)
256 { 269 {
270 case ACTION_QS_TOP:
271 invert = true;
272 item = QUICKSCREEN_TOP;
273 break;
257 case ACTION_QS_LEFT: 274 case ACTION_QS_LEFT:
275 invert = true;
258 item = QUICKSCREEN_LEFT; 276 item = QUICKSCREEN_LEFT;
259 break; 277 break;
260 278
261 case ACTION_QS_DOWNINV:
262 invert = true; /* fallthrough */
263 case ACTION_QS_DOWN: 279 case ACTION_QS_DOWN:
264 item = QUICKSCREEN_BOTTOM; 280 item = QUICKSCREEN_BOTTOM;
265 break; 281 break;
@@ -367,6 +383,9 @@ bool quick_screen_quick(int button_enter)
367 bool oldshuffle = global_settings.playlist_shuffle; 383 bool oldshuffle = global_settings.playlist_shuffle;
368 int oldrepeat = global_settings.repeat_mode; 384 int oldrepeat = global_settings.repeat_mode;
369 385
386 qs.items[QUICKSCREEN_TOP] =
387 get_setting(global_settings.qs_item_top,
388 find_setting(&global_settings.party_mode, NULL));
370 qs.items[QUICKSCREEN_LEFT] = 389 qs.items[QUICKSCREEN_LEFT] =
371 get_setting(global_settings.qs_item_left, 390 get_setting(global_settings.qs_item_left,
372 find_setting(&global_settings.playlist_shuffle, NULL)); 391 find_setting(&global_settings.playlist_shuffle, NULL));
@@ -452,6 +471,9 @@ void set_as_qs_item(const struct settings_list *setting,
452 } 471 }
453 switch (item) 472 switch (item)
454 { 473 {
474 case QUICKSCREEN_TOP:
475 global_settings.qs_item_top = i;
476 break;
455 case QUICKSCREEN_LEFT: 477 case QUICKSCREEN_LEFT:
456 global_settings.qs_item_left = i; 478 global_settings.qs_item_left = i;
457 break; 479 break;
@@ -461,7 +483,7 @@ void set_as_qs_item(const struct settings_list *setting,
461 case QUICKSCREEN_BOTTOM: 483 case QUICKSCREEN_BOTTOM:
462 global_settings.qs_item_bottom = i; 484 global_settings.qs_item_bottom = i;
463 break; 485 break;
464 default: /* shut the copiler up */ 486 default: /* shut the compiler up */
465 break; 487 break;
466 } 488 }
467} 489}
diff --git a/apps/gui/quickscreen.h b/apps/gui/quickscreen.h
index 2a67916d37..c725eae60a 100644
--- a/apps/gui/quickscreen.h
+++ b/apps/gui/quickscreen.h
@@ -29,7 +29,8 @@
29#include "screen_access.h" 29#include "screen_access.h"
30 30
31enum quickscreen_item { 31enum quickscreen_item {
32 QUICKSCREEN_LEFT = 0, 32 QUICKSCREEN_TOP = 0,
33 QUICKSCREEN_LEFT,
33 QUICKSCREEN_RIGHT, 34 QUICKSCREEN_RIGHT,
34 QUICKSCREEN_BOTTOM, 35 QUICKSCREEN_BOTTOM,
35 QUICKSCREEN_ITEM_COUNT, 36 QUICKSCREEN_ITEM_COUNT,