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 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 mutable_property_alist_
149 = handle_broken_grobs(original_l_->mutable_property_alist_,
150 gh_int2scm (break_status_dir ()));
154 Can't do this earlier, because try_visibility_lambda () might set
155 the elt property transparent, which would then be copied.
159 handle visibility-lambda the item itself iso. breakstatusdir, so
160 the function can do more complicated things.
163 SCM vis = get_grob_property ("visibility-lambda");
164 if (gh_procedure_p (vis))
166 SCM args = scm_list_n (gh_int2scm (break_status_dir ()), SCM_UNDEFINED);
167 SCM result = gh_apply (vis, args);
168 bool trans = gh_scm2bool (ly_car (result));
169 bool empty = gh_scm2bool (ly_cdr (result));
175 set_extent (SCM_EOL, X_AXIS);
176 set_extent (SCM_EOL, Y_AXIS);
179 set_grob_property ("molecule-callback", SCM_EOL);
184 Item::do_derived_mark ()
186 if (broken_to_drul_[LEFT])
187 scm_gc_mark (broken_to_drul_[LEFT]->self_scm ());
188 if (broken_to_drul_[RIGHT])
189 scm_gc_mark (broken_to_drul_[RIGHT]->self_scm ());
196 return dynamic_cast<Item*> (unsmob_grob (s));
204 "no-spacing-rods visibility-lambda breakable")