@@ -7,7 +7,9 @@ use std::sync::{Arc, RwLock};
77use std:: time:: Duration ;
88
99use eframe:: egui:: panel:: Side ;
10- use eframe:: egui:: { Align2 , Color32 , FontFamily , FontId , KeyboardShortcut , Pos2 , Sense , Vec2 , Visuals } ;
10+ use eframe:: egui:: {
11+ Align2 , Color32 , FontFamily , FontId , KeyboardShortcut , Pos2 , Sense , Vec2 , Visuals ,
12+ } ;
1113use eframe:: { egui, Storage } ;
1214use egui:: ThemePreference ;
1315use egui_plot:: { log_grid_spacer, GridMark , Legend , Line , Plot , PlotPoint , PlotPoints } ;
@@ -16,12 +18,12 @@ use preferences::Preferences;
1618use serde:: { Deserialize , Serialize } ;
1719use serialport:: { DataBits , FlowControl , Parity , StopBits } ;
1820
21+ use crate :: color_picker:: { color_picker_widget, color_picker_window, COLORS } ;
1922use crate :: data:: { DataContainer , SerialDirection } ;
2023use crate :: serial:: { clear_serial_settings, save_serial_settings, Device , SerialDevices } ;
2124use crate :: toggle:: toggle;
2225use crate :: FileOptions ;
2326use crate :: { APP_INFO , PREFS_KEY } ;
24- use crate :: color_picker:: { color_picker_widget, color_picker_window, COLORS } ;
2527
2628const MAX_FPS : f64 = 60.0 ;
2729
@@ -71,9 +73,9 @@ impl Print {
7173 Print :: Empty => None ,
7274 Print :: Message ( s) => {
7375 let color = if gui_conf. dark_mode {
74- egui :: Color32 :: WHITE
76+ Color32 :: WHITE
7577 } else {
76- egui :: Color32 :: BLACK
78+ Color32 :: BLACK
7779 } ;
7880 Some ( ScrollAreaMessage {
7981 label : "[MSG] " . to_owned ( ) ,
@@ -82,7 +84,7 @@ impl Print {
8284 } )
8385 }
8486 Print :: Error ( s) => {
85- let color = egui :: Color32 :: RED ;
87+ let color = Color32 :: RED ;
8688 Some ( ScrollAreaMessage {
8789 label : "[ERR] " . to_owned ( ) ,
8890 content : s. to_owned ( ) ,
@@ -91,9 +93,9 @@ impl Print {
9193 }
9294 Print :: Debug ( s) => {
9395 let color = if gui_conf. dark_mode {
94- egui :: Color32 :: YELLOW
96+ Color32 :: YELLOW
9597 } else {
96- egui :: Color32 :: LIGHT_RED
98+ Color32 :: LIGHT_RED
9799 } ;
98100 Some ( ScrollAreaMessage {
99101 label : "[DBG] " . to_owned ( ) ,
@@ -102,7 +104,7 @@ impl Print {
102104 } )
103105 }
104106 Print :: Ok ( s) => {
105- let color = egui :: Color32 :: GREEN ;
107+ let color = Color32 :: GREEN ;
106108 Some ( ScrollAreaMessage {
107109 label : "[OK] " . to_owned ( ) ,
108110 content : s. to_owned ( ) ,
@@ -117,7 +119,7 @@ impl Print {
117119pub struct ScrollAreaMessage {
118120 label : String ,
119121 content : String ,
120- color : egui :: Color32 ,
122+ color : Color32 ,
121123}
122124
123125pub fn print_to_console ( print_lock : & Arc < RwLock < Vec < Print > > > , message : Print ) {
@@ -171,7 +173,7 @@ pub fn load_gui_settings() -> GuiSettingsContainer {
171173
172174pub enum ColorWindow {
173175 NoShow ,
174- ColorIndex ( usize )
176+ ColorIndex ( usize ) ,
175177}
176178
177179pub struct MyApp {
@@ -193,7 +195,6 @@ pub struct MyApp {
193195 devices_lock : Arc < RwLock < Vec < String > > > ,
194196 connected_lock : Arc < RwLock < bool > > ,
195197 data_lock : Arc < RwLock < DataContainer > > ,
196- names_tx : Sender < Vec < String > > ,
197198 save_tx : Sender < FileOptions > ,
198199 send_tx : Sender < String > ,
199200 clear_tx : Sender < bool > ,
@@ -221,7 +222,6 @@ impl MyApp {
221222 devices : SerialDevices ,
222223 connected_lock : Arc < RwLock < bool > > ,
223224 gui_conf : GuiSettingsContainer ,
224- names_tx : Sender < Vec < String > > ,
225225 save_tx : Sender < FileOptions > ,
226226 send_tx : Sender < String > ,
227227 clear_tx : Sender < bool > ,
@@ -243,7 +243,6 @@ impl MyApp {
243243 print_lock,
244244 gui_conf,
245245 data_lock,
246- names_tx,
247246 save_tx,
248247 send_tx,
249248 clear_tx,
@@ -254,7 +253,7 @@ impl MyApp {
254253 show_timestamps : true ,
255254 save_raw : false ,
256255 eol : "\\ r\\ n" . to_string ( ) ,
257- colors : vec ! [ COLORS [ 0 ] ] ,
256+ colors : vec ! [ COLORS [ 0 ] ] ,
258257 color_vals : vec ! [ 0.0 ] ,
259258 labels : vec ! [ "Column 0" . to_string( ) ] ,
260259 history : vec ! [ ] ,
@@ -343,9 +342,8 @@ impl MyApp {
343342 self . colors = ( 0 ..max ( self . data . dataset . len ( ) , 1 ) )
344343 . map ( |i| COLORS [ i % COLORS . len ( ) ] )
345344 . collect ( ) ;
346- self . color_vals = ( 0 ..max ( self . data . dataset . len ( ) , 1 ) )
347- . map ( |i| 0.0 )
348- . collect ( ) ;
345+ self . color_vals =
346+ ( 0 ..max ( self . data . dataset . len ( ) , 1 ) ) . map ( |_| 0.0 ) . collect ( ) ;
349347 }
350348
351349 let mut graphs: Vec < Vec < PlotPoint > > = vec ! [ vec![ ] ; self . data. dataset. len( ) ] ;
@@ -386,9 +384,9 @@ impl MyApp {
386384 // this check needs to be here for when we change devices (not very elegant)
387385 if i < self . labels . len ( ) {
388386 signal_plot_ui. line (
389- Line :: new ( PlotPoints :: Owned ( graph. to_vec ( ) ) ) . name (
390- & self . labels [ i] ,
391- ) . color ( self . colors [ i] ) ,
387+ Line :: new ( PlotPoints :: Owned ( graph. to_vec ( ) ) )
388+ . name ( & self . labels [ i] )
389+ . color ( self . colors [ i] ) ,
392390 ) ;
393391 }
394392 }
@@ -426,9 +424,9 @@ impl MyApp {
426424 let row_height = ui. text_style_height ( & egui:: TextStyle :: Body ) ;
427425
428426 let color = if self . gui_conf . dark_mode {
429- egui :: Color32 :: WHITE
427+ Color32 :: WHITE
430428 } else {
431- egui :: Color32 :: BLACK
429+ Color32 :: BLACK
432430 } ;
433431
434432 egui:: ScrollArea :: vertical ( )
@@ -803,7 +801,7 @@ impl MyApp {
803801 }
804802 // need to clear the data here in order to prevent errors in the gui (plot)
805803 self . data = DataContainer :: default ( ) ;
806- self . names_tx . send ( self . serial_devices . labels [ self . device_idx ] . clone ( ) ) . expect ( "Failed to send names" ) ;
804+ // self.names_tx.send(self.serial_devices.labels[self.device_idx].clone()).expect("Failed to send names");
807805
808806 }
809807 ui. end_row ( ) ;
@@ -821,7 +819,6 @@ impl MyApp {
821819 if ui. add ( ThemeSwitch :: new ( & mut self . gui_conf . theme_preference ) ) . changed ( ) {
822820 ui. ctx ( ) . set_theme ( self . gui_conf . theme_preference ) ;
823821 } ;
824-
825822 ui. add_space ( 25.0 ) ;
826823 self . gui_conf . dark_mode = ui. visuals ( ) == & Visuals :: dark ( ) ;
827824 ui. horizontal ( |ui| {
@@ -844,15 +841,15 @@ impl MyApp {
844841 for i in 0 ..self . labels . len ( ) . min ( 10 ) {
845842 // if init, set names to what has been stored in the device last time
846843 if init {
847- self . names_tx . send ( self . labels . clone ( ) ) . expect ( "Failed to send names" ) ;
844+ // self.names_tx.send(self.labels.clone()).expect("Failed to send names");
848845 init = false ;
849846 }
850847
851848 if self . labels . len ( ) <= i {
852849 break ;
853850 }
854851 ui. horizontal ( |ui| {
855-
852+
856853 let response = color_picker_widget ( ui, "" , & mut self . colors , i ) ;
857854
858855 // Check if the square was clicked and toggle color picker window
@@ -864,20 +861,20 @@ impl MyApp {
864861 egui:: TextEdit :: singleline ( & mut self . labels [ i] )
865862 . desired_width ( 0.95 * RIGHT_PANEL_WIDTH )
866863 ) . on_hover_text ( "Use custom names for your Datasets." ) . changed ( ) {
867- self . names_tx . send ( self . labels . clone ( ) ) . expect ( "Failed to send names" ) ;
864+ // self.names_tx.send(self.labels.clone()).expect("Failed to send names");
868865 } ;
869866 } ) ;
870867 }
871-
872- match self . show_color_window {
873- ColorWindow :: NoShow => { }
868+ match self . show_color_window { ColorWindow :: NoShow => {
869+
870+ }
874871 ColorWindow :: ColorIndex ( index) => {
875872 if color_picker_window ( ui. ctx ( ) , & mut self . colors [ index] , & mut self . color_vals [ index] ) {
876873 self . show_color_window = ColorWindow :: NoShow ;
877874 }
878875 }
879876 }
880-
877+
881878 if self . labels . len ( ) > 10 {
882879 ui. label ( "Only renaming up to 10 Datasets is currently supported." ) ;
883880 }
@@ -920,9 +917,9 @@ impl MyApp {
920917 fn paint_connection_indicator ( & self , ui : & mut egui:: Ui ) {
921918 let ( color, color_stroke) = if !self . connected_to_device {
922919 ui. add ( egui:: Spinner :: new ( ) ) ;
923- ( egui :: Color32 :: DARK_RED , egui :: Color32 :: RED )
920+ ( Color32 :: DARK_RED , Color32 :: RED )
924921 } else {
925- ( egui :: Color32 :: DARK_GREEN , egui :: Color32 :: GREEN )
922+ ( Color32 :: DARK_GREEN , Color32 :: GREEN )
926923 } ;
927924
928925 let radius = ui. spacing ( ) . interact_size . y * 0.375 ;
0 commit comments