diff --git a/gtk2_ardour/automation_time_axis.cc b/gtk2_ardour/automation_time_axis.cc index e7958d1908..767fe49c9b 100644 --- a/gtk2_ardour/automation_time_axis.cc +++ b/gtk2_ardour/automation_time_axis.cc @@ -56,6 +56,7 @@ #include "automation_time_axis.h" #include "automation_streamview.h" +#include "ghostregion.h" #include "gui_thread.h" #include "route_time_axis.h" #include "automation_line.h" @@ -1250,3 +1251,19 @@ AutomationTimeAxisView::set_velocity_mode (VelocityMode vm, bool force) break; } } + +void +AutomationTimeAxisView::set_selected_regionviews (RegionSelection& rs) +{ + if (_parameter.type() != MidiVelocityAutomation) { + return; + } + + for (auto & ghost : ghosts) { + if (std::find (rs.begin(), rs.end(), &ghost->parent_rv) != rs.end()) { + ghost->set_selected (true); + } else { + ghost->set_selected (false); + } + } +} diff --git a/gtk2_ardour/automation_time_axis.h b/gtk2_ardour/automation_time_axis.h index 3a8080db72..4f235a5081 100644 --- a/gtk2_ardour/automation_time_axis.h +++ b/gtk2_ardour/automation_time_axis.h @@ -145,6 +145,8 @@ public: VelocityMode velocity_mode () const { return _velocity_mode; } void set_velocity_mode (VelocityMode, bool force = false); + void set_selected_regionviews (RegionSelection&); + protected: /* Note that for MIDI controller "automation" (in regions), all of these * may be set. In this case, _automatable is likely _route so the diff --git a/gtk2_ardour/ghostregion.h b/gtk2_ardour/ghostregion.h index 8a682f3e75..153aada5ce 100644 --- a/gtk2_ardour/ghostregion.h +++ b/gtk2_ardour/ghostregion.h @@ -68,6 +68,8 @@ public: void set_duration(double units); + virtual void set_selected (bool) {} + guint source_track_color(unsigned char alpha = 0xff); bool is_automation_ghost(); diff --git a/gtk2_ardour/midi_time_axis.cc b/gtk2_ardour/midi_time_axis.cc index 9790bd21df..c00648ae58 100644 --- a/gtk2_ardour/midi_time_axis.cc +++ b/gtk2_ardour/midi_time_axis.cc @@ -1849,4 +1849,3 @@ MidiTimeAxisView::create_velocity_automation_child (Evoral::Parameter const &, b add_automation_child (Evoral::Parameter(MidiVelocityAutomation), velocity_track, show); } - diff --git a/gtk2_ardour/route_time_axis.cc b/gtk2_ardour/route_time_axis.cc index 5e13350afe..1cc534396a 100644 --- a/gtk2_ardour/route_time_axis.cc +++ b/gtk2_ardour/route_time_axis.cc @@ -1145,6 +1145,10 @@ RouteTimeAxisView::set_selected_regionviews (RegionSelection& regions) if (_view) { _view->set_selected_regionviews (regions); } + + for (auto & child : children) { + child->set_selected_regionviews (regions); + } } /** Add the selectable things that we have to a list. diff --git a/gtk2_ardour/velocity_ghost_region.cc b/gtk2_ardour/velocity_ghost_region.cc index b5b25f6b30..c29fb6dcb6 100644 --- a/gtk2_ardour/velocity_ghost_region.cc +++ b/gtk2_ardour/velocity_ghost_region.cc @@ -56,6 +56,7 @@ VelocityGhostRegion::VelocityGhostRegion (MidiRegionView& mrv, TimeAxisView& tv, , dragging_line (nullptr) , last_drag_x (-1) , drag_did_change (false) + , selected (false) { base_rect->Event.connect (sigc::mem_fun (*this, &VelocityGhostRegion::base_event)); base_rect->set_fill_color (UIConfiguration::instance().color_mod ("ghost track base", "ghost track midi fill")); @@ -71,6 +72,11 @@ VelocityGhostRegion::~VelocityGhostRegion () bool VelocityGhostRegion::base_event (GdkEvent* ev) { + if (!selected) { + /* eat event to prevent it passing up th the automation track */ + return true; + } + std::vector affected_lollis; MidiRegionView* mrv = dynamic_cast (&parent_rv); @@ -97,10 +103,12 @@ VelocityGhostRegion::base_event (GdkEvent* ev) dragging_line->add_point (ArdourCanvas::Duple (ev->motion.x - r.x0, ev->motion.y - r.y0)); last_drag_x = ev->motion.x; } + return true; } break; case GDK_BUTTON_PRESS: if (ev->button.button == 1) { + assert (!dragging); desensitize_lollis (); dragging = true; drag_did_change = false; @@ -115,15 +123,17 @@ VelocityGhostRegion::base_event (GdkEvent* ev) dragging_line->raise_to_top(); base_rect->grab(); mrv->begin_drag_edit (_("draw velocities")); + return true; } break; case GDK_BUTTON_RELEASE: - if (ev->button.button == 1) { + if (ev->button.button == 1 && dragging) { mrv->end_drag_edit (drag_did_change); base_rect->ungrab(); dragging_line->hide (); dragging = false; sensitize_lollis (); + return true; } break; default: @@ -131,6 +141,7 @@ VelocityGhostRegion::base_event (GdkEvent* ev) break; } + return false; } @@ -210,7 +221,13 @@ VelocityGhostRegion::set_colors () base_rect->set_fill_color (UIConfiguration::instance().color_mod ("ghost track base", "ghost track midi fill")); for (auto & gev : events) { - gev.second->item->set_fill_color (gev.second->event->base_color()); + if (selected) { + gev.second->item->set_fill_color (gev.second->event->base_color()); + gev.second->item->set_ignore_events (false); + } else { + gev.second->item->set_fill_color (UIConfiguration::instance().color ("ghost track wave")); + gev.second->item->set_ignore_events (true); + } } } @@ -361,3 +378,9 @@ VelocityGhostRegion::sensitize_lollis () } } +void +VelocityGhostRegion::set_selected (bool yn) +{ + selected = yn; + set_colors (); +} diff --git a/gtk2_ardour/velocity_ghost_region.h b/gtk2_ardour/velocity_ghost_region.h index 9018b2ae54..152569eba8 100644 --- a/gtk2_ardour/velocity_ghost_region.h +++ b/gtk2_ardour/velocity_ghost_region.h @@ -47,11 +47,14 @@ public: int y_position_to_velocity (double y) const; + void set_selected (bool); + private: bool dragging; ArdourCanvas::PolyLine* dragging_line; int last_drag_x; bool drag_did_change; + bool selected; bool base_event (GdkEvent*); bool lollevent (GdkEvent*, MidiGhostRegion::GhostEvent*);