X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fregion_editor.cc;h=27c74552816c0a9f9015a2eb6eca7f3422c12cfa;hb=c546ad359a1edb9cc2c2383cac00d49648b97268;hp=73aa3465d974a260c716de3c3c81560acef2094d;hpb=4ae64c91058a25423a9e1f533edfcda559736b1b;p=ardour.git diff --git a/gtk2_ardour/region_editor.cc b/gtk2_ardour/region_editor.cc old mode 100644 new mode 100755 index 73aa3465d9..27c7455281 --- a/gtk2_ardour/region_editor.cc +++ b/gtk2_ardour/region_editor.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2001 Paul Davis + Copyright (C) 2001 Paul Davis This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -15,17 +15,20 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id$ */ -#include -#include +#include "pbd/memento_command.h" +#include "pbd/stateful_diff_command.h" + +#include "ardour/session.h" +#include "ardour/region.h" +#include "ardour/playlist.h" +#include "ardour/utils.h" +#include "ardour/dB.h" #include -#include #include #include "region_editor.h" -#include "regionview.h" #include "ardour_ui.h" #include "utils.h" #include "gui_thread.h" @@ -33,331 +36,145 @@ #include "i18n.h" using namespace ARDOUR; -using namespace sigc; +using namespace PBD; using namespace std; +using namespace Gtkmm2ext; -AudioRegionEditor::AudioRegionEditor (Session&s, AudioRegion& r, AudioRegionView& rv) - : ArdourDialog ("audio region editor"), - _session (s), +RegionEditor::RegionEditor (Session* s, boost::shared_ptr r) + : ArdourDialog (_("Region")), + _table (8, 2), _region (r), - _region_view (rv), - name_label (_("NAME:")), - lock_button (_("lock")), - mute_button (_("mute")), - opaque_button (_("opaque")), - envelope_active_button(_("active")), - envelope_view_button(_("visible")), - raise_arrow (Gtk::ARROW_UP, Gtk::SHADOW_OUT), - lower_arrow (Gtk::ARROW_DOWN, Gtk::SHADOW_OUT), - layer_label (_("Layer")), - audition_button (_("play")), - time_table (3, 2), - start_clock ("AudioRegionEditorClock", true), - end_clock ("AudioRegionEditorClock", true), - length_clock ("AudioRegionEditorClock", true, true), - sync_offset_clock ("AudioRegionEditorClock", true, true), - envelope_loop_table (1, 3), - envelope_label (_("ENVELOPE")), - fade_in_table (4, 3), - fade_in_length_adjustment (5.0, 0.0, 10000, 0.05, 1), - fade_in_length_spinner (fade_in_length_adjustment, 10), - fade_out_table (4, 3), - fade_out_length_adjustment (5.0, 0.0, 10000, 0.05, 1), - fade_out_length_spinner (fade_out_length_adjustment, 10) - -{ - start_clock.set_session (&_session); - end_clock.set_session (&_session); - length_clock.set_session (&_session); - - name_entry.set_name ("AudioRegionEditorEntry"); - name_label.set_name ("AudioRegionEditorLabel"); - - name_hbox.set_spacing (5); - name_hbox.pack_start (name_label, false, false); - name_hbox.pack_start (name_entry, false, false); - - raise_button.add (raise_arrow); - lower_button.add (lower_arrow); - layer_frame.set_name ("BaseFrame"); - layer_frame.set_shadow_type (Gtk::SHADOW_IN); - layer_frame.add (layer_value_label); - layer_label.set_name ("AudioRegionEditorLabel"); - layer_value_label.set_name ("AudioRegionEditorLabel"); - Gtkmm2ext::set_size_request_to_display_given_text (layer_value_label, "99", 5, 2); - - layer_hbox.set_spacing (5); - layer_hbox.pack_start (layer_label, false, false); - layer_hbox.pack_start (layer_frame, false, false); -#if 0 - layer_hbox.pack_start (raise_button, false, false); - layer_hbox.pack_start (lower_button, false, false); -#endif - - mute_button.set_name ("AudioRegionEditorToggleButton"); - opaque_button.set_name ("AudioRegionEditorToggleButton"); - lock_button.set_name ("AudioRegionEditorToggleButton"); - envelope_active_button.set_name ("AudioRegionEditorToggleButton"); - envelope_view_button.set_name ("AudioRegionEditorToggleButton"); - fade_in_active_button.set_name ("AudioRegionEditorToggleButton"); - fade_out_active_button.set_name ("AudioRegionEditorToggleButton"); - audition_button.set_name ("AudioRegionEditorToggleButton"); - - ARDOUR_UI::instance()->tooltips().set_tip (mute_button, _("mute this region")); - ARDOUR_UI::instance()->tooltips().set_tip (opaque_button, _("regions underneath this one cannot be heard")); - ARDOUR_UI::instance()->tooltips().set_tip (lock_button, _("prevent any changes to this region")); - ARDOUR_UI::instance()->tooltips().set_tip (envelope_active_button, _("use the gain envelope during playback")); - ARDOUR_UI::instance()->tooltips().set_tip (envelope_view_button, _("show the gain envelope")); - ARDOUR_UI::instance()->tooltips().set_tip (fade_in_active_button, _("use fade in curve during playback")); - ARDOUR_UI::instance()->tooltips().set_tip (fade_out_active_button, _("use fade out curve during playback")); - ARDOUR_UI::instance()->tooltips().set_tip (audition_button, _("audition this region")); - - mute_button.unset_flags (Gtk::CAN_FOCUS); - opaque_button.unset_flags (Gtk::CAN_FOCUS); - lock_button.unset_flags (Gtk::CAN_FOCUS); - envelope_active_button.unset_flags (Gtk::CAN_FOCUS); - envelope_view_button.unset_flags (Gtk::CAN_FOCUS); - fade_in_active_button.unset_flags (Gtk::CAN_FOCUS); - fade_out_active_button.unset_flags (Gtk::CAN_FOCUS); - audition_button.unset_flags (Gtk::CAN_FOCUS); + name_label (_("Name:")), + audition_button (_("Play")), + position_clock (X_("regionposition"), true, X_("RegionEditorClock"), true, false), + end_clock (X_("regionend"), true, X_("RegionEditorClock"), true, false), + length_clock (X_("regionlength"), true, X_("RegionEditorClock"), true, false, true), + sync_offset_relative_clock (X_("regionsyncoffsetrelative"), true, X_("RegionEditorClock"), true, false), + sync_offset_absolute_clock (X_("regionsyncoffsetabsolute"), true, X_("RegionEditorClock"), true, false), + /* XXX cannot file start yet */ + start_clock (X_("regionstart"), true, X_("RegionEditorClock"), false, false) +{ + set_session (s); - mute_button.set_events (mute_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK)); - opaque_button.set_events (opaque_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK)); - lock_button.set_events (lock_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK)); - envelope_active_button.set_events (envelope_active_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK)); - envelope_view_button.set_events (envelope_view_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK)); - fade_in_active_button.set_events (fade_in_active_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK)); - fade_out_active_button.set_events (fade_out_active_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK)); - audition_button.set_events (audition_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK)); - - top_row_button_hbox.set_border_width (5); - top_row_button_hbox.set_spacing (5); - top_row_button_hbox.set_homogeneous (false); - top_row_button_hbox.pack_start (mute_button, false, false); - top_row_button_hbox.pack_start (opaque_button, false, false); - top_row_button_hbox.pack_start (lock_button, false, false); - top_row_button_hbox.pack_start (layer_hbox, false, false, 5); - top_row_button_hbox.pack_end (audition_button, false, false); - - top_row_hbox.pack_start (name_hbox, true, true); - top_row_hbox.pack_end (top_row_button_hbox, true, true); - - start_label.set_name ("AudioRegionEditorLabel"); - start_label.set_text (_("START:")); - end_label.set_name ("AudioRegionEditorLabel"); - end_label.set_text (_("END:")); - length_label.set_name ("AudioRegionEditorLabel"); - length_label.set_text (_("LENGTH:")); - - time_table.set_col_spacings (2); - time_table.set_row_spacings (5); - time_table.set_border_width (5); - - start_alignment.set (1.0, 0.5); - end_alignment.set (1.0, 0.5); - length_alignment.set (1.0, 0.5); - - start_alignment.add (start_label); - end_alignment.add (end_label); - length_alignment.add (length_label); - - time_table.attach (start_alignment, 0, 1, 0, 1, Gtk::FILL, Gtk::FILL); - time_table.attach (start_clock, 1, 2, 0, 1, Gtk::FILL, Gtk::FILL); - - time_table.attach (end_alignment, 0, 1, 1, 2, Gtk::FILL, Gtk::FILL); - time_table.attach (end_clock, 1, 2, 1, 2, Gtk::FILL, Gtk::FILL); - - time_table.attach (length_alignment, 0, 1, 2, 3, Gtk::FILL, Gtk::FILL); - time_table.attach (length_clock, 1, 2, 2, 3, Gtk::FILL, Gtk::FILL); - - envelope_label.set_name ("AudioRegionEditorLabel"); - - envelope_loop_table.set_border_width (5); - envelope_loop_table.set_row_spacings (2); - envelope_loop_table.attach (envelope_label, 0, 1, 0, 1, Gtk::FILL, Gtk::FILL); - envelope_loop_table.attach (envelope_active_button, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL); - envelope_loop_table.attach (envelope_view_button, 0, 1, 2, 3, Gtk::FILL|Gtk::EXPAND, Gtk::FILL); - - /* fade in */ - - fade_in_table.set_border_width (5); - fade_in_table.set_homogeneous (false); - - fade_in_label.set_name ("AudioRegionEditorLabel"); - fade_in_active_button_label.set_name ("AudioRegionEditorSmallLabel"); - fade_in_length_label.set_name ("AudioRegionEditorSmallLabel"); - - fade_in_label.set_text (_("FADE IN")); - fade_in_active_button_label.set_text (_("active")); - fade_in_length_label.set_text (_("msecs")); - - fade_in_active_button.add (fade_in_active_button_label); - - fade_in_length_spinner.set_name("GenericSpinner"); + position_clock.set_session (_session); + end_clock.set_session (_session); + length_clock.set_session (_session); + sync_offset_relative_clock.set_session (_session); + sync_offset_absolute_clock.set_session (_session); + start_clock.set_session (_session); - fade_in_length_spinner.set_digits (3); + ARDOUR_UI::instance()->set_tip (audition_button, _("audition this region")); - // fade_in_length_spinner.signal_activate().connect (mem_fun(*this, &AudioRegionEditor::activation)); - - Gtkmm2ext::set_size_request_to_display_given_text (fade_in_length_spinner, "500g", 20, -1); - - fade_in_label_align.add (fade_in_label); - fade_in_label_align.set (0.5); - - - fade_in_table.attach (fade_in_label_align, 0, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL); - - fade_in_table.attach (fade_in_length_label, 0, 1, 1, 2, Gtk::EXPAND, Gtk::FILL); - fade_in_table.attach (fade_in_length_spinner, 0, 1, 2, 3, Gtk::FILL|Gtk::EXPAND, Gtk::FILL); - - fade_in_table.attach (fade_in_active_button, 0, 2, 3, 5, Gtk::FILL|Gtk::EXPAND, Gtk::FILL); - - /* fade out */ - - fade_out_table.set_border_width (5); - fade_out_table.set_homogeneous (false); - - fade_out_label.set_name ("AudioRegionEditorLabel"); - fade_out_active_button_label.set_name ("AudioRegionEditorSmallLabel"); - fade_out_length_label.set_name ("AudioRegionEditorSmallLabel"); - - fade_out_label.set_text (_("FADE OUT")); - fade_out_active_button_label.set_text (_("active")); - fade_out_length_label.set_text (_("msecs")); + audition_button.unset_flags (Gtk::CAN_FOCUS); - fade_out_active_button.add (fade_out_active_button_label); + audition_button.set_events (audition_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK)); - fade_out_length_spinner.set_name("GenericSpinner"); + name_entry.set_name ("RegionEditorEntry"); + name_label.set_name ("RegionEditorLabel"); + position_label.set_name ("RegionEditorLabel"); + position_label.set_text (_("Position:")); + end_label.set_name ("RegionEditorLabel"); + end_label.set_text (_("End:")); + length_label.set_name ("RegionEditorLabel"); + length_label.set_text (_("Length:")); + sync_relative_label.set_name ("RegionEditorLabel"); + sync_relative_label.set_text (_("Sync point (relative to region):")); + sync_absolute_label.set_name ("RegionEditorLabel"); + sync_absolute_label.set_text (_("Sync point (absolute):")); + start_label.set_name ("RegionEditorLabel"); + start_label.set_text (_("File start:")); + + _table.set_col_spacings (12); + _table.set_row_spacings (6); + _table.set_border_width (12); + + name_label.set_alignment (1, 0.5); + position_label.set_alignment (1, 0.5); + end_label.set_alignment (1, 0.5); + length_label.set_alignment (1, 0.5); + sync_relative_label.set_alignment (1, 0.5); + sync_absolute_label.set_alignment (1, 0.5); + start_label.set_alignment (1, 0.5); + + Gtk::HBox* nb = Gtk::manage (new Gtk::HBox); + nb->set_spacing (6); + nb->pack_start (name_entry); + nb->pack_start (audition_button); + + _table.attach (name_label, 0, 1, 0, 1, Gtk::FILL, Gtk::FILL); + _table.attach (*nb, 1, 2, 0, 1, Gtk::FILL, Gtk::FILL); + + _table.attach (position_label, 0, 1, 1, 2, Gtk::FILL, Gtk::FILL); + _table.attach (position_clock, 1, 2, 1, 2, Gtk::FILL, Gtk::FILL); + + _table.attach (end_label, 0, 1, 2, 3, Gtk::FILL, Gtk::FILL); + _table.attach (end_clock, 1, 2, 2, 3, Gtk::FILL, Gtk::FILL); - fade_out_length_spinner.set_digits (3); - - fade_out_length_spinner.signal_activate().connect (mem_fun(*this, &AudioRegionEditor::activation)); + _table.attach (length_label, 0, 1, 3, 4, Gtk::FILL, Gtk::FILL); + _table.attach (length_clock, 1, 2, 3, 4, Gtk::FILL, Gtk::FILL); + + _table.attach (sync_relative_label, 0, 1, 4, 5, Gtk::FILL, Gtk::FILL); + _table.attach (sync_offset_relative_clock, 1, 2, 4, 5, Gtk::FILL, Gtk::FILL); + + _table.attach (sync_absolute_label, 0, 1, 5, 6, Gtk::FILL, Gtk::FILL); + _table.attach (sync_offset_absolute_clock, 1, 2, 5, 6, Gtk::FILL, Gtk::FILL); - Gtkmm2ext::set_size_request_to_display_given_text (fade_out_length_spinner, "500g", 20, -1); + _table.attach (start_label, 0, 1, 6, 7, Gtk::FILL, Gtk::FILL); + _table.attach (start_clock, 1, 2, 6, 7, Gtk::FILL, Gtk::FILL); - fade_out_label_align.add (fade_out_label); - fade_out_label_align.set (0.5); + get_vbox()->pack_start (_table, true, true); - fade_out_table.attach (fade_out_label_align, 0, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL); + add_button (Gtk::Stock::CLOSE, Gtk::RESPONSE_ACCEPT); - fade_out_table.attach (fade_out_length_label, 0, 1, 1, 2, Gtk::EXPAND, Gtk::FILL); - fade_out_table.attach (fade_out_length_spinner, 0, 1, 2, 3, Gtk::FILL|Gtk::EXPAND, Gtk::FILL); + set_name ("RegionEditorWindow"); + add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK); - fade_out_table.attach (fade_out_active_button, 0, 2, 3, 5, Gtk::FILL|Gtk::EXPAND, Gtk::FILL); + signal_delete_event().connect (sigc::bind (sigc::ptr_fun (just_hide_it), static_cast (this))); + signal_response().connect (sigc::mem_fun (*this, &RegionEditor::handle_response)); - lower_hbox.pack_start (time_table, true, true); - lower_hbox.pack_start (sep1, false, false); - lower_hbox.pack_start (envelope_loop_table, true, true); - lower_hbox.pack_start (sep2, false, false); - lower_hbox.pack_start (fade_in_table, true, true); - lower_hbox.pack_start (fade_out_table, true, true); + set_title (string_compose (_("Region '%1'"), _region->name())); - get_vbox()->pack_start (top_row_hbox, true, true); - get_vbox()->pack_start (sep3, false, false); - get_vbox()->pack_start (lower_hbox, true, true); + show_all(); - set_name ("AudioRegionEditorWindow"); - add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK); + name_changed (); - signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), static_cast (this))); + PropertyChange change; - string title = _("ardour: region "); - title += _region.name(); - set_title (title); + change.add (ARDOUR::Properties::start); + change.add (ARDOUR::Properties::length); + change.add (ARDOUR::Properties::position); + change.add (ARDOUR::Properties::sync_position); - show_all(); + bounds_changed (change); - name_changed (); - bounds_changed (Change (StartChanged|LengthChanged|PositionChanged)); - envelope_active_changed (); - mute_changed (); - opacity_changed (); - lock_changed (); - layer_changed (); - fade_in_changed (); - fade_out_changed (); - - XMLNode *node = _region.extra_xml ("GUI"); - XMLProperty *prop = 0; - bool showing_envelope = false; - - if (node && (prop = node->property ("envelope-visible")) != 0) { - if (prop->value() == "yes") { - showing_envelope = true; - } - } - - if (showing_envelope) { - envelope_view_button.set_active (true); - } else { - envelope_view_button.set_active (false); - } + _region->PropertyChanged.connect (state_connection, invalidator (*this), ui_bind (&RegionEditor::region_changed, this, _1), gui_context()); - _region.StateChanged.connect (mem_fun(*this, &AudioRegionEditor::region_changed)); - spin_arrow_grab = false; - - connect_editor_events (); -} -AudioRegionEditor::~AudioRegionEditor () -{ + connect_editor_events (); } void -AudioRegionEditor::region_changed (Change what_changed) +RegionEditor::region_changed (const PBD::PropertyChange& what_changed) { - if (what_changed & NameChanged) { + if (what_changed.contains (ARDOUR::Properties::name)) { name_changed (); } - if (what_changed & BoundsChanged) { - bounds_changed (what_changed); - } - if (what_changed & Region::OpacityChanged) { - opacity_changed (); - } - if (what_changed & Region::MuteChanged) { - mute_changed (); - } - if (what_changed & Region::LockChanged) { - lock_changed (); - } - if (what_changed & Region::LayerChanged) { - layer_changed (); - } - - if (what_changed & AudioRegion::EnvelopeActiveChanged) { - envelope_active_changed (); - } - if (what_changed & AudioRegion::FadeInChanged) { - fade_in_changed (); - } - if (what_changed & AudioRegion::FadeOutChanged) { - fade_out_changed (); - } - if (what_changed & AudioRegion::FadeInActiveChanged) { - fade_in_active_changed (); - } - if (what_changed & AudioRegion::FadeOutActiveChanged) { - fade_out_active_changed (); - } -} + PropertyChange interesting_stuff; -void -AudioRegionEditor::fade_in_realized () -{ - fade_in_changed (); -} + interesting_stuff.add (ARDOUR::Properties::position); + interesting_stuff.add (ARDOUR::Properties::length); + interesting_stuff.add (ARDOUR::Properties::start); + interesting_stuff.add (ARDOUR::Properties::sync_position); -void -AudioRegionEditor::fade_out_realized () -{ - fade_out_changed (); + if (what_changed.contains (interesting_stuff)) { + bounds_changed (what_changed); + } } -gint -AudioRegionEditor::bpressed (GdkEventButton* ev, Gtk::SpinButton* but, void (AudioRegionEditor::*pmf)()) +gint +RegionEditor::bpressed (GdkEventButton* ev, Gtk::SpinButton* /*but*/, void (RegionEditor::*/*pmf*/)()) { switch (ev->button) { case 1: @@ -369,9 +186,9 @@ AudioRegionEditor::bpressed (GdkEventButton* ev, Gtk::SpinButton* but, void (Aud // if ((ev->window == but->gobj()->panel)) { // spin_arrow_grab = true; // (this->*pmf)(); - // } - } - } + // } + } + } break; default: break; @@ -379,8 +196,8 @@ AudioRegionEditor::bpressed (GdkEventButton* ev, Gtk::SpinButton* but, void (Aud return FALSE; } -gint -AudioRegionEditor::breleased (GdkEventButton* ev, Gtk::SpinButton* but, void (AudioRegionEditor::*pmf)()) +gint +RegionEditor::breleased (GdkEventButton* /*ev*/, Gtk::SpinButton* /*but*/, void (RegionEditor::*pmf)()) { if (spin_arrow_grab) { (this->*pmf)(); @@ -390,342 +207,192 @@ AudioRegionEditor::breleased (GdkEventButton* ev, Gtk::SpinButton* but, void (Au } void -AudioRegionEditor::start_editing_fade_in () +RegionEditor::connect_editor_events () { - _region.freeze (); -} + name_entry.signal_changed().connect (sigc::mem_fun(*this, &RegionEditor::name_entry_changed)); -void -AudioRegionEditor::stop_editing_fade_in () -{ - _region.thaw (_("fade in edit")); -} + position_clock.ValueChanged.connect (sigc::mem_fun(*this, &RegionEditor::position_clock_changed)); + end_clock.ValueChanged.connect (sigc::mem_fun(*this, &RegionEditor::end_clock_changed)); + length_clock.ValueChanged.connect (sigc::mem_fun(*this, &RegionEditor::length_clock_changed)); + sync_offset_absolute_clock.ValueChanged.connect (sigc::mem_fun (*this, &RegionEditor::sync_offset_absolute_clock_changed)); + sync_offset_relative_clock.ValueChanged.connect (sigc::mem_fun (*this, &RegionEditor::sync_offset_relative_clock_changed)); -void -AudioRegionEditor::start_editing_fade_out () -{ - _region.freeze (); -} + audition_button.signal_toggled().connect (sigc::mem_fun(*this, &RegionEditor::audition_button_toggled)); -void -AudioRegionEditor::stop_editing_fade_out () -{ - _region.thaw (_("fade out edit")); + _session->AuditionActive.connect (audition_connection, invalidator (*this), ui_bind (&RegionEditor::audition_state_changed, this, _1), gui_context()); } void -AudioRegionEditor::connect_editor_events () +RegionEditor::position_clock_changed () { - name_entry.signal_changed().connect (mem_fun(*this, &AudioRegionEditor::name_entry_changed)); - - start_clock.ValueChanged.connect (mem_fun(*this, &AudioRegionEditor::start_clock_changed)); - end_clock.ValueChanged.connect (mem_fun(*this, &AudioRegionEditor::end_clock_changed)); - length_clock.ValueChanged.connect (mem_fun(*this, &AudioRegionEditor::length_clock_changed)); - - fade_in_length_spinner.signal_button_press_event().connect (bind (mem_fun(*this, &AudioRegionEditor::bpressed), &fade_in_length_spinner, - &AudioRegionEditor::start_editing_fade_in)); - fade_in_length_spinner.signal_button_release_event().connect (bind (mem_fun (*this, &AudioRegionEditor::breleased), &fade_in_length_spinner, - &AudioRegionEditor::stop_editing_fade_in)); - - fade_out_length_spinner.signal_button_press_event().connect (bind (mem_fun(*this, &AudioRegionEditor::bpressed), &fade_out_length_spinner, - &AudioRegionEditor::start_editing_fade_out)); - fade_out_length_spinner.signal_button_release_event().connect (bind (mem_fun (*this, &AudioRegionEditor::breleased), &fade_out_length_spinner, - &AudioRegionEditor::stop_editing_fade_out)); - - fade_in_length_adjustment.signal_value_changed().connect (mem_fun(*this, &AudioRegionEditor::fade_in_length_adjustment_changed)); - fade_out_length_adjustment.signal_value_changed().connect (mem_fun(*this, &AudioRegionEditor::fade_out_length_adjustment_changed)); - - fade_in_active_button.signal_toggled().connect (mem_fun(*this, &AudioRegionEditor::fade_in_active_toggled)); - fade_out_active_button.signal_toggled().connect (mem_fun(*this, &AudioRegionEditor::fade_out_active_toggled)); - - envelope_active_button.signal_button_press_event().connect (mem_fun(*this, &AudioRegionEditor::envelope_active_button_press)); - envelope_active_button.signal_button_release_event().connect (mem_fun(*this, &AudioRegionEditor::envelope_active_button_release)); - audition_button.signal_toggled().connect (mem_fun(*this, &AudioRegionEditor::audition_button_toggled)); - envelope_view_button.signal_toggled().connect (mem_fun(*this, &AudioRegionEditor::envelope_view_button_toggled)); - lock_button.signal_clicked().connect (mem_fun(*this, &AudioRegionEditor::lock_button_clicked)); - mute_button.signal_clicked().connect (mem_fun(*this, &AudioRegionEditor::mute_button_clicked)); - opaque_button.signal_clicked().connect (mem_fun(*this, &AudioRegionEditor::opaque_button_clicked)); - raise_button.signal_clicked().connect (mem_fun(*this, &AudioRegionEditor::raise_button_clicked)); - lower_button.signal_clicked().connect (mem_fun(*this, &AudioRegionEditor::lower_button_clicked)); - _session.AuditionActive.connect (mem_fun(*this, &AudioRegionEditor::audition_state_changed)); -} + _session->begin_reversible_command (_("change region start position")); -void -AudioRegionEditor::start_clock_changed () -{ - _region.set_position (start_clock.current_time(), this); -} + boost::shared_ptr pl = _region->playlist(); -void -AudioRegionEditor::end_clock_changed () -{ - _region.trim_end (end_clock.current_time(), this); - - end_clock.set (_region.position() + _region.length(), true); -} - -void -AudioRegionEditor::length_clock_changed () -{ - jack_nframes_t frames = length_clock.current_time(); - _region.trim_end (_region.position() + frames, this); - - length_clock.set (_region.length()); -} - -gint -AudioRegionEditor::envelope_active_button_press(GdkEventButton *ev) -{ - return stop_signal (envelope_active_button, "button_press_event"); -} + if (pl) { + _region->clear_history (); + _region->set_position (position_clock.current_time(), this); + _session->add_command(new StatefulDiffCommand (_region)); + } -gint -AudioRegionEditor::envelope_active_button_release (GdkEventButton *ev) -{ - _region.set_envelope_active (!_region.envelope_active()); - return stop_signal (envelope_active_button, "button_release_event"); + _session->commit_reversible_command (); } void -AudioRegionEditor::envelope_view_button_toggled () +RegionEditor::end_clock_changed () { - bool visible = envelope_view_button.get_active (); + _session->begin_reversible_command (_("change region end position")); - _region_view.set_envelope_visible (visible); -} + boost::shared_ptr pl = _region->playlist(); -void -AudioRegionEditor::audition_button_toggled () -{ - if (audition_button.get_active()) { - _session.audition_region (_region); - } else { - _session.cancel_audition (); + if (pl) { + _region->clear_history (); + _region->trim_end (end_clock.current_time(), this); + _session->add_command(new StatefulDiffCommand (_region)); } -} -void -AudioRegionEditor::raise_button_clicked () -{ - _region.raise (); -} + _session->commit_reversible_command (); -void -AudioRegionEditor::lower_button_clicked () -{ - _region.lower (); + end_clock.set (_region->position() + _region->length() - 1, true); } void -AudioRegionEditor::opaque_button_clicked () +RegionEditor::length_clock_changed () { - bool ractive = _region.opaque(); + nframes_t frames = length_clock.current_time(); - if (opaque_button.get_active() != ractive) { - _region.set_opaque (!ractive); - } -} + _session->begin_reversible_command (_("change region length")); -void -AudioRegionEditor::mute_button_clicked () -{ - bool ractive = _region.muted(); + boost::shared_ptr pl = _region->playlist(); - if (mute_button.get_active() != ractive) { - _region.set_muted (!ractive); + if (pl) { + _region->clear_history (); + _region->trim_end (_region->position() + frames - 1, this); + _session->add_command(new StatefulDiffCommand (_region)); } -} -void -AudioRegionEditor::lock_button_clicked () -{ - bool ractive = _region.locked(); - - if (lock_button.get_active() != ractive) { - _region.set_locked (!ractive); - } -} + _session->commit_reversible_command (); -void -AudioRegionEditor::layer_changed () -{ - char buf[8]; - snprintf (buf, sizeof(buf), "%d", (int) _region.layer() + 1); - layer_value_label.set_text (buf); + length_clock.set (_region->length()); } void -AudioRegionEditor::name_changed () +RegionEditor::audition_button_toggled () { - if (name_entry.get_text() != _region.name()) { - name_entry.set_text (_region.name()); + if (audition_button.get_active()) { + _session->audition_region (_region); + } else { + _session->cancel_audition (); } } void -AudioRegionEditor::lock_changed () +RegionEditor::name_changed () { - bool yn; - - if ((yn = _region.locked()) != lock_button.get_active()) { - lock_button.set_active (yn); + if (name_entry.get_text() != _region->name()) { + name_entry.set_text (_region->name()); } - - start_clock.set_sensitive (!yn); - end_clock.set_sensitive (!yn); - length_clock.set_sensitive (!yn); } void -AudioRegionEditor::envelope_active_changed () +RegionEditor::bounds_changed (const PropertyChange& what_changed) { - bool yn; - - if ((yn = _region.envelope_active()) != envelope_active_button.get_active()) { - envelope_active_button.set_active (yn); + if (what_changed.contains (ARDOUR::Properties::position) && what_changed.contains (ARDOUR::Properties::length)) { + position_clock.set (_region->position(), true); + end_clock.set (_region->position() + _region->length() - 1, true); + length_clock.set (_region->length(), true); + } else if (what_changed.contains (ARDOUR::Properties::position)) { + position_clock.set (_region->position(), true); + end_clock.set (_region->position() + _region->length() - 1, true); + } else if (what_changed.contains (ARDOUR::Properties::length)) { + end_clock.set (_region->position() + _region->length() - 1, true); + length_clock.set (_region->length(), true); } -} -void -AudioRegionEditor::opacity_changed () -{ - bool yn; - if ((yn = _region.opaque()) != opaque_button.get_active()) { - opaque_button.set_active (yn); - } -} + if (what_changed.contains (ARDOUR::Properties::sync_position) || what_changed.contains (ARDOUR::Properties::position)) { + int dir; + nframes_t off = _region->sync_offset (dir); + if (dir == -1) { + off = -off; + } -void -AudioRegionEditor::mute_changed () -{ - bool yn; - if ((yn = _region.muted()) != mute_button.get_active()) { - mute_button.set_active (yn); + if (what_changed.contains (ARDOUR::Properties::sync_position)) { + sync_offset_relative_clock.set (off, true); + } + + sync_offset_absolute_clock.set (off + _region->position (), true); } -} -void -AudioRegionEditor::bounds_changed (Change what_changed) -{ - if (what_changed & Change ((PositionChanged|LengthChanged))) { - start_clock.set (_region.position(), true); - end_clock.set (_region.position() + _region.length(), true); - length_clock.set (_region.length(), true); + if (what_changed.contains (ARDOUR::Properties::start)) { + start_clock.set (_region->start(), true); } } void -AudioRegionEditor::activation () +RegionEditor::activation () { - -} -void -AudioRegionEditor::name_entry_changed () -{ - if (name_entry.get_text() != _region.name()) { - _region.set_name (name_entry.get_text()); - } } void -AudioRegionEditor::fade_in_changed () +RegionEditor::name_entry_changed () { - float msecs = fade_in_length_adjustment.get_value(); - jack_nframes_t sr = _session.frame_rate(); - jack_nframes_t adj_frames = (jack_nframes_t) floor (msecs * (sr/1000.0f)); - jack_nframes_t frames; - bool x; - - if (adj_frames != (frames = (jack_nframes_t) _region.fade_in().back()->when)) { - fade_in_length_adjustment.set_value ((frames * 1000.0f) / sr); - } - - if ((x = _region.fade_in_active()) != fade_in_active_button.get_active()) { - fade_in_active_button.set_active (x); + if (name_entry.get_text() != _region->name()) { + _region->set_name (name_entry.get_text()); } } void -AudioRegionEditor::fade_out_changed () +RegionEditor::audition_state_changed (bool yn) { - float msecs = fade_out_length_adjustment.get_value(); - jack_nframes_t sr = _session.frame_rate(); - jack_nframes_t adj_frames = (jack_nframes_t) floor (msecs * (sr/1000.0f)); - jack_nframes_t frames; - bool x; - if (adj_frames != (frames = (jack_nframes_t) _region.fade_out().back()->when)) { - fade_out_length_adjustment.set_value ((frames * 1000.0f) / sr); - } + ENSURE_GUI_THREAD (*this, &RegionEditor::audition_state_changed, yn) - if ((x = _region.fade_out_active()) != fade_out_active_button.get_active()) { - fade_out_active_button.set_active (x); + if (!yn) { + audition_button.set_active (false); } } void -AudioRegionEditor::fade_in_length_adjustment_changed () +RegionEditor::sync_offset_absolute_clock_changed () { - jack_nframes_t fade_length = (jack_nframes_t) floor (fade_in_length_adjustment.get_value() * _session.frame_rate() * 0.001); - fade_length = max (fade_length, (jack_nframes_t) 64); - fade_length = min (fade_length, _region.length()); - - _region.set_fade_in_length (fade_length); - /* region is frozen, no worries */ - fade_in_changed(); -} + _session->begin_reversible_command (_("change region sync point")); -void -AudioRegionEditor::fade_out_length_adjustment_changed () -{ - jack_nframes_t fade_length = (jack_nframes_t) floor (fade_out_length_adjustment.get_value() * _session.frame_rate() * 0.001); - fade_length = max (fade_length, (jack_nframes_t) 64); - fade_length = min (fade_length, _region.length()); + _region->clear_history (); + _region->set_sync_position (sync_offset_absolute_clock.current_time()); + _session->add_command (new StatefulDiffCommand (_region)); - _region.set_fade_out_length (fade_length); - /* region is frozen, no worries */ - fade_out_changed(); + _session->commit_reversible_command (); } void -AudioRegionEditor::fade_in_active_toggled () +RegionEditor::sync_offset_relative_clock_changed () { - _region.set_fade_in_active (fade_in_active_button.get_active()); -} + _session->begin_reversible_command (_("change region sync point")); -void -AudioRegionEditor::fade_out_active_toggled () -{ - _region.set_fade_out_active (fade_out_active_button.get_active()); + _region->clear_history (); + _region->set_sync_position (sync_offset_relative_clock.current_time() + _region->position ()); + _session->add_command (new StatefulDiffCommand (_region)); + + _session->commit_reversible_command (); } -void -AudioRegionEditor::fade_out_active_changed () +bool +RegionEditor::on_delete_event (GdkEventAny* ev) { - bool x; + PropertyChange change; - if ((x = _region.fade_out_active()) != fade_out_active_button.get_active()) { - fade_out_active_button.set_active (x); - } -} + change.add (ARDOUR::Properties::start); + change.add (ARDOUR::Properties::length); + change.add (ARDOUR::Properties::position); + change.add (ARDOUR::Properties::sync_position); -void -AudioRegionEditor::fade_in_active_changed () -{ - bool x; + bounds_changed (change); - if ((x = _region.fade_in_active()) != fade_in_active_button.get_active()) { - fade_in_active_button.set_active (x); - } + return true; } void -AudioRegionEditor::audition_state_changed (bool yn) +RegionEditor::handle_response (int) { - ENSURE_GUI_THREAD (bind (mem_fun(*this, &AudioRegionEditor::audition_state_changed), yn)); - - if (!yn) { - audition_button.set_active (false); - } + hide (); } -