summaryrefslogtreecommitdiff
path: root/gtk2_ardour/ardour_button.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2016-06-09 15:35:37 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2016-06-09 16:03:14 -0400
commitef6f0de5a31bd14a4d48e806b3b56b2845ebd690 (patch)
tree01d97a0d2b189302f0aeb362f2a0ffa4a9d94ead /gtk2_ardour/ardour_button.cc
parent37aed5715b69428f86b169377f9597e563fff7df (diff)
extend ArdourButton API to allow independently setting fixed active/inactive colors
Diffstat (limited to 'gtk2_ardour/ardour_button.cc')
-rw-r--r--gtk2_ardour/ardour_button.cc50
1 files changed, 36 insertions, 14 deletions
diff --git a/gtk2_ardour/ardour_button.cc b/gtk2_ardour/ardour_button.cc
index 305956ff59..0fa53c5372 100644
--- a/gtk2_ardour/ardour_button.cc
+++ b/gtk2_ardour/ardour_button.cc
@@ -619,19 +619,26 @@ void
ArdourButton::set_colors ()
{
_update_colors = false;
- if (_fixed_colors_set) {
+
+ if (_fixed_colors_set == 0x3) {
return;
}
+
std::string name = get_name();
bool failed = false;
- fill_active_color = UIConfiguration::instance().color (string_compose ("%1: fill active", name), &failed);
- if (failed) {
- fill_active_color = UIConfiguration::instance().color ("generic button: fill active");
+ if (!(_fixed_colors_set & 0x1)) {
+ fill_active_color = UIConfiguration::instance().color (string_compose ("%1: fill active", name), &failed);
+ if (failed) {
+ fill_active_color = UIConfiguration::instance().color ("generic button: fill active");
+ }
}
- fill_inactive_color = UIConfiguration::instance().color (string_compose ("%1: fill", name), &failed);
- if (failed) {
- fill_inactive_color = UIConfiguration::instance().color ("generic button: fill");
+
+ if (!(_fixed_colors_set & 0x2)) {
+ fill_inactive_color = UIConfiguration::instance().color (string_compose ("%1: fill", name), &failed);
+ if (failed) {
+ fill_inactive_color = UIConfiguration::instance().color ("generic button: fill");
+ }
}
text_active_color = ArdourCanvas::contrasting_text_color (fill_active_color);
@@ -659,13 +666,18 @@ ArdourButton::set_colors ()
*/
void ArdourButton::set_fixed_colors (const uint32_t color_active, const uint32_t color_inactive)
{
- _fixed_colors_set = true;
+ set_active_color (color_active);
+ set_inactive_color (color_inactive);
+}
+
+void ArdourButton::set_active_color (const uint32_t color)
+{
+ _fixed_colors_set |= 0x1;
- fill_active_color = color_active;
- fill_inactive_color = color_inactive;
+ fill_active_color = color;
unsigned char r, g, b, a;
- UINT_TO_RGBA(color_active, &r, &g, &b, &a);
+ UINT_TO_RGBA(color, &r, &g, &b, &a);
double white_contrast = (max (double(r), 255.) - min (double(r), 255.)) +
(max (double(g), 255.) - min (double(g), 255.)) +
@@ -679,14 +691,24 @@ void ArdourButton::set_fixed_colors (const uint32_t color_active, const uint32_t
RGBA_TO_UINT(255, 255, 255, 255) : /* use white */
RGBA_TO_UINT( 0, 0, 0, 255); /* use black */
+ /* XXX what about led colors ? */
+ CairoWidget::set_dirty ();
+}
+
+void ArdourButton::set_inactive_color (const uint32_t color)
+{
+ _fixed_colors_set |= 0x2;
- UINT_TO_RGBA(color_inactive, &r, &g, &b, &a);
+ fill_inactive_color = color;
- white_contrast = (max (double(r), 255.) - min (double(r), 255.)) +
+ unsigned char r, g, b, a;
+ UINT_TO_RGBA(color, &r, &g, &b, &a);
+
+ double white_contrast = (max (double(r), 255.) - min (double(r), 255.)) +
(max (double(g), 255.) - min (double(g), 255.)) +
(max (double(b), 255.) - min (double(b), 255.));
- black_contrast = (max (double(r), 0.) - min (double(r), 0.)) +
+ double black_contrast = (max (double(r), 0.) - min (double(r), 0.)) +
(max (double(g), 0.) - min (double(g), 0.)) +
(max (double(b), 0.) - min (double(b), 0.));