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