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"));
90 if (!no_vertical_start)
91 start = Lookup::line (t, Offset (0,0), Offset (0, h));
94 end = Lookup::line (t, Offset (w, 0), Offset (w,h));
96 Molecule mol = Lookup::line (t, Offset (0, h), Offset (w,h));
97 mol.add_molecule (start);
98 mol.add_molecule (end);
100 SCM text = me->get_grob_property ("text");
101 SCM properties = scm_list_n (me->mutable_property_alist_,
102 me->immutable_property_alist_,SCM_UNDEFINED);
103 Molecule num = Text_item::text2molecule (me, text, properties);
105 mol.add_at_edge (X_AXIS, LEFT, num, - num.extent (X_AXIS).length ()
107 mol.translate_axis (left, X_AXIS);
108 return mol.smobbed_copy ();
113 Volta_bracket_interface::add_bar (Grob *me, Item* b)
115 Pointer_group_interface::add_grob (me, ly_symbol2scm ("bars"), b);
116 Side_position_interface::add_support (me,b);
117 add_bound_item (dynamic_cast<Spanner*> (me), b);
121 Volta_bracket_interface::add_column (Grob*me, Grob* c)
123 Side_position_interface::add_support (me,c);
126 ADD_INTERFACE (Volta_bracket_interface,"volta-bracket-interface",
127 "Volta bracket with number",
128 "bars thickness height");