@@ -70,11 +70,9 @@ impl BridgeApp {
7070impl eframe:: App for BridgeApp {
7171 fn update ( & mut self , ctx : & egui:: Context , _frame : & mut eframe:: Frame ) {
7272 // Intercept Close Request (System X button)
73- if ctx. input ( |i| i. viewport ( ) . close_requested ( ) ) {
74- if !self . allowed_to_close {
75- ctx. send_viewport_cmd ( egui:: ViewportCommand :: CancelClose ) ;
76- self . show_quit_confirmation = true ;
77- }
73+ if ctx. input ( |i| i. viewport ( ) . close_requested ( ) ) && !self . allowed_to_close {
74+ ctx. send_viewport_cmd ( egui:: ViewportCommand :: CancelClose ) ;
75+ self . show_quit_confirmation = true ;
7876 }
7977
8078 // Handle Quit Shortcut (Ctrl+Q / Cmd+Q)
@@ -120,55 +118,51 @@ impl eframe::App for BridgeApp {
120118 let main_enabled = !self . show_quit_confirmation ;
121119
122120 // --- Activity Log Consumption ---
123- if let Ok ( mut m) = self . midi . lock ( ) {
124- if !m. activity_log . is_empty ( ) {
125- let logs: Vec < _ > = m. activity_log . drain ( ..) . collect ( ) ;
126- log:: debug!( "Received {} activity events" , logs. len( ) ) ;
127- for event in logs {
128- log:: debug!(
129- "Activity: mapping_idx={}, part={:?}, value={}" ,
130- event. mapping_idx,
131- event. part,
132- event. value
133- ) ;
134-
135- if let Some ( node_ids) = self . mapping_nodes . get ( & event. mapping_idx ) {
136- let target_node_id = match event. part {
137- eos_midi_bridge:: ActivityPart :: Trigger => Some ( node_ids. trigger ) ,
138- eos_midi_bridge:: ActivityPart :: Action => Some ( node_ids. action ) ,
139- eos_midi_bridge:: ActivityPart :: Output ( i) => {
140- node_ids. outputs . get ( i) . copied ( )
141- }
142- } ;
121+ if let Ok ( mut m) = self . midi . lock ( )
122+ && !m. activity_log . is_empty ( )
123+ {
124+ let logs: Vec < _ > = m. activity_log . drain ( ..) . collect ( ) ;
125+ log:: debug!( "Received {} activity events" , logs. len( ) ) ;
126+ for event in logs {
127+ log:: debug!(
128+ "Activity: mapping_idx={}, part={:?}, value={}" ,
129+ event. mapping_idx,
130+ event. part,
131+ event. value
132+ ) ;
133+
134+ if let Some ( node_ids) = self . mapping_nodes . get ( & event. mapping_idx ) {
135+ let target_node_id = match event. part {
136+ eos_midi_bridge:: ActivityPart :: Trigger => Some ( node_ids. trigger ) ,
137+ eos_midi_bridge:: ActivityPart :: Action => Some ( node_ids. action ) ,
138+ eos_midi_bridge:: ActivityPart :: Output ( i) => {
139+ node_ids. outputs . get ( i) . copied ( )
140+ }
141+ } ;
143142
144- if let Some ( node_id) = target_node_id {
145- if let Some ( node) = self . snarl . get_node_mut ( node_id) {
146- let live_state = match node {
147- eos_midi_bridge:: nodes:: NodeData :: Trigger ( _, s) => s,
148- eos_midi_bridge:: nodes:: NodeData :: Action ( _, s) => s,
149- eos_midi_bridge:: nodes:: NodeData :: Output ( _, s) => s,
150- } ;
151- live_state. last_value = event. value . clone ( ) ;
152- live_state. last_activity = Some ( std:: time:: Instant :: now ( ) ) ;
153- log:: debug!(
154- "Updated node {:?} with value: {}" ,
155- node_id,
156- event. value
157- ) ;
158- }
159- } else {
160- log:: warn!(
161- "No node_id found for mapping_idx={}, part={:?}" ,
162- event. mapping_idx,
163- event. part
164- ) ;
143+ if let Some ( node_id) = target_node_id {
144+ if let Some ( node) = self . snarl . get_node_mut ( node_id) {
145+ let live_state = match node {
146+ eos_midi_bridge:: nodes:: NodeData :: Trigger ( _, s) => s,
147+ eos_midi_bridge:: nodes:: NodeData :: Action ( _, s) => s,
148+ eos_midi_bridge:: nodes:: NodeData :: Output ( _, s) => s,
149+ } ;
150+ live_state. last_value = event. value . clone ( ) ;
151+ live_state. last_activity = Some ( std:: time:: Instant :: now ( ) ) ;
152+ log:: debug!( "Updated node {:?} with value: {}" , node_id, event. value) ;
165153 }
166154 } else {
167- log:: warn!( "No mapping found for mapping_idx={}" , event. mapping_idx) ;
155+ log:: warn!(
156+ "No node_id found for mapping_idx={}, part={:?}" ,
157+ event. mapping_idx,
158+ event. part
159+ ) ;
168160 }
161+ } else {
162+ log:: warn!( "No mapping found for mapping_idx={}" , event. mapping_idx) ;
169163 }
170- ctx. request_repaint ( ) ;
171164 }
165+ ctx. request_repaint ( ) ;
172166 }
173167
174168 egui:: CentralPanel :: default ( ) . show ( ctx, |ui| {
@@ -367,12 +361,11 @@ impl eframe::App for BridgeApp {
367361 ui. label ( "MIDI Input:" ) ;
368362 let mut selected_in =
369363 self . config_edit . midi_in_name . clone ( ) ;
370- if let Some ( ref name) = selected_in {
371- if !m. available_in_ports . is_empty ( )
372- && !m. available_in_ports . contains ( name)
373- {
374- selected_in = None ;
375- }
364+ if let Some ( ref name) = selected_in
365+ && !m. available_in_ports . is_empty ( )
366+ && !m. available_in_ports . contains ( name)
367+ {
368+ selected_in = None ;
376369 }
377370 let display_in =
378371 selected_in. as_deref ( ) . unwrap_or ( "None" ) ;
@@ -398,12 +391,11 @@ impl eframe::App for BridgeApp {
398391 ui. label ( "MIDI Output:" ) ;
399392 let mut selected_out =
400393 self . config_edit . midi_out_name . clone ( ) ;
401- if let Some ( ref name) = selected_out {
402- if !m. available_out_ports . is_empty ( )
403- && !m. available_out_ports . contains ( name)
404- {
405- selected_out = None ;
406- }
394+ if let Some ( ref name) = selected_out
395+ && !m. available_out_ports . is_empty ( )
396+ && !m. available_out_ports . contains ( name)
397+ {
398+ selected_out = None ;
407399 }
408400 let display_out =
409401 selected_out. as_deref ( ) . unwrap_or ( "None" ) ;
@@ -465,16 +457,17 @@ impl eframe::App for BridgeApp {
465457 }
466458
467459 // Auto-apply changes if config has changed and is valid
468- if self . config_edit != self . last_applied_config {
469- if self . config_edit . validate ( ) . is_ok ( ) {
470- if let Err ( e) = self . tx_system . blocking_send (
471- SystemCommand :: Reconfigure ( self . config_edit . clone ( ) ) ,
472- ) {
473- error ! ( "Failed to send live reconfiguration command: {}" , e) ;
474- } else {
475- self . last_applied_config = self . config_edit . clone ( ) ;
476- self . status_message = "Settings applied" . to_string ( ) ;
477- }
460+ if self . config_edit != self . last_applied_config
461+ && self . config_edit . validate ( ) . is_ok ( )
462+ {
463+ if let Err ( e) = self
464+ . tx_system
465+ . blocking_send ( SystemCommand :: Reconfigure ( self . config_edit . clone ( ) ) )
466+ {
467+ error ! ( "Failed to send live reconfiguration command: {}" , e) ;
468+ } else {
469+ self . last_applied_config = self . config_edit . clone ( ) ;
470+ self . status_message = "Settings applied" . to_string ( ) ;
478471 }
479472 }
480473 }
@@ -492,10 +485,10 @@ impl eframe::App for BridgeApp {
492485 self . snarl_zoom_pending *= 0.8 ;
493486 }
494487 ui. separator ( ) ;
495- if ui. button ( "🔄 Refresh Mapping" ) . clicked ( ) {
496- if let Ok ( m) = self . midi . lock ( ) {
497- populate_needed = Some ( m . profile . clone ( ) ) ;
498- }
488+ if ui. button ( "🔄 Refresh Mapping" ) . clicked ( )
489+ && let Ok ( m) = self . midi . lock ( )
490+ {
491+ populate_needed = Some ( m . profile . clone ( ) ) ;
499492 }
500493 ui. separator ( ) ;
501494 ui. label ( "Ctrl + Scroll to zoom, Drag to pan" ) ;
@@ -504,10 +497,10 @@ impl eframe::App for BridgeApp {
504497 ui. separator ( ) ;
505498
506499 // If snarl is empty, populate it automatically
507- if self . snarl . nodes ( ) . next ( ) . is_none ( ) {
508- if let Ok ( m) = self . midi . lock ( ) {
509- populate_needed = Some ( m . profile . clone ( ) ) ;
510- }
500+ if self . snarl . nodes ( ) . next ( ) . is_none ( )
501+ && let Ok ( m) = self . midi . lock ( )
502+ {
503+ populate_needed = Some ( m . profile . clone ( ) ) ;
511504 }
512505
513506 let snarl_rect = ui. available_rect_before_wrap ( ) ;
0 commit comments