2 item.cc -- implement Item
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
14 #include "lily-guile.hh"
18 broken_to_drul_[LEFT] = broken_to_drul_[RIGHT]=0;
22 Item::breakable_b () const
27 Item * i =dynamic_cast<Item*> (parent_l (X_AXIS));
28 return (i) ? i->breakable_b () : get_elt_property( breakable_scm_sym) != SCM_BOOL_F;
32 Item::do_print() const
40 return absolute_coordinate (X_AXIS);
46 Graphical_element *g = parent_l (X_AXIS);
49 return dynamic_cast<Score_element *> (g)-> line_l ();
54 Item::copy_breakable_items()
56 if (broken_to_drul_[LEFT] || broken_to_drul_[RIGHT]
60 Drul_array<Item *> new_copies;
64 Score_element * dolly = clone();
65 Item * item_p = dynamic_cast<Item*>(dolly);
66 pscore_l_->typeset_element (item_p);
67 new_copies[i] =item_p;
69 while (flip(&i) != LEFT);
70 broken_to_drul_= new_copies;
74 broken_to_drul_[i]->handle_prebroken_dependencies();
75 broken_to_drul_[i]->try_visibility_lambda();
77 while (flip(&i) != LEFT);
78 try_visibility_lambda ();
82 Item::try_visibility_lambda ()
84 SCM vis = remove_elt_property (visibility_lambda_scm_sym);
85 if (vis != SCM_BOOL_F)
87 SCM args = scm_listify (gh_int2scm (break_status_dir ()), SCM_UNDEFINED);
88 SCM result = gh_apply ( SCM_CDR(vis), args);
89 int trans = gh_scm2bool (gh_car (result));
90 int empty = gh_scm2bool (gh_cdr (result));
95 set_elt_property (transparent_scm_sym, SCM_BOOL_T);
102 copy_breakable_items();
103 handle_prebroken_dependencies();
106 Otherwise the broken items won't be pre_process()'ed.
108 add_dependency (broken_to_drul_[LEFT]);
109 add_dependency (broken_to_drul_[RIGHT]);
113 Item::do_breakable_col_processing()
120 Item::find_prebroken_piece (Line_of_score*l) const
123 return (Item*)(this);
124 else if (broken_to_drul_[LEFT] && broken_to_drul_[LEFT]->line_l() == l)
125 return broken_to_drul_[LEFT];
126 else if (broken_to_drul_[RIGHT] && broken_to_drul_[RIGHT]->line_l() == l)
127 return broken_to_drul_[RIGHT];
133 Item::find_prebroken_piece (Direction d) const
136 return (Item *) (this); // ugh
138 return dynamic_cast<Item*> (broken_to_drul_[d]);
142 Item::handle_prebroken_dependencies()
145 Score_element::handle_prebroken_dependencies();
149 Item::broken_original_b () const
151 return broken_to_drul_[LEFT] || broken_to_drul_[RIGHT];
155 Item::left_right_compare(Item const *l, Item const *r)
157 Paper_column *p1 = l->column_l ();
158 Paper_column* p2 = r->column_l ();
159 return p1->rank_i () - p2->rank_i ();
163 Item::column_l () const
165 return dynamic_cast<Item*> (parent_l (X_AXIS))->column_l ();
168 Item::Item (Item const &s)
171 broken_to_drul_[LEFT] = broken_to_drul_[RIGHT] =0;
176 Item::handle_prebroken_dependents ()
178 Item * parent = dynamic_cast<Item*> (parent_l (X_AXIS));
179 if (breakable_b () && parent)
181 if(!(broken_to_drul_[LEFT] || broken_to_drul_[RIGHT]))
187 Item * broken_self = find_prebroken_piece (d);
188 Item * broken_parent = parent->find_prebroken_piece (d);
190 broken_self->dim_cache_[X_AXIS].parent_l_ =
191 &broken_parent->dim_cache_[X_AXIS];
194 ugh. Should do this is after breaking?
196 if (!broken_self->parent_l (Y_AXIS))
198 Score_element * yparent =dynamic_cast<Score_element*>(parent_l (Y_AXIS));
199 Item *yparenti = dynamic_cast<Item*> (yparent);
200 Item *broken_yparent = yparenti ?
201 yparenti->find_prebroken_piece (d) : 0;
204 programming_error ("Vertical refpoint lost!");
207 broken_self->dim_cache_[Y_AXIS].parent_l_ =
208 &broken_yparent->dim_cache_[Y_AXIS];
212 while ((flip (&d))!=LEFT);
217 Item::break_status_dir () const
221 Item * i = dynamic_cast<Item*> (original_l_);
223 return (i->broken_to_drul_[LEFT] == this) ? LEFT : RIGHT;