pub struct AbsLimits(/* private fields */);
Implementations§
Source§impl AbsLimits
impl AbsLimits
Sourcepub const fn new(min: Vec2, max: Vec2) -> Self
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 }
pub fn min(&self) -> Vec2
pub fn max(&self) -> Vec2
Trait Implementations§
impl Copy for AbsLimits
Auto Trait Implementations§
impl Freeze for AbsLimits
impl RefUnwindSafe for AbsLimits
impl Send for AbsLimits
impl Sync for AbsLimits
impl Unpin for AbsLimits
impl UnwindSafe for AbsLimits
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
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>
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)
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)
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
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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