11use std:: { cmp:: Ordering , default:: Default } ;
22
3- use egui:: { text:: LayoutJob , Id , Label , Response , RichText , Sense , Widget } ;
3+ use egui:: { text:: LayoutJob , Id , Label , Layout , Response , RichText , Sense , Widget } ;
44use egui_extras:: TableRow ;
55use objdiff_core:: {
66 diff:: {
@@ -414,6 +414,7 @@ fn asm_col_ui(
414414}
415415
416416#[ must_use]
417+ #[ expect( clippy:: too_many_arguments) ]
417418fn asm_table_ui (
418419 ui : & mut egui:: Ui ,
419420 available_width : f32 ,
@@ -422,6 +423,7 @@ fn asm_table_ui(
422423 appearance : & Appearance ,
423424 ins_view_state : & FunctionViewState ,
424425 symbol_state : & SymbolViewState ,
426+ open_sections : ( Option < bool > , Option < bool > ) ,
425427) -> Option < DiffViewAction > {
426428 let mut ret = None ;
427429 let left_len = left_ctx. and_then ( |ctx| {
@@ -512,7 +514,7 @@ fn asm_table_ui(
512514 SymbolFilter :: Mapping ( right_symbol_ref) ,
513515 appearance,
514516 column,
515- None ,
517+ open_sections . 0 ,
516518 ) {
517519 match action {
518520 DiffViewAction :: Navigate ( DiffViewNavigation {
@@ -571,7 +573,7 @@ fn asm_table_ui(
571573 SymbolFilter :: Mapping ( left_symbol_ref) ,
572574 appearance,
573575 column,
574- None ,
576+ open_sections . 1 ,
575577 ) {
576578 match action {
577579 DiffViewAction :: Navigate ( DiffViewNavigation {
@@ -685,6 +687,7 @@ pub fn function_diff_ui(
685687
686688 // Header
687689 let available_width = ui. available_width ( ) ;
690+ let mut open_sections = ( None , None ) ;
688691 render_header ( ui, available_width, 2 , |ui, column| {
689692 if column == 0 {
690693 // Left column
@@ -738,11 +741,24 @@ pub fn function_diff_ui(
738741 . font ( appearance. code_font . clone ( ) )
739742 . color ( appearance. replace_color ) ,
740743 ) ;
741- ui. label (
742- RichText :: new ( "Choose target symbol" )
743- . font ( appearance. code_font . clone ( ) )
744- . color ( appearance. highlight_color ) ,
745- ) ;
744+
745+ ui. horizontal ( |ui| {
746+ ui. label (
747+ RichText :: new ( "Choose target symbol" )
748+ . font ( appearance. code_font . clone ( ) )
749+ . color ( appearance. highlight_color ) ,
750+ ) ;
751+
752+ ui. with_layout ( Layout :: right_to_left ( egui:: Align :: TOP ) , |ui| {
753+ if ui. small_button ( "⏷" ) . on_hover_text_at_pointer ( "Expand all" ) . clicked ( ) {
754+ open_sections. 0 = Some ( true ) ;
755+ }
756+ if ui. small_button ( "⏶" ) . on_hover_text_at_pointer ( "Collapse all" ) . clicked ( )
757+ {
758+ open_sections. 0 = Some ( false ) ;
759+ }
760+ } )
761+ } ) ;
746762 }
747763 } else if column == 1 {
748764 // Right column
@@ -814,11 +830,24 @@ pub fn function_diff_ui(
814830 . font ( appearance. code_font . clone ( ) )
815831 . color ( appearance. replace_color ) ,
816832 ) ;
817- ui. label (
818- RichText :: new ( "Choose base symbol" )
819- . font ( appearance. code_font . clone ( ) )
820- . color ( appearance. highlight_color ) ,
821- ) ;
833+
834+ ui. horizontal ( |ui| {
835+ ui. label (
836+ RichText :: new ( "Choose base symbol" )
837+ . font ( appearance. code_font . clone ( ) )
838+ . color ( appearance. highlight_color ) ,
839+ ) ;
840+
841+ ui. with_layout ( Layout :: right_to_left ( egui:: Align :: TOP ) , |ui| {
842+ if ui. small_button ( "⏷" ) . on_hover_text_at_pointer ( "Expand all" ) . clicked ( ) {
843+ open_sections. 1 = Some ( true ) ;
844+ }
845+ if ui. small_button ( "⏶" ) . on_hover_text_at_pointer ( "Collapse all" ) . clicked ( )
846+ {
847+ open_sections. 1 = Some ( false ) ;
848+ }
849+ } )
850+ } ) ;
822851 }
823852 }
824853 } ) ;
@@ -836,6 +865,7 @@ pub fn function_diff_ui(
836865 appearance,
837866 & state. function_state ,
838867 & state. symbol_state ,
868+ open_sections,
839869 )
840870 } )
841871 . inner
0 commit comments