1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
use super::*;
pub trait Widgets<E>: Sized + 'static where E: Env {
fn widget<'a>(&'a self, i: E::WidgetPath) -> Result<Resolved<'a,E>,()>;
#[inline]
fn widget_mut<'a>(&'a mut self, i: E::WidgetPath) -> Result<ResolvedMut<'a,E>,()> {
self._widget_mut(i,true)
}
fn _widget_mut<'a>(&'a mut self, i: E::WidgetPath, invalidate: bool) -> Result<ResolvedMut<'a,E>,()>;
#[inline]
fn has_widget(&self, i: E::WidgetPath) -> bool {
self.widget(i).is_ok()
}
fn trace_bounds(&self, ctx: &mut E::Context, i: E::WidgetPath, b: &Bounds, force: bool) -> Result<Bounds,()>;
#[deprecated] #[inline] fn tune_path(&self, _i: &mut E::WidgetPath) {}
#[deprecated] #[inline] fn tune_path_mut(&mut self, _i: &mut E::WidgetPath) {}
#[inline]
fn with_env<F: Env<Storage=Self>>(&self) -> &F::Storage where Self: Widgets<F> {
&self
}
}
#[doc(hidden)]
pub fn resolve_in_root<'l:'s,'s,E: Env>(w: &'s dyn Widget<'l,E>, p: E::WidgetPath) -> Result<(WidgetRef<'s,E>,E::WidgetPath),()> {
let r = w.resolve(p.refc())?;
match r {
Resolvable::Widget(w) =>
Ok(
(w,From::from(p))
),
Resolvable::Path(p) => resolve_in_root(w,p),
}
}
#[doc(hidden)]
pub fn resolve_in_root_mut<'l:'s,'s,E: Env>(w: &'s mut dyn WidgetMut<'l,E>, p: E::WidgetPath, invalidate: bool) -> Result<(WidgetRefMut<'s,E>,E::WidgetPath),()> {
let final_path = resolve_in_root::<E>(w.base(),p)
.map(|e| e.1 )?;
Ok((
w.resolve_mut(final_path.refc(),invalidate)
.unwrap()
.as_widget()
.unwrap_nodebug(),
final_path
))
}