From 94279c93fb2c85b2e79e9e945bb79c5904543625 Mon Sep 17 00:00:00 2001 From: viktorstrate Date: Fri, 20 Dec 2024 13:04:52 +0100 Subject: [PATCH] Rebase and update test screenshot --- ..._tests__zstack_alignments_self_aligned.png | 4 +-- masonry/src/widget/zstack.rs | 28 +++++++------------ xilem/src/view/zstack.rs | 8 +++--- 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/masonry/src/widget/screenshots/masonry__widget__zstack__tests__zstack_alignments_self_aligned.png b/masonry/src/widget/screenshots/masonry__widget__zstack__tests__zstack_alignments_self_aligned.png index 7f555d33f..f0129aaf2 100644 --- a/masonry/src/widget/screenshots/masonry__widget__zstack__tests__zstack_alignments_self_aligned.png +++ b/masonry/src/widget/screenshots/masonry__widget__zstack__tests__zstack_alignments_self_aligned.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:77c51ecd65204dc8156786dd9f0194f30e0fe5120e0a4c13061a9e21401d5391 -size 13593 +oid sha256:a7b02562b6e2e018886a7c7e171bc4b1e5f8c60458c0a2964ec3b46aadcc21b1 +size 13346 diff --git a/masonry/src/widget/zstack.rs b/masonry/src/widget/zstack.rs index 98cf6a164..5041387dc 100644 --- a/masonry/src/widget/zstack.rs +++ b/masonry/src/widget/zstack.rs @@ -108,26 +108,18 @@ impl Alignment { /// Gets the vertical component of the alignment. pub fn vertical(self) -> VerticalAlignment { match self { - Alignment::Center | Alignment::Leading | Alignment::Trailing => { - VerticalAlignment::Center - } - Alignment::Top | Alignment::TopLeading | Alignment::TopTrailing => { - VerticalAlignment::Top - } - Alignment::Bottom | Alignment::BottomLeading | Alignment::BottomTrailing => { - VerticalAlignment::Bottom - } + Self::Center | Self::Leading | Self::Trailing => VerticalAlignment::Center, + Self::Top | Self::TopLeading | Self::TopTrailing => VerticalAlignment::Top, + Self::Bottom | Self::BottomLeading | Self::BottomTrailing => VerticalAlignment::Bottom, } } /// Gets the horizontal component of the alignment. pub fn horizontal(self) -> HorizontalAlignment { match self { - Alignment::Center | Alignment::Top | Alignment::Bottom => HorizontalAlignment::Center, - Alignment::Leading | Alignment::TopLeading | Alignment::BottomLeading => { - HorizontalAlignment::Leading - } - Alignment::Trailing | Alignment::TopTrailing | Alignment::BottomTrailing => { + Self::Center | Self::Top | Self::Bottom => HorizontalAlignment::Center, + Self::Leading | Self::TopLeading | Self::BottomLeading => HorizontalAlignment::Leading, + Self::Trailing | Self::TopTrailing | Self::BottomTrailing => { HorizontalAlignment::Trailing } } @@ -148,25 +140,25 @@ impl From for HorizontalAlignment { impl From<(VerticalAlignment, HorizontalAlignment)> for Alignment { fn from((vertical, horizontal): (VerticalAlignment, HorizontalAlignment)) -> Self { - Alignment::new(vertical, horizontal) + Self::new(vertical, horizontal) } } impl From for Alignment { fn from(vertical: VerticalAlignment) -> Self { - Alignment::new(vertical, HorizontalAlignment::Center) + Self::new(vertical, HorizontalAlignment::Center) } } impl From for Alignment { fn from(horizontal: HorizontalAlignment) -> Self { - Alignment::new(VerticalAlignment::Center, horizontal) + Self::new(VerticalAlignment::Center, horizontal) } } impl From for ChildAlignment { fn from(value: Alignment) -> Self { - ChildAlignment::SelfAligned(value) + Self::SelfAligned(value) } } diff --git a/xilem/src/view/zstack.rs b/xilem/src/view/zstack.rs index 50f8dbd7f..1fd58f3b9 100644 --- a/xilem/src/view/zstack.rs +++ b/xilem/src/view/zstack.rs @@ -254,14 +254,14 @@ impl ViewElement for ZStackElement { type Mut<'a> = ZStackElementMut<'a>; } -impl SuperElement for ZStackElement { - fn upcast(_ctx: &mut ViewCtx, child: ZStackElement) -> Self { +impl SuperElement for ZStackElement { + fn upcast(_ctx: &mut ViewCtx, child: Self) -> Self { child } fn with_downcast_val( mut this: Mut, - f: impl FnOnce(Mut) -> R, + f: impl FnOnce(Mut) -> R, ) -> (Self::Mut<'_>, R) { let r = { let parent = this.parent.reborrow_mut(); @@ -277,7 +277,7 @@ impl SuperElement for ZStackElement { impl SuperElement, ViewCtx> for ZStackElement { fn upcast(ctx: &mut ViewCtx, child: Pod) -> Self { - ZStackElement::new(ctx.boxed_pod(child), ChildAlignment::ParentAligned) + Self::new(ctx.boxed_pod(child), ChildAlignment::ParentAligned) } fn with_downcast_val(