NetSurf
Data Structures | Macros | Typedefs | Enumerations | Functions
scrollbar.h File Reference

Scrollbar widget interface. More...

#include <stdbool.h>
#include <limits.h>
Include dependency graph for scrollbar.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  scrollbar_msg_data
 scrollbar message context data More...
 

Macros

#define SCROLLBAR_WIDTH   16
 
#define SCROLL_TOP   INT_MIN
 
#define SCROLL_PAGE_UP   (INT_MIN + 1)
 
#define SCROLL_PAGE_DOWN   (INT_MAX - 1)
 
#define SCROLL_BOTTOM   INT_MAX
 

Typedefs

typedef void(* scrollbar_client_callback) (void *client_data, struct scrollbar_msg_data *scrollbar_data)
 Client callback for the scrollbar. More...
 

Enumerations

enum  scrollbar_msg { SCROLLBAR_MSG_MOVED , SCROLLBAR_MSG_SCROLL_START , SCROLLBAR_MSG_SCROLL_FINISHED }
 scrollbar message types More...
 
enum  scrollbar_mouse_status {
  SCROLLBAR_MOUSE_NONE = 0 , SCROLLBAR_MOUSE_USED = (1 << 0) , SCROLLBAR_MOUSE_BOTH = (1 << 1) , SCROLLBAR_MOUSE_UP = (1 << 2) ,
  SCROLLBAR_MOUSE_PUP = (1 << 3) , SCROLLBAR_MOUSE_VRT = (1 << 4) , SCROLLBAR_MOUSE_PDWN = (1 << 5) , SCROLLBAR_MOUSE_DWN = (1 << 6) ,
  SCROLLBAR_MOUSE_LFT = (1 << 7) , SCROLLBAR_MOUSE_PLFT = (1 << 8) , SCROLLBAR_MOUSE_HRZ = (1 << 9) , SCROLLBAR_MOUSE_PRGT = (1 << 10) ,
  SCROLLBAR_MOUSE_RGT = (1 << 11)
}
 Scrollbar mouse input status flags. More...
 

Functions

nserror scrollbar_create (bool horizontal, int length, int full_size, int visible_size, void *client_data, scrollbar_client_callback client_callback, struct scrollbar **s)
 Create a scrollbar. More...
 
void scrollbar_destroy (struct scrollbar *s)
 Destroy a scrollbar. More...
 
nserror scrollbar_redraw (struct scrollbar *s, int x, int y, const struct rect *clip, float scale, const struct redraw_context *ctx)
 Redraw a part of the scrollbar. More...
 
void scrollbar_set (struct scrollbar *s, int value, bool bar_pos)
 Set the scroll value of the scrollbar. More...
 
bool scrollbar_scroll (struct scrollbar *s, int change)
 Scroll the scrollbar by given amount. More...
 
int scrollbar_get_offset (struct scrollbar *s)
 Get the current scroll offset to the visible part of the full area. More...
 
void scrollbar_set_extents (struct scrollbar *s, int length, int visible_size, int full_size)
 Set the length of the scrollbar widget, the size of the visible area, and the size of the full area. More...
 
bool scrollbar_is_horizontal (struct scrollbar *s)
 Check orientation of the scrollbar. More...
 
scrollbar_mouse_status scrollbar_mouse_action (struct scrollbar *s, browser_mouse_state mouse, int x, int y)
 Handle mouse actions other then drag ends. More...
 
const char * scrollbar_mouse_status_to_message (scrollbar_mouse_status status)
 Get a status bar message from a scrollbar mouse input status. More...
 
void scrollbar_mouse_drag_end (struct scrollbar *s, browser_mouse_state mouse, int x, int y)
 Handle end of mouse drags. More...
 
void scrollbar_start_content_drag (struct scrollbar *s, int x, int y)
 Called when the content is being dragged to the scrollbars have to adjust. More...
 
