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>
10 #include "paper-score.hh"
13 #include "paper-column.hh"
15 #include "lily-guile.hh"
16 #include "line-of-score.hh"
21 broken_to_drul_
[LEFT
] = broken_to_drul_
[RIGHT
]=0;
25 Item copy ctor. Copy nothing: everything should be a elt property
26 or a special purpose pointer (such as broken_to_drul_[]) */
27 Item::Item (Item
const &s
)
30 broken_to_drul_
[LEFT
] = broken_to_drul_
[RIGHT
] =0;
35 Item::breakable_b (Score_element
*me
)
40 if (!dynamic_cast<Item
*>(me
))
41 programming_error ("only items can be breakable.");
43 Item
* i
=dynamic_cast<Item
*> (me
->parent_l (X_AXIS
));
44 return (i
) ? Item::breakable_b (i
) : to_boolean (me
->get_elt_property ("breakable"));
48 Item::column_l () const
50 return dynamic_cast<Item
*> (parent_l (X_AXIS
))->column_l ();
56 Score_element
*g
= parent_l (X_AXIS
);
57 return g
? g
->line_l () : 0;
62 Item::copy_breakable_items()
64 Drul_array
<Item
*> new_copies
;
68 Score_element
* dolly
= clone();
69 Item
* item_p
= dynamic_cast<Item
*>(dolly
);
70 pscore_l_
->line_l_
->typeset_element (item_p
);
71 new_copies
[i
] =item_p
;
73 while (flip(&i
) != LEFT
);
74 broken_to_drul_
= new_copies
;
79 Item::broken_b () const
81 return broken_to_drul_
[LEFT
] || broken_to_drul_
[RIGHT
];
86 Generate items for begin and end-of line.
89 Item::discretionary_processing()
94 if (Item::breakable_b (this))
95 copy_breakable_items();
99 Item::find_broken_piece (Line_of_score
*l
) const
102 return (Item
*)(this);
106 Score_element
*s
= broken_to_drul_
[d
];
107 if (s
&& s
->line_l () == l
)
110 while (flip (&d
) != LEFT
);
117 Item::find_prebroken_piece (Direction d
) const
119 Item
* me
= (Item
*) (this);
122 return dynamic_cast<Item
*> (broken_to_drul_
[d
]);
127 Item::break_status_dir () const
131 Item
* i
= dynamic_cast<Item
*> (original_l_
);
133 return (i
->broken_to_drul_
[LEFT
] == this) ? LEFT
: RIGHT
;
140 Item::handle_prebroken_dependencies ()
144 mutable_property_alist_
145 = handle_broken_smobs (original_l_
->mutable_property_alist_
,
146 gh_int2scm (break_status_dir ()));
150 Can't do this earlier, because try_visibility_lambda () might set
151 the elt property transparent, which would then be copied.
153 SCM vis
= get_elt_property ("visibility-lambda");
154 if (gh_procedure_p (vis
))
156 SCM args
= scm_listify (gh_int2scm (break_status_dir ()), SCM_UNDEFINED
);
157 SCM result
= gh_apply (vis
, args
);
158 bool trans
= gh_scm2bool (gh_car (result
));
159 bool empty
= gh_scm2bool (gh_cdr (result
));
165 set_extent_callback (0, X_AXIS
);
166 set_extent_callback (0, Y_AXIS
);
169 set_elt_property ("molecule-callback", SCM_BOOL_T
);