Scrollbar. More...
#include <scrollbar.hpp>
Public Member Functions | |
scrollbar () | |
Create a scrollbar. More... | |
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... | |
void | scroll_down () |
Scrolls down one step. More... | |
void | scroll_up () |
Scrolls up one step. More... | |
Public Member Functions inherited from gui::widget | |
const rect & | location () const |
virtual void | set_location (const SDL_Rect &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) |
virtual void | hide (bool value=true) |
bool | hidden () const |
virtual void | enable (bool new_val=true) |
bool | enabled () const |
void | set_clip_rect (const SDL_Rect &rect) |
void | queue_redraw () |
Indicate that the widget should be redrawn. More... | |
void | queue_redraw (const rect &) |
Indicate that a specific region of the screen should be redrawn. More... | |
void | set_dirty (bool dirty=true) |
bool | dirty () const |
const std::string & | id () const |
void | set_id (const std::string &id) |
void | set_tooltip_string (const std::string &str) |
virtual void | process_tooltip_string (int mousex, int mousey) override |
virtual void | layout () override |
Called by draw_manager to validate layout. More... | |
virtual bool | expose (const rect ®ion) override |
Called by draw_manager when it believes a redraw is necessary. More... | |
virtual rect | screen_location () override |
The current draw location of the display, on the screen. More... | |
Public Member Functions inherited from events::sdl_handler | |
virtual void | handle_window_event (const SDL_Event &) |
virtual void | process_event () |
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 () |
virtual bool | has_joined () |
virtual bool | has_joined_global () |
sdl_handler & | operator= (sdl_handler &&)=delete |
Moving would require two instances' context membership to be handled, it's simpler to delete these and require the two instances to be separately constructed / destructed. More... | |
sdl_handler (sdl_handler &&)=delete | |
Public Member Functions inherited from gui2::top_level_drawable | |
virtual void | update () |
Update state and any parameters that may effect layout, or any of the later stages. More... | |
virtual void | render () |
Perform any internal rendering necessary to prepare the drawable. More... | |
Protected Member Functions | |
virtual void | handle_event (const SDL_Event &event) |
virtual void | draw_contents () |
Protected Member Functions inherited from gui::widget | |
widget (const bool auto_join=true) | |
virtual | ~widget () |
virtual void | update_location (const SDL_Rect &) |
bool | mouse_locked () const |
void | aquire_mouse_lock () |
void | free_mouse_lock () |
Protected Member Functions inherited from events::sdl_handler | |
sdl_handler (const bool auto_join=true) | |
sdl_handler (const sdl_handler &) | |
sdl_handler & | operator= (const sdl_handler &) |
virtual | ~sdl_handler () |
virtual std::vector< sdl_handler * > | handler_members () |
Protected Member Functions inherited from gui2::top_level_drawable | |
top_level_drawable () | |
virtual | ~top_level_drawable () |
top_level_drawable (const top_level_drawable &) | |
top_level_drawable & | operator= (const top_level_drawable &) |
top_level_drawable (top_level_drawable &&) | |
top_level_drawable & | operator= (top_level_drawable &&) |
Private Types | |
enum | STATE { UNINIT , NORMAL , ACTIVE , DRAGGED } |
Private Member Functions | |
SDL_Rect | grip_area () const |
Private Attributes | |
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 | |
Protected Attributes inherited from gui::widget | |
bool | focus_ |
Scrollbar.
Definition at line 25 of file scrollbar.hpp.
|
private |
Enumerator | |
---|---|
UNINIT | |
NORMAL | |
ACTIVE | |
DRAGGED |
Definition at line 78 of file scrollbar.hpp.
gui::scrollbar::scrollbar | ( | ) |
Create a scrollbar.
Definition at line 46 of file scrollbar.cpp.
References image::get_size(), minimum_grip_height_, and gui::widget::set_width().
void gui::scrollbar::adjust_position | ( | unsigned | pos | ) |
Ensure the viewport contains the position.
Definition at line 85 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 156 of file scrollbar.cpp.
References ACTIVE, draw::blit(), c, DRAGGED, draw::fill(), image::get_texture(), grip_area(), texture::h(), gui::widget::location(), NORMAL, PLAIN_LOG, state_, UNINIT, and texture::w().
unsigned gui::scrollbar::get_max_position | ( | ) | const |
Definition at line 70 of file scrollbar.cpp.
References full_height_, and grip_height_.
Referenced by gui::scrollarea::get_max_position(), gui::scrollarea::handle_event(), 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 or (full_size - shown_size) if it is at the bottom. |
Definition at line 65 of file scrollbar.cpp.
References grip_position_.
Referenced by gui::scrollarea::get_position(), gui::scrollarea::handle_event(), gui::scrollarea::process_event(), set_full_size(), and set_shown_size().
|
private |
Definition at line 144 of file scrollbar.cpp.
References full_height_, grip_height_, grip_position_, h, gui::widget::location(), and minimum_grip_height_.
Referenced by draw_contents(), and handle_event().
|
protectedvirtual |
Reimplemented from gui::widget.
Definition at line 219 of file scrollbar.cpp.
References ACTIVE, rect::contains(), DRAGGED, e, full_height_, sdl::get_mouse_location(), grip_area(), grip_height_, gui::widget::handle_event(), gui::widget::hidden(), gui::widget::location(), gui::widget::mouse_locked(), mousey_on_grip_, move_position(), NORMAL, gui::widget::queue_redraw(), scroll_rate_, and state_.
void gui::scrollbar::move_position | ( | int | dep | ) |
Move the scrollbar.
Definition at line 93 of file scrollbar.cpp.
References grip_position_, and set_position().
Referenced by handle_event(), gui::scrollarea::move_position(), scroll_down(), and scroll_up().
void gui::scrollbar::scroll_down | ( | ) |
Scrolls down one step.
Definition at line 134 of file scrollbar.cpp.
References move_position(), and scroll_rate_.
Referenced by gui::scrollarea::handle_event().
void gui::scrollbar::scroll_up | ( | ) |
Scrolls up one step.
Definition at line 139 of file scrollbar.cpp.
References move_position(), and scroll_rate_.
Referenced by gui::scrollarea::handle_event().
void gui::scrollbar::set_full_size | ( | unsigned | h | ) |
Set the relative size of the scrollbar.
Definition at line 116 of file scrollbar.cpp.
References full_height_, get_max_position(), get_position(), grip_height_, grip_position_, h, gui::widget::queue_redraw(), 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 75 of file scrollbar.cpp.
References full_height_, grip_height_, grip_position_, and gui::widget::queue_redraw().
Referenced by adjust_position(), gui::scrollarea::handle_event(), 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 129 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 102 of file scrollbar.cpp.
References full_height_, get_max_position(), get_position(), grip_height_, grip_position_, h, gui::widget::queue_redraw(), and set_position().
Referenced by set_full_size(), and gui::scrollarea::set_shown_size().
|
private |
Definition at line 83 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 83 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 83 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 81 of file scrollbar.hpp.
Referenced by grip_area(), and scrollbar().
|
private |
Definition at line 81 of file scrollbar.hpp.
Referenced by handle_event().
|
private |
Definition at line 84 of file scrollbar.hpp.
Referenced by handle_event(), scroll_down(), scroll_up(), and set_scroll_rate().
|
private |
Definition at line 79 of file scrollbar.hpp.
Referenced by draw_contents(), and handle_event().