NetSurf
|
implementation of scrollbar widget. More...
#include <stdbool.h>
#include <stdlib.h>
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/utils.h"
#include "utils/nscolour.h"
#include "utils/nsoption.h"
#include "netsurf/browser_window.h"
#include "netsurf/mouse.h"
#include "netsurf/plotters.h"
#include "desktop/system_colour.h"
#include "desktop/scrollbar.h"
Go to the source code of this file.
Data Structures | |
struct | scrollbar |
Scrollbar context. 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... | |
static nserror | scrollbar_rectangle (const struct redraw_context *ctx, struct rect *area, colour c, bool inset) |
Draw an outline rectangle common to several scrollbar elements. 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... | |
static void | scrollbar_drag_start_internal (struct scrollbar *s, int x, int y, bool content_drag, bool pair) |
Internal procedure used for starting a drag scroll for a 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... | |
implementation of scrollbar widget.
Definition in file scrollbar.c.
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.
horizontal | true = horizontal scrollbar, false = vertical |
length | length of scrollbar widget |
full_size | length of contained scrollable area |
visible_size | length of visible part of scrollable area |
client_data | data for the client callback |
client_callback | client callback for scrollbar events |
s | updated to point at the newly created scrollbar |
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().
void scrollbar_destroy | ( | struct scrollbar * | s | ) |
Destroy a scrollbar.
s | the 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().
|
static |
Internal procedure used for starting a drag scroll for a scrollbar.
s | the scrollbar to start the drag for |
x | the X coordinate of the drag start |
y | the Y coordinate of the drag start |
content_drag | whether this should be a reverse drag (used when the user drags the content area, rather than the scrollbar) |
pair | whether the drag is a '2D' scroll |
Definition at line 712 of file scrollbar.c.
References scrollbar::bar_pos, 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::offset, scrollbar::pair, scrollbar::pair_drag, and SCROLLBAR_MSG_SCROLL_START.
Referenced by scrollbar_mouse_action(), and scrollbar_start_content_drag().
void * scrollbar_get_data | ( | struct scrollbar * | s | ) |
Get the scrollbar's client data.
s | the scrollbar to get the client data from |
Definition at line 1004 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().
int scrollbar_get_offset | ( | struct scrollbar * | s | ) |
Get the current scroll offset to the visible part of the full area.
s | the scrollbar to get the scroll offset value from |
Definition at line 628 of file scrollbar.c.
References scrollbar::offset.
Referenced by box_at_point(), box_coords(), box_nearest_text_box(), browser_window__get_contextual_content(), browser_window_drop_file_at_point_internal(), browser_window_get_position(), browser_window_mouse_click_internal(), browser_window_mouse_drag_end(), browser_window_mouse_track_internal(), browser_window_page_drag_start(), browser_window_redraw(), browser_window_scroll_at_point_internal(), browser_window_scroll_callback(), browser_window_update(), form_redraw_select_menu(), form_select_menu_clicked(), get_mouse_action_node(), html_redraw_box(), html_redraw_box_children(), textarea_scroll_visible(), and textarea_scrollbar_callback().
bool scrollbar_is_horizontal | ( | struct scrollbar * | s | ) |
Check orientation of the scrollbar.
s | the scrollbar to check the orientation of |
Definition at line 695 of file scrollbar.c.
References scrollbar::horizontal.
Referenced by browser_window_scroll_callback(), html_overflow_scroll_drag_end(), and mouse_action_drag_scrollbar().
Connect a horizontal and a vertical scrollbar into a pair so that they co-operate during 2D drags.
horizontal | the scrollbar used for horizontal scrolling |
vertical | the scrollbar used for vertical scrolling |
Definition at line 990 of file scrollbar.c.
References scrollbar::horizontal, and scrollbar::pair.
Referenced by box_handle_scrollbars(), browser_window_handle_scrollbars(), and textarea_reflow_multiline().
scrollbar_mouse_status scrollbar_mouse_action | ( | struct scrollbar * | s, |
browser_mouse_state | mouse, | ||
int | x, | ||
int | y | ||
) |
Handle mouse actions other then drag ends.
s | the scrollbar which gets the mouse action |
mouse | mouse state |
x | X coordinate of the mouse |
y | Y coordinate of the mouse |
Definition at line 769 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().
void scrollbar_mouse_drag_end | ( | struct scrollbar * | s, |
browser_mouse_state | mouse, | ||
int | x, | ||
int | y | ||
) |
Handle end of mouse drags.
s | the scrollbar for which the drag ends |
mouse | mouse state |
x | X coordinate of the mouse |
y | Y coordinate of the mouse |
Definition at line 933 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().
const char * scrollbar_mouse_status_to_message | ( | scrollbar_mouse_status | status | ) |
Get a status bar message from a scrollbar mouse input status.
status | Status to convert to message |
Definition at line 889 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().
|
inlinestatic |
Draw an outline rectangle common to several scrollbar elements.
ctx | current redraw context |
area | the area of the scrollbar |
c | base colour of the outline, the other colours are created by lightening or darkening this one |
inset | true for inset outline, false for an outset one |
Definition at line 158 of file scrollbar.c.
References blend_colour, darken_colour, lighten_colour, line(), plotter_table::line, NSERROR_OK, redraw_context::plot, PLOT_OP_TYPE_SOLID, plot_style_int_to_fixed, plot_style_s::stroke_colour, plot_style_s::stroke_type, rect::x0, rect::x1, rect::y0, and rect::y1.
Referenced by 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.
s | the scrollbar to be redrawn |
x | the X coordinate to draw the scrollbar at |
y | the Y coordinate to draw the scrollbar at |
clip | the clipping rectangle |
scale | scale for the redraw |
ctx | current redraw context |
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().
bool scrollbar_scroll | ( | struct scrollbar * | s, |
int | change | ||
) |
Scroll the scrollbar by given amount.
s | the scrollbar to be scrolled |
change | the change in scroll offset required (in px) |
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().
void scrollbar_set | ( | struct scrollbar * | s, |
int | value, | ||
bool | bar_pos | ||
) |
Set the scroll value of the scrollbar.
s | the scrollbar to have the value set |
value | the new value to be set |
bar_pos | true 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().
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.
s | the 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 640 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().
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.
s | one of the the scrollbars owned by the dragged content |
x | X coordinate of mouse during drag start |
y | Y coordinate of mouse during drag start |
Definition at line 981 of file scrollbar.c.
References scrollbar_drag_start_internal().
Referenced by html_box_drag_start().