~ubuntu-branches/ubuntu/precise/lilypond/precise

« back to all changes in this revision

Viewing changes to lily/custos.cc

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Bushnell, BSG
  • Date: 2006-12-19 10:18:12 UTC
  • mfrom: (3.1.4 feisty)
  • Revision ID: james.westby@ubuntu.com-20061219101812-7awtjkp0i393wxty
Tags: 2.8.7-3
scripts/midi2ly.py: When setting DATADIR, find Lilypond python files
in the @TOPLEVEL_VERSION@ directory, not 'current'.  Patch thanks to
Chris Lamb (chris@chris-lamb.co.uk).  (Closes: #400550)

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 
4
4
  source file of the GNU LilyPond music typesetter
5
5
 
6
 
  (c) 2000--2004 Juergen Reuter <reuter@ipd.uka.de>
 
6
  (c) 2000--2006 Juergen Reuter <reuter@ipd.uka.de>
7
7
*/
8
8
 
9
9
/* TODO:
10
10
 
11
 
 - do not show if a clef change immediately follows in the next line
12
 
 
13
 
 - decide: do or do not print custos if the next line starts with a rest
14
 
 
 
11
- do not show if a clef change immediately follows in the next line
 
12
 
 
13
- decide: do or do not print custos if the next line starts with a rest
15
14
*/
16
15
 
 
16
#include <cstdio>
 
17
#include <cmath> // rint
 
18
using namespace std;
17
19
 
18
 
#include <stdio.h>
 
20
#include "custos.hh"
19
21
#include "direction.hh"
 
22
#include "font-interface.hh"
 
23
#include "international.hh"
 
24
#include "item.hh"
 
25
#include "note-head.hh"
20
26
#include "staff-symbol-referencer.hh"
21
 
#include "custos.hh"
22
 
#include "stencil.hh"
23
27
#include "warn.hh"
24
 
#include "note-head.hh"
25
 
#include "item.hh"
26
 
#include "font-interface.hh"
27
 
#include "math.h" // rint
28
28
 
29
 
MAKE_SCHEME_CALLBACK (Custos,print,1);
 
29
MAKE_SCHEME_CALLBACK (Custos, print, 1);
30
30
SCM
31
31
Custos::print (SCM smob)
32
32
{
33
33
  Item *me = (Item *)unsmob_grob (smob);
34
34
 
35
35
  SCM scm_style = me->get_property ("style");
36
 
  String style;
37
 
  if (gh_symbol_p (scm_style))
38
 
    {
39
 
      style = ly_symbol2string (scm_style);
40
 
    }
 
36
  string style;
 
37
  if (scm_is_symbol (scm_style))
 
38
    style = ly_symbol2string (scm_style);
41
39
  else
42
 
    {
43
 
      style = "mensural";
44
 
    }
 
40
    style = "mensural";
45
41
 
46
42
  /*
47
43
   * Shall we use a common custos font character regardless if on
48
44
   * staffline or not, or shall we use individual font characters
49
45
   * for both cases?
50
46
   */
51
 
  bool adjust = true; 
 
47
  bool adjust = true;
52
48
 
53
49
  int neutral_pos = robust_scm2int (me->get_property ("neutral-position"), 0);
54
 
  Direction neutral_direction =
55
 
    to_dir (me->get_property ("neutral-direction"));
 
50
  Direction neutral_direction
 
51
    = to_dir (me->get_property ("neutral-direction"));
56
52
 
57
53
  int pos = Staff_symbol_referencer::get_rounded_position (me);
58
 
  int sz = Staff_symbol_referencer::line_count (me)-1;
 
54
  int sz = Staff_symbol_referencer::line_count (me) - 1;
59
55
 
60
 
  String font_char = "custodes-" + style + "-";
 
56
  string font_char = "custodes." + style + ".";
61
57
  if (pos < neutral_pos)
62
58
    font_char += "u";
63
59
  else if (pos > neutral_pos)
70
66
    font_char += "d";
71
67
 
72
68
  if (adjust)
73
 
    {
74
 
      font_char += (((pos ^ sz) & 0x1) == 0) ? "1" : "0";
75
 
    }
 
69
    font_char += (((pos ^ sz) & 0x1) == 0) ? "1" : "0";
76
70
  else
77
 
    {
78
 
      font_char += "2";
79
 
    }
 
71
    font_char += "2";
80
72
 
81
73
  Stencil stencil
82
74
    = Font_interface::get_default_font (me)->find_by_name (font_char);
85
77
      me->warning (_f ("custos `%s' not found", font_char));
86
78
      return SCM_EOL;
87
79
    }
88
 
  else
89
 
    {
90
 
      // add ledger lines
91
 
      int pos = Staff_symbol_referencer::get_rounded_position (me);
92
 
      int interspaces = Staff_symbol_referencer::line_count (me)-1;
93
 
      if (abs (pos) - interspaces > 1)
94
 
        {
95
 
          Stencil ledger_lines =
96
 
            Note_head::brew_ledger_lines (me, pos, interspaces,
97
 
                                          stencil.extent (X_AXIS), 0, true);
98
 
          stencil.add_stencil (ledger_lines);
99
 
        }
100
 
      return stencil.smobbed_copy ();
101
 
    }
 
80
 
 
81
  return stencil.smobbed_copy ();
102
82
}
103
83
 
104
84
ADD_INTERFACE (Custos, "custos-interface",
105
 
  "A custos object.",
106
 
  "style neutral-position neutral-direction");
 
85
               "A custos object.",
 
86
               "style neutral-position neutral-direction");