diff --git a/gtk2_ardour/audio_trigger_properties_box.cc b/gtk2_ardour/audio_trigger_properties_box.cc index 7f3f0870ea..ff8eb3b42e 100644 --- a/gtk2_ardour/audio_trigger_properties_box.cc +++ b/gtk2_ardour/audio_trigger_properties_box.cc @@ -76,6 +76,8 @@ TriggerPropertiesBox::trigger_swap (uint32_t n) AudioTriggerPropertiesBox::AudioTriggerPropertiesBox () : _length_clock (X_("regionlength"), true, "", true, false, true) , _start_clock (X_("regionstart"), true, "", false, false) + , _follow_length_adjustment (0, 0, 128, 1, 4) + , _follow_length_spinner (_follow_length_adjustment) , _stretch_toggle (ArdourButton::led_default_elements) { _header_label.set_text (_("AUDIO Trigger Properties:")); @@ -123,12 +125,21 @@ AudioTriggerPropertiesBox::AudioTriggerPropertiesBox () _table.attach (_start_clock, 1, 2, row, row + 1, Gtk::SHRINK, Gtk::SHRINK); row++; - label = manage (new Gtk::Label (_("Length:"))); + label = manage (new Gtk::Label (_("Clip Length:"))); label->set_alignment (1.0, 0.5); _table.attach (*label, 0, 1, row, row + 1, Gtk::SHRINK, Gtk::SHRINK); _table.attach (_length_clock, 1, 2, row, row + 1, Gtk::SHRINK, Gtk::SHRINK); row++; + label = manage (new Gtk::Label (_("Follow Length:"))); + label->set_alignment (1.0, 0.5); + Gtk::Label *beat_label = manage (new Gtk::Label (_("(beats)"))); + beat_label->set_alignment (0.0, 0.5); + _table.attach (*label, 0, 1, row, row + 1, Gtk::SHRINK, Gtk::SHRINK); + _table.attach (_follow_length_spinner, 1, 2, row, row + 1, Gtk::SHRINK, Gtk::SHRINK); + _table.attach (*beat_label, 2, 3, row, row + 1, Gtk::SHRINK, Gtk::SHRINK); + row++; + _table.set_homogeneous (false); _table.set_spacings (4); _table.set_border_width (2); @@ -224,9 +235,46 @@ AudioTriggerPropertiesBox::trigger_changed (const PBD::PropertyChange& what_chan _start_clock.set (tref.trigger()->start_offset ()); _length_clock.set (tref.trigger()->current_length ()); // set_duration() ? + int metrum_numerator = 4; //TODO: use the SegmentDescriptor's meter + int bar_beats = metrum_numerator * tref.trigger()->follow_length().bars; + int beats = tref.trigger()->follow_length().beats; + _follow_length_adjustment.set_value (bar_beats+beats); //note: 0 is a special case meaning "use clip length" + + _start_clock.ValueChanged.connect (sigc::mem_fun (*this, &AudioTriggerPropertiesBox::start_clock_changed)); + _length_clock.ValueChanged.connect (sigc::mem_fun (*this, &AudioTriggerPropertiesBox::length_clock_changed)); + + _follow_length_spinner.set_can_focus(false); + _follow_length_spinner.signal_changed ().connect (sigc::mem_fun (*this, &AudioTriggerPropertiesBox::follow_clock_changed)); + _bpm_button.set_text (string_compose ("%1", trigger->apparent_tempo ())); _abpm_label.set_text (string_compose ("%1", trigger->apparent_tempo ())); _metrum_button.set_text ("4/4"); _stretch_toggle.set_active (tref.trigger()->stretchable () ? Gtkmm2ext::ExplicitActive : Gtkmm2ext::Off); } + + +void +AudioTriggerPropertiesBox::start_clock_changed () +{ + tref.trigger()->set_start(_start_clock.current_time()); +} + +void +AudioTriggerPropertiesBox::length_clock_changed () +{ + tref.trigger()->set_length(_length_clock.current_duration()); //? +} + +void +AudioTriggerPropertiesBox::follow_clock_changed () +{ + int beatz = (int) _follow_length_adjustment.get_value(); + + int metrum_numerator = 4; //TODO: use the SegmentDescriptor's meter + + int bars = beatz/metrum_numerator; + int beats = beatz%metrum_numerator; + + tref.trigger()->set_follow_length(Temporal::BBT_Offset(bars,beats,0)); +} diff --git a/gtk2_ardour/audio_trigger_properties_box.h b/gtk2_ardour/audio_trigger_properties_box.h index 1c6c3d62f3..7fbbe728e0 100644 --- a/gtk2_ardour/audio_trigger_properties_box.h +++ b/gtk2_ardour/audio_trigger_properties_box.h @@ -64,6 +64,10 @@ protected: void toggle_stretch (); void trigger_changed (const PBD::PropertyChange& what_changed); + void start_clock_changed(); + void length_clock_changed(); + void follow_clock_changed(); + private: Gtk::Table _table; @@ -71,6 +75,9 @@ private: AudioClock _length_clock; AudioClock _start_clock; + Gtk::Adjustment _follow_length_adjustment; + Gtk::SpinButton _follow_length_spinner; + ArdourWidgets::ArdourButton _bpm_button; ArdourWidgets::ArdourButton _metrum_button;