2 volta-bracket.cc -- implement Volta_bracket_interface
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2003 Jan Nieuwenhuizen <janneke@gnu.org>
13 #include "font-interface.hh"
14 #include "molecule.hh"
15 #include "paper-column.hh"
16 #include "paper-def.hh"
17 #include "text-item.hh"
18 #include "volta-bracket.hh"
19 #include "group-interface.hh"
20 #include "side-position-interface.hh"
21 #include "directional-element-interface.hh"
25 this is too complicated. Yet another version of side-positioning,
30 * Should look for system_start_delim to find left edge of staff.
34 MAKE_SCHEME_CALLBACK (Volta_bracket_interface,brew_molecule,1);
36 Volta_bracket_interface::brew_molecule (SCM smob)
38 Grob *me = unsmob_grob (smob);
40 = Pointer_group_interface__extract_grobs (me, (Item*)0, "bars");
45 Spanner *orig_span = dynamic_cast<Spanner*> (me->original_);
47 bool broken_first_bracket = orig_span && (orig_span->broken_intos_[0] == (Spanner*)me);
49 bool broken_last_bracket = orig_span && (orig_span->broken_intos_.top () == (Spanner*)me);
51 bool no_vertical_start = orig_span && !broken_first_bracket;
52 bool no_vertical_end = orig_span && !broken_last_bracket;
53 SCM s = me->get_grob_property ("bars");
54 Grob * endbar = unsmob_grob (ly_car (s));
55 SCM glyph = endbar->get_grob_property("glyph");
58 if (gh_string_p (glyph))
59 str = ly_scm2string(glyph);
63 const char* cs = str.to_str0 ();
65 (strcmp(cs,":|")!=0 && strcmp(cs,"|:")!=0 && strcmp(cs,"|.")!=0
66 && strcmp(cs,":|:")!=0 && strcmp(cs,".|")!=0);
68 Paper_def * paper =me->get_paper ();
69 Real staff_thick = paper->get_realvar (ly_symbol2scm ("linethickness"));
70 Real half_space = 0.5;
72 Item * bound = dynamic_cast<Spanner*> (me)->get_bound (LEFT);
75 not a start, but really broken in two
78 if (bound->break_status_dir () == RIGHT)
80 Paper_column *pc = bound->get_column ();
81 left = pc->extent (pc, X_AXIS)[RIGHT] - bound->relative_coordinate (pc, X_AXIS);
86 the volta spanner is attached to the bar-line, which is moved
87 to the right. We don't need to compensate for the left edge.
91 Real w = dynamic_cast<Spanner*> (me)->spanner_length () - left - half_space;
92 Real h = gh_scm2double (me->get_grob_property ("height"));
93 Real t = staff_thick * gh_scm2double (me->get_grob_property ("thickness"));
97 if (!no_vertical_start)
98 start = Lookup::line (t, Offset (0,0), Offset (0, h));
100 if (!no_vertical_end)
101 end = Lookup::line (t, Offset (w, 0), Offset (w,h));
103 Molecule mol = Lookup::line (t, Offset (0, h), Offset (w,h));
104 mol.add_molecule (start);
105 mol.add_molecule (end);
107 if (!orig_span || broken_first_bracket)
109 SCM text = me->get_grob_property ("text");
110 SCM properties = me->get_property_alist_chain (SCM_EOL);
111 SCM snum = Text_item::interpret_markup (paper->self_scm (), properties, text);
112 Molecule num = *unsmob_molecule (snum);
114 mol.add_at_edge (X_AXIS, LEFT, num, - num.extent (X_AXIS).length ()
117 mol.translate_axis (left, X_AXIS);
118 return mol.smobbed_copy ();
123 Volta_bracket_interface::add_bar (Grob *me, Item* b)
125 Pointer_group_interface::add_grob (me, ly_symbol2scm ("bars"), b);
126 Side_position_interface::add_support (me,b);
127 add_bound_item (dynamic_cast<Spanner*> (me), b);
131 Volta_bracket_interface::add_column (Grob*me, Grob* c)
133 Side_position_interface::add_support (me,c);
136 ADD_INTERFACE (Volta_bracket_interface,"volta-bracket-interface",
137 "Volta bracket with number",
138 "bars thickness height");