Skip to content

Commit

Permalink
Remove WidgetPod::layout
Browse files Browse the repository at this point in the history
  • Loading branch information
PoignardAzur committed Sep 9, 2024
1 parent b87ef86 commit 294ca03
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
5 changes: 4 additions & 1 deletion masonry/src/passes/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ use crate::render_root::RenderRoot;
use crate::widget::WidgetState;
use crate::{BoxConstraints, LayoutCtx, Widget, WidgetPod};

// TODO - negative rects?
// TODO - Replace with contains_rect once new Kurbo version is released.
// See https://github.com/linebender/kurbo/pull/347
/// Return `true` if all of `smaller` is within `larger`.
fn rect_contains(larger: &Rect, smaller: &Rect) -> bool {
smaller.x0 >= larger.x0
Expand Down Expand Up @@ -146,6 +147,8 @@ fn log_layout_issues(type_name: &str, size: Size) {
}
}

/// Run [`Widget::layout`] method on the widget contained in `pod`.
/// This will be called by [`LayoutCtx::run_layout`], which is itself called in the parent widget's `layout`.
pub(crate) fn run_layout_on<W: Widget>(
parent_ctx: &mut LayoutCtx<'_>,
pod: &mut WidgetPod<W>,
Expand Down
2 changes: 1 addition & 1 deletion masonry/src/testing/helper_widgets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ impl Widget for ReplaceChild {
}

fn layout(&mut self, ctx: &mut LayoutCtx, bc: &BoxConstraints) -> Size {
self.child.layout(ctx, bc)
ctx.run_layout(&mut self.child, bc)
}

fn compose(&mut self, _ctx: &mut ComposeCtx) {}
Expand Down
16 changes: 1 addition & 15 deletions masonry/src/widget/widget_pod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,10 @@

use smallvec::SmallVec;
use tracing::{info_span, trace};
use vello::kurbo::Size;

use crate::passes::layout::run_layout_on;
use crate::tree_arena::ArenaRefChildren;
use crate::widget::WidgetState;
use crate::{
BoxConstraints, InternalLifeCycle, LayoutCtx, LifeCycle, LifeCycleCtx, StatusChange, Widget,
WidgetId,
};
use crate::{InternalLifeCycle, LifeCycle, LifeCycleCtx, StatusChange, Widget, WidgetId};

// TODO - rewrite links in doc

Expand Down Expand Up @@ -424,13 +419,4 @@ impl<W: Widget> WidgetPod<W> {

call_widget || extra_event.is_some()
}

// --- MARK: LAYOUT ---

// FIXME - We keep this around to keep the diff of PR #529 small.
// We should remove this function in a follow-up PR after #529 lands.
/// Deprecated. Used `LayoutCtx::run_layout` instead.
pub fn layout(&mut self, parent_ctx: &mut LayoutCtx, bc: &BoxConstraints) -> Size {
run_layout_on(parent_ctx, self, bc)
}
}

0 comments on commit 294ca03

Please sign in to comment.