Skip to content

Commit

Permalink
Rebase and update test screenshot
Browse files Browse the repository at this point in the history
  • Loading branch information
viktorstrate committed Dec 20, 2024
1 parent 793db31 commit 94279c9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 24 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 10 additions & 18 deletions masonry/src/widget/zstack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand All @@ -148,25 +140,25 @@ impl From<Alignment> 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<VerticalAlignment> for Alignment {
fn from(vertical: VerticalAlignment) -> Self {
Alignment::new(vertical, HorizontalAlignment::Center)
Self::new(vertical, HorizontalAlignment::Center)
}
}

impl From<HorizontalAlignment> for Alignment {
fn from(horizontal: HorizontalAlignment) -> Self {
Alignment::new(VerticalAlignment::Center, horizontal)
Self::new(VerticalAlignment::Center, horizontal)
}
}

impl From<Alignment> for ChildAlignment {
fn from(value: Alignment) -> Self {
ChildAlignment::SelfAligned(value)
Self::SelfAligned(value)
}
}

Expand Down
8 changes: 4 additions & 4 deletions xilem/src/view/zstack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,14 @@ impl ViewElement for ZStackElement {
type Mut<'a> = ZStackElementMut<'a>;
}

impl SuperElement<ZStackElement, ViewCtx> for ZStackElement {
fn upcast(_ctx: &mut ViewCtx, child: ZStackElement) -> Self {
impl SuperElement<Self, ViewCtx> for ZStackElement {
fn upcast(_ctx: &mut ViewCtx, child: Self) -> Self {
child
}

fn with_downcast_val<R>(
mut this: Mut<Self>,
f: impl FnOnce(Mut<ZStackElement>) -> R,
f: impl FnOnce(Mut<Self>) -> R,
) -> (Self::Mut<'_>, R) {
let r = {
let parent = this.parent.reborrow_mut();
Expand All @@ -277,7 +277,7 @@ impl SuperElement<ZStackElement, ViewCtx> for ZStackElement {

impl<W: Widget> SuperElement<Pod<W>, ViewCtx> for ZStackElement {
fn upcast(ctx: &mut ViewCtx, child: Pod<W>) -> Self {
ZStackElement::new(ctx.boxed_pod(child), ChildAlignment::ParentAligned)
Self::new(ctx.boxed_pod(child), ChildAlignment::ParentAligned)
}

fn with_downcast_val<R>(
Expand Down

0 comments on commit 94279c9

Please sign in to comment.