diff options
author | David Robillard <d@drobilla.net> | 2011-09-23 18:11:49 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-09-23 18:11:49 +0000 |
commit | 9a99f038176a7fadc59bbeaa3d3d57f16e4abb74 (patch) | |
tree | f3c1dbb555ff095c1ba7a296009924390e60db09 /src/gui | |
parent | 650a13f7c18a4caf4387c0845b708e2c2bf1625d (diff) | |
download | ingen-9a99f038176a7fadc59bbeaa3d3d57f16e4abb74.tar.gz ingen-9a99f038176a7fadc59bbeaa3d3d57f16e4abb74.tar.bz2 ingen-9a99f038176a7fadc59bbeaa3d3d57f16e4abb74.zip |
Animate audio port colours based on levels.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3475 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/Configuration.cpp | 4 | ||||
-rw-r--r-- | src/gui/Port.cpp | 59 | ||||
-rw-r--r-- | src/gui/Port.hpp | 2 |
3 files changed, 59 insertions, 6 deletions
diff --git a/src/gui/Configuration.cpp b/src/gui/Configuration.cpp index 8eb39cd7..5018cbf1 100644 --- a/src/gui/Configuration.cpp +++ b/src/gui/Configuration.cpp @@ -40,8 +40,8 @@ using namespace Ingen::Client; Configuration::Configuration() // Colours from the Tango palette with modified V and alpha : _name_style(HUMAN) - , _audio_port_color( 0x244678C0) // Blue - , _control_port_color(0x4A8A0EC0) // Green + , _audio_port_color( 0x4A8A0EC0) // Green + , _control_port_color(0x244678C0) // Blue , _event_port_color( 0x960909C0) // Red , _string_port_color( 0x5C3566C0) // Plum , _value_port_color( 0xBABDB6C0) // Aluminum diff --git a/src/gui/Port.cpp b/src/gui/Port.cpp index 9b2a1c8f..450b75cf 100644 --- a/src/gui/Port.cpp +++ b/src/gui/Port.cpp @@ -77,7 +77,7 @@ Port::Port(FlowCanvas::Module& module, ArtVpathDash* dash = this->dash(); _rect.property_dash() = dash; - set_border_width(dash ? 2.0 : 0.0); + set_border_width(1.0); pm->signal_moved().connect(sigc::mem_fun(this, &Port::moved)); @@ -162,10 +162,63 @@ Port::on_event(GdkEvent* ev) return false; } +/* Peak colour stuff */ + +static inline uint32_t +rgba_to_uint(uint8_t r, uint8_t g, uint8_t b, uint8_t a) +{ + return ((((uint32_t)(r)) << 24) | + (((uint32_t)(g)) << 16) | + (((uint32_t)(b)) << 8) | + (((uint32_t)(a)))); +} + +static inline uint8_t +mono_interpolate(uint8_t v1, uint8_t v2, float f) +{ + return ((int)rint((v2) * (f) + (v1) * (1 - (f)))); +} + +#define RGBA_R(x) (((uint32_t)(x)) >> 24) +#define RGBA_G(x) ((((uint32_t)(x)) >> 16) & 0xFF) +#define RGBA_B(x) ((((uint32_t)(x)) >> 8) & 0xFF) +#define RGBA_A(x) (((uint32_t)(x)) & 0xFF) + +static inline uint32_t +rgba_interpolate(uint32_t c1, uint32_t c2, float f) +{ + return rgba_to_uint( + mono_interpolate(RGBA_R(c1), RGBA_R(c2), f), + mono_interpolate(RGBA_G(c1), RGBA_G(c2), f), + mono_interpolate(RGBA_B(c1), RGBA_B(c2), f), + mono_interpolate(RGBA_A(c1), RGBA_A(c2), f)); +} + +inline static uint32_t +peak_color(float peak) +{ + static const uint32_t min = 0x4A8A0EC0; + static const uint32_t max = 0xFFCE1FC0; + static const uint32_t peak_min = 0xFF561FC0; + static const uint32_t peak_max = 0xFF0A38C0; + + if (peak < 1.0) { + return rgba_interpolate(min, max, peak); + } else { + return rgba_interpolate(peak_min, peak_max, fminf(peak, 2.0f) - 1.0f); + } +} + +/* End peak colour stuff */ + void -Port::activity() +Port::activity(const Raul::Atom& value) { - App::instance().port_activity(this); + if (model()->is_a(PortType::AUDIO)) { + set_fill_color(peak_color(value.get_float())); + } else { + App::instance().port_activity(this); + } } void diff --git a/src/gui/Port.hpp b/src/gui/Port.hpp index 65f7c2e2..788baa0e 100644 --- a/src/gui/Port.hpp +++ b/src/gui/Port.hpp @@ -55,7 +55,7 @@ public: virtual void set_control(float value, bool signal); void value_changed(const Raul::Atom& value); - void activity(); + void activity(const Raul::Atom& value); void set_selected(bool b); |