diff options
author | Alessio Treglia <alessio@debian.org> | 2010-09-22 11:13:01 +0200 |
---|---|---|
committer | Alessio Treglia <alessio@debian.org> | 2010-09-22 11:13:01 +0200 |
commit | 21c0acaad1b1fa3d17c911ff7e4ad05d63310195 (patch) | |
tree | 78c71c4b3e27b7e107e5023c67123a3cacc018de /snd-marks.c | |
parent | 6d99b2e313fc5878ab1ac115460f0e85595825a0 (diff) |
Imported Upstream version 11.9
Diffstat (limited to 'snd-marks.c')
-rw-r--r-- | snd-marks.c | 125 |
1 files changed, 30 insertions, 95 deletions
diff --git a/snd-marks.c b/snd-marks.c index 3bc6930..ba9f3ab 100644 --- a/snd-marks.c +++ b/snd-marks.c @@ -261,6 +261,8 @@ void marks_off(chan_info *cp) } +static void show_mark(chan_info *cp, axis_info *ap, mark *mp, bool show); + static XEN draw_mark_hook; static void draw_mark_1(chan_info *cp, axis_info *ap, mark *mp, bool show) @@ -291,7 +293,9 @@ static void draw_mark(chan_info *cp, axis_info *ap, mark *mp) static void erase_mark(chan_info *cp, axis_info *ap, mark *mp) { +#if (!USE_GTK) if (mp->visible) draw_mark_1(cp, ap, mp, false); +#endif } @@ -324,7 +328,9 @@ static mark *hit_mark_1(chan_info *cp, mark *mp, void *m) } -static mark *hit_triangle_1(chan_info *cp, mark *mp, void *m) +#define MARK_PLAY_ARROW_SIZE 10 + +static mark *hit_mark_triangle_1(chan_info *cp, mark *mp, void *m) { /* m->samp = raw x mouse position */ /* we're going left to right, so after passing x, give up */ @@ -347,7 +353,7 @@ static mark *hit_triangle_1(chan_info *cp, mark *mp, void *m) } -mark *hit_triangle(chan_info *cp, int x, int y) +mark *hit_mark_triangle(chan_info *cp, int x, int y) { if (cp->edits[cp->edit_ctr]->marks) { @@ -363,7 +369,7 @@ mark *hit_triangle(chan_info *cp, int x, int y) md->x = x; md->y = y; md->all_done = (mark *)1; - mp = map_over_marks(cp, hit_triangle_1, (void *)md, READ_FORWARD); + mp = map_over_marks(cp, hit_mark_triangle_1, (void *)md, READ_FORWARD); if (mp == (mark *)1) mp = NULL; free(md); return(mp); @@ -475,6 +481,7 @@ static void sort_marks(chan_info *cp) } +static void show_mark_triangle(chan_info *cp, int x); static int prev_cx = -1; mus_long_t move_play_mark(chan_info *cp, mus_long_t *mc, int cx) @@ -1420,7 +1427,7 @@ static void mark_save_graph(mark_context *ms, int j) static void erase_and_draw_grf_points(mark_context *ms, chan_info *cp, int nj) { chan_context *cx; - axis_context *ax; + graphics_context *ax; point_t *points; #if USE_MOTIF GC draw_gc, undraw_gc; @@ -1455,7 +1462,7 @@ static void erase_and_draw_grf_points(mark_context *ms, chan_info *cp, int nj) static void erase_and_draw_both_grf_points(mark_context *ms, chan_info *cp, int nj) { chan_context *cx; - axis_context *ax; + graphics_context *ax; point_t *points, *points1; #if USE_MOTIF GC draw_gc, undraw_gc; @@ -1562,7 +1569,11 @@ void move_mark(chan_info *cp, mark *mp, int x) /* from mouse drag callback in sn else redraw = move_mark_1(cp, mp, x); if (mark_control_clicked) make_mark_graph(cp, mark_initial_sample, mp->samp, 0); + #if (!USE_GTK) if (redraw) draw_mark(cp, cp->axis, mp); + #else + if (redraw) display_channel_time_data(cp); + #endif } @@ -1861,10 +1872,10 @@ static void make_mark_graph(chan_info *cp, mus_long_t initial_sample, mus_long_t /* -------------------------------- display mark -------------------------------- */ -void show_mark(chan_info *cp, axis_info *ap, mark *mp, bool show) +static void show_mark(chan_info *cp, axis_info *ap, mark *mp, bool show) { int len, top, cx, y0, y1; - axis_context *ax; + graphics_context *ax; #if USE_MOTIF #define STRING_Y_OFFSET 6 @@ -1878,99 +1889,19 @@ void show_mark(chan_info *cp, axis_info *ap, mark *mp, bool show) if (mp->name) top += 10; cx = grf_x((double)(mp->samp) / (double)SND_SRATE(cp->sound), ap); - /* split into 3 cases to try to make it more readable */ -#if USE_MOTIF - ax = mark_tag_context(cp); if (mp->name) { +#if USE_MOTIF ax->current_font = ss->sgx->peaks_fontstruct->fid; XSetFont(ax->dp, ax->gc, ss->sgx->peaks_fontstruct->fid); +#else + ax->current_font = PEAKS_FONT(ss); +#endif len = mark_name_width(mp->name); draw_string(ax, (int)(cx - 0.5 * len), y1 + STRING_Y_OFFSET, mp->name, strlen(mp->name)); } - fill_rectangle(ax, - cx - mark_tag_width(ss), top, - 2 * mark_tag_width(ss), mark_tag_height(ss)); - draw_line(ax, cx, top + 4, cx, y0); - fill_polygon(ax, 4, - cx, y0, - cx + MARK_PLAY_ARROW_SIZE, y0 + MARK_PLAY_ARROW_SIZE, - cx, y0 + 2 * MARK_PLAY_ARROW_SIZE, - cx, y0); - mp->visible = show; -#else - /* gtk / cairo */ - -#if USE_CAIRO - { - color_t bg_color, old_color; - int slop = 0; - ax = mark_tag_context(cp); - if (mp->name) - { - ax->current_font = PEAKS_FONT(ss); - len = mark_name_width(mp->name); - if (!show) /* erase mark */ - { - ax = erase_context(cp); - fill_rectangle(ax, (int)(cx - 0.5 * len - 1), top - 15, len + 3, 16); - ax = mark_tag_context(cp); - } - else draw_string(ax, (int)(cx - 0.5 * len), y1 + STRING_Y_OFFSET, mp->name, strlen(mp->name)); - } - if (ax->cr) cairo_destroy(ax->cr); - ax->cr = gdk_cairo_create(ax->wn); - - old_color = ax->gc->fg_color; - if (show) - bg_color = ss->sgx->red; - else - { - if (cp->cgx->selected) - bg_color = ss->sgx->selected_graph_color; - else bg_color = ss->sgx->graph_color; - slop = 1; - } - set_foreground_color(ax, bg_color); - - fill_rectangle(ax, - cx - mark_tag_width(ss), top, - 2 * mark_tag_width(ss), mark_tag_height(ss) + slop); - draw_line(ax, cx, top + 4, cx, y0); - fill_polygon(ax, 4, - cx, y0, - cx + MARK_PLAY_ARROW_SIZE + slop, y0 + MARK_PLAY_ARROW_SIZE, - cx, y0 + 2 * MARK_PLAY_ARROW_SIZE + slop, - cx, y0); - mp->visible = show; - - set_foreground_color(ax, old_color); - make_graph(cp); - } - - -#else - - /* gtk without cairo */ - if (mp->name) - { - len = mark_name_width(mp->name); - if (!show) /* erase mark */ - { - ax = erase_context(cp); - /* gtk and cairo cases need to be separate because we're using XOR (red) in the non-cairo case (so the tag needs to be left unerased) */ - fill_rectangle(ax, (int)(cx - 0.5 * len), top - 15, len + 1, 13); /* this should depend on TINY_FONT height */ - } - else - { - ax = copy_context(cp); - ax->current_font = PEAKS_FONT(ss); - draw_string(ax, (int)(cx - 0.5 * len), y1 + STRING_Y_OFFSET, mp->name, strlen(mp->name)); - } - } - ax = mark_tag_context(cp); fill_rectangle(ax, cx - mark_tag_width(ss), top, 2 * mark_tag_width(ss), mark_tag_height(ss)); @@ -1981,13 +1912,13 @@ void show_mark(chan_info *cp, axis_info *ap, mark *mp, bool show) cx, y0 + 2 * MARK_PLAY_ARROW_SIZE, cx, y0); mp->visible = show; - -#endif +#if USE_GTK + copy_context(cp); #endif } -void show_mark_triangle(chan_info *cp, int x) +static void show_mark_triangle(chan_info *cp, int x) { int y0; y0 = ((axis_info *)(cp->axis))->y_axis_y0; @@ -1998,6 +1929,10 @@ void show_mark_triangle(chan_info *cp, int x) x, y0); } +#else +/* no gui */ +static void show_mark(chan_info *cp, axis_info *ap, mark *mp, bool show) {} +static void show_mark_triangle(chan_info *cp, int x) {} #endif @@ -2200,7 +2135,7 @@ static XEN g_test_control_drag_mark(XEN snd, XEN chn, XEN mid) finish_moving_mark(cp, m); x = grf_x((double)(m->samp) / (double)SND_SRATE(cp->sound), cp->axis); y = cp->axis->y_axis_y0 + 2; - hit_triangle(cp, x, y); + hit_mark_triangle(cp, x, y); cx = m->samp + 50; move_play_mark(cp, &cx, x + 50); finish_moving_play_mark(cp); |