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:
|
protected:
|
||||||
|
|
||||||
|
virtual void on_scroll(geom::vector<float, 2> const & delta);
|
||||||
|
|
||||||
virtual float width() const;
|
virtual float width() const;
|
||||||
virtual geom::box<float, 2> visible_range() 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]);
|
float c = geom::unlerp<float>(box[0], e.position[0]);
|
||||||
c = geom::clamp(c, {0.f, 1.f});
|
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;
|
shift_tgt_[0] = shape_.box[0].length() / 2.f - c * sc[0].min;
|
||||||
clamp_shift();
|
clamp_shift();
|
||||||
|
on_scroll(shift_tgt_ - old);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -85,8 +87,10 @@ namespace psemek::ui
|
||||||
float c = geom::unlerp<float>(box[1], e.position[1]);
|
float c = geom::unlerp<float>(box[1], e.position[1]);
|
||||||
c = geom::clamp(c, {0.f, 1.f});
|
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;
|
shift_tgt_[1] = shape_.box[1].length() / 2.f - c * sc[1].min;
|
||||||
clamp_shift();
|
clamp_shift();
|
||||||
|
on_scroll(shift_tgt_ - old);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -182,8 +186,10 @@ namespace psemek::ui
|
||||||
delta[0] = e.delta;
|
delta[0] = e.delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto old = shift_tgt_;
|
||||||
shift_tgt_ += delta * 50.f;
|
shift_tgt_ += delta * 50.f;
|
||||||
clamp_shift();
|
clamp_shift();
|
||||||
|
on_scroll(shift_tgt_ - old);
|
||||||
post_reshape();
|
post_reshape();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -291,6 +297,9 @@ namespace psemek::ui
|
||||||
p.end_stencil();
|
p.end_stencil();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void scroller::on_scroll(geom::vector<float, 2> const &)
|
||||||
|
{}
|
||||||
|
|
||||||
float scroller::width() const
|
float scroller::width() const
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue