diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2006-10-31 02:40:08 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2006-10-31 02:40:08 +0000 |
commit | 71c94e69438c7c282b2dcac5ead080119944b290 (patch) | |
tree | 17bc6b75ff24c0eca6a7a45043f2c9d11cc2ff0c /gtk2_ardour/automation_line.cc | |
parent | 74df5d49c8ff42c05d7eb9300c3a9f9a7257e694 (diff) |
massive changes in automation state handling, not entirely complete; some bug fixes for automation line drawing
git-svn-id: svn://localhost/ardour2/trunk@1034 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/automation_line.cc')
-rw-r--r-- | gtk2_ardour/automation_line.cc | 56 |
1 files changed, 33 insertions, 23 deletions
diff --git a/gtk2_ardour/automation_line.cc b/gtk2_ardour/automation_line.cc index 339af96d76..f52b2dcf42 100644 --- a/gtk2_ardour/automation_line.cc +++ b/gtk2_ardour/automation_line.cc @@ -245,7 +245,7 @@ AutomationLine::AutomationLine (const string & name, TimeAxisView& tv, ArdourCan alist.StateChanged.connect (mem_fun(*this, &AutomationLine::list_changed)); - trackview.session().register_with_memento_command_factory(_id, this); + trackview.session().register_with_memento_command_factory(alist.id(), this); } @@ -670,11 +670,16 @@ AutomationLine::determine_visible_control_points (ALPoints& points) uint32_t this_ry = 0; uint32_t prev_ry = 0; double* slope; + double box_size; + uint32_t cpsize; /* hide all existing points, and the line */ + + cpsize = 0; for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) { (*i)->hide(); + ++cpsize; } line->hide (); @@ -695,6 +700,13 @@ AutomationLine::determine_visible_control_points (ALPoints& points) slope[n] = ydelta/xdelta; } + if (_height > (guint32) TimeAxisView::Larger) { + box_size = 8.0; + } else if (_height > (guint32) TimeAxisView::Normal) { + box_size = 6.0; + } else { + box_size = 4.0; + } /* read all points and decide which ones to show as control points */ view_index = 0; @@ -738,27 +750,23 @@ AutomationLine::determine_visible_control_points (ALPoints& points) this_rx = (uint32_t) rint (tx); this_ry = (unsigned long) rint (ty); - if (view_index && pi != npoints && (this_rx == prev_rx) && (this_ry == prev_ry)) { - + if (view_index && pi != npoints && (this_rx == prev_rx) && (this_ry == prev_ry) || + ((this_rx - prev_rx) < (box_size + 2))) { continue; } /* ok, we should display this point */ - if (view_index >= control_points.size()) { + if (view_index >= cpsize) { + /* make sure we have enough control points */ ControlPoint* ncp = new ControlPoint (*this); - - if (_height > (guint32) TimeAxisView::Larger) { - ncp->set_size (8.0); - } else if (_height > (guint32) TimeAxisView::Normal) { - ncp->set_size (6.0); - } else { - ncp->set_size (4.0); - } + + ncp->set_size (box_size); control_points.push_back (ncp); + ++cpsize; } ControlPoint::ShapeType shape; @@ -829,6 +837,10 @@ AutomationLine::determine_visible_control_points (ALPoints& points) line_points.push_back (Art::Point (0,0)); } + while (line_points.size() > npoints) { + line_points.pop_back (); + } + for (view_index = 0; view_index < npoints; ++view_index) { line_points[view_index].set_x (control_points[view_index]->get_x()); line_points[view_index].set_y (control_points[view_index]->get_y()); @@ -1193,9 +1205,7 @@ AutomationLine::reset_callback (const AutomationList& events) for (ai = events.const_begin(); ai != events.const_end(); ++ai) { - double translated_y; - - translated_y = (*ai)->value; + double translated_y = (*ai)->value; model_to_view_y (translated_y); tmp_points.push_back (ALPoint (trackview.editor.frame_to_unit ((*ai)->when), @@ -1263,16 +1273,16 @@ AutomationLine::hide_all_but_selected_control_points () } } -XMLNode &AutomationLine::get_state(void) +XMLNode & +AutomationLine::get_state (void) { - XMLNode *node = new XMLNode("AutomationLine"); - node->add_child_nocopy(alist.get_state()); - return *node; + /* function as a proxy for the model */ + return alist.get_state(); } -int AutomationLine::set_state(const XMLNode &node) +int +AutomationLine::set_state (const XMLNode &node) { - // TODO - //alist.set_state(node); - return 0; + /* function as a proxy for the model */ + return alist.set_state (node); } |