File: slurs.c

package info (click to toggle)
denemo 0.5.9-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 2,500 kB
  • ctags: 2,415
  • sloc: ansic: 23,057; sh: 3,321; yacc: 1,737; makefile: 449; lex: 376
file content (52 lines) | stat: -rw-r--r-- 1,040 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* slurs.c
 *
 * Functions for drawing slurs
 *
 * for Denemo, a gtk+ frontend to GNU Lilypond
 * (c) 2000, 2001 Adam Tee, Matthew Hiller
 */

#include "datastructures.h"
#include "utils.h"		/* Includes <gdk.h> */

GSList *
push_slur_stack (GSList * slur_stack, gint x)
{
  slur_stack = g_slist_prepend (slur_stack, GINT_TO_POINTER (x));
  return slur_stack;
}

gint top_slur_stack (GSList * slur_stack)
{
  if (slur_stack)
    return GPOINTER_TO_INT (slur_stack->data);
  else
    return -1;
}

GSList *
pop_slur_stack (GSList * slur_stack)
{
  if (slur_stack)
    {
      GSList *head = slur_stack;

      slur_stack = g_slist_remove_link (slur_stack, head);
      g_slist_free_1 (head);
      return slur_stack;
    }
  else
    return NULL;
}

void
draw_slur (GdkPixmap * pixmap, GdkGC * gc, GSList ** slur_stack,
	   gint x2, gint y)
{
  gint x1 = top_slur_stack (*slur_stack);
  if (x1 != -1)
    {
      *slur_stack = pop_slur_stack (*slur_stack);
      gdk_draw_arc (pixmap, gc, FALSE, x1, y - 15, x2 - x1, 8, 0, 64 * 180);
    }
}