Added a scroll rate factor.
This commit is contained in:
parent
66a828dba6
commit
5355cb147c
6 changed files with 25 additions and 7 deletions
|
@ -1607,7 +1607,9 @@ help_text_area::help_text_area(display &disp, const section &toplevel)
|
|||
title_spacing_(16), curr_loc_(0, 0),
|
||||
min_row_height_(font::get_max_height(normal_font_size)), curr_row_height_(min_row_height_),
|
||||
contents_height_(0)
|
||||
{}
|
||||
{
|
||||
set_scroll_rate(40);
|
||||
}
|
||||
|
||||
void help_text_area::set_inner_location(SDL_Rect const &rect) {
|
||||
bg_register(rect);
|
||||
|
|
|
@ -101,6 +101,11 @@ void scrollarea::set_full_size(unsigned h)
|
|||
test_scrollbar();
|
||||
}
|
||||
|
||||
void scrollarea::set_scroll_rate(unsigned r)
|
||||
{
|
||||
scrollbar_.set_scroll_rate(r);
|
||||
}
|
||||
|
||||
void scrollarea::process_event()
|
||||
{
|
||||
int grip_position = scrollbar_.get_position();
|
||||
|
@ -131,9 +136,9 @@ void scrollarea::handle_event(const SDL_Event& event)
|
|||
SDL_MouseButtonEvent const &e = event.button;
|
||||
if (point_in_rect(e.x, e.y, inner_location()))
|
||||
if (e.button == SDL_BUTTON_WHEELDOWN)
|
||||
scrollbar_.move_position(1);
|
||||
scrollbar_.move_position(scrollbar_.scroll_rate_);
|
||||
else if (e.button == SDL_BUTTON_WHEELUP)
|
||||
scrollbar_.move_position(-1);
|
||||
scrollbar_.move_position(-scrollbar_.scroll_rate_);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ protected:
|
|||
void move_position(int dep);
|
||||
void set_shown_size(unsigned h);
|
||||
void set_full_size(unsigned h);
|
||||
void set_scroll_rate(unsigned r);
|
||||
bool has_scrollbar() const;
|
||||
|
||||
private:
|
||||
|
|
|
@ -40,7 +40,8 @@ scrollbar::scrollbar(display &d)
|
|||
: widget(d), mid_scaled_(NULL), groove_scaled_(NULL),
|
||||
uparrow_(d, "", button::TYPE_TURBO, "uparrow-button"),
|
||||
downarrow_(d, "", button::TYPE_TURBO, "downarrow-button"),
|
||||
state_(NORMAL), grip_position_(0), grip_height_(0), full_height_(0)
|
||||
state_(NORMAL),
|
||||
grip_position_(0), grip_height_(0), full_height_(0), scroll_rate_(1)
|
||||
{
|
||||
static const surface img(image::get_image(scrollbar_mid, image::UNSCALED));
|
||||
|
||||
|
@ -124,12 +125,17 @@ void scrollbar::set_full_size(unsigned h)
|
|||
set_dirty(true);
|
||||
}
|
||||
|
||||
void scrollbar::set_scroll_rate(unsigned r)
|
||||
{
|
||||
scroll_rate_ = r;
|
||||
}
|
||||
|
||||
void scrollbar::process_event()
|
||||
{
|
||||
if (uparrow_.pressed())
|
||||
move_position(-1);
|
||||
move_position(-scroll_rate_);
|
||||
if (downarrow_.pressed())
|
||||
move_position(1);
|
||||
move_position(scroll_rate_);
|
||||
}
|
||||
|
||||
SDL_Rect scrollbar::groove_area() const
|
||||
|
|
|
@ -54,6 +54,9 @@ public:
|
|||
/// Set the relative size of the scrollbar.
|
||||
void set_full_size(unsigned h);
|
||||
|
||||
/// Set scroll rate.
|
||||
void set_scroll_rate(unsigned r);
|
||||
|
||||
protected:
|
||||
virtual void update_location(SDL_Rect const &rect);
|
||||
virtual void handle_event(const SDL_Event& event);
|
||||
|
@ -72,7 +75,7 @@ private:
|
|||
|
||||
int minimum_grip_height_, mousey_on_grip_;
|
||||
// Relative data
|
||||
int grip_position_, old_position_, grip_height_, full_height_;
|
||||
int grip_position_, old_position_, grip_height_, full_height_, scroll_rate_;
|
||||
|
||||
friend class scrollarea;
|
||||
};
|
||||
|
|
|
@ -36,6 +36,7 @@ scrollpane::scrollpane(display& d) : scrollarea(d), border_(5)
|
|||
content_pos_.x = 0;
|
||||
content_pos_.y = 0;
|
||||
update_content_size();
|
||||
set_scroll_rate(40);
|
||||
}
|
||||
|
||||
void scrollpane::clear()
|
||||
|
|
Loading…
Add table
Reference in a new issue