diff --git a/src/widget/imp.rs b/src/widget/imp.rs index dcbef5ea..0b1a6e1a 100644 --- a/src/widget/imp.rs +++ b/src/widget/imp.rs @@ -45,8 +45,8 @@ impl<'i,E> Widget for AWidget<'i,E> where E: Env { match_view!(self|s| s.id() ) } #[inline] - fn childs(&self) -> usize { - match_view!(self|s| s.childs() ) + fn childs(&self, own_path: E::WidgetPath) -> usize { + match_view!(self|s| s.childs(own_path) ) } #[inline] fn focusable(&self) -> bool { @@ -86,27 +86,27 @@ impl<'i,E> Widget for AWidget<'i,E> where E: Env { match_view!(self|s| s._size(l,e) ) } #[inline] - fn child<'s>(&'s self, i: usize) -> Result,()> { - match_view!(self|s| s.child(i) ) + fn child<'s>(&'s self, i: usize, own_path: E::WidgetPath) -> Result,()> { + match_view!(self|s| s.child(i,own_path) ) } #[inline] fn child_paths(&self, own_path: E::WidgetPath) -> Vec { match_view!(self|s| s.child_paths(own_path) ) } #[inline] - fn into_child<'s>(self: Box, i: usize) -> Result,()> where Self: 's { + fn into_child<'s>(self: Box, i: usize, own_path: E::WidgetPath) -> Result,()> where Self: 's { match *self { - Self::Ref(s) => s.child(i), - Self::Mut(s) => s.child(i), - Self::Box(s) => s.into_child(i), + Self::Ref(s) => s.child(i,own_path), + Self::Mut(s) => s.child(i,own_path), + Self::Box(s) => s.into_child(i,own_path), } } #[inline] - fn into_childs<'w>(self: Box) -> Vec> where Self: 'w { + fn into_childs<'w>(self: Box, own_path: E::WidgetPath) -> Vec> where Self: 'w { match *self { - Self::Ref(s) => s.childs_ref(), - Self::Mut(s) => s.childs_ref(), - Self::Box(s) => s.into_childs(), + Self::Ref(s) => s.childs_ref(own_path), + Self::Mut(s) => s.childs_ref(own_path), + Self::Box(s) => s.into_childs(own_path), } } #[inline] @@ -114,24 +114,24 @@ impl<'i,E> Widget for AWidget<'i,E> where E: Env { match_view!(self|s| s.child_bounds(l,b,e,force) ) } #[inline] - fn childs_ref<'s>(&'s self) -> Vec> { - match_view!(self|s| s.childs_ref() ) + fn childs_ref<'s>(&'s self, own_path: E::WidgetPath) -> Vec> { + match_view!(self|s| s.childs_ref(own_path) ) } #[inline] - fn resolve<'s>(&'s self, i: E::WidgetPath) -> Result,E::Error> { - match_view!(self|s| s.resolve(i) ) + fn resolve<'s>(&'s self, i: E::WidgetPath, own_path: E::WidgetPath) -> Result,E::Error> { + match_view!(self|s| s.resolve(i,own_path) ) } #[inline] - fn into_resolve<'w>(self: Box, i: E::WidgetPath) -> Result,E::Error> where Self: 'w { + fn into_resolve<'w>(self: Box, i: E::WidgetPath, own_path: E::WidgetPath) -> Result,E::Error> where Self: 'w { match *self { - Self::Ref(s) => s.resolve(i), - Self::Mut(s) => s.resolve(i), - Self::Box(s) => s.into_resolve(i), + Self::Ref(s) => s.resolve(i,own_path), + Self::Mut(s) => s.resolve(i,own_path), + Self::Box(s) => s.into_resolve(i,own_path), } } #[inline] - fn resolve_child(&self, sub_path: &E::WidgetPath) -> Result<(usize,E::WidgetPath),E::Error> { //TODO descriptive struct like ResolvesThruResult instead confusing tuple - match_view!(self|s| s.resolve_child(sub_path) ) + fn resolve_child(&self, sub_path: E::WidgetPath, own_path: E::WidgetPath) -> Result<(usize,E::WidgetPath),E::Error> { //TODO descriptive struct like ResolvesThruResult instead confusing tuple + match_view!(self|s| s.resolve_child(sub_path,own_path) ) } #[inline] fn trace_bounds(&self, l: Link, i: E::WidgetPath, b: &Bounds, e: &EStyle, force: bool) -> Result { @@ -175,8 +175,8 @@ impl<'i,E> Widget for AWidget<'i,E> where E: Env { } } #[inline] - fn gen_diag_error_resolve_fail(&self, sub_path: &E::WidgetPath, op: &'static str) -> E::Error { - match_view!(self|s| s.gen_diag_error_resolve_fail(sub_path,op) ) + fn gen_diag_error_resolve_fail(&self, sub_path: &E::WidgetPath, own_path: E::WidgetPath, op: &'static str) -> E::Error { + match_view!(self|s| s.gen_diag_error_resolve_fail(sub_path,own_path,op) ) } } @@ -186,8 +186,8 @@ impl<'i,E> Widget for AWidgetMut<'i,E> where E: Env { match_mut!(self|s| s.id() ) } #[inline] - fn childs(&self) -> usize { - match_mut!(self|s| s.childs() ) + fn childs(&self, own_path: E::WidgetPath) -> usize { + match_mut!(self|s| s.childs(own_path) ) } #[inline] fn focusable(&self) -> bool { @@ -227,25 +227,25 @@ impl<'i,E> Widget for AWidgetMut<'i,E> where E: Env { match_mut!(self|s| s._size(l,e) ) } #[inline] - fn child<'s>(&'s self, i: usize) -> Result,()> { - match_mut!(self|s| s.child(i) ) + fn child<'s>(&'s self, i: usize, own_path: E::WidgetPath) -> Result,()> { + match_mut!(self|s| s.child(i,own_path) ) } #[inline] fn child_paths(&self, own_path: E::WidgetPath) -> Vec { match_mut!(self|s| s.child_paths(own_path) ) } #[inline] - fn into_child<'s>(self: Box, i: usize) -> Result,()> where Self: 's { + fn into_child<'s>(self: Box, i: usize, own_path: E::WidgetPath) -> Result,()> where Self: 's { match *self { - Self::Mut(s) => s.child(i), - Self::Box(s) => s.into_child(i), + Self::Mut(s) => s.child(i,own_path), + Self::Box(s) => s.into_child(i,own_path), } } #[inline] - fn into_childs<'w>(self: Box) -> Vec> where Self: 'w { + fn into_childs<'w>(self: Box, own_path: E::WidgetPath) -> Vec> where Self: 'w { match *self { - Self::Mut(s) => s.childs_ref(), - Self::Box(s) => s.into_childs(), + Self::Mut(s) => s.childs_ref(own_path), + Self::Box(s) => s.into_childs(own_path), } } #[inline] @@ -253,23 +253,23 @@ impl<'i,E> Widget for AWidgetMut<'i,E> where E: Env { match_mut!(self|s| s.child_bounds(l,b,e,force) ) } #[inline] - fn childs_ref<'s>(&'s self) -> Vec> { - match_mut!(self|s| s.childs_ref() ) + fn childs_ref<'s>(&'s self, own_path: E::WidgetPath) -> Vec> { + match_mut!(self|s| s.childs_ref(own_path) ) } #[inline] - fn resolve<'s>(&'s self, i: E::WidgetPath) -> Result,E::Error> { - match_mut!(self|s| s.resolve(i) ) + fn resolve<'s>(&'s self, i: E::WidgetPath, own_path: E::WidgetPath) -> Result,E::Error> { + match_mut!(self|s| s.resolve(i,own_path) ) } #[inline] - fn into_resolve<'w>(self: Box, i: E::WidgetPath) -> Result,E::Error> where Self: 'w { + fn into_resolve<'w>(self: Box, i: E::WidgetPath, own_path: E::WidgetPath) -> Result,E::Error> where Self: 'w { match *self { - Self::Mut(s) => s.resolve(i), - Self::Box(s) => s.into_resolve(i), + Self::Mut(s) => s.resolve(i,own_path), + Self::Box(s) => s.into_resolve(i,own_path), } } #[inline] - fn resolve_child(&self, sub_path: &E::WidgetPath) -> Result<(usize,E::WidgetPath),E::Error> { //TODO descriptive struct like ResolvesThruResult instead confusing tuple - match_mut!(self|s| s.resolve_child(sub_path) ) + fn resolve_child(&self, sub_path: E::WidgetPath, own_path: E::WidgetPath) -> Result<(usize,E::WidgetPath),E::Error> { //TODO descriptive struct like ResolvesThruResult instead confusing tuple + match_mut!(self|s| s.resolve_child(sub_path,own_path) ) } #[inline] fn trace_bounds(&self, l: Link, i: E::WidgetPath, b: &Bounds, e: &EStyle, force: bool) -> Result { @@ -312,32 +312,32 @@ impl<'i,E> Widget for AWidgetMut<'i,E> where E: Env { } } #[inline] - fn gen_diag_error_resolve_fail(&self, sub_path: &E::WidgetPath, op: &'static str) -> E::Error { - match_mut!(self|s| s.gen_diag_error_resolve_fail(sub_path,op) ) + fn gen_diag_error_resolve_fail(&self, sub_path: &E::WidgetPath, own_path: E::WidgetPath, op: &'static str) -> E::Error { + match_mut!(self|s| s.gen_diag_error_resolve_fail(sub_path,own_path,op) ) } } impl<'i,E> WidgetMut for AWidgetMut<'i,E> where E: Env { #[inline] - fn child_mut<'s>(&'s mut self, i: usize) -> Result,()> { - match_mut!(self|s| s.child_mut(i) ) + fn child_mut<'s>(&'s mut self, i: usize, own_path: E::WidgetPath) -> Result,()> { + match_mut!(self|s| s.child_mut(i,own_path) ) } #[inline] - fn into_child_mut<'w>(self: Box, i: usize) -> Result,()> where Self: 'w { + fn into_child_mut<'w>(self: Box, i: usize, own_path: E::WidgetPath) -> Result,()> where Self: 'w { match *self { - Self::Mut(s) => s.child_mut(i), - Self::Box(s) => s.into_child_mut(i), + Self::Mut(s) => s.child_mut(i,own_path), + Self::Box(s) => s.into_child_mut(i,own_path), } } #[inline] - fn childs_mut<'s>(&'s mut self) -> Vec> { - match_mut!(self|s| s.childs_mut() ) + fn childs_mut<'s>(&'s mut self, own_path: E::WidgetPath) -> Vec> { + match_mut!(self|s| s.childs_mut(own_path) ) } #[inline] - fn into_childs_mut<'w>(self: Box) -> Vec> where Self: 'w { + fn into_childs_mut<'w>(self: Box, own_path: E::WidgetPath) -> Vec> where Self: 'w { match *self { - Self::Mut(s) => s.childs_mut(), - Self::Box(s) => s.into_childs_mut(), + Self::Mut(s) => s.childs_mut(own_path), + Self::Box(s) => s.into_childs_mut(own_path), } } #[inline] @@ -349,19 +349,19 @@ impl<'i,E> WidgetMut for AWidgetMut<'i,E> where E: Env { match_mut!(self|s| s._set_invalid(v) ) } #[inline] - fn resolve_mut<'s>(&'s mut self, i: E::WidgetPath) -> Result,E::Error> { //TODO eventually use reverse "dont_invaldiate"/"keep_valid" bool - match_mut!(self|s| s.resolve_mut(i) ) + fn resolve_mut<'s>(&'s mut self, i: E::WidgetPath, own_path: E::WidgetPath) -> Result,E::Error> { //TODO eventually use reverse "dont_invaldiate"/"keep_valid" bool + match_mut!(self|s| s.resolve_mut(i,own_path) ) } #[inline] - fn into_resolve_mut<'w>(self: Box, i: E::WidgetPath) -> Result,E::Error> where Self: 'w { + fn into_resolve_mut<'w>(self: Box, i: E::WidgetPath, own_path: E::WidgetPath) -> Result,E::Error> where Self: 'w { match *self { - Self::Mut(s) => s.resolve_mut(i), - Self::Box(s) => s.into_resolve_mut(i), + Self::Mut(s) => s.resolve_mut(i,own_path), + Self::Box(s) => s.into_resolve_mut(i,own_path), } } #[inline] - fn resolve_child_mut(&mut self, sub_path: &E::WidgetPath) -> Result<(usize,E::WidgetPath),E::Error> { //TODO descriptive struct like ResolvesThruResult instead confusing tuple - match_mut!(self|s| s.resolve_child_mut(sub_path) ) + fn resolve_child_mut(&mut self, sub_path: E::WidgetPath, own_path: E::WidgetPath) -> Result<(usize,E::WidgetPath),E::Error> { //TODO descriptive struct like ResolvesThruResult instead confusing tuple + match_mut!(self|s| s.resolve_child_mut(sub_path,own_path) ) } #[inline] fn inner_mut(&mut self) -> Option<&mut dyn WidgetMut> { @@ -396,8 +396,8 @@ impl<'i,E> WidgetMut for AWidgetMut<'i,E> where E: Env { } } #[inline] - fn gen_diag_error_resolve_fail_mut(&mut self, sub_path: &E::WidgetPath, op: &'static str) -> E::Error { - match_mut!(self|s| s.gen_diag_error_resolve_fail_mut(sub_path,op) ) + fn gen_diag_error_resolve_fail_mut(&mut self, sub_path: &E::WidgetPath, own_path: E::WidgetPath, op: &'static str) -> E::Error { + match_mut!(self|s| s.gen_diag_error_resolve_fail_mut(sub_path,own_path,op) ) } } @@ -412,27 +412,27 @@ impl<'i,E> AWidget<'i,E> where E: Env { } #[inline] - pub fn into_child<'s>(self, i: usize) -> Result,()> where Self: 's { + pub fn into_child<'s>(self, i: usize, own_path: E::WidgetPath) -> Result,()> where Self: 's { match self { - Self::Ref(s) => s.child(i), - Self::Mut(s) => s.child(i), - Self::Box(s) => s.into_child(i), + Self::Ref(s) => s.child(i,own_path), + Self::Mut(s) => s.child(i,own_path), + Self::Box(s) => s.into_child(i,own_path), } } #[inline] - pub fn into_childs<'w>(self) -> Vec> where Self: 'w { + pub fn into_childs<'w>(self, own_path: E::WidgetPath) -> Vec> where Self: 'w { match self { - Self::Ref(s) => s.childs_ref(), - Self::Mut(s) => s.childs_ref(), - Self::Box(s) => s.into_childs(), + Self::Ref(s) => s.childs_ref(own_path), + Self::Mut(s) => s.childs_ref(own_path), + Self::Box(s) => s.into_childs(own_path), } } #[inline] - pub fn into_resolve<'w>(self, i: E::WidgetPath) -> Result,E::Error> where Self: 'w { + pub fn into_resolve<'w>(self, i: E::WidgetPath, own_path: E::WidgetPath) -> Result,E::Error> where Self: 'w { match self { - Self::Ref(s) => s.resolve(i), - Self::Mut(s) => s.resolve(i), - Self::Box(s) => s.into_resolve(i), + Self::Ref(s) => s.resolve(i,own_path), + Self::Mut(s) => s.resolve(i,own_path), + Self::Box(s) => s.into_resolve(i,own_path), } } } @@ -447,24 +447,24 @@ impl<'i,E> AWidgetMut<'i,E> where E: Env { } #[inline] - pub fn into_child_mut<'w>(self, i: usize) -> Result,()> where Self: 'w { + pub fn into_child_mut<'w>(self, i: usize, own_path: E::WidgetPath) -> Result,()> where Self: 'w { match self { - Self::Mut(s) => s.child_mut(i), - Self::Box(s) => s.into_child_mut(i), + Self::Mut(s) => s.child_mut(i,own_path), + Self::Box(s) => s.into_child_mut(i,own_path), } } #[inline] - pub fn into_childs_mut<'w>(self) -> Vec> where Self: 'w { + pub fn into_childs_mut<'w>(self, own_path: E::WidgetPath) -> Vec> where Self: 'w { match self { - Self::Mut(s) => s.childs_mut(), - Self::Box(s) => s.into_childs_mut(), + Self::Mut(s) => s.childs_mut(own_path), + Self::Box(s) => s.into_childs_mut(own_path), } } #[inline] - pub fn into_resolve_mut<'w>(self, i: E::WidgetPath) -> Result,E::Error> where Self: 'w { + pub fn into_resolve_mut<'w>(self, i: E::WidgetPath, own_path: E::WidgetPath) -> Result,E::Error> where Self: 'w { match self { - Self::Mut(s) => s.resolve_mut(i), - Self::Box(s) => s.into_resolve_mut(i), + Self::Mut(s) => s.resolve_mut(i,own_path), + Self::Box(s) => s.into_resolve_mut(i,own_path), } } } diff --git a/src/widget/link/mod.rs b/src/widget/link/mod.rs index 8d07a5e1..722cce27 100644 --- a/src/widget/link/mod.rs +++ b/src/widget/link/mod.rs @@ -298,7 +298,7 @@ impl<'c,E> Link<'c,E> where E: Env { pub fn resolve_sub<'s>(&'s mut self, sub: &E::WidgetPath) -> Result,E::Error> where 'c: 's { let path = self.widget.path.refc().attached_subpath(sub); - let rw = self.widget.wref.resolve(sub.refc())?; + let rw = self.widget.resolve(sub.refc())?; let mut r; match rw { diff --git a/src/widget/mod.rs b/src/widget/mod.rs index a79eb455..93326d7e 100644 --- a/src/widget/mod.rs +++ b/src/widget/mod.rs @@ -46,27 +46,27 @@ pub trait Widget: WBase where E: Env + 'static { fn _size(&self, l: Link, e: &EStyle) -> ESize; /// ![CHILDS](https://img.shields.io/badge/-childs-000?style=flat-square) - fn childs(&self) -> usize; + fn childs(&self, own_path: E::WidgetPath) -> usize; /// ![CHILDS](https://img.shields.io/badge/-childs-000?style=flat-square) - fn child<'s>(&'s self, i: usize) -> Result,()>; + fn child<'s>(&'s self, i: usize, own_path: E::WidgetPath) -> Result,()>; /// ![CHILDS](https://img.shields.io/badge/-childs-000?style=flat-square) - fn into_child<'s>(self: Box, i: usize) -> Result,()> where Self: 's; + fn into_child<'s>(self: Box, i: usize, own_path: E::WidgetPath) -> Result,()> where Self: 's; /// ![CHILDS](https://img.shields.io/badge/-childs-000?style=flat-square) #[deprecated] - fn childs_ref<'s>(&'s self) -> Vec> { - (0..self.childs()) - .map(#[inline] |i| self.child(i).unwrap() ) + fn childs_ref<'s>(&'s self, own_path: E::WidgetPath) -> Vec> { + (0..self.childs(own_path.clone())) + .map(#[inline] |i| self.child(i,own_path.clone()).unwrap() ) .collect::>() } /// ![CHILDS](https://img.shields.io/badge/-childs-000?style=flat-square) - fn into_childs<'w>(self: Box) -> Vec> where Self: 'w; + fn into_childs<'w>(self: Box, own_path: E::WidgetPath) -> Vec> where Self: 'w; /// ![CHILDS](https://img.shields.io/badge/-childs-000?style=flat-square) #[deprecated] fn child_paths(&self, own_path: E::WidgetPath) -> Vec { - (0..self.childs()) - .map(#[inline] |i| self.child(i).unwrap().in_parent_path(own_path.refc(),todo!("TODO")) ) + (0..self.childs(own_path.clone())) + .map(#[inline] |i| self.child(i,own_path.clone()).unwrap().in_parent_path(own_path.refc(),todo!("TODO")) ) .collect::>() } @@ -77,12 +77,14 @@ pub trait Widget: WBase where E: Env + 'static { /// /// ![USER](https://img.shields.io/badge/-user-0077ff?style=flat-square) generally not used directly, but through [`Widgets::widget`] #[inline] - fn resolve<'s>(&'s self, i: E::WidgetPath) -> Result,E::Error> { + fn resolve<'s>(&'s self, i: E::WidgetPath, own_path: E::WidgetPath) -> Result,E::Error> { if i.is_empty() { return Ok(Resolvable::Widget(self.box_ref())) } - let (c,sub) = self.resolve_child(&i)?; - self.child(c).unwrap().resolve_child(sub) + let (c,sub) = self.resolve_child(i,own_path.clone())?; + let child = self.child(c,own_path.clone()).unwrap(); + let child_path = child.in_parent_path(own_path,false); + child.resolve_child(sub,child_path) } /// ![RESOLVING](https://img.shields.io/badge/-resolving-000?style=flat-square) /// Resolve a deep child item by the given relative path @@ -91,12 +93,14 @@ pub trait Widget: WBase where E: Env + 'static { /// /// ![USER](https://img.shields.io/badge/-user-0077ff?style=flat-square) generally not used directly, but through [`Widgets::widget`] #[inline] - fn into_resolve<'w>(self: Box, i: E::WidgetPath) -> Result,E::Error> where Self: 'w { + fn into_resolve<'w>(self: Box, i: E::WidgetPath, own_path: E::WidgetPath) -> Result,E::Error> where Self: 'w { if i.is_empty() { return Ok(Resolvable::Widget(self.box_box())) } - let (c,sub) = self.resolve_child(&i)?; - self.into_child(c).unwrap_nodebug().resolve_child(sub) + let (c,sub) = self.resolve_child(i,own_path.clone())?; + let child = self.into_child(c,own_path.clone()).unwrap_nodebug(); + let child_path = child.in_parent_path(own_path,false); + child.resolve_child(sub,child_path) } /// ![RESOLVING](https://img.shields.io/badge/-resolving-000?style=flat-square) /// To (or through) which child path would the given sub_path resolve? @@ -105,26 +109,28 @@ pub trait Widget: WBase where E: Env + 'static { /// /// ![USER](https://img.shields.io/badge/-user-0077ff?style=flat-square) generally not used directly, but through [`Widgets::widget`] #[inline] - fn resolve_child(&self, sub_path: &E::WidgetPath) -> Result<(usize,E::WidgetPath),E::Error> { //TODO descriptive struct like ResolvesThruResult instead confusing tuple - for c in 0..self.childs() { - if let Some(r) = self.child(c).unwrap().resolved_by_path(sub_path) { + fn resolve_child(&self, sub_path: E::WidgetPath, own_path: E::WidgetPath) -> Result<(usize,E::WidgetPath),E::Error> { //TODO descriptive struct like ResolvesThruResult instead confusing tuple + for c in 0..self.childs(own_path.clone()) { + if let Some(r) = self.child(c,own_path.clone()).unwrap().resolved_by_path(&sub_path) { return Ok((c,r.sub_path)); } } - Err(self.gen_diag_error_resolve_fail(sub_path, "resolve")) + Err(self.gen_diag_error_resolve_fail(&sub_path,own_path, "resolve")) } /// ![LAYOUT](https://img.shields.io/badge/-resolving-000?style=flat-square) #[inline] + #[deprecated] fn trace_bounds(&self, l: Link, i: E::WidgetPath, b: &Bounds, e: &EStyle, force: bool) -> Result { if i.is_empty() { return Ok(*b) } - let (child,_) = self.resolve_child(&i)?; + let (child,_) = self.resolve_child(i,l.path())?; let bounds = self.child_bounds(l,b,e,force)?; Ok(bounds[child]) } /// ![LAYOUT](https://img.shields.io/badge/-resolving-000?style=flat-square) + #[deprecated] fn child_bounds(&self, l: Link, b: &Bounds, e: &EStyle, force: bool) -> Result,()>; /// ![RESOLVING](https://img.shields.io/badge/-resolving-000?style=flat-square) @@ -159,21 +165,21 @@ pub trait Widget: WBase where E: Env + 'static { } /// Determines the next child in this widget in the tabulation step - fn _tabulate_next_child(&self, _l: Link, origin: TabulateNextChildOrigin, dir: TabulateDirection) -> TabulateNextChildResponse { + fn _tabulate_next_child(&self, l: Link, origin: TabulateNextChildOrigin, dir: TabulateDirection) -> TabulateNextChildResponse { match origin { TabulateNextChildOrigin::Enter => match dir { TabulateDirection::Forward if self.focusable() => TabulateNextChildResponse::This, - TabulateDirection::Forward if self.childs() != 0 => TabulateNextChildResponse::Child(0), - TabulateDirection::Backward if self.childs() != 0 => TabulateNextChildResponse::Child(self.childs()-1), + TabulateDirection::Forward if self.childs(l.path()) != 0 => TabulateNextChildResponse::Child(0), + TabulateDirection::Backward if self.childs(l.path()) != 0 => TabulateNextChildResponse::Child(self.childs(l.path())-1), TabulateDirection::Backward if self.focusable() => TabulateNextChildResponse::This, _ => TabulateNextChildResponse::Leave, } TabulateNextChildOrigin::This => match dir { - TabulateDirection::Forward if self.childs() != 0 => TabulateNextChildResponse::Child(0), + TabulateDirection::Forward if self.childs(l.path()) != 0 => TabulateNextChildResponse::Child(0), _ => TabulateNextChildResponse::Leave, } TabulateNextChildOrigin::Child(child_id) => match dir { //assert!(child_id < self.childs()); - TabulateDirection::Forward if child_id < self.childs()-1 => TabulateNextChildResponse::Child(child_id+1), + TabulateDirection::Forward if child_id < self.childs(l.path())-1 => TabulateNextChildResponse::Child(child_id+1), TabulateDirection::Backward if child_id != 0 => TabulateNextChildResponse::Child(child_id-1), TabulateDirection::Backward if self.focusable() => TabulateNextChildResponse::This, _ => TabulateNextChildResponse::Leave, @@ -229,7 +235,7 @@ pub trait Widget: WBase where E: Env + 'static { TabulateOrigin::Resolve(p) => { if !p.is_empty() { // pass 1: resolve to previous focused widget - let (child_id,sub_path) = self.resolve_child(&p)?; + let (child_id,sub_path) = self.resolve_child(p,l.path())?; return enter_child(&mut l, child_id, TabulateOrigin::Resolve(sub_path)); }else{ // pass 2: we are the previous focused widget and should tabulate away @@ -312,7 +318,7 @@ pub trait Widget: WBase where E: Env + 'static { } #[inline(never)] - fn gen_diag_error_resolve_fail(&self, sub_path: &E::WidgetPath, op: &'static str) -> E::Error { + fn gen_diag_error_resolve_fail(&self, sub_path: &E::WidgetPath, own_path: E::WidgetPath, op: &'static str) -> E::Error { /* Failed to resolve 3/5/2 in Pane>> Child #0: 6 Button> @@ -323,8 +329,8 @@ pub trait Widget: WBase where E: Env + 'static { Traitcast(_mut) from Label to ICheckBox not implemented (strip "dyn " prefix) */ let widget_type = self.debugged_type_name(); - let child_info = (0..self.childs()) - .map(#[inline] |i| self.child(i).unwrap().guion_resolve_error_child_info(i) ) + let child_info = (0..self.childs(own_path.clone())) + .map(#[inline] |i| self.child(i,own_path.clone()).unwrap().guion_resolve_error_child_info(i) ) .collect::>(); GuionError::ResolveError(Box::new(ResolveError{ op, @@ -352,15 +358,15 @@ pub trait WidgetMut: Widget + WBaseMut where E: Env + 'static { } /// ![CHILDS](https://img.shields.io/badge/-childs-000?style=flat-square) - fn child_mut<'s>(&'s mut self, i: usize) -> Result,()>; + fn child_mut<'s>(&'s mut self, i: usize, own_path: E::WidgetPath) -> Result,()>; /// ![CHILDS](https://img.shields.io/badge/-childs-000?style=flat-square) - fn into_child_mut<'w>(self: Box, i: usize) -> Result,()> where Self: 'w; + fn into_child_mut<'w>(self: Box, i: usize, own_path: E::WidgetPath) -> Result,()> where Self: 'w; /// ![CHILDS](https://img.shields.io/badge/-childs-000?style=flat-square) #[deprecated] - fn childs_mut<'s>(&'s mut self) -> Vec>; + fn childs_mut<'s>(&'s mut self, own_path: E::WidgetPath) -> Vec>; /// ![CHILDS](https://img.shields.io/badge/-childs-000?style=flat-square) - fn into_childs_mut<'w>(self: Box) -> Vec> where Self: 'w; + fn into_childs_mut<'w>(self: Box, own_path: E::WidgetPath) -> Vec> where Self: 'w; /// ![RESOLVING](https://img.shields.io/badge/-resolving-000?style=flat-square) /// Resolve a deep child item by the given relative path @@ -369,12 +375,14 @@ pub trait WidgetMut: Widget + WBaseMut where E: Env + 'static { /// /// ![USER](https://img.shields.io/badge/-user-0077ff?style=flat-square) generally not used directly, but through [`Widgets::widget`] #[inline] - fn resolve_mut<'s>(&'s mut self, i: E::WidgetPath) -> Result,E::Error> { //TODO eventually use reverse "dont_invaldiate"/"keep_valid" bool + fn resolve_mut<'s>(&'s mut self, i: E::WidgetPath, own_path: E::WidgetPath) -> Result,E::Error> { //TODO eventually use reverse "dont_invaldiate"/"keep_valid" bool if i.is_empty() { return Ok(ResolvableMut::Widget(self.box_mut())) } - let (c,sub) = self.resolve_child_mut(&i)?; - self.child_mut(c).unwrap().resolve_child_mut(sub) + let (c,sub) = self.resolve_child_mut(i,own_path.clone())?; + let child = self.child_mut(c,own_path.clone()).unwrap(); + let child_path = child.in_parent_path(own_path,false); + child.resolve_child_mut(sub,child_path) } /// ![RESOLVING](https://img.shields.io/badge/-resolving-000?style=flat-square) @@ -384,12 +392,14 @@ pub trait WidgetMut: Widget + WBaseMut where E: Env + 'static { /// /// ![USER](https://img.shields.io/badge/-user-0077ff?style=flat-square) generally not used directly, but through [`Widgets::widget`] #[inline] - fn into_resolve_mut<'w>(mut self: Box, i: E::WidgetPath) -> Result,E::Error> where Self: 'w { + fn into_resolve_mut<'w>(mut self: Box, i: E::WidgetPath, own_path: E::WidgetPath) -> Result,E::Error> where Self: 'w { if i.is_empty() { return Ok(ResolvableMut::Widget(self.box_box_mut())) } - let (c,sub) = self.resolve_child_mut(&i)?; - self.into_child_mut(c).unwrap_nodebug().resolve_child_mut(sub) + let (c,sub) = self.resolve_child_mut(i,own_path.clone())?; + let child = self.into_child_mut(c,own_path.clone()).unwrap_nodebug(); + let child_path = child.in_parent_path(own_path,false); + child.resolve_child_mut(sub,child_path) } /// ![RESOLVING](https://img.shields.io/badge/-resolving-000?style=flat-square) @@ -399,13 +409,13 @@ pub trait WidgetMut: Widget + WBaseMut where E: Env + 'static { /// /// ![USER](https://img.shields.io/badge/-user-0077ff?style=flat-square) generally not used directly, but through [`Widgets::widget`] #[inline] - fn resolve_child_mut(&mut self, sub_path: &E::WidgetPath) -> Result<(usize,E::WidgetPath),E::Error> { //TODO descriptive struct like ResolvesThruResult instead confusing tuple - for c in 0..self.childs() { - if let Some(r) = self.child_mut(c).unwrap().resolved_by_path(sub_path) { + fn resolve_child_mut(&mut self, sub_path: E::WidgetPath, own_path: E::WidgetPath) -> Result<(usize,E::WidgetPath),E::Error> { //TODO descriptive struct like ResolvesThruResult instead confusing tuple + for c in 0..self.childs(own_path.clone()) { + if let Some(r) = self.child_mut(c,own_path.clone()).unwrap().resolved_by_path(&sub_path) { return Ok((c,r.sub_path)); } } - Err(self.gen_diag_error_resolve_fail_mut(sub_path,"resolve_mut")) + Err(self.gen_diag_error_resolve_fail_mut(&sub_path,own_path,"resolve_mut")) } #[inline] @@ -457,10 +467,10 @@ pub trait WidgetMut: Widget + WBaseMut where E: Env + 'static { } #[inline(never)] - fn gen_diag_error_resolve_fail_mut(&mut self, sub_path: &E::WidgetPath, op: &'static str) -> E::Error { + fn gen_diag_error_resolve_fail_mut(&mut self, sub_path: &E::WidgetPath, own_path: E::WidgetPath, op: &'static str) -> E::Error { let widget_type = self.debugged_type_name_mut(); - let child_info = (0..self.childs()) - .map(#[inline] |i| self.child_mut(i).unwrap().guion_resolve_error_child_info(i) ) + let child_info = (0..self.childs(own_path.clone())) + .map(#[inline] |i| self.child_mut(i,own_path.clone()).unwrap().guion_resolve_error_child_info(i) ) .collect::>(); GuionError::ResolveError(Box::new(ResolveError{ op, diff --git a/src/widget/resolvable.rs b/src/widget/resolvable.rs index 78b3fdc6..243afd8f 100644 --- a/src/widget/resolvable.rs +++ b/src/widget/resolvable.rs @@ -17,9 +17,9 @@ impl<'w,E> Resolvable<'w,E> where E: Env + 'static { /// /// Meant to be used inside widget's resolve fn #[inline] - pub fn resolve_child(self, sub: E::WidgetPath) -> Result,E::Error> { + pub fn resolve_child(self, sub: E::WidgetPath, own_path: E::WidgetPath) -> Result,E::Error> { match self { - Self::Widget(w) => w.into_resolve(sub), + Self::Widget(w) => w.into_resolve(sub,own_path), Self::Path(p) => Ok(Self::Path(p.attached_subpath(&sub))), } } @@ -95,9 +95,9 @@ impl<'w,E> ResolvableMut<'w,E> where E: Env { /// /// Meant to be used inside widget's resolve fn #[inline] - pub fn resolve_child_mut(self, i: E::WidgetPath) -> Result,E::Error> { + pub fn resolve_child_mut(self, i: E::WidgetPath, own_path: E::WidgetPath) -> Result,E::Error> { match self { - Self::Widget(w) => w.into_resolve_mut(i), + Self::Widget(w) => w.into_resolve_mut(i,own_path), Self::Path(p) => Ok(Self::Path(p.attached_subpath(&i))), } } @@ -125,12 +125,12 @@ impl<'w,E> ResolvableMut<'w,E> where E: Env { } } /// Extend the path representing the parent of this widget to resolve to this widget - #[deprecated] + #[deprecated] //TODO stabilize #[inline] - pub fn in_parent_path(&self, parent: E::WidgetPath) -> E::WidgetPath { + pub fn in_parent_path(&self, parent: E::WidgetPath, reduce: bool) -> E::WidgetPath { match self { Self::Widget(w) => w.in_parent_path(parent), - Self::Path(w) => w.refc().into(), //TODO WRONG use widget's fns + Self::Path(w) => parent.for_child_widget_path(w,reduce) //TODO WRONG use widget's fns } } diff --git a/src/widget/resolved.rs b/src/widget/resolved.rs index eebd4fe5..e44ef4a5 100644 --- a/src/widget/resolved.rs +++ b/src/widget/resolved.rs @@ -85,6 +85,60 @@ impl<'a,E> Resolved<'a,E> where E: Env { } } + /// ![CHILDS](https://img.shields.io/badge/-childs-000?style=flat-square) + pub fn childs(&self) -> usize { + (**self).childs(self.path.clone()) + } + /// ![CHILDS](https://img.shields.io/badge/-childs-000?style=flat-square) + pub fn child<'s>(&'s self, i: usize) -> Result,()> { + (**self).child(i,self.path.clone()) + } + /// ![CHILDS](https://img.shields.io/badge/-childs-000?style=flat-square) + pub fn into_child<'s>(self: Box, i: usize) -> Result,()> where Self: 's { + self.wref.into_child(i,self.path.clone()) + } + + /// ![CHILDS](https://img.shields.io/badge/-childs-000?style=flat-square) + #[deprecated] + pub fn childs_ref<'s>(&'s self) -> Vec> { + (**self).childs_ref(self.path.clone()) + } + /// ![CHILDS](https://img.shields.io/badge/-childs-000?style=flat-square) + pub fn into_childs<'w>(self: Box) -> Vec> where Self: 'w { + self.wref.into_childs(self.path.clone()) + } + + /// ![RESOLVING](https://img.shields.io/badge/-resolving-000?style=flat-square) + /// Resolve a deep child item by the given relative path + /// + /// An empty path will resolve to this widget + /// + /// ![USER](https://img.shields.io/badge/-user-0077ff?style=flat-square) generally not used directly, but through [`Widgets::widget`] + #[inline] + pub fn resolve<'s>(&'s self, i: E::WidgetPath) -> Result,E::Error> { + (**self).resolve(i,self.path.clone()) + } + /// ![RESOLVING](https://img.shields.io/badge/-resolving-000?style=flat-square) + /// Resolve a deep child item by the given relative path + /// + /// An empty path will resolve to this widget + /// + /// ![USER](https://img.shields.io/badge/-user-0077ff?style=flat-square) generally not used directly, but through [`Widgets::widget`] + #[inline] + pub fn into_resolve<'w>(self: Box, i: E::WidgetPath) -> Result,E::Error> where Self: 'w { + self.wref.into_resolve(i,self.path.clone()) + } + /// ![RESOLVING](https://img.shields.io/badge/-resolving-000?style=flat-square) + /// To (or through) which child path would the given sub_path resolve? + /// + /// Returns the child index and the subpath inside the child widget to resolve further + /// + /// ![USER](https://img.shields.io/badge/-user-0077ff?style=flat-square) generally not used directly, but through [`Widgets::widget`] + #[inline] + pub fn resolve_child(&self, sub_path: E::WidgetPath) -> Result<(usize,E::WidgetPath),E::Error> { //TODO descriptive struct like ResolvesThruResult instead confusing tuple + (**self).resolve_child(sub_path,self.path.clone()) + } + /*#[inline] pub fn childs(&self) -> Vec> { (**self)._childs(self.path) diff --git a/src/widget/root.rs b/src/widget/root.rs index 898597da..83977b61 100644 --- a/src/widget/root.rs +++ b/src/widget/root.rs @@ -31,8 +31,8 @@ pub trait Widgets: Sized + 'static where E: Env { } //#[doc(hidden)] /// Used by [`Widgets::widget`] implementations -pub fn resolve_in_root<'l,'s,E>(root: &'s dyn Widget, sub: E::WidgetPath, abs_path: E::WidgetPath, stor: &'l E::Storage) -> Result,E::Error> where E: Env, 'l: 's { - let r = root.resolve(sub.refc())?; +pub fn resolve_in_root<'l,'s,E>(root: &'s dyn Widget, sub: E::WidgetPath, abs_path: E::WidgetPath, root_path: E::WidgetPath, stor: &'l E::Storage) -> Result,E::Error> where E: Env, 'l: 's { + let r = root.resolve(sub.refc(),root_path)?; match r { Resolvable::Widget(w) => @@ -54,13 +54,13 @@ pub fn resolve_in_root<'l,'s,E>(root: &'s dyn Widget, sub: E::WidgetPath, abs pub fn resolve_in_root_mut( stor: &mut E::Storage, mut root_in_stor_mut: impl FnMut(&mut E::Storage) -> &mut dyn WidgetMut, - sub: E::WidgetPath, abs_path: E::WidgetPath, + sub: E::WidgetPath, abs_path: E::WidgetPath, root_path: E::WidgetPath, ) -> Result,E::Error> { let final_path; - match root_in_stor_mut(stor).resolve_mut(sub.clone())? { - ResolvableMut::Widget(w) => + match root_in_stor_mut(stor).resolve_mut(sub.clone(),root_path.clone())? { + ResolvableMut::Widget(_) => final_path = Ok(abs_path.clone()), ResolvableMut::Path(p) => final_path = Err(p), @@ -68,7 +68,7 @@ pub fn resolve_in_root_mut( match final_path { Ok(p) => { - let w = root_in_stor_mut(stor).resolve_mut(sub)? + let w = root_in_stor_mut(stor).resolve_mut(sub,root_path)? .as_widget().unwrap(); Ok(ResolvedMut { wref: w, diff --git a/src/widgets/area/widget.rs b/src/widgets/area/widget.rs index d2d1929a..70d74f4e 100644 --- a/src/widgets/area/widget.rs +++ b/src/widgets/area/widget.rs @@ -93,13 +93,13 @@ impl<'w,E,W,Scroll> Widget for Area<'w,E,W,Scroll> where let e = e.and(&self.style); self.size.clone() } - fn childs(&self) -> usize { + fn childs(&self, _: E::WidgetPath) -> usize { 1 } - fn childs_ref(&self) -> Vec> { + fn childs_ref(&self, _: E::WidgetPath) -> Vec> { vec![self.inner.as_ref()] } - fn into_childs<'a>(self: Box) -> Vec> where Self: 'a { + fn into_childs<'a>(self: Box, _: E::WidgetPath) -> Vec> where Self: 'a { vec![self.inner.into_ref()] } @@ -109,11 +109,11 @@ impl<'w,E,W,Scroll> Widget for Area<'w,E,W,Scroll> where fn focusable(&self) -> bool { false //TODO } - fn child(&self, i: usize) -> Result,()> { + fn child(&self, i: usize, _: E::WidgetPath) -> Result,()> { if i != 0 {return Err(());} Ok(self.inner.as_ref()) } - fn into_child<'a>(self: Box, i: usize) -> Result,()> where Self: 'a { + fn into_child<'a>(self: Box, i: usize, _: E::WidgetPath) -> Result,()> where Self: 'a { if i != 0 {return Err(());} Ok(self.inner.into_ref()) } @@ -131,17 +131,17 @@ impl<'w,E,W,Scroll> WidgetMut for Area<'w,E,W,Scroll> where W: AsWidgetMut+'w, Scroll: AtomStateMut, { - fn childs_mut(&mut self) -> Vec> { + fn childs_mut(&mut self, _: E::WidgetPath) -> Vec> { vec![self.inner.as_mut()] } - fn into_childs_mut<'a>(self: Box) -> Vec> where Self: 'a { + fn into_childs_mut<'a>(self: Box, _: E::WidgetPath) -> Vec> where Self: 'a { vec![self.inner.into_mut()] } - fn child_mut(&mut self, i: usize) -> Result,()> { + fn child_mut(&mut self, i: usize, _: E::WidgetPath) -> Result,()> { if i != 0 {return Err(());} Ok(self.inner.as_mut()) } - fn into_child_mut<'a>(self: Box, i: usize) -> Result,()> where Self: 'a { + fn into_child_mut<'a>(self: Box, i: usize, _: E::WidgetPath) -> Result,()> where Self: 'a { if i != 0 {return Err(());} Ok(self.inner.into_mut()) } diff --git a/src/widgets/button/widget.rs b/src/widgets/button/widget.rs index df040086..e29e59d0 100644 --- a/src/widgets/button/widget.rs +++ b/src/widgets/button/widget.rs @@ -80,13 +80,13 @@ impl<'w,E,Text,Tr,TrMut> Widget for Button<'w,E,Text,Tr,TrMut> where ms.add_border(&e.border(&StdSelectag::::BorderVisual.into_selector(),l.ctx)); ms.max( &self.size ) } - fn childs(&self) -> usize { + fn childs(&self, _: E::WidgetPath) -> usize { 1 } - fn childs_ref(&self) -> Vec> { + fn childs_ref(&self, _: E::WidgetPath) -> Vec> { vec![self.text.as_ref()] } - fn into_childs<'a>(self: Box) -> Vec> where Self: 'a { + fn into_childs<'a>(self: Box, _: E::WidgetPath) -> Vec> where Self: 'a { vec![self.text.into_ref()] } @@ -96,11 +96,11 @@ impl<'w,E,Text,Tr,TrMut> Widget for Button<'w,E,Text,Tr,TrMut> where } fn focusable(&self) -> bool { true } - fn child(&self, i: usize) -> Result,()> { + fn child(&self, i: usize, _: E::WidgetPath) -> Result,()> { if i != 0 {return Err(());} Ok(self.text.as_ref()) } - fn into_child<'a>(self: Box, i: usize) -> Result,()> where Self: 'a { + fn into_child<'a>(self: Box, i: usize, _: E::WidgetPath) -> Result,()> where Self: 'a { if i != 0 {return Err(());} Ok(self.text.into_ref()) } @@ -120,17 +120,17 @@ impl<'w,E,Text,Tr,TrMut> WidgetMut for Button<'w,E,Text,Tr,TrMut> where Tr: Trigger, TrMut: TriggerMut, { - fn childs_mut(&mut self) -> Vec> { + fn childs_mut(&mut self, _: E::WidgetPath) -> Vec> { vec![self.text.as_mut()] } - fn into_childs_mut<'a>(self: Box) -> Vec> where Self: 'a { + fn into_childs_mut<'a>(self: Box, _: E::WidgetPath) -> Vec> where Self: 'a { vec![self.text.into_mut()] } - fn child_mut(&mut self, i: usize) -> Result,()> { + fn child_mut(&mut self, i: usize, _: E::WidgetPath) -> Result,()> { if i != 0 {return Err(());} Ok(self.text.as_mut()) } - fn into_child_mut<'a>(self: Box, i: usize) -> Result,()> where Self: 'a { + fn into_child_mut<'a>(self: Box, i: usize, _: E::WidgetPath) -> Result,()> where Self: 'a { if i != 0 {return Err(());} Ok(self.text.into_mut()) } diff --git a/src/widgets/checkbox/widget.rs b/src/widgets/checkbox/widget.rs index 717f8ecb..a7d7828c 100644 --- a/src/widgets/checkbox/widget.rs +++ b/src/widgets/checkbox/widget.rs @@ -95,13 +95,13 @@ impl<'w,E,State,Text> Widget for CheckBox<'w,E,State,Text> where ms.add_x( &self.size ); ms } - fn childs(&self) -> usize { + fn childs(&self, _: E::WidgetPath) -> usize { 1 } - fn childs_ref(&self) -> Vec> { + fn childs_ref(&self, _: E::WidgetPath) -> Vec> { vec![self.text.as_ref()] } - fn into_childs<'a>(self: Box) -> Vec> where Self: 'a { + fn into_childs<'a>(self: Box, _: E::WidgetPath) -> Vec> where Self: 'a { vec![self.text.into_ref()] } @@ -111,11 +111,11 @@ impl<'w,E,State,Text> Widget for CheckBox<'w,E,State,Text> where } fn focusable(&self) -> bool { true } - fn child(&self, i: usize) -> Result,()> { + fn child(&self, i: usize, _: E::WidgetPath) -> Result,()> { if i != 0 {return Err(());} Ok(self.text.as_ref()) } - fn into_child<'a>(self: Box, i: usize) -> Result,()> where Self: 'a { + fn into_child<'a>(self: Box, i: usize, _: E::WidgetPath) -> Result,()> where Self: 'a { if i != 0 {return Err(());} Ok(self.text.into_ref()) } @@ -134,17 +134,17 @@ impl<'w,E,State,Text> WidgetMut for CheckBox<'w,E,State,Text> where State: AtomStateMut, Text: AsWidgetMut, { - fn childs_mut(&mut self) -> Vec> { + fn childs_mut(&mut self, _: E::WidgetPath) -> Vec> { vec![self.text.as_mut()] } - fn into_childs_mut<'a>(self: Box) -> Vec> where Self: 'a { + fn into_childs_mut<'a>(self: Box, _: E::WidgetPath) -> Vec> where Self: 'a { vec![self.text.into_mut()] } - fn child_mut(&mut self, i: usize) -> Result,()> { + fn child_mut(&mut self, i: usize, _: E::WidgetPath) -> Result,()> { if i != 0 {return Err(());} Ok(self.text.as_mut()) } - fn into_child_mut<'a>(self: Box, i: usize) -> Result,()> where Self: 'a { + fn into_child_mut<'a>(self: Box, i: usize, _: E::WidgetPath) -> Result,()> where Self: 'a { if i != 0 {return Err(());} Ok(self.text.into_mut()) } diff --git a/src/widgets/label/widget.rs b/src/widgets/label/widget.rs index a83138a5..863bcb93 100644 --- a/src/widgets/label/widget.rs +++ b/src/widgets/label/widget.rs @@ -32,13 +32,13 @@ impl<'w,E,Text,GlyphCache> Widget for Label<'w,E,Text,GlyphCache> where let ms = ESize::::fixed(ms.w, ms.h); ms.max( &self.size ) } - fn childs(&self) -> usize { + fn childs(&self, _: E::WidgetPath) -> usize { 0 } - fn childs_ref(&self) -> Vec> { + fn childs_ref(&self, _: E::WidgetPath) -> Vec> { vec![] } - fn into_childs<'a>(self: Box) -> Vec> where Self: 'a { + fn into_childs<'a>(self: Box, _: E::WidgetPath) -> Vec> where Self: 'a { vec![] } @@ -48,10 +48,10 @@ impl<'w,E,Text,GlyphCache> Widget for Label<'w,E,Text,GlyphCache> where fn focusable(&self) -> bool { false } - fn child(&self, _: usize) -> Result,()> { + fn child(&self, _: usize, _: E::WidgetPath) -> Result,()> { Err(()) } - fn into_child<'a>(self: Box, _: usize) -> Result,()> where Self: 'a { + fn into_child<'a>(self: Box, _: usize, _: E::WidgetPath) -> Result,()> where Self: 'a { Err(()) } @@ -69,16 +69,16 @@ impl<'w,E,Text,GlyphCache> WidgetMut for Label<'w,E,Text,GlyphCache> where Text: CaptionMut+ValidationMut+'w, GlyphCache: AtomStateMut>+Clone, { - fn childs_mut(&mut self) -> Vec> { + fn childs_mut(&mut self, _: E::WidgetPath) -> Vec> { vec![] } - fn into_childs_mut<'a>(self: Box) -> Vec> where Self: 'a { + fn into_childs_mut<'a>(self: Box, _: E::WidgetPath) -> Vec> where Self: 'a { vec![] } - fn child_mut(&mut self, _: usize) -> Result,()> { + fn child_mut(&mut self, _: usize, _: E::WidgetPath) -> Result,()> { Err(()) } - fn into_child_mut<'a>(self: Box, _: usize) -> Result,()> where Self: 'a { + fn into_child_mut<'a>(self: Box, _: usize, _: E::WidgetPath) -> Result,()> where Self: 'a { Err(()) } diff --git a/src/widgets/pane/widget.rs b/src/widgets/pane/widget.rs index 8a1b7bbe..53912e7b 100644 --- a/src/widgets/pane/widget.rs +++ b/src/widgets/pane/widget.rs @@ -19,13 +19,13 @@ impl<'w,E,T> Widget for Pane<'w,E,T> where fn child_bounds(&self, l: Link, b: &Bounds, e: &EStyle, force: bool) -> Result,()> { self.child_bounds_impl(l,b,e,force) } - fn childs(&self) -> usize { + fn childs(&self, _: E::WidgetPath) -> usize { self.childs.len() } - fn childs_ref(&self) -> Vec> { + fn childs_ref(&self, _: E::WidgetPath) -> Vec> { self.childs.childs() } - fn into_childs<'a>(self: Box) -> Vec> where Self: 'a { + fn into_childs<'a>(self: Box, _: E::WidgetPath) -> Vec> where Self: 'a { self.childs.into_childs() } @@ -33,10 +33,10 @@ impl<'w,E,T> Widget for Pane<'w,E,T> where false } - fn child(&self, i: usize) -> Result,()> { + fn child(&self, i: usize, _: E::WidgetPath) -> Result,()> { self.childs.child(i) } - fn into_child<'a>(self: Box, i: usize) -> Result,()> where Self: 'a { + fn into_child<'a>(self: Box, i: usize, _: E::WidgetPath) -> Result,()> where Self: 'a { self.childs.into_child(i) } } @@ -48,16 +48,16 @@ impl<'w,E,T> WidgetMut for Pane<'w,E,T> where let _ = v; //self.invalid = true } - fn childs_mut(&mut self) -> Vec> { + fn childs_mut(&mut self, _: E::WidgetPath) -> Vec> { self.childs.childs_mut() } - fn into_childs_mut<'a>(self: Box) -> Vec> where Self: 'a { + fn into_childs_mut<'a>(self: Box, _: E::WidgetPath) -> Vec> where Self: 'a { self.childs.into_childs_mut() } - fn child_mut(&mut self, i: usize) -> Result,()> { + fn child_mut(&mut self, i: usize, _: E::WidgetPath) -> Result,()> { self.childs.child_mut(i) } - fn into_child_mut<'a>(self: Box, i: usize) -> Result,()> where Self: 'a { + fn into_child_mut<'a>(self: Box, i: usize, _: E::WidgetPath) -> Result,()> where Self: 'a { self.childs.into_child_mut(i) } } @@ -74,7 +74,7 @@ impl<'w,E,T> Pane<'w,E,T> where let sizes = l.child_sizes(r.style()).expect("Dead Path Inside Pane"); let bounds = calc_bounds(&r.bounds().size,&sizes,self.orientation); - for i in 0..self.childs() { + for i in 0..self.childs(l.path()) { let l = l.for_child(i).expect("Dead Path Inside Pane"); let mut r = r.slice(&bounds[i]); r.render_widget(l); @@ -92,7 +92,7 @@ impl<'w,E,T> Pane<'w,E,T> where let mut passed = false; - for i in 0..self.childs() { + for i in 0..self.childs(l.path()) { let mut l = l.for_child(i).expect("Dead Path Inside Pane"); let sliced = e.slice_bounds(&bounds[i]); if let Some(ee) = sliced.filter(&l) { diff --git a/src/widgets/pbar/widget.rs b/src/widgets/pbar/widget.rs index 589d6bf9..32fd40a4 100644 --- a/src/widgets/pbar/widget.rs +++ b/src/widgets/pbar/widget.rs @@ -26,13 +26,13 @@ impl<'w,E> Widget for ProgressBar<'w,E> where let e = e.and(&self.style); self.size.clone() } - fn childs(&self) -> usize { + fn childs(&self, _: E::WidgetPath) -> usize { 0 } - fn childs_ref(&self) -> Vec> { + fn childs_ref(&self, _: E::WidgetPath) -> Vec> { vec![] } - fn into_childs<'a>(self: Box) -> Vec> where Self: 'a { + fn into_childs<'a>(self: Box, _: E::WidgetPath) -> Vec> where Self: 'a { vec![] } fn child_bounds(&self, _: Link, _: &Bounds, e: &EStyle, _: bool) -> Result,()> { @@ -41,10 +41,10 @@ impl<'w,E> Widget for ProgressBar<'w,E> where fn focusable(&self) -> bool { false } - fn child(&self, _: usize) -> Result,()> { + fn child(&self, _: usize, _: E::WidgetPath) -> Result,()> { Err(()) } - fn into_child<'a>(self: Box, _: usize) -> Result,()> where Self: 'a { + fn into_child<'a>(self: Box, _: usize, _: E::WidgetPath) -> Result,()> where Self: 'a { Err(()) } @@ -57,16 +57,16 @@ impl<'w,E> WidgetMut for ProgressBar<'w,E> where E: Env, ERenderer: RenderStdWidgets, { - fn childs_mut(&mut self) -> Vec> { + fn childs_mut(&mut self, _: E::WidgetPath) -> Vec> { vec![] } - fn into_childs_mut<'a>(self: Box) -> Vec> where Self: 'a { + fn into_childs_mut<'a>(self: Box, _: E::WidgetPath) -> Vec> where Self: 'a { vec![] } - fn child_mut(&mut self, _: usize) -> Result,()> { + fn child_mut(&mut self, _: usize, _: E::WidgetPath) -> Result,()> { Err(()) } - fn into_child_mut<'a>(self: Box, _: usize) -> Result,()> where Self: 'a { + fn into_child_mut<'a>(self: Box, _: usize, _: E::WidgetPath) -> Result,()> where Self: 'a { Err(()) } diff --git a/src/widgets/splitpane/widget.rs b/src/widgets/splitpane/widget.rs index 97e3de24..22831bdf 100644 --- a/src/widgets/splitpane/widget.rs +++ b/src/widgets/splitpane/widget.rs @@ -124,13 +124,13 @@ impl<'w,E,L,R,V> Widget for SplitPane<'w,E,L,R,V> where fn child_bounds(&self, l: Link, b: &Bounds, e: &EStyle, force: bool) -> Result,()> { Ok(self.calc_bounds(b,self.state.get(l.ctx))) } - fn childs(&self) -> usize { + fn childs(&self, _: E::WidgetPath) -> usize { self.childs.len() } - fn childs_ref(&self) -> Vec> { + fn childs_ref(&self, _: E::WidgetPath) -> Vec> { self.childs.childs() } - fn into_childs<'a>(self: Box) -> Vec> where Self: 'a { + fn into_childs<'a>(self: Box, _: E::WidgetPath) -> Vec> where Self: 'a { self.childs.into_childs() } @@ -138,10 +138,10 @@ impl<'w,E,L,R,V> Widget for SplitPane<'w,E,L,R,V> where false } - fn child(&self, i: usize) -> Result,()> { + fn child(&self, i: usize, _: E::WidgetPath) -> Result,()> { self.childs.child(i) } - fn into_child<'a>(self: Box, i: usize) -> Result,()> where Self: 'a { + fn into_child<'a>(self: Box, i: usize, _: E::WidgetPath) -> Result,()> where Self: 'a { self.childs.into_child(i) } @@ -162,16 +162,16 @@ impl<'w,E,L,R,V> WidgetMut for SplitPane<'w,E,L,R,V> where let _ = v; //self.invalid = true } - fn childs_mut(&mut self) -> Vec> { + fn childs_mut(&mut self, _: E::WidgetPath) -> Vec> { self.childs.childs_mut() } - fn into_childs_mut<'a>(self: Box) -> Vec> where Self: 'a { + fn into_childs_mut<'a>(self: Box, _: E::WidgetPath) -> Vec> where Self: 'a { self.childs.into_childs_mut() } - fn child_mut(&mut self, i: usize) -> Result,()> { + fn child_mut(&mut self, i: usize, _: E::WidgetPath) -> Result,()> { self.childs.child_mut(i) } - fn into_child_mut<'a>(self: Box, i: usize) -> Result,()> where Self: 'a { + fn into_child_mut<'a>(self: Box, i: usize, _: E::WidgetPath) -> Result,()> where Self: 'a { self.childs.into_child_mut(i) } diff --git a/src/widgets/textbox/widget.rs b/src/widgets/textbox/widget.rs index c005e984..e26421bf 100644 --- a/src/widgets/textbox/widget.rs +++ b/src/widgets/textbox/widget.rs @@ -191,13 +191,13 @@ impl<'w,E,Text,Scroll,Curs,CursorStickX,GlyphCache> Widget for TextBox<'w,E,T let e = e.and(&self.style); self.size.clone() } - fn childs(&self) -> usize { + fn childs(&self, _: E::WidgetPath) -> usize { 0 } - fn childs_ref(&self) -> Vec> { + fn childs_ref(&self, _: E::WidgetPath) -> Vec> { vec![] } - fn into_childs<'a>(self: Box) -> Vec> where Self: 'a { + fn into_childs<'a>(self: Box, _: E::WidgetPath) -> Vec> where Self: 'a { vec![] } @@ -207,10 +207,10 @@ impl<'w,E,Text,Scroll,Curs,CursorStickX,GlyphCache> Widget for TextBox<'w,E,T fn focusable(&self) -> bool { true } - fn child(&self, _: usize) -> Result,()> { + fn child(&self, _: usize, _: E::WidgetPath) -> Result,()> { Err(()) } - fn into_child<'a>(self: Box, _: usize) -> Result,()> where Self: 'a { + fn into_child<'a>(self: Box, _: usize, _: E::WidgetPath) -> Result,()> where Self: 'a { Err(()) } @@ -236,16 +236,16 @@ impl<'w,E,Text,Scroll,Curs,CursorStickX,GlyphCache> WidgetMut for TextBox<'w, CursorStickX: AtomStateMut>, GlyphCache: AtomStateMut>+Clone, { - fn childs_mut(&mut self) -> Vec> { + fn childs_mut(&mut self, _: E::WidgetPath) -> Vec> { vec![] } - fn into_childs_mut<'a>(self: Box) -> Vec> where Self: 'a { + fn into_childs_mut<'a>(self: Box, _: E::WidgetPath) -> Vec> where Self: 'a { vec![] } - fn child_mut(&mut self, _: usize) -> Result,()> { + fn child_mut(&mut self, _: usize, _: E::WidgetPath) -> Result,()> { Err(()) } - fn into_child_mut<'a>(self: Box, _: usize) -> Result,()> where Self: 'a { + fn into_child_mut<'a>(self: Box, _: usize, _: E::WidgetPath) -> Result,()> where Self: 'a { Err(()) }