2 plet-spanner.cc -- implement Tuplet_spanner
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1999 Jan Nieuwenhuizen <janneke@gnu.org>
13 #include "molecule.hh"
14 #include "paper-column.hh"
15 #include "paper-def.hh"
16 #include "tuplet-spanner.hh"
18 #include "note-column.hh"
19 #include "dimensions.hh"
20 #include "group-interface.hh"
21 #include "directional-element-interface.hh"
25 Tuplet_spanner::Tuplet_spanner ()
30 parallel_beam_b_ = false;
31 set_elt_property ("beams", SCM_EOL);
32 set_elt_property ("columns", SCM_EOL);
39 Tuplet_spanner::do_brew_molecule_p () const
41 Molecule* mol_p = new Molecule;
43 // Default behaviour: number always, bracket when no beam!
44 bool bracket_visibility = !parallel_beam_b_;
45 bool number_visibility = true;
46 SCM visibility_sym =get_elt_property ("tuplet-visibility");
47 if (visibility_sym != SCM_UNDEFINED)
56 2 show (number and bracket)-if-no-beam
57 3 show number, and bracket-if-no-beam
58 4 show number, and bracket
60 int value = gh_scm2int ((visibility_sym));
61 bracket_visibility = (value == 4 || (value > 1 && !parallel_beam_b_));
62 number_visibility = (value > 2 || value == 1 ||
63 (value == 2 && !parallel_beam_b_));
66 if (gh_pair_p (get_elt_property ("columns")))
68 Link_array<Note_column> column_arr=
69 Group_interface__extract_elements (this, (Note_column*)0, "columns");
71 Real ncw = column_arr.top ()->extent(X_AXIS).length ();
72 Real w = spanner_length () + ncw;
73 Molecule num (lookup_l ()->text ("italic",
74 number_str_, paper_l ()));
75 num.align_to (X_AXIS, CENTER);
76 num.translate_axis (w/2, X_AXIS);
77 Real interline = paper_l ()->get_var ("interline");
79 Direction dir = directional_element (this).get ();
80 Real dy = column_arr.top ()->extent (Y_AXIS) [dir]
81 - column_arr[0]->extent (Y_AXIS) [dir];
82 num.align_to (Y_AXIS, CENTER);
83 num.translate_axis (dir * interline, Y_AXIS);
85 num.translate_axis (dy/2, Y_AXIS);
87 Real thick = paper_l ()->get_var ("tuplet_thick");
88 if (bracket_visibility)
90 Real gap = paper_l () -> get_var ("tuplet_spanner_gap");
92 mol_p->add_molecule (lookup_l ()->tuplet_bracket (dy, w, thick, gap, interline, dir));
95 if (number_visibility)
97 mol_p->add_molecule (num);
99 mol_p->translate_axis (dir * interline, Y_AXIS);
105 Tuplet_spanner::do_add_processing ()
107 if (gh_pair_p (get_elt_property ("columns")))
109 Link_array<Note_column> column_arr=
110 Group_interface__extract_elements (this, (Note_column*)0, "columns");
112 set_bounds (LEFT, column_arr[0]);
113 set_bounds (RIGHT, column_arr.top ());
118 Tuplet_spanner::do_post_processing ()
120 Link_array<Note_column> column_arr=
121 Group_interface__extract_elements (this, (Note_column*)0, "columns");
124 Direction d = directional_element (this).get ();
128 directional_element (this).set (d);
131 if (column_arr.size())
132 translate_axis (column_arr[0]->extent (Y_AXIS)[d], Y_AXIS);
135 if (scm_ilength (get_elt_property ("beams")) == 1)
137 SCM bs = get_elt_property ("beams");
138 Score_element *b = unsmob_element (gh_car (bs));
139 Beam * beam_l = dynamic_cast<Beam*> (b);
141 && spanned_drul_[LEFT]->column_l () == beam_l->spanned_drul_[LEFT]->column_l ()
142 && spanned_drul_[RIGHT]->column_l () == beam_l->spanned_drul_[RIGHT]->column_l ())
143 parallel_beam_b_ = true;
149 Tuplet_spanner::get_default_dir () const
152 SCM dir_sym =get_elt_property ("dir-forced");
153 if (gh_number_p (dir_sym))
155 d= (Direction) gh_scm2int (dir_sym);
160 for (SCM s = get_elt_property ("columns"); gh_pair_p (s); s = gh_cdr (s))
162 Score_element * sc = unsmob_element (gh_car (s));
163 Note_column * nc = dynamic_cast<Note_column*> (sc);
175 Tuplet_spanner::add_beam (Beam *b)
178 Group_interface gi (this, "beams");
183 Tuplet_spanner::add_column (Note_column*n)
185 Group_interface gi (this, "columns");