diff options
author | James Bursa <james@netsurf-browser.org> | 2007-08-07 03:55:18 +0000 |
---|---|---|
committer | James Bursa <james@netsurf-browser.org> | 2007-08-07 03:55:18 +0000 |
commit | 07c54283e364bd66e21fbd659ea0dd469201a747 (patch) | |
tree | 17bcc30ded5b29d3c2c769ef9933228168aa69f1 /riscos | |
parent | 7ec7ba37dbeeee678ec573bcfe0594660fbe5195 (diff) | |
download | netsurf-07c54283e364bd66e21fbd659ea0dd469201a747.tar.gz netsurf-07c54283e364bd66e21fbd659ea0dd469201a747.tar.bz2 |
Move window scaling from platform-specific code to desktop/browser.c. Modify gtk gui to handle scaling in the same way as RO.
svn path=/trunk/netsurf/; revision=3478
Diffstat (limited to 'riscos')
-rw-r--r-- | riscos/dialog.c | 2 | ||||
-rw-r--r-- | riscos/gui.c | 7 | ||||
-rw-r--r-- | riscos/gui.h | 4 | ||||
-rw-r--r-- | riscos/options.h | 3 | ||||
-rw-r--r-- | riscos/window.c | 181 |
5 files changed, 80 insertions, 117 deletions
diff --git a/riscos/dialog.c b/riscos/dialog.c index 562ef052c..77a434b87 100644 --- a/riscos/dialog.c +++ b/riscos/dialog.c @@ -675,7 +675,7 @@ bool ro_gui_dialog_zoom_apply(wimp_w w) { void ro_gui_dialog_prepare_zoom(struct gui_window *g) { char scale_buffer[8]; - sprintf(scale_buffer, "%.0f", g->option.scale * 100); + sprintf(scale_buffer, "%.0f", g->bw->scale * 100); ro_gui_set_icon_string(dialog_zoom, ICON_ZOOM_VALUE, scale_buffer); ro_gui_set_icon_selected_state(dialog_zoom, ICON_ZOOM_FRAMES, true); ro_gui_set_icon_shaded_state(dialog_zoom, ICON_ZOOM_FRAMES, diff --git a/riscos/gui.c b/riscos/gui.c index e0ccfb048..408f62f84 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -156,9 +156,6 @@ static wimp_w gui_track_wimp_w; /** Browser window which the pointer is over, or 0 if none. */ struct gui_window *gui_track_gui_window; -/** Some windows have been resized, and should be reformatted. */ -bool gui_reformat_pending = false; - gui_drag_type gui_current_drag_type; wimp_t task_handle; /**< RISC OS wimp task handle. */ static clock_t gui_last_poll; /**< Time of last wimp_poll. */ @@ -883,7 +880,7 @@ void gui_poll(bool active) xhourglass_off(); if (active) { event = wimp_poll(mask, &block, 0); - } else if (sched_active || gui_track || gui_reformat_pending || + } else if (sched_active || gui_track || browser_reformat_pending || bitmap_maintenance) { os_t t = os_read_monotonic_time(); @@ -914,7 +911,7 @@ void gui_poll(bool active) schedule_run(); ro_gui_window_update_boxes(); - if (gui_reformat_pending && event == wimp_NULL_REASON_CODE) + if (browser_reformat_pending && event == wimp_NULL_REASON_CODE) ro_gui_window_process_reformats(); else if (bitmap_maintenance_priority || (bitmap_maintenance && event == wimp_NULL_REASON_CODE)) diff --git a/riscos/gui.h b/riscos/gui.h index 2bc251060..b9c05ee83 100644 --- a/riscos/gui.h +++ b/riscos/gui.h @@ -49,7 +49,6 @@ extern bool current_menu_open; extern wimp_menu *recent_search_menu; /* search.c */ extern wimp_w history_window; extern struct form_control *current_gadget; -extern bool gui_reformat_pending; extern bool gui_redraw_debug; extern osspriteop_area *gui_sprites; extern bool dialog_folder_add, dialog_entry_add, hotlist_insert; @@ -79,8 +78,6 @@ struct gui_window { wimp_w window; /**< RISC OS window handle. */ - /** Window has been resized, and content needs reformatting. */ - bool reformat_pending; int old_width; /**< Width when last opened / os units. */ int old_height; /**< Height when last opened / os units. */ bool update_extent; /**< Update the extent on next opening */ @@ -96,7 +93,6 @@ struct gui_window { /** Options. */ struct { - float scale; /**< Scale, 1.0 = 100%. */ bool background_images; /**< Display background images. */ bool buffer_animations; /**< Use screen buffering for animations. */ bool buffer_everything; /**< Use screen buffering for everything. */ diff --git a/riscos/options.h b/riscos/options.h index 1aa2c2f0f..f7bf56feb 100644 --- a/riscos/options.h +++ b/riscos/options.h @@ -23,7 +23,6 @@ extern char *option_language; extern int option_fg_plot_style; /* tinct flagword */ extern int option_bg_plot_style; /* tinct flagword */ extern bool option_history_tooltip; -extern int option_scale; extern bool option_toolbar_show_buttons; extern bool option_toolbar_show_address; extern bool option_toolbar_show_throbber; @@ -61,7 +60,6 @@ char *option_language = 0;\ int option_fg_plot_style = tinct_ERROR_DIFFUSE;\ int option_bg_plot_style = tinct_DITHER;\ bool option_history_tooltip = true; \ -int option_scale = 100; \ bool option_toolbar_show_buttons = true; \ bool option_toolbar_show_address = true; \ bool option_toolbar_show_throbber = true; \ @@ -99,7 +97,6 @@ bool option_thumbnail_iconise = true; { "plot_fg_quality", OPTION_INTEGER, &option_fg_plot_style },\ { "plot_bg_quality", OPTION_INTEGER, &option_bg_plot_style },\ { "history_tooltip", OPTION_BOOL, &option_history_tooltip }, \ -{ "scale", OPTION_INTEGER, &option_scale }, \ { "toolbar_show_buttons", OPTION_BOOL, &option_toolbar_show_buttons }, \ { "toolbar_show_address", OPTION_BOOL, &option_toolbar_show_address }, \ { "toolbar_show_throbber", OPTION_BOOL, &option_toolbar_show_throbber }, \ diff --git a/riscos/window.c b/riscos/window.c index c47d02c49..fb9900674 100644 --- a/riscos/window.c +++ b/riscos/window.c @@ -173,7 +173,6 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw, g->bw = bw; g->toolbar = 0; g->status_bar = 0; - g->reformat_pending = false; g->old_width = 0; g->old_height = 0; g->update_extent = true; @@ -469,13 +468,14 @@ void gui_window_set_title(struct gui_window *g, const char *title) assert(g); assert(title); - if (g->option.scale != 1.0) { - scale_disp = g->option.scale * 100; - if (ABS((float)scale_disp - g->option.scale * 100) >= 0.05) - snprintf(g->title, sizeof g->title, "%s (%.1f%%)", title, - g->option.scale * 100); + if (g->bw->scale != 1.0) { + scale_disp = g->bw->scale * 100; + if (ABS((float)scale_disp - g->bw->scale * 100) >= 0.05) + snprintf(g->title, sizeof g->title, "%s (%.1f%%)", + title, g->bw->scale * 100); else - snprintf(g->title, sizeof g->title, "%s (%i%%)", title, scale_disp); + snprintf(g->title, sizeof g->title, "%s (%i%%)", + title, scale_disp); } else { strncpy(g->title, title, sizeof g->title); } @@ -558,10 +558,10 @@ void gui_window_update_box(struct gui_window *g, if (!c) return; - x0 = floorf(data->redraw.x * 2 * g->option.scale); - y0 = -ceilf((data->redraw.y + data->redraw.height) * 2 * g->option.scale); - x1 = ceilf((data->redraw.x + data->redraw.width) * 2 * g->option.scale) + 1; - y1 = -floorf(data->redraw.y * 2 * g->option.scale) + 1; + x0 = floorf(data->redraw.x * 2 * g->bw->scale); + y0 = -ceilf((data->redraw.y + data->redraw.height) * 2 * g->bw->scale); + x1 = ceilf((data->redraw.x + data->redraw.width) * 2 * g->bw->scale) + 1; + y1 = -floorf(data->redraw.y * 2 * g->bw->scale) + 1; use_buffer = (data->redraw.full_redraw) && (g->option.buffer_everything || g->option.buffer_animations); @@ -627,8 +627,8 @@ bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy) if (g->toolbar) toolbar_height = ro_gui_theme_toolbar_full_height(g->toolbar); - *sx = state.xscroll / (2 * g->option.scale); - *sy = -(state.yscroll - toolbar_height) / (2 * g->option.scale); + *sx = state.xscroll / (2 * g->bw->scale); + *sy = -(state.yscroll - toolbar_height) / (2 * g->bw->scale); return true; } @@ -657,8 +657,8 @@ void gui_window_set_scroll(struct gui_window *g, int sx, int sy) return; } - state.xscroll = sx * 2 * g->option.scale; - state.yscroll = -sy * 2 * g->option.scale; + state.xscroll = sx * 2 * g->bw->scale; + state.yscroll = -sy * 2 * g->bw->scale; if (g->toolbar) state.yscroll += ro_gui_theme_toolbar_full_height(g->toolbar); ro_gui_window_open((wimp_open *)&state); @@ -697,10 +697,10 @@ void gui_window_scroll_visible(struct gui_window *g, int x0, int y0, int x1, int if (g->toolbar) toolbar_height = ro_gui_theme_toolbar_full_height(g->toolbar); - x0 = x0 * 2 * g->option.scale; - y0 = y0 * 2 * g->option.scale; - x1 = x1 * 2 * g->option.scale; - y1 = y1 * 2 * g->option.scale; + x0 = x0 * 2 * g->bw->scale; + y0 = y0 * 2 * g->bw->scale; + x1 = x1 * 2 * g->bw->scale; + y1 = y1 * 2 * g->bw->scale; cx0 = state.xscroll; cy0 = -state.yscroll + toolbar_height; @@ -790,7 +790,7 @@ void gui_window_position_frame(struct gui_window *g, int x0, int y0, int x1, int /* only scale iframe locations */ if (bw->browser_window_type == BROWSER_WINDOW_IFRAME) - scale = g->option.scale; + scale = g->bw->scale; /* get the position of the top level window */ state.w = top->window->window; @@ -858,8 +858,8 @@ void gui_window_get_dimensions(struct gui_window *g, int *width, int *height, bo *width = g->old_width / 2; *height = g->old_height / 2; if (scaled) { - *width /= g->option.scale; - *height /= g->option.scale; + *width /= g->bw->scale; + *height /= g->bw->scale; } } @@ -897,7 +897,7 @@ void gui_window_update_extent(struct gui_window *g) /* only allow a further reformat if we've gained/lost scrollbars */ flags = state.flags & (wimp_WINDOW_HSCROLL | wimp_WINDOW_VSCROLL); - update = g->reformat_pending; + update = g->bw->reformat_pending; g->update_extent = true; ro_gui_window_open((wimp_open *)&state); @@ -910,7 +910,7 @@ void gui_window_update_extent(struct gui_window *g) return; } if (flags == (state.flags & (wimp_WINDOW_HSCROLL | wimp_WINDOW_VSCROLL))) - g->reformat_pending = update; + g->bw->reformat_pending = update; if ((scroll != 0) && (g->bw->children)) browser_window_recalculate_frameset(g->bw); } @@ -1090,9 +1090,9 @@ void gui_window_place_caret(struct gui_window *g, int x, int y, int height) os_error *error; error = xwimp_set_caret_position(g->window, -1, - x * 2 * g->option.scale, - -(y + height) * 2 * g->option.scale, - height * 2 * g->option.scale, -1); + x * 2 * g->bw->scale, + -(y + height) * 2 * g->bw->scale, + height * 2 * g->bw->scale, -1); if (error) { LOG(("xwimp_set_caret_position: 0x%x: %s", error->errnum, error->errmess)); @@ -1230,10 +1230,10 @@ bool gui_window_box_scroll_start(struct gui_window *g, int x0, int y0, int x1, i } drag.type = wimp_DRAG_USER_POINT; - drag.bbox.x0 = pointer.pos.x + (int)(x0 * 2 * g->option.scale); - drag.bbox.y0 = pointer.pos.y + (int)(y0 * 2 * g->option.scale); - drag.bbox.x1 = pointer.pos.x + (int)(x1 * 2 * g->option.scale); - drag.bbox.y1 = pointer.pos.y + (int)(y1 * 2 * g->option.scale); + drag.bbox.x0 = pointer.pos.x + (int)(x0 * 2 * g->bw->scale); + drag.bbox.y0 = pointer.pos.y + (int)(y0 * 2 * g->bw->scale); + drag.bbox.x1 = pointer.pos.x + (int)(x1 * 2 * g->bw->scale); + drag.bbox.y1 = pointer.pos.y + (int)(y1 * 2 * g->bw->scale); error = xwimp_drag_box(&drag); if (error) { @@ -1363,19 +1363,6 @@ void gui_window_save_as_link(struct gui_window *g, struct content *c) /** - * Get the scale setting of a window - * - * \param g gui window - * \return scale value (1.0 == normal scale) - */ - -float gui_window_get_scale(struct gui_window *g) -{ - return g->option.scale; -} - - -/** * Set the scale setting of a window * * \param g gui window @@ -1384,21 +1371,7 @@ float gui_window_get_scale(struct gui_window *g) void gui_window_set_scale(struct gui_window *g, float scale) { - struct content *c; - - if (g->option.scale == scale) - return; - g->option.scale = scale; - c = g->bw->current_content; - if (c) { - ro_gui_dialog_update_zoom(g); - if (!content_get_reformat(c)) { - browser_window_update(g->bw, false); - } else { - g->reformat_pending = true; - gui_reformat_pending = true; - } - } + ro_gui_dialog_update_zoom(g); } @@ -1422,7 +1395,7 @@ void ro_gui_window_redraw(wimp_draw *redraw) osbool more; bool knockout = true; struct gui_window *g = (struct gui_window *)ro_gui_wimp_event_get_user_data(redraw->w); - float scale = g->option.scale; + float scale = g->bw->scale; struct content *c = g->bw->current_content; int clip_x0, clip_y0, clip_x1, clip_y1, clear_x1, clear_y1; os_error *error; @@ -1439,9 +1412,9 @@ void ro_gui_window_redraw(wimp_draw *redraw) ro_gui_current_redraw_gui = g; current_redraw_browser = g->bw; - /* rendering textplain has no advantages using knockout rendering other than to - * slow things down. */ - if (c->type == CONTENT_TEXTPLAIN) + /* rendering textplain has no advantages using knockout rendering other + * than to slow things down. */ + if (c->type == CONTENT_TEXTPLAIN || c->type == CONTENT_SVG) knockout = false; /* HTML rendering handles scale itself */ @@ -1477,7 +1450,7 @@ void ro_gui_window_redraw(wimp_draw *redraw) content_redraw(c, 0, 0, c->width * scale, c->height * scale, clip_x0, clip_y0, clip_x1, clip_y1, - g->option.scale, + g->bw->scale, 0xFFFFFF); if (knockout) knockout_plot_end(); @@ -1569,7 +1542,7 @@ void ro_gui_window_update_boxes(void) { plot = ro_plotters; ro_plot_origin_x = update.box.x0 - update.xscroll; ro_plot_origin_y = update.box.y1 - update.yscroll; - ro_plot_set_scale(g->option.scale); + ro_plot_set_scale(g->bw->scale); /* We should clear the background, except for HTML. */ @@ -1601,21 +1574,21 @@ void ro_gui_window_update_boxes(void) { content_redraw(c, 0, 0, c->width, c->height, clip_x0, clip_y0, clip_x1, clip_y1, - g->option.scale, + g->bw->scale, 0xFFFFFF); } else { assert(data->redraw.object); content_redraw(data->redraw.object, floorf(data->redraw.object_x * - g->option.scale), + g->bw->scale), ceilf(data->redraw.object_y * - g->option.scale), + g->bw->scale), data->redraw.object_width * - g->option.scale, + g->bw->scale, data->redraw.object_height * - g->option.scale, + g->bw->scale, clip_x0, clip_y0, clip_x1, clip_y1, - g->option.scale, + g->bw->scale, 0xFFFFFF); } @@ -1745,8 +1718,8 @@ void gui_window_set_extent(struct gui_window *g, int width, int height) height -= ro_get_title_height(g->window); } if (content) { - width = max(width, content->width * 2 * g->option.scale); - height = max(height, content->height * 2 * g->option.scale); + width = max(width, content->width * 2 * g->bw->scale); + height = max(height, content->height * 2 * g->bw->scale); } os_box extent = { 0, -height, width, toolbar_height }; error = xwimp_set_extent(g->window, &extent); @@ -1823,14 +1796,14 @@ void ro_gui_window_open(wimp_open *open) if ((!no_hscroll) && ((fheight > size) || (g->bw->browser_window_type == BROWSER_WINDOW_NORMAL)) && - ((content && width < content->width * 2 * g->option.scale) || + ((content && width < content->width * 2 * g->bw->scale) || (g->bw->browser_window_type == BROWSER_WINDOW_NORMAL))) { if (!(state.flags & wimp_WINDOW_HSCROLL)) { height -= size; state.visible.y0 += size; if (content) { - g->reformat_pending = true; - gui_reformat_pending = true; + g->bw->reformat_pending = true; + browser_reformat_pending = true; } } state.flags |= wimp_WINDOW_HSCROLL; @@ -1839,8 +1812,8 @@ void ro_gui_window_open(wimp_open *open) height += size; state.visible.y0 -= size; if (content) { - g->reformat_pending = true; - gui_reformat_pending = true; + g->bw->reformat_pending = true; + browser_reformat_pending = true; } } state.flags &= ~wimp_WINDOW_HSCROLL; @@ -1856,14 +1829,14 @@ void ro_gui_window_open(wimp_open *open) if ((!no_vscroll) && ((fwidth > size) || (g->bw->browser_window_type == BROWSER_WINDOW_NORMAL)) && - ((content && height < content->height * 2 * g->option.scale) || + ((content && height < content->height * 2 * g->bw->scale) || (g->bw->scrolling == SCROLLING_YES))) { if (!(state.flags & wimp_WINDOW_VSCROLL)) { width -= size; state.visible.x1 -= size; if (content) { - g->reformat_pending = true; - gui_reformat_pending = true; + g->bw->reformat_pending = true; + browser_reformat_pending = true; } } state.flags |= wimp_WINDOW_VSCROLL; @@ -1872,8 +1845,8 @@ void ro_gui_window_open(wimp_open *open) width += size; state.visible.x1 += size; if (content) { - g->reformat_pending = true; - gui_reformat_pending = true; + g->bw->reformat_pending = true; + browser_reformat_pending = true; } } state.flags &= ~wimp_WINDOW_VSCROLL; @@ -1885,9 +1858,9 @@ void ro_gui_window_open(wimp_open *open) /* Ctrl-resize of a top-level window scales the content size */ if ((g->old_width > 0) && (g->old_width != width) && (!g->bw->parent) && (ro_gui_ctrl_pressed())) - new_scale = (g->option.scale * width) / g->old_width; - g->reformat_pending = true; - gui_reformat_pending = true; + new_scale = (g->bw->scale * width) / g->old_width; + g->bw->reformat_pending = true; + browser_reformat_pending = true; } if (g->update_extent || g->old_width != width || g->old_height != height) { g->old_width = width; @@ -2514,16 +2487,16 @@ bool ro_gui_window_keypress(wimp_key *key) case 23: /* CTRL+W (Zoom in) */ if (!content) break; - scale = g->option.scale; + scale = g->bw->scale; if (ro_gui_shift_pressed() && c == 17) - scale = g->option.scale - 0.1; + scale = g->bw->scale - 0.1; else if (ro_gui_shift_pressed() && c == 23) - scale = g->option.scale + 0.1; + scale = g->bw->scale + 0.1; else if (c == 17) { for (int i = SCALE_SNAP_TO_SIZE - 1; i >= 0; i--) if (scale_snap_to[i] < - g->option.scale) { + g->bw->scale) { scale = scale_snap_to[i]; break; } @@ -2531,7 +2504,7 @@ bool ro_gui_window_keypress(wimp_key *key) for (unsigned int i = 0; i < SCALE_SNAP_TO_SIZE; i++) if (scale_snap_to[i] > - g->option.scale) { + g->bw->scale) { scale = scale_snap_to[i]; break; } @@ -2540,12 +2513,12 @@ bool ro_gui_window_keypress(wimp_key *key) scale = scale_snap_to[0]; if (scale > scale_snap_to[SCALE_SNAP_TO_SIZE - 1]) scale = scale_snap_to[SCALE_SNAP_TO_SIZE - 1]; - if (g->option.scale != scale) { + if (g->bw->scale != scale) { browser_window_set_scale(g->bw, scale, true); // g->reformat_pending = true; // if ((content) && (content->type != CONTENT_HTML)) // browser_window_update(g->bw, false); -// gui_reformat_pending = true; +// browser_reformat_pending = true; } return true; @@ -2712,8 +2685,8 @@ bool ro_gui_window_to_window_pos(struct gui_window *g, int x, int y, os_coord *p warn_user("WimpError", error->errmess); return false; } - pos->x = (x - (state.visible.x0 - state.xscroll)) / 2 / g->option.scale; - pos->y = ((state.visible.y1 - state.yscroll) - y) / 2 / g->option.scale; + pos->x = (x - (state.visible.x0 - state.xscroll)) / 2 / g->bw->scale; + pos->y = ((state.visible.y1 - state.yscroll) - y) / 2 / g->bw->scale; return true; } @@ -2743,8 +2716,8 @@ bool ro_gui_window_to_screen_pos(struct gui_window *g, int x, int y, os_coord *p warn_user("WimpError", error->errmess); return false; } - pos->x = (x * 2 * g->option.scale) + (state.visible.x0 - state.xscroll); - pos->y = (state.visible.y1 - state.yscroll) - (y * 2 * g->option.scale); + pos->x = (x * 2 * g->bw->scale) + (state.visible.x0 - state.xscroll); + pos->y = (state.visible.y1 - state.yscroll) - (y * 2 * g->bw->scale); return true; } @@ -2896,14 +2869,14 @@ void ro_gui_window_process_reformats(void) { struct gui_window *g; - gui_reformat_pending = false; + browser_reformat_pending = false; for (g = window_list; g; g = g->next) { - if (!g->reformat_pending) + if (!g->bw->reformat_pending) continue; - g->reformat_pending = false; + g->bw->reformat_pending = false; browser_window_reformat(g->bw, - g->old_width / 2 / g->option.scale, - g->old_height / 2 / g->option.scale); + g->old_width / 2, + g->old_height / 2); } } @@ -2932,7 +2905,7 @@ void ro_gui_window_clone_options(struct browser_window *new_bw, /* Clone the basic options */ if (!old_gui) { - new_gui->option.scale = ((float)option_scale) / 100; + new_bw->scale = ((float)option_scale) / 100; new_gui->option.background_images = option_background_images; new_gui->option.buffer_animations = option_buffer_animations; new_gui->option.buffer_everything = option_buffer_everything; @@ -2975,7 +2948,7 @@ void ro_gui_window_default_options(struct browser_window *bw) { /* Save the basic options */ - option_scale = gui->option.scale * 100; + option_scale = bw->scale * 100; option_buffer_animations = gui->option.buffer_animations; option_buffer_everything = gui->option.buffer_everything; |