Add named scroll offset values for page up, page down, top and bottom.

svn path=/trunk/netsurf/; revision=13293
This commit is contained in:
Michael Drake 2011-12-18 15:36:38 +00:00
parent a40b9fbecd
commit 877988a7ef
2 changed files with 32 additions and 0 deletions

View File

@ -461,6 +461,30 @@ bool scrollbar_scroll(struct scrollbar *s, int change)
/* zero scroll step, or unscrollable */
return false;
/* Convert named change values to appropriate pixel offset value */
switch (change) {
case SCROLL_TOP:
change = -s->full_size;
break;
case SCROLL_PAGE_UP:
change = -s->visible_size;
break;
case SCROLL_PAGE_DOWN:
change = s->visible_size;
break;
case SCROLL_BOTTOM:
change = s->full_size;
break;
default:
/* Change value is already a pixel offset */
break;
}
/* Get new offset */
if (s->offset + change > s->full_size - s->visible_size)
s->offset = s->full_size - s->visible_size;
else if (s->offset + change < 0)
@ -472,6 +496,7 @@ bool scrollbar_scroll(struct scrollbar *s, int change)
/* Nothing happened */
return false;
/* Update scrollbar */
well_length = s->length - 2 * SCROLLBAR_WIDTH;
s->bar_pos = (s->full_size < 1) ? 0 :
((well_length * s->offset) / s->full_size);

View File

@ -24,11 +24,18 @@
#define _NETSURF_DESKTOP_SCROLLBAR_H_
#include <stdbool.h>
#include <limits.h>
#include "desktop/browser.h"
#define SCROLLBAR_WIDTH 16
/* Region dependent values for scrollbar_scroll function */
#define SCROLL_TOP INT_MIN
#define SCROLL_PAGE_UP INT_MIN + 1
#define SCROLL_PAGE_DOWN INT_MAX - 1
#define SCROLL_BOTTOM INT_MAX
struct scrollbar;
typedef enum {