]> git.donarmstrong.com Git - lilypond.git/blob - lily/volta-spanner.cc
fa986542eb9c727925b439151af211440d34e2d3
[lilypond.git] / lily / volta-spanner.cc
1 /*
2   volta-spanner.cc -- implement Volta_spanner
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--2000 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
8
9
10 #include "box.hh"
11 #include "debug.hh"
12 #include "lookup.hh"
13 #include "molecule.hh"
14 #include "paper-column.hh"
15 #include "bar.hh"
16 #include "paper-def.hh"
17 #include "volta-spanner.hh"
18 #include "group-interface.hh"
19 #include "side-position-interface.hh"
20 #include "directional-element-interface.hh"
21
22
23 void
24 Volta_spanner::set_interface (Score_element*me)
25 {
26   me->set_elt_pointer ("bars", SCM_EOL);
27   Side_position_interface (me).set_axis (Y_AXIS);
28   Directional_element_interface (me).set (UP);
29 }
30
31
32 /*
33   me is too complicated. Yet another version of side-positioning,
34   badly implemented.
35
36   --
37
38   * Should look for system_start_delim to find left edge of staff.
39   
40   
41 */
42
43 MAKE_SCHEME_SCORE_ELEMENT_CALLBACK(Volta_spanner,brew_molecule);
44 SCM
45 Volta_spanner::brew_molecule (SCM smob) 
46 {
47   Score_element *me = unsmob_element (smob);
48   Link_array<Bar> bar_arr
49     = Pointer_group_interface__extract_elements (me, (Bar*)0, "bars");
50
51   if (!bar_arr.size ())
52     return SCM_EOL;
53
54   bool no_vertical_start = false;
55   bool no_vertical_end = to_boolean (me->get_elt_property ("last-volta"));
56   Spanner *orig_span =  dynamic_cast<Spanner*> (me->original_l_);
57   if (orig_span && (orig_span->broken_into_l_arr_[0] != (Spanner*)me))
58     no_vertical_start = true;
59   if (orig_span && (orig_span->broken_into_l_arr_.top () != (Spanner*)me))
60     no_vertical_end = true;
61
62 #if 0
63   // FIXME
64   if (bar_arr.top ()->me->get_elt_property (type_str_.length_i () > 1)
65     no_vertical_end = false;
66 #endif
67
68   Real staff_space = me->paper_l ()->get_var ("interline");
69   Real half_space = staff_space / 2;
70   Real left = dynamic_cast<Spanner*>(me)->get_broken_left_end_align ();
71   Real w = dynamic_cast<Spanner*>(me)->spanner_length () - left - half_space;
72   Real h = me->paper_l()->get_var ("volta_spanner_height");
73   Real t = me->paper_l ()->get_var ("volta_thick");
74
75   SCM at = (gh_list (ly_symbol2scm ("volta"),
76                      gh_double2scm (h),
77                      gh_double2scm (w),
78                      gh_double2scm (t),
79                      gh_int2scm (no_vertical_start),
80                      gh_int2scm (no_vertical_end),
81                      SCM_UNDEFINED));
82
83   Box b (Interval (0, w), Interval (0, h));
84   Molecule  mol (b, at);
85   Molecule num (me->lookup_l ()->text ("volta",
86                                        ly_scm2string (me->get_elt_property("text")),
87                                        me->paper_l ()));
88
89   mol.add_at_edge (X_AXIS, LEFT, num, - num.extent (X_AXIS).length ()
90                    - staff_space);
91   mol.translate_axis (left, X_AXIS);
92   return mol.create_scheme();
93 }
94
95
96 void
97 Volta_spanner::add_bar  (Score_element *me, Item* b)
98 {
99   Pointer_group_interface gi(me, "bars");
100   gi.add_element (b);
101
102   Side_position_interface (me).add_support (b);
103   add_bound_item (dynamic_cast<Spanner*>(me), b); 
104 }
105
106 void
107 Volta_spanner::add_column (Score_element*me, Score_element* c)
108 {
109   Side_position_interface (me).add_support (c);
110 }