Struct AbsLimits

Source
pub struct AbsLimits(/* private fields */);

Implementations§

Source§

impl AbsLimits

Source

pub const fn new(min: Vec2, max: Vec2) -> Self

Examples found in repository?
examples/basic-rs.rs (lines 104-107)
50    fn call(
51        &mut self,
52        mut store: Self::Store,
53        args: &CounterState,
54    ) -> (Self::Store, im::HashMap<Arc<SourceID>, Option<Window>>) {
55        if store.0 != *args {
56            let button = {
57                let text = Text::<FixedData> {
58                    id: gen_id!(),
59                    props: Rc::new(FixedData {
60                        area: URect {
61                            abs: AbsRect::new(8.0, 0.0, 8.0, 0.0),
62                            rel: RelRect::new(0.0, 0.5, UNSIZED_AXIS, UNSIZED_AXIS),
63                        }
64                        .into(),
65                        anchor: feather_ui::RelPoint(Vec2 { x: 0.0, y: 0.5 }).into(),
66                        ..Default::default()
67                    }),
68                    text: format!("Clicks: {}", args.count),
69                    font_size: 40.0,
70                    line_height: 56.0,
71                    ..Default::default()
72                };
73
74                let rect = Shape::<DRect, { ShapeKind::RoundRect as u8 }>::new(
75                    gen_id!(),
76                    feather_ui::FILL_DRECT.into(),
77                    0.0,
78                    0.0,
79                    Vec4::broadcast(10.0),
80                    sRGB::new(0.2, 0.7, 0.4, 1.0),
81                    sRGB::transparent(),
82                );
83
84                Button::<FixedData>::new(
85                    gen_id!(),
86                    FixedData {
87                        area: URect {
88                            abs: AbsRect::new(45.0, 45.0, 0.0, 0.0),
89                            rel: RelRect::new(0.0, 0.0, UNSIZED_AXIS, 1.0),
90                        }
91                        .into(),
92                        ..Default::default()
93                    },
94                    Slot(feather_ui::APP_SOURCE_ID.into(), 0),
95                    feather_ui::children![fixed::Prop, rect, text],
96                )
97            };
98
99            let fakebutton = {
100                let text = Text::<FixedData> {
101                    id: gen_id!(),
102                    props: Rc::new(FixedData {
103                        area: RelRect::new(0.5, 0.0, UNSIZED_AXIS, UNSIZED_AXIS).into(),
104                        limits: feather_ui::AbsLimits::new(
105                            Vec2::new(f32::NEG_INFINITY, 10.0),
106                            Vec2::new(f32::INFINITY, 200.0),
107                        )
108                        .into(),
109                        rlimits: feather_ui::RelLimits::new(
110                            Vec2::new(f32::NEG_INFINITY, f32::NEG_INFINITY),
111                            Vec2::new(1.0, f32::INFINITY),
112                        ),
113                        anchor: feather_ui::RelPoint(Vec2 { x: 0.5, y: 0.0 }).into(),
114                        padding: AbsRect::new(8.0, 8.0, 8.0, 8.0).into(),
115                        ..Default::default()
116                    }),
117                    text: (0..args.count).map(|_| "█").collect::<String>(),
118                    font_size: 40.0,
119                    line_height: 56.0,
120                    wrap: feather_ui::cosmic_text::Wrap::WordOrGlyph,
121                    ..Default::default()
122                };
123
124                let rect = Shape::<DRect, { ShapeKind::RoundRect as u8 }>::new(
125                    gen_id!(),
126                    feather_ui::FILL_DRECT.into(),
127                    0.0,
128                    0.0,
129                    Vec4::broadcast(10.0),
130                    sRGB::new(0.7, 0.2, 0.4, 1.0),
131                    sRGB::transparent(),
132                );
133
134                Button::<FixedData>::new(
135                    gen_id!(),
136                    FixedData {
137                        area: URect {
138                            abs: AbsRect::new(45.0, 245.0, 0.0, 0.0),
139                            rel: RelRect::new(0.0, 0.0, UNSIZED_AXIS, UNSIZED_AXIS),
140                        }
141                        .into(),
142                        limits: feather_ui::AbsLimits::new(
143                            Vec2::new(100.0, f32::NEG_INFINITY),
144                            Vec2::new(300.0, f32::INFINITY),
145                        )
146                        .into(),
147                        ..Default::default()
148                    },
149                    Slot(feather_ui::APP_SOURCE_ID.into(), 0),
150                    feather_ui::children![fixed::Prop, rect, text],
151                )
152            };
153
154            let pixel = Shape::<DRect, { ShapeKind::RoundRect as u8 }>::new(
155                gen_id!(),
156                Rc::new(DRect {
157                    px: AbsRect::new(1.0, 1.0, 2.0, 2.0),
158                    dp: ZERO_RECT,
159                    rel: ZERO_RELRECT,
160                }),
161                0.0,
162                0.0,
163                Vec4::broadcast(0.0),
164                sRGB::new(1.0, 1.0, 1.0, 1.0),
165                sRGB::transparent(),
166            );
167
168            let region = Region::new(
169                gen_id!(),
170                FixedData {
171                    area: URect {
172                        abs: AbsRect::new(90.0, 90.0, 0.0, 200.0),
173                        rel: RelRect::new(0.0, 0.0, UNSIZED_AXIS, 0.0),
174                    }
175                    .into(),
176                    zindex: 0,
177                    ..Default::default()
178                }
179                .into(),
180                feather_ui::children![fixed::Prop, button, fakebutton, pixel],
181            );
182            let window = Window::new(
183                gen_id!(),
184                winit::window::Window::default_attributes()
185                    .with_title(env!("CARGO_CRATE_NAME"))
186                    .with_resizable(true),
187                Box::new(region),
188            );
189
190            store.1 = im::HashMap::new();
191            store.1.insert(window.id.clone(), Some(window));
192            store.0 = args.clone();
193        }
194        let windows = store.1.clone();
195        (store, windows)
196    }
Source

pub fn min(&self) -> Vec2

Source

pub fn max(&self) -> Vec2

Trait Implementations§

Source§

impl Add for AbsLimits

Source§

type Output = AbsLimits

The resulting type after applying the + operator.
Source§

fn add(self, rhs: AbsLimits) -> Self::Output

Performs the + operation. Read more
Source§

impl Clone for AbsLimits

Source§

fn clone(&self) -> AbsLimits

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AbsLimits

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for AbsLimits

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<AbsLimits> for DLimits

Source§

fn from(value: AbsLimits) -> Self

Converts to this type from the input type.
Source§

impl Copy for AbsLimits

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> MaybeSend for T

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,