Implement scroll_by operation for scrollable

`scroll_by` allows scrolling an absolute offset
that is applied to the current scrolling position.
This commit is contained in:
lufte 2024-05-10 18:50:10 -03:00 committed by Héctor Ramón Jiménez
parent 44235f0c0b
commit e102e89c6a
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
5 changed files with 157 additions and 36 deletions

View file

@ -38,6 +38,7 @@ pub trait Operation<T = ()>: Send {
_state: &mut dyn Scrollable,
_id: Option<&Id>,
_bounds: Rectangle,
_content_bounds: Rectangle,
_translation: Vector,
) {
}
@ -76,9 +77,16 @@ where
state: &mut dyn Scrollable,
id: Option<&Id>,
bounds: Rectangle,
content_bounds: Rectangle,
translation: Vector,
) {
self.as_mut().scrollable(state, id, bounds, translation);
self.as_mut().scrollable(
state,
id,
bounds,
content_bounds,
translation,
);
}
fn text_input(&mut self, state: &mut dyn TextInput, id: Option<&Id>) {
@ -151,9 +159,16 @@ where
state: &mut dyn Scrollable,
id: Option<&Id>,
bounds: Rectangle,
content_bounds: Rectangle,
translation: Vector,
) {
self.operation.scrollable(state, id, bounds, translation);
self.operation.scrollable(
state,
id,
bounds,
content_bounds,
translation,
);
}
fn text_input(&mut self, state: &mut dyn TextInput, id: Option<&Id>) {
@ -222,9 +237,16 @@ where
state: &mut dyn Scrollable,
id: Option<&Id>,
bounds: Rectangle,
content_bounds: Rectangle,
translation: Vector,
) {
self.operation.scrollable(state, id, bounds, translation);
self.operation.scrollable(
state,
id,
bounds,
content_bounds,
translation,
);
}
fn focusable(
@ -262,9 +284,16 @@ where
state: &mut dyn Scrollable,
id: Option<&Id>,
bounds: Rectangle,
content_bounds: Rectangle,
translation: Vector,
) {
self.operation.scrollable(state, id, bounds, translation);
self.operation.scrollable(
state,
id,
bounds,
content_bounds,
translation,
);
}
fn text_input(&mut self, state: &mut dyn TextInput, id: Option<&Id>) {
@ -341,9 +370,16 @@ where
state: &mut dyn Scrollable,
id: Option<&Id>,
bounds: Rectangle,
content_bounds: Rectangle,
translation: crate::Vector,
) {
self.operation.scrollable(state, id, bounds, translation);
self.operation.scrollable(
state,
id,
bounds,
content_bounds,
translation,
);
}
fn text_input(&mut self, state: &mut dyn TextInput, id: Option<&Id>) {