summaryrefslogtreecommitdiff
path: root/libs/gtkmm2ext
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2011-12-02 21:08:13 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2011-12-02 21:08:13 +0000
commit5b913f9a2b285f1bbd63328b9c26ddb49bc3a092 (patch)
tree1ff8e9b5f4bbba050fa56d091b8bfa22c87a3f38 /libs/gtkmm2ext
parentfecc02f6f5a3b76a8a9ac069ef84877958ff737a (diff)
add PAINT_VERTA_GR and PAINT_BOX_GR to rgba macros (from Mike Dawes)
git-svn-id: svn://localhost/ardour2/branches/3.0@10874 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/gtkmm2ext')
-rw-r--r--libs/gtkmm2ext/gtkmm2ext/rgb_macros.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/libs/gtkmm2ext/gtkmm2ext/rgb_macros.h b/libs/gtkmm2ext/gtkmm2ext/rgb_macros.h
index a3909d9a08..cd195f8a32 100644
--- a/libs/gtkmm2ext/gtkmm2ext/rgb_macros.h
+++ b/libs/gtkmm2ext/gtkmm2ext/rgb_macros.h
@@ -239,6 +239,34 @@ UINT_TO_RGB((i), ((guchar*)p), ((guchar*)p)+1, ((guchar*)p)+2)
} \
}
+#define PAINT_VERTA_GR(inbuf, colr, colg, colb, cola, ptx, pty0, pty1, origin_y, obj_top) \
+{ \
+ GnomeCanvasBuf* pv_buf = (inbuf); \
+ guchar* pv_p; \
+ gint pv_b0, pv_b1; \
+ gint pv_colr=(colr), pv_colg=(colg), pv_colb=(colb), pv_cola=(cola); \
+ gint y_fract; \
+ gint y_span = (origin_y - obj_top); \
+ gint alpha; \
+ gint sat; \
+\
+ pv_b0 = MAX(pv_buf->rect.y0, (pty0)); \
+ pv_b1 = MIN(pv_buf->rect.y1, (pty1)); \
+\
+ if (pv_b0 < pv_b1 && BUF_INBOUNDS_X(pv_buf, ptx)) { \
+ pv_p = BUF_PTR(pv_buf, ptx, pv_b0); \
+ while (pv_b0 < pv_b1) { \
+ y_fract = (abs(origin_y - pv_b0)) * 0xFF; \
+ y_fract = y_fract / y_span; \
+ alpha = 0x7F + (y_fract >> 1); \
+ sat = 0xFF - (y_fract); \
+ PIXEL_RGBA(pv_p, (((pv_colr << 8) * sat) >> 16), (((pv_colg << 8) * sat) >> 16), (((pv_colb << 8) * sat) >> 16), pv_cola); \
+ ++pv_b0; \
+ pv_p += pv_buf->buf_rowstride; \
+ } \
+ } \
+}
+
/* Paint a solid-colored box into a GnomeCanvasBuf (clipping as necessary).
The box contains (ptx0,pty0), but not (ptx1, pty1).
Each macro arg should appear exactly once in the body of the code. */
@@ -268,6 +296,44 @@ UINT_TO_RGB((i), ((guchar*)p), ((guchar*)p)+1, ((guchar*)p)+2)
} \
}
+/* Paint a gradient-colored box into a GnomeCanvasBuf (clipping as necessary).
+ The box contains (ptx0,pty0), but not (ptx1, pty1).
+ Each macro arg should appear exactly once in the body of the code. */
+#define PAINT_BOX_GR(inbuf, colr, colg, colb, cola, ptx0, pty0, ptx1, pty1, v_span) \
+{ \
+ GnomeCanvasBuf* pb_buf = (inbuf); \
+ guchar* pb_p; \
+ guchar* pb_pp; \
+ gint pb_a0, pb_a1, pb_b0, pb_b1, pb_i, pb_j; \
+ gint pb_colr=(colr), pb_colg=(colg), pb_colb=(colb), pb_cola=(cola); \
+ gint alpha; \
+ gint sat; \
+ gint y_fract; \
+ gint y_span = MAX(abs(v_span), 1); \
+\
+ pb_a0 = MAX(pb_buf->rect.x0, (ptx0)); \
+ pb_a1 = MIN(pb_buf->rect.x1, (ptx1)); \
+ pb_b0 = MAX(pb_buf->rect.y0, (pty0)); \
+ pb_b1 = MIN(pb_buf->rect.y1, (pty1)); \
+\
+ if (pb_a0 < pb_a1 && pb_b0 < pb_b1) { \
+ pb_p = BUF_PTR(pb_buf, pb_a0, pb_b0); \
+ for (pb_j=pb_b0; pb_j<pb_b1; ++pb_j) { \
+ y_fract = 0xFF * (abs(pb_j - pty0)); \
+ y_fract = y_fract / y_span; \
+ alpha = 0xFF - y_fract; \
+ sat = 0xFF - (y_fract >> 1); \
+ pb_pp = pb_p; \
+ for (pb_i=pb_a0; pb_i<pb_a1; ++pb_i) { \
+ PIXEL_RGBA(pb_pp, (((pb_colr << 8) * sat) >> 16), (((pb_colg << 8) * sat) >> 16), (((pb_colb << 8) * sat) >> 16), pb_cola); \
+ pb_pp += 3; \
+ } \
+ pb_p += pb_buf->buf_rowstride; \
+ } \
+ } \
+}
+
+
/* No bounds checking in this version */
#define FAST_PAINT_BOX(inbuf, colr, colg, colb, cola, ptx0, pty0, ptx1, pty1) \