The Battle for Wesnoth  1.19.0-dev
Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
gui::scrollbar Class Reference

Scrollbar. More...

#include <scrollbar.hpp>

Inheritance diagram for gui::scrollbar:

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 rectlocation () 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 &region) 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_handleroperator= (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_handleroperator= (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_drawableoperator= (const top_level_drawable &)
 
 top_level_drawable (top_level_drawable &&)
 
top_level_drawableoperator= (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_
 

Detailed Description

Scrollbar.

Definition at line 25 of file scrollbar.hpp.

Member Enumeration Documentation

◆ STATE

enum gui::scrollbar::STATE
private
Enumerator
UNINIT 
NORMAL 
ACTIVE 
DRAGGED 

Definition at line 78 of file scrollbar.hpp.

Constructor & Destructor Documentation

◆ scrollbar()

gui::scrollbar::scrollbar ( )

Create a scrollbar.

Todo:
FIXME: parameterlist ??

Definition at line 46 of file scrollbar.cpp.

References image::get_size(), minimum_grip_height_, and gui::widget::set_width().

Member Function Documentation

◆ adjust_position()

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().

◆ draw_contents()

void gui::scrollbar::draw_contents ( )
protectedvirtual

◆ get_max_position()

unsigned gui::scrollbar::get_max_position ( ) const

◆ get_position()

unsigned gui::scrollbar::get_position ( ) const

Determine where the scrollbar is.

Returns
the position.
Return values
returns0 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().

◆ grip_area()

SDL_Rect gui::scrollbar::grip_area ( ) const
private

◆ handle_event()

void gui::scrollbar::handle_event ( const SDL_Event &  event)
protectedvirtual

◆ move_position()

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().

◆ scroll_down()

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().

◆ scroll_up()

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().

◆ set_full_size()

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().

◆ set_position()

void gui::scrollbar::set_position ( unsigned  pos)

◆ set_scroll_rate()

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().

◆ set_shown_size()

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().

Member Data Documentation

◆ full_height_

unsigned int gui::scrollbar::full_height_
private

◆ grip_height_

unsigned int gui::scrollbar::grip_height_
private

◆ grip_position_

unsigned int gui::scrollbar::grip_position_
private

◆ minimum_grip_height_

int gui::scrollbar::minimum_grip_height_
private

Definition at line 81 of file scrollbar.hpp.

Referenced by grip_area(), and scrollbar().

◆ mousey_on_grip_

int gui::scrollbar::mousey_on_grip_
private

Definition at line 81 of file scrollbar.hpp.

Referenced by handle_event().

◆ scroll_rate_

int gui::scrollbar::scroll_rate_
private

Definition at line 84 of file scrollbar.hpp.

Referenced by handle_event(), scroll_down(), scroll_up(), and set_scroll_rate().

◆ state_

STATE gui::scrollbar::state_
private

Definition at line 79 of file scrollbar.hpp.

Referenced by draw_contents(), and handle_event().


The documentation for this class was generated from the following files: