Added scale property to gui_window and use it.

This commit is contained in:
Ole Loots 2013-12-22 04:52:18 +01:00
parent feef0562b5
commit 289cd3a797
4 changed files with 28 additions and 20 deletions

View File

@ -379,35 +379,19 @@ static void __CDECL menu_reload(short item, short title, void *data)
static void __CDECL menu_inc_scale(short item, short title, void *data)
{
int width = 0, heigth = 0;
if(input_window == NULL)
return;
float now = plot_get_scale();
plot_set_scale(now+0.25);
LOG(("%s, scale: %f", __FUNCTION__, plot_get_scale()));
browser_window_reload(input_window->browser->bw, false);
gui_window_get_dimensions(input_window, &width, &heigth, true);
browser_window_reformat(input_window->browser->bw, false, width, heigth);
gui_window_set_scale(input_window, gui_window_get_scale(input_window)+0.25);
}
static void __CDECL menu_dec_scale(short item, short title, void *data)
{
int width = 0, heigth = 0;
if(input_window == NULL)
return;
float now = plot_get_scale();
if (now > 0.5) {
plot_set_scale(now-0.25);
}
LOG(("%s, scale: %f", __FUNCTION__, plot_get_scale()));
return;
browser_window_reload(input_window->browser->bw, false);
gui_window_get_dimensions(input_window, &width, &heigth, true);
browser_window_reformat(input_window->browser->bw, false, width, heigth);
gui_window_set_scale(input_window, gui_window_get_scale(input_window)-0.25);
}

View File

@ -207,6 +207,7 @@ gui_create_browser_window(struct browser_window *bw,
option_window_x, option_window_y,
option_window_width, option_window_height
};
gui_window_set_scale(gw, 1.0);
gui_window_set_url(gw, "");
gui_window_set_pointer(gw, BROWSER_POINTER_DEFAULT);
gui_set_input_gui_window(gw);
@ -345,6 +346,24 @@ void gui_window_set_status(struct gui_window *w, const char *text)
window_set_stauts(w->root, (char*)text);
}
float gui_window_get_scale(struct gui_window *gw)
{
return(gw->scale);
}
void gui_window_set_scale(struct gui_window *gw, float scale)
{
int width = 0, heigth = 0;
LOG(("scale: %f", scale));
gw->scale = MAX(scale, 0.25);
browser_window_reload(gw->browser->bw, false);
gui_window_get_dimensions(gw, &width, &heigth, true);
browser_window_reformat(gw->browser->bw, false, width, heigth);
}
void gui_window_redraw_window(struct gui_window *gw)
{
CMP_BROWSER b;

View File

@ -149,6 +149,7 @@ struct gui_window {
char * title;
char * url;
struct bitmap * icon;
float scale;
struct s_caret caret;
struct s_search_form_session *search;
struct gui_window *next, *prev;

View File

@ -835,13 +835,14 @@ static void window_redraw_content(ROOTWIN *rootwin, GRECT *content_area,
struct rect redraw_area;
GRECT content_area_rel;
float oldscale = 1.0;
//dbg_grect("browser redraw, content area", content_area);
//dbg_grect("browser redraw, content clip", clip);
plot_set_dimensions(content_area->g_x, content_area->g_y,
content_area->g_w, content_area->g_h);
oldscale = plot_set_scale(gui_window_get_scale(rootwin->active_gui_window));
/* first, we make the coords relative to the content area: */
content_area_rel.g_x = clip->g_x - content_area->g_x;
@ -872,6 +873,8 @@ static void window_redraw_content(ROOTWIN *rootwin, GRECT *content_area,
browser_window_redraw( bw, -(slid->x_pos*slid->x_unit_px),
-(slid->y_pos*slid->y_unit_px), &redraw_area, &rootwin_rdrw_ctx);
plot_set_scale(oldscale);
}
@ -1398,6 +1401,7 @@ static void on_redraw(ROOTWIN *rootwin, short msg[8])
//dbg_grect("on_redraw", &clip);
if(gemtk_wm_get_state(rootwin->win) & GEMTK_WM_STATUS_ICONIFIED) {
// TODO: remove asignment:
GRECT clip = {msg[4], msg[5], msg[6], msg[7]};
window_redraw_favicon(rootwin, NULL);
} else {