@@ -11,6 +11,7 @@ pub struct Appearance {
11
11
pub ui_font : FontId ,
12
12
pub code_font : FontId ,
13
13
pub diff_colors : Vec < Color32 > ,
14
+ pub diff_bg_color : Option < Color32 > ,
14
15
pub theme : egui:: Theme ,
15
16
16
17
// Applied by theme
@@ -67,6 +68,7 @@ impl Default for Appearance {
67
68
replace_color : Color32 :: LIGHT_BLUE ,
68
69
insert_color : Color32 :: GREEN ,
69
70
delete_color : Color32 :: from_rgb ( 200 , 40 , 41 ) ,
71
+ diff_bg_color : None ,
70
72
utc_offset : UtcOffset :: UTC ,
71
73
fonts : FontState :: default ( ) ,
72
74
next_ui_font : None ,
@@ -103,6 +105,9 @@ impl Appearance {
103
105
match self . theme {
104
106
egui:: Theme :: Dark => {
105
107
style. visuals = egui:: Visuals :: dark ( ) ;
108
+ if let Some ( diff_bg_color) = self . diff_bg_color {
109
+ style. visuals . faint_bg_color = diff_bg_color;
110
+ }
106
111
self . text_color = Color32 :: GRAY ;
107
112
self . emphasized_text_color = Color32 :: LIGHT_GRAY ;
108
113
self . deemphasized_text_color = Color32 :: DARK_GRAY ;
@@ -114,6 +119,9 @@ impl Appearance {
114
119
}
115
120
egui:: Theme :: Light => {
116
121
style. visuals = egui:: Visuals :: light ( ) ;
122
+ if let Some ( diff_bg_color) = self . diff_bg_color {
123
+ style. visuals . faint_bg_color = diff_bg_color;
124
+ }
117
125
self . text_color = Color32 :: GRAY ;
118
126
self . emphasized_text_color = Color32 :: DARK_GRAY ;
119
127
self . deemphasized_text_color = Color32 :: LIGHT_GRAY ;
@@ -294,6 +302,21 @@ pub fn appearance_window(ctx: &egui::Context, show: &mut bool, appearance: &mut
294
302
appearance,
295
303
) ;
296
304
ui. separator ( ) ;
305
+ ui. horizontal ( |ui| {
306
+ ui. label ( "Diff fill color:" ) ;
307
+ let mut diff_bg_color =
308
+ appearance. diff_bg_color . unwrap_or_else ( || match appearance. theme {
309
+ egui:: Theme :: Dark => egui:: Visuals :: dark ( ) . faint_bg_color ,
310
+ egui:: Theme :: Light => egui:: Visuals :: light ( ) . faint_bg_color ,
311
+ } ) ;
312
+ if ui. color_edit_button_srgba ( & mut diff_bg_color) . changed ( ) {
313
+ appearance. diff_bg_color = Some ( diff_bg_color) ;
314
+ }
315
+ if ui. button ( "Reset" ) . clicked ( ) {
316
+ appearance. diff_bg_color = None ;
317
+ }
318
+ } ) ;
319
+ ui. separator ( ) ;
297
320
ui. label ( "Diff colors:" ) ;
298
321
if ui. button ( "Reset" ) . clicked ( ) {
299
322
appearance. diff_colors = DEFAULT_COLOR_ROTATION . to_vec ( ) ;
0 commit comments