From 8a0152bd4ae638c1fe4917b855fcb9fc6a15202c Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Sun, 10 Oct 2010 23:15:05 +0000 Subject: 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 --- apps/plugins/lib/pluginlib_touchscreen.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'apps/plugins') diff --git a/apps/plugins/lib/pluginlib_touchscreen.c b/apps/plugins/lib/pluginlib_touchscreen.c index 1e1bf8d..3920b8e 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) { int i; /* These store the width and height of the title offset */ int title_width, title_height; - + struct screen *lcd = rb->screens[SCREEN_MAIN]; + /* Loop over all the elements in data */ for(i=0; iscreens[SCREEN_MAIN]->set_viewport(&data[i].vp); + lcd->set_viewport(&data[i].vp); /* Get the string size so that the title can be centered. */ - rb->lcd_getstringsize(data[i].title, &title_width, &title_height); + lcd->getstringsize(data[i].title, &title_width, &title_height); /* Center the title vertically */ title_height=(data[i].vp.height-title_height)/2; @@ -121,16 +122,17 @@ void touchbutton_draw(struct touchbutton *data, int num_buttons) { * print the title. */ if(title_width==0) { - rb->lcd_puts_scroll(0, 0, data[i].title); + lcd->puts_scroll_style_xyoffset(0, 0, data[i].title, + STYLE_DEFAULT, 0, title_height); } else { - rb->lcd_putsxy(title_width, title_height, data[i].title); + lcd->putsxy(title_width, title_height, data[i].title); } /* Draw bounding box around the button location. */ - rb->lcd_drawrect( 0, 0, data[i].vp.width, data[i].vp.height); + lcd->draw_viewport(NULL); } } - rb->screens[SCREEN_MAIN]->set_viewport(NULL); /* Go back to the default viewport */ + lcd->set_viewport(NULL); /* Go back to the default viewport */ } /******************************************************************************* -- cgit v1.1