diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2013-04-16 21:23:50 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2013-04-16 21:23:50 -0400 |
commit | 381d4debf4c84816d08ff4de27bc9ae8d5d15f28 (patch) | |
tree | 2cb77585cecff9f4ca3d8be6b5d3e75eb39ef650 /libs | |
parent | 6b78532dd5a75e2d13dba2b1fd07f099dde706a8 (diff) |
make waveform gradient depth continuously variable. color probably needs adjusting as do color stops to get a pleasing effect at most settings
Diffstat (limited to 'libs')
-rw-r--r-- | libs/canvas/canvas/wave_view.h | 18 | ||||
-rw-r--r-- | libs/canvas/wave_view.cc | 21 |
2 files changed, 25 insertions, 14 deletions
diff --git a/libs/canvas/canvas/wave_view.h b/libs/canvas/canvas/wave_view.h index 44cc6f6f70..4fd45cff5d 100644 --- a/libs/canvas/canvas/wave_view.h +++ b/libs/canvas/canvas/wave_view.h @@ -72,6 +72,8 @@ public: 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; } @@ -80,13 +82,13 @@ public: set_logscaled_independent() */ - static void set_gradient_waveforms (bool); + static void set_global_gradient_depth (double); static void set_global_logscaled (bool); static void set_global_shape (Shape); - static bool gradient_waveforms() { return _gradient_waveforms; } - static bool global_logscaled() { return _global_logscaled; } - static Shape global_shape() { return _global_shape; } + static double global_gradient_depth() { return _global_gradient_depth; } + static bool global_logscaled() { return _global_logscaled; } + static Shape global_shape() { return _global_shape; } #ifdef CANVAS_COMPATIBILITY void*& property_gain_src () { @@ -154,9 +156,11 @@ private: Color _clip_color; bool _logscaled; Shape _shape; + double _gradient_depth; double _amplitude; bool _shape_independent; bool _logscaled_independent; + bool _gradient_depth_independent; /** The `start' value to use for the region; we can't use the region's * value as the crossfade editor needs to alter it. @@ -167,9 +171,9 @@ private: PBD::ScopedConnection invalidation_connection; - static bool _gradient_waveforms; - static bool _global_logscaled; - static Shape _global_shape; + static double _global_gradient_depth; + static bool _global_logscaled; + static Shape _global_shape; static PBD::Signal0<void> VisualPropertiesChanged; diff --git a/libs/canvas/wave_view.cc b/libs/canvas/wave_view.cc index f420c73980..6a2661262a 100644 --- a/libs/canvas/wave_view.cc +++ b/libs/canvas/wave_view.cc @@ -40,7 +40,7 @@ using namespace std; using namespace ARDOUR; using namespace ArdourCanvas; -bool WaveView::_gradient_waveforms = true; +double WaveView::_global_gradient_depth = 0.6; bool WaveView::_global_logscaled = false; WaveView::Shape WaveView::_global_shape = WaveView::Normal; @@ -60,9 +60,11 @@ WaveView::WaveView (Group* parent, boost::shared_ptr<ARDOUR::AudioRegion> region , _clip_color (0xff0000ff) , _logscaled (_global_logscaled) , _shape (_global_shape) + , _gradient_depth (_global_gradient_depth) , _amplitude (1.0) , _shape_independent (false) , _logscaled_independent (false) + , _gradient_depth_independent (false) , _region_start (0) { VisualPropertiesChanged.connect_same_thread (invalidation_connection, boost::bind (&WaveView::handle_visual_property_change, this)); @@ -83,6 +85,11 @@ WaveView::handle_visual_property_change () changed = true; } + if (!_gradient_depth_independent && (_gradient_depth != global_gradient_depth())) { + _gradient_depth = global_gradient_depth(); + changed = true; + } + if (changed) { invalidate_image_cache (); } @@ -482,8 +489,8 @@ WaveView::CacheEntry::image () context->close_path (); - if (WaveView::gradient_waveforms()) { - + if (_wave_view->gradient_depth() != 0.0) { + Cairo::RefPtr<Cairo::LinearGradient> gradient (Cairo::LinearGradient::create (0, 0, 0, _wave_view->_height)); double stops[3]; @@ -508,7 +515,7 @@ WaveView::CacheEntry::image () double h, s, v; color_to_hsv (_wave_view->_fill_color, h, s, v); /* tone down the saturation */ - s *= 0.60; + s *= 1.0 - _wave_view->gradient_depth(); Color center = hsv_to_color (h, s, v, a); color_to_rgba (center, r, g, b, a); gradient->add_color_stop_rgba (stops[1], r, g, b, a); @@ -553,10 +560,10 @@ WaveView::CacheEntry::clear_image () } void -WaveView::set_gradient_waveforms (bool yn) +WaveView::set_global_gradient_depth (double depth) { - if (_gradient_waveforms != yn) { - _gradient_waveforms = yn; + if (_global_gradient_depth != depth) { + _global_gradient_depth = depth; VisualPropertiesChanged (); /* EMIT SIGNAL */ } } |