2 volta-spanner.cc -- implement Volta_spanner
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2001 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-spanner.hh"
19 #include "group-interface.hh"
20 #include "side-position-interface.hh"
21 #include "directional-element-interface.hh"
25 Volta_spanner::set_interface (Grob*)
30 this is too complicated. Yet another version of side-positioning,
35 * Should look for system_start_delim to find left edge of staff.
39 MAKE_SCHEME_CALLBACK (Volta_spanner,brew_molecule,1);
41 Volta_spanner::brew_molecule (SCM smob)
43 Grob *me = unsmob_grob (smob);
44 Link_array<Item> bar_arr
45 = Pointer_group_interface__extract_grobs (me, (Item*)0, "bars");
50 Spanner *orig_span = dynamic_cast<Spanner*> (me->original_l_);
52 bool first_bracket = orig_span && (orig_span->broken_into_l_arr_[0] == (Spanner*)me);
54 bool last_bracket = orig_span && (orig_span->broken_into_l_arr_.top () == (Spanner*)me);
56 bool no_vertical_start = orig_span && !first_bracket;
57 bool no_vertical_end = orig_span && !last_bracket;
58 SCM bars = me->get_grob_property ("bars");
59 Grob * endbar = unsmob_grob (ly_car (bars));
60 SCM glyph = endbar->get_grob_property("glyph");
61 String str = ly_scm2string(glyph);
62 const char* cs = str.ch_C();
64 (strcmp(cs,":|")!=0 && strcmp(cs,"|:")!=0 && strcmp(cs,"|.")!=0
65 && strcmp(cs,":|:")!=0 && strcmp(cs,".|")!=0);
67 Real staff_thick = me->paper_l ()->get_var ("stafflinethickness");
68 Real half_space = 0.5;
70 Item * bound = dynamic_cast<Spanner*> (me)->get_bound (LEFT);
73 not a start, but really broken in two
76 if (bound->break_status_dir () == RIGHT)
78 Paper_column *pc = bound->column_l ();
79 left = pc->extent (pc, X_AXIS)[RIGHT] - bound->relative_coordinate (pc, X_AXIS);
84 the volta spanner is attached to the bar-line, which is moved
85 to the right. We don't need to compensate for the left edge.
89 Real w = dynamic_cast<Spanner*> (me)->spanner_length () - left - half_space;
90 Real h = gh_scm2double (me->get_grob_property ("height"));
91 Real t = staff_thick * gh_scm2double (me->get_grob_property ("thickness"));
94 ugh: should build from line segments.
96 SCM at = (scm_list_n (ly_symbol2scm ("volta"),
100 gh_int2scm (no_vertical_start),
101 gh_int2scm (no_vertical_end),
104 Box b (Interval (0, w), Interval (0, h));
105 Molecule mol (b, at);
106 SCM text = me->get_grob_property ("text");
107 SCM properties = scm_list_n (me->mutable_property_alist_, me->immutable_property_alist_,SCM_UNDEFINED);
108 Molecule num = Text_item::text2molecule (me, text, properties);
110 mol.add_at_edge (X_AXIS, LEFT, num, - num.extent (X_AXIS).length ()
112 mol.translate_axis (left, X_AXIS);
113 return mol.smobbed_copy ();
118 Volta_spanner::add_bar (Grob *me, Item* b)
120 Pointer_group_interface::add_grob (me, ly_symbol2scm ("bars"), b);
121 Side_position_interface::add_support (me,b);
122 add_bound_item (dynamic_cast<Spanner*> (me), b);
126 Volta_spanner::add_column (Grob*me, Grob* c)
128 Side_position_interface::add_support (me,c);