X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Froute_time_axis.cc;h=cc51444d43bfea3e08407f620c556b076e6d275a;hb=fd289ac9677d93f816038871440e52f20dd891fb;hp=68c108c91760af5924700b1cd198acc63bfdf9b8;hpb=3c45ab08468e552b1c6f2b5bd6dff2b74204a0b9;p=ardour.git diff --git a/gtk2_ardour/route_time_axis.cc b/gtk2_ardour/route_time_axis.cc index 68c108c917..cc51444d43 100644 --- a/gtk2_ardour/route_time_axis.cc +++ b/gtk2_ardour/route_time_axis.cc @@ -40,6 +40,7 @@ #include #include +#include #include #include #include @@ -104,9 +105,6 @@ RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session& sess, boost::sh ignore_toggle = false; - mute_button->set_active (false); - solo_button->set_active (false); - mute_button->set_name ("TrackMuteButton"); solo_button->set_name ("SoloButton"); edit_group_button.set_name ("TrackGroupButton"); @@ -116,7 +114,8 @@ RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session& sess, boost::sh visual_button.set_name ("TrackVisualButton"); hide_button.set_name ("TrackRemoveButton"); - hide_button.add (*(manage (new Image (get_xpm("small_x.xpm"))))); + hide_button.add (*(manage (new Image (::get_icon("hide"))))); + hide_button.show_all (); edit_group_button.signal_button_release_event().connect (mem_fun(*this, &RouteTimeAxisView::edit_click), false); playlist_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::playlist_click)); @@ -125,15 +124,27 @@ RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session& sess, boost::sh visual_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::visual_click)); hide_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::hide_click)); - solo_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::solo_press), false); - solo_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::solo_release), false); - mute_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::mute_press), false); - mute_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::mute_release), false); + solo_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::solo_press)); + solo_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::solo_release)); + mute_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::mute_press)); + mute_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::mute_release)); if (is_track()) { - rec_enable_button->set_active (false); + + /* use icon */ + + rec_enable_button->remove (); + switch (track()->mode()) { + case ARDOUR::Normal: + rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red")))))); + break; + case ARDOUR::Destructive: + rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red")))))); + break; + } + rec_enable_button->show_all (); + rec_enable_button->set_name ("TrackRecordEnableButton"); - //rec_enable_button->signal_button_press_event().connect (mem_fun (*this, &RouteTimeAxisView::select_me), false); rec_enable_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::rec_enable_press)); controls_table.attach (*rec_enable_button, 5, 6, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0); ARDOUR_UI::instance()->tooltips().set_tip(*rec_enable_button, _("Record")); @@ -178,21 +189,16 @@ RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session& sess, boost::sh /* map current state of the route */ update_diskstream_display (); - solo_changed(0); - mute_changed(0); - //redirects_changed (0); - //reset_redirect_automation_curves (); + redirects_changed (0); + reset_redirect_automation_curves (); y_position = -1; - _route->mute_changed.connect (mem_fun(*this, &RouteUI::mute_changed)); - _route->solo_changed.connect (mem_fun(*this, &RouteUI::solo_changed)); _route->redirects_changed.connect (mem_fun(*this, &RouteTimeAxisView::redirects_changed)); _route->name_changed.connect (mem_fun(*this, &RouteTimeAxisView::route_name_changed)); - _route->solo_safe_changed.connect (mem_fun(*this, &RouteUI::solo_changed)); - if (is_track()) { + track()->TrackModeChanged.connect (mem_fun(*this, &RouteTimeAxisView::track_mode_changed)); track()->FreezeChange.connect (mem_fun(*this, &RouteTimeAxisView::map_frozen)); track()->DiskstreamChanged.connect (mem_fun(*this, &RouteTimeAxisView::diskstream_changed)); get_diskstream()->SpeedChanged.connect (mem_fun(*this, &RouteTimeAxisView::speed_changed)); @@ -245,9 +251,6 @@ RouteTimeAxisView::set_playlist (Playlist *newplaylist) assert(pl); modified_connection.disconnect (); - state_changed_connection.disconnect (); - - state_changed_connection = pl->StateChanged.connect (mem_fun(*this, &RouteTimeAxisView::playlist_state_changed)); modified_connection = pl->Modified.connect (mem_fun(*this, &RouteTimeAxisView::playlist_modified)); } @@ -290,8 +293,6 @@ RouteTimeAxisView::add_edit_group_menu_item (RouteGroup *eg, RadioMenuItem::Grou MenuList &items = edit_group_menu.items(); - cerr << "adding edit group " << eg->name() << endl; - items.push_back (RadioMenuElem (*group, eg->name(), bind (mem_fun(*this, &RouteTimeAxisView::set_edit_group_from_menu), eg))); if (_route->edit_group() == eg) { static_cast(&items.back())->set_active (); @@ -300,18 +301,10 @@ RouteTimeAxisView::add_edit_group_menu_item (RouteGroup *eg, RadioMenuItem::Grou void RouteTimeAxisView::set_edit_group_from_menu (RouteGroup *eg) - { _route->set_edit_group (eg, this); } -void -RouteTimeAxisView::playlist_state_changed (Change ignored) -{ - // ENSURE_GUI_THREAD (bind (mem_fun(*this, &RouteTimeAxisView::playlist_state_changed), ignored)); - // why are we here ? -} - void RouteTimeAxisView::playlist_changed () @@ -356,14 +349,16 @@ RouteTimeAxisView::playlist_click () { // always build a new action menu - if (playlist_action_menu == 0) { - playlist_action_menu = new Menu; - playlist_action_menu->set_name ("ArdourContextMenu"); - } - - build_playlist_menu(playlist_action_menu); + if (playlist_action_menu != 0) { + delete playlist_action_menu; + } - playlist_action_menu->popup (1, 0); + playlist_action_menu = new Menu; + playlist_action_menu->set_name ("ArdourContextMenu"); + + build_playlist_menu (playlist_action_menu); + editor.set_selected_track (*this, Selection::Add); + playlist_action_menu->popup (1, gtk_get_current_event_time()); } void @@ -375,7 +370,8 @@ RouteTimeAxisView::automation_click () */ build_display_menu (); } - automation_action_menu->popup (1, 0); + editor.set_selected_track (*this, Selection::Add); + automation_action_menu->popup (1, gtk_get_current_event_time()); } void @@ -457,6 +453,24 @@ RouteTimeAxisView::build_display_menu () get_diskstream()->AlignmentStyleChanged.connect ( mem_fun(*this, &RouteTimeAxisView::align_style_changed)); + + RadioMenuItem::Group mode_group; + items.push_back (RadioMenuElem (mode_group, _("Normal mode"), + bind (mem_fun (*this, &RouteTimeAxisView::set_track_mode), ARDOUR::Normal))); + normal_track_mode_item = dynamic_cast(&items.back()); + items.push_back (RadioMenuElem (mode_group, _("Tape mode"), + bind (mem_fun (*this, &RouteTimeAxisView::set_track_mode), ARDOUR::Destructive))); + destructive_track_mode_item = dynamic_cast(&items.back()); + + + switch (track()->mode()) { + case ARDOUR::Destructive: + destructive_track_mode_item->set_active (); + break; + case ARDOUR::Normal: + normal_track_mode_item->set_active (); + break; + } } items.push_back (SeparatorElem()); @@ -468,9 +482,94 @@ RouteTimeAxisView::build_display_menu () items.push_back (MenuElem (_("Remove"), mem_fun(*this, &RouteUI::remove_this_route))); } +static bool __reset_item (RadioMenuItem* item) +{ + cerr << "reset item to true\n"; + item->set_active (); + return false; +} + +void +RouteTimeAxisView::set_track_mode (TrackMode mode) +{ + RadioMenuItem* item; + RadioMenuItem* other_item; + + switch (mode) { + case ARDOUR::Normal: + item = normal_track_mode_item; + other_item = destructive_track_mode_item; + break; + case ARDOUR::Destructive: + item = destructive_track_mode_item; + other_item = normal_track_mode_item; + break; + default: + fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", mode) << endmsg; + /*NOTREACHED*/ + return; + } + + if (item->get_active () && track()->mode() != mode) { + _set_track_mode (track(), mode, other_item); + } +} + +void +RouteTimeAxisView::_set_track_mode (Track* track, TrackMode mode, RadioMenuItem* reset_item) +{ + bool needs_bounce; + + if (!track->can_use_mode (mode, needs_bounce)) { + + if (!needs_bounce) { + /* cannot be done */ + Glib::signal_idle().connect (bind (sigc::ptr_fun (__reset_item), reset_item)); + return; + } else { + cerr << "would bounce this one\n"; + return; + } + } + + track->set_mode (mode); + + rec_enable_button->remove (); + switch (mode) { + case ARDOUR::Normal: + rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red")))))); + break; + case ARDOUR::Destructive: + rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red")))))); + break; + } + rec_enable_button->show_all (); + +} + +void +RouteTimeAxisView::track_mode_changed () +{ + RadioMenuItem* item; + + switch (track()->mode()) { + case ARDOUR::Normal: + item = normal_track_mode_item; + break; + case ARDOUR::Destructive: + item = destructive_track_mode_item; + break; + default: + fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", track()->mode()) << endmsg; + /*NOTREACHED*/ + return; + } + + item->set_active (); +} void -RouteTimeAxisView::show_timestretch (jack_nframes_t start, jack_nframes_t end) +RouteTimeAxisView::show_timestretch (nframes_t start, nframes_t end) { double x1; double x2; @@ -714,7 +813,24 @@ RouteTimeAxisView::align_style_changed () void RouteTimeAxisView::set_align_style (AlignStyle style) { - get_diskstream()->set_align_style (style); + RadioMenuItem* item; + + switch (style) { + case ExistingMaterial: + item = align_existing_item; + break; + case CaptureTime: + item = align_capture_item; + break; + default: + fatal << string_compose (_("programming error: %1 %2"), "illegal align style in RouteTimeAxisView::set_align_style", style) << endmsg; + /*NOTREACHED*/ + return; + } + + if (item->get_active()) { + get_diskstream()->set_align_style (style); + } } void @@ -786,7 +902,7 @@ RouteTimeAxisView::use_copy_playlist (bool prompt) if (name.length()) { ds->use_copy_playlist (); - pl->set_name (name); + ds->playlist()->set_name (name); } } @@ -813,7 +929,7 @@ RouteTimeAxisView::use_new_playlist (bool prompt) prompter.set_initial_text (name); prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT); prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false); - + switch (prompter.run ()) { case Gtk::RESPONSE_ACCEPT: prompter.get_result (name); @@ -826,7 +942,7 @@ RouteTimeAxisView::use_new_playlist (bool prompt) if (name.length()) { ds->use_new_playlist (); - pl->set_name (name); + ds->playlist()->set_name (name); } } @@ -883,6 +999,10 @@ RouteTimeAxisView::selection_click (GdkEventButton* ev) case Selection::Extend: /* not defined yet */ break; + + case Selection::Add: + editor.get_selection().add (*tracks); + break; } delete tracks; @@ -903,7 +1023,7 @@ RouteTimeAxisView::set_selected_regionviews (RegionSelection& regions) } void -RouteTimeAxisView::get_selectables (jack_nframes_t start, jack_nframes_t end, double top, double bot, list& results) +RouteTimeAxisView::get_selectables (nframes_t start, nframes_t end, double top, double bot, list& results) { double speed = 1.0; @@ -911,8 +1031,8 @@ RouteTimeAxisView::get_selectables (jack_nframes_t start, jack_nframes_t end, do speed = get_diskstream()->speed(); } - jack_nframes_t start_adjusted = session_frame_to_track_frame(start, speed); - jack_nframes_t end_adjusted = session_frame_to_track_frame(end, speed); + nframes_t start_adjusted = session_frame_to_track_frame(start, speed); + nframes_t end_adjusted = session_frame_to_track_frame(end, speed); if (_view && ((top < 0.0 && bot < 0.0)) || touched (top, bot)) { _view->get_selectables (start_adjusted, end_adjusted, results); @@ -1002,11 +1122,16 @@ RouteTimeAxisView::visual_click () void RouteTimeAxisView::hide_click () { + // LAME fix for hide_button refresh fix + hide_button.set_sensitive(false); + editor.hide_track_in_display (*this); + + hide_button.set_sensitive(true); } boost::shared_ptr -RouteTimeAxisView::find_next_region (jack_nframes_t pos, RegionPoint point, int32_t dir) +RouteTimeAxisView::find_next_region (nframes_t pos, RegionPoint point, int32_t dir) { boost::shared_ptr stream; Playlist *playlist; @@ -1071,7 +1196,7 @@ RouteTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op) } bool -RouteTimeAxisView::paste (jack_nframes_t pos, float times, Selection& selection, size_t nth) +RouteTimeAxisView::paste (nframes_t pos, float times, Selection& selection, size_t nth) { if (!is_track()) { return false; @@ -1128,12 +1253,28 @@ RouteTimeAxisView::build_playlist_menu (Gtk::Menu * menu) if (playlist_menu) { delete playlist_menu; } + playlist_menu = new Menu; playlist_menu->set_name ("ArdourContextMenu"); - playlist_items.push_back (MenuElem (string_compose (_("Current: %1"), get_diskstream()->playlist()->name()))); - playlist_items.push_back (SeparatorElem()); + vector playlists; + boost::shared_ptr ds = get_diskstream(); + RadioMenuItem::Group playlist_group; + + _session.get_playlists (playlists); + for (vector::iterator i = playlists.begin(); i != playlists.end(); ++i) { + + if ((*i)->get_orig_diskstream_id() == ds->id()) { + playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name(), bind (mem_fun (*this, &RouteTimeAxisView::use_playlist), (*i)))); + + if (ds->playlist()->id() == (*i)->id()) { + static_cast(&playlist_items.back())->set_active(); + } + } + } + + playlist_items.push_back (SeparatorElem()); playlist_items.push_back (MenuElem (_("Rename"), mem_fun(*this, &RouteTimeAxisView::rename_current_playlist))); playlist_items.push_back (SeparatorElem()); @@ -1142,8 +1283,20 @@ RouteTimeAxisView::build_playlist_menu (Gtk::Menu * menu) playlist_items.push_back (SeparatorElem()); playlist_items.push_back (MenuElem (_("Clear Current"), mem_fun(editor, &PublicEditor::clear_playlists))); playlist_items.push_back (SeparatorElem()); - playlist_items.push_back (MenuElem(_("Select"), mem_fun(*this, &RouteTimeAxisView::show_playlist_selector))); + playlist_items.push_back (MenuElem(_("Select from all ..."), mem_fun(*this, &RouteTimeAxisView::show_playlist_selector))); +} + +void +RouteTimeAxisView::use_playlist (Playlist* pl) +{ + AudioPlaylist* apl = dynamic_cast (pl); + + assert (is_track()); + + if (apl) { + get_diskstream()->use_playlist (apl); + } } void