span direction (sign) now works
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
use crate::{Dir, Painter, UINum, UIRegion, UIScalar, Widget, WidgetId};
|
use crate::{Dir, Painter, Sign, UINum, UIRegion, UIScalar, Widget, WidgetId};
|
||||||
|
|
||||||
pub struct Span {
|
pub struct Span {
|
||||||
pub children: Vec<(WidgetId, SpanLen)>,
|
pub children: Vec<(WidgetId, SpanLen)>,
|
||||||
@@ -30,6 +30,9 @@ impl Widget for Span {
|
|||||||
axis.bot_right.set(start);
|
axis.bot_right.set(start);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if self.dir.sign == Sign::Neg {
|
||||||
|
child_region.flip();
|
||||||
|
}
|
||||||
painter.draw_within(child, child_region);
|
painter.draw_within(child, child_region);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,10 +40,10 @@ impl UIPos {
|
|||||||
let anchor = self
|
let anchor = self
|
||||||
.anchor
|
.anchor
|
||||||
.lerp(region.top_left.anchor, region.bot_right.anchor);
|
.lerp(region.top_left.anchor, region.bot_right.anchor);
|
||||||
let offset = self.offset;
|
let offset = self.offset
|
||||||
// + self
|
+ self
|
||||||
// .anchor
|
.anchor
|
||||||
// .lerp(region.top_left.offset, region.bot_right.offset);
|
.lerp(region.top_left.offset, region.bot_right.offset);
|
||||||
UIPos { anchor, offset }
|
UIPos { anchor, offset }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,6 +59,16 @@ impl UIPos {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn flip(&mut self) {
|
||||||
|
self.anchor = 1.0 - self.anchor;
|
||||||
|
self.offset = -self.offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn flipped(mut self) -> Self {
|
||||||
|
self.flip();
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
@@ -133,6 +143,12 @@ impl UIRegion {
|
|||||||
bot_right: self.bot_right.axis_mut(axis),
|
bot_right: self.bot_right.axis_mut(axis),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn flip(&mut self) {
|
||||||
|
self.top_left.flip();
|
||||||
|
self.bot_right.flip();
|
||||||
|
std::mem::swap(&mut self.top_left, &mut self.bot_right);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct UIRegionAxisView<'a> {
|
pub struct UIRegionAxisView<'a> {
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ impl Client {
|
|||||||
rect.color(UIColor::RED),
|
rect.color(UIColor::RED),
|
||||||
)
|
)
|
||||||
.span(
|
.span(
|
||||||
Dir::RIGHT,
|
Dir::LEFT,
|
||||||
[
|
[
|
||||||
fixed(100),
|
fixed(100),
|
||||||
ratio(1),
|
ratio(1),
|
||||||
|
|||||||
@@ -40,6 +40,15 @@ macro_rules! impl_op {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
impl const $op<$T> for f32 {
|
||||||
|
type Output = $T;
|
||||||
|
|
||||||
|
fn $fn(self, rhs: $T) -> Self::Output {
|
||||||
|
$T {
|
||||||
|
$($field: self.$fn(rhs.$field),)*
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
impl $opa<f32> for $T {
|
impl $opa<f32> for $T {
|
||||||
fn $fna(&mut self, rhs: f32) {
|
fn $fna(&mut self, rhs: f32) {
|
||||||
$(self.$field.$fna(rhs);)*
|
$(self.$field.$fna(rhs);)*
|
||||||
|
|||||||
Reference in New Issue
Block a user