2 item.cc -- implement Item
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "paper-score.hh"
13 #include "paper-column.hh"
15 #include "lily-guile.hh"
17 #include "group-interface.hh"
22 broken_to_drul_[LEFT] = broken_to_drul_[RIGHT]=0;
23 Group_interface::add_thing (this, ly_symbol2scm ("interfaces"), ly_symbol2scm ("item-interface"));
28 Item copy ctor. Copy nothing: everything should be a elt property
29 or a special purpose pointer (such as broken_to_drul_[]) */
30 Item::Item (Item const &s)
33 broken_to_drul_[LEFT] = broken_to_drul_[RIGHT] =0;
38 Item::breakable_b (Grob*me)
43 if (!dynamic_cast<Item*> (me))
44 me->programming_error ("only items can be breakable.");
46 Item * i =dynamic_cast<Item*> (me->get_parent (X_AXIS));
47 return (i) ? Item::breakable_b (i) : to_boolean (me->get_grob_property ("breakable"));
51 Item::column_l () const
53 Item *parent = dynamic_cast<Item*> (get_parent (X_AXIS));
54 return parent ? parent->column_l () : 0;
60 Grob *g = get_parent (X_AXIS);
61 return g ? g->line_l () : 0;
66 Item::copy_breakable_items ()
68 Drul_array<Item *> new_copies;
72 Grob * dolly = clone ();
73 Item * item_p = dynamic_cast<Item*> (dolly);
74 pscore_l_->line_l_->typeset_grob (item_p);
75 new_copies[i] =item_p;
77 while (flip (&i) != LEFT);
78 broken_to_drul_= new_copies;
83 Item::broken_b () const
85 return broken_to_drul_[LEFT] || broken_to_drul_[RIGHT];
90 Generate items for begin and end-of line.
93 Item::discretionary_processing ()
98 if (Item::breakable_b (this))
99 copy_breakable_items ();
103 Item::find_broken_piece (System*l) const
106 return (Item*) (this);
110 Grob *s = broken_to_drul_[d];
111 if (s && s->line_l () == l)
114 while (flip (&d) != LEFT);
121 Item::find_prebroken_piece (Direction d) const
123 Item * me = (Item *) (this);
126 return dynamic_cast<Item*> (broken_to_drul_[d]);
131 Item::break_status_dir () const
135 Item * i = dynamic_cast<Item*> (original_l_);
137 return (i->broken_to_drul_[LEFT] == this) ? LEFT : RIGHT;
144 Item::handle_prebroken_dependencies ()
148 set_break_subsititution (gh_int2scm (break_status_dir ()));
149 mutable_property_alist_ = substitute_mutable_properties(original_l_->mutable_property_alist_);
153 Can't do this earlier, because try_visibility_lambda () might set
154 the elt property transparent, which would then be copied.
158 handle break-visibility the item itself iso. breakstatusdir, so
159 the function can do more complicated things.
161 SCM vis = get_grob_property ("break-visibility");
162 if (gh_procedure_p (vis))
164 SCM args = scm_list_n (gh_int2scm (break_status_dir ()), SCM_UNDEFINED);
165 SCM result = gh_apply (vis, args);
166 bool trans = gh_scm2bool (ly_car (result));
167 bool empty = gh_scm2bool (ly_cdr (result));
173 set_extent (SCM_EOL, X_AXIS);
174 set_extent (SCM_EOL, Y_AXIS);
177 set_grob_property ("molecule-callback", SCM_EOL);
182 Item::do_derived_mark ()
184 if (broken_to_drul_[LEFT])
185 scm_gc_mark (broken_to_drul_[LEFT]->self_scm ());
186 if (broken_to_drul_[RIGHT])
187 scm_gc_mark (broken_to_drul_[RIGHT]->self_scm ());
194 return dynamic_cast<Item*> (unsmob_grob (s));
203 Grobs can also be distinguished in their role in the horizontal spacing.
204 Many grobs define constraints on the spacing by their sizes. For
205 example, note heads, clefs, stems, and all other symbols with a fixed
206 shape. These grobs form a subtype called @code{Item}.
209 "no-spacing-rods break-visibility breakable")