#include "paper-def.hh"
#include "molecule.hh"
#include "warn.hh"
+#include "axis-group-interface.hh"
#include "group-interface.hh"
-
void
Span_bar::add_bar (Score_element*b)
{
- Group_interface gi (this);
+ Pointer_group_interface gi (this);
gi.add_element (b);
add_dependency (b);
Interval
-Span_bar::width_callback (Dimension_cache const * c)
+Span_bar::width_callback (Score_element const *se, Axis )
{
- 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"));
- /*urg.
+ /*
+ urg.
*/
Molecule m = s->compound_barline (gl, 40 PT);
return m.extent (X_AXIS);
}
-void
-Span_bar::before_line_breaking ()
+GLUE_SCORE_ELEMENT(Span_bar,before_line_breaking);
+SCM
+Span_bar::member_before_line_breaking ()
{
- Bar::before_line_breaking ();
+ Bar::member_before_line_breaking ();
evaluate_empty ();
-
- // set_empty (false, Y_AXIS); // a hack to make mark scripts work.
+
+ return SCM_UNDEFINED;
}
-void
-Span_bar::after_line_breaking ()
+GLUE_SCORE_ELEMENT(Span_bar,after_line_breaking);
+SCM
+Span_bar::member_after_line_breaking ()
{
- Bar::after_line_breaking ();
- SCM s = get_elt_property ("collapse-height");
- if (gh_number_p (s)
- && get_spanned_interval ().length () < gh_scm2double (s))
- {
- set_elt_property ("transparent", SCM_BOOL_T);
- set_empty (X_AXIS);
- set_empty (Y_AXIS);
- }
-
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 (!gh_pair_p (get_elt_property ("elements")))
- {
- set_elt_property ("transparent", SCM_BOOL_T);
- set_empty (X_AXIS);
- set_empty (Y_AXIS);
- }
+ if (!gh_pair_p (get_elt_pointer ("elements")))
+ {
+ suicide ();
+ }
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);
+ 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= ".|.";
- }
+ {
+ 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()));
}
-
- /*
- uhh. should do something with type_str ?!!
- */
}
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 ();
-}
Real
Span_bar::get_bar_size () const
{
- Interval iv (get_spanned_interval ());
- if (iv.empty_b ())
- {
- programming_error("Huh? My children deflated (FIXME)");
- iv = Interval (0,0);
- }
- return iv.length ();
+ Interval iv (get_spanned_interval ());
+ if (iv.empty_b ())
+ {
+ programming_error("Huh? My children deflated (FIXME)");
+ iv = Interval (0,0);
+ }
+ return iv.length ();
}
-Span_bar::Span_bar ()
+Span_bar::Span_bar (SCM s)
+ : Bar (s)
{
- group (this).set_interface ();
- dim_cache_[X_AXIS]->set_extent_callback (width_callback);
- dim_cache_[Y_AXIS]->set_extent_callback (height_callback);
+ 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);
}