Skip to content

Commit

Permalink
Add alignment to Viewport
Browse files Browse the repository at this point in the history
  • Loading branch information
tarkah committed Jun 25, 2023
1 parent d73dba1 commit e1445be
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion widget/src/scrollable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,15 @@ pub fn update<Message>(
content_bounds,
);

notify_on_scroll(state, on_scroll, bounds, content_bounds, shell);
notify_on_scroll(
state,
on_scroll,
bounds,
content_bounds,
horizontal_alignment,
vertical_alignment,
shell,
);

return event::Status::Captured;
}
Expand Down Expand Up @@ -599,6 +607,8 @@ pub fn update<Message>(
on_scroll,
bounds,
content_bounds,
horizontal_alignment,
vertical_alignment,
shell,
);
}
Expand Down Expand Up @@ -645,6 +655,8 @@ pub fn update<Message>(
on_scroll,
bounds,
content_bounds,
horizontal_alignment,
vertical_alignment,
shell,
);

Expand Down Expand Up @@ -681,6 +693,8 @@ pub fn update<Message>(
on_scroll,
bounds,
content_bounds,
horizontal_alignment,
vertical_alignment,
shell,
);
}
Expand Down Expand Up @@ -722,6 +736,8 @@ pub fn update<Message>(
on_scroll,
bounds,
content_bounds,
horizontal_alignment,
vertical_alignment,
shell,
);
}
Expand Down Expand Up @@ -758,6 +774,8 @@ pub fn update<Message>(
on_scroll,
bounds,
content_bounds,
horizontal_alignment,
vertical_alignment,
shell,
);

Expand Down Expand Up @@ -995,6 +1013,8 @@ fn notify_on_scroll<Message>(
on_scroll: &Option<Box<dyn Fn(Viewport) -> Message + '_>>,
bounds: Rectangle,
content_bounds: Rectangle,
horizontal_alignment: Alignment,
vertical_alignment: Alignment,
shell: &mut Shell<'_, Message>,
) {
if let Some(on_scroll) = on_scroll {
Expand All @@ -1009,6 +1029,8 @@ fn notify_on_scroll<Message>(
offset_y: state.offset_y,
bounds,
content_bounds,
horizontal_alignment,
vertical_alignment,
};

// Don't publish redundant viewports to shell
Expand Down Expand Up @@ -1101,6 +1123,10 @@ pub struct Viewport {
pub bounds: Rectangle,
/// The content bounds of the [`Scrollable`].
pub content_bounds: Rectangle,
/// The horizontal [`Alignment`] of the [`Scrollable`].
pub horizontal_alignment: Alignment,
/// The vertical [`Alignment`] of the [`Scrollable`].
pub vertical_alignment: Alignment,
}

impl Viewport {
Expand Down

0 comments on commit e1445be

Please sign in to comment.