diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2013-04-17 15:22:09 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2013-04-17 15:22:09 -0400 |
commit | ec102f94e1105a6c9f445a0cde6c2dd1b6ea4b8b (patch) | |
tree | 970d269534121d51960bc56a5d6092d88c6baf97 /libs/canvas | |
parent | 9727a2311100d87bba1ceac62e5a9e42e9420cd8 (diff) |
various work waveview amplitude mgmt; fix playhead cursor drag from timebar click
Diffstat (limited to 'libs/canvas')
-rw-r--r-- | libs/canvas/canvas.cc | 12 | ||||
-rw-r--r-- | libs/canvas/canvas/line.h | 2 | ||||
-rw-r--r-- | libs/canvas/canvas/wave_view.h | 17 | ||||
-rw-r--r-- | libs/canvas/line.cc | 14 | ||||
-rw-r--r-- | libs/canvas/wave_view.cc | 45 |
5 files changed, 62 insertions, 28 deletions
diff --git a/libs/canvas/canvas.cc b/libs/canvas/canvas.cc index ff624be8fb..3c3980890e 100644 --- a/libs/canvas/canvas.cc +++ b/libs/canvas/canvas.cc @@ -72,6 +72,18 @@ Canvas::render (Rect const & area, Cairo::RefPtr<Cairo::Context> const & context context->save (); +#ifdef CANVAS_DEBUG + if (getenv ("ARDOUR_REDRAW_CANVAS")) { + /* light up the canvas to show redraws */ + context->set_source_rgba (random()%255 / 255.0, + random()%255 / 255.0, + random()%255 / 255.0, + 255); + context->rectangle (area.x0, area.y0, area.width(), area.height()); + context->stroke (); + } +#endif + /* clip to the requested area */ context->rectangle (area.x0, area.y0, area.width(), area.height()); context->clip (); diff --git a/libs/canvas/canvas/line.h b/libs/canvas/canvas/line.h index b84d831143..36c0f48379 100644 --- a/libs/canvas/canvas/line.h +++ b/libs/canvas/canvas/line.h @@ -39,6 +39,8 @@ public: void set_y0 (Coord); void set_x1 (Coord); void set_y1 (Coord); + void set_x (Coord, Coord); + Coord x0 () const { return _points[0].x; } diff --git a/libs/canvas/canvas/wave_view.h b/libs/canvas/canvas/wave_view.h index 4fd45cff5d..f88ca41ba4 100644 --- a/libs/canvas/canvas/wave_view.h +++ b/libs/canvas/canvas/wave_view.h @@ -65,17 +65,17 @@ public: void set_outline_color (Color); void region_resized (); + void gain_changed (); void set_show_zero_line (bool); bool show_zero_line() const { return _show_zero; } void set_zero_color (Color); void set_clip_color (Color); - void set_amplitude (double); void set_logscaled (bool); void set_gradient_depth (double); double gradient_depth() const { return _gradient_depth; } void set_shape (Shape); - double amplitude() const { return _amplitude; } + /* currently missing because we don't need them (yet): set_shape_independent(); @@ -90,6 +90,9 @@ public: static bool global_logscaled() { return _global_logscaled; } static Shape global_shape() { return _global_shape; } + void set_amplitude_above_axis (double v); + double amplitude_above_axis () const { return _amplitude_above_axis; } + #ifdef CANVAS_COMPATIBILITY void*& property_gain_src () { return _foo_void; @@ -97,15 +100,9 @@ public: void*& property_gain_function () { return _foo_void; } - double& property_amplitude_above_axis () { - return _foo_double; - } private: void* _foo_void; - bool _foo_bool; - int _foo_int; - Color _foo_uint; - double _foo_double; + #endif class CacheEntry @@ -157,10 +154,10 @@ private: bool _logscaled; Shape _shape; double _gradient_depth; - double _amplitude; bool _shape_independent; bool _logscaled_independent; bool _gradient_depth_independent; + double _amplitude_above_axis; /** The `start' value to use for the region; we can't use the region's * value as the crossfade editor needs to alter it. diff --git a/libs/canvas/line.cc b/libs/canvas/line.cc index 2894a80a89..c409f48c7d 100644 --- a/libs/canvas/line.cc +++ b/libs/canvas/line.cc @@ -76,6 +76,20 @@ Line::set (Duple a, Duple b) } void +Line::set_x (Coord x0, Coord x1) +{ + begin_change (); + + _points[0].x = x0; + _points[1].x = x1; + + _bounding_box_dirty = true; + end_change (); + + DEBUG_TRACE (PBD::DEBUG::CanvasItemsDirtied, "canvas item dirty: line change\n"); +} + +void Line::set_x0 (Coord x0) { begin_change (); diff --git a/libs/canvas/wave_view.cc b/libs/canvas/wave_view.cc index 6a2661262a..71f993a579 100644 --- a/libs/canvas/wave_view.cc +++ b/libs/canvas/wave_view.cc @@ -61,10 +61,10 @@ WaveView::WaveView (Group* parent, boost::shared_ptr<ARDOUR::AudioRegion> region , _logscaled (_global_logscaled) , _shape (_global_shape) , _gradient_depth (_global_gradient_depth) - , _amplitude (1.0) , _shape_independent (false) , _logscaled_independent (false) , _gradient_depth_independent (false) + , _amplitude_above_axis (1.0) , _region_start (0) { VisualPropertiesChanged.connect_same_thread (invalidation_connection, boost::bind (&WaveView::handle_visual_property_change, this)); @@ -252,21 +252,26 @@ WaveView::set_channel (int channel) void WaveView::invalidate_whole_cache () { + begin_visual_change (); for (list<CacheEntry*>::iterator i = _cache.begin(); i != _cache.end(); ++i) { delete *i; } _cache.clear (); - _canvas->item_visual_property_changed (this); + + end_visual_change (); } void WaveView::invalidate_image_cache () { + begin_visual_change (); + for (list<CacheEntry*>::iterator i = _cache.begin(); i != _cache.end(); ++i) { (*i)->clear_image (); } - _canvas->item_visual_property_changed (this); + + end_visual_change (); } void @@ -285,12 +290,9 @@ WaveView::set_logscaled (bool yn) } void -WaveView::set_amplitude (double a) +WaveView::gain_changed () { - if (_amplitude != a) { - _amplitude = a; - invalidate_image_cache (); - } + invalidate_whole_cache (); } void @@ -330,6 +332,15 @@ WaveView::set_shape (Shape s) } void +WaveView::set_amplitude_above_axis (double a) +{ + if (_amplitude_above_axis != a) { + _amplitude_above_axis = a; + invalidate_image_cache (); + } +} + +void WaveView::set_global_shape (Shape s) { if (_global_shape != s) { @@ -410,7 +421,6 @@ WaveView::CacheEntry::image () context->begin_new_path(); - if (_wave_view->_shape == WaveView::Rectified) { /* top edge of waveform is based on max (fabs (peak_min, peak_max)) @@ -418,13 +428,12 @@ WaveView::CacheEntry::image () if (_wave_view->_logscaled) { for (int i = 0; i < _n_peaks; ++i) { - context->line_to (i + 0.5, position (_wave_view->amplitude() * - alt_log_meter (fast_coefficient_to_dB ( + context->line_to (i + 0.5, position (alt_log_meter (fast_coefficient_to_dB ( max (fabs (_peaks[i].max), fabs (_peaks[i].min)))))); } } else { for (int i = 0; i < _n_peaks; ++i) { - context->line_to (i + 0.5, position (_wave_view->amplitude() * max (fabs (_peaks[i].max), fabs (_peaks[i].min)))); + context->line_to (i + 0.5, position (max (fabs (_peaks[i].max), fabs (_peaks[i].min)))); } } @@ -433,16 +442,16 @@ WaveView::CacheEntry::image () for (int i = 0; i < _n_peaks; ++i) { Coord y = _peaks[i].max; if (y > 0.0) { - context->line_to (i + 0.5, position (_wave_view->amplitude() * alt_log_meter (fast_coefficient_to_dB (y)))); + context->line_to (i + 0.5, position (alt_log_meter (fast_coefficient_to_dB (y)))); } else if (y < 0.0) { - context->line_to (i + 0.5, position (_wave_view->amplitude() * -alt_log_meter (fast_coefficient_to_dB (-y)))); + context->line_to (i + 0.5, position (alt_log_meter (fast_coefficient_to_dB (-y)))); } else { context->line_to (i + 0.5, position (0.0)); } } } else { for (int i = 0; i < _n_peaks; ++i) { - context->line_to (i + 0.5, position (_wave_view->amplitude() * _peaks[i].max)); + context->line_to (i + 0.5, position (_peaks[i].max)); } } } @@ -469,16 +478,16 @@ WaveView::CacheEntry::image () for (int i = _n_peaks-1; i >= 0; --i) { Coord y = _peaks[i].min; if (y > 0.0) { - context->line_to (i + 0.5, position (_wave_view->amplitude() * alt_log_meter (fast_coefficient_to_dB (y)))); + context->line_to (i + 0.5, position (alt_log_meter (fast_coefficient_to_dB (y)))); } else if (y < 0.0) { - context->line_to (i + 0.5, position (_wave_view->amplitude() * -alt_log_meter (fast_coefficient_to_dB (-y)))); + context->line_to (i + 0.5, position (-alt_log_meter (fast_coefficient_to_dB (-y)))); } else { context->line_to (i + 0.5, position (0.0)); } } } else { for (int i = _n_peaks-1; i >= 0; --i) { - context->line_to (i + 0.5, position (_wave_view->amplitude() * _peaks[i].min)); + context->line_to (i + 0.5, position (_peaks[i].min)); } } |