void scrollbar_make_pair (struct scrollbar *horizontal, struct scrollbar *vertical)
 Connect a horizontal and a vertical scrollbar into a pair so that they co-operate during 2D drags. More...
 
void * scrollbar_get_data (struct scrollbar *s)
 Get the scrollbar's client data. More...
 

Detailed Description

Scrollbar widget interface.

Scrollbar widgets used in frames code, not for frontend use

Definition in file scrollbar.h.

Macro Definition Documentation

◆ SCROLL_BOTTOM

#define SCROLL_BOTTOM   INT_MAX

Definition at line 38 of file scrollbar.h.

◆ SCROLL_PAGE_DOWN

#define SCROLL_PAGE_DOWN   (INT_MAX - 1)

Definition at line 37 of file scrollbar.h.

◆ SCROLL_PAGE_UP

#define SCROLL_PAGE_UP   (INT_MIN + 1)

Definition at line 36 of file scrollbar.h.

◆ SCROLL_TOP

#define SCROLL_TOP   INT_MIN

Definition at line 35 of file scrollbar.h.

◆ SCROLLBAR_WIDTH

#define SCROLLBAR_WIDTH   16

Definition at line 32 of file scrollbar.h.

Typedef Documentation

◆ scrollbar_client_callback

typedef void(* scrollbar_client_callback) (void *client_data, struct scrollbar_msg_data *scrollbar_data)

Client callback for the scrollbar.

Parameters
client_datauser data passed at scroll creation
scrollbar_datascrollbar message data

Definition at line 93 of file scrollbar.h.

Enumeration Type Documentation

◆ scrollbar_mouse_status

Scrollbar mouse input status flags.

Enumerator
SCROLLBAR_MOUSE_NONE 

Not relevant.

SCROLLBAR_MOUSE_USED 

Took action with input.

SCROLLBAR_MOUSE_BOTH 

Scrolling both bars.

SCROLLBAR_MOUSE_UP 

Hover: scroll up.

SCROLLBAR_MOUSE_PUP 

Hover: scroll page up.

SCROLLBAR_MOUSE_VRT 

Hover: vert.

drag bar

SCROLLBAR_MOUSE_PDWN 

Hover: scroll page down.

SCROLLBAR_MOUSE_DWN 

Hover: scroll down.

SCROLLBAR_MOUSE_LFT 

Hover: scroll left.

SCROLLBAR_MOUSE_PLFT 

Hover: scroll page left.

SCROLLBAR_MOUSE_HRZ 

Hover: horiz.

drag bar

SCROLLBAR_MOUSE_PRGT 

Hover: scroll page right.

SCROLLBAR_MOUSE_RGT 

Hover: scroll right.

Definition at line 70 of file scrollbar.h.

◆ scrollbar_msg

scrollbar message types

Enumerator
SCROLLBAR_MSG_MOVED 

the scroll value has changed

SCROLLBAR_MSG_SCROLL_START 

a scrollbar drag has started, all mouse events should be passed to the scrollbar regardless of the coordinates

SCROLLBAR_MSG_SCROLL_FINISHED 

cancel a scrollbar drag

Definition at line 46 of file scrollbar.h.

Function Documentation

◆ scrollbar_create()

nserror scrollbar_create ( bool  horizontal,
int  length,
int  full_size,
int  visible_size,
void *  client_data,
scrollbar_client_callback  client_callback,
struct scrollbar **  s 
)

Create a scrollbar.

Parameters
horizontaltrue = horizontal scrollbar, false = vertical
lengthlength of scrollbar widget
full_sizelength of contained scrollable area
visible_sizelength of visible part of scrollable area
client_datadata for the client callback
client_callbackclient callback for scrollbar events
supdated to point at the newly created scrollbar
Returns
NSERROR_OK and s updated if scrollbar has been created succesfully or eror code and s set to NULL on faliure;

Definition at line 93 of file scrollbar.c.

