mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-07 07:14:56 +01:00
add option to not use gradients when rendering waveforms (#4944)
git-svn-id: svn://localhost/ardour2/branches/3.0@13015 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
9a3d9dcb3c
commit
1eb4f9a2da
5 changed files with 579 additions and 4 deletions
|
|
@ -121,6 +121,9 @@ static guint32 gnome_canvas_waveview_ensure_cache (GnomeCanvasWaveView *waveview
|
|||
gulong start_sample,
|
||||
gulong end_sample);
|
||||
|
||||
|
||||
static int _gradient_rendering = 0;
|
||||
|
||||
static GnomeCanvasItemClass *parent_class;
|
||||
|
||||
GType
|
||||
|
|
@ -328,6 +331,12 @@ gnome_canvas_waveview_class_init (GnomeCanvasWaveViewClass *class)
|
|||
item_class->draw = gnome_canvas_waveview_draw;
|
||||
}
|
||||
|
||||
void
|
||||
gnome_canvas_waveview_set_gradient_waveforms (int yn)
|
||||
{
|
||||
_gradient_rendering = yn;
|
||||
}
|
||||
|
||||
GnomeCanvasWaveViewCache*
|
||||
gnome_canvas_waveview_cache_new ()
|
||||
{
|
||||
|
|
@ -1094,7 +1103,7 @@ gnome_canvas_waveview_update (GnomeCanvasItem *item, double *affine, ArtSVP *cli
|
|||
}
|
||||
|
||||
static void
|
||||
gnome_canvas_waveview_render (GnomeCanvasItem *item,
|
||||
gnome_canvas_waveview_gradient_render (GnomeCanvasItem *item,
|
||||
GnomeCanvasBuf *buf)
|
||||
{
|
||||
GnomeCanvasWaveView *waveview;
|
||||
|
|
@ -1349,9 +1358,10 @@ gnome_canvas_waveview_render (GnomeCanvasItem *item,
|
|||
if(pymax == fill_max) {
|
||||
PAINT_DOTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymax);
|
||||
++fill_max;
|
||||
} else {
|
||||
PAINT_VERTA_GR(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymax, fill_max, wave_middle, wave_top);
|
||||
}
|
||||
else {
|
||||
PAINT_VERTA_GR(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymax, fill_max, wave_middle, wave_top); }
|
||||
|
||||
}
|
||||
|
||||
if((prev_pymin > pymin && next_pymin > pymin) ||
|
||||
|
|
@ -1640,6 +1650,549 @@ gnome_canvas_waveview_render (GnomeCanvasItem *item,
|
|||
|
||||
}
|
||||
|
||||
static void
|
||||
gnome_canvas_waveview_flat_render (GnomeCanvasItem *item,
|
||||
GnomeCanvasBuf *buf)
|
||||
{
|
||||
GnomeCanvasWaveView *waveview;
|
||||
gulong s1, s2;
|
||||
int clip_length = 0;
|
||||
int pymin, pymax;
|
||||
guint cache_index;
|
||||
double half_height;
|
||||
int x;
|
||||
char rectify;
|
||||
|
||||
waveview = GNOME_CANVAS_WAVEVIEW (item);
|
||||
|
||||
// check_cache (waveview, "start of render");
|
||||
|
||||
if (parent_class->render) {
|
||||
(*parent_class->render) (item, buf);
|
||||
}
|
||||
|
||||
if (buf->is_bg) {
|
||||
gnome_canvas_buf_ensure_buf (buf);
|
||||
buf->is_bg = FALSE;
|
||||
}
|
||||
|
||||
/* a "unit" means a pixel */
|
||||
|
||||
/* begin: render start x (units) */
|
||||
int const begin = MAX (waveview->bbox_ulx, buf->rect.x0);
|
||||
|
||||
/* zbegin: start x for zero line (units) */
|
||||
int const zbegin = (begin == waveview->bbox_ulx) ? (begin + 1) : begin;
|
||||
|
||||
/* end: render end x (units) */
|
||||
int const end = (waveview->bbox_lrx >= 0) ? MIN (waveview->bbox_lrx,buf->rect.x1) : buf->rect.x1;
|
||||
|
||||
/* zend: end x for zero-line (units) */
|
||||
int const zend = (end == waveview->bbox_lrx) ? (end - 1) : end;
|
||||
|
||||
if (begin == end) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* s1: start sample
|
||||
s2: end sample
|
||||
*/
|
||||
|
||||
s1 = floor ((begin - waveview->bbox_ulx) * waveview->samples_per_unit);
|
||||
|
||||
// fprintf (stderr, "0x%x begins at sample %f\n", waveview, waveview->bbox_ulx * waveview->samples_per_unit);
|
||||
|
||||
if (end == waveview->bbox_lrx) {
|
||||
/* This avoids minor rounding errors when we have the
|
||||
entire region visible.
|
||||
*/
|
||||
s2 = waveview->samples;
|
||||
} else {
|
||||
s2 = s1 + floor ((end - begin) * waveview->samples_per_unit);
|
||||
}
|
||||
|
||||
#if 0
|
||||
printf ("0x%x r (%d..%d)(%d..%d) bbox (%d..%d)(%d..%d)"
|
||||
" b/e %d..%d s= %lu..%lu @ %f\n",
|
||||
waveview,
|
||||
buf->rect.x0,
|
||||
buf->rect.x1,
|
||||
buf->rect.y0,
|
||||
buf->rect.y1,
|
||||
waveview->bbox_ulx,
|
||||
waveview->bbox_lrx,
|
||||
waveview->bbox_uly,
|
||||
waveview->bbox_lry,
|
||||
begin, end, s1, s2,
|
||||
waveview->samples_per_unit);
|
||||
#endif
|
||||
|
||||
/* now ensure that the cache is full and properly
|
||||
positioned.
|
||||
*/
|
||||
|
||||
// check_cache (waveview, "pre-ensure");
|
||||
|
||||
if (waveview->cache_updater && waveview->reload_cache_in_render) {
|
||||
waveview->cache->start = 0;
|
||||
waveview->cache->end = 0;
|
||||
waveview->reload_cache_in_render = FALSE;
|
||||
}
|
||||
|
||||
// check_cache (waveview, "post-ensure");
|
||||
|
||||
/* don't rectify at single-sample zoom */
|
||||
if (waveview->rectified && waveview->samples_per_unit > 1) {
|
||||
rectify = TRUE;
|
||||
}
|
||||
else {
|
||||
rectify = FALSE;
|
||||
}
|
||||
|
||||
clip_length = MIN(5,(waveview->height/4));
|
||||
|
||||
/*
|
||||
Now draw each line, clipping it appropriately. The clipping
|
||||
is done by the macros PAINT_FOO().
|
||||
*/
|
||||
|
||||
half_height = waveview->half_height;
|
||||
|
||||
/* this makes it slightly easier to comprehend whats going on */
|
||||
#define origin half_height
|
||||
|
||||
if (waveview->filled && !rectify) {
|
||||
int prev_pymin = 1;
|
||||
int prev_pymax = 0;
|
||||
int last_pymin = 1;
|
||||
int last_pymax = 0;
|
||||
int next_pymin, next_pymax;
|
||||
double max, min;
|
||||
int next_clip_max = 0;
|
||||
int next_clip_min = 0;
|
||||
|
||||
if (s1 < waveview->samples_per_unit) {
|
||||
/* we haven't got a prev vars to compare with, so outline the whole line here */
|
||||
prev_pymax = (int) rint ((item->y1 + origin) * item->canvas->pixels_per_unit);
|
||||
prev_pymin = prev_pymax;
|
||||
}
|
||||
else {
|
||||
s1 -= waveview->samples_per_unit;
|
||||
}
|
||||
|
||||
if(end == waveview->bbox_lrx) {
|
||||
/* we don't have the NEXT vars for the last sample */
|
||||
last_pymax = (int) rint ((item->y1 + origin) * item->canvas->pixels_per_unit);
|
||||
last_pymin = last_pymax;
|
||||
}
|
||||
else {
|
||||
s2 += waveview->samples_per_unit;
|
||||
}
|
||||
|
||||
cache_index = gnome_canvas_waveview_ensure_cache (waveview, s1, s2);
|
||||
|
||||
/*
|
||||
* Compute the variables outside the rendering rect
|
||||
*/
|
||||
if(prev_pymax != prev_pymin) {
|
||||
|
||||
prev_pymax = (int) rint ((item->y1 + origin - MIN(waveview->cache->data[cache_index].max, 1.0) * half_height) * item->canvas->pixels_per_unit);
|
||||
prev_pymin = (int) rint ((item->y1 + origin - MAX(waveview->cache->data[cache_index].min, -1.0) * half_height) * item->canvas->pixels_per_unit);
|
||||
++cache_index;
|
||||
}
|
||||
if(last_pymax != last_pymin) {
|
||||
/* take the index of one sample right of what we render */
|
||||
guint index = cache_index + (end - begin);
|
||||
|
||||
if (index >= waveview->cache->data_size) {
|
||||
|
||||
/* the data we want is off the end of the cache, which must mean its beyond
|
||||
the end of the region's source; hence the peak values are 0 */
|
||||
last_pymax = (int) rint ((item->y1 + origin) * item->canvas->pixels_per_unit);
|
||||
last_pymin = (int) rint ((item->y1 + origin) * item->canvas->pixels_per_unit);
|
||||
|
||||
} else {
|
||||
|
||||
last_pymax = (int) rint ((item->y1 + origin - MIN(waveview->cache->data[index].max, 1.0) * half_height) * item->canvas->pixels_per_unit);
|
||||
last_pymin = (int) rint ((item->y1 + origin - MAX(waveview->cache->data[index].min, -1.0) * half_height) * item->canvas->pixels_per_unit);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* initialize NEXT* variables for the first run, duplicated in the loop for speed
|
||||
*/
|
||||
max = waveview->cache->data[cache_index].max;
|
||||
min = waveview->cache->data[cache_index].min;
|
||||
|
||||
if (max >= 1.0) {
|
||||
max = 1.0;
|
||||
next_clip_max = 1;
|
||||
}
|
||||
|
||||
if (min <= -1.0) {
|
||||
min = -1.0;
|
||||
next_clip_min = 1;
|
||||
}
|
||||
|
||||
max *= half_height;
|
||||
min *= half_height;
|
||||
|
||||
next_pymax = (int) rint ((item->y1 + origin - max) * item->canvas->pixels_per_unit);
|
||||
next_pymin = (int) rint ((item->y1 + origin - min) * item->canvas->pixels_per_unit);
|
||||
|
||||
/*
|
||||
* And now the loop
|
||||
*/
|
||||
for(x = begin; x < end; ++x) {
|
||||
int clip_max = next_clip_max;
|
||||
int clip_min = next_clip_min;
|
||||
int fill_max, fill_min;
|
||||
|
||||
pymax = next_pymax;
|
||||
pymin = next_pymin;
|
||||
|
||||
/* compute next */
|
||||
if(x == end - 1) {
|
||||
/*next is now the last column, which is outside the rendering rect, and possibly outside the region*/
|
||||
next_pymax = last_pymax;
|
||||
next_pymin = last_pymin;
|
||||
}
|
||||
else {
|
||||
++cache_index;
|
||||
|
||||
if (cache_index < waveview->cache->data_size) {
|
||||
max = waveview->cache->data[cache_index].max;
|
||||
min = waveview->cache->data[cache_index].min;
|
||||
} else {
|
||||
max = min = 0;
|
||||
}
|
||||
|
||||
next_clip_max = 0;
|
||||
next_clip_min = 0;
|
||||
|
||||
if (max >= 1.0) {
|
||||
max = 1.0;
|
||||
next_clip_max = 1;
|
||||
}
|
||||
|
||||
if (min <= -1.0) {
|
||||
min = -1.0;
|
||||
next_clip_min = 1;
|
||||
}
|
||||
|
||||
max *= half_height;
|
||||
min *= half_height;
|
||||
|
||||
next_pymax = (int) rint ((item->y1 + origin - max) * item->canvas->pixels_per_unit);
|
||||
next_pymin = (int) rint ((item->y1 + origin - min) * item->canvas->pixels_per_unit);
|
||||
}
|
||||
|
||||
/* render */
|
||||
if (pymax == pymin) {
|
||||
PAINT_DOTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymin);
|
||||
} else {
|
||||
if((prev_pymax < pymax && next_pymax < pymax) ||
|
||||
(prev_pymax == pymax && next_pymax == pymax)) {
|
||||
fill_max = pymax + 1;
|
||||
PAINT_DOTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymax);
|
||||
}
|
||||
else {
|
||||
fill_max = MAX(prev_pymax, next_pymax);
|
||||
if(pymax == fill_max) {
|
||||
PAINT_DOTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymax);
|
||||
++fill_max;
|
||||
}
|
||||
else {
|
||||
PAINT_VERTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymax, fill_max);
|
||||
}
|
||||
}
|
||||
|
||||
if((prev_pymin > pymin && next_pymin > pymin) ||
|
||||
(prev_pymin == pymin && next_pymin == pymin)) {
|
||||
fill_min = pymin - 1;
|
||||
PAINT_DOTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymin-1);
|
||||
}
|
||||
else {
|
||||
fill_min = MIN(prev_pymin, next_pymin);
|
||||
if(pymin == fill_min) {
|
||||
PAINT_DOTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymin);
|
||||
}
|
||||
else {
|
||||
PAINT_VERTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, fill_min, pymin);
|
||||
}
|
||||
}
|
||||
|
||||
if(fill_max < fill_min) {
|
||||
PAINT_VERTA(buf, waveview->fill_r, waveview->fill_g, waveview->fill_b, waveview->fill_a, x, fill_max, fill_min);
|
||||
}
|
||||
else if(fill_max == fill_min) {
|
||||
PAINT_DOTA(buf, waveview->fill_r, waveview->fill_g, waveview->fill_b, waveview->fill_a, x, fill_max);
|
||||
}
|
||||
}
|
||||
|
||||
if (clip_max) {
|
||||
PAINT_VERTA(buf, waveview->clip_r, waveview->clip_g, waveview->clip_b, waveview->clip_a, x, pymax, pymax+clip_length);
|
||||
}
|
||||
|
||||
if (clip_min) {
|
||||
PAINT_VERTA(buf, waveview->clip_r, waveview->clip_g, waveview->clip_b, waveview->clip_a, x, pymin-clip_length, pymin);
|
||||
}
|
||||
|
||||
prev_pymax = pymax;
|
||||
prev_pymin = pymin;
|
||||
}
|
||||
|
||||
} else if (waveview->filled && rectify) {
|
||||
|
||||
int prev_pymax = -1;
|
||||
int last_pymax = -1;
|
||||
int next_pymax;
|
||||
double max, min;
|
||||
int next_clip_max = 0;
|
||||
int next_clip_min = 0;
|
||||
|
||||
// for rectified, this stays constant throughout the loop
|
||||
pymin = (int) rint ((item->y1 + waveview->height) * item->canvas->pixels_per_unit);
|
||||
|
||||
if(s1 < waveview->samples_per_unit) {
|
||||
/* we haven't got a prev vars to compare with, so outline the whole line here */
|
||||
prev_pymax = pymin;
|
||||
}
|
||||
else {
|
||||
s1 -= waveview->samples_per_unit;
|
||||
}
|
||||
|
||||
if(end == waveview->bbox_lrx) {
|
||||
/* we don't have the NEXT vars for the last sample */
|
||||
last_pymax = pymin;
|
||||
}
|
||||
else {
|
||||
s2 += waveview->samples_per_unit;
|
||||
}
|
||||
|
||||
cache_index = gnome_canvas_waveview_ensure_cache (waveview, s1, s2);
|
||||
|
||||
/*
|
||||
* Compute the variables outside the rendering rect
|
||||
*/
|
||||
if(prev_pymax < 0) {
|
||||
max = MIN(waveview->cache->data[cache_index].max, 1.0);
|
||||
min = MAX(waveview->cache->data[cache_index].min, -1.0);
|
||||
|
||||
if (fabs (min) > fabs (max)) {
|
||||
max = fabs (min);
|
||||
}
|
||||
|
||||
prev_pymax = (int) rint ((item->y1 + waveview->height - max * waveview->height) * item->canvas->pixels_per_unit);
|
||||
++cache_index;
|
||||
}
|
||||
if(last_pymax < 0) {
|
||||
/* take the index of one sample right of what we render */
|
||||
int index = cache_index + (end - begin);
|
||||
|
||||
max = MIN(waveview->cache->data[index].max, 1.0);
|
||||
min = MAX(waveview->cache->data[index].min, -1.0);
|
||||
|
||||
if (fabs (min) > fabs (max)) {
|
||||
max = fabs (min);
|
||||
}
|
||||
|
||||
last_pymax = (int) rint ((item->y1 + waveview->height - max * waveview->height) * item->canvas->pixels_per_unit);
|
||||
}
|
||||
|
||||
/*
|
||||
* initialize NEXT* variables for the first run, duplicated in the loop for speed
|
||||
*/
|
||||
max = waveview->cache->data[cache_index].max;
|
||||
min = waveview->cache->data[cache_index].min;
|
||||
|
||||
if (max >= 1.0) {
|
||||
max = 1.0;
|
||||
next_clip_max = 1;
|
||||
}
|
||||
|
||||
if (min <= -1.0) {
|
||||
min = -1.0;
|
||||
next_clip_min = 1;
|
||||
}
|
||||
|
||||
if (fabs (min) > fabs (max)) {
|
||||
max = fabs (min);
|
||||
}
|
||||
|
||||
next_pymax = (int) rint ((item->y1 + waveview->height - max * waveview->height) * item->canvas->pixels_per_unit);
|
||||
|
||||
/*
|
||||
* And now the loop
|
||||
*/
|
||||
for(x = begin; x < end; ++x) {
|
||||
int clip_max = next_clip_max;
|
||||
int clip_min = next_clip_min;
|
||||
int fill_max;
|
||||
|
||||
pymax = next_pymax;
|
||||
|
||||
/* compute next */
|
||||
if(x == end - 1) {
|
||||
/*next is now the last column, which is outside the rendering rect, and possibly outside the region*/
|
||||
next_pymax = last_pymax;
|
||||
}
|
||||
else {
|
||||
++cache_index;
|
||||
|
||||
max = waveview->cache->data[cache_index].max;
|
||||
min = waveview->cache->data[cache_index].min;
|
||||
|
||||
if (max >= 1.0) {
|
||||
max = 1.0;
|
||||
next_clip_max = 1;
|
||||
}
|
||||
|
||||
if (min <= -1.0) {
|
||||
min = -1.0;
|
||||
next_clip_min = 1;
|
||||
}
|
||||
|
||||
if (fabs (min) > fabs (max)) {
|
||||
max = fabs (min);
|
||||
}
|
||||
|
||||
next_pymax = (int) rint ((item->y1 + waveview->height - max * waveview->height) * item->canvas->pixels_per_unit);
|
||||
}
|
||||
|
||||
/* render */
|
||||
if (pymax == pymin) {
|
||||
PAINT_DOTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymin);
|
||||
} else {
|
||||
if((prev_pymax < pymax && next_pymax < pymax) ||
|
||||
(prev_pymax == pymax && next_pymax == pymax)) {
|
||||
fill_max = pymax + 1;
|
||||
PAINT_DOTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymax);
|
||||
}
|
||||
else {
|
||||
fill_max = MAX(prev_pymax, next_pymax);
|
||||
if(pymax == fill_max) {
|
||||
PAINT_DOTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymax);
|
||||
++fill_max;
|
||||
}
|
||||
else {
|
||||
PAINT_VERTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymax, fill_max);
|
||||
}
|
||||
}
|
||||
|
||||
if(fill_max < pymin) {
|
||||
PAINT_VERTA(buf, waveview->fill_r, waveview->fill_g, waveview->fill_b, waveview->fill_a, x, fill_max, pymin);
|
||||
}
|
||||
else if(fill_max == pymin) {
|
||||
PAINT_DOTA(buf, waveview->fill_r, waveview->fill_g, waveview->fill_b, waveview->fill_a, x, pymin);
|
||||
}
|
||||
}
|
||||
|
||||
if (clip_max) {
|
||||
PAINT_VERTA(buf, waveview->clip_r, waveview->clip_g, waveview->clip_b, waveview->clip_a, x, pymax, pymax+clip_length);
|
||||
}
|
||||
|
||||
if (clip_min) {
|
||||
PAINT_VERTA(buf, waveview->clip_r, waveview->clip_g, waveview->clip_b, waveview->clip_a, x, pymin-clip_length, pymin);
|
||||
}
|
||||
|
||||
prev_pymax = pymax;
|
||||
}
|
||||
}
|
||||
else {
|
||||
cache_index = gnome_canvas_waveview_ensure_cache (waveview, s1, s2);
|
||||
|
||||
for (x = begin; x < end; x++) {
|
||||
|
||||
double max, min;
|
||||
int clip_max, clip_min;
|
||||
|
||||
clip_max = 0;
|
||||
clip_min = 0;
|
||||
|
||||
max = waveview->cache->data[cache_index].max;
|
||||
min = waveview->cache->data[cache_index].min;
|
||||
|
||||
if (max >= 1.0) {
|
||||
max = 1.0;
|
||||
clip_max = 1;
|
||||
}
|
||||
|
||||
if (min <= -1.0) {
|
||||
min = -1.0;
|
||||
clip_min = 1;
|
||||
}
|
||||
|
||||
if (rectify) {
|
||||
|
||||
if (fabs (min) > fabs (max)) {
|
||||
max = fabs (min);
|
||||
}
|
||||
|
||||
max = max * waveview->height;
|
||||
|
||||
pymax = (int) rint ((item->y1 + waveview->height - max) * item->canvas->pixels_per_unit);
|
||||
pymin = (int) rint ((item->y1 + waveview->height) * item->canvas->pixels_per_unit);
|
||||
|
||||
} else {
|
||||
|
||||
max = max * half_height;
|
||||
min = min * half_height;
|
||||
|
||||
pymax = (int) rint ((item->y1 + origin - max) * item->canvas->pixels_per_unit);
|
||||
pymin = (int) rint ((item->y1 + origin - min) * item->canvas->pixels_per_unit);
|
||||
}
|
||||
|
||||
/* OK, now fill the RGB buffer at x=i with a line between pymin and pymax,
|
||||
or, if samples_per_unit == 1, then a dot at each location.
|
||||
*/
|
||||
|
||||
if (pymax == pymin) {
|
||||
PAINT_DOTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymin);
|
||||
} else {
|
||||
PAINT_VERTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymax, pymin);
|
||||
}
|
||||
|
||||
/* show clipped waveforms with small red lines */
|
||||
|
||||
if (clip_max) {
|
||||
PAINT_VERTA(buf, waveview->clip_r, waveview->clip_g, waveview->clip_b, waveview->clip_a, x, pymax, pymax+clip_length);
|
||||
}
|
||||
|
||||
if (clip_min) {
|
||||
PAINT_VERTA(buf, waveview->clip_r, waveview->clip_g, waveview->clip_b, waveview->clip_a, x, pymin-clip_length, pymin);
|
||||
}
|
||||
|
||||
/* presto, we're done */
|
||||
|
||||
cache_index++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!waveview->rectified && waveview->zero_line && waveview->height >= 100) {
|
||||
// Paint zeroline.
|
||||
|
||||
unsigned char zero_r, zero_g, zero_b, zero_a;
|
||||
UINT_TO_RGBA( waveview->zero_color, &zero_r, &zero_g, &zero_b, &zero_a);
|
||||
int zeroline_y = (int) rint ((item->y1 + origin) * item->canvas->pixels_per_unit);
|
||||
PAINT_HORIZA(buf, zero_r, zero_g, zero_b, zero_a, zbegin, zend, zeroline_y);
|
||||
}
|
||||
#undef origin
|
||||
}
|
||||
|
||||
static void
|
||||
gnome_canvas_waveview_render (GnomeCanvasItem *item,
|
||||
GnomeCanvasBuf *buf)
|
||||
{
|
||||
if (_gradient_rendering) {
|
||||
gnome_canvas_waveview_gradient_render (item, buf);
|
||||
} else {
|
||||
gnome_canvas_waveview_flat_render (item, buf);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gnome_canvas_waveview_draw (GnomeCanvasItem *item,
|
||||
GdkDrawable *drawable,
|
||||
|
|
|
|||
|
|
@ -64,6 +64,8 @@ struct _GnomeCanvasWaveViewCache
|
|||
GnomeCanvasWaveViewCache* gnome_canvas_waveview_cache_new ();
|
||||
void gnome_canvas_waveview_cache_destroy (GnomeCanvasWaveViewCache*);
|
||||
|
||||
void gnome_canvas_waveview_set_gradient_waveforms (int);
|
||||
|
||||
typedef gulong (*waveview_length_function_t)(void*);
|
||||
typedef gulong (*waveview_sourcefile_length_function_t)(void*, double);
|
||||
typedef void (*waveview_gain_curve_function_t)(void *arg, double start, double end, float* vector, gint64 veclen);
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@
|
|||
#include "ardour/filesystem_paths.h"
|
||||
|
||||
#include "ardour_button.h"
|
||||
#include "canvas-waveview.h"
|
||||
#include "theme_manager.h"
|
||||
#include "rgb_macros.h"
|
||||
#include "ardour_ui.h"
|
||||
|
|
@ -56,6 +57,7 @@ ThemeManager::ThemeManager()
|
|||
, light_button (_("Light Theme"))
|
||||
, reset_button (_("Restore Defaults"))
|
||||
, flat_buttons (_("Draw \"flat\" buttons"))
|
||||
, gradient_waveforms (_("Draw waveforms with color gradient"))
|
||||
{
|
||||
set_title (_("Theme Manager"));
|
||||
|
||||
|
|
@ -91,6 +93,7 @@ ThemeManager::ThemeManager()
|
|||
vbox->pack_start (theme_selection_hbox, PACK_SHRINK);
|
||||
vbox->pack_start (reset_button, PACK_SHRINK);
|
||||
vbox->pack_start (flat_buttons, PACK_SHRINK);
|
||||
vbox->pack_start (gradient_waveforms, PACK_SHRINK);
|
||||
vbox->pack_start (scroller);
|
||||
add (*vbox);
|
||||
|
||||
|
|
@ -105,6 +108,7 @@ ThemeManager::ThemeManager()
|
|||
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));
|
||||
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));
|
||||
|
||||
set_size_request (-1, 400);
|
||||
setup_theme ();
|
||||
|
|
@ -238,6 +242,18 @@ ThemeManager::on_flat_buttons_toggled ()
|
|||
gtk_rc_reset_styles (gtk_settings_get_default());
|
||||
}
|
||||
|
||||
void
|
||||
ThemeManager::on_gradient_waveforms_toggled ()
|
||||
{
|
||||
ARDOUR_UI::config()->gradient_waveforms.set (gradient_waveforms.get_active());
|
||||
ARDOUR_UI::config()->set_dirty ();
|
||||
|
||||
gnome_canvas_waveview_set_gradient_waveforms (gradient_waveforms.get_active());
|
||||
|
||||
/* force a redraw */
|
||||
gtk_rc_reset_styles (gtk_settings_get_default());
|
||||
}
|
||||
|
||||
void
|
||||
ThemeManager::on_dark_theme_button_toggled()
|
||||
{
|
||||
|
|
@ -347,6 +363,7 @@ ThemeManager::setup_theme ()
|
|||
}
|
||||
|
||||
flat_buttons.set_active (ARDOUR_UI::config()->flat_buttons.get());
|
||||
gradient_waveforms.set_active (ARDOUR_UI::config()->gradient_waveforms.get());
|
||||
|
||||
load_rc_file(rcfile, false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ class ThemeManager : public ArdourWindow
|
|||
void on_dark_theme_button_toggled ();
|
||||
void on_light_theme_button_toggled ();
|
||||
void on_flat_buttons_toggled ();
|
||||
void on_gradient_waveforms_toggled ();
|
||||
|
||||
private:
|
||||
struct ColorDisplayModelColumns : public Gtk::TreeModel::ColumnRecord {
|
||||
|
|
@ -69,6 +70,7 @@ class ThemeManager : public ArdourWindow
|
|||
Gtk::RadioButton light_button;
|
||||
Gtk::Button reset_button;
|
||||
Gtk::CheckButton flat_buttons;
|
||||
Gtk::CheckButton gradient_waveforms;
|
||||
|
||||
bool button_press_event (GdkEventButton*);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
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, gradient_waveforms, "gradient-waveforms", false)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue