X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Feditor_selection.cc;h=7b08eaeaa6765aea2db48504efd9a6fa9a09037e;hb=44680aa1bb6c42d261e4b6424d5d76fd42f26624;hp=f788ef1f9d98698722bab1b3bc168ed945e60810;hpb=a2897ecef6da6a458aa1de8c2d9973a1e809dca2;p=ardour.git diff --git a/gtk2_ardour/editor_selection.cc b/gtk2_ardour/editor_selection.cc index f788ef1f9d..7b08eaeaa6 100644 --- a/gtk2_ardour/editor_selection.cc +++ b/gtk2_ardour/editor_selection.cc @@ -22,12 +22,11 @@ #include "pbd/stacktrace.h" -#include "ardour/session.h" +#include "ardour/midi_region.h" #include "ardour/playlist.h" -#include "ardour/route_group.h" #include "ardour/profile.h" -#include "ardour/midi_region.h" -#include "ardour/audioplaylist.h" +#include "ardour/route_group.h" +#include "ardour/session.h" #include "control_protocol/control_protocol.h" @@ -264,7 +263,6 @@ Editor::set_selected_track_as_side_effect (Selection::Operation op) case Selection::Extend: selection->clear(); - cerr << ("Editor::set_selected_track_as_side_effect case Selection::Add not yet implemented\n"); break; } } @@ -314,7 +312,7 @@ Editor::set_selected_track_from_click (bool press, Selection::Operation op, bool } bool -Editor::set_selected_control_point_from_click (Selection::Operation op, bool /*no_remove*/) +Editor::set_selected_control_point_from_click (bool press, Selection::Operation op) { if (!clicked_control_point) { return false; @@ -322,13 +320,37 @@ Editor::set_selected_control_point_from_click (Selection::Operation op, bool /*n switch (op) { case Selection::Set: - selection->set (clicked_control_point); + if (press) { + selection->set (clicked_control_point); + } break; case Selection::Add: - selection->add (clicked_control_point); + if (press) { + selection->add (clicked_control_point); + } break; case Selection::Toggle: - selection->toggle (clicked_control_point); + /* This is a bit of a hack; if we Primary-Click-Drag a control + point (for push drag) we want the point we clicked on to be + selected, otherwise we end up confusingly dragging an + unselected point. So here we ensure that the point is selected + after the press, and if we subsequently get a release (meaning no + drag occurred) we set things up so that the toggle has happened. + */ + if (press && !selection->selected (clicked_control_point)) { + /* This is the button press, and the control point is not selected; make it so, + in case this press leads to a drag. Also note that having done this, we don't + need to toggle again on release. + */ + selection->toggle (clicked_control_point); + _control_point_toggled_on_press = true; + } else if (!press && !_control_point_toggled_on_press) { + /* This is the release, and the point wasn't toggled on the press, so do it now */ + selection->toggle (clicked_control_point); + } else { + /* Reset our flag */ + _control_point_toggled_on_press = false; + } break; case Selection::Extend: /* XXX */ @@ -757,7 +779,7 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op) RouteTimeAxisView* closest = 0; int distance = INT_MAX; - int key = rtv->route()->order_key ("editor"); + int key = rtv->route()->order_key (EditorSort); for (RegionSelection::iterator x = selection->regions.begin(); x != selection->regions.end(); ++x) { @@ -772,7 +794,7 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op) if (result.second) { /* newly added to already_in_selection */ - int d = artv->route()->order_key ("editor"); + int d = artv->route()->order_key (EditorSort); d -= key; @@ -788,7 +810,7 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op) /* now add all tracks between that one and this one */ - int okey = closest->route()->order_key ("editor"); + int okey = closest->route()->order_key (EditorSort); if (okey > key) { swap (okey, key); @@ -798,7 +820,7 @@ Editor::set_selected_regionview_from_click (bool press, Selection::Operation op) RouteTimeAxisView* artv = dynamic_cast(*x); if (artv && artv != rtv) { - int k = artv->route()->order_key ("editor"); + int k = artv->route()->order_key (EditorSort); if (k >= okey && k <= key) { @@ -1014,19 +1036,6 @@ Editor::sensitize_all_region_actions (bool s) void Editor::sensitize_the_right_region_actions () { - if ((mouse_mode == MouseRange) || (mouse_mode != MouseObject && _join_object_range_state == JOIN_OBJECT_RANGE_RANGE)) { - sensitize_all_region_actions (false); - if (!selection->time.empty()) { - _region_actions->get_action("split-region")->set_sensitive (true); - } - return; - - } else if (mouse_mode != MouseObject) { - sensitize_all_region_actions (false); - return; - } - - /* We get here if we are in Object mode */ RegionSelection rs = get_regions_from_selection_and_entered (); sensitize_all_region_actions (!rs.empty ()); @@ -1051,6 +1060,10 @@ Editor::sensitize_the_right_region_actions () bool have_envelope_inactive = false; bool have_non_unity_scale_amplitude = false; bool have_compound_regions = false; + bool have_inactive_fade_in = false; + bool have_inactive_fade_out = false; + bool have_active_fade_in = false; + bool have_active_fade_out = false; for (list::const_iterator i = rs.begin(); i != rs.end(); ++i) { @@ -1110,6 +1123,18 @@ Editor::sensitize_the_right_region_actions () if (ar->scale_amplitude() != 1) { have_non_unity_scale_amplitude = true; } + + if (ar->fade_in_active ()) { + have_active_fade_in = true; + } else { + have_inactive_fade_in = true; + } + + if (ar->fade_out_active ()) { + have_active_fade_out = true; + } else { + have_inactive_fade_out = true; + } } } @@ -1164,7 +1189,7 @@ Editor::sensitize_the_right_region_actions () if (have_envelope_active && !have_envelope_inactive) { Glib::RefPtr::cast_dynamic (_region_actions->get_action("toggle-region-gain-envelope-active"))->set_active (); } else if (have_envelope_active && have_envelope_inactive) { - // _region_actions->get_action("toggle-region-gain-envelope-active")->set_inconsistent (); + // Glib::RefPtr::cast_dynamic (_region_actions->get_action("toggle-region-gain-envelope-active"))->set_inconsistent (); } } else { @@ -1180,25 +1205,29 @@ Editor::sensitize_the_right_region_actions () _region_actions->get_action("reset-region-scale-amplitude")->set_sensitive (false); } - Glib::RefPtr::cast_dynamic (_region_actions->get_action("toggle-region-lock"))->set_active (have_locked && !have_unlocked); + Glib::RefPtr a = Glib::RefPtr::cast_dynamic (_region_actions->get_action("toggle-region-lock")); + a->set_active (have_locked && !have_unlocked); if (have_locked && have_unlocked) { - // _region_actions->get_action("toggle-region-lock")->set_inconsistent (); + // a->set_inconsistent (); } - Glib::RefPtr::cast_dynamic (_region_actions->get_action("toggle-region-lock-style"))->set_active (have_position_lock_style_music && !have_position_lock_style_audio); + a = Glib::RefPtr::cast_dynamic (_region_actions->get_action("toggle-region-lock-style")); + a->set_active (have_position_lock_style_music && !have_position_lock_style_audio); if (have_position_lock_style_music && have_position_lock_style_audio) { - // _region_actions->get_action("toggle-region-lock-style")->set_inconsistent (); + // a->set_inconsistent (); } - Glib::RefPtr::cast_dynamic (_region_actions->get_action("toggle-region-mute"))->set_active (have_muted && !have_unmuted); + a = Glib::RefPtr::cast_dynamic (_region_actions->get_action("toggle-region-mute")); + a->set_active (have_muted && !have_unmuted); if (have_muted && have_unmuted) { - // _region_actions->get_action("toggle-region-mute")->set_inconsistent (); + // a->set_inconsistent (); } - Glib::RefPtr::cast_dynamic (_region_actions->get_action("toggle-opaque-region"))->set_active (have_opaque && !have_non_opaque); + a = Glib::RefPtr::cast_dynamic (_region_actions->get_action("toggle-opaque-region")); + a->set_active (have_opaque && !have_non_opaque); if (have_opaque && have_non_opaque) { - // _region_actions->get_action("toggle-opaque-region")->set_inconsistent (); + // a->set_inconsistent (); } if (!have_not_at_natural_position) { @@ -1212,6 +1241,29 @@ Editor::sensitize_the_right_region_actions () _region_actions->get_action("insert-region-from-region-list")->set_sensitive (true); } + a = Glib::RefPtr::cast_dynamic (_region_actions->get_action("toggle-region-fade-in")); + a->set_active (have_active_fade_in && !have_inactive_fade_in); + if (have_active_fade_in && have_inactive_fade_in) { + // a->set_inconsistent (); + } + + a = Glib::RefPtr::cast_dynamic (_region_actions->get_action("toggle-region-fade-out")); + a->set_active (have_active_fade_out && !have_inactive_fade_out); + + if (have_active_fade_out && have_inactive_fade_out) { + // a->set_inconsistent (); + } + + bool const have_active_fade = have_active_fade_in || have_active_fade_out; + bool const have_inactive_fade = have_inactive_fade_in || have_inactive_fade_out; + + a = Glib::RefPtr::cast_dynamic (_region_actions->get_action("toggle-region-fades")); + a->set_active (have_active_fade && !have_inactive_fade); + + if (have_active_fade && have_inactive_fade) { + // a->set_inconsistent (); + } + _ignore_region_action = false; _all_region_actions_sensitized = false;