1 #include "font-interface.hh"
4 #include "accidental-interface.hh"
7 TODO: insert support for smaller cautionaries, tie-break-reminders.
8 Either here or in new-accidental-engraver.
10 'accidentals should go, for a single 'accidental property -- see
11 accidental-placement.cc
17 parenthesize (Grob*me, Molecule m)
19 Molecule open = Font_interface::get_default_font (me)->find_by_name (String ("accidentals-leftparen"));
20 Molecule close = Font_interface::get_default_font (me)->find_by_name (String ("accidentals-rightparen"));
21 m.add_at_edge (X_AXIS, LEFT, Molecule (open), 0);
22 m.add_at_edge (X_AXIS, RIGHT, Molecule (close), 0);
28 MAKE_SCHEME_CALLBACK (Accidental_interface,after_line_breaking,1);
30 Accidental_interface::after_line_breaking (SCM smob)
32 Grob *me = unsmob_grob (smob);
33 Grob *tie = unsmob_grob (me->get_grob_property ("tie"));
35 if (tie && !tie->original_l_)
39 return SCM_UNSPECIFIED;
43 Accidental_interface::accurate_boxes (Grob *a,Grob**common)
46 b[X_AXIS] = a->extent (a, X_AXIS);
47 b[Y_AXIS] = a->extent (a, Y_AXIS);
52 if (to_boolean (a->get_grob_property ("cautionary")))
54 SCM cstyle = a->get_grob_property ("cautionary-style");
55 parens = gh_equal_p (cstyle, ly_symbol2scm ("parentheses"));
59 SCM accs = a->get_grob_property ("accidentals");
60 SCM scm_style = a->get_grob_property ("style");
61 if (!gh_symbol_p (scm_style)
63 && scm_ilength (accs) == 1)
65 if (gh_scm2int (gh_car (accs)) == -1)
71 we could make the stem thinner, but that places the flats
74 stem[X_AXIS][RIGHT] *= .5;
75 bulb[Y_AXIS][UP] *= .35;
81 TODO: add support for natural, double flat.
88 Offset o (a->relative_coordinate (common[X_AXIS], X_AXIS),
89 a->relative_coordinate (common[Y_AXIS], Y_AXIS));
90 for(int i = boxes.size(); i--;)
92 boxes[i].translate(o);
98 MAKE_SCHEME_CALLBACK (Accidental_interface,brew_molecule,1);
100 Accidental_interface::brew_molecule (SCM smob)
102 Grob *me = unsmob_grob (smob);
103 bool smaller = false;
106 bool caut = to_boolean (me->get_grob_property ("cautionary"));
109 SCM cstyle = me->get_grob_property ("cautionary-style");
110 parens = gh_equal_p (cstyle, ly_symbol2scm ("parentheses"));
111 smaller = gh_equal_p (cstyle, ly_symbol2scm ("smaller"));
114 SCM scm_style = me->get_grob_property ("style");
116 if (gh_symbol_p (scm_style))
118 style = ly_scm2string (scm_symbol_to_string (scm_style));
123 preferably no name for the default style.
132 SCM ac = Font_interface::font_alist_chain (me);
133 ac = gh_cons (gh_cons (gh_cons
134 (ly_symbol2scm ("font-relative-size"),
135 gh_int2scm (-1)), SCM_EOL),
137 fm = Font_interface::get_font (me, ac);
140 fm = Font_interface::get_default_font (me);
143 for (SCM s = me->get_grob_property ("accidentals");
144 gh_pair_p (s); s= gh_cdr (s))
146 SCM entry = gh_car (s);
149 Molecule acc (fm->find_by_name (String ("accidentals-") +
151 to_str (gh_scm2int(entry))));
153 mol.add_at_edge (X_AXIS, RIGHT, acc, 0.1);
157 mol = parenthesize (me, mol);
159 return mol.smobbed_copy();
164 ADD_INTERFACE (Accidental_interface, "accidental-interface",
165 "a single accidental",
166 "cautionary-style style tie accidentals");