summaryrefslogtreecommitdiff
path: root/gtk2_ardour/automation_line.cc
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2010-01-05 02:22:58 +0000
committerCarl Hetherington <carl@carlh.net>2010-01-05 02:22:58 +0000
commit5f8f48117298231b053e62b9940ce753e0235906 (patch)
treeda0716c4b7a81ce03568bff1175ef79a23a59f8c /gtk2_ardour/automation_line.cc
parent14e32ba0758c776b2660f8b86a9192cddaa3de99 (diff)
Fixes to permit drags of multiply-selected automation control points.
git-svn-id: svn://localhost/ardour2/branches/3.0@6450 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/automation_line.cc')
-rw-r--r--gtk2_ardour/automation_line.cc58
1 files changed, 31 insertions, 27 deletions
diff --git a/gtk2_ardour/automation_line.cc b/gtk2_ardour/automation_line.cc
index c6cedb1c48..b304dcf2d4 100644
--- a/gtk2_ardour/automation_line.cc
+++ b/gtk2_ardour/automation_line.cc
@@ -1037,50 +1037,54 @@ AutomationLine::get_inverted_selectables (Selection&, list<Selectable*>& /*resul
// hmmm ....
}
-void
-AutomationLine::set_selected_points (PointSelection& points)
+/** Take a PointSelection and find ControlPoints that fall within it */
+list<ControlPoint*>
+AutomationLine::point_selection_to_control_points (PointSelection const & s)
{
- double top;
- double bot;
-
- for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
- (*i)->set_selected(false);
- }
-
- if (points.empty()) {
- goto out;
- }
-
- for (PointSelection::iterator r = points.begin(); r != points.end(); ++r) {
+ list<ControlPoint*> cp;
+
+ for (PointSelection::const_iterator i = s.begin(); i != s.end(); ++i) {
- if ((*r).track != &trackview) {
+ if (i->track != &trackview) {
continue;
}
/* Curse X11 and its inverted coordinate system! */
- bot = (1.0 - (*r).high_fract) * _height;
- top = (1.0 - (*r).low_fract) * _height;
+ double const bot = (1.0 - i->high_fract) * _height;
+ double const top = (1.0 - i->low_fract) * _height;
- for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
+ for (vector<ControlPoint*>::iterator j = control_points.begin(); j != control_points.end(); ++j) {
- double rstart, rend;
+ double const rstart = trackview.editor().frame_to_unit (i->start);
+ double const rend = trackview.editor().frame_to_unit (i->end);
- rstart = trackview.editor().frame_to_unit ((*r).start);
- rend = trackview.editor().frame_to_unit ((*r).end);
+ if ((*j)->get_x() >= rstart && (*j)->get_x() <= rend) {
+ if ((*j)->get_y() >= bot && (*j)->get_y() <= top) {
+ cp.push_back (*j);
+ }
+ }
+ }
- if ((*i)->get_x() >= rstart && (*i)->get_x() <= rend) {
+ }
- if ((*i)->get_y() >= bot && (*i)->get_y() <= top) {
+ return cp;
+}
- (*i)->set_selected(true);
- }
- }
+void
+AutomationLine::set_selected_points (PointSelection& points)
+{
+ for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
+ (*i)->set_selected (false);
+ }
+ if (!points.empty()) {
+ list<ControlPoint*> cp = point_selection_to_control_points (points);
+ for (list<ControlPoint*>::iterator i = cp.begin(); i != cp.end(); ++i) {
+ (*i)->set_selected (true);
}
}
- out:
set_colors ();
}