@@ -15,6 +15,12 @@ const CYAN: Color32 = Color32::from_rgb(14,177,210);
1515const YELLOW : Color32 = Color32 :: from_rgb ( 248 , 255 , 31 ) ;
1616const DARK : Color32 = Color32 :: from_rgb ( 40 , 40 , 40 ) ;
1717
18+ #[ derive( Enum , Clone , PartialEq ) ]
19+ pub enum BeatSync {
20+ Beat ,
21+ Bar
22+ }
23+
1824pub struct Gain {
1925 params : Arc < GainParams > ,
2026
@@ -57,6 +63,10 @@ struct GainParams {
5763 /// Horizontal Scaling
5864 #[ id = "scaling" ]
5965 pub h_scale : IntParam ,
66+
67+ /// Sync Timing
68+ #[ id = "Sync Timing" ]
69+ pub sync_timing : EnumParam < BeatSync > ,
6070}
6171
6272impl Default for Gain {
@@ -114,6 +124,9 @@ impl Default for GainParams {
114124 24 ,
115125 IntRange :: Linear { min : 1 , max : 150 } ,
116126 ) . with_unit ( " Skip" ) ,
127+
128+ // Sync timing parameter
129+ sync_timing : EnumParam :: new ( "Timing" , BeatSync :: Beat ) ,
117130 }
118131 }
119132}
@@ -225,16 +238,17 @@ impl Plugin for Gain {
225238 ui. add_space ( 4.0 ) ;
226239 let _swap_response = ui. checkbox ( & mut ontop. lock ( ) , "Swap" ) . on_hover_text ( "Change the drawing order of waveforms" ) ;
227240
228- let sync_response = ui. checkbox ( & mut sync_var. lock ( ) , "Sync Beat " ) . on_hover_text ( "Lock drawing to beat " ) ;
241+ let sync_response = ui. checkbox ( & mut sync_var. lock ( ) , "Sync" ) . on_hover_text ( "Lock drawing to timing " ) ;
229242 let alt_sync = ui. checkbox ( & mut alt_sync. lock ( ) , "Alt. Sync" ) . on_hover_text ( "Try this if Sync doesn't work" ) ;
243+ let timing = ui. add ( widgets:: ParamSlider :: for_param ( & params. sync_timing , setter) . with_width ( 60.0 ) ) ;
230244
231245 let dir_response = ui. checkbox ( & mut dir_var. lock ( ) , "Flip" ) . on_hover_text ( "Flip direction of oscilloscope" ) ;
232246
233247 if gain_handle. changed ( ) {
234248 sum_line = Line :: new ( PlotPoints :: default ( ) ) ;
235249 }
236250 // Reset our line on change
237- if sync_response. clicked ( ) || dir_response. clicked ( ) || alt_sync. clicked ( )
251+ if sync_response. clicked ( ) || dir_response. clicked ( ) || alt_sync. clicked ( ) || timing . changed ( )
238252 {
239253 sum_line = Line :: new ( PlotPoints :: default ( ) ) ;
240254 aux_line = Line :: new ( PlotPoints :: default ( ) ) ;
0 commit comments