static void gui_window_update_box(struct gui_window *g, const struct rect *rect) { struct browser_widget_s *bwidget = fbtk_get_userpw(g->browser); fb_queue_redraw(g->browser, rect->x0 - bwidget->scrollx, rect->y0 - bwidget->scrolly, rect->x1 - bwidget->scrollx, rect->y1 - bwidget->scrolly); }
static void gui_window_remove_caret_cb(fbtk_widget_t *widget) { struct browser_widget_s *bwidget = fbtk_get_userpw(widget); int c_x, c_y, c_h; if (fbtk_get_caret(widget, &c_x, &c_y, &c_h)) { /* browser window already had caret: * redraw its area to remove it first */ fb_queue_redraw(widget, c_x - bwidget->scrollx, c_y - bwidget->scrolly, c_x + 1 - bwidget->scrollx, c_y + c_h - bwidget->scrolly); } }
void gui_window_place_caret(struct gui_window *g, int x, int y, int height) { struct browser_widget_s *bwidget = fbtk_get_userpw(g->browser); /* set new pos */ fbtk_set_caret(g->browser, true, x, y, height, gui_window_remove_caret_cb); /* redraw new caret pos */ fb_queue_redraw(g->browser, x - bwidget->scrollx, y - bwidget->scrolly, x + 1 - bwidget->scrollx, y + height - bwidget->scrolly); }
static void fb_pan(fbtk_widget_t *widget, struct browser_widget_s *bwidget, struct browser_window *bw) { int x; int y; int width; int height; nsfb_bbox_t srcbox; nsfb_bbox_t dstbox; nsfb_t *nsfb = fbtk_get_nsfb(widget); height = fbtk_get_height(widget); width = fbtk_get_width(widget); LOG(("panning %d, %d", bwidget->panx, bwidget->pany)); x = fbtk_get_absx(widget); y = fbtk_get_absy(widget); /* if the pan exceeds the viewport size just redraw the whole area */ if (bwidget->pany >= height || bwidget->pany <= -height || bwidget->panx >= width || bwidget->panx <= -width) { bwidget->scrolly += bwidget->pany; bwidget->scrollx += bwidget->panx; fb_queue_redraw(widget, 0, 0, width, height); /* ensure we don't try to scroll again */ bwidget->panx = 0; bwidget->pany = 0; bwidget->pan_required = false; return; } if (bwidget->pany < 0) { /* pan up by less then viewport height */ srcbox.x0 = x; srcbox.y0 = y; srcbox.x1 = srcbox.x0 + width; srcbox.y1 = srcbox.y0 + height + bwidget->pany; dstbox.x0 = x; dstbox.y0 = y - bwidget->pany; dstbox.x1 = dstbox.x0 + width; dstbox.y1 = dstbox.y0 + height + bwidget->pany; /* move part that remains visible up */ nsfb_plot_copy(nsfb, &srcbox, nsfb, &dstbox); /* redraw newly exposed area */ bwidget->scrolly += bwidget->pany; fb_queue_redraw(widget, 0, 0, width, - bwidget->pany); } else if (bwidget->pany > 0) { /* pan down by less then viewport height */ srcbox.x0 = x; srcbox.y0 = y + bwidget->pany; srcbox.x1 = srcbox.x0 + width; srcbox.y1 = srcbox.y0 + height - bwidget->pany; dstbox.x0 = x; dstbox.y0 = y; dstbox.x1 = dstbox.x0 + width; dstbox.y1 = dstbox.y0 + height - bwidget->pany; /* move part that remains visible down */ nsfb_plot_copy(nsfb, &srcbox, nsfb, &dstbox); /* redraw newly exposed area */ bwidget->scrolly += bwidget->pany; fb_queue_redraw(widget, 0, height - bwidget->pany, width, height); } if (bwidget->panx < 0) { /* pan left by less then viewport width */ srcbox.x0 = x; srcbox.y0 = y; srcbox.x1 = srcbox.x0 + width + bwidget->panx; srcbox.y1 = srcbox.y0 + height; dstbox.x0 = x - bwidget->panx; dstbox.y0 = y; dstbox.x1 = dstbox.x0 + width + bwidget->panx; dstbox.y1 = dstbox.y0 + height; /* move part that remains visible left */ nsfb_plot_copy(nsfb, &srcbox, nsfb, &dstbox); /* redraw newly exposed area */ bwidget->scrollx += bwidget->panx; fb_queue_redraw(widget, 0, 0, -bwidget->panx, height); } else if (bwidget->panx > 0) { /* pan right by less then viewport width */ srcbox.x0 = x + bwidget->panx; srcbox.y0 = y; srcbox.x1 = srcbox.x0 + width - bwidget->panx; srcbox.y1 = srcbox.y0 + height; dstbox.x0 = x; dstbox.y0 = y; dstbox.x1 = dstbox.x0 + width - bwidget->panx; dstbox.y1 = dstbox.y0 + height; /* move part that remains visible right */ nsfb_plot_copy(nsfb, &srcbox, nsfb, &dstbox); /* redraw newly exposed area */ bwidget->scrollx += bwidget->panx; fb_queue_redraw(widget, width - bwidget->panx, 0, width, height); } bwidget->pan_required = false; bwidget->panx = 0; bwidget->pany = 0; }
static void gui_window_redraw_window(struct gui_window *g) { fb_queue_redraw(g->browser, 0, 0, fbtk_get_width(g->browser), fbtk_get_height(g->browser) ); }