@@ -6,23 +6,18 @@ use std::{
6
6
7
7
#[ cfg( not( target_arch = "wasm32" ) ) ]
8
8
use anyhow:: { bail, Context } ;
9
- use egui_extras:: { Column , Size , StripBuilder , TableBuilder } ;
9
+ use egui_extras:: { Column , TableBuilder } ;
10
10
use log:: info;
11
11
12
12
use self :: { data:: Data , data_display_options:: DataDisplayOptions } ;
13
13
14
14
mod data;
15
15
mod data_display_options;
16
16
17
- const SPACE_BETWEEN_TABLES : f32 = 10. ;
18
-
19
- // TODO 3: Replace current setup with using resizable panels https://github.com/emilk/egui/blob/34db001db14940c948eb03d3fe87f2af2c45daba/crates/egui_demo_lib/src/demo/panels.rs#L26
20
-
21
17
#[ derive( serde:: Deserialize , serde:: Serialize ) ]
22
18
#[ serde( default ) ] // if we add new fields, give them default values when deserializing old state
23
19
pub struct LogViewerApp {
24
20
data : Option < Data > ,
25
- main_table_screen_proportion : f32 ,
26
21
data_display_options : DataDisplayOptions ,
27
22
start_open_path : Arc < Mutex < Option < PathBuf > > > ,
28
23
last_filename : Arc < Mutex < Option < PathBuf > > > ,
@@ -36,7 +31,6 @@ impl Default for LogViewerApp {
36
31
fn default ( ) -> Self {
37
32
Self {
38
33
data : Default :: default ( ) ,
39
- main_table_screen_proportion : 0.5 ,
40
34
data_display_options : Default :: default ( ) ,
41
35
start_open_path : Default :: default ( ) ,
42
36
loading_status : Default :: default ( ) ,
@@ -330,12 +324,6 @@ impl LogViewerApp {
330
324
331
325
fn ui_options ( & mut self , ui : & mut egui:: Ui ) {
332
326
ui. collapsing ( "Options" , |ui| {
333
- ui. add (
334
- egui:: DragValue :: new ( & mut self . main_table_screen_proportion )
335
- . speed ( 0.01 )
336
- . clamp_range ( 0.2 ..=0.85 )
337
- . prefix ( "Main Area Proportion Percentage " ) ,
338
- ) ;
339
327
ui. checkbox ( & mut self . show_last_filename , "Show last filename" ) ;
340
328
} ) ;
341
329
}
@@ -472,51 +460,39 @@ impl eframe::App for LogViewerApp {
472
460
self . ui_help ( ui) ;
473
461
ui. separator ( ) ;
474
462
475
- egui:: ScrollArea :: vertical ( )
476
- . id_source ( "scroll for overflow" )
477
- . show ( ui, |ui| {
478
- StripBuilder :: new ( ui)
479
- . size ( Size :: relative ( self . main_table_screen_proportion ) ) // for the log lines
480
- . size ( Size :: exact ( SPACE_BETWEEN_TABLES ) ) // for the log lines
481
- . size ( Size :: remainder ( ) ) // for the details area
482
- . vertical ( |mut strip| {
483
- strip. cell ( |ui| {
484
- egui:: ScrollArea :: horizontal ( ) . id_source ( "log lines" ) . show (
485
- ui,
486
- |ui| {
487
- ui. push_id ( "table log lines" , |ui| self . show_log_lines ( ui) ) ;
488
- } ,
489
- ) ;
490
- } ) ;
491
- strip. cell ( |ui| {
492
- expanding_content ( ui) ;
493
- } ) ;
494
- strip. cell ( |ui| {
495
- egui:: ScrollArea :: horizontal ( )
496
- . id_source ( "details area" )
497
- . show ( ui, |ui| {
498
- ui. push_id ( "table details" , |ui| self . show_log_details ( ui) ) ;
499
- } ) ;
500
- } ) ;
463
+ const MIN_LOG_LINES_SIZE : f32 = 100.0 ;
464
+ let max_details_height = ui. available_height ( ) - MIN_LOG_LINES_SIZE ;
465
+
466
+ egui:: TopBottomPanel :: bottom ( "details_panel" )
467
+ . resizable ( true )
468
+ . default_height ( 200. )
469
+ . max_height ( max_details_height)
470
+ . min_height ( 60. )
471
+ . show_inside ( ui, |ui| {
472
+ ui. vertical_centered ( |ui| {
473
+ ui. heading ( "Details" ) ;
474
+ } ) ;
475
+ egui:: ScrollArea :: horizontal ( )
476
+ . id_source ( "details area" )
477
+ . show ( ui, |ui| {
478
+ ui. push_id ( "table details" , |ui| self . show_log_details ( ui) ) ;
501
479
} ) ;
480
+ if ui. available_height ( ) > 0.0 {
481
+ ui. allocate_space ( ui. available_size ( ) ) ;
482
+ }
502
483
} ) ;
484
+
485
+ egui:: CentralPanel :: default ( ) . show_inside ( ui, |ui| {
486
+ egui:: ScrollArea :: horizontal ( )
487
+ . id_source ( "log lines" )
488
+ . show ( ui, |ui| {
489
+ ui. push_id ( "table log lines" , |ui| self . show_log_lines ( ui) ) ;
490
+ } ) ;
491
+ } ) ;
503
492
} ) ;
504
493
}
505
494
}
506
495
507
- fn expanding_content ( ui : & mut egui:: Ui ) {
508
- // Taken from https://github.com/emilk/egui/blob/15370bbea0b468cf719a75cc6d1e39eb00c420d8/crates/egui_demo_lib/src/demo/table_demo.rs#L276
509
- let width = ui. available_width ( ) ;
510
- let height = ui. available_height ( ) ;
511
- let ( rect, response) = ui. allocate_exact_size ( egui:: vec2 ( width, height) , egui:: Sense :: hover ( ) ) ;
512
- response. on_hover_text ( "See options to change size" ) ;
513
- ui. painter ( ) . hline (
514
- rect. x_range ( ) ,
515
- rect. center ( ) . y ,
516
- ( 2.0 , ui. visuals ( ) . text_color ( ) ) ,
517
- ) ;
518
- }
519
-
520
496
pub fn calculate_hash < T : Hash + ?Sized > ( t : & T ) -> u64 {
521
497
let mut s = DefaultHasher :: new ( ) ;
522
498
t. hash ( & mut s) ;
0 commit comments