[project @ 2004-06-25 23:10:46 by jmb]

background-attachment: fixed; support. Disabled for the moment due to redraw issues.

svn path=/import/netsurf/; revision=1012
This commit is contained in:
John Mark Bell 2004-06-25 23:10:46 +00:00
parent da1ad11a35
commit 002a353042

View File

@ -13,6 +13,7 @@
#include "oslib/draw.h" #include "oslib/draw.h"
#include "oslib/font.h" #include "oslib/font.h"
#include "oslib/os.h" #include "oslib/os.h"
#include "oslib/wimp.h"
#include "swis.h" #include "swis.h"
#include "netsurf/utils/config.h" #include "netsurf/utils/config.h"
#include "netsurf/css/css.h" #include "netsurf/css/css.h"
@ -22,6 +23,7 @@
#include "netsurf/riscos/gui.h" #include "netsurf/riscos/gui.h"
#include "netsurf/riscos/options.h" #include "netsurf/riscos/options.h"
#include "netsurf/riscos/tinct.h" #include "netsurf/riscos/tinct.h"
#include "netsurf/riscos/toolbar.h"
#include "netsurf/riscos/wimp.h" #include "netsurf/riscos/wimp.h"
#include "netsurf/utils/log.h" #include "netsurf/utils/log.h"
#include "netsurf/utils/messages.h" #include "netsurf/utils/messages.h"
@ -603,11 +605,27 @@ void html_redraw_background(long xi, long yi, int width, int height,
os_coord image_size; os_coord image_size;
float multiplier; float multiplier;
bool fixed = false; bool fixed = false;
wimp_window_state state;
if (box->background == 0) return; if (box->background == 0) return;
/* Set the plot options */ state.w = 0;
if (ro_gui_current_redraw_gui) { if (ro_gui_current_redraw_gui) {
/* read state of window we're drawing in */
os_error *error;
state.w = ro_gui_current_redraw_gui->window;
error = xwimp_get_window_state(&state);
if (error) {
/* not fatal: fixed backgrounds will scroll. */
LOG(("xwimp_get_window_state: 0x%x: %s",
error->errnum, error->errmess));
/* invalidate state.w */
state.w = 0;
}
/* Set the plot options */
if (!ro_gui_current_redraw_gui->option_background_images) return; if (!ro_gui_current_redraw_gui->option_background_images) return;
tinct_options = (ro_gui_current_redraw_gui->option_filter_sprites?tinct_BILINEAR_FILTER:0) | tinct_options = (ro_gui_current_redraw_gui->option_filter_sprites?tinct_BILINEAR_FILTER:0) |
(ro_gui_current_redraw_gui->option_dither_sprites?tinct_DITHER:0); (ro_gui_current_redraw_gui->option_dither_sprites?tinct_DITHER:0);
@ -624,7 +642,9 @@ void html_redraw_background(long xi, long yi, int width, int height,
/* handle background-attachment */ /* handle background-attachment */
switch (box->style->background_attachment) { switch (box->style->background_attachment) {
case CSS_BACKGROUND_ATTACHMENT_FIXED: case CSS_BACKGROUND_ATTACHMENT_FIXED:
fixed = true; /* uncomment this to enable fixed backgrounds */
/*if (state.w != 0)
fixed = true;*/
break; break;
case CSS_BACKGROUND_ATTACHMENT_SCROLL: case CSS_BACKGROUND_ATTACHMENT_SCROLL:
break; break;
@ -649,43 +669,73 @@ void html_redraw_background(long xi, long yi, int width, int height,
break; break;
} }
/* handle window offset */ /* fixed background */
x = xi;
if (fixed) { if (fixed) {
/**\todo fixed background attachments */ int toolbar_height = 0;
x -= 0;
/* get toolbar height */
if (ro_gui_current_redraw_gui &&
ro_gui_current_redraw_gui->data.browser.toolbar)
toolbar_height = ro_gui_current_redraw_gui->data.browser.toolbar->height;
/* top left of viewport, taking account of toolbar height */
x = state.visible.x0;
y = state.visible.y1 - toolbar_height;
/* handle background-position */
switch (box->style->background_position.horz.pos) {
case CSS_BACKGROUND_POSITION_PERCENT:
multiplier = box->style->background_position.horz.value.percent / 100;
x += ((state.visible.x1 - state.visible.x0) - (image_size.x * 2)) * multiplier;
break;
case CSS_BACKGROUND_POSITION_LENGTH:
x += 2 * len(&box->style->background_position.horz.value.length, box->style) * scale;
break;
default:
break;
}
switch (box->style->background_position.vert.pos) {
case CSS_BACKGROUND_POSITION_PERCENT:
multiplier = box->style->background_position.vert.value.percent / 100;
y -= ((state.visible.y1 - state.visible.y0 - toolbar_height) - (image_size.y * 2)) * multiplier;
break;
case CSS_BACKGROUND_POSITION_LENGTH:
y -= 2 * len(&box->style->background_position.vert.value.length, box->style) * scale;
break;
default:
break;
}
} }
else {
/* handle window offset */
x = xi;
y = yi;
/* handle window offset */ /* handle background-position */
y = yi; switch (box->style->background_position.horz.pos) {
if (fixed) { case CSS_BACKGROUND_POSITION_PERCENT:
/**\todo fixed background attachments */ multiplier = box->style->background_position.horz.value.percent / 100;
y -= 0; x += 2 * (box->width + box->padding[LEFT] + box->padding[RIGHT] - image_size.x) * multiplier;
} break;
case CSS_BACKGROUND_POSITION_LENGTH:
x += 2 * len(&box->style->background_position.horz.value.length, box->style) * scale;
break;
default:
break;
}
/* handle background-position */ switch (box->style->background_position.vert.pos) {
switch (box->style->background_position.horz.pos) { case CSS_BACKGROUND_POSITION_PERCENT:
case CSS_BACKGROUND_POSITION_PERCENT: multiplier = box->style->background_position.vert.value.percent / 100;
multiplier = box->style->background_position.horz.value.percent / 100; y -= 2 * (box->height + box->padding[TOP] + box->padding[BOTTOM] - image_size.y) * multiplier;
x += 2 * (box->width + box->padding[LEFT] + box->padding[RIGHT] - image_size.x) * multiplier; break;
break; case CSS_BACKGROUND_POSITION_LENGTH:
case CSS_BACKGROUND_POSITION_LENGTH: y -= 2 * len(&box->style->background_position.vert.value.length, box->style) * scale;
x += 2 * len(&box->style->background_position.horz.value.length, box->style) * scale; break;
break; default:
default: break;
break; }
}
switch (box->style->background_position.vert.pos) {
case CSS_BACKGROUND_POSITION_PERCENT:
multiplier = box->style->background_position.vert.value.percent / 100;
y -= 2 * (box->height + box->padding[TOP] + box->padding[BOTTOM] - image_size.y) * multiplier;
break;
case CSS_BACKGROUND_POSITION_LENGTH:
y -= 2 * len(&box->style->background_position.vert.value.length, box->style) * scale;
break;
default:
break;
} }
// LOG(("Body [%ld, %ld], Image: [%ld, %ld], Flags: %x", xi, yi, x, y, tinct_options)); // LOG(("Body [%ld, %ld], Image: [%ld, %ld], Flags: %x", xi, yi, x, y, tinct_options));