2 volta-bracket.cc -- implement Volta_bracket_interface
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2002 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);
39 Link_array<Item> bar_arr
40 = Pointer_group_interface__extract_grobs (me, (Item*)0, "bars");
45 Spanner *orig_span = dynamic_cast<Spanner*> (me->original_l_);
47 bool first_bracket = orig_span && (orig_span->broken_into_l_arr_[0] == (Spanner*)me);
49 bool last_bracket = orig_span && (orig_span->broken_into_l_arr_.top () == (Spanner*)me);
51 bool no_vertical_start = orig_span && !first_bracket;
52 bool no_vertical_end = orig_span && !last_bracket;
53 SCM bars = me->get_grob_property ("bars");
54 Grob * endbar = unsmob_grob (ly_car (bars));
55 SCM glyph = endbar->get_grob_property("glyph");
56 String str = ly_scm2string(glyph);
57 const char* cs = str.ch_C();
59 (strcmp(cs,":|")!=0 && strcmp(cs,"|:")!=0 && strcmp(cs,"|.")!=0
60 && strcmp(cs,":|:")!=0 && strcmp(cs,".|")!=0);
62 Real staff_thick = me->paper_l ()->get_var ("linethickness");
63 Real half_space = 0.5;
65 Item * bound = dynamic_cast<Spanner*> (me)->get_bound (LEFT);
68 not a start, but really broken in two
71 if (bound->break_status_dir () == RIGHT)
73 Paper_column *pc = bound->column_l ();
74 left = pc->extent (pc, X_AXIS)[RIGHT] - bound->relative_coordinate (pc, X_AXIS);
79 the volta spanner is attached to the bar-line, which is moved
80 to the right. We don't need to compensate for the left edge.
84 Real w = dynamic_cast<Spanner*> (me)->spanner_length () - left - half_space;
85 Real h = gh_scm2double (me->get_grob_property ("height"));
86 Real t = staff_thick * gh_scm2double (me->get_grob_property ("thickness"));
89 ugh: should build from line segments.
91 SCM at = (scm_list_n (ly_symbol2scm ("volta"),
95 gh_int2scm (no_vertical_start),
96 gh_int2scm (no_vertical_end),
99 Box b (Interval (0, w), Interval (0, h));
100 Molecule mol (b, at);
101 SCM text = me->get_grob_property ("text");
102 SCM properties = scm_list_n (me->mutable_property_alist_,
103 me->immutable_property_alist_,SCM_UNDEFINED);
104 Molecule num = Text_item::text2molecule (me, text, properties);
106 mol.add_at_edge (X_AXIS, LEFT, num, - num.extent (X_AXIS).length ()
108 mol.translate_axis (left, X_AXIS);
109 return mol.smobbed_copy ();
114 Volta_bracket_interface::add_bar (Grob *me, Item* b)
116 Pointer_group_interface::add_grob (me, ly_symbol2scm ("bars"), b);
117 Side_position_interface::add_support (me,b);
118 add_bound_item (dynamic_cast<Spanner*> (me), b);
122 Volta_bracket_interface::add_column (Grob*me, Grob* c)
124 Side_position_interface::add_support (me,c);
127 ADD_INTERFACE (Volta_bracket_interface,"volta-bracket-interface",
128 "Volta bracket with number",
129 "bars thickness height");