2 item.cc -- implement Item
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "dimension-cache.hh"
10 #include "paper-score.hh"
13 #include "paper-column.hh"
15 #include "lily-guile.hh"
19 broken_to_drul_
[LEFT
] = broken_to_drul_
[RIGHT
]=0;
23 Item::breakable_b () const
28 Item
* i
=dynamic_cast<Item
*> (parent_l (X_AXIS
));
29 return (i
) ? i
->breakable_b () : to_boolean (get_elt_property( "breakable"));
35 return relative_coordinate (0, X_AXIS
);
41 Score_element
*g
= parent_l (X_AXIS
);
44 return dynamic_cast<Score_element
*> (g
)-> line_l ();
49 Item::copy_breakable_items()
51 Drul_array
<Item
*> new_copies
;
55 Score_element
* dolly
= clone();
56 Item
* item_p
= dynamic_cast<Item
*>(dolly
);
57 pscore_l_
->typeset_element (item_p
);
58 new_copies
[i
] =item_p
;
60 while (flip(&i
) != LEFT
);
61 broken_to_drul_
= new_copies
;
65 broken_to_drul_
[i
]->handle_prebroken_dependencies();
66 broken_to_drul_
[i
]->try_visibility_lambda();
68 while (flip(&i
) != LEFT
);
72 Item::try_visibility_lambda ()
74 SCM vis
= remove_elt_property ("visibility-lambda");
75 if (gh_procedure_p (vis
))
77 SCM args
= scm_listify (gh_int2scm (break_status_dir ()), SCM_UNDEFINED
);
78 SCM result
= gh_apply (vis
, args
);
79 bool trans
= gh_scm2bool (gh_car (result
));
80 bool empty
= gh_scm2bool (gh_cdr (result
));
88 set_elt_property ("transparent", SCM_BOOL_T
);
93 Item::broken_b () const
95 return broken_to_drul_
[LEFT
] || broken_to_drul_
[RIGHT
];
106 copy_breakable_items();
107 handle_prebroken_dependencies();
110 Otherwise the broken items won't be pre_process()'ed.
113 if (broken_to_drul_
[LEFT
])
115 add_dependency (broken_to_drul_
[LEFT
]);
116 add_dependency (broken_to_drul_
[RIGHT
]);
119 try_visibility_lambda (); // ugh.
123 Item::do_breakable_col_processing()
129 Item::find_broken_piece (Line_of_score
*l
) const
132 return (Item
*)(this);
136 Score_element
*s
= find_broken_piece (d
);
137 if (s
&& s
->line_l () == l
)
140 while (flip (&d
) != LEFT
);
146 Item::find_broken_piece (Direction d
) const
148 Item
* me
= (Item
*) (this);
151 else if (breakable_b ())
154 return dynamic_cast<Item
*> (broken_to_drul_
[d
]);
161 Item::column_l () const
163 return dynamic_cast<Item
*> (parent_l (X_AXIS
))->column_l ();
166 Item::Item (Item
const &s
)
169 broken_to_drul_
[LEFT
] = broken_to_drul_
[RIGHT
] =0;
173 Item::break_status_dir () const
177 Item
* i
= dynamic_cast<Item
*> (original_l_
);
179 return (i
->broken_to_drul_
[LEFT
] == this) ? LEFT
: RIGHT
;