app work
This commit is contained in:
@@ -39,6 +39,13 @@ pub struct Padding {
|
||||
}
|
||||
|
||||
impl Padding {
|
||||
pub const ZERO: Self = Self {
|
||||
left: 0.0,
|
||||
right: 0.0,
|
||||
top: 0.0,
|
||||
bottom: 0.0,
|
||||
};
|
||||
|
||||
pub fn uniform(amt: impl UiNum) -> Self {
|
||||
let amt = amt.to_f32();
|
||||
Self {
|
||||
@@ -75,6 +82,30 @@ impl Padding {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn top(amt: impl UiNum) -> Self {
|
||||
let mut s = Self::ZERO;
|
||||
s.top = amt.to_f32();
|
||||
s
|
||||
}
|
||||
|
||||
pub fn bottom(amt: impl UiNum) -> Self {
|
||||
let mut s = Self::ZERO;
|
||||
s.bottom = amt.to_f32();
|
||||
s
|
||||
}
|
||||
|
||||
pub fn left(amt: impl UiNum) -> Self {
|
||||
let mut s = Self::ZERO;
|
||||
s.left = amt.to_f32();
|
||||
s
|
||||
}
|
||||
|
||||
pub fn right(amt: impl UiNum) -> Self {
|
||||
let mut s = Self::ZERO;
|
||||
s.right = amt.to_f32();
|
||||
s
|
||||
}
|
||||
|
||||
pub fn with_top(mut self, amt: impl UiNum) -> Self {
|
||||
self.top = amt.to_f32();
|
||||
self
|
||||
|
||||
@@ -114,7 +114,7 @@ impl<O: TextBuilderOutput, H: WidgetOption> FnOnce<(&mut Ui,)> for TextBuilder<O
|
||||
}
|
||||
}
|
||||
|
||||
pub fn text(content: impl Into<String>) -> TextBuilder {
|
||||
pub fn wtext(content: impl Into<String>) -> TextBuilder {
|
||||
TextBuilder {
|
||||
content: content.into(),
|
||||
attrs: TextAttrs::default(),
|
||||
|
||||
@@ -15,7 +15,9 @@ pub trait CoreWidget<W, Tag> {
|
||||
fn scroll(self) -> impl WidgetIdFn<Scroll>;
|
||||
fn masked(self) -> impl WidgetFn<Masked>;
|
||||
fn background<T>(self, w: impl WidgetLike<T>) -> impl WidgetFn<Stack>;
|
||||
fn foreground<T>(self, w: impl WidgetLike<T>) -> impl WidgetFn<Stack>;
|
||||
fn layer_offset(self, offset: usize) -> impl WidgetFn<LayerOffset>;
|
||||
fn to_any(self) -> impl WidgetRet;
|
||||
}
|
||||
|
||||
impl<W: WidgetLike<Tag>, Tag> CoreWidget<W::Widget, Tag> for W {
|
||||
@@ -120,12 +122,23 @@ impl<W: WidgetLike<Tag>, Tag> CoreWidget<W::Widget, Tag> for W {
|
||||
}
|
||||
}
|
||||
|
||||
fn foreground<T>(self, w: impl WidgetLike<T>) -> impl WidgetFn<Stack> {
|
||||
move |ui| Stack {
|
||||
children: vec![self.add(ui).any(), w.add(ui).any()],
|
||||
size: StackSize::Child(0),
|
||||
}
|
||||
}
|
||||
|
||||
fn layer_offset(self, offset: usize) -> impl WidgetFn<LayerOffset> {
|
||||
move |ui| LayerOffset {
|
||||
inner: self.add(ui).any(),
|
||||
offset,
|
||||
}
|
||||
}
|
||||
|
||||
fn to_any(self) -> impl WidgetRet {
|
||||
|ui| self.add(ui).any()
|
||||
}
|
||||
}
|
||||
|
||||
pub trait CoreWidgetArr<const LEN: usize, Wa: WidgetArrLike<LEN, Tag>, Tag> {
|
||||
|
||||
Reference in New Issue
Block a user