References scrollbar::bar_len, scrollbar::bar_pos, scrollbar::client_callback, scrollbar::client_data, scrollbar::drag_content, scrollbar::dragging, scrollbar::full_size, scrollbar::horizontal, scrollbar::length, NSERROR_NOMEM, NSERROR_OK, scrollbar::offset, scrollbar::pair, scrollbar::pair_drag, SCROLLBAR_WIDTH, and scrollbar::visible_size.

Referenced by box_handle_scrollbars(), browser_window_handle_scrollbars(), form_open_select_menu(), and textarea_reflow_multiline().

Here is the caller graph for this function:

◆ scrollbar_destroy()

void scrollbar_destroy ( struct scrollbar s)

Destroy a scrollbar.

Parameters
sthe scrollbar to be destroyed

Definition at line 138 of file scrollbar.c.

References scrollbar::pair.

Referenced by box_free_box(), box_handle_scrollbars(), box_talloc_destructor(), browser_window_destroy_internal(), browser_window_handle_scrollbars(), form_free_select_menu(), textarea_destroy(), and textarea_reflow_multiline().

Here is the caller graph for this function:

◆ scrollbar_get_data()

void * scrollbar_get_data ( struct scrollbar s)

Get the scrollbar's client data.

Parameters
sthe scrollbar to get the client data from
Returns
client data

Definition at line 1003 of file scrollbar.c.

References scrollbar::client_data.

Referenced by box_handle_scrollbars(), box_talloc_destructor(), html_overflow_scroll_drag_end(), and mouse_action_drag_scrollbar().

Here is the caller graph for this function:

◆ scrollbar_get_offset()

int scrollbar_get_offset ( struct scrollbar s)

◆ scrollbar_is_horizontal()

bool scrollbar_is_horizontal ( struct scrollbar s)

Check orientation of the scrollbar.

Parameters
sthe scrollbar to check the orientation of
Returns
true for a horizontal scrollbar, else false (vertical)

Definition at line 694 of file scrollbar.c.

References scrollbar::horizontal.

Referenced by browser_window_scroll_callback(), html_overflow_scroll_drag_end(), and mouse_action_drag_scrollbar().

Here is the caller graph for this function:

◆ scrollbar_make_pair()

void scrollbar_make_pair ( struct scrollbar horizontal,
struct scrollbar vertical 
)

Connect a horizontal and a vertical scrollbar into a pair so that they co-operate during 2D drags.

Parameters
horizontalthe scrollbar used for horizontal scrolling
verticalthe scrollbar used for vertical scrolling

Definition at line 989 of file scrollbar.c.

References scrollbar::horizontal, and scrollbar::pair.

Referenced by box_handle_scrollbars(), browser_window_handle_scrollbars(), and textarea_reflow_multiline().

Here is the caller graph for this function:

◆ scrollbar_mouse_action()

scrollbar_mouse_status scrollbar_mouse_action ( struct scrollbar s,
browser_mouse_state  mouse,
int  x,
int  y 
)

Handle mouse actions other then drag ends.

Parameters
sthe scrollbar which gets the mouse action
mousemouse state
xX coordinate of the mouse
yY coordinate of the mouse
Returns
the scrollbar mouse status

Definition at line 768 of file scrollbar.c.

