summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2010-10-10 23:15:05 +0000
committerThomas Martitz <kugel@rockbox.org>2010-10-10 23:15:05 +0000
commit8a0152bd4ae638c1fe4917b855fcb9fc6a15202c (patch)
tree7a3a81bf30d49a3c072d89485f79207bc7d2c29e
parent752c91b50dcf36e4476cf89cceb6493e2fd4c586 (diff)
downloadrockbox-8a0152bd4ae638c1fe4917b855fcb9fc6a15202c.tar.gz
rockbox-8a0152bd4ae638c1fe4917b855fcb9fc6a15202c.zip
Two new lcd/multi screen api convinience functions: draw_viewport(), fill_viewport().
They work as the drawrect/fillrect pendants but work on a viewport basis; pass NULL to draw the current viewport (the one set with set_viewport()). In conjunction with action_get_touchscreen_press_in_vp() it should be less of a pain to draw buttons and get presses on them. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28239 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/gui/buttonbar.c5
-rw-r--r--apps/gui/splash.c4
-rw-r--r--apps/gui/statusbar.c2
-rw-r--r--apps/plugins/lib/pluginlib_touchscreen.c16
-rw-r--r--apps/screen_access.c4
-rw-r--r--apps/screen_access.h4
-rw-r--r--firmware/drivers/lcd-bitmap-common.c22
-rw-r--r--firmware/export/lcd-remote.h2
-rw-r--r--firmware/export/lcd.h2
9 files changed, 47 insertions, 14 deletions
diff --git a/apps/gui/buttonbar.c b/apps/gui/buttonbar.c
index 84d49464c0..db94362352 100644
--- a/apps/gui/buttonbar.c
+++ b/apps/gui/buttonbar.c
@@ -66,16 +66,17 @@ static void gui_buttonbar_draw_button(struct gui_buttonbar * buttonbar, int num)
66 struct viewport vp = bb_vp[display->screen_type]; 66 struct viewport vp = bb_vp[display->screen_type];
67 67
68 button_width = display->lcdwidth/BUTTONBAR_MAX_BUTTONS; 68 button_width = display->lcdwidth/BUTTONBAR_MAX_BUTTONS;
69 vp.width = button_width; 69 vp.width = button_width-1;
70 vp.x = button_width * num; 70 vp.x = button_width * num;
71 display->set_viewport(&vp); 71 display->set_viewport(&vp);
72 display->fillrect(0, 0, button_width - 1, vp.height); 72 display->fill_viewport(NULL);
73 if(buttonbar->caption[num][0] != 0) 73 if(buttonbar->caption[num][0] != 0)
74 { 74 {
75 display->getstringsize(buttonbar->caption[num], &fw, &fh); 75 display->getstringsize(buttonbar->caption[num], &fw, &fh);
76 display->putsxy((button_width - fw)/2, 76 display->putsxy((button_width - fw)/2,
77 (vp.height-fh)/2, buttonbar->caption[num]); 77 (vp.height-fh)/2, buttonbar->caption[num]);
78 } 78 }
79 display->set_viewport(NULL);
79} 80}
80 81
81void gui_buttonbar_set(struct gui_buttonbar * buttonbar, 82void gui_buttonbar_set(struct gui_buttonbar * buttonbar,
diff --git a/apps/gui/splash.c b/apps/gui/splash.c
index 10dee12052..8c5f57fdd9 100644
--- a/apps/gui/splash.c
+++ b/apps/gui/splash.c
@@ -163,7 +163,7 @@ static void splash_internal(struct screen * screen, const char *fmt, va_list ap)
163#endif 163#endif
164 vp.drawmode = (DRMODE_SOLID|DRMODE_INVERSEVID); 164 vp.drawmode = (DRMODE_SOLID|DRMODE_INVERSEVID);
165 165
166 screen->fillrect(0, 0, vp.width, vp.height); 166 screen->fill_viewport(NULL);
167 167
168#if LCD_DEPTH > 1 168#if LCD_DEPTH > 1
169 if (screen->depth > 1) 169 if (screen->depth > 1)
@@ -174,7 +174,7 @@ static void splash_internal(struct screen * screen, const char *fmt, va_list ap)
174#endif 174#endif
175 vp.drawmode = DRMODE_SOLID; 175 vp.drawmode = DRMODE_SOLID;
176 176
177 screen->drawrect(0, 0, vp.width, vp.height); 177 screen->draw_viewport(NULL);
178 178
179 /* prepare putting the text */ 179 /* prepare putting the text */
180 y = RECT_SPACING; 180 y = RECT_SPACING;
diff --git a/apps/gui/statusbar.c b/apps/gui/statusbar.c
index 73ccfa7762..a05a11a502 100644
--- a/apps/gui/statusbar.c
+++ b/apps/gui/statusbar.c
@@ -280,7 +280,7 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw, struct vi
280 { 280 {
281 display->set_viewport(vp); 281 display->set_viewport(vp);
282 display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); 282 display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
283 display->fillrect(0, 0, display->getwidth(), STATUSBAR_HEIGHT); 283 display->fill_viewport(NULL);
284 display->set_drawmode(DRMODE_SOLID); 284 display->set_drawmode(DRMODE_SOLID);
285 285
286 if (bar->info.battery_state) 286 if (bar->info.battery_state)
diff --git a/apps/plugins/lib/pluginlib_touchscreen.c b/apps/plugins/lib/pluginlib_touchscreen.c
index 1e1bf8d3c2..3920b8ec18 100644
--- a/apps/plugins/lib/pluginlib_touchscreen.c
+++ b/apps/plugins/lib/pluginlib_touchscreen.c
@@ -88,7 +88,8 @@ void touchbutton_draw(struct touchbutton *data, int num_buttons) {
88 int i; 88 int i;
89 /* These store the width and height of the title offset */ 89 /* These store the width and height of the title offset */
90 int title_width, title_height; 90 int title_width, title_height;
91 91 struct screen *lcd = rb->screens[SCREEN_MAIN];
92
92 /* Loop over all the elements in data */ 93 /* Loop over all the elements in data */
93 for(i=0; i<num_buttons; i++) { 94 for(i=0; i<num_buttons; i++) {
94 /* Is this a visible button? */ 95 /* Is this a visible button? */
@@ -96,10 +97,10 @@ void touchbutton_draw(struct touchbutton *data, int num_buttons) {
96 /* Set the current viewport to the button so that all drawing 97 /* Set the current viewport to the button so that all drawing
97 * operations are within the button location. 98 * operations are within the button location.
98 */ 99 */
99 rb->screens[SCREEN_MAIN]->set_viewport(&data[i].vp); 100 lcd->set_viewport(&data[i].vp);
100 101
101 /* Get the string size so that the title can be centered. */ 102 /* Get the string size so that the title can be centered. */
102 rb->lcd_getstringsize(data[i].title, &title_width, &title_height); 103 lcd->getstringsize(data[i].title, &title_width, &title_height);
103 104
104 /* Center the title vertically */ 105 /* Center the title vertically */
105 title_height=(data[i].vp.height-title_height)/2; 106 title_height=(data[i].vp.height-title_height)/2;
@@ -121,16 +122,17 @@ void touchbutton_draw(struct touchbutton *data, int num_buttons) {
121 * print the title. 122 * print the title.
122 */ 123 */
123 if(title_width==0) { 124 if(title_width==0) {
124 rb->lcd_puts_scroll(0, 0, data[i].title); 125 lcd->puts_scroll_style_xyoffset(0, 0, data[i].title,
126 STYLE_DEFAULT, 0, title_height);
125 } else { 127 } else {
126 rb->lcd_putsxy(title_width, title_height, data[i].title); 128 lcd->putsxy(title_width, title_height, data[i].title);
127 } 129 }
128 130
129 /* Draw bounding box around the button location. */ 131 /* Draw bounding box around the button location. */
130 rb->lcd_drawrect( 0, 0, data[i].vp.width, data[i].vp.height); 132 lcd->draw_viewport(NULL);
131 } 133 }
132 } 134 }
133 rb->screens[SCREEN_MAIN]->set_viewport(NULL); /* Go back to the default viewport */ 135 lcd->set_viewport(NULL); /* Go back to the default viewport */
134} 136}
135 137
136/******************************************************************************* 138/*******************************************************************************
diff --git a/apps/screen_access.c b/apps/screen_access.c
index d059547402..e828feafc1 100644
--- a/apps/screen_access.c
+++ b/apps/screen_access.c
@@ -162,6 +162,8 @@ struct screen screens[NB_SCREENS] =
162 .update_viewport_rect=&lcd_update_viewport_rect, 162 .update_viewport_rect=&lcd_update_viewport_rect,
163 .fillrect=&lcd_fillrect, 163 .fillrect=&lcd_fillrect,
164 .drawrect=&lcd_drawrect, 164 .drawrect=&lcd_drawrect,
165 .draw_viewport=&lcd_draw_viewport,
166 .fill_viewport=&lcd_fill_viewport,
165 .drawpixel=&lcd_drawpixel, 167 .drawpixel=&lcd_drawpixel,
166 .drawline=&lcd_drawline, 168 .drawline=&lcd_drawline,
167 .vline=&lcd_vline, 169 .vline=&lcd_vline,
@@ -253,6 +255,8 @@ struct screen screens[NB_SCREENS] =
253 .update_viewport_rect=&lcd_remote_update_viewport_rect, 255 .update_viewport_rect=&lcd_remote_update_viewport_rect,
254 .fillrect=&lcd_remote_fillrect, 256 .fillrect=&lcd_remote_fillrect,
255 .drawrect=&lcd_remote_drawrect, 257 .drawrect=&lcd_remote_drawrect,
258 .draw_viewport=&lcd_remote_draw_viewport,
259 .fill_viewport=&lcd_remote_fill_viewport,
256 .drawpixel=&lcd_remote_drawpixel, 260 .drawpixel=&lcd_remote_drawpixel,
257 .drawline=&lcd_remote_drawline, 261 .drawline=&lcd_remote_drawline,
258 .vline=&lcd_remote_vline, 262 .vline=&lcd_remote_vline,
diff --git a/apps/screen_access.h b/apps/screen_access.h
index a154d20195..fb7aa7bd26 100644
--- a/apps/screen_access.h
+++ b/apps/screen_access.h
@@ -117,6 +117,8 @@ struct screen
117 void (*update_viewport_rect)(int x, int y, int width, int height); 117 void (*update_viewport_rect)(int x, int y, int width, int height);
118 void (*fillrect)(int x, int y, int width, int height); 118 void (*fillrect)(int x, int y, int width, int height);
119 void (*drawrect)(int x, int y, int width, int height); 119 void (*drawrect)(int x, int y, int width, int height);
120 void (*fill_viewport)(const struct viewport *vp);
121 void (*draw_viewport)(const struct viewport *vp);
120 void (*drawpixel)(int x, int y); 122 void (*drawpixel)(int x, int y);
121 void (*drawline)(int x1, int y1, int x2, int y2); 123 void (*drawline)(int x1, int y1, int x2, int y2);
122 void (*vline)(int x, int y1, int y2); 124 void (*vline)(int x, int y1, int y2);
@@ -139,8 +141,6 @@ struct screen
139 void (*puts_scroll)(int x, int y, const unsigned char *string); 141 void (*puts_scroll)(int x, int y, const unsigned char *string);
140 void (*puts_scroll_offset)(int x, int y, const unsigned char *string, 142 void (*puts_scroll_offset)(int x, int y, const unsigned char *string,
141 int x_offset); 143 int x_offset);
142 void (*puts_scroll_xyoffset)(int x, int y, const unsigned char *string,
143 int x_offset, int y_offset);
144 void (*scroll_speed)(int speed); 144 void (*scroll_speed)(int speed);
145 void (*scroll_delay)(int ms); 145 void (*scroll_delay)(int ms);
146 void (*stop_scroll)(void); 146 void (*stop_scroll)(void);
diff --git a/firmware/drivers/lcd-bitmap-common.c b/firmware/drivers/lcd-bitmap-common.c
index 2ce11e3398..d242096138 100644
--- a/firmware/drivers/lcd-bitmap-common.c
+++ b/firmware/drivers/lcd-bitmap-common.c
@@ -81,6 +81,28 @@ static void lcd_gradient_rect(int x1, int x2, int y, unsigned h,
81} 81}
82#endif 82#endif
83 83
84/*
85 * draws the borders of the viewport, or of current_vp if vp == NULL
86 **/
87void LCDFN(draw_viewport)(const struct viewport *vp)
88{
89 if (vp == NULL)
90 LCDFN(drawrect)(0, 0, current_vp->width, current_vp->height);
91 else
92 LCDFN(drawrect)(vp->x, vp->y, vp->width, vp->height);
93}
94
95/*
96 * fills the rectangle formed by vp or by current_vp if vp == NULL
97 **/
98void LCDFN(fill_viewport)(const struct viewport *vp)
99{
100 if (vp == NULL)
101 LCDFN(fillrect)(0, 0, current_vp->width, current_vp->height);
102 else
103 LCDFN(fillrect)(vp->x, vp->y, vp->width, vp->height);
104}
105
84/* put a string at a given pixel position, skipping first ofs pixel columns */ 106/* put a string at a given pixel position, skipping first ofs pixel columns */
85static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str) 107static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str)
86{ 108{
diff --git a/firmware/export/lcd-remote.h b/firmware/export/lcd-remote.h
index 93b2968033..894d35ca11 100644
--- a/firmware/export/lcd-remote.h
+++ b/firmware/export/lcd-remote.h
@@ -178,6 +178,8 @@ extern void lcd_remote_hline(int x1, int x2, int y);
178extern void lcd_remote_vline(int x, int y1, int y2); 178extern void lcd_remote_vline(int x, int y1, int y2);
179extern void lcd_remote_drawrect(int x, int y, int width, int height); 179extern void lcd_remote_drawrect(int x, int y, int width, int height);
180extern void lcd_remote_fillrect(int x, int y, int width, int height); 180extern void lcd_remote_fillrect(int x, int y, int width, int height);
181extern void lcd_remote_draw_viewport(const struct viewport *vp);
182extern void lcd_remote_fill_viewport(const struct viewport *vp);
181extern void lcd_remote_bitmap_part(const fb_remote_data *src, int src_x, 183extern void lcd_remote_bitmap_part(const fb_remote_data *src, int src_x,
182 int src_y, int stride, int x, int y, 184 int src_y, int stride, int x, int y,
183 int width, int height); 185 int width, int height);
diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h
index 54a2f3c511..6dab8f4cad 100644
--- a/firmware/export/lcd.h
+++ b/firmware/export/lcd.h
@@ -507,6 +507,8 @@ extern void lcd_hline(int x1, int x2, int y);
507extern void lcd_vline(int x, int y1, int y2); 507extern void lcd_vline(int x, int y1, int y2);
508extern void lcd_drawrect(int x, int y, int width, int height); 508extern void lcd_drawrect(int x, int y, int width, int height);
509extern void lcd_fillrect(int x, int y, int width, int height); 509extern void lcd_fillrect(int x, int y, int width, int height);
510extern void lcd_draw_viewport(const struct viewport *vp);
511extern void lcd_fill_viewport(const struct viewport *vp);
510extern void lcd_bitmap_part(const fb_data *src, int src_x, int src_y, 512extern void lcd_bitmap_part(const fb_data *src, int src_x, int src_y,
511 int stride, int x, int y, int width, int height); 513 int stride, int x, int y, int width, int height);
512extern void lcd_bitmap(const fb_data *src, int x, int y, int width, 514extern void lcd_bitmap(const fb_data *src, int x, int y, int width,