mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-23 04:26:50 +03:00
Fix 1553282.
svn path=/trunk/netsurf/; revision=2932
This commit is contained in:
parent
79554528ba
commit
02a8722cc6
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -60,6 +60,7 @@ struct browser_window *current_redraw_browser;
|
||||
/** fake content for <a> being saved as a link */
|
||||
struct content browser_window_href_content;
|
||||
|
||||
static void browser_window_set_scale_internal(struct browser_window *bw, float scale);
|
||||
static void browser_window_resize_frame(struct browser_window *bw, int x, int y);
|
||||
static bool browser_window_resolve_frame_dimension(struct browser_window *bw,
|
||||
struct browser_window *sibling, int x, int y, bool width, bool height);
|
||||
@ -405,7 +406,8 @@ void browser_window_recalculate_frameset(struct browser_window *bw) {
|
||||
|
||||
switch (window->frame_width.unit) {
|
||||
case FRAME_DIMENSION_PIXELS:
|
||||
widths[col][row] = window->frame_width.value;
|
||||
widths[col][row] = window->frame_width.value *
|
||||
gui_window_get_scale(window->window);
|
||||
if (window->border) {
|
||||
if (col != 0)
|
||||
widths[col][row] += 1;
|
||||
@ -466,7 +468,8 @@ void browser_window_recalculate_frameset(struct browser_window *bw) {
|
||||
|
||||
switch (window->frame_height.unit) {
|
||||
case FRAME_DIMENSION_PIXELS:
|
||||
heights[col][row] = window->frame_height.value;
|
||||
heights[col][row] = window->frame_height.value *
|
||||
gui_window_get_scale(window->window);
|
||||
if (window->border) {
|
||||
if (row != 0)
|
||||
heights[col][row] += 1;
|
||||
@ -542,6 +545,33 @@ void browser_window_recalculate_frameset(struct browser_window *bw) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the scale of a browser window
|
||||
*
|
||||
* \param bw The browser window to scale
|
||||
* \param scale The new scale
|
||||
* \param all Scale all windows in the tree (ie work up aswell as down)
|
||||
*/
|
||||
void browser_window_set_scale(struct browser_window *bw, float scale, bool all) {
|
||||
while (bw->parent && all)
|
||||
bw = bw->parent;
|
||||
browser_window_set_scale_internal(bw, scale);
|
||||
}
|
||||
|
||||
void browser_window_set_scale_internal(struct browser_window *bw, float scale) {
|
||||
int i;
|
||||
|
||||
gui_window_set_scale(bw->window, scale);
|
||||
|
||||
for (i = 0; i < (bw->cols * bw->rows); i++)
|
||||
browser_window_set_scale_internal(&bw->children[i], scale);
|
||||
for (i = 0; i < bw->iframe_count; i++)
|
||||
browser_window_set_scale_internal(&bw->iframes[i], scale);
|
||||
if (bw->children)
|
||||
browser_window_recalculate_frameset(bw);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Resize a browser window that is a frame.
|
||||
*
|
||||
|
@ -199,6 +199,7 @@ void browser_window_recalculate_iframes(struct browser_window *bw);
|
||||
void browser_window_create_frameset(struct browser_window *bw,
|
||||
struct content_html_frames *frameset);
|
||||
void browser_window_recalculate_frameset(struct browser_window *bw);
|
||||
void browser_window_set_scale(struct browser_window *bw, float scale, bool all);
|
||||
|
||||
void browser_window_mouse_click(struct browser_window *bw,
|
||||
browser_mouse_state mouse, int x, int y);
|
||||
|
@ -84,6 +84,8 @@ bool gui_window_box_scroll_start(struct gui_window *g,
|
||||
int x0, int y0, int x1, int y1);
|
||||
bool gui_window_frame_resize_start(struct gui_window *g);
|
||||
void gui_window_save_as_link(struct gui_window *g, struct content *c);
|
||||
float gui_window_get_scale(struct gui_window *g);
|
||||
void gui_window_set_scale(struct gui_window *g, float scale);
|
||||
|
||||
struct gui_download_window *gui_download_window_create(const char *url,
|
||||
const char *mime_type, struct fetch *fetch,
|
||||
|
@ -40,6 +40,13 @@
|
||||
#include "netsurf/utils/url.h"
|
||||
#include "netsurf/utils/utils.h"
|
||||
|
||||
#define ICON_ZOOM_VALUE 1
|
||||
#define ICON_ZOOM_DEC 2
|
||||
#define ICON_ZOOM_INC 3
|
||||
#define ICON_ZOOM_FRAMES 5
|
||||
#define ICON_ZOOM_CANCEL 7
|
||||
#define ICON_ZOOM_OK 8
|
||||
|
||||
/* The maximum number of persistent dialogues
|
||||
*/
|
||||
#define MAX_PERSISTENT 64
|
||||
@ -66,7 +73,6 @@ static struct {
|
||||
|
||||
|
||||
static bool ro_gui_dialog_openurl_apply(wimp_w w);
|
||||
static bool ro_gui_dialog_zoom_click(wimp_pointer *pointer);
|
||||
static bool ro_gui_dialog_zoom_apply(wimp_w w);
|
||||
|
||||
/**
|
||||
@ -193,8 +199,7 @@ void ro_gui_dialog_init(void)
|
||||
dialog_zoom = ro_gui_dialog_create("zoom");
|
||||
ro_gui_wimp_event_register_numeric_field(dialog_zoom, ICON_ZOOM_VALUE,
|
||||
ICON_ZOOM_INC, ICON_ZOOM_DEC, 10, 1600, 10, 0);
|
||||
ro_gui_wimp_event_register_mouse_click(dialog_zoom,
|
||||
ro_gui_dialog_zoom_click);
|
||||
ro_gui_wimp_event_register_checkbox(dialog_zoom, ICON_ZOOM_FRAMES);
|
||||
ro_gui_wimp_event_register_cancel(dialog_zoom, ICON_ZOOM_CANCEL);
|
||||
ro_gui_wimp_event_register_ok(dialog_zoom, ICON_ZOOM_OK,
|
||||
ro_gui_dialog_zoom_apply);
|
||||
@ -654,39 +659,13 @@ void ro_gui_save_options(void)
|
||||
options_write("<NetSurf$ChoicesSave>");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle clicks in the Scale view dialog.
|
||||
*/
|
||||
|
||||
bool ro_gui_dialog_zoom_click(wimp_pointer *pointer)
|
||||
{
|
||||
switch (pointer->i) {
|
||||
case ICON_ZOOM_75:
|
||||
ro_gui_set_icon_integer(dialog_zoom,
|
||||
ICON_ZOOM_VALUE, 75);
|
||||
return true;
|
||||
case ICON_ZOOM_100:
|
||||
ro_gui_set_icon_integer(dialog_zoom,
|
||||
ICON_ZOOM_VALUE, 100);
|
||||
return true;
|
||||
case ICON_ZOOM_150:
|
||||
ro_gui_set_icon_integer(dialog_zoom,
|
||||
ICON_ZOOM_VALUE, 150);
|
||||
return true;
|
||||
case ICON_ZOOM_200:
|
||||
ro_gui_set_icon_integer(dialog_zoom,
|
||||
ICON_ZOOM_VALUE, 200);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ro_gui_dialog_zoom_apply(wimp_w w) {
|
||||
unsigned int scale;
|
||||
bool all;
|
||||
|
||||
scale = atoi(ro_gui_get_icon_string(w, ICON_ZOOM_VALUE));
|
||||
ro_gui_window_set_scale(ro_gui_current_zoom_gui, scale * 0.01);
|
||||
all = ro_gui_get_icon_selected_state(w, ICON_ZOOM_FRAMES);
|
||||
browser_window_set_scale(ro_gui_current_zoom_gui->bw, scale * 0.01, all);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -700,7 +679,9 @@ void ro_gui_dialog_prepare_zoom(struct gui_window *g)
|
||||
char scale_buffer[8];
|
||||
sprintf(scale_buffer, "%.0f", g->option.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,
|
||||
!(g->bw->parent));
|
||||
ro_gui_current_zoom_gui = g;
|
||||
ro_gui_wimp_event_memorise(dialog_zoom);
|
||||
}
|
||||
|
11
riscos/gui.h
11
riscos/gui.h
@ -158,7 +158,6 @@ bool ro_gui_shift_pressed(void);
|
||||
bool ro_gui_ctrl_pressed(void);
|
||||
void ro_gui_window_scroll_end(struct gui_window *g, wimp_dragged *drag);
|
||||
void ro_gui_window_frame_resize_end(struct gui_window *g, wimp_dragged *drag);
|
||||
void ro_gui_window_set_scale(struct gui_window *g, float scale);
|
||||
void ro_gui_window_iconise(struct gui_window *g,
|
||||
wimp_full_message_window_info *wi);
|
||||
bool ro_gui_window_navigate_up(struct gui_window *g, const char *url);
|
||||
@ -222,16 +221,6 @@ bool ro_gui_theme_install_apply(wimp_w w);
|
||||
#define ICON_STATUS_RESIZE 0
|
||||
#define ICON_STATUS_TEXT 1
|
||||
|
||||
#define ICON_ZOOM_VALUE 1
|
||||
#define ICON_ZOOM_DEC 2
|
||||
#define ICON_ZOOM_INC 3
|
||||
#define ICON_ZOOM_75 5
|
||||
#define ICON_ZOOM_100 6
|
||||
#define ICON_ZOOM_150 7
|
||||
#define ICON_ZOOM_200 8
|
||||
#define ICON_ZOOM_CANCEL 9
|
||||
#define ICON_ZOOM_OK 10
|
||||
|
||||
#define ICON_SAVE_ICON 0
|
||||
#define ICON_SAVE_PATH 1
|
||||
#define ICON_SAVE_OK 2
|
||||
|
111
riscos/window.c
111
riscos/window.c
@ -1349,6 +1349,57 @@ bool gui_window_frame_resize_start(struct gui_window *g)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save the specified content as a link.
|
||||
*
|
||||
* \param g gui_window containing the content
|
||||
* \param c the content to save
|
||||
*/
|
||||
|
||||
void gui_window_save_as_link(struct gui_window *g, struct content *c)
|
||||
{
|
||||
if (!c)
|
||||
return;
|
||||
ro_gui_save_prepare(GUI_SAVE_LINK_URL, c);
|
||||
ro_gui_dialog_open_persistent(g->window, dialog_saveas, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
* \param scale scale value (1.0 == normal scale)
|
||||
*/
|
||||
|
||||
void gui_window_set_scale(struct gui_window *g, float scale)
|
||||
{
|
||||
struct content *c;
|
||||
|
||||
if (g->option.scale == scale)
|
||||
return;
|
||||
g->option.scale = scale;
|
||||
g->reformat_pending = true;
|
||||
c = g->bw->current_content;
|
||||
if ((c) && (c->type != CONTENT_HTML))
|
||||
browser_window_update(g->bw, false);
|
||||
gui_reformat_pending = true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Redraws the content for all windows.
|
||||
*/
|
||||
@ -1635,16 +1686,14 @@ void ro_gui_window_open(wimp_open *open)
|
||||
struct gui_window *g = (struct gui_window *)ro_gui_wimp_event_get_user_data(open->w);
|
||||
int width = open->visible.x1 - open->visible.x0;
|
||||
int height = open->visible.y1 - open->visible.y0;
|
||||
int toolbar_height = 0;
|
||||
int size, fheight, fwidth, toolbar_height = 0;
|
||||
bool no_vscroll, no_hscroll;
|
||||
float new_scale = 0;
|
||||
struct content *content;
|
||||
wimp_window_state state;
|
||||
os_error *error;
|
||||
int key_down = 0;
|
||||
wimp_w parent;
|
||||
bits linkage;
|
||||
int size;
|
||||
bool no_vscroll, no_hscroll;
|
||||
int fheight, fwidth;
|
||||
|
||||
if (open->next == wimp_TOP && g->iconise_icon >= 0) {
|
||||
/* window is no longer iconised, release its sprite number */
|
||||
@ -1759,15 +1808,13 @@ void ro_gui_window_open(wimp_open *open)
|
||||
/* change extent if necessary */
|
||||
if (g->old_width != width || g->old_height != height) {
|
||||
if (content) {
|
||||
if (g->old_width != width) {
|
||||
xosbyte1(osbyte_SCAN_KEYBOARD, 1 ^ 0x80, 0, &key_down);
|
||||
if (key_down)
|
||||
g->option.scale = (g->option.scale * width) / g->old_width;
|
||||
};
|
||||
/* 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;
|
||||
}
|
||||
|
||||
g->old_width = width;
|
||||
g->old_height = height;
|
||||
|
||||
@ -1797,11 +1844,17 @@ void ro_gui_window_open(wimp_open *open)
|
||||
return;
|
||||
}
|
||||
|
||||
/* update the toolbar */
|
||||
if (g->toolbar) {
|
||||
ro_gui_theme_process_toolbar(g->toolbar, -1);
|
||||
/* second resize updates to the new URL bar width */
|
||||
ro_gui_url_complete_resize(g, open);
|
||||
}
|
||||
|
||||
/* set the new scale from a ctrl-resize. this must be done at the end as
|
||||
* it may cause a frameset recalculation based on the new window size. */
|
||||
if (new_scale > 0)
|
||||
browser_window_set_scale(g->bw, new_scale, true);
|
||||
}
|
||||
|
||||
|
||||
@ -3062,22 +3115,6 @@ void ro_gui_window_scroll_end(struct gui_window *g, wimp_dragged *drag)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save the specified content as a link.
|
||||
*
|
||||
* \param g gui_window containing the content
|
||||
* \param c the content to save
|
||||
*/
|
||||
|
||||
void gui_window_save_as_link(struct gui_window *g, struct content *c)
|
||||
{
|
||||
if (!c)
|
||||
return;
|
||||
ro_gui_save_prepare(GUI_SAVE_LINK_URL, c);
|
||||
ro_gui_dialog_open_persistent(g->window, dialog_saveas, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Completes resizing of a browser frame
|
||||
*
|
||||
@ -3090,26 +3127,6 @@ void ro_gui_window_frame_resize_end(struct gui_window *g, wimp_dragged *drag)
|
||||
ro_gui_window_scroll_end(g, drag);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Alter the scale setting of a window
|
||||
*
|
||||
* \param g gui window
|
||||
* \param scale scale value (1.0 == normal scale)
|
||||
*/
|
||||
|
||||
void ro_gui_window_set_scale(struct gui_window *g, float scale)
|
||||
{
|
||||
struct content *c;
|
||||
g->option.scale = scale;
|
||||
g->reformat_pending = true;
|
||||
c = g->bw->current_content;
|
||||
if ((c) && (c->type != CONTENT_HTML))
|
||||
browser_window_update(g->bw, false);
|
||||
gui_reformat_pending = true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Import text file into window or its toolbar
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user