2 volta-bracket.cc -- implement Volta_bracket_interface
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2004 Jan Nieuwenhuizen <janneke@gnu.org>
13 #include "font-interface.hh"
14 #include "line-interface.hh"
16 #include "paper-column.hh"
17 #include "output-def.hh"
18 #include "text-item.hh"
19 #include "volta-bracket.hh"
20 #include "group-interface.hh"
21 #include "side-position-interface.hh"
22 #include "directional-element-interface.hh"
26 this is too complicated. Yet another version of side-positioning,
31 * Should look for system_start_delim to find left edge of staff.
35 MAKE_SCHEME_CALLBACK (Volta_bracket_interface,print,1);
37 Volta_bracket_interface::print (SCM smob)
39 Grob *me = unsmob_grob (smob);
40 Spanner *orig_span = dynamic_cast<Spanner*> (me->original_);
42 bool broken_first_bracket = orig_span && (orig_span->broken_intos_[0] == (Spanner*)me);
44 bool broken_last_bracket = orig_span && (orig_span->broken_intos_.top () == (Spanner*)me);
46 bool no_vertical_start = orig_span && !broken_first_bracket;
47 bool no_vertical_end = orig_span && !broken_last_bracket;
48 SCM s = me->get_property ("bars");
49 Grob * endbar = ly_c_pair_p (s) ? unsmob_grob (ly_car (s)) : 0;
50 SCM glyph = endbar ? endbar->get_property ("glyph") : SCM_EOL;
53 if (ly_c_string_p (glyph))
54 str = ly_scm2string (glyph);
58 const char* cs = str.to_str0 ();
60 (strcmp (cs,":|")!=0 && strcmp (cs,"|:")!=0 && strcmp (cs,"|.")!=0
61 && strcmp (cs,":|:")!=0 && strcmp (cs,".|")!=0);
63 Output_def * paper =me->get_paper ();
64 Real half_space = 0.5;
66 Item * bound = dynamic_cast<Spanner*> (me)->get_bound (LEFT);
69 not a start, but really broken in two
72 if (bound->break_status_dir () == RIGHT)
74 Paper_column *pc = bound->get_column ();
75 left = pc->extent (pc, X_AXIS)[RIGHT] - bound->relative_coordinate (pc, X_AXIS);
80 the volta spanner is attached to the bar-line, which is moved
81 to the right. We don't need to compensate for the left edge.
85 Real w = dynamic_cast<Spanner*> (me)->spanner_length () - left - half_space;
86 Real h = robust_scm2double (me->get_property ("height"), 1);
89 if (!no_vertical_start)
90 start = Line_interface::line (me, Offset (0,0), Offset (0, h));
93 end = Line_interface::line (me, Offset (w, 0), Offset (w,h));
95 Stencil mol = Line_interface::line (me, Offset (0, h), Offset (w,h));
96 mol.add_stencil (start);
97 mol.add_stencil (end);
99 if (!orig_span || broken_first_bracket)
101 SCM text = me->get_property ("text");
102 SCM properties = me->get_property_alist_chain (SCM_EOL);
103 SCM snum = Text_item::interpret_markup (paper->self_scm (), properties, text);
104 Stencil num = *unsmob_stencil (snum);
106 mol.add_at_edge (X_AXIS, LEFT, num, - num.extent (X_AXIS).length ()
109 mol.translate_axis (left, X_AXIS);
110 return mol.smobbed_copy ();
115 Volta_bracket_interface::add_bar (Grob *me, Item* b)
117 Pointer_group_interface::add_grob (me, ly_symbol2scm ("bars"), b);
118 Side_position_interface::add_support (me,b);
119 add_bound_item (dynamic_cast<Spanner*> (me), b);
123 Volta_bracket_interface::add_column (Grob*me, Grob* c)
125 Side_position_interface::add_support (me,c);
128 ADD_INTERFACE (Volta_bracket_interface,"volta-bracket-interface",
129 "Volta bracket with number",
130 "bars thickness height");