1
1
use egui:: {
2
- include_image , Button , Color32 , CursorIcon , ImageSource , Response , RichText , Sense , Vec2 ,
2
+ Button , Color32 , CursorIcon , ImageSource , include_image , Response , RichText , Sense , Vec2 ,
3
3
} ;
4
4
use egui_extras:: { Column , TableBuilder } ;
5
5
use egui_toast:: ToastKind ;
6
6
7
7
use super :: {
8
8
log_file_reader:: LogFileReader ,
9
- log_view:: { LogViewTabTrait , LogViewerState } ,
9
+ log_view:: { LogViewerState , LogViewTabTrait } ,
10
10
} ;
11
11
12
12
pub struct LogEntryContextTab { }
@@ -21,12 +21,9 @@ impl LogEntryContextTab {
21
21
image_source : ImageSource < ' _ > ,
22
22
hover_text : & str ,
23
23
) -> Response {
24
- ui. add_sized (
25
- Vec2 :: new ( 14.0 , 14.0 ) ,
26
- Button :: image ( image_source) . frame ( false ) ,
27
- )
28
- . on_hover_cursor ( CursorIcon :: PointingHand )
29
- . on_hover_text ( hover_text)
24
+ ui. add_sized ( Vec2 :: new ( 18.0 , 18.0 ) , Button :: image ( image_source) )
25
+ . on_hover_text ( hover_text)
26
+ . on_hover_cursor ( CursorIcon :: PointingHand )
30
27
}
31
28
}
32
29
@@ -52,10 +49,16 @@ impl LogViewTabTrait for LogEntryContextTab {
52
49
return ;
53
50
}
54
51
52
+ let row_height_padding = 6.0 ;
53
+ let row_content_height = 14.0 ;
54
+
55
55
let log_entry = read_log_entry. unwrap ( ) ;
56
56
57
57
TableBuilder :: new ( ui)
58
58
. striped ( true )
59
+ . min_scrolled_height ( 0.0 )
60
+ . max_scroll_height ( f32:: INFINITY )
61
+ . auto_shrink ( false )
59
62
. sense ( Sense :: hover ( ) )
60
63
. cell_layout ( egui:: Layout :: left_to_right ( egui:: Align :: Center ) )
61
64
. column ( Column :: auto ( ) )
@@ -67,45 +70,49 @@ impl LogViewTabTrait for LogEntryContextTab {
67
70
let key_str = entry. 0 ;
68
71
let value_str = entry. 1 . to_string ( ) ;
69
72
let line_count = value_str. chars ( ) . filter ( |c| * c == '\n' ) . count ( ) + 1 ;
70
- body. row ( ( line_count as f32 ) * 16.0 , |mut row| {
71
- row. col ( |ui| {
72
- let column_is_shown =
73
- viewer_state. displayed_columns . iter ( ) . any ( |s| s == key_str) ;
74
- if !column_is_shown {
75
- let add_icon =
76
- include_image ! ( "../../assets/icons8-add-48-white.png" ) ;
77
- if Self :: add_tool_button ( ui, add_icon, "Add Column" ) . clicked ( ) {
78
- viewer_state. displayed_columns . push ( key_str. to_string ( ) ) ;
73
+ body. row (
74
+ ( line_count as f32 ) * row_content_height + row_height_padding,
75
+ |mut row| {
76
+ row. col ( |ui| {
77
+ let column_is_shown =
78
+ viewer_state. displayed_columns . iter ( ) . any ( |s| s == key_str) ;
79
+ if !column_is_shown {
80
+ let add_icon =
81
+ include_image ! ( "../../assets/icons8-add-48-white.png" ) ;
82
+ if Self :: add_tool_button ( ui, add_icon, "Add Column" ) . clicked ( ) {
83
+ viewer_state. displayed_columns . push ( key_str. to_string ( ) ) ;
84
+
85
+ viewer_state. add_toast (
86
+ ToastKind :: Info ,
87
+ format ! ( "Added column '{}'" , key_str) . into ( ) ,
88
+ 2.0 ,
89
+ ) ;
90
+ }
91
+ }
92
+ } ) ;
93
+ row. col ( |ui| {
94
+ ui. label ( RichText :: new ( key_str) . color ( Color32 :: WHITE ) . monospace ( ) ) ;
95
+ } ) ;
96
+ row. col ( |ui| {
97
+ let copy_icon =
98
+ include_image ! ( "../../assets/icons8-copy-48-white.png" ) ;
99
+ if Self :: add_tool_button ( ui, copy_icon, "Copy Value" ) . clicked ( ) {
100
+ ui. output_mut ( |o| {
101
+ o. copied_text = value_str. clone ( ) ;
102
+ } ) ;
79
103
80
104
viewer_state. add_toast (
81
105
ToastKind :: Info ,
82
- format ! ( "Added column '{}'" , key_str ) . into ( ) ,
106
+ "Copied value to clipboard." . into ( ) ,
83
107
2.0 ,
84
108
) ;
85
109
}
86
- }
87
- } ) ;
88
- row. col ( |ui| {
89
- ui. label ( RichText :: new ( key_str) . color ( Color32 :: WHITE ) . monospace ( ) ) ;
90
- } ) ;
91
- row. col ( |ui| {
92
- let copy_icon = include_image ! ( "../../assets/icons8-copy-48-white.png" ) ;
93
- if Self :: add_tool_button ( ui, copy_icon, "Copy Value" ) . clicked ( ) {
94
- ui. output_mut ( |o| {
95
- o. copied_text = value_str. clone ( ) ;
96
- } ) ;
97
-
98
- viewer_state. add_toast (
99
- ToastKind :: Info ,
100
- "Copied value to clipboard." . into ( ) ,
101
- 2.0 ,
102
- ) ;
103
- }
104
- } ) ;
105
- row. col ( |ui| {
106
- ui. label ( RichText :: new ( value_str. trim ( ) ) . monospace ( ) ) ;
107
- } ) ;
108
- } ) ;
110
+ } ) ;
111
+ row. col ( |ui| {
112
+ ui. label ( RichText :: new ( value_str. trim ( ) ) . monospace ( ) ) ;
113
+ } ) ;
114
+ } ,
115
+ ) ;
109
116
}
110
117
} ) ;
111
118
}
0 commit comments