References scrollbar::bar_len, scrollbar::bar_pos, BROWSER_MOUSE_DRAG_1, BROWSER_MOUSE_DRAG_2, BROWSER_MOUSE_DRAG_ON, BROWSER_MOUSE_HOLDING_1, BROWSER_MOUSE_HOLDING_2, BROWSER_MOUSE_PRESS_1, BROWSER_MOUSE_PRESS_2, scrollbar::drag_content, scrollbar::drag_start_coord, scrollbar::drag_start_pos, scrollbar::dragging, scrollbar::horizontal, scrollbar::length, scrollbar::offset, scrollbar::pair, scrollbar::pair_drag, scrollbar_drag_start_internal(), scrollbar_mouse_action(), SCROLLBAR_MOUSE_BOTH, SCROLLBAR_MOUSE_DWN, SCROLLBAR_MOUSE_HRZ, SCROLLBAR_MOUSE_LFT, SCROLLBAR_MOUSE_NONE, SCROLLBAR_MOUSE_PDWN, SCROLLBAR_MOUSE_PLFT, SCROLLBAR_MOUSE_PRGT, SCROLLBAR_MOUSE_PUP, SCROLLBAR_MOUSE_RGT, SCROLLBAR_MOUSE_UP, SCROLLBAR_MOUSE_VRT, scrollbar_set(), SCROLLBAR_WIDTH, scrollbar_msg_data::x0, scrollbar_msg_data::x1, scrollbar_msg_data::y0, and scrollbar_msg_data::y1.

Referenced by browser_window_mouse_click_internal(), browser_window_mouse_track_internal(), form_select_mouse_action(), mouse_action_drag_none(), mouse_action_drag_scrollbar(), scrollbar_mouse_action(), and textarea_mouse_scrollbar_action().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scrollbar_mouse_drag_end()

void scrollbar_mouse_drag_end ( struct scrollbar s,
browser_mouse_state  mouse,
int  x,
int  y 
)

Handle end of mouse drags.

Parameters
sthe scrollbar for which the drag ends
mousemouse state
xX coordinate of the mouse
yY coordinate of the mouse

Definition at line 932 of file scrollbar.c.

References scrollbar::client_callback, scrollbar::client_data, scrollbar::drag_content, scrollbar::drag_start_coord, scrollbar::drag_start_pos, scrollbar::dragging, scrollbar::horizontal, scrollbar_msg_data::msg, scrollbar::pair, scrollbar::pair_drag, SCROLLBAR_MSG_SCROLL_FINISHED, and scrollbar_set().

Referenced by browser_window_mouse_drag_end(), form_select_mouse_drag_end(), html_overflow_scroll_drag_end(), and textarea_drag_end().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scrollbar_mouse_status_to_message()

const char * scrollbar_mouse_status_to_message ( scrollbar_mouse_status  status)

Get a status bar message from a scrollbar mouse input status.

Parameters
statusStatus to convert to message
Returns
Message for the status bar or NULL on failure

Definition at line 888 of file scrollbar.c.

References messages_get(), SCROLLBAR_MOUSE_DWN, SCROLLBAR_MOUSE_HRZ, SCROLLBAR_MOUSE_LFT, SCROLLBAR_MOUSE_PDWN, SCROLLBAR_MOUSE_PLFT, SCROLLBAR_MOUSE_PRGT, SCROLLBAR_MOUSE_PUP, SCROLLBAR_MOUSE_RGT, SCROLLBAR_MOUSE_UP, SCROLLBAR_MOUSE_USED, and SCROLLBAR_MOUSE_VRT.

Referenced by browser_window_mouse_click_internal(), browser_window_mouse_track_internal(), form_select_mouse_action(), gadget_mouse_action(), mouse_action_drag_none(), and mouse_action_drag_scrollbar().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scrollbar_redraw()

nserror scrollbar_redraw ( struct scrollbar s,
int  x,
int  y,
const struct rect clip,
float  scale,
const struct redraw_context ctx 
)

Redraw a part of the scrollbar.

Parameters
sthe scrollbar to be redrawn
xthe X coordinate to draw the scrollbar at
ythe Y coordinate to draw the scrollbar at
clipthe clipping rectangle
scalescale for the redraw
ctxcurrent redraw context
Returns
NSERROR_OK on success otherwise error code

Definition at line 239 of file scrollbar.c.

