@@ -50,8 +50,8 @@ pub fn run(config_path: PathBuf) -> Result<()> {
5050 . with_title ( APP_WINDOW_TITLE )
5151 . with_app_id ( APP_ID )
5252 . with_icon ( branding:: icon_data ( 256 ) )
53- . with_inner_size ( [ 980 .0, 720 .0] )
54- . with_min_inner_size ( [ 860 .0, 640 .0] )
53+ . with_inner_size ( [ 1120 .0, 820 .0] )
54+ . with_min_inner_size ( [ 920 .0, 760 .0] )
5555 . with_max_inner_size ( [ 1440.0 , 1080.0 ] )
5656 . with_minimize_button ( !cfg ! ( target_os = "linux" ) )
5757 . with_maximize_button ( true )
@@ -584,16 +584,14 @@ impl AcceleratorApp {
584584 } ;
585585
586586 if ui
587- . add_enabled (
587+ . add ( filled_button (
588+ primary_label,
589+ primary_fill,
590+ primary_text,
591+ primary_stroke,
592+ egui:: vec2 ( ui. available_width ( ) , 46.0 ) ,
588593 !self . busy ,
589- filled_button (
590- primary_label,
591- primary_fill,
592- primary_text,
593- primary_stroke,
594- egui:: vec2 ( ui. available_width ( ) , 44.0 ) ,
595- ) ,
596- )
594+ ) )
597595 . clicked ( )
598596 {
599597 let action = if self . status . running {
@@ -607,19 +605,19 @@ impl AcceleratorApp {
607605 ui. add_space ( 6.0 ) ;
608606 ui. horizontal_wrapped ( |ui| {
609607 if ui
610- . add_enabled ( ! self . busy , subtle_button ( "最小化" , egui:: vec2 ( 92 .0, 32 .0) ) )
608+ . add ( subtle_button ( "最小化" , egui:: vec2 ( 96 .0, 34 .0) , ! self . busy ) )
611609 . clicked ( )
612610 {
613611 self . minimize_to_tray ( ctx) ;
614612 }
615613 if ui
616- . add ( subtle_button ( "设置" , egui:: vec2 ( 74 .0, 32 .0) ) )
614+ . add ( subtle_button ( "设置" , egui:: vec2 ( 78 .0, 34 .0) , true ) )
617615 . clicked ( )
618616 {
619617 self . show_config = true ;
620618 }
621619 if ui
622- . add ( subtle_button ( "关于" , egui:: vec2 ( 74 .0, 32 .0) ) )
620+ . add ( subtle_button ( "关于" , egui:: vec2 ( 78 .0, 34 .0) , true ) )
623621 . clicked ( )
624622 {
625623 self . show_about = true ;
@@ -671,32 +669,28 @@ impl AcceleratorApp {
671669 ui. add_space ( 10.0 ) ;
672670
673671 if ui
674- . add_enabled (
672+ . add ( filled_button (
673+ "恢复 hosts" ,
674+ egui:: Color32 :: from_rgb ( 46 , 102 , 86 ) ,
675+ egui:: Color32 :: from_rgb ( 245 , 249 , 247 ) ,
676+ egui:: Color32 :: from_rgb ( 68 , 136 , 116 ) ,
677+ egui:: vec2 ( ui. available_width ( ) , 38.0 ) ,
675678 self . can_restore_hosts ( ) ,
676- filled_button (
677- "恢复 hosts" ,
678- egui:: Color32 :: from_rgb ( 46 , 102 , 86 ) ,
679- egui:: Color32 :: from_rgb ( 245 , 249 , 247 ) ,
680- egui:: Color32 :: from_rgb ( 68 , 136 , 116 ) ,
681- egui:: vec2 ( ui. available_width ( ) , 36.0 ) ,
682- ) ,
683- )
679+ ) )
684680 . clicked ( )
685681 {
686682 self . confirm_action = Some ( GuiAction :: RestoreHosts ) ;
687683 }
688684
689685 if ui
690- . add_enabled (
686+ . add ( filled_button (
687+ "彻底恢复原始状态" ,
688+ egui:: Color32 :: from_rgb ( 136 , 63 , 56 ) ,
689+ egui:: Color32 :: from_rgb ( 252 , 247 , 245 ) ,
690+ egui:: Color32 :: from_rgb ( 176 , 86 , 77 ) ,
691+ egui:: vec2 ( ui. available_width ( ) , 38.0 ) ,
691692 !self . busy ,
692- filled_button (
693- "彻底恢复原始状态" ,
694- egui:: Color32 :: from_rgb ( 136 , 63 , 56 ) ,
695- egui:: Color32 :: from_rgb ( 252 , 247 , 245 ) ,
696- egui:: Color32 :: from_rgb ( 176 , 86 , 77 ) ,
697- egui:: vec2 ( ui. available_width ( ) , 36.0 ) ,
698- ) ,
699- )
693+ ) )
700694 . clicked ( )
701695 {
702696 self . confirm_action = Some ( GuiAction :: Cleanup ) ;
@@ -902,22 +896,20 @@ impl AcceleratorApp {
902896 ui. add_space ( 10.0 ) ;
903897 ui. with_layout ( egui:: Layout :: right_to_left ( egui:: Align :: Center ) , |ui| {
904898 if ui
905- . add ( subtle_button ( "取消" , egui:: vec2 ( 88 .0, 32 .0) ) )
899+ . add ( subtle_button ( "取消" , egui:: vec2 ( 92 .0, 34 .0) , true ) )
906900 . clicked ( )
907901 {
908902 cancelled = true ;
909903 }
910904 if ui
911- . add_enabled (
905+ . add ( filled_button (
906+ action. confirm_button ( ) ,
907+ egui:: Color32 :: from_rgb ( 243 , 180 , 66 ) ,
908+ egui:: Color32 :: from_rgb ( 24 , 24 , 22 ) ,
909+ egui:: Color32 :: from_rgb ( 216 , 158 , 58 ) ,
910+ egui:: vec2 ( 172.0 , 34.0 ) ,
912911 !self . busy ,
913- filled_button (
914- action. confirm_button ( ) ,
915- egui:: Color32 :: from_rgb ( 243 , 180 , 66 ) ,
916- egui:: Color32 :: from_rgb ( 24 , 24 , 22 ) ,
917- egui:: Color32 :: from_rgb ( 216 , 158 , 58 ) ,
918- egui:: vec2 ( 168.0 , 32.0 ) ,
919- ) ,
920- )
912+ ) )
921913 . clicked ( )
922914 {
923915 confirmed = true ;
@@ -1100,7 +1092,7 @@ impl eframe::App for AcceleratorApp {
11001092 self . render_header ( ui) ;
11011093 ui. add_space ( 16.0 ) ;
11021094
1103- if ui. available_width ( ) >= 980 .0 {
1095+ if ui. available_width ( ) >= 900 .0 {
11041096 ui. columns ( 2 , |columns| {
11051097 columns[ 0 ] . spacing_mut ( ) . item_spacing = egui:: vec2 ( 10.0 , 10.0 ) ;
11061098 self . render_action_panel ( & mut columns[ 0 ] , ctx) ;
@@ -1172,7 +1164,7 @@ impl eframe::App for AcceleratorApp {
11721164 } ) ;
11731165 ui. add_space ( 10.0 ) ;
11741166 if ui
1175- . add ( subtle_button ( "关闭" , egui:: vec2 ( 88 .0, 32 .0) ) )
1167+ . add ( subtle_button ( "关闭" , egui:: vec2 ( 92 .0, 34 .0) , true ) )
11761168 . clicked ( )
11771169 {
11781170 self . show_config = false ;
@@ -1207,7 +1199,7 @@ impl eframe::App for AcceleratorApp {
12071199 ) ;
12081200 } ) ;
12091201 if ui
1210- . add ( subtle_button ( "关闭" , egui:: vec2 ( 88 .0, 32 .0) ) )
1202+ . add ( subtle_button ( "关闭" , egui:: vec2 ( 92 .0, 34 .0) , true ) )
12111203 . clicked ( )
12121204 {
12131205 self . show_about = false ;
@@ -1574,28 +1566,65 @@ fn filled_button(
15741566 text : egui:: Color32 ,
15751567 stroke : egui:: Color32 ,
15761568 min_size : egui:: Vec2 ,
1569+ enabled : bool ,
15771570) -> egui:: Button < ' static > {
1571+ let ( fill, text, stroke) = if enabled {
1572+ ( fill, text, stroke)
1573+ } else {
1574+ (
1575+ fill. linear_multiply ( 0.62 ) ,
1576+ text. linear_multiply ( 0.9 ) ,
1577+ stroke. linear_multiply ( 0.68 ) ,
1578+ )
1579+ } ;
15781580 egui:: Button :: new (
15791581 RichText :: new ( label)
1580- . font ( FontId :: proportional ( 12.8 ) )
1582+ . font ( FontId :: proportional ( 13.0 ) )
15811583 . strong ( )
15821584 . color ( text) ,
15831585 )
15841586 . fill ( fill)
15851587 . stroke ( egui:: Stroke :: new ( 1.0 , stroke) )
15861588 . min_size ( min_size)
1589+ . sense ( if enabled {
1590+ egui:: Sense :: click ( )
1591+ } else {
1592+ egui:: Sense :: hover ( )
1593+ } )
15871594}
15881595
1589- fn subtle_button ( label : & ' static str , min_size : egui:: Vec2 ) -> egui:: Button < ' static > {
1596+ fn subtle_button (
1597+ label : & ' static str ,
1598+ min_size : egui:: Vec2 ,
1599+ enabled : bool ,
1600+ ) -> egui:: Button < ' static > {
1601+ let ( fill, text, stroke) = if enabled {
1602+ (
1603+ egui:: Color32 :: from_rgb ( 38 , 46 , 54 ) ,
1604+ egui:: Color32 :: from_rgb ( 234 , 238 , 241 ) ,
1605+ egui:: Color32 :: from_rgb ( 60 , 72 , 82 ) ,
1606+ )
1607+ } else {
1608+ (
1609+ egui:: Color32 :: from_rgb ( 56 , 66 , 76 ) ,
1610+ egui:: Color32 :: from_rgb ( 224 , 229 , 234 ) ,
1611+ egui:: Color32 :: from_rgb ( 86 , 98 , 109 ) ,
1612+ )
1613+ } ;
15901614 egui:: Button :: new (
15911615 RichText :: new ( label)
1592- . font ( FontId :: proportional ( 12.0 ) )
1616+ . font ( FontId :: proportional ( 12.2 ) )
15931617 . strong ( )
1594- . color ( egui :: Color32 :: from_rgb ( 234 , 238 , 241 ) ) ,
1618+ . color ( text ) ,
15951619 )
1596- . fill ( egui :: Color32 :: from_rgb ( 38 , 46 , 54 ) )
1597- . stroke ( egui:: Stroke :: new ( 1.0 , egui :: Color32 :: from_rgb ( 60 , 72 , 82 ) ) )
1620+ . fill ( fill )
1621+ . stroke ( egui:: Stroke :: new ( 1.0 , stroke ) )
15981622 . min_size ( min_size)
1623+ . sense ( if enabled {
1624+ egui:: Sense :: click ( )
1625+ } else {
1626+ egui:: Sense :: hover ( )
1627+ } )
15991628}
16001629
16011630fn compact_metric ( ui : & mut egui:: Ui , label : & str , value : & str ) {
0 commit comments