add axis to flip so spans w negative sign work correctly
This commit is contained in:
@@ -33,7 +33,7 @@ impl Widget for Span {
|
|||||||
}
|
}
|
||||||
axis.bot_right.set(start);
|
axis.bot_right.set(start);
|
||||||
if self.dir.sign == Sign::Neg {
|
if self.dir.sign == Sign::Neg {
|
||||||
child_region.flip();
|
child_region.flip(self.dir.axis);
|
||||||
}
|
}
|
||||||
painter.widget_within(child, child_region);
|
painter.widget_within(child, child_region);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,13 +87,14 @@ impl UiVec2 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn flip(&mut self) {
|
/// reflection about an axis
|
||||||
self.rel = 1.0 - self.rel;
|
pub fn flip(&mut self, axis: Axis) {
|
||||||
self.abs = -self.abs;
|
*self.rel.axis_mut(axis) = 1.0 - self.rel.axis(axis);
|
||||||
|
*self.abs.axis_mut(axis) = -self.abs.axis(axis);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn flipped(mut self) -> Self {
|
pub fn flipped(mut self, axis: Axis) -> Self {
|
||||||
self.flip();
|
self.flip(axis);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,10 +228,13 @@ impl UiRegion {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn flip(&mut self) {
|
pub fn flip(&mut self, axis: Axis) {
|
||||||
self.top_left.flip();
|
self.top_left.flip(axis);
|
||||||
self.bot_right.flip();
|
self.bot_right.flip(axis);
|
||||||
std::mem::swap(&mut self.top_left, &mut self.bot_right);
|
let tl = self.top_left.axis_mut(axis);
|
||||||
|
let br = self.bot_right.axis_mut(axis);
|
||||||
|
std::mem::swap(tl.rel, br.rel);
|
||||||
|
std::mem::swap(tl.abs, br.abs);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn shift(&mut self, offset: impl Into<UiVec2>) {
|
pub fn shift(&mut self, offset: impl Into<UiVec2>) {
|
||||||
|
|||||||
Reference in New Issue
Block a user