From 4a95a17b0c6106137e629bbcf572be3d837e8b42 Mon Sep 17 00:00:00 2001 From: Ashish Gupta Date: Thu, 11 May 2017 21:36:08 +0200 Subject: Changes to gui.c as framebuffer frontend has changed --- frontends/kolibrios/fb/gui.c | 55 +++++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/frontends/kolibrios/fb/gui.c b/frontends/kolibrios/fb/gui.c index ebd3a3d3b..90388acda 100644 --- a/frontends/kolibrios/fb/gui.c +++ b/frontends/kolibrios/fb/gui.c @@ -1592,7 +1592,7 @@ resize_browser_widget(struct gui_window *gw, int x, int y, int width, int height) { fbtk_set_pos_and_size(gw->browser, x, y, width, height); - browser_window_reformat(gw->bw, false, width, height); + browser_window_schedule_reformat(gw->bw); } static void @@ -1858,34 +1858,56 @@ gui_window_get_scroll(struct gui_window *g, int *sx, int *sy) return true; } -static void -gui_window_set_scroll(struct gui_window *gw, int sx, int sy) +/** + * Set the scroll position of a framebuffer browser window. + * + * Scrolls the viewport to ensure the specified rectangle of the + * content is shown. The framebuffer implementation scrolls the contents so + * the specified point in the content is at the top of the viewport. + * + * \param gw gui_window to scroll + * \param rect The rectangle to ensure is shown. + * \return NSERROR_OK on success or apropriate error code. + */ +static nserror +gui_window_set_scroll(struct gui_window *gw, const struct rect *rect) { struct browser_widget_s *bwidget = fbtk_get_userpw(gw->browser); float scale = browser_window_get_scale(gw->bw); assert(bwidget); - widget_scroll_x(gw, sx * scale, true); - widget_scroll_y(gw, sy * scale, true); + widget_scroll_x(gw, rect->x0 * scale, true); + widget_scroll_y(gw, rect->y0 * scale, true); + + return NSERROR_OK; } -static void -gui_window_get_dimensions(struct gui_window *g, +/** + * Find the current dimensions of a framebuffer browser window content area. + * + * \param gw The gui window to measure content area of. + * \param width receives width of window + * \param height receives height of window + * \param scaled whether to return scaled values + * \return NSERROR_OK on sucess and width and height updated. + */ +static nserror +gui_window_get_dimensions(struct gui_window *gw, int *width, int *height, bool scaled) { - float scale = browser_window_get_scale(g->bw); - - *width = fbtk_get_width(g->browser); - *height = fbtk_get_height(g->browser); + *width = fbtk_get_width(gw->browser); + *height = fbtk_get_height(gw->browser); if (scaled) { + float scale = browser_window_get_scale(gw->bw); *width /= scale; *height /= scale; } + return NSERROR_OK; } static void @@ -2064,15 +2086,6 @@ gui_window_remove_caret(struct gui_window *g) } } -static void framebuffer_window_reformat(struct gui_window *gw) -{ - /** @todo if we ever do zooming reformat should be implemented */ - LOG("window:%p", gw); - - /* - browser_window_reformat(gw->bw, false, width, height); - */ -} static struct gui_window_table framebuffer_window_table = { .create = gui_window_create, @@ -2082,7 +2095,6 @@ static struct gui_window_table framebuffer_window_table = { .set_scroll = gui_window_set_scroll, .get_dimensions = gui_window_get_dimensions, .update_extent = gui_window_update_extent, - .reformat = framebuffer_window_reformat, .set_url = gui_window_set_url, .set_status = gui_window_set_status, @@ -2234,6 +2246,7 @@ MKARGV(ARGC, "\0"); fb_warn_user(messages_get_errorcode(ret), 0); } else { framebuffer_run(); + browser_window_destroy(bw); } -- cgit v1.2.3