References scrollbar::bar_len, scrollbar::bar_pos, clip(), plot_style_s::fill_colour, plot_style_s::fill_type, scrollbar::horizontal, scrollbar::length, NSCOLOUR_BUTTON_BG, NSCOLOUR_BUTTON_FG, NSCOLOUR_SCROLL_WELL, nscolours, NSERROR_OK, redraw_context::plot, PLOT_OP_TYPE_SOLID, plotter_table::polygon, plotter_table::rectangle, scrollbar_rectangle(), SCROLLBAR_WIDTH, rect::x0, rect::x1, rect::y0, and rect::y1.

Referenced by browser_window_redraw(), form_redraw_select_menu(), html_redraw_box(), and textarea_redraw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scrollbar_scroll()

bool scrollbar_scroll ( struct scrollbar s,
int  change 
)

Scroll the scrollbar by given amount.

Parameters
sthe scrollbar to be scrolled
changethe change in scroll offset required (in px)
Returns
true iff the scrollbar was moved.

Definition at line 562 of file scrollbar.c.

References scrollbar::bar_pos, scrollbar::client_callback, scrollbar::client_data, scrollbar::full_size, scrollbar::length, scrollbar_msg_data::msg, scrollbar::offset, SCROLL_BOTTOM, SCROLL_PAGE_DOWN, SCROLL_PAGE_UP, SCROLL_TOP, SCROLLBAR_MSG_MOVED, SCROLLBAR_WIDTH, and scrollbar::visible_size.

Referenced by browser_window_scroll_at_point_internal(), html_scroll_at_point(), and textarea_scroll().

Here is the caller graph for this function:

◆ scrollbar_set()

void scrollbar_set ( struct scrollbar s,
int  value,
bool  bar_pos 
)

Set the scroll value of the scrollbar.

Parameters
sthe scrollbar to have the value set
valuethe new value to be set
bar_postrue if the value is for the scrollbar indication bar position, false if it is for the scrolled area offset

Definition at line 512 of file scrollbar.c.

References scrollbar::bar_len, scrollbar::bar_pos, scrollbar::client_callback, scrollbar::client_data, scrollbar::full_size, scrollbar::length, scrollbar_msg_data::msg, scrollbar::offset, SCROLLBAR_MSG_MOVED, SCROLLBAR_WIDTH, and scrollbar::visible_size.

Referenced by browser_window_set_scroll(), html_object_callback(), scrollbar_mouse_action(), scrollbar_mouse_drag_end(), and textarea_scroll_visible().

Here is the caller graph for this function:

◆ scrollbar_set_extents()

void scrollbar_set_extents ( struct scrollbar s,
int  length,
int  visible_size,
int  full_size 
)

Set the length of the scrollbar widget, the size of the visible area, and the size of the full area.

Parameters
sthe scrollbar to set the values for
length-1 or the new scrollbar widget length
visible_size-1 or the new size of the visible area
full_size-1 or the new size of the full contained area

Definition at line 639 of file scrollbar.c.

References scrollbar::bar_len, scrollbar::bar_pos, scrollbar::client_callback, scrollbar::client_data, scrollbar::full_size, scrollbar::length, scrollbar_msg_data::msg, scrollbar::offset, SCROLLBAR_MSG_MOVED, SCROLLBAR_WIDTH, and scrollbar::visible_size.

Referenced by box_handle_scrollbars(), browser_window_handle_scrollbars(), and textarea_reflow_multiline().

Here is the caller graph for this function:

◆ scrollbar_start_content_drag()

void scrollbar_start_content_drag ( struct scrollbar s,
int  x,
int  y 
)

Called when the content is being dragged to the scrollbars have to adjust.

If the content has both scrollbars, and scrollbar_make_pair has beed called before, only the one scroll which will receive further mouse events has to be passed.

Parameters
sone of the the scrollbars owned by the dragged content
xX coordinate of mouse during drag start
yY coordinate of mouse during drag start

Definition at line 980 of file scrollbar.c.

References scrollbar_drag_start_internal().

Referenced by html_box_drag_start().

Here is the call graph for this function:
Here is the caller graph for this function: