pub struct DomainPoint<T: Prop + 'static> {
pub id: Arc<SourceID>,
/* private fields */
}
Fields§
§id: Arc<SourceID>
Implementations§
Source§impl<T: Prop + 'static> DomainPoint<T>
impl<T: Prop + 'static> DomainPoint<T>
Sourcepub fn new(id: Arc<SourceID>, props: T) -> Self
pub fn new(id: Arc<SourceID>, props: T) -> Self
Examples found in repository?
examples/graph-rs.rs (line 81)
66 fn call(
67 &mut self,
68 mut store: Self::Store,
69 args: &GraphState,
70 ) -> (Self::Store, im::HashMap<Arc<SourceID>, Option<Window>>) {
71 if store.0 != *args {
72 let mut children: im::Vector<Option<Box<ChildOf<dyn fixed::Prop>>>> = im::Vector::new();
73 let domain: Arc<CrossReferenceDomain> = Default::default();
74
75 let mut node_ids: Vec<Arc<SourceID>> = Vec::new();
76
77 for i in 0..args.nodes.len() {
78 let node = args.nodes[i];
79 const BASE: sRGB = sRGB::new(0.2, 0.7, 0.4, 1.0);
80
81 let point = DomainPoint::new(gen_id!(), domain.clone());
82 node_ids.push(point.id.clone());
83
84 let circle = Shape::<DRect, { ShapeKind::Circle as u8 }>::new(
85 gen_id!(),
86 FILL_DRECT.into(),
87 0.0,
88 0.0,
89 Vec2::new(0.0, 20.0),
90 if args.selected == Some(i) {
91 sRGB::new(0.7, 1.0, 0.8, 1.0)
92 } else {
93 BASE
94 },
95 BASE,
96 );
97
98 let bag = Region::<MinimalArea>::new(
99 gen_id!(gen_id!(), i),
100 MinimalArea {
101 area: AbsRect::new(
102 node.x - NODE_RADIUS,
103 node.y - NODE_RADIUS,
104 node.x + NODE_RADIUS,
105 node.y + NODE_RADIUS,
106 )
107 .into(),
108 }
109 .into(),
110 feather_ui::children![fixed::Prop, point, circle],
111 );
112
113 children.push_back(Some(Box::new(bag)));
114 }
115
116 let edge_id = gen_id!();
117
118 for (a, b) in &args.edges {
119 let line = DomainLine::<()> {
120 id: edge_id
121 .child(DataID::Int(*a as i64))
122 .child(DataID::Int(*b as i64)),
123 fill: sRGB::white(),
124 domain: domain.clone(),
125 start: node_ids[*a].clone(),
126 end: node_ids[*b].clone(),
127 props: ().into(),
128 };
129
130 children.push_back(Some(Box::new(line)));
131 }
132
133 let subregion = Region::new(
134 gen_id!(),
135 MinimalArea {
136 area: AbsRect::new(
137 args.offset.x,
138 args.offset.y,
139 args.offset.x + 10000.0,
140 args.offset.y + 10000.0,
141 )
142 .into(),
143 }
144 .into(),
145 children,
146 );
147
148 let mousearea: MouseArea<MinimalArea> = MouseArea::new(
149 gen_id!(),
150 MinimalArea { area: FILL_DRECT },
151 Some(4.0),
152 [
153 Some(Slot(feather_ui::APP_SOURCE_ID.into(), 0)),
154 Some(Slot(feather_ui::APP_SOURCE_ID.into(), 0)),
155 Some(Slot(feather_ui::APP_SOURCE_ID.into(), 0)),
156 None,
157 None,
158 None,
159 ],
160 );
161
162 let region = Region::new(
163 gen_id!(),
164 MinimalArea { area: FILL_DRECT }.into(),
165 feather_ui::children![fixed::Prop, subregion, mousearea],
166 );
167
168 let window = Window::new(
169 gen_id!(),
170 feather_ui::winit::window::Window::default_attributes()
171 .with_title(env!("CARGO_CRATE_NAME"))
172 .with_resizable(true),
173 Box::new(region),
174 );
175
176 store.1 = im::HashMap::new();
177 store.1.insert(window.id.clone(), Some(window));
178 store.0 = args.clone();
179 }
180 let windows = store.1.clone();
181 (store, windows)
182 }
Trait Implementations§
Source§impl<T: Prop + 'static> Clone for DomainPoint<T>
impl<T: Prop + 'static> Clone for DomainPoint<T>
Source§impl<T: Prop + 'static> Component for DomainPoint<T>
impl<T: Prop + 'static> Component for DomainPoint<T>
Source§impl<T: Prop + 'static> StateMachineChild for DomainPoint<T>
impl<T: Prop + 'static> StateMachineChild for DomainPoint<T>
Auto Trait Implementations§
impl<T> Freeze for DomainPoint<T>
impl<T> !RefUnwindSafe for DomainPoint<T>
impl<T> !Send for DomainPoint<T>
impl<T> !Sync for DomainPoint<T>
impl<T> Unpin for DomainPoint<T>
impl<T> !UnwindSafe for DomainPoint<T>
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<U, C> ComponentWrap<U> for C
impl<U, C> ComponentWrap<U> for C
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> 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