summaryrefslogtreecommitdiff
path: root/apps/gui
diff options
context:
space:
mode:
Diffstat (limited to 'apps/gui')
-rw-r--r--apps/gui/quickscreen.c81
1 files changed, 35 insertions, 46 deletions
diff --git a/apps/gui/quickscreen.c b/apps/gui/quickscreen.c
index 9c850b74ca..0bfe746661 100644
--- a/apps/gui/quickscreen.c
+++ b/apps/gui/quickscreen.c
@@ -59,13 +59,16 @@ static void quickscreen_fix_viewports(struct gui_quickscreen *qs,
59 const int screen = 0; 59 const int screen = 0;
60#endif 60#endif
61 61
62 int char_height, i; 62 int char_height, i, width, pad = 0;
63 int left_width, right_width, bottom_lines = 3; 63 int left_width, right_width, bottom_lines = 2;
64 unsigned char *s; 64 unsigned char *s;
65 int nb_lines = viewport_get_nb_lines(parent); 65 int nb_lines = viewport_get_nb_lines(parent);
66 char_height = parent->height/nb_lines; 66 char_height = parent->height/nb_lines;
67 67
68 /* center the icons VP first */
68 vp_icons[screen] = *parent; 69 vp_icons[screen] = *parent;
70 vp_icons[screen].width = CENTER_ICONAREA_WIDTH; /* abosulte smallest allowed */
71 vp_icons[screen].x = (parent->width-parent->x-CENTER_ICONAREA_WIDTH)/2;
69 72
70 vps[screen][QUICKSCREEN_BOTTOM] = *parent; 73 vps[screen][QUICKSCREEN_BOTTOM] = *parent;
71 if (nb_lines <= MIN_LINES) /* make the bottom item use 1 line */ 74 if (nb_lines <= MIN_LINES) /* make the bottom item use 1 line */
@@ -86,10 +89,38 @@ static void quickscreen_fix_viewports(struct gui_quickscreen *qs,
86 s = P2STR(ID2P(qs->items[QUICKSCREEN_RIGHT]->lang_id)); 89 s = P2STR(ID2P(qs->items[QUICKSCREEN_RIGHT]->lang_id));
87 right_width = display->getstringsize(s, NULL, NULL); 90 right_width = display->getstringsize(s, NULL, NULL);
88 nb_lines -= bottom_lines; 91 nb_lines -= bottom_lines;
89 92
93 width = MAX(left_width, right_width);
94 if (width*2 + vp_icons[screen].width > display->lcdwidth)
95 width = (display->lcdwidth - vp_icons[screen].width)/2;
96 else /* add more gap in icons vp */
97 {
98 int excess = display->lcdwidth - vp_icons[screen].width - width*2;
99 if (excess > CENTER_MARGIN*4)
100 {
101 pad = CENTER_MARGIN;
102 excess -= CENTER_MARGIN*2;
103 }
104 vp_icons[screen].x -= excess/2;
105 vp_icons[screen].width += excess;
106 }
90 vps[screen][QUICKSCREEN_LEFT] = *parent; 107 vps[screen][QUICKSCREEN_LEFT] = *parent;
108 vps[screen][QUICKSCREEN_LEFT].x = parent->x + pad;
109 vps[screen][QUICKSCREEN_LEFT].width = width;
110
91 vps[screen][QUICKSCREEN_RIGHT] = *parent; 111 vps[screen][QUICKSCREEN_RIGHT] = *parent;
92 vps[screen][QUICKSCREEN_LEFT].x = parent->x; 112 vps[screen][QUICKSCREEN_RIGHT].x = parent->x + parent->width - width - pad;
113 vps[screen][QUICKSCREEN_RIGHT].width = width;
114
115 /* shrink the icons vp by a few pixels if there is room so the arrows
116 arnt' drawn right next to the text */
117 if (vp_icons[screen].width > CENTER_ICONAREA_WIDTH+8)
118 {
119 vp_icons[screen].width -= 8;
120 vp_icons[screen].x += 4;
121 }
122
123
93 if (nb_lines <= MIN_LINES) 124 if (nb_lines <= MIN_LINES)
94 i = 0; 125 i = 0;
95 else 126 else
@@ -106,48 +137,6 @@ static void quickscreen_fix_viewports(struct gui_quickscreen *qs,
106 vp_icons[screen].y = vps[screen][QUICKSCREEN_LEFT].y + (char_height/2); 137 vp_icons[screen].y = vps[screen][QUICKSCREEN_LEFT].y + (char_height/2);
107 vp_icons[screen].height = 138 vp_icons[screen].height =
108 vps[screen][QUICKSCREEN_BOTTOM].y - vp_icons[screen].y; 139 vps[screen][QUICKSCREEN_BOTTOM].y - vp_icons[screen].y;
109
110 if (MAX(left_width, right_width)*2 > parent->width - CENTER_ICONAREA_WIDTH)
111 {
112 /* scrolling needed */
113 int center = (parent->width - CENTER_ICONAREA_WIDTH)/2;
114 int width = MIN(center, MIN(left_width, right_width));
115 vps[screen][QUICKSCREEN_LEFT].width = width;
116 vps[screen][QUICKSCREEN_RIGHT].width = width;
117 vps[screen][QUICKSCREEN_RIGHT].x = parent->x+parent->width - width;
118 vp_icons[screen].x = parent->x + center;
119 vp_icons[screen].width = CENTER_ICONAREA_WIDTH;
120 }
121 else
122 {
123 int width, pad = 0;
124 if (left_width > right_width)
125 width = left_width;
126 else
127 width = right_width;
128 width += CENTER_MARGIN;
129 if (width*2 < parent->width/2)
130 {
131 width += parent->width/6;
132 /* add some padding on the edges */
133 pad = CENTER_MARGIN;
134 }
135 vps[screen][QUICKSCREEN_LEFT].width = width;
136 vps[screen][QUICKSCREEN_RIGHT].width = width;
137 vps[screen][QUICKSCREEN_RIGHT].x = parent->x + parent->width - width;
138 vp_icons[screen].x = parent->x + width;
139 if (pad)
140 {
141 vp_icons[screen].x += pad;
142 vps[screen][QUICKSCREEN_LEFT].x += pad;
143 vps[screen][QUICKSCREEN_RIGHT].x -= pad;
144 /* need to add the pad to the bottom to make it all centered nicely */
145 vps[screen][QUICKSCREEN_BOTTOM].x += pad;
146 vps[screen][QUICKSCREEN_BOTTOM].width -= pad;
147 }
148 vp_icons[screen].width = vps[screen][QUICKSCREEN_RIGHT].x - (vps[screen][QUICKSCREEN_LEFT].x+width);
149
150 }
151} 140}
152 141
153static void quickscreen_draw_text(char *s, int item, bool title, 142static void quickscreen_draw_text(char *s, int item, bool title,