make waveform gradient depth continuously variable. color probably needs adjusting as do color stops to get a pleasing effect at most settings

This commit is contained in:
Paul Davis 2013-04-16 21:23:50 -04:00
parent 6b78532dd5
commit 381d4debf4
5 changed files with 49 additions and 24 deletions

View file

@ -58,7 +58,9 @@ ThemeManager::ThemeManager()
, light_button (_("Light Theme")) , light_button (_("Light Theme"))
, reset_button (_("Restore Defaults")) , reset_button (_("Restore Defaults"))
, flat_buttons (_("Draw \"flat\" buttons")) , flat_buttons (_("Draw \"flat\" buttons"))
, gradient_waveforms (_("Draw waveforms with color gradient")) , waveform_gradient_depth (0, 1.0, 0.1)
, waveform_gradient_depth_label (_("Waveforms color gradient depth"))
{ {
set_title (_("Theme Manager")); set_title (_("Theme Manager"));
@ -94,10 +96,18 @@ ThemeManager::ThemeManager()
vbox->pack_start (theme_selection_hbox, PACK_SHRINK); vbox->pack_start (theme_selection_hbox, PACK_SHRINK);
vbox->pack_start (reset_button, PACK_SHRINK); vbox->pack_start (reset_button, PACK_SHRINK);
vbox->pack_start (flat_buttons, PACK_SHRINK); vbox->pack_start (flat_buttons, PACK_SHRINK);
vbox->pack_start (gradient_waveforms, PACK_SHRINK);
Gtk::HBox* hbox = Gtk::manage (new Gtk::HBox());
hbox->set_spacing (6);
hbox->pack_start (waveform_gradient_depth, true, true);
hbox->pack_start (waveform_gradient_depth_label, false, false);
vbox->pack_start (*hbox, PACK_SHRINK);
vbox->pack_start (scroller); vbox->pack_start (scroller);
add (*vbox); add (*vbox);
waveform_gradient_depth.set_update_policy (Gtk::UPDATE_DELAYED);
color_display.signal_button_press_event().connect (sigc::mem_fun (*this, &ThemeManager::button_press_event), false); color_display.signal_button_press_event().connect (sigc::mem_fun (*this, &ThemeManager::button_press_event), false);
color_dialog.get_colorsel()->set_has_opacity_control (true); color_dialog.get_colorsel()->set_has_opacity_control (true);
@ -109,7 +119,7 @@ ThemeManager::ThemeManager()
light_button.signal_toggled().connect (sigc::mem_fun (*this, &ThemeManager::on_light_theme_button_toggled)); light_button.signal_toggled().connect (sigc::mem_fun (*this, &ThemeManager::on_light_theme_button_toggled));
reset_button.signal_clicked().connect (sigc::mem_fun (*this, &ThemeManager::reset_canvas_colors)); reset_button.signal_clicked().connect (sigc::mem_fun (*this, &ThemeManager::reset_canvas_colors));
flat_buttons.signal_toggled().connect (sigc::mem_fun (*this, &ThemeManager::on_flat_buttons_toggled)); flat_buttons.signal_toggled().connect (sigc::mem_fun (*this, &ThemeManager::on_flat_buttons_toggled));
gradient_waveforms.signal_toggled().connect (sigc::mem_fun (*this, &ThemeManager::on_gradient_waveforms_toggled)); waveform_gradient_depth.signal_value_changed().connect (sigc::mem_fun (*this, &ThemeManager::on_waveform_gradient_depth_change));
set_size_request (-1, 400); set_size_request (-1, 400);
setup_theme (); setup_theme ();
@ -247,11 +257,13 @@ ThemeManager::on_flat_buttons_toggled ()
} }
void void
ThemeManager::on_gradient_waveforms_toggled () ThemeManager::on_waveform_gradient_depth_change ()
{ {
ARDOUR_UI::config()->gradient_waveforms.set (gradient_waveforms.get_active()); double v = waveform_gradient_depth.get_value();
ARDOUR_UI::config()->waveform_gradient_depth.set (v);
ARDOUR_UI::config()->set_dirty (); ARDOUR_UI::config()->set_dirty ();
ArdourCanvas::WaveView::set_gradient_waveforms (gradient_waveforms.get_active()); ArdourCanvas::WaveView::set_global_gradient_depth (v);
} }
void void
@ -363,7 +375,7 @@ ThemeManager::setup_theme ()
} }
flat_buttons.set_active (ARDOUR_UI::config()->flat_buttons.get()); flat_buttons.set_active (ARDOUR_UI::config()->flat_buttons.get());
gradient_waveforms.set_active (ARDOUR_UI::config()->gradient_waveforms.get()); waveform_gradient_depth.set_value (ARDOUR_UI::config()->waveform_gradient_depth.get());
load_rc_file(rcfile, false); load_rc_file(rcfile, false);
} }

