Skip to content

Commit

Permalink
Remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp-M committed Nov 22, 2024
1 parent ffb4da3 commit b97a9e9
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 33 deletions.
2 changes: 1 addition & 1 deletion masonry/src/testing/helper_widgets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use accesskit::{Node, Role};
use smallvec::SmallVec;
use tracing::trace_span;
use vello::Scene;
use widget::widget::{get_child_at_pos, AsDynWidget as _};
use widget::widget::AsDynWidget as _;
use widget::WidgetRef;

use crate::event::{PointerEvent, TextEvent};
Expand Down
32 changes: 0 additions & 32 deletions masonry/src/widget/widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,38 +327,6 @@ pub trait Widget: AsAny + AsDynWidget {
}
}

pub(crate) fn get_child_at_pos<'c>(
widget: &(impl Widget + ?Sized),
ctx: QueryCtx<'c>,
pos: Point,
) -> Option<WidgetRef<'c, dyn Widget>> {
let local_pos = ctx.widget_state.window_transform.inverse() * pos;
if !ctx
.clip_path()
.map_or(true, |clip| clip.contains(local_pos))
{
return None;
}

// Assumes `Self::children_ids` is in increasing "z-order", picking the last child in case
// of overlapping children.
for child_id in widget.children_ids().iter().rev() {
let child = ctx.get(*child_id);
let local_pos = child.ctx().widget_state.window_transform.inverse() * pos;

// The position must be inside the child's layout and inside the child's clip path (if
// any).
if !child.ctx().is_stashed()
&& child.ctx().accepts_pointer_interaction()
&& child.ctx().size().to_rect().contains(local_pos)
{
return Some(child);
}
}

None
}

/// Marker trait for Widgets whose parents can get a raw mutable reference to them.
///
/// "Raw mut" means using a mutable reference (eg `&mut MyWidget`) to the data
Expand Down

0 comments on commit b97a9e9

Please sign in to comment.