diff options
author | David Robillard <d@drobilla.net> | 2014-11-28 19:17:39 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2014-11-28 21:15:28 -0500 |
commit | f190e630ab2b3d2ff1f7c8640a7d4a072ea3437e (patch) | |
tree | 3c4e9e186186eb051e88ffbed4b17243282ea8d5 /libs | |
parent | e55b68298bbc820734532129be908459813acb8d (diff) |
Show discrete/toggled automation as stepped line.
Diffstat (limited to 'libs')
-rw-r--r-- | libs/canvas/canvas/poly_line.h | 2 | ||||
-rw-r--r-- | libs/canvas/poly_line.cc | 24 |
2 files changed, 26 insertions, 0 deletions
diff --git a/libs/canvas/canvas/poly_line.h b/libs/canvas/canvas/poly_line.h index 16db9a69e2..04b05f5df1 100644 --- a/libs/canvas/canvas/poly_line.h +++ b/libs/canvas/canvas/poly_line.h @@ -33,6 +33,8 @@ class LIBCANVAS_API PolyLine : public PolyItem PolyLine (Item*); void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const; + + virtual void set_steps (Points const &, bool stepped); bool covers (Duple const &) const; /** diff --git a/libs/canvas/poly_line.cc b/libs/canvas/poly_line.cc index 60bca6bccf..3150907db6 100644 --- a/libs/canvas/poly_line.cc +++ b/libs/canvas/poly_line.cc @@ -47,6 +47,30 @@ PolyLine::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) cons } } +void +PolyLine::set_steps (Points const & points, bool stepped) +{ + if (!stepped) { + PolyItem::set(points); + return; + } + + Points copy; + for (Points::const_iterator p = points.begin(); p != points.end();) { + Points::const_iterator next = p; + ++next; + + copy.push_back(*p); + if (next != points.end() && next->x != p->x) { + copy.push_back(Duple(next->x, p->y)); + } + + p = next; + } + + PolyItem::set(copy); +} + bool PolyLine::covers (Duple const & point) const { |