Scrollbar. More...
#include <scrollbar.hpp>
Public Member Functions | |
scrollbar (CVideo &video) | |
Create a scrollbar. More... | |
virtual void | hide (bool value=true) |
unsigned | get_position () const |
Determine where the scrollbar is. More... | |
unsigned | get_max_position () const |
void | set_position (unsigned pos) |
Manually update the scrollbar. More... | |
void | adjust_position (unsigned pos) |
Ensure the viewport contains the position. More... | |
void | move_position (int dep) |
Move the scrollbar. More... | |
void | set_shown_size (unsigned h) |
Set the relative size of the grip. More... | |
void | set_full_size (unsigned h) |
Set the relative size of the scrollbar. More... | |
void | set_scroll_rate (unsigned r) |
Set scroll rate. More... | |
bool | is_valid_height (int height) const |
Return true if the scrollbar has a valid size. More... | |
void | scroll_down () |
Scrolls down one step. More... | |
void | scroll_up () |
Scrolls up one step. More... | |
![]() | |
SDL_Rect const & | location () const |
virtual void | set_location (SDL_Rect const &rect) |
void | set_location (int x, int y) |
void | set_width (int w) |
void | set_height (int h) |
void | set_measurements (int w, int h) |
int | width () const |
int | height () const |
bool | focus (const SDL_Event *event) |
void | set_focus (bool focus) |
bool | hidden () const |
virtual void | enable (bool new_val=true) |
bool | enabled () const |
void | set_clip_rect (const SDL_Rect &rect) |
void | set_volatile (bool val=true) |
void | set_dirty (bool dirty=true) |
bool | dirty () const |
const std::string & | id () const |
void | set_id (const std::string &id) |
void | set_help_string (const std::string &str) |
void | set_tooltip_string (const std::string &str) |
virtual void | process_help_string (int mousex, int mousey) |
virtual void | process_tooltip_string (int mousex, int mousey) |
![]() | |
virtual bool | requires_event_focus (const SDL_Event *=nullptr) const |
virtual void | join () |
virtual void | join (context &c) |
virtual void | join_same (sdl_handler *parent) |
virtual void | leave () |
virtual void | join_global () |
virtual void | leave_global () |
Protected Member Functions | |
virtual sdl_handler_vector | handler_members () |
virtual void | update_location (SDL_Rect const &rect) |
virtual void | handle_event (const SDL_Event &event) |
virtual void | process_event () |
virtual void | draw_contents () |
![]() | |
widget (widget const &o) | |
widget (CVideo &video, const bool auto_join=true) | |
virtual | ~widget () |
void | bg_register (SDL_Rect const &rect) |
void | bg_restore () const |
void | bg_restore (SDL_Rect const &rect) const |
void | bg_update () |
void | bg_cancel () |
CVideo & | video () const |
virtual void | draw () |
const SDL_Rect * | clip_rect () const |
virtual sdl_handler_vector | member_handlers () |
virtual void | handle_window_event (SDL_Event const &event) |
bool | mouse_locked () const |
void | aquire_mouse_lock () |
void | free_mouse_lock () |
![]() | |
sdl_handler (const bool auto_join=true) | |
virtual | ~sdl_handler () |
Private Types | |
enum | STATE { UNINIT, NORMAL, ACTIVE, DRAGGED } |
Private Member Functions | |
SDL_Rect | grip_area () const |
SDL_Rect | groove_area () const |
Private Attributes | |
surface | mid_scaled_ |
surface | groove_scaled_ |
button | uparrow_ |
button | downarrow_ |
STATE | state_ |
int | minimum_grip_height_ |
int | mousey_on_grip_ |
unsigned int | grip_position_ |
unsigned int | grip_height_ |
unsigned int | full_height_ |
int | scroll_rate_ |
Additional Inherited Members | |
![]() | |
bool | focus_ |
Scrollbar.
Definition at line 28 of file scrollbar.hpp.
|
private |
Enumerator | |
---|---|
UNINIT | |
NORMAL | |
ACTIVE | |
DRAGGED |
Definition at line 94 of file scrollbar.hpp.
gui::scrollbar::scrollbar | ( | CVideo & | video | ) |
Create a scrollbar.
Definition at line 50 of file scrollbar.cpp.
References downarrow_, gui::button::enable(), image::get_image(), minimum_grip_height_, gui::widget::set_width(), and uparrow_.
void gui::scrollbar::adjust_position | ( | unsigned | pos | ) |
Ensure the viewport contains the position.
Definition at line 129 of file scrollbar.cpp.
References grip_height_, grip_position_, and set_position().
Referenced by gui::scrollarea::adjust_position().
|
protectedvirtual |
Reimplemented from gui::widget.
Definition at line 235 of file scrollbar.cpp.
References ACTIVE, surface::assign(), CVideo::blit_surface(), DRAGGED, image::get_image(), grip_area(), groove_area(), groove_scaled_, mid_scaled_, NORMAL, surface::null(), scale_surface(), state_, UNINIT, update_rect(), and gui::widget::video().
unsigned gui::scrollbar::get_max_position | ( | ) | const |
Definition at line 112 of file scrollbar.cpp.
References full_height_, and grip_height_.
Referenced by gui::scrollarea::get_max_position(), set_full_size(), and set_shown_size().
unsigned gui::scrollbar::get_position | ( | ) | const |
Determine where the scrollbar is.
returns | 0 if the scrollbar is at the top, |
returns | (full_size - shown_size) if it is at the bottom. |
Definition at line 107 of file scrollbar.cpp.
References grip_position_.
Referenced by gui::scrollarea::get_position(), gui::scrollarea::process_event(), set_full_size(), and set_shown_size().
|
private |
Definition at line 223 of file scrollbar.cpp.
References sdl::create_rect(), full_height_, grip_height_, grip_position_, groove_area(), and minimum_grip_height_.
Referenced by draw_contents(), and handle_event().
|
private |
Definition at line 209 of file scrollbar.cpp.
References downarrow_, gui::widget::height(), gui::widget::location(), and uparrow_.
Referenced by draw_contents(), grip_area(), and handle_event().
|
protectedvirtual |
Reimplemented from gui::widget.
Definition at line 322 of file scrollbar.cpp.
References ACTIVE, surface::assign(), DRAGGED, e, full_height_, grip_area(), grip_height_, groove_area(), gui::widget::handle_event(), gui::widget::hidden(), int(), mid_scaled_, gui::widget::mouse_locked(), mousey_on_grip_, move_position(), NORMAL, sdl::point_in_rect(), scroll_rate_, gui::widget::set_dirty(), and state_.
|
protectedvirtual |
Reimplemented from events::sdl_handler.
Definition at line 78 of file scrollbar.cpp.
References downarrow_, h, and uparrow_.
|
virtual |
Reimplemented from gui::widget.
Definition at line 100 of file scrollbar.cpp.
References downarrow_, gui::widget::hide(), and uparrow_.
Referenced by gui::scrollarea::hide(), gui::scrollarea::scrollarea(), and gui::scrollarea::update_location().
bool gui::scrollbar::is_valid_height | ( | int | height | ) | const |
Return true if the scrollbar has a valid size.
Definition at line 179 of file scrollbar.cpp.
References downarrow_, gui::widget::height(), and uparrow_.
Referenced by gui::scrollarea::has_scrollbar().
Move the scrollbar.
Definition at line 137 of file scrollbar.cpp.
References grip_position_, pos, and set_position().
Referenced by handle_event(), gui::scrollarea::move_position(), scroll_down(), and scroll_up().
|
protectedvirtual |
Reimplemented from events::sdl_handler.
Definition at line 200 of file scrollbar.cpp.
References downarrow_, gui::button::pressed(), scroll_down(), scroll_up(), and uparrow_.
void gui::scrollbar::scroll_down | ( | ) |
Scrolls down one step.
Definition at line 190 of file scrollbar.cpp.
References move_position(), and scroll_rate_.
Referenced by gui::scrollarea::handle_event(), and process_event().
void gui::scrollbar::scroll_up | ( | ) |
Scrolls up one step.
Definition at line 195 of file scrollbar.cpp.
References move_position(), and scroll_rate_.
Referenced by gui::scrollarea::handle_event(), and process_event().
void gui::scrollbar::set_full_size | ( | unsigned | h | ) |
Set the relative size of the scrollbar.
Definition at line 160 of file scrollbar.cpp.
References downarrow_, gui::button::enable(), full_height_, get_max_position(), get_position(), grip_height_, grip_position_, h, gui::widget::set_dirty(), set_position(), and set_shown_size().
Referenced by gui::scrollarea::set_full_size().
void gui::scrollbar::set_position | ( | unsigned | pos | ) |
Manually update the scrollbar.
Definition at line 117 of file scrollbar.cpp.
References downarrow_, gui::button::enable(), full_height_, grip_height_, grip_position_, pos, gui::widget::set_dirty(), and uparrow_.
Referenced by adjust_position(), move_position(), set_full_size(), gui::scrollarea::set_position(), and set_shown_size().
void gui::scrollbar::set_scroll_rate | ( | unsigned | r | ) |
Set scroll rate.
Definition at line 174 of file scrollbar.cpp.
References scroll_rate_.
Referenced by gui::scrollarea::set_scroll_rate().
void gui::scrollbar::set_shown_size | ( | unsigned | h | ) |
Set the relative size of the grip.
Definition at line 146 of file scrollbar.cpp.
References full_height_, get_max_position(), get_position(), grip_height_, grip_position_, h, gui::widget::set_dirty(), and set_position().
Referenced by set_full_size(), and gui::scrollarea::set_shown_size().
|
protectedvirtual |
Reimplemented from gui::widget.
Definition at line 86 of file scrollbar.cpp.
References downarrow_, gui::widget::height(), gui::widget::set_location(), uparrow_, and gui::widget::update_location().
|
private |
Definition at line 92 of file scrollbar.hpp.
Referenced by groove_area(), handler_members(), hide(), is_valid_height(), process_event(), scrollbar(), set_full_size(), set_position(), and update_location().
|
private |
Definition at line 99 of file scrollbar.hpp.
Referenced by get_max_position(), grip_area(), handle_event(), set_full_size(), set_position(), and set_shown_size().
|
private |
Definition at line 99 of file scrollbar.hpp.
Referenced by adjust_position(), get_max_position(), grip_area(), handle_event(), set_full_size(), set_position(), and set_shown_size().
|
private |
Definition at line 99 of file scrollbar.hpp.
Referenced by adjust_position(), get_position(), grip_area(), move_position(), set_full_size(), set_position(), and set_shown_size().
|
private |
Definition at line 90 of file scrollbar.hpp.
Referenced by draw_contents().
|
private |
Definition at line 90 of file scrollbar.hpp.
Referenced by draw_contents(), and handle_event().
|
private |
Definition at line 97 of file scrollbar.hpp.
Referenced by grip_area(), and scrollbar().
|
private |
Definition at line 97 of file scrollbar.hpp.
Referenced by handle_event().
|
private |
Definition at line 100 of file scrollbar.hpp.
Referenced by handle_event(), scroll_down(), scroll_up(), and set_scroll_rate().
|
private |
Definition at line 95 of file scrollbar.hpp.
Referenced by draw_contents(), and handle_event().
|
private |
Definition at line 92 of file scrollbar.hpp.
Referenced by groove_area(), handler_members(), hide(), is_valid_height(), process_event(), scrollbar(), set_position(), and update_location().