@@ -12,7 +12,7 @@ use egui_json_tree::{
12
12
DefaultRender , RenderBaseValueContext , RenderContext , RenderExpandableDelimiterContext ,
13
13
RenderPropertyContext ,
14
14
} ,
15
- DefaultExpand , JsonTree ,
15
+ DefaultExpand , JsonTree , ToggleButtonsState ,
16
16
} ;
17
17
use serde_json:: { json, Value } ;
18
18
@@ -625,6 +625,53 @@ impl Show for JsonEditorExample {
625
625
}
626
626
}
627
627
628
+ struct ToggleButtonsCustomisationDemo {
629
+ value : Value ,
630
+ toggle_buttons_state : ToggleButtonsState ,
631
+ }
632
+
633
+ impl ToggleButtonsCustomisationDemo {
634
+ fn new ( value : Value ) -> Self {
635
+ Self {
636
+ value,
637
+ toggle_buttons_state : Default :: default ( ) ,
638
+ }
639
+ }
640
+ }
641
+
642
+ impl Show for ToggleButtonsCustomisationDemo {
643
+ fn title ( & self ) -> & ' static str {
644
+ "Toggle Buttons Customisation"
645
+ }
646
+
647
+ fn show ( & mut self , ui : & mut Ui ) {
648
+ ui. vertical ( |ui| {
649
+ ui. horizontal ( |ui| {
650
+ ui. selectable_value (
651
+ & mut self . toggle_buttons_state ,
652
+ ToggleButtonsState :: VisibleEnabled ,
653
+ "Visible and enabled" ,
654
+ ) ;
655
+ ui. selectable_value (
656
+ & mut self . toggle_buttons_state ,
657
+ ToggleButtonsState :: VisibleDisabled ,
658
+ "Visible and disabled" ,
659
+ ) ;
660
+ ui. selectable_value (
661
+ & mut self . toggle_buttons_state ,
662
+ ToggleButtonsState :: Hidden ,
663
+ "Hidden" ,
664
+ ) ;
665
+ } ) ;
666
+
667
+ JsonTree :: new ( "show" , & self . value )
668
+ . default_expand ( DefaultExpand :: All )
669
+ . toggle_buttons_state ( self . toggle_buttons_state )
670
+ . show ( ui) ;
671
+ } ) ;
672
+ }
673
+ }
674
+
628
675
struct DemoApp {
629
676
examples : Vec < Box < dyn Show > > ,
630
677
open_example_idx : Option < usize > ,
@@ -655,7 +702,8 @@ impl Default for DemoApp {
655
702
Box :: new( CustomExample :: new( "Custom Input" ) ) ,
656
703
Box :: new( SearchExample :: new( complex_object. clone( ) ) ) ,
657
704
Box :: new( CopyToClipboardExample :: new( complex_object. clone( ) ) ) ,
658
- Box :: new( JsonEditorExample :: new( complex_object) ) ,
705
+ Box :: new( JsonEditorExample :: new( complex_object. clone( ) ) ) ,
706
+ Box :: new( ToggleButtonsCustomisationDemo :: new( complex_object) ) ,
659
707
] ,
660
708
open_example_idx : None ,
661
709
}
0 commit comments