Other than the Amiga issue, and the comment related stuff I'll mention below, I think the select/scroll branch is ready of merge.
In article <[email protected]>, <[email protected]> wrote: > Author: paulblokus > Date: Tue Aug 11 17:24:54 2009 > New Revision: 9205 > URL: http://source.netsurf-browser.org?rev=9205&view=rev > Log: > applied most of tlsa remarks > Modified: > branches/paulblokus/selectscroll/!NetSurf/Resources/de/Messages > branches/paulblokus/selectscroll/!NetSurf/Resources/en/Messages > branches/paulblokus/selectscroll/!NetSurf/Resources/fr/Messages > branches/paulblokus/selectscroll/!NetSurf/Resources/it/Messages > branches/paulblokus/selectscroll/!NetSurf/Resources/nl/Messages > branches/paulblokus/selectscroll/desktop/browser.c > branches/paulblokus/selectscroll/desktop/scroll.c > branches/paulblokus/selectscroll/desktop/scroll.h > branches/paulblokus/selectscroll/desktop/textinput.c > branches/paulblokus/selectscroll/render/box.c > branches/paulblokus/selectscroll/render/form.c > branches/paulblokus/selectscroll/render/form.h > branches/paulblokus/selectscroll/render/html_redraw.c > Modified: branches/paulblokus/selectscroll/desktop/browser.c > URL: > http://source.netsurf-browser.org/branches/paulblokus/selectscroll/desktop/browser.c?rev=9205&r1=9204&r2=9205&view=diff > ============================================================================== > --- branches/paulblokus/selectscroll/desktop/browser.c (original) > +++ branches/paulblokus/selectscroll/desktop/browser.c Tue Aug 11 17:24:54 > 2009 > @@ -1520,30 +1520,33 @@ > drag_candidate == NULL) > drag_candidate = box; > > + /* mouse above vertical box scroll*/ > if (box->scroll_y != NULL && Put comments like this inside the if > - x > box_x + scroll_get(box->scroll_x) + > + x > box_x + scroll_get_offset(box->scroll_x) + > box->padding[LEFT] + box->width + > box->padding[RIGHT] - SCROLLBAR_WIDTH) { > bw->scrolling_box = box; > scroll = box->scroll_y; > scroll_mouse_x = x - (box_x + > - scroll_get(box->scroll_x) + > + scroll_get_offset(box->scroll_x) + > box->padding[LEFT] + > box->width + box->padding[RIGHT] - > SCROLLBAR_WIDTH); > - scroll_mouse_y = y - > - (box_y + scroll_get(box->scroll_y)); > + scroll_mouse_y = y - (box_y + > + scroll_get_offset(box->scroll_y)); > break; > + > + /* mouse above horizontal box scroll*/ > } else if (box->scroll_x != NULL && same > - y > box_y + scroll_get(box->scroll_y) + > + y > box_y + scroll_get_offset(box->scroll_y) + > box->padding[TOP] + box->height + > box->padding[BOTTOM] - SCROLLBAR_WIDTH) { > bw->scrolling_box = box; > scroll = box->scroll_x; > - scroll_mouse_x = x - > - (box_x + scroll_get(box->scroll_x)); > + scroll_mouse_x = x - (box_x + > + scroll_get_offset(box->scroll_x)); > scroll_mouse_y = y - (box_y + > - scroll_get(box->scroll_y) + > + scroll_get_offset(box->scroll_y) + > box->padding[TOP] + > box->height + box->padding[BOTTOM] - > SCROLLBAR_WIDTH); > @@ -2559,11 +2562,11 @@ > > box_coords(box, &box_x, &box_y); > if (scroll_is_horizontal(scroll_data->scroll)) { > - x = box_x + scroll_get(box->scroll_x); > - y = box_y + scroll_get(box->scroll_y) + diff_y; > + x = box_x + scroll_get_offset(box->scroll_x); > + y = box_y + scroll_get_offset(box->scroll_y) + diff_y; > } else { > - x = box_x + scroll_get(box->scroll_x) + diff_x; > - y = box_y + scroll_get(box->scroll_y); > + x = box_x + scroll_get_offset(box->scroll_x) + diff_x; > + y = box_y + scroll_get_offset(box->scroll_y); > } > } > > @@ -2737,11 +2740,15 @@ > while (child) { > if (child->type == BOX_FLOAT_LEFT || > child->type == BOX_FLOAT_RIGHT) { > - c_bx = fx + child->x - scroll_get(child->scroll_x); > - c_by = fy + child->y - scroll_get(child->scroll_y); > + c_bx = fx + child->x - > + scroll_get_offset(child->scroll_x); > + c_by = fy + child->y - > + scroll_get_offset(child->scroll_y); > } else { > - c_bx = bx + child->x - scroll_get(child->scroll_x); > - c_by = by + child->y - scroll_get(child->scroll_y); > + c_bx = bx + child->x - > + scroll_get_offset(child->scroll_x); > + c_by = by + child->y - > + scroll_get_offset(child->scroll_y); > } > if (child->float_children) { > c_fx = c_bx; > Modified: branches/paulblokus/selectscroll/desktop/scroll.c > URL: > http://source.netsurf-browser.org/branches/paulblokus/selectscroll/desktop/scroll.c?rev=9205&r1=9204&r2=9205&view=diff > ============================================================================== > --- branches/paulblokus/selectscroll/desktop/scroll.c (original) > +++ branches/paulblokus/selectscroll/desktop/scroll.c Tue Aug 11 17:24:54 2009 > @@ -33,27 +33,31 @@ > #include "utils/utils.h" > > struct scroll { > - bool horizontal; /* horizontal scroll if true vertical if false > + bool horizontal; /* Horizontal scroll if true, vertical if false > */ > - int length; /* Length of the scroll */ > + int length; /* Length of the scroll widget */ > > int scrolled_d; /* The dimension of the scrolled area */ > int scrolled_vis; /* The visible part of the scrolled area */ > > - int area_scroll; /* scroll value of the scrolled area */ > - int bar_off; /* offset of the scrollbar */ > - int bar_len; /* length of the scrollbar */ > - > - scroll_client_callback client_callback; > - void *client_data; > - > - bool dragging; > - int drag_start_coord; > - int drag_start_bar_off; > - bool reverse; > - > - struct scroll *pair; > - bool pair_drag; > + int area_scroll; /* Scroll value of the scrolled area */ > + int bar_off; /* Offset of the scrollbar */ > + int bar_len; /* Length of the scrollbar */ > + > + scroll_client_callback client_callback; /* Callback receiving scroll > + events */ > + void *client_data; /* User data passed to the callback */ > + > + bool dragging; /* Flag indicating drag at progess */ > + int drag_start_coord; /* Coordinate value at drag start */ > + int drag_start_bar_off; /* Scrollbar offset at drag start */ > + bool reverse; /* Flag indicating that the scroll should move > + * in the opposite direction than the mouse does > + */ > + > + struct scroll *pair; /* Parpendicular scroll */ > + bool pair_drag; /* Flag indicating that the current drag affects > + also the pair scroll */ > }; > > /** Overflow scrollbar colours > @@ -63,9 +67,9 @@ > * > * If a front end doesn't set scrollbar colours, these defaults are used. > */ > -colour css_scrollbar_fg_colour = 0x00d9d9d9; /* light grey */ > -colour css_scrollbar_bg_colour = 0x006b6b6b; /* mid grey */ > -colour css_scrollbar_arrow_colour = 0x00444444; /* dark grey */ > +colour scroll_widget_fg_colour = 0x00d9d9d9; /* light grey */ > +colour scroll_widget_bg_colour = 0x006b6b6b; /* mid grey */ > +colour scroll_widget_arrow_colour = 0x00444444; /* dark grey */ > > static void scroll_drag_start_internal(struct scroll *scroll, int x, int y, > bool reverse, bool pair); > @@ -76,12 +80,13 @@ > * > * \param horizontal true for a horizontal scrollbar false for a > * vertical one > - * \param length full length of the scrollbar > + * \param length full length of the scroll widget > * \param scrolled_dimension full length of the scrolled area > * \param scrolled_visible length of the visible part of the scrolled area > - * \param client_data data for th client callback > + * \param client_data data for the client callback > * \param client_callback client callback for scroll events > - * \param scroll_pt gets updated to point at te newly created scroll > + * \param scroll_pt gets updated to point at the newly created > + * scroll > * \return true if the scroll has been created succesfully > * or false on memory exhaustion > */ > @@ -113,8 +118,7 @@ > scroll->pair_drag = false; > > well_length = length - 2 * SCROLLBAR_WIDTH; > - scroll->bar_len = ((float) well_length * scrolled_visible) / > - scrolled_dimension; > + scroll->bar_len = (well_length * scrolled_visible) / scrolled_dimension; > > scroll->client_callback = client_callback; > scroll->client_data = client_data; > @@ -216,17 +220,17 @@ > int well_length, bar_off, bar_c0, bar_c1; > int v[6]; /* array of triangle vertices */ > int x0, y0, x1, y1; > - plot_style_t pstyle_css_scrollbar_bg_colour = { > + plot_style_t pstyle_scroll_widget_bg_colour = { > .fill_type = PLOT_OP_TYPE_SOLID, > - .fill_colour = css_scrollbar_bg_colour, > + .fill_colour = scroll_widget_bg_colour, > }; > - plot_style_t pstyle_css_scrollbar_fg_colour = { > + plot_style_t pstyle_scroll_widget_fg_colour = { > .fill_type = PLOT_OP_TYPE_SOLID, > - .fill_colour = css_scrollbar_fg_colour, > + .fill_colour = scroll_widget_fg_colour, > }; > - plot_style_t pstyle_css_scrollbar_arrow_colour = { > + plot_style_t pstyle_scroll_widget_arrow_colour = { > .fill_type = PLOT_OP_TYPE_SOLID, > - .fill_colour = css_scrollbar_arrow_colour, > + .fill_colour = scroll_widget_arrow_colour, > }; > > well_length = scroll->length - 2 * SCROLLBAR_WIDTH; > @@ -268,27 +272,28 @@ > if (clip_x0 > clip_x1 || clip_y0 > clip_y1) > return true; > > - plot.clip(clip_x0, clip_y0, clip_x1, clip_y1); > + if (!plot.clip(clip_x0, clip_y0, clip_x1, clip_y1)) > + return false; > > /* horizontal scrollbar */ > if (scroll->horizontal) { > /* scrollbar outline */ > if (!scroll_redraw_scrollbar_rectangle(x0, y0, x1, y1, > - css_scrollbar_bg_colour, true)) > + scroll_widget_bg_colour, true)) > return false; > /* left arrow icon border */ > if (!scroll_redraw_scrollbar_rectangle(x0 + 1, > y0 + 1, > x0 + w - 2, > y1 - 1, > - css_scrollbar_fg_colour, false)) > + scroll_widget_fg_colour, false)) > return false; > /* left arrow icon background */ > if (!plot.rectangle(x0 + 2, > y0 + 2, > x0 + w - 2, > y1 - 1, > - &pstyle_css_scrollbar_fg_colour)) > + &pstyle_scroll_widget_fg_colour)) > return false; > /* left arrow */ > v[0] = x0 + w / 4; > @@ -297,41 +302,41 @@ > v[3] = y0 + w / 4; > v[4] = x0 + w * 3 / 4; > v[5] = y0 + w * 3 / 4; > - if (!plot.polygon(v, 3, &pstyle_css_scrollbar_arrow_colour)) > + if (!plot.polygon(v, 3, &pstyle_scroll_widget_arrow_colour)) > return false; > /* scroll well background */ > if (!plot.rectangle(x0 + w - 1, > y0 + 1, > x1 - w + 2, > y1, > - &pstyle_css_scrollbar_bg_colour)) > + &pstyle_scroll_widget_bg_colour)) > return false; > /* scroll position indicator bar */ > if (!scroll_redraw_scrollbar_rectangle(bar_c0, > y0 + 1, > bar_c1, > y1 - 1, > - css_scrollbar_fg_colour, false)) > + scroll_widget_fg_colour, false)) > return false; > if (!plot.rectangle(bar_c0 + 1, > y0 + 2, > bar_c1, > y1 - 1, > - &pstyle_css_scrollbar_fg_colour)) > + &pstyle_scroll_widget_fg_colour)) > return false; > /* right arrow icon border */ > if (!scroll_redraw_scrollbar_rectangle(x1 - w + 2, > y0 + 1, > x1 - 1, > y1 - 1, > - css_scrollbar_fg_colour, false)) > + scroll_widget_fg_colour, false)) > return false; > /* right arrow icon background */ > if (!plot.rectangle(x1 - w + 3, > y0 + 2, > x1 - 1, > y1 - 1, > - &pstyle_css_scrollbar_fg_colour)) > + &pstyle_scroll_widget_fg_colour)) > return false; > /* right arrow */ > v[0] = x1 - w / 4 + 1; > @@ -340,12 +345,12 @@ > v[3] = y0 + w / 4; > v[4] = x1 - w * 3 / 4 + 1; > v[5] = y0 + w * 3 / 4; > - if (!plot.polygon(v, 3, &pstyle_css_scrollbar_arrow_colour)) > + if (!plot.polygon(v, 3, &pstyle_scroll_widget_arrow_colour)) > return false; > } else { > /* outline */ > if (!scroll_redraw_scrollbar_rectangle(x0, y0, x1, y1, > - css_scrollbar_bg_colour, > + scroll_widget_bg_colour, > true)) > return false; > /* top arrow background */ > @@ -353,14 +358,14 @@ > y0 + 1, > x1 - 1, > y0 + w - 2, > - css_scrollbar_fg_colour, > + scroll_widget_fg_colour, > false)) > return false; > if (!plot.rectangle(x0 + 2, > y0 + 2, > x1 - 1, > y0 + w - 2, > - &pstyle_css_scrollbar_fg_colour)) > + &pstyle_scroll_widget_fg_colour)) > return false; > /* up arrow */ > v[0] = x0 + w / 2; > @@ -369,40 +374,40 @@ > v[3] = y0 + w * 3 / 4; > v[4] = x0 + w * 3 / 4; > v[5] = y0 + w * 3 / 4; > - if (!plot.polygon(v, 3, &pstyle_css_scrollbar_arrow_colour)) > + if (!plot.polygon(v, 3, &pstyle_scroll_widget_arrow_colour)) > return false; > /* scroll well background */ > if (!plot.rectangle(x0 + 1, > y0 + w - 1, > x1, > y1 - w + 2, > - &pstyle_css_scrollbar_bg_colour)) > + &pstyle_scroll_widget_bg_colour)) > return false; > /* scroll position indicator bar */ > if (!scroll_redraw_scrollbar_rectangle(x0 + 1, > bar_c0, > x1 - 1, > bar_c1, > - css_scrollbar_fg_colour, false)) > + scroll_widget_fg_colour, false)) > return false; > if (!plot.rectangle(x0 + 2, > bar_c0 + 1, > x1 - 1, > bar_c1, > - &pstyle_css_scrollbar_fg_colour)) > + &pstyle_scroll_widget_fg_colour)) > return false; > /* bottom arrow background */ > if (!scroll_redraw_scrollbar_rectangle(x0 + 1, > y1 - w + 2, > x1 - 1, > y1 - 1, > - css_scrollbar_fg_colour, false)) > + scroll_widget_fg_colour, false)) > return false; > if (!plot.rectangle(x0 + 2, > y1 - w + 3, > x1 - 1, > y1 - 1, > - &pstyle_css_scrollbar_fg_colour)) > + &pstyle_scroll_widget_fg_colour)) > return false; > /* down arrow */ > v[0] = x0 + w / 2; > @@ -411,7 +416,7 @@ > v[3] = y1 - w * 3 / 4 + 1; > v[4] = x0 + w * 3 / 4; > v[5] = y1 - w * 3 / 4 + 1; > - if (!plot.polygon(v, 3, &pstyle_css_scrollbar_arrow_colour)) > + if (!plot.polygon(v, 3, &pstyle_scroll_widget_arrow_colour)) > return false; > } > > @@ -444,10 +449,9 @@ > else > scroll->bar_off = scroll_val; > > - scroll->area_scroll = (float) (scroll->scrolled_d - > - scroll->scrolled_vis) * > - (float) (scroll->bar_off)/ > - (float) (well_length - scroll->bar_len); > + scroll->area_scroll = ((scroll->scrolled_d - > + scroll->scrolled_vis) * (scroll->bar_off)) / > + (well_length - scroll->bar_len); > > } else { > if (scroll_val > scroll->scrolled_d - scroll->scrolled_vis) > @@ -456,9 +460,8 @@ > else > scroll->area_scroll = scroll_val; > > - scroll->bar_off = (float) well_length * > - (float) scroll->area_scroll / > - (float) scroll->scrolled_d; > + scroll->bar_off = (well_length * scroll->area_scroll) / > + scroll->scrolled_d; > } > > msg.scroll = scroll; > @@ -466,23 +469,23 @@ > msg.new_scroll = scroll->area_scroll; > scroll->client_callback(scroll->client_data, &msg); > > - /* TODO: redraw only the necessary part */ > msg.msg = SCROLL_MSG_REDRAW; > - msg.x0 = 0; > - msg.y0 = 0; > - msg.x1 = (scroll->horizontal ? scroll->length : SCROLLBAR_WIDTH); > + msg.x0 = scroll->horizontal ? SCROLLBAR_WIDTH - 1: 0; > + msg.y0 = scroll->horizontal ? 0 : SCROLLBAR_WIDTH - 1; > + msg.x1 = (scroll->horizontal ? > + scroll->length - SCROLLBAR_WIDTH + 1: SCROLLBAR_WIDTH); > msg.y1 = (scroll->horizontal ? > - SCROLLBAR_WIDTH : scroll->length); > + SCROLLBAR_WIDTH : scroll->length - SCROLLBAR_WIDTH + 1); > scroll->client_callback(scroll->client_data, &msg); > } > > /** > - * Get the value of the scroll. > - * > - * \param scroll the scroll to get the value of > + * Get the scroll offset for the visible part of the scrolled area. > + * > + * \param scroll the scroll to get the value from > * \return scroll offset for the scrolled area > */ > -int scroll_get(struct scroll *scroll) > +int scroll_get_offset(struct scroll *scroll) > { > if (scroll == NULL) > return 0; > @@ -507,7 +510,7 @@ > scroll->scrolled_vis = scrolled_visible; > well_length = length - 2 * SCROLLBAR_WIDTH; > > - scroll->bar_len = ((float) well_length * scrolled_visible) / > + scroll->bar_len = (well_length * scrolled_visible) / > scroll->scrolled_d; > } > > @@ -523,7 +526,7 @@ > } > > /** > - * Handle mouse actions other then movements and drag ends. > + * Handle mouse actions other then drag ends. > * > * \param scroll the scroll which gets the mouse action > * \param mouse mouse state > @@ -538,6 +541,9 @@ > int val; > const char *status; > bool h; > + /* we want mouse presses and mouse drags that were not started at > + * the scroll indication bar to be launching actions on the scroll area > + */ > bool but1 = ((mouse & BROWSER_MOUSE_PRESS_1) || > ((mouse & BROWSER_MOUSE_HOLDING_1) && > (mouse & BROWSER_MOUSE_DRAG_ON) && > @@ -554,6 +560,7 @@ > x1 = h ? scroll->length : SCROLLBAR_WIDTH; > y1 = h ? SCROLLBAR_WIDTH : scroll->length; > > + /* Not a drag and mouse outside scroll widget */ > if (!scroll->dragging && !(x >= x0 && x <= x1 && y >= y0 && y <= y1)) { > return NULL; > } Put the comment inside the if, because it's only true inside the if. Or if there's no 'else's, you can have the comment before but say /* If not a drag... */ ^^ I prefer the former. > @@ -629,13 +636,16 @@ > status = messages_get(h ? "ScrollH" : "ScrollV"); > } > > + /* The mouse event is a drag start and takes place at the scroll > + * indication bar. > + */ Same. > if (mouse & (BROWSER_MOUSE_DRAG_1 | BROWSER_MOUSE_DRAG_2) && > (val >= SCROLLBAR_WIDTH + scroll->bar_off > && val < SCROLLBAR_WIDTH + scroll->bar_off + > scroll->bar_len)) > - scroll_drag_start_internal(scroll, x, y, false, > - (mouse & BROWSER_MOUSE_DRAG_2) ? > - true : false); > + scroll_drag_start_internal(scroll, x, y, false, > + (mouse & BROWSER_MOUSE_DRAG_2) ? > + true : false); > > return status; > } > Modified: branches/paulblokus/selectscroll/desktop/scroll.h > URL: > http://source.netsurf-browser.org/branches/paulblokus/selectscroll/desktop/scroll.h?rev=9205&r1=9204&r2=9205&view=diff > ============================================================================== > --- branches/paulblokus/selectscroll/desktop/scroll.h (original) > +++ branches/paulblokus/selectscroll/desktop/scroll.h Tue Aug 11 17:24:54 2009 > @@ -69,7 +69,7 @@ > float scale); > > void scroll_set(struct scroll *scroll, int scroll_val, bool bar); > -int scroll_get(struct scroll *scroll); > +int scroll_get_offset(struct scroll *scroll); > > void scroll_set_length_and_visible(struct scroll *scroll, int length, > int scrolled_visible); > Modified: branches/paulblokus/selectscroll/desktop/textinput.c > URL: > http://source.netsurf-browser.org/branches/paulblokus/selectscroll/desktop/textinput.c?rev=9205&r1=9204&r2=9205&view=diff > ============================================================================== > --- branches/paulblokus/selectscroll/desktop/textinput.c (original) > +++ branches/paulblokus/selectscroll/desktop/textinput.c Tue Aug 11 17:24:54 > 2009 > @@ -280,11 +280,11 @@ > textarea->gadget->caret_box_offset = char_offset; > textarea->gadget->caret_pixel_offset = pixel_offset; > > - box_x += scroll_get(textarea->scroll_x); > - box_y += scroll_get(textarea->scroll_y); > + box_x += scroll_get_offset(textarea->scroll_x); > + box_y += scroll_get_offset(textarea->scroll_y); > scrolled = ensure_caret_visible(textarea); > - box_x -= scroll_get(textarea->scroll_x); > - box_y -= scroll_get(textarea->scroll_y); > + box_x -= scroll_get_offset(textarea->scroll_x); > + box_y -= scroll_get_offset(textarea->scroll_y); > > browser_window_place_caret(bw, > box_x + inline_container->x + text_box->x + > @@ -333,8 +333,8 @@ > (int) text_box->length, text_box->text)); > > box_coords(textarea, &box_x, &box_y); > - box_x -= scroll_get(textarea->scroll_x); > - box_y -= scroll_get(textarea->scroll_y); > + box_x -= scroll_get_offset(textarea->scroll_x); > + box_y -= scroll_get_offset(textarea->scroll_y); > > if (!(key <= 0x001F || (0x007F <= key && key <= 0x009F))) { > /* normal character insertion */ > @@ -757,7 +757,7 @@ > assert(text_box); > assert(char_offset <= text_box->length); > /* Scroll back to the left */ > - box_x += scroll_get(textarea->scroll_x); > + box_x += scroll_get_offset(textarea->scroll_x); > scroll_set(textarea->scroll_x, 0, false); > } else { > assert(!text_box->next || > @@ -779,11 +779,11 @@ > textarea->gadget->caret_box_offset = char_offset; > textarea->gadget->caret_pixel_offset = pixel_offset; > > - box_x += scroll_get(textarea->scroll_x); > - box_y += scroll_get(textarea->scroll_y); > + box_x += scroll_get_offset(textarea->scroll_x); > + box_y += scroll_get_offset(textarea->scroll_y); > scrolled = ensure_caret_visible(textarea); > - box_x -= scroll_get(textarea->scroll_x); > - box_y -= scroll_get(textarea->scroll_y); > + box_x -= scroll_get_offset(textarea->scroll_x); > + box_y -= scroll_get_offset(textarea->scroll_y); > > browser_window_place_caret(bw, > box_x + inline_container->x + text_box->x + > @@ -1399,11 +1399,11 @@ > textarea->gadget->caret_pixel_offset = pixel_offset; > > box_coords(textarea, &box_x, &box_y); > - box_x += scroll_get(textarea->scroll_x); > - box_y += scroll_get(textarea->scroll_y); > + box_x += scroll_get_offset(textarea->scroll_x); > + box_y += scroll_get_offset(textarea->scroll_y); > ensure_caret_visible(textarea); > - box_x -= scroll_get(textarea->scroll_x); > - box_y -= scroll_get(textarea->scroll_y); > + box_x -= scroll_get_offset(textarea->scroll_x); > + box_y -= scroll_get_offset(textarea->scroll_y); > > browser_window_place_caret(bw, > box_x + inline_container->x + text_box->x + > @@ -1519,8 +1519,8 @@ > font_plot_style_from_css(text_box->style, &fstyle); > > box_coords(textarea, &box_x, &box_y); > - box_x -= scroll_get(textarea->scroll_x); > - box_y -= scroll_get(textarea->scroll_y); > + box_x -= scroll_get_offset(textarea->scroll_x); > + box_y -= scroll_get_offset(textarea->scroll_y); > > nsfont.font_width(&fstyle, text_box->text, > char_offset, &pixel_offset); > @@ -2192,8 +2192,8 @@ > > assert(textarea->gadget); > > - scrollx = scroll_get(textarea->scroll_x); > - scrolly = scroll_get(textarea->scroll_y); > + scrollx = scroll_get_offset(textarea->scroll_x); > + scrolly = scroll_get_offset(textarea->scroll_y); > > /* Calculate the caret coordinates */ > cx = textarea->gadget->caret_pixel_offset + > @@ -2203,24 +2203,26 @@ > /* Ensure they are visible */ > if (textarea->scroll_x == NULL) { > scrollx = 0; > - } else if (cx - scroll_get(textarea->scroll_x) < 0) { > + } else if (cx - scroll_get_offset(textarea->scroll_x) < 0) { > scrollx = cx; > - } else if (cx > scroll_get(textarea->scroll_x) + textarea->width) { > + } else if (cx > scroll_get_offset(textarea->scroll_x) + > + textarea->width) { > scrollx = cx - textarea->width; > } > > if (textarea->scroll_y == NULL) { > scrolly = 0; > - } else if (cy - scroll_get(textarea->scroll_y) < 0) { > + } else if (cy - scroll_get_offset(textarea->scroll_y) < 0) { > scrolly = cy; > } else if (cy + textarea->gadget->caret_text_box->height > > - scroll_get(textarea->scroll_y) + textarea->height) { > + scroll_get_offset(textarea->scroll_y) + > + textarea->height) { > scrolly = (cy + textarea->gadget->caret_text_box->height) - > textarea->height; > } > > - if ((scrollx == scroll_get(textarea->scroll_x)) && > - (scrolly == scroll_get(textarea->scroll_y))) > + if ((scrollx == scroll_get_offset(textarea->scroll_x)) && > + (scrolly == scroll_get_offset(textarea->scroll_y))) > return false; > > > Modified: branches/paulblokus/selectscroll/render/box.c > URL: > http://source.netsurf-browser.org/branches/paulblokus/selectscroll/render/box.c?rev=9205&r1=9204&r2=9205&view=diff > ============================================================================== > --- branches/paulblokus/selectscroll/render/box.c (original) > +++ branches/paulblokus/selectscroll/render/box.c Tue Aug 11 17:24:54 2009 > @@ -256,8 +256,8 @@ > } while (!box->float_children); > } else > box = box->parent; > - *x += box->x - scroll_get(box->scroll_x); > - *y += box->y - scroll_get(box->scroll_y); > + *x += box->x - scroll_get_offset(box->scroll_x); > + *y += box->y - scroll_get_offset(box->scroll_y); > } > } > > @@ -333,8 +333,10 @@ > /* consider floats second, since they will often overlap other boxes */ > for (child = box->float_children; child; child = child->next_float) { > if (box_contains_point(child, x - bx, y - by, &physically)) { > - *box_x = bx + child->x - scroll_get(child->scroll_x); > - *box_y = by + child->y - scroll_get(child->scroll_y); > + *box_x = bx + child->x - > + scroll_get_offset(child->scroll_x); > + *box_y = by + child->y - > + scroll_get_offset(child->scroll_y); > > if (physically) > return child; > @@ -350,8 +352,10 @@ > if (box_is_float(child)) > continue; > if (box_contains_point(child, x - bx, y - by, &physically)) { > - *box_x = bx + child->x - scroll_get(child->scroll_x); > - *box_y = by + child->y - scroll_get(child->scroll_y); > + *box_x = bx + child->x - > + scroll_get_offset(child->scroll_x); > + *box_y = by + child->y - > + scroll_get_offset(child->scroll_y); > > if (physically) > return child; > @@ -375,15 +379,17 @@ > /* siblings and siblings of ancestors */ > while (box) { > if (box_is_float(box)) { > - bx -= box->x - scroll_get(box->scroll_x); > - by -= box->y - scroll_get(box->scroll_y); > + bx -= box->x - scroll_get_offset(box->scroll_x); > + by -= box->y - scroll_get_offset(box->scroll_y); > for (sibling = box->next_float; sibling; > sibling = sibling->next_float) { > if (box_contains_point(sibling, > x - bx, y - by, &physically)) { > - *box_x = bx + sibling->x - scroll_get( > + *box_x = bx + sibling->x - > + scroll_get_offset( > sibling->scroll_x); > - *box_y = by + sibling->y - scroll_get( > + *box_y = by + sibling->y - > + scroll_get_offset( > sibling->scroll_y); > > if (physically) > @@ -403,17 +409,19 @@ > goto non_float_children; > > } else { > - bx -= box->x - scroll_get(box->scroll_x); > - by -= box->y - scroll_get(box->scroll_y); > + bx -= box->x - scroll_get_offset(box->scroll_x); > + by -= box->y - scroll_get_offset(box->scroll_y); > for (sibling = box->next; sibling; > sibling = sibling->next) { > if (box_is_float(sibling)) > continue; > if (box_contains_point(sibling, x - bx, y - by, > &physically)) { > - *box_x = bx + sibling->x - scroll_get( > + *box_x = bx + sibling->x - > + scroll_get_offset( > sibling->scroll_x); > - *box_y = by + sibling->y - scroll_get( > + *box_y = by + sibling->y - > + scroll_get_offset( > sibling->scroll_y); > > if (physically) > @@ -984,6 +992,75 @@ > } > } > > +/** > + * Applies the given scroll setup to a box. This includes scroll > + * creation/deletion as well as scroll dimension updates. > + * > + * \param box the box to handle the scrolls for > + * \param x X coordinate of the box > + * \param y Y coordinate of the box > + * \param bottom whether the horizontal scrollbar should be present > + * \param right whether the vertical scrollbar should be present > + * \return true on success false otherwise > + */ > +bool box_handle_scrollbars(struct box *box, int x, int y, bool bottom, > + bool right) > +{ > + int padding_width, padding_height; > + > + padding_width = box->width + box->padding[RIGHT] + box->padding[LEFT]; > + padding_height = box->height + box->padding[TOP] + box->padding[BOTTOM]; > + > + if (!bottom && box->scroll_x != NULL) { > + scroll_destroy(box->scroll_x); > + box->scroll_x = NULL; > + } > + > + if (!right && box->scroll_y != NULL) { > + scroll_destroy(box->scroll_y); > + box->scroll_y = NULL; > + } > + > + if (!bottom && !right) > + return true; > + > + if (right) { > + if (box->scroll_y == NULL) { > + if (!scroll_create(false, > + padding_height, > + box->descendant_y1 - box->descendant_y0, > + box->height, > + current_redraw_browser, > + browser_scroll_callback, > + &(box->scroll_y))) > + return false; > + } else > + scroll_set_length_and_visible(box->scroll_y, > + padding_height, box->height); > + } > + if (bottom) { > + if (box->scroll_x == NULL) { > + if (!scroll_create(true, > + padding_width - > + (right ? SCROLLBAR_WIDTH : 0), > + box->descendant_x1 - box->descendant_x0, > + box->width, > + current_redraw_browser, > + browser_scroll_callback, > + &box->scroll_x)) > + return false; > + } else > + scroll_set_length_and_visible(box->scroll_x, > + padding_width - > + (right ? SCROLLBAR_WIDTH : 0), > + box->width); > + } > + > + if (right && bottom) > + scroll_make_pair(box->scroll_x, box->scroll_y); > + > + return true; > +} > > /** > * Determine if a box has a vertical scrollbar. > Modified: branches/paulblokus/selectscroll/render/form.c > URL: > http://source.netsurf-browser.org/branches/paulblokus/selectscroll/render/form.c?rev=9205&r1=9204&r2=9205&view=diff > ============================================================================== > --- branches/paulblokus/selectscroll/render/form.c (original) > +++ branches/paulblokus/selectscroll/render/form.c Tue Aug 11 17:24:54 2009 > @@ -58,7 +58,7 @@ > struct scroll *scroll; > int f_size; > bool scroll_capture; > - select_menu_callback callback; > + select_menu_redraw_callback callback; > void *client_data; > struct browser_window *bw; > }; > @@ -870,7 +870,7 @@ > */ > bool form_open_select_menu(void *client_data, > struct form_control *control, > - select_menu_callback callback, > + select_menu_redraw_callback callback, > struct browser_window *bw) > { > int i, line_height_with_spacing, scroll; > @@ -991,7 +991,6 @@ > struct box *box; > struct form_select_menu *menu = control->data.select.menu; > struct form_option *option; > - bool result; > int line_height, line_height_with_spacing; > int width, height; > int x0, y0, x1, scrollbar_x, y1, y2, y3; > @@ -1012,7 +1011,7 @@ > > line_height_with_spacing = line_height + > line_height * SELECT_LINE_SPACING; > - scroll = scroll_get(menu->scroll); > + scroll = scroll_get_offset(menu->scroll); > > if (scale != 1.0) { > x *= scale; > @@ -1036,8 +1035,10 @@ > y1 = y + height - 1; > scrollbar_x = x1 - scrollbar_width; > > - result = plot.clip(x0, y0, x1 + 1, y1 + 1); > - result &= plot.rectangle(x0, y0, x1, y1 ,plot_style_stroke_darkwbasec); > + if (!plot.clip(x0, y0, x1 + 1, y1 + 1)) > + return false; > + if (!plot.rectangle(x0, y0, x1, y1 ,plot_style_stroke_darkwbasec)) > + return false; > > > x0 = x0 + SELECT_BORDER_WIDTH; > @@ -1046,9 +1047,11 @@ > y1 = y1 - SELECT_BORDER_WIDTH; > height = height - 2 * SELECT_BORDER_WIDTH; > > - result = plot.clip(x0, y0, x1 + 1, y1 + 1); > - result &= plot.rectangle(x0, y0, x1 + 1, y1 + 1, > - plot_style_fill_lightwbasec); > + if (!plot.clip(x0, y0, x1 + 1, y1 + 1)) > + return false; > + if (!plot.rectangle(x0, y0, x1 + 1, y1 + 1, > + plot_style_fill_lightwbasec)) > + return false; > option = control->data.select.items; > item_y = line_height_with_spacing; > > @@ -1068,26 +1071,29 @@ > if (option->selected) { > y2 = y + item_y - scroll; > y3 = y + item_y + line_height_with_spacing - scroll; > - result &= plot.rectangle(x0, (y0 > y2 ? y0 : y2), > + if (!plot.rectangle(x0, (y0 > y2 ? y0 : y2), > scrollbar_x + 1, > (y3 < y1 + 1 ? y3 : y1 + 1), > - &plot_style_fill_selected); > + &plot_style_fill_selected)) > + return false; > } > > y2 = text_pos_offset + item_y; > - result &= plot.text(text_x, y2, option->text, > - strlen(option->text), &plot_fstyle_entry); > + if (!plot.text(text_x, y2, option->text, > + strlen(option->text), &plot_fstyle_entry)) > + return false; > > item_y += line_height_with_spacing; > option = option->next; > } > > - result &= scroll_redraw(menu->scroll, > + if (!scroll_redraw(menu->scroll, > x_cp + menu->width - SCROLLBAR_WIDTH, > y_cp, > - clip_x0, clip_y0, clip_x1, clip_y1, scale); > - > - return result; > + clip_x0, clip_y0, clip_x1, clip_y1, scale)) > + return false; > + > + return true; > } > > /** > @@ -1139,7 +1145,7 @@ > int item_bottom_y; > int scroll, i; > > - scroll = scroll_get(menu->scroll); > + scroll = scroll_get_offset(menu->scroll); > > line_height = menu->line_height; > line_height_with_spacing = line_height + > @@ -1167,45 +1173,53 @@ > * \param mouse current mouse state > * \param x X coordinate of click > * \param y Y coordinate of click > - * \return text for the browser status bar or NULL on failure > + * \return text for the browser status bar or NULL if the menu has > + * to be closed > */ > const char *form_select_mouse_action(struct form_control *control, > browser_mouse_state mouse, int x, int y) > { > struct form_select_menu *menu = control->data.select.menu; > - int x0, y0, x1, y1, x3; > + int x0, y0, x1, y1, scrollbar_x; > const char *status = NULL; > bool closed = false; > + bool option_area = false; > > x0 = 0; > y0 = 0; > x1 = menu->width; > y1 = menu->height; > - x3 = x1 - SCROLLBAR_WIDTH; > - > + scrollbar_x = x1 - SCROLLBAR_WIDTH; > + > + /* The scroll is currently capturing all events or the mouse event is > + * taking place on the scrollbar widget area > + */ > if (menu->scroll_capture || > - (x > x3 && x < x1 && y > y0 && y < y1)) { > - x -= menu->width - SCROLLBAR_WIDTH; > + (x > scrollbar_x && x < x1 && y > y0 && y < y1)) { Comment inside. > + x -= scrollbar_x; > return scroll_mouse_action(menu->scroll, > mouse, x, y); > } > - > - if (mouse & BROWSER_MOUSE_CLICK_1) { > - if (x > x0 && x < x1 && y > y0 && y < y1) { > - if (x < x1 - SCROLLBAR_WIDTH) > - form_select_menu_clicked(control, x, y); > - else { > - x -= menu->width - SCROLLBAR_WIDTH; > - status = scroll_mouse_action(menu->scroll, > - mouse, x, y); > - } > - } > + > + if (x > x0 && x < scrollbar_x && y > y0 && y < y1) > + option_area = true; > + > + /* button 1 or 2 click */ > + if (mouse & (BROWSER_MOUSE_CLICK_1 | BROWSER_MOUSE_CLICK_2)) { > + > + /* over option area */ > + if (option_area) Comment inside. > + form_select_menu_clicked(control, x, y); > else > closed = true; > - } > - if (status == NULL && !closed) > - status = messages_get(control->data.select.multiple ? > - "SelectMClick" : "SelectClick"); > + } else { > + if (option_area) > + status = messages_get(control->data.select.multiple ? > + "SelectMClick" : "SelectClick"); > + else > + status = messages_get("SelectClose"); > + } > + > return status; > } > > @@ -1235,6 +1249,7 @@ > x1 = menu->width; > y1 = menu->height; > > + /* handle drag end above the option area like a regular click */ > if (x > x0 && x < x1 - SCROLLBAR_WIDTH && y > y0 && y < y1) Comment inside. > form_select_menu_clicked(control, x, y); > } > Modified: branches/paulblokus/selectscroll/render/form.h > URL: > http://source.netsurf-browser.org/branches/paulblokus/selectscroll/render/form.h?rev=9205&r1=9204&r2=9205&view=diff > ============================================================================== > --- branches/paulblokus/selectscroll/render/form.h (original) > +++ branches/paulblokus/selectscroll/render/form.h Tue Aug 11 17:24:54 2009 > @@ -133,7 +133,17 @@ > struct form_successful_control *next; /**< Next in linked list. */ > }; > > -typedef void(*select_menu_callback)(void *client_data, > +/** > + * Called by the select menu when it wants an area to be redrawn. The > + * coordinates are menu origin relative. > + * > + * \param client_data data which was passed to form_open_select_menu > + * \param x X coordinate of redraw rectangle > + * \param y Y coordinate of redraw rectangle > + * \param width width of redraw rectangle > + * \param height height of redraw rectangle > + */ > +typedef void(*select_menu_redraw_callback)(void *client_data, > int x, int y, int width, int height); > > struct form *form_new(void *node, const char *action, const char *target, > @@ -154,7 +164,7 @@ > > bool form_open_select_menu(void *client_data, > struct form_control *control, > - select_menu_callback redraw_callback, > + select_menu_redraw_callback redraw_callback, > struct browser_window *bw); > void form_free_select_menu(struct form_control *control); > bool form_redraw_select_menu(struct form_control *control, int x, int y, > Modified: branches/paulblokus/selectscroll/render/html_redraw.c > URL: > http://source.netsurf-browser.org/branches/paulblokus/selectscroll/render/html_redraw.c?rev=9205&r1=9204&r2=9205&view=diff > ============================================================================== > --- branches/paulblokus/selectscroll/render/html_redraw.c (original) > +++ branches/paulblokus/selectscroll/render/html_redraw.c Tue Aug 11 17:24:54 > 2009 > @@ -647,8 +647,8 @@ > return false; > > if (box->object) { > - x_scrolled = x - scroll_get(box->scroll_x) * scale; > - y_scrolled = y - scroll_get(box->scroll_y) * scale; > + x_scrolled = x - scroll_get_offset(box->scroll_x) * scale; > + y_scrolled = y - scroll_get_offset(box->scroll_y) * scale; > if (!content_redraw(box->object, > x_scrolled + padding_left, > y_scrolled + padding_top, > @@ -689,8 +689,10 @@ > /* list marker */ > if (box->list_marker) > if (!html_redraw_box(box->list_marker, > - x_parent + box->x - scroll_get(box->scroll_x), > - y_parent + box->y - scroll_get(box->scroll_y), > + x_parent + box->x - > + scroll_get_offset(box->scroll_x), > + y_parent + box->y - > + scroll_get_offset(box->scroll_y), > clip_x0, clip_y0, clip_x1, clip_y1, > scale, current_background_color)) > return false; > @@ -770,17 +772,19 @@ > if (c->type != BOX_FLOAT_LEFT && c->type != BOX_FLOAT_RIGHT) > if (!html_redraw_box(c, > x_parent + box->x - > - scroll_get(box->scroll_x), > + scroll_get_offset(box->scroll_x), > y_parent + box->y - > - scroll_get(box->scroll_y), > + scroll_get_offset(box->scroll_y), > clip_x0, clip_y0, clip_x1, clip_y1, > scale, current_background_color)) > return false; > } > for (c = box->float_children; c; c = c->next_float) > if (!html_redraw_box(c, > - x_parent + box->x - scroll_get(box->scroll_x), > - y_parent + box->y - scroll_get(box->scroll_y), > + x_parent + box->x - > + scroll_get_offset(box->scroll_x), > + y_parent + box->y - > + scroll_get_offset(box->scroll_y), > clip_x0, clip_y0, clip_x1, clip_y1, > scale, current_background_color)) > return false; > @@ -2011,73 +2015,3 @@ > } > return true; > } > - > -/** > - * Applies the given scroll setup to a box. This includes scroll > - * creation/deletion as well as scroll dimension updates. > - * > - * \param box the box to handle the scrolls for > - * \param x X coordinate of the box > - * \param y Y coordinate of the box > - * \param bottom whether the horizontal scrollbar should be present > - * \param right whether the vertical scrollbar should be present > - * \return true on success false otherwise > - */ > -bool box_handle_scrollbars(struct box *box, int x, int y, bool bottom, > - bool right) > -{ > - int padding_width, padding_height; > - > - padding_width = box->width + box->padding[RIGHT] + box->padding[LEFT]; > - padding_height = box->height + box->padding[TOP] + box->padding[BOTTOM]; > - > - if (!bottom && box->scroll_x != NULL) { > - scroll_destroy(box->scroll_x); > - box->scroll_x = NULL; > - } > - > - if (!right && box->scroll_y != NULL) { > - scroll_destroy(box->scroll_y); > - box->scroll_y = NULL; > - } > - > - if (!bottom && !right) > - return true; > - > - if (right) { > - if (box->scroll_y == NULL) { > - if (!scroll_create(false, > - padding_height, > - box->descendant_y1 - box->descendant_y0, > - box->height, > - current_redraw_browser, > - browser_scroll_callback, > - &(box->scroll_y))) > - return false; > - } else > - scroll_set_length_and_visible(box->scroll_y, > - padding_height, box->height); > - } > - if (bottom) { > - if (box->scroll_x == NULL) { > - if (!scroll_create(true, > - padding_width - > - (right ? SCROLLBAR_WIDTH : 0), > - box->descendant_x1 - box->descendant_x0, > - box->width, > - current_redraw_browser, > - browser_scroll_callback, > - &box->scroll_x)) > - return false; > - } else > - scroll_set_length_and_visible(box->scroll_x, > - padding_width - > - (right ? SCROLLBAR_WIDTH : 0), > - box->width); > - } > - > - if (right && bottom) > - scroll_make_pair(box->scroll_x, box->scroll_y); > - > - return true; > -} > _______________________________________________ > netsurf-commits mailing list > [email protected] > http://vlists.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org -- Michael Drake (tlsa) http://www.netsurf-browser.org/
