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 "lookup.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)
{
- spanning_l_arr_.push (b);
- add_dependency (b);
-}
+ Pointer_group_interface gi (this);
+ gi.add_element (b);
-void
-Span_bar::do_substitute_element_pointer (Score_element*o, Score_element*n)
-{
- spanning_l_arr_.unordered_substitute (o, n);
+ add_dependency (b);
}
Interval
-Span_bar::do_width () const
+Span_bar::width_callback (Score_element const *se, Axis )
{
- Molecule m = lookup_l ()->bar (type_str_, 40 PT);
+ Span_bar* s= dynamic_cast<Span_bar*> ((Score_element*)se);
+ String gl = ly_scm2string (s->get_elt_property ("glyph"));
+
+ /*
+ urg.
+ */
+ Molecule m = s->compound_barline (gl, 40 PT);
return m.extent (X_AXIS);
}
-void
-Span_bar::do_pre_processing ()
+GLUE_SCORE_ELEMENT(Span_bar,before_line_breaking);
+SCM
+Span_bar::member_before_line_breaking ()
{
- Bar::do_pre_processing ();
+ Bar::member_before_line_breaking ();
evaluate_empty ();
-
- dim_cache_[Y_AXIS]->set_empty (false); // a hack to make mark scripts work.
+
+ return SCM_UNDEFINED;
}
-void
-Span_bar::do_post_processing ()
+GLUE_SCORE_ELEMENT(Span_bar,after_line_breaking);
+SCM
+Span_bar::member_after_line_breaking ()
{
- Bar::do_post_processing ();
+ Interval i (get_spanned_interval ());
+
+ /*
+ Bar::brew_molecule delivers a barline of y-extent (-h/2,h/2), so
+ we have to translate ourselves to be in the center of the
+ interval that we span. */
+ translate_axis (i.center (), Y_AXIS);
+ return SCM_UNDEFINED;
}
void
Span_bar::evaluate_empty ()
{
- if (spanning_l_arr_.size () < 1)
- {
- set_elt_property (transparent_scm_sym, SCM_BOOL_T);
- set_empty (true);
- }
- if (type_str_.empty_b ())
- {
- set_elt_property (transparent_scm_sym, SCM_BOOL_T);
- set_empty (true);
- }
- else if (type_str_ == "|:")
+ if (!gh_pair_p (get_elt_pointer ("elements")))
{
- type_str_ = ".|";
+ suicide ();
}
- else if (type_str_ == ":|")
- {
- type_str_ = "|.";
- }
- else if (type_str_ == ":|:")
+
+ SCM gl = get_elt_property ("glyph");
+ if (!gh_string_p (gl))
{
- type_str_ = ".|.";
+ suicide ();
+ return ;
}
+ else {
+ String type_str = ly_scm2string (gl);
+ String orig = type_str;
+ if (type_str == "|:")
+ {
+ type_str= ".|";
+ }
+ else if (type_str== ":|")
+ {
+ type_str= "|.";
+ }
+ else if (type_str== ":|:")
+ {
+ type_str= ".|.";
+ }
+ if (orig != type_str)
+ set_elt_property ("glyph", ly_str02scm (type_str.ch_C()));
+ }
}
Interval
Span_bar::get_spanned_interval () const
{
- Interval y_int;
- for (int i=0; i < spanning_l_arr_.size (); i++)
- {
- Dimension_cache*common =
- common_group (spanning_l_arr_[i], Y_AXIS);
-
- Real y = spanning_l_arr_[i]->dim_cache_[Y_AXIS]->relative_coordinate (common)
- -dim_cache_[Y_AXIS]->relative_coordinate (common);
-
- y_int.unite (y + spanning_l_arr_[i]->extent(Y_AXIS));
- }
- return y_int;
+ return Axis_group_interface::group_extent_callback (this, Y_AXIS);
}
-Interval
-Span_bar::do_height () const
-{
- return 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;
- if (!iv.empty_b())
- {
- output->add_molecule (lookup_l ()->bar (type_str_, iv.length ()));
- output->translate_axis (iv.center (), Y_AXIS);
- }
- 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 ()
+Span_bar::Span_bar (SCM s)
+ : Bar (s)
{
- type_str_ = "";
+ Pointer_group_interface(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);
}
+