Support on_scroll event in ui::scroller
This commit is contained in:
parent
3760741ba6
commit
b5145b9596
2 changed files with 11 additions and 0 deletions
|
|
@ -40,6 +40,8 @@ namespace psemek::ui
|
|||
|
||||
protected:
|
||||
|
||||
virtual void on_scroll(geom::vector<float, 2> const & delta);
|
||||
|
||||
virtual float width() const;
|
||||
virtual geom::box<float, 2> visible_range() const;
|
||||
|
||||
|
|
|
|||
|
|
@ -53,8 +53,10 @@ namespace psemek::ui
|
|||
float c = geom::unlerp<float>(box[0], e.position[0]);
|
||||
c = geom::clamp(c, {0.f, 1.f});
|
||||
|
||||
auto old = shift_tgt_;
|
||||
shift_tgt_[0] = shape_.box[0].length() / 2.f - c * sc[0].min;
|
||||
clamp_shift();
|
||||
on_scroll(shift_tgt_ - old);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -85,8 +87,10 @@ namespace psemek::ui
|
|||
float c = geom::unlerp<float>(box[1], e.position[1]);
|
||||
c = geom::clamp(c, {0.f, 1.f});
|
||||
|
||||
auto old = shift_tgt_;
|
||||
shift_tgt_[1] = shape_.box[1].length() / 2.f - c * sc[1].min;
|
||||
clamp_shift();
|
||||
on_scroll(shift_tgt_ - old);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -182,8 +186,10 @@ namespace psemek::ui
|
|||
delta[0] = e.delta;
|
||||
}
|
||||
|
||||
auto old = shift_tgt_;
|
||||
shift_tgt_ += delta * 50.f;
|
||||
clamp_shift();
|
||||
on_scroll(shift_tgt_ - old);
|
||||
post_reshape();
|
||||
return true;
|
||||
}
|
||||
|
|
@ -291,6 +297,9 @@ namespace psemek::ui
|
|||
p.end_stencil();
|
||||
}
|
||||
|
||||
void scroller::on_scroll(geom::vector<float, 2> const &)
|
||||
{}
|
||||
|
||||
float scroller::width() const
|
||||
{
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue