app work?

This commit is contained in:
2025-11-14 13:49:01 -05:00
parent e2690fa611
commit 218b3f14ed
6 changed files with 56 additions and 47 deletions

View File

@@ -1,7 +1,7 @@
use std::ops::Not;
use crate::{
layout::{UiNum, UiVec2, Vec2, vec2},
layout::{UiNum, UiScalar, UiVec2, Vec2, vec2},
util::impl_op,
};
@@ -143,17 +143,8 @@ impl Size {
}
}
pub fn to_uivec2(self) -> UiVec2 {
UiVec2 {
rel: Vec2 {
x: self.x.total_rel(),
y: self.y.total_rel(),
},
abs: Vec2 {
x: self.x.abs,
y: self.y.abs,
},
}
pub fn to_uivec2(self, rel_len: Vec2) -> UiVec2 {
UiVec2::from_scalars(self.x.apply_rest(rel_len.x), self.y.apply_rest(rel_len.y))
}
pub fn from_axis(axis: Axis, aligned: Len, ortho: Len) -> Self {
@@ -184,13 +175,17 @@ impl Len {
rest: 0.0,
};
pub fn total_rel(&self) -> f32 {
if self.rest > 0.0 {
self.rel.max(1.0)
} else {
self.rel
pub fn apply_rest(&self, rel_len: f32) -> UiScalar {
UiScalar {
rel: if self.rest > 0.0 {
self.rel.max(1.0)
} else {
self.rel
} * rel_len,
abs: if self.rest > 0.0 { 0.0 } else { self.abs },
}
}
pub fn abs(abs: impl UiNum) -> Self {
Self {
abs: abs.to_f32(),