@@ -45,9 +45,12 @@ impl<'a, T: ToJsonTreeValue> JsonTreeNode<'a, T> {
45
45
persistent_id. with ( tree_id. with ( path_segments) )
46
46
} ;
47
47
48
+ let style = config. style . unwrap_or_default ( ) ;
49
+ let default_expand = config. default_expand . unwrap_or_default ( ) ;
50
+
48
51
let mut path_id_map = HashMap :: new ( ) ;
49
52
50
- let ( default_expand, search_term) = match config . default_expand {
53
+ let ( default_expand, search_term) = match default_expand {
51
54
DefaultExpand :: All => ( InnerExpand :: All , None ) ,
52
55
DefaultExpand :: None => ( InnerExpand :: None , None ) ,
53
56
DefaultExpand :: ToLevel ( l) => ( InnerExpand :: ToLevel ( l) , None ) ,
@@ -58,7 +61,7 @@ impl<'a, T: ToJsonTreeValue> JsonTreeNode<'a, T> {
58
61
let paths = search_term
59
62
. as_ref ( )
60
63
. 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 )
62
65
} )
63
66
. unwrap_or_default ( ) ;
64
67
( InnerExpand :: Paths ( paths) , search_term)
@@ -69,17 +72,15 @@ impl<'a, T: ToJsonTreeValue> JsonTreeNode<'a, T> {
69
72
70
73
let node_config = JsonTreeNodeConfig {
71
74
default_expand,
72
- abbreviate_root : config. abbreviate_root ,
73
- style : config. style ,
75
+ style,
74
76
search_term,
75
- toggle_buttons_state : config. toggle_buttons_state ,
76
77
} ;
77
78
78
79
// Wrap in a vertical layout in case this tree is placed directly in a horizontal layout,
79
80
// which does not allow indent layouts as direct children.
80
81
ui. vertical ( |ui| {
81
82
// 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 ;
83
84
84
85
self . show_impl (
85
86
ui,
@@ -176,10 +177,8 @@ fn show_expandable<'a, 'b, T: ToJsonTreeValue>(
176
177
) {
177
178
let JsonTreeNodeConfig {
178
179
default_expand,
179
- abbreviate_root,
180
180
style,
181
181
search_term,
182
- toggle_buttons_state,
183
182
} = config;
184
183
185
184
let delimiters = match expandable. expandable_type {
@@ -204,14 +203,14 @@ fn show_expandable<'a, 'b, T: ToJsonTreeValue>(
204
203
let header_res = ui. horizontal_wrapped ( |ui| {
205
204
ui. spacing_mut ( ) . item_spacing . x = 0.0 ;
206
205
207
- if let Some ( enabled) = toggle_buttons_state. enabled ( ) {
206
+ if let Some ( enabled) = style . toggle_buttons_state . enabled ( ) {
208
207
ui. add_enabled_ui ( enabled, |ui| {
209
208
state. show_toggle_button ( ui, paint_default_icon)
210
209
} ) ;
211
210
}
212
211
213
212
if path_segments. is_empty ( ) && !is_expanded {
214
- if * abbreviate_root {
213
+ if style . abbreviate_root {
215
214
renderer. render_expandable_delimiter (
216
215
ui,
217
216
RenderExpandableDelimiterContext {
@@ -381,7 +380,7 @@ fn show_expandable<'a, 'b, T: ToJsonTreeValue>(
381
380
}
382
381
} ) ;
383
382
384
- let toggle_buttons_hidden = * toggle_buttons_state == ToggleButtonsState :: Hidden ;
383
+ let toggle_buttons_hidden = style . toggle_buttons_state == ToggleButtonsState :: Hidden ;
385
384
if toggle_buttons_hidden {
386
385
ui. visuals_mut ( ) . indent_has_left_vline = true ;
387
386
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>(
450
449
451
450
struct JsonTreeNodeConfig < ' a > {
452
451
default_expand : InnerExpand < ' a > ,
453
- abbreviate_root : bool ,
454
452
style : JsonTreeStyle ,
455
453
search_term : Option < SearchTerm > ,
456
- toggle_buttons_state : ToggleButtonsState ,
457
454
}
458
455
459
456
#[ derive( Debug , Clone ) ]
0 commit comments