source file of the GNU LilyPond music typesetter
- (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "dimension-cache.hh"
#include "span-bar.hh"
#include "dimensions.hh"
#include "paper-def.hh"
#include "molecule.hh"
-#include "align-element.hh"
#include "warn.hh"
+#include "axis-group-interface.hh"
#include "group-interface.hh"
-
void
Span_bar::add_bar (Score_element*b)
{
Interval
-Span_bar::width_callback (Dimension_cache const * c)
+Span_bar::width_callback (Score_element const *se, Axis a)
{
- Span_bar* s= dynamic_cast<Span_bar*> (c->element_l ());
+ Span_bar* s= dynamic_cast<Span_bar*> ((Score_element*)se);
String gl = ly_scm2string (s->get_elt_property ("glyph"));
-
- Molecule m = s->lookup_l ()->bar (gl, 40 PT, s->paper_l ());
+
+ /*
+ urg.
+ */
+ Molecule m = s->compound_barline (gl, 40 PT);
return m.extent (X_AXIS);
}
void
-Span_bar::do_pre_processing ()
+Span_bar::before_line_breaking ()
{
- Bar::do_pre_processing ();
+ Bar::before_line_breaking ();
evaluate_empty ();
-
- // set_empty (false, Y_AXIS); // a hack to make mark scripts work.
}
void
-Span_bar::do_post_processing ()
+Span_bar::after_line_breaking ()
{
- Bar::do_post_processing ();
- Interval i(get_spanned_interval ());
-
+ Bar::after_line_breaking ();
+ Interval i (get_spanned_interval ());
translate_axis (i.center (), Y_AXIS);
}
void
Span_bar::evaluate_empty ()
{
- if (!gh_pair_p (get_elt_property ("elements")))
+ if (!gh_pair_p (get_elt_property ("elements")))
{
set_elt_property ("transparent", SCM_BOOL_T);
- set_empty (X_AXIS);
- set_empty (Y_AXIS);
+ set_extent_callback (0, X_AXIS);
+ set_extent_callback (0, Y_AXIS);
}
-
+
SCM gl = get_elt_property ("glyph");
if (!gh_string_p (gl))
{
set_elt_property ("transparent", SCM_BOOL_T);
- set_empty (X_AXIS);
- set_empty (Y_AXIS);
+ set_extent_callback (0, X_AXIS);
+ set_extent_callback (0, Y_AXIS);
}
else {
String type_str = ly_scm2string (gl);
if (type_str == "|:")
- {
- type_str= ".|";
- }
- else if (type_str== ":|")
- {
- type_str= "|.";
- }
- else if (type_str== ":|:")
- {
- type_str= ".|.";
- }
+ {
+ type_str= ".|";
+ }
+ else if (type_str== ":|")
+ {
+ type_str= "|.";
+ }
+ else if (type_str== ":|:")
+ {
+ type_str= ".|.";
+ }
+
+ set_elt_property ("glyph", ly_str02scm (type_str.ch_C()));
}
}
Interval
Span_bar::get_spanned_interval () const
{
- Interval y_int;
-
- for (SCM s = get_elt_property ("elements"); gh_pair_p (s); s = gh_cdr (s))
- {
- Score_element *bar = unsmob_element ( gh_car (s));
-
- if (!bar)
- continue;
-
- Score_element*common = common_refpoint (bar, Y_AXIS);
-
- Interval iv (bar->extent(Y_AXIS));
- if (!iv.empty_b ())
- {
- Real y = bar->relative_coordinate (common, Y_AXIS)
- - relative_coordinate (common, Y_AXIS);
-
- y_int.unite (y + iv);
- }
- }
- return y_int;
+ return Axis_group_interface::group_extent_callback (this, Y_AXIS);
}
-Interval
-Span_bar::height_callback (Dimension_cache const *c)
-{
- Span_bar * s= dynamic_cast<Span_bar*> (c->element_l ());
- return s->get_spanned_interval ();
-}
-Molecule*
-Span_bar::do_brew_molecule_p () const
+Real
+Span_bar::get_bar_size () const
{
Interval iv (get_spanned_interval ());
- Molecule*output = new Molecule;
- SCM s = get_elt_property ("glyph");
- if (gh_string_p (s) && !iv.empty_b())
- {
- output->add_molecule (lookup_l ()->bar (ly_scm2string (s),
- iv.length (),
- paper_l ()));
- }
- else
+ if (iv.empty_b ())
{
programming_error("Huh? My children deflated (FIXME)");
+ iv = Interval (0,0);
}
- return output;
+ return iv.length ();
}
-
-
Span_bar::Span_bar ()
{
- dim_cache_[X_AXIS]->set_callback (width_callback);
- dim_cache_[Y_AXIS]->set_callback (height_callback);
+ group (this).set_interface ();
+ set_extent_callback (width_callback, X_AXIS);
+
+ // dim_cache_[Y_AXIS]->set_extent_callback (Axis_group_interface::group_extent_callback);
+
+ set_extent_callback (0, Y_AXIS);
}