View file

@ -26,6 +26,7 @@
#include <gtkmm/colorselection.h> #include <gtkmm/colorselection.h>
#include <gtkmm/radiobutton.h> #include <gtkmm/radiobutton.h>
#include <gtkmm/button.h> #include <gtkmm/button.h>
#include <gtkmm/scale.h>
#include <gtkmm/rc.h> #include <gtkmm/rc.h>
#include "ardour_window.h" #include "ardour_window.h"
#include "ui_config.h" #include "ui_config.h"
@ -43,7 +44,7 @@ class ThemeManager : public ArdourWindow
void on_dark_theme_button_toggled (); void on_dark_theme_button_toggled ();
void on_light_theme_button_toggled (); void on_light_theme_button_toggled ();
void on_flat_buttons_toggled (); void on_flat_buttons_toggled ();
void on_gradient_waveforms_toggled (); void on_waveform_gradient_depth_change ();
private: private:
struct ColorDisplayModelColumns : public Gtk::TreeModel::ColumnRecord { struct ColorDisplayModelColumns : public Gtk::TreeModel::ColumnRecord {
@ -70,7 +71,8 @@ class ThemeManager : public ArdourWindow
Gtk::RadioButton light_button; Gtk::RadioButton light_button;
Gtk::Button reset_button; Gtk::Button reset_button;
Gtk::CheckButton flat_buttons; Gtk::CheckButton flat_buttons;
Gtk::CheckButton gradient_waveforms; Gtk::HScale waveform_gradient_depth;
Gtk::Label waveform_gradient_depth_label;
bool button_press_event (GdkEventButton*); bool button_press_event (GdkEventButton*);
}; };

View file

@ -19,5 +19,5 @@
UI_CONFIG_VARIABLE(std::string, ui_rc_file, "ui-rc-file", "ardour3_ui_dark.rc") UI_CONFIG_VARIABLE(std::string, ui_rc_file, "ui-rc-file", "ardour3_ui_dark.rc")
UI_CONFIG_VARIABLE(bool, flat_buttons, "flat-buttons", false) UI_CONFIG_VARIABLE(bool, flat_buttons, "flat-buttons", false)
UI_CONFIG_VARIABLE(bool, gradient_waveforms, "gradient-waveforms", false) UI_CONFIG_VARIABLE(float, waveform_gradient_depth, "waveform-gradient-depth", 0.6)

View file

