/*
fixme: default should be no callback.
*/
- set_extent_callback (molecule_extent_proc, X_AXIS);
- set_extent_callback (molecule_extent_proc, Y_AXIS) ;
pscore_l_=0;
lookup_l_ =0;
smobify_self ();
- dim_cache_[X_AXIS].offset_callbacks_
- = get_elt_property ("X-offset-callbacks");
- dim_cache_[Y_AXIS].offset_callbacks_
- = get_elt_property ("Y-offset-callbacks");
-
- dim_cache_[X_AXIS].offsets_left_ = scm_ilength (dim_cache_[X_AXIS].offset_callbacks_);
- dim_cache_[Y_AXIS].offsets_left_ = scm_ilength (dim_cache_[Y_AXIS].offset_callbacks_);
-
- SCM cb = get_elt_property ("X-extent-callback");
- if (cb != SCM_EOL)
- dim_cache_[X_AXIS].dimension_ = cb;
+ char const*onames[] = {"X-offset-callbacks", "Y-offset-callbacks"};
+ char const*enames[] = {"X-extent-callback", "Y-extent-callback"};
+
+ for (int a = X_AXIS; a <= Y_AXIS; a++){
+ SCM l = get_elt_property (onames[a]);
+
+ if (scm_ilength (l) >=0)
+ {
+ dim_cache_[a].offset_callbacks_ = l;
+ dim_cache_[a].offsets_left_ = scm_ilength (l);
+ }
+ else
+ {
+ programming_error ("[XY]-offset-callbacks must be a list");
+ }
+
+ SCM cb = get_elt_property (enames[a]);
+
+ /*
+ Should change default to be empty?
+ */
+ if (!gh_procedure_p (cb) && !gh_pair_p (cb))
+ cb = molecule_extent_proc;
+
+ dim_cache_[a].dimension_ = cb;
+ }
- cb = get_elt_property ("Y-extent-callback");
- if (cb != SCM_EOL)
- dim_cache_[Y_AXIS].dimension_ = cb;
+ SCM meta = get_elt_property ("meta");
+ SCM ifs = scm_assoc (ly_symbol2scm ("interfaces"), meta);
+
+ set_elt_property ("interfaces",gh_cdr (ifs));
}
{
if (e)
{
- Pointer_group_interface gi (this, "dependencies");
- gi.add_element (e);
+ Pointer_group_interface ::add_element (this, "dependencies",e);
+
}
else
programming_error ("Null dependency added");
gh_procedure_p (dim_cache_[a].dimension_ ));
}
+/*
+ TODO: add
+
+ Score_element *refpoint
+
+ to arguments?
+ */
Interval
-Score_element::extent (Axis a) const
+Score_element::extent (Score_element * refp, Axis a) const
{
+ Real x = relative_coordinate (refp, a);
+
+
Dimension_cache * d = (Dimension_cache *)&dim_cache_[a];
Interval ext ;
if (gh_pair_p (d->dimension_))
else
return ext;
+ if (!gh_pair_p (d->dimension_))
+ return ext;
+
ext = ly_scm2interval (d->dimension_);
SCM extra = get_elt_property (a == X_AXIS
ext.unite (Interval (s * gh_scm2double (gh_car (extra)),
s * gh_scm2double (gh_cdr (extra))));
}
+
+ ext.translate (x);
return ext;
}
String
Score_element::name () const
{
- SCM nm = get_elt_property ("name");
-
- return nm == SCM_EOL ? classname (this) :ly_scm2string (nm) ;
+ SCM meta = get_elt_property ("meta");
+ SCM nm = scm_assoc (ly_symbol2scm ("name"), meta);
+ nm = (gh_pair_p (nm)) ? gh_cdr (nm) : SCM_EOL;
+ return gh_string_p (nm) ?ly_scm2string (nm) : classname (this);
}
void
init_functions ()
{
interfaces_sym = scm_permanent_object (ly_symbol2scm ("interfaces"));
-
+
scm_make_gsubr ("ly-get-elt-property", 2, 0, 0, (Scheme_function_unknown)ly_get_elt_property);
scm_make_gsubr ("ly-set-elt-property", 3, 0, 0, (Scheme_function_unknown)ly_set_elt_property);
scm_make_gsubr ("ly-get-spanner-bound", 2 , 0, 0, (Scheme_function_unknown) spanner_get_bound);
ADD_SCM_INIT_FUNC(scoreelt, init_functions);
-
+IMPLEMENT_TYPE_P(Score_element, "ly-element?");