@@ -12,6 +12,7 @@ use std::{
12
12
use eframe:: Frame ;
13
13
use egui:: Widget ;
14
14
use notify:: { RecursiveMode , Watcher } ;
15
+ use time:: { OffsetDateTime , UtcOffset } ;
15
16
16
17
use crate :: {
17
18
jobs:: {
@@ -38,7 +39,14 @@ pub enum DiffKind {
38
39
WholeBinary ,
39
40
}
40
41
41
- #[ derive( Default , serde:: Deserialize , serde:: Serialize ) ]
42
+ #[ derive( Default , Clone ) ]
43
+ pub struct DiffConfig {
44
+ // TODO
45
+ // pub stripped_symbols: Vec<String>,
46
+ // pub mapped_symbols: HashMap<String, String>,
47
+ }
48
+
49
+ #[ derive( serde:: Deserialize , serde:: Serialize ) ]
42
50
#[ serde( default ) ]
43
51
pub struct ViewState {
44
52
#[ serde( skip) ]
@@ -53,11 +61,35 @@ pub struct ViewState {
53
61
pub current_view : View ,
54
62
#[ serde( skip) ]
55
63
pub show_config : bool ,
64
+ #[ serde( skip) ]
65
+ pub diff_config : DiffConfig ,
66
+ #[ serde( skip) ]
67
+ pub search : String ,
68
+ #[ serde( skip) ]
69
+ pub utc_offset : UtcOffset ,
56
70
// Config
57
71
pub diff_kind : DiffKind ,
58
72
pub reverse_fn_order : bool ,
59
73
}
60
74
75
+ impl Default for ViewState {
76
+ fn default ( ) -> Self {
77
+ Self {
78
+ jobs : vec ! [ ] ,
79
+ build : None ,
80
+ highlighted_symbol : None ,
81
+ selected_symbol : None ,
82
+ current_view : Default :: default ( ) ,
83
+ show_config : false ,
84
+ diff_config : Default :: default ( ) ,
85
+ search : Default :: default ( ) ,
86
+ utc_offset : UtcOffset :: UTC ,
87
+ diff_kind : Default :: default ( ) ,
88
+ reverse_fn_order : false ,
89
+ }
90
+ }
91
+ }
92
+
61
93
#[ derive( Default , Clone , serde:: Deserialize , serde:: Serialize ) ]
62
94
#[ serde( default ) ]
63
95
pub struct AppConfig {
@@ -107,7 +139,7 @@ const CONFIG_KEY: &str = "app_config";
107
139
108
140
impl App {
109
141
/// Called once before the first frame.
110
- pub fn new ( cc : & eframe:: CreationContext < ' _ > ) -> Self {
142
+ pub fn new ( cc : & eframe:: CreationContext < ' _ > , utc_offset : UtcOffset ) -> Self {
111
143
// This is also where you can customized the look at feel of egui using
112
144
// `cc.egui_ctx.set_visuals` and `cc.egui_ctx.set_fonts`.
113
145
@@ -120,6 +152,7 @@ impl App {
120
152
config. project_dir_change = true ;
121
153
}
122
154
app. config = Arc :: new ( RwLock :: new ( config) ) ;
155
+ app. view_state . utc_offset = utc_offset;
123
156
app
124
157
} else {
125
158
Self :: default ( )
@@ -149,16 +182,20 @@ impl eframe::App for App {
149
182
if view_state. current_view == View :: FunctionDiff
150
183
&& matches ! ( & view_state. build, Some ( b) if b. first_status. success && b. second_status. success)
151
184
{
152
- egui:: SidePanel :: left ( "side_panel" ) . show ( ctx, |ui| {
153
- if ui. button ( "Back" ) . clicked ( ) {
154
- view_state. current_view = View :: SymbolDiff ;
155
- }
156
- ui. separator ( ) ;
157
- jobs_ui ( ui, view_state) ;
158
- } ) ;
185
+ // egui::SidePanel::left("side_panel").show(ctx, |ui| {
186
+ // if ui.button("Back").clicked() {
187
+ // view_state.current_view = View::SymbolDiff;
188
+ // }
189
+ // ui.separator();
190
+ // jobs_ui(ui, view_state);
191
+ // });
159
192
160
193
egui:: CentralPanel :: default ( ) . show ( ctx, |ui| {
161
- function_diff_ui ( ui, view_state) ;
194
+ if function_diff_ui ( ui, view_state) {
195
+ view_state
196
+ . jobs
197
+ . push ( queue_build ( config. clone ( ) , view_state. diff_config . clone ( ) ) ) ;
198
+ }
162
199
} ) ;
163
200
} else {
164
201
egui:: SidePanel :: left ( "side_panel" ) . show ( ctx, |ui| {
@@ -253,6 +290,7 @@ impl eframe::App for App {
253
290
} ,
254
291
first_obj : Some ( state. first_obj ) ,
255
292
second_obj : Some ( state. second_obj ) ,
293
+ time : OffsetDateTime :: now_utc ( ) ,
256
294
} ) ) ;
257
295
}
258
296
}
@@ -267,7 +305,10 @@ impl eframe::App for App {
267
305
let mut i = 0 ;
268
306
while i < self . view_state . jobs . len ( ) {
269
307
let job = & self . view_state . jobs [ i] ;
270
- if job. should_remove && job. handle . is_none ( ) {
308
+ if job. should_remove
309
+ && job. handle . is_none ( )
310
+ && job. status . read ( ) . unwrap ( ) . error . is_none ( )
311
+ {
271
312
self . view_state . jobs . remove ( i) ;
272
313
} else {
273
314
i += 1 ;
@@ -288,20 +329,19 @@ impl eframe::App for App {
288
329
}
289
330
}
290
331
291
- if let Some ( build_obj) = & config. obj_path {
292
- if self . modified . load ( Ordering :: Relaxed ) {
293
- if !self
294
- . view_state
295
- . jobs
296
- . iter ( )
297
- . any ( |j| j. job_type == Job :: ObjDiff && j. handle . is_some ( ) )
298
- {
299
- self . view_state
300
- . jobs
301
- . push ( queue_build ( build_obj. clone ( ) , self . config . clone ( ) ) ) ;
302
- }
303
- self . modified . store ( false , Ordering :: Relaxed ) ;
332
+ if config. obj_path . is_some ( ) && self . modified . load ( Ordering :: Relaxed ) {
333
+ if !self
334
+ . view_state
335
+ . jobs
336
+ . iter ( )
337
+ . any ( |j| j. job_type == Job :: ObjDiff && j. handle . is_some ( ) )
338
+ {
339
+ self . view_state . jobs . push ( queue_build (
340
+ self . config . clone ( ) ,
341
+ self . view_state . diff_config . clone ( ) ,
342
+ ) ) ;
304
343
}
344
+ self . modified . store ( false , Ordering :: Relaxed ) ;
305
345
}
306
346
}
307
347
}
0 commit comments