@@ -45,9 +45,12 @@ impl<'a, T: ToJsonTreeValue> JsonTreeNode<'a, T> {
4545 persistent_id. with ( tree_id. with ( path_segments) )
4646 } ;
4747
48+ let style = config. style . unwrap_or_default ( ) ;
49+ let default_expand = config. default_expand . unwrap_or_default ( ) ;
50+
4851 let mut path_id_map = HashMap :: new ( ) ;
4952
50- let ( default_expand, search_term) = match config . default_expand {
53+ let ( default_expand, search_term) = match default_expand {
5154 DefaultExpand :: All => ( InnerExpand :: All , None ) ,
5255 DefaultExpand :: None => ( InnerExpand :: None , None ) ,
5356 DefaultExpand :: ToLevel ( l) => ( InnerExpand :: ToLevel ( l) , None ) ,
@@ -58,7 +61,7 @@ impl<'a, T: ToJsonTreeValue> JsonTreeNode<'a, T> {
5861 let paths = search_term
5962 . as_ref ( )
6063 . map ( |search_term| {
61- search_term. find_matching_paths_in ( self . value , config . abbreviate_root )
64+ search_term. find_matching_paths_in ( self . value , style . abbreviate_root )
6265 } )
6366 . unwrap_or_default ( ) ;
6467 ( InnerExpand :: Paths ( paths) , search_term)
@@ -69,17 +72,15 @@ impl<'a, T: ToJsonTreeValue> JsonTreeNode<'a, T> {
6972
7073 let node_config = JsonTreeNodeConfig {
7174 default_expand,
72- abbreviate_root : config. abbreviate_root ,
73- style : config. style ,
75+ style,
7476 search_term,
75- toggle_buttons_state : config. toggle_buttons_state ,
7677 } ;
7778
7879 // Wrap in a vertical layout in case this tree is placed directly in a horizontal layout,
7980 // which does not allow indent layouts as direct children.
8081 ui. vertical ( |ui| {
8182 // Centres the collapsing header icon.
82- ui. spacing_mut ( ) . interact_size . y = node_config. style . font_id ( ui) . size ;
83+ ui. spacing_mut ( ) . interact_size . y = node_config. style . resolve_font_id ( ui) . size ;
8384
8485 self . show_impl (
8586 ui,
@@ -176,10 +177,8 @@ fn show_expandable<'a, 'b, T: ToJsonTreeValue>(
176177) {
177178 let JsonTreeNodeConfig {
178179 default_expand,
179- abbreviate_root,
180180 style,
181181 search_term,
182- toggle_buttons_state,
183182 } = config;
184183
185184 let delimiters = match expandable. expandable_type {
@@ -204,14 +203,14 @@ fn show_expandable<'a, 'b, T: ToJsonTreeValue>(
204203 let header_res = ui. horizontal_wrapped ( |ui| {
205204 ui. spacing_mut ( ) . item_spacing . x = 0.0 ;
206205
207- if let Some ( enabled) = toggle_buttons_state. enabled ( ) {
206+ if let Some ( enabled) = style . toggle_buttons_state . enabled ( ) {
208207 ui. add_enabled_ui ( enabled, |ui| {
209208 state. show_toggle_button ( ui, paint_default_icon)
210209 } ) ;
211210 }
212211
213212 if path_segments. is_empty ( ) && !is_expanded {
214- if * abbreviate_root {
213+ if style . abbreviate_root {
215214 renderer. render_expandable_delimiter (
216215 ui,
217216 RenderExpandableDelimiterContext {
@@ -381,7 +380,7 @@ fn show_expandable<'a, 'b, T: ToJsonTreeValue>(
381380 }
382381 } ) ;
383382
384- let toggle_buttons_hidden = * toggle_buttons_state == ToggleButtonsState :: Hidden ;
383+ let toggle_buttons_hidden = style . toggle_buttons_state == ToggleButtonsState :: Hidden ;
385384 if toggle_buttons_hidden {
386385 ui. visuals_mut ( ) . indent_has_left_vline = true ;
387386 ui. spacing_mut ( ) . indent = ( ui. spacing ( ) . icon_width + ui. spacing ( ) . icon_spacing ) / 2.0 ;
@@ -450,10 +449,8 @@ fn show_expandable<'a, 'b, T: ToJsonTreeValue>(
450449
451450struct JsonTreeNodeConfig < ' a > {
452451 default_expand : InnerExpand < ' a > ,
453- abbreviate_root : bool ,
454452 style : JsonTreeStyle ,
455453 search_term : Option < SearchTerm > ,
456- toggle_buttons_state : ToggleButtonsState ,
457454}
458455
459456#[ derive( Debug , Clone ) ]
0 commit comments