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"));
27 Item copy ctor. Copy nothing: everything should be a elt property
28 or a special purpose pointer (such as broken_to_drul_[]) */
29 Item::Item (Item
const &s
)
32 broken_to_drul_
[LEFT
] = broken_to_drul_
[RIGHT
] =0;
37 Item::breakable_b (Grob
*me
)
42 if (!dynamic_cast<Item
*> (me
))
43 me
->programming_error ("only items can be breakable.");
45 Item
* i
=dynamic_cast<Item
*> (me
->get_parent (X_AXIS
));
46 return (i
) ? Item::breakable_b (i
) : to_boolean (me
->get_grob_property ("breakable"));
50 Item::get_column () const
52 Item
*parent
= dynamic_cast<Item
*> (get_parent (X_AXIS
));
53 return parent
? parent
->get_column () : 0;
57 Item::get_system () const
59 Grob
*g
= get_parent (X_AXIS
);
60 return g
? g
->get_system () : 0;
65 Item::copy_breakable_items ()
67 Drul_array
<Item
*> new_copies
;
71 Grob
* dolly
= clone ();
72 Item
* item
= dynamic_cast<Item
*> (dolly
);
73 pscore_
->system_
->typeset_grob (item
);
76 while (flip (&i
) != LEFT
);
77 broken_to_drul_
= new_copies
;
82 Item::broken_b () const
84 return broken_to_drul_
[LEFT
] || broken_to_drul_
[RIGHT
];
89 Generate items for begin and end-of line.
92 Item::discretionary_processing ()
97 if (Item::breakable_b (this))
98 copy_breakable_items ();
102 Item::find_broken_piece (System
*l
) const
104 if (get_system () == l
)
105 return (Item
*) (this);
109 Grob
*s
= broken_to_drul_
[d
];
110 if (s
&& s
->get_system () == l
)
113 while (flip (&d
) != LEFT
);
120 Item::find_prebroken_piece (Direction d
) const
122 Item
* me
= (Item
*) (this);
125 return dynamic_cast<Item
*> (broken_to_drul_
[d
]);
130 Item::break_status_dir () const
134 Item
* i
= dynamic_cast<Item
*> (original_
);
136 return (i
->broken_to_drul_
[LEFT
] == this) ? LEFT
: RIGHT
;
143 Item::handle_prebroken_dependencies ()
145 Grob::handle_prebroken_dependencies ();
148 Can't do this earlier, because try_visibility_lambda () might set
149 the elt property transparent, which would then be copied.
153 give the item to break-visibility itself, so the function can do
154 more complicated things.
156 SCM vis
= get_grob_property ("break-visibility");
157 if (gh_procedure_p (vis
))
159 SCM args
= scm_list_n (gh_int2scm (break_status_dir ()), SCM_UNDEFINED
);
160 SCM result
= gh_apply (vis
, args
);
161 bool trans
= gh_scm2bool (ly_car (result
));
162 bool empty
= gh_scm2bool (ly_cdr (result
));
168 set_extent (SCM_EOL
, X_AXIS
);
169 set_extent (SCM_EOL
, Y_AXIS
);
172 set_grob_property ("molecule-callback", SCM_EOL
);
177 Item::do_derived_mark ()const
179 if (broken_to_drul_
[LEFT
])
180 scm_gc_mark (broken_to_drul_
[LEFT
]->self_scm ());
181 if (broken_to_drul_
[RIGHT
])
182 scm_gc_mark (broken_to_drul_
[RIGHT
]->self_scm ());
189 return dynamic_cast<Item
*> (unsmob_grob (s
));
198 Grobs can be distinguished in their role in the horizontal spacing.
199 Many grobs define constraints on the spacing by their sizes. For
200 example, note heads, clefs, stems, and all other symbols with a fixed
201 shape. These grobs form a subtype called @code{Item}.
204 "no-spacing-rods break-visibility breakable")