diff --git a/core/src/orientation/len.rs b/core/src/orientation/len.rs index f1bcc60..7c31074 100644 --- a/core/src/orientation/len.rs +++ b/core/src/orientation/len.rs @@ -148,20 +148,20 @@ impl LayoutLen { /// Only pixels: the same number of them whatever box it lands in, and /// whatever anyone else in the row asks for. A length that is any part /// of a box or of what is left over is not one. - pub fn is_px(self) -> bool { + pub fn is_px(&self) -> bool { self.rel == Rel::ZERO && self.leftover == Weight::ZERO } /// Nothing but a claim on what is left over, so there is no length here /// at all where nothing is. - pub fn is_only_leftover(self) -> bool { + pub fn is_only_leftover(&self) -> bool { self.leftover > Weight::ZERO && self.without_leftover() == Len::ZERO } /// This as a length of a box, where it is one. `leftover` is not: a /// share of what is left over is a length only to whoever divides one, /// so it passes up in the reported size instead and is resolved there. - pub fn declared(self) -> Option { + pub fn declared(&self) -> Option { (self.leftover == Weight::ZERO).then(|| self.without_leftover()) } diff --git a/core/src/ui/holds.rs b/core/src/ui/holds.rs index 68a8818..2845aaa 100644 --- a/core/src/ui/holds.rs +++ b/core/src/ui/holds.rs @@ -29,17 +29,17 @@ impl Holds { Self { lo: len, hi: len } } - pub const fn contains(self, len: Px) -> bool { + pub const fn contains(&self, len: Px) -> bool { len.raw() >= self.lo.raw() && len.raw() <= self.hi.raw() } /// Every length `other` holds for is one this holds for, so a drawing /// made under this range is still good wherever `other` is. - pub const fn covers(self, other: Self) -> bool { + pub const fn covers(&self, other: Self) -> bool { self.lo.raw() <= other.lo.raw() && self.hi.raw() >= other.hi.raw() } - pub const fn and(self, other: Self) -> Self { + pub const fn and(&self, other: Self) -> Self { Self { lo: self.lo.max(other.lo), hi: self.hi.min(other.hi), @@ -57,7 +57,7 @@ impl Holds { /// boxes therefore give one length. That is a floor rather than an /// allowance: inverting it is two divisions and nothing else, and the /// whole of a box maps back to itself. - pub const fn through(self, len: Len) -> Self { + pub const fn through(&self, len: Len) -> Self { if self.lo.raw() == Px::MIN.raw() && self.hi.raw() == Px::MAX.raw() { return Self::ANY; } diff --git a/core/src/ui/layout_holds.rs b/core/src/ui/layout_holds.rs index e52a916..0d44334 100644 --- a/core/src/ui/layout_holds.rs +++ b/core/src/ui/layout_holds.rs @@ -34,7 +34,7 @@ impl AxisHolds { region_len: None, }; - pub fn and(self, other: Self) -> Self { + pub fn and(&self, other: Self) -> Self { // Two pins of the same length disagreeing would mean one drawing was // a fraction of two different lengths at once. debug_assert!( @@ -53,7 +53,7 @@ impl AxisHolds { } } - pub fn covers(self, other: Self) -> bool { + pub fn covers(&self, other: Self) -> bool { self.window.covers(other.window) && self.region.covers(other.region) && self @@ -64,7 +64,7 @@ impl AxisHolds { /// Whether a widget in a box `len` long, with that rel base, in that /// window, is one this drawing holds for. - pub fn contains(self, window: Px, rel_base: Len, len: Len) -> bool { + pub fn contains(&self, window: Px, rel_base: Len, len: Len) -> bool { self.window.contains(window) && self.rel_base.is_none_or(|pinned| pinned == rel_base) && self.region.contains(len.to_px(window)) @@ -87,18 +87,18 @@ impl LayoutHolds { y: AxisHolds::ANY, }; - pub fn and(self, other: Self) -> Self { + pub fn and(&self, other: Self) -> Self { Self { x: self.x.and(other.x), y: self.y.and(other.y), } } - pub fn covers(self, other: Self) -> bool { + pub fn covers(&self, other: Self) -> bool { self.x.covers(other.x) && self.y.covers(other.y) } - pub fn contains(self, window: PxVec2, rel_base: UiVec2, region: UiRegion) -> bool { + pub fn contains(&self, window: PxVec2, rel_base: UiVec2, region: UiRegion) -> bool { Axis::BOTH .into_iter() .all(|axis| self[axis].contains(window[axis], rel_base[axis], region[axis].len())) diff --git a/core/src/ui/painter.rs b/core/src/ui/painter.rs index 04c202d..44153c2 100644 --- a/core/src/ui/painter.rs +++ b/core/src/ui/painter.rs @@ -665,7 +665,7 @@ impl Widgets { // the box it was offered. widget .and_then(|widget| widget.size_hint(axis)) - .and_then(LayoutLen::declared) + .and_then(|len| len.declared()) }) }) } @@ -679,7 +679,7 @@ impl LayoutLen { /// the rule already gave the region its length, and the rule's length is /// what the widget reports there. And an axis the parent decided from /// the answer is the answer already. - pub(super) fn fills(self, declared: Option, decided: bool) -> bool { + pub(super) fn fills(&self, declared: Option, decided: bool) -> bool { self.leftover != Weight::ZERO || declared.is_some() || decided } } diff --git a/core/src/ui/render_state.rs b/core/src/ui/render_state.rs index adadb74..bd8eab2 100644 --- a/core/src/ui/render_state.rs +++ b/core/src/ui/render_state.rs @@ -1167,7 +1167,7 @@ impl Size { /// in. Both are lengths of the window, so the comparison is in its /// pixels. A share is a length only to whoever divides one, so it is not /// a claim about this box and cannot exceed it. - fn within_box(self, region: UiRegion, window: PxVec2, axis: Axis) -> bool { + fn within_box(&self, region: UiRegion, window: PxVec2, axis: Axis) -> bool { let len = self[axis]; let window = window[axis]; len.leftover != Weight::ZERO diff --git a/core/src/widget/size_rule.rs b/core/src/widget/size_rule.rs index bb0c8f7..1d59154 100644 --- a/core/src/widget/size_rule.rs +++ b/core/src/widget/size_rule.rs @@ -22,7 +22,7 @@ impl SizeRule { /// The length this rule gives without the widget being drawn, if it can /// give one. pub fn declared(&self) -> Option { - self.exact().and_then(LayoutLen::declared) + self.exact().and_then(|len| len.declared()) } /// The length this rule gives outright, whatever the widget reports --