@ -72,6 +72,8 @@ public:
void set_clip_color (Color); void set_clip_color (Color);
void set_amplitude (double); void set_amplitude (double);
void set_logscaled (bool); void set_logscaled (bool);
void set_gradient_depth (double);
double gradient_depth() const { return _gradient_depth; }
void set_shape (Shape); void set_shape (Shape);
double amplitude() const { return _amplitude; } double amplitude() const { return _amplitude; }
@ -80,13 +82,13 @@ public:
set_logscaled_independent() 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_logscaled (bool);
static void set_global_shape (Shape); static void set_global_shape (Shape);
static bool gradient_waveforms() { return _gradient_waveforms; } static double global_gradient_depth() { return _global_gradient_depth; }
static bool global_logscaled() { return _global_logscaled; } static bool global_logscaled() { return _global_logscaled; }
static Shape global_shape() { return _global_shape; } static Shape global_shape() { return _global_shape; }
#ifdef CANVAS_COMPATIBILITY #ifdef CANVAS_COMPATIBILITY
void*& property_gain_src () { void*& property_gain_src () {
@ -154,9 +156,11 @@ private:
Color _clip_color; Color _clip_color;
bool _logscaled; bool _logscaled;
Shape _shape; Shape _shape;
double _gradient_depth;
double _amplitude; double _amplitude;
bool _shape_independent; bool _shape_independent;
bool _logscaled_independent; bool _logscaled_independent;
bool _gradient_depth_independent;
/** The `start' value to use for the region; we can't use the region's /** The `start' value to use for the region; we can't use the region's
* value as the crossfade editor needs to alter it. * value as the crossfade editor needs to alter it.
@ -167,9 +171,9 @@ private:
PBD::ScopedConnection invalidation_connection; PBD::ScopedConnection invalidation_connection;
static bool _gradient_waveforms; static double _global_gradient_depth;
static bool _global_logscaled; static bool _global_logscaled;
static Shape _global_shape; static Shape _global_shape;
static PBD::Signal0<void> VisualPropertiesChanged; static PBD::Signal0<void> VisualPropertiesChanged;

View file

@ -40,7 +40,7 @@ using namespace std;
using namespace ARDOUR; using namespace ARDOUR;
using namespace ArdourCanvas; using namespace ArdourCanvas;
bool WaveView::_gradient_waveforms = true; double WaveView::_global_gradient_depth = 0.6;
bool WaveView::_global_logscaled = false; bool WaveView::_global_logscaled = false;
WaveView::Shape WaveView::_global_shape = WaveView::Normal; WaveView::Shape WaveView::_global_shape = WaveView::Normal;
@ -60,9 +60,11 @@ WaveView::WaveView (Group* parent, boost::shared_ptr<ARDOUR::AudioRegion> region
, _clip_color (0xff0000ff) , _clip_color (0xff0000ff)
, _logscaled (_global_logscaled) , _logscaled (_global_logscaled)
, _shape (_global_shape) , _shape (_global_shape)
, _gradient_depth (_global_gradient_depth)
, _amplitude (1.0) , _amplitude (1.0)
, _shape_independent (false) , _shape_independent (false)
, _logscaled_independent (false) , _logscaled_independent (false)
, _gradient_depth_independent (false)
, _region_start (0) , _region_start (0)
{ {
VisualPropertiesChanged.connect_same_thread (invalidation_connection, boost::bind (&WaveView::handle_visual_property_change, this)); 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; changed = true;
} }
if (!_gradient_depth_independent && (_gradient_depth != global_gradient_depth())) {
_gradient_depth = global_gradient_depth();
changed = true;
}
if (changed) { if (changed) {
invalidate_image_cache (); invalidate_image_cache ();
} }
@ -482,8 +489,8 @@ WaveView::CacheEntry::image ()
context->close_path (); 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)); Cairo::RefPtr<Cairo::LinearGradient> gradient (Cairo::LinearGradient::create (0, 0, 0, _wave_view->_height));
double stops[3]; double stops[3];
@ -508,7 +515,7 @@ WaveView::CacheEntry::image ()
double h, s, v; double h, s, v;
color_to_hsv (_wave_view->_fill_color, h, s, v); color_to_hsv (_wave_view->_fill_color, h, s, v);
/* tone down the saturation */ /* tone down the saturation */
s *= 0.60; s *= 1.0 - _wave_view->gradient_depth();
Color center = hsv_to_color (h, s, v, a); Color center = hsv_to_color (h, s, v, a);
color_to_rgba (center, r, g, b, a); color_to_rgba (center, r, g, b, a);
gradient->add_color_stop_rgba (stops[1], r, g, b, a); gradient->add_color_stop_rgba (stops[1], r, g, b, a);
@ -553,10 +560,10 @@ WaveView::CacheEntry::clear_image ()
} }
void void
WaveView::set_gradient_waveforms (bool yn) WaveView::set_global_gradient_depth (double depth)
{ {
if (_gradient_waveforms != yn) { if (_global_gradient_depth != depth) {
_gradient_waveforms = yn; _global_gradient_depth = depth;
VisualPropertiesChanged (); /* EMIT SIGNAL */ VisualPropertiesChanged (); /* EMIT SIGNAL */
} }
} }