summaryrefslogtreecommitdiff
path: root/libs/surfaces
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2016-09-23 13:53:45 -0500
committerPaul Davis <paul@linuxaudiosystems.com>2016-09-27 14:59:32 -0500
commit44c0ea209526dcdec70412f88e7a0dfcb5b0527d (patch)
tree4cb462208577bb36f7d69ce53afc2e1c193d79b3 /libs/surfaces
parent48087c3161e4f4ab00b364ddb14f9ef9d1ee6937 (diff)
fix assignment of palette colors by using white-balance = 126; also use ArdourCanvas color macros
Diffstat (limited to 'libs/surfaces')
-rw-r--r--libs/surfaces/push2/push2.cc36
1 files changed, 26 insertions, 10 deletions
diff --git a/libs/surfaces/push2/push2.cc b/libs/surfaces/push2/push2.cc
index 0d3e2b405d..87d4c4d9c5 100644
--- a/libs/surfaces/push2/push2.cc
+++ b/libs/surfaces/push2/push2.cc
@@ -42,6 +42,8 @@
#include "gtkmm2ext/gui_thread.h"
#include "gtkmm2ext/rgb_macros.h"
+#include "canvas/colors.h"
+
#include "canvas.h"
#include "gui.h"
#include "layout.h"
@@ -1542,9 +1544,15 @@ Push2::get_color_index (ArdourCanvas::Color rgba)
return i->second;
}
- int r, g, b, a;
- UINT_TO_RGBA (rgba, &r, &g, &b, &a);
- int w = 204; /* not sure where/when we should get this value */
+ double dr, dg, db, da;
+ int r, g, b;
+ ArdourCanvas::color_to_rgba (rgba, dr, dg, db, da);
+ int w = 126; /* not sure where/when we should get this value */
+
+
+ r = (int) floor (255.0 * dr);
+ g = (int) floor (255.0 * dg);
+ b = (int) floor (255.0 * db);
/* get a free index */
@@ -1560,20 +1568,28 @@ Push2::get_color_index (ArdourCanvas::Color rgba)
color_map_free_list.pop();
}
- MidiByteArray palette_msg (17, 0xf0, 0x00 , 0x21, 0x1d, 0x01, 0x01, 0x03, 0x7D, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x01, 0x7E, 0x00, 0xF7);
- MidiByteArray update_pallette_msg (8, 0xf0, 0x00, 0x21, 0x1d, 0x01, 0x01, 0x05, 0xF7);
-
+ MidiByteArray palette_msg (17,
+ 0xf0,
+ 0x00 , 0x21, 0x1d, 0x01, 0x01, 0x03, /* reset palette header */
+ 0x00, /* index = 7 */
+ 0x00, 0x00, /* r = 8 & 9 */
+ 0x00, 0x00, /* g = 10 & 11 */
+ 0x00, 0x00, /* b = 12 & 13 */
+ 0x00, 0x00, /* w (a?) = 14 & 15*/
+ 0xf7);
palette_msg[7] = index;
palette_msg[8] = r & 0x7f;
- palette_msg[9] = r & 0x1;
+ palette_msg[9] = (r & 0x80) >> 7;
palette_msg[10] = g & 0x7f;
- palette_msg[11] = g & 0x1;
+ palette_msg[11] = (g & 0x80) >> 7;
palette_msg[12] = b & 0x7f;
- palette_msg[13] = b & 0x1;
+ palette_msg[13] = (b & 0x80) >> 7;
palette_msg[14] = w & 0x7f;
- palette_msg[15] = w & 0x1;
+ palette_msg[15] = w & 0x80;
write (palette_msg);
+
+ MidiByteArray update_pallette_msg (8, 0xf0, 0x00, 0x21, 0x1d, 0x01, 0x01, 0x05, 0xF7);
write (update_pallette_msg);
color_map[rgba] = index;