summaryrefslogtreecommitdiff
path: root/desktop/scrollbar.c
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2011-08-25 09:21:41 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2011-08-25 09:21:41 +0000
commitbbc06d64493bf30feed25a379905d8312e6ba2e8 (patch)
tree6439dcb3f32710206768833022ae6e6947696374 /desktop/scrollbar.c
parent65398660e51cd811f3be8fa0d592b34fc727973f (diff)
downloadnetsurf-bbc06d64493bf30feed25a379905d8312e6ba2e8.tar.gz
netsurf-bbc06d64493bf30feed25a379905d8312e6ba2e8.tar.bz2
When scrollbar extents are updated, scale current offset appropriately.
svn path=/trunk/netsurf/; revision=12667
Diffstat (limited to 'desktop/scrollbar.c')
-rw-r--r--desktop/scrollbar.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/desktop/scrollbar.c b/desktop/scrollbar.c
index 6dd9b0b15..b84ed08a1 100644
--- a/desktop/scrollbar.c
+++ b/desktop/scrollbar.c
@@ -458,8 +458,7 @@ void scrollbar_set_extents(struct scrollbar *s, int length,
int visible_size, int full_size)
{
int well_length;
-
- /* TODO: update offset appropriately */
+ int cur_excess = s->full_size - s->visible_size;
if (length != -1)
s->length = length;
@@ -468,6 +467,9 @@ void scrollbar_set_extents(struct scrollbar *s, int length,
if (full_size != -1)
s->full_size = full_size;
+ /* Update scroll offset (scaled in proportion with change in excess) */
+ s->offset = (s->full_size - s->visible_size) * s->offset / cur_excess;
+
well_length = s->length - 2 * SCROLLBAR_WIDTH;
s->bar_len = (well_length * s->visible_size) / s->full_size;