X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Feditor_timefx.cc;h=2efdc03f8fdca0c723997ea380732ed01ef2b7e8;hb=60b97472b1e99c75fe68dd20de59d105c09b6c4e;hp=805c4e0b1daee20997e7526d10350dcde2f220c9;hpb=54a80321064aa543023cd0b224ba9d433520983f;p=ardour.git diff --git a/gtk2_ardour/editor_timefx.cc b/gtk2_ardour/editor_timefx.cc index 805c4e0b1d..2efdc03f8f 100644 --- a/gtk2_ardour/editor_timefx.cc +++ b/gtk2_ardour/editor_timefx.cc @@ -15,7 +15,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id$ */ #include @@ -25,10 +24,13 @@ #include #include +#include + +#include #include "editor.h" #include "audio_time_axis.h" -#include "regionview.h" +#include "audio_region_view.h" #include "region_selection.h" #include @@ -36,62 +38,55 @@ #include #include #include -#include +#include #include "i18n.h" using namespace ARDOUR; +using namespace PBD; using namespace sigc; using namespace Gtk; +using namespace Gtkmm2ext; Editor::TimeStretchDialog::TimeStretchDialog (Editor& e) : ArdourDialog ("time stretch dialog"), editor (e), quick_button (_("Quick but Ugly")), - antialias_button (_("Skip Anti-aliasing")), - cancel_button (_("Cancel")), - action_button (_("Stretch/Shrink it")) + antialias_button (_("Skip Anti-aliasing")) { set_modal (true); set_position (Gtk::WIN_POS_MOUSE); - set_title (_("ardour: timestretch")); set_name (N_("TimeStretchDialog")); - set_hide_on_stop (false); + WindowTitle title(Glib::get_application_name()); + title += _("Timestretch"); + set_title(title.get_string()); - add (packer); + get_vbox()->set_spacing (5); + get_vbox()->set_border_width (5); + get_vbox()->pack_start (upper_button_box); + get_vbox()->pack_start (progress_bar); - packer.set_spacing (5); - packer.set_border_width (5); - packer.pack_start (upper_button_box); - packer.pack_start (progress_bar); - packer.pack_start (lower_button_box); - upper_button_box.set_homogeneous (true); upper_button_box.set_spacing (5); upper_button_box.set_border_width (5); upper_button_box.pack_start (quick_button, true, true); upper_button_box.pack_start (antialias_button, true, true); - lower_button_box.set_homogeneous (true); - lower_button_box.set_spacing (5); - lower_button_box.set_border_width (5); - lower_button_box.pack_start (action_button, true, true); - lower_button_box.pack_start (cancel_button, true, true); + action_button = add_button (_("Stretch/Shrink it"), Gtk::RESPONSE_ACCEPT); + cancel_button = add_button (_("Cancel"), Gtk::RESPONSE_CANCEL); - action_button.set_name (N_("TimeStretchButton")); - cancel_button.set_name (N_("TimeStretchButton")); quick_button.set_name (N_("TimeStretchButton")); antialias_button.set_name (N_("TimeStretchButton")); progress_bar.set_name (N_("TimeStretchProgress")); - action_button.signal_clicked().connect (bind (mem_fun(*this, &ArdourDialog::stop), 1)); + show_all_children (); } gint Editor::TimeStretchDialog::update_progress () { - progress_bar.set_fraction (request.progress/100); + progress_bar.set_fraction (request.progress); return request.running; } @@ -111,7 +106,7 @@ Editor::TimeStretchDialog::delete_timestretch_in_progress (GdkEventAny* ev) } int -Editor::run_timestretch (AudioRegionSelection& regions, float fraction) +Editor::run_timestretch (RegionSelection& regions, float fraction) { pthread_t thread; @@ -120,16 +115,13 @@ Editor::run_timestretch (AudioRegionSelection& regions, float fraction) } current_timestretch->progress_bar.set_fraction (0.0f); - current_timestretch->first_cancel = current_timestretch->cancel_button.signal_clicked().connect (bind (mem_fun (*current_timestretch, &ArdourDialog::stop), -1)); - // GTK2FIX - // current_timestretch->first_delete = current_timestretch->signal_delete_event().connect (mem_fun (*current_timestretch, &ArdourDialog::wm_close_event)); - current_timestretch->run (); - - if (current_timestretch->run_status() != 1) { - // GTK2FIX - // current_timestretch->close (); - return 1; /* no error, but we did nothing */ + switch (current_timestretch->run ()) { + case RESPONSE_ACCEPT: + break; + default: + current_timestretch->hide (); + return 1; } current_timestretch->status = 0; @@ -145,12 +137,11 @@ Editor::run_timestretch (AudioRegionSelection& regions, float fraction) current_timestretch->first_cancel.disconnect(); current_timestretch->first_delete.disconnect(); - current_timestretch->cancel_button.signal_clicked().connect (mem_fun (current_timestretch, &TimeStretchDialog::cancel_timestretch_in_progress)); + current_timestretch->cancel_button->signal_clicked().connect (mem_fun (current_timestretch, &TimeStretchDialog::cancel_timestretch_in_progress)); current_timestretch->signal_delete_event().connect (mem_fun (current_timestretch, &TimeStretchDialog::delete_timestretch_in_progress)); if (pthread_create_and_store ("timestretch", &thread, 0, timestretch_thread, current_timestretch)) { - // GTK2FIX - //current_timestretch->close (); + current_timestretch->hide (); error << _("timestretch cannot be started - thread creation error") << endmsg; return -1; } @@ -165,44 +156,46 @@ Editor::run_timestretch (AudioRegionSelection& regions, float fraction) c.disconnect (); - // GTK2FIX - // current_timestretch->close (); + current_timestretch->hide (); return current_timestretch->status; } void Editor::do_timestretch (TimeStretchDialog& dialog) { - AudioTrack* at; - Playlist* playlist; - AudioRegion* new_region; + Track* t; + boost::shared_ptr playlist; + boost::shared_ptr new_region; - for (AudioRegionSelection::iterator i = dialog.regions.begin(); i != dialog.regions.end(); ) { + for (RegionSelection::iterator i = dialog.regions.begin(); i != dialog.regions.end(); ) { + AudioRegionView* arv = dynamic_cast(*i); + if (!arv) + continue; - AudioRegion& aregion ((*i)->region); - TimeAxisView* tv = &(*i)->get_time_axis_view(); - AudioTimeAxisView* atv; - AudioRegionSelection::iterator tmp; + boost::shared_ptr region (arv->audio_region()); + TimeAxisView* tv = &(arv->get_time_axis_view()); + RouteTimeAxisView* rtv; + RegionSelection::iterator tmp; tmp = i; ++tmp; - if ((atv = dynamic_cast (tv)) == 0) { + if ((rtv = dynamic_cast (tv)) == 0) { i = tmp; continue; } - if ((at = dynamic_cast (&atv->route())) == 0) { + if ((t = dynamic_cast (rtv->route().get())) == 0) { i = tmp; continue; } - if ((playlist = at->disk_stream().playlist()) == 0) { + if ((playlist = t->diskstream()->playlist()) == 0) { i = tmp; continue; } - dialog.request.region = &aregion; + dialog.request.region = region; if (!dialog.request.running) { /* we were cancelled */ @@ -216,15 +209,17 @@ Editor::do_timestretch (TimeStretchDialog& dialog) return; } - session->add_undo (playlist->get_memento()); - playlist->replace_region (aregion, *new_region, aregion.position()); - session->add_redo_no_execute (playlist->get_memento()); + XMLNode &before = playlist->get_state(); + playlist->replace_region (region, new_region, region->position()); + XMLNode &after = playlist->get_state(); + session->add_command (new MementoCommand(*playlist, &before, &after)); i = tmp; } dialog.status = 0; dialog.request.running = false; + dialog.request.region.reset (); } void*