Skip to content

Commit

Permalink
wip: provide WidgetRef to Widget::get_child_at_pos
Browse files Browse the repository at this point in the history
  • Loading branch information
tomcur committed Aug 30, 2024
1 parent 50768e1 commit be65d65
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions masonry/src/widget/widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,11 @@ pub trait Widget: AsAny {
/// [`Self::children_ids`].
fn get_child_at_pos<'w>(
&self,
children: &[WidgetRef<'w, dyn Widget>],
widget_ref: WidgetRef<'w, dyn Widget>,
pos: Point,
) -> Option<WidgetRef<'w, dyn Widget>> {
children
widget_ref
.children()
.iter()
// TODO: currently assumes `Self::children_ids` is in increasing "z-order". Picks the
// last child in case of overlapping children. Is this the desired behavior?
Expand Down Expand Up @@ -367,10 +368,10 @@ impl Widget for Box<dyn Widget> {

fn get_child_at_pos<'w>(
&self,
children: &[WidgetRef<'w, dyn Widget>],
widget_ref: WidgetRef<'w, dyn Widget>,
pos: Point,
) -> Option<WidgetRef<'w, dyn Widget>> {
self.deref().get_child_at_pos(children, pos)
self.deref().get_child_at_pos(widget_ref, pos)
}

fn as_any(&self) -> &dyn Any {
Expand Down
2 changes: 1 addition & 1 deletion masonry/src/widget/widget_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ impl<'w> WidgetRef<'w, dyn Widget> {

if let Some(child) = innermost_widget
.widget
.get_child_at_pos(&innermost_widget.children(), pos)
.get_child_at_pos(innermost_widget, pos)
{
innermost_widget = child;
} else {
Expand Down

0 comments on commit be65d65

Please sign in to comment.