2 volta-spanner.cc -- implement Volta_spanner
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1998 Jan Nieuwenhuizen <janneke@gnu.org>
13 #include "molecule.hh"
14 #include "note-column.hh"
15 #include "p-col.hh" // urg
18 #include "paper-def.hh"
19 #include "volta-spanner.hh"
21 #include "text-def.hh"
24 Hmm, should probably make generic Bracket_spanner,
25 or and derive Plet and volta spanner from that.
28 Volta_spanner::Volta_spanner ()
32 number_p_
.set_p (new Text_def
);
33 number_p_
->align_dir_
= LEFT
;
34 dot_p_
.set_p (new Text_def
);
35 dot_p_
->align_dir_
= LEFT
;
39 Volta_spanner::brew_molecule_p () const
41 Molecule
* mol_p
= new Molecule
;
43 if (column_arr_
.size ())
45 Real internote_f
= paper ()->internote_f ();
46 Real dx
= internote_f
;
47 Real w
= width ().length () - 2 * dx
;
48 Atom
volta (lookup_l ()->volta (w
, last_b_
));
49 Real h
= volta
.dim_
.y ().length ();
50 Atom
num (number_p_
->get_atom (paper (), LEFT
));
51 Atom
dot (dot_p_
->get_atom (paper (), LEFT
));
52 Real dy
= column_arr_
.top ()->extent (Y_AXIS
) [dir_
] >
53 column_arr_
[0]->extent (Y_AXIS
) [dir_
];
55 for (int i
= 0; i
< note_column_arr_
.size (); i
++)
56 dy
= dy
>? note_column_arr_
[i
]->height ().max ();
59 Real gap
= num
.dim_
.x ().length () / 2;
60 Offset
off (num
.dim_
.x ().length () + gap
,
61 (h
- num
.dim_
.y ().length ()) / internote_f
- gap
);
63 Real dotheight
= dot
.dim_
.y ().length () / 7;
64 off
-= Offset (0, dotheight
);
66 mol_p
->add_atom (volta
);
67 mol_p
->add_atom (num
);
68 mol_p
->add_atom (dot
);
69 mol_p
->translate (Offset (dx
, dy
));
75 Volta_spanner::do_add_processing ()
77 if (column_arr_
.size ())
79 set_bounds (LEFT
, column_arr_
[0]);
80 set_bounds (RIGHT
, column_arr_
.top ());
82 number_p_
->style_str_
= "number-1";
83 dot_p_
->text_str_
= ".";
84 dot_p_
->style_str_
= "bold";
88 Volta_spanner::do_post_processing ()
90 if (column_arr_
.size())
91 translate_axis (column_arr_
[0]->extent (Y_AXIS
)[dir_
], Y_AXIS
);
95 Volta_spanner::do_substitute_dependency (Score_element
* o
, Score_element
* n
)
97 if (Note_column
* c
= dynamic_cast <Note_column
*> (o
))
98 note_column_arr_
.substitute (c
, dynamic_cast<Note_column
*> (n
));
99 else if (Bar
* c
= dynamic_cast <Bar
*> (o
))
100 column_arr_
.substitute (c
, dynamic_cast<Bar
*> (n
));
104 Volta_spanner::add_column (Bar
* c
)
106 column_arr_
.push (c
);
111 Volta_spanner::add_column (Note_column
* c
)
113 note_column_arr_
.push (c
);