diff --git a/gtk2_ardour/automation_line.cc b/gtk2_ardour/automation_line.cc index ead6a2b56d..eca2b705ce 100644 --- a/gtk2_ardour/automation_line.cc +++ b/gtk2_ardour/automation_line.cc @@ -950,28 +950,24 @@ AutomationLine::remove_point (ControlPoint& cp) /** Get selectable points within an area. * @param start Start position in session frames. * @param end End position in session frames. - * @param botfrac Bottom of area, as a fraction of the line height. - * @param topfrac Bottom of area, as a fraction of the line height. + * @param bot Bottom y range, as a fraction of line height, where 0 is the bottom of the line. + * @param top Top y range, as a fraction of line height, where 0 is the bottom of the line. + * @param result Filled in with selectable things. */ void AutomationLine::get_selectables ( framepos_t start, framepos_t end, double botfrac, double topfrac, list& results ) { - - double top; - double bot; - /* these two are in AutomationList model coordinates */ double nstart; double nend; bool collecting = false; - /* Curse X11 and its inverted coordinate system! */ - - bot = (1.0 - topfrac) * _height; - top = (1.0 - botfrac) * _height; + /* convert fractions to display coordinates with 0 at the top of the track */ + double const bot_track = (1 - topfrac) * trackview.current_height (); + double const top_track = (1 - botfrac) * trackview.current_height (); nstart = DBL_MAX; nend = 0; @@ -982,7 +978,7 @@ AutomationLine::get_selectables ( if (session_frames_when >= start && session_frames_when <= end) { - if ((*i)->get_y() >= bot && (*i)->get_y() <= top) { + if ((*i)->get_y() >= bot_track && (*i)->get_y() <= top_track) { (*i)->show(); (*i)->set_visible(true); @@ -1027,10 +1023,8 @@ AutomationLine::point_selection_to_control_points (PointSelection const & s) continue; } - /* Curse X11 and its inverted coordinate system! */ - - double const bot = (1.0 - i->high_fract) * _height; - double const top = (1.0 - i->low_fract) * _height; + double const bot = (1 - i->high_fract) * trackview.current_height (); + double const top = (1 - i->low_fract) * trackview.current_height (); for (vector::iterator j = control_points.begin(); j != control_points.end(); ++j) { diff --git a/gtk2_ardour/automation_line.h b/gtk2_ardour/automation_line.h index 2704c13146..7377ab92a0 100644 --- a/gtk2_ardour/automation_line.h +++ b/gtk2_ardour/automation_line.h @@ -68,9 +68,7 @@ class AutomationLine : public sigc::trackable, public PBD::StatefulDestructible std::list point_selection_to_control_points (PointSelection const &); void set_selected_points (PointSelection&); - void get_selectables (ARDOUR::framepos_t start, ARDOUR::framepos_t end, - double botfrac, double topfrac, - std::list& results); + void get_selectables (ARDOUR::framepos_t, ARDOUR::framepos_t, double, double, std::list&); void get_inverted_selectables (Selection&, std::list& results); virtual void remove_point (ControlPoint&); diff --git a/gtk2_ardour/automation_selectable.h b/gtk2_ardour/automation_selectable.h index 8c897816ba..62ebd08aa2 100644 --- a/gtk2_ardour/automation_selectable.h +++ b/gtk2_ardour/automation_selectable.h @@ -25,8 +25,11 @@ class TimeAxisView; /** A selected automation point, expressed as a rectangle. + * * x coordinates start/end are in AutomationList model coordinates. - * y coordinates are a expressed as a fraction of track height. + * y coordinates are a expressed as a fraction of the AutomationTimeAxisView's height, where 0 is the + * bottom of the track, and 1 is the top. + * * This representation falls between the visible GUI control points and * the back-end "actual" automation points, some of which may not be * visible; it is not trivial to convert from one of these to the diff --git a/gtk2_ardour/automation_streamview.cc b/gtk2_ardour/automation_streamview.cc index 90e1b991fd..cdca5ec08f 100644 --- a/gtk2_ardour/automation_streamview.cc +++ b/gtk2_ardour/automation_streamview.cc @@ -276,6 +276,10 @@ AutomationStreamView::clear () /** @param start Start position in session frames. * @param end End position in session frames. + * @param bot Bottom position expressed as a fraction of track height where 0 is the bottom of the track. + * @param top Top position expressed as a fraction of track height where 0 is the bottom of the track. + * NOTE: this y system is different to that for the StreamView method that this overrides, which is a little + * confusing. */ void AutomationStreamView::get_selectables (framepos_t start, framepos_t end, double botfrac, double topfrac, list& results) diff --git a/gtk2_ardour/automation_time_axis.cc b/gtk2_ardour/automation_time_axis.cc index 56a54c0092..b9edc4ef63 100644 --- a/gtk2_ardour/automation_time_axis.cc +++ b/gtk2_ardour/automation_time_axis.cc @@ -827,21 +827,23 @@ AutomationTimeAxisView::paste_one (AutomationLine& line, framepos_t pos, float t } void -AutomationTimeAxisView::get_selectables (nframes_t start, nframes_t end, double top, double bot, list& results) +AutomationTimeAxisView::get_selectables (framepos_t start, framepos_t end, double top, double bot, list& results) { if (!_line && !_view) { return; } - + if (touched (top, bot)) { - double topfrac; - double botfrac; /* remember: this is X Window - coordinate space starts in upper left and moves down. _y_position is the "origin" or "top" of the track. */ - double mybot = _y_position + height; + /* bottom of our track */ + double const mybot = _y_position + height; + + double topfrac; + double botfrac; if (_y_position >= top && mybot <= bot) { @@ -858,6 +860,7 @@ AutomationTimeAxisView::get_selectables (nframes_t start, nframes_t end, double topfrac = 1.0 - ((top - _y_position) / height); botfrac = 1.0 - ((bot - _y_position) / height); + } if (_line) { diff --git a/gtk2_ardour/automation_time_axis.h b/gtk2_ardour/automation_time_axis.h index 85ad6ad7d9..8daccf97eb 100644 --- a/gtk2_ardour/automation_time_axis.h +++ b/gtk2_ardour/automation_time_axis.h @@ -78,7 +78,7 @@ class AutomationTimeAxisView : public TimeAxisView { boost::shared_ptr line() { return _line; } void set_selected_points (PointSelection&); - void get_selectables (nframes_t start, nframes_t end, double top, double bot, std::list&); + void get_selectables (ARDOUR::framepos_t start, ARDOUR::framepos_t end, double top, double bot, std::list&); void get_inverted_selectables (Selection&, std::list& results); void show_timestretch (nframes_t /*start*/, nframes_t /*end*/) {} diff --git a/gtk2_ardour/editor_canvas_events.cc b/gtk2_ardour/editor_canvas_events.cc index 34a73d318c..3ec82b3746 100644 --- a/gtk2_ardour/editor_canvas_events.cc +++ b/gtk2_ardour/editor_canvas_events.cc @@ -275,7 +275,7 @@ Editor::canvas_stream_view_event (GdkEvent *event, ArdourCanvas::Item* item, Rou clicked_regionview = 0; clicked_control_point = 0; clicked_axisview = tv; - clicked_routeview = dynamic_cast(tv); + clicked_routeview = dynamic_cast(clicked_axisview); ret = button_press_handler (item, event, StreamItem); break; diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 48ddeb55d2..cab8a929ef 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -2832,7 +2832,7 @@ ControlPointDrag::finished (GdkEvent* event, bool movement_occurred) /* just a click */ - if ((event->type == GDK_BUTTON_RELEASE) && (event->button.button == 1) && Keyboard::modifier_state_equals (event->button.state, Keyboard::TertiaryModifier)) { + if (Keyboard::modifier_state_equals (event->button.state, Keyboard::TertiaryModifier)) { _editor->reset_point_selection (); } diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc index 4febbacb68..3cc3129bf6 100644 --- a/gtk2_ardour/editor_mouse.cc +++ b/gtk2_ardour/editor_mouse.cc @@ -500,7 +500,7 @@ Editor::button_selection (ArdourCanvas::Item* /*item*/, GdkEvent* event, ItemTyp break; case ControlPointItem: - set_selected_track_as_side_effect (); + set_selected_track_as_side_effect (true); if (mouse_mode != MouseRange || _join_object_range_state == JOIN_OBJECT_RANGE_OBJECT) { set_selected_control_point_from_click (op, false); } diff --git a/gtk2_ardour/editor_selection.cc b/gtk2_ardour/editor_selection.cc index 75b4f30d61..33685be2ff 100644 --- a/gtk2_ardour/editor_selection.cc +++ b/gtk2_ardour/editor_selection.cc @@ -170,23 +170,23 @@ Editor::select_all_tracks () selection->set (visible_views); } -/** Select clicked_routeview, unless there are no currently selected +/** Select clicked_axisview, unless there are no currently selected * tracks, in which case nothing will happen unless `force' is true. */ void Editor::set_selected_track_as_side_effect (bool force) { - if (!clicked_routeview) { + if (!clicked_axisview) { return; } if (!selection->tracks.empty()) { - if (!selection->selected (clicked_routeview)) { - selection->add (clicked_routeview); + if (!selection->selected (clicked_axisview)) { + selection->add (clicked_axisview); } } else if (force) { - selection->set (clicked_routeview); + selection->set (clicked_axisview); } } @@ -255,9 +255,10 @@ Editor::set_selected_control_point_from_click (Selection::Operation op, bool /*n */ double const size = clicked_control_point->size (); + AutomationLine& line = clicked_control_point->line (); - nframes64_t const x1 = pixel_to_frame (clicked_control_point->get_x() - size / 2); - nframes64_t const x2 = pixel_to_frame (clicked_control_point->get_x() + size / 2); + nframes64_t const x1 = pixel_to_frame (clicked_control_point->get_x() - size / 2) + line.time_converter().origin_b (); + nframes64_t const x2 = pixel_to_frame (clicked_control_point->get_x() + size / 2) + line.time_converter().origin_b (); double y1 = clicked_control_point->get_y() - size / 2; double y2 = clicked_control_point->get_y() + size / 2; @@ -269,7 +270,7 @@ Editor::set_selected_control_point_from_click (Selection::Operation op, bool /*n _trackview_group->w2i (dummy, y2); /* and set up the selection */ - return select_all_within (x1, x2, y1, y2, selection->tracks, Selection::Set); + return select_all_within (x1, x2, y1, y2, selection->tracks, op); } void @@ -979,8 +980,8 @@ Editor::invert_selection () /** @param start Start time in session frames. * @param end End time in session frames. - * @param top Top (lower) y limit in trackview coordinates. - * @param bottom Bottom (higher) y limit in trackview coordinates. + * @param top Top (lower) y limit in trackview coordinates (ie 0 at the top of the track view) + * @param bottom Bottom (higher) y limit in trackview coordinates (ie 0 at the top of the track view) */ bool Editor::select_all_within (framepos_t start, framepos_t end, double top, double bot, const TrackViewList& tracklist, Selection::Operation op) diff --git a/gtk2_ardour/midi_streamview.h b/gtk2_ardour/midi_streamview.h index b9ce5a0ae8..2ef4697b37 100644 --- a/gtk2_ardour/midi_streamview.h +++ b/gtk2_ardour/midi_streamview.h @@ -57,7 +57,6 @@ class MidiStreamView : public StreamView ~MidiStreamView (); void set_selected_regionviews (RegionSelection&); - void get_selectables (nframes_t start, nframes_t end, std::list&); void get_inverted_selectables (Selection&, std::list& results); enum VisibleNoteRange { diff --git a/gtk2_ardour/route_time_axis.cc b/gtk2_ardour/route_time_axis.cc index b4f56f2ffe..fd528a4dbf 100644 --- a/gtk2_ardour/route_time_axis.cc +++ b/gtk2_ardour/route_time_axis.cc @@ -1182,7 +1182,7 @@ RouteTimeAxisView::set_selected_regionviews (RegionSelection& regions) * @param results List to add things to. */ void -RouteTimeAxisView::get_selectables (nframes_t start, nframes_t end, double top, double bot, list& results) +RouteTimeAxisView::get_selectables (framepos_t start, framepos_t end, double top, double bot, list& results) { double speed = 1.0; diff --git a/gtk2_ardour/route_time_axis.h b/gtk2_ardour/route_time_axis.h index baef76ee61..189035bf17 100644 --- a/gtk2_ardour/route_time_axis.h +++ b/gtk2_ardour/route_time_axis.h @@ -83,7 +83,7 @@ public: void selection_click (GdkEventButton*); void set_selected_points (PointSelection&); void set_selected_regionviews (RegionSelection&); - void get_selectables (nframes_t start, nframes_t end, double top, double bot, std::list&); + void get_selectables (ARDOUR::framepos_t start, ARDOUR::framepos_t end, double top, double bot, std::list&); void get_inverted_selectables (Selection&, std::list&); void set_layer_display (LayerDisplay d); LayerDisplay layer_display () const; diff --git a/gtk2_ardour/streamview.cc b/gtk2_ardour/streamview.cc index 8e8a87d49f..242510b32e 100644 --- a/gtk2_ardour/streamview.cc +++ b/gtk2_ardour/streamview.cc @@ -501,8 +501,17 @@ StreamView::set_selected_regionviews (RegionSelection& regions) } } + +/** Get selectable things within a given range. + * @param start Start time in session frames. + * @param end End time in session frames. + * @param top Top y range, in trackview coordinates (ie 0 is the top of the track view) + * @param bot Bottom y range, in trackview coordinates (ie 0 is the top of the track view) + * @param result Filled in with selectable things. + */ + void -StreamView::get_selectables (nframes_t start, nframes_t end, double top, double bottom, list& results) +StreamView::get_selectables (framepos_t start, framepos_t end, double top, double bottom, list& results) { layer_t min_layer = 0; layer_t max_layer = 0; diff --git a/gtk2_ardour/streamview.h b/gtk2_ardour/streamview.h index 304f38894e..5dbe32b2f3 100644 --- a/gtk2_ardour/streamview.h +++ b/gtk2_ardour/streamview.h @@ -94,7 +94,7 @@ public: void foreach_selected_regionview (sigc::slot slot); void set_selected_regionviews (RegionSelection&); - void get_selectables (nframes_t, nframes_t, double, double, std::list&); + void get_selectables (ARDOUR::framepos_t, ARDOUR::framepos_t, double, double, std::list&); void get_inverted_selectables (Selection&, std::list& results); virtual void update_contents_metrics(boost::shared_ptr) {} diff --git a/gtk2_ardour/time_axis_view.cc b/gtk2_ardour/time_axis_view.cc index 741756f1b2..631f6428e5 100644 --- a/gtk2_ardour/time_axis_view.cc +++ b/gtk2_ardour/time_axis_view.cc @@ -886,8 +886,15 @@ TimeAxisView::remove_child (boost::shared_ptr child) } } +/** Get selectable things within a given range. + * @param start Start time in session frames. + * @param end End time in session frames. + * @param top Top y range, in trackview coordinates (ie 0 is the top of the track view) + * @param bot Bottom y range, in trackview coordinates (ie 0 is the top of the track view) + * @param result Filled in with selectable things. + */ void -TimeAxisView::get_selectables (nframes_t /*start*/, nframes_t /*end*/, double /*top*/, double /*bot*/, list& /*result*/) +TimeAxisView::get_selectables (framepos_t /*start*/, framepos_t /*end*/, double /*top*/, double /*bot*/, list& /*result*/) { return; } diff --git a/gtk2_ardour/time_axis_view.h b/gtk2_ardour/time_axis_view.h index d84075977f..031b4e26f2 100644 --- a/gtk2_ardour/time_axis_view.h +++ b/gtk2_ardour/time_axis_view.h @@ -189,7 +189,7 @@ class TimeAxisView : public virtual AxisView, public PBD::Stateful void order_selection_trims (ArdourCanvas::Item *item, bool put_start_on_top); - virtual void get_selectables (nframes_t start, nframes_t end, double top, double bot, std::list& results); + virtual void get_selectables (ARDOUR::framepos_t, ARDOUR::framepos_t, double, double, std::list&); virtual void get_inverted_selectables (Selection&, std::list& results); void add_ghost (RegionView*);