]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/axis-group-element.cc
patch::: 1.3.18.jcn3
[lilypond.git] / lily / axis-group-element.cc
index cd6000b464156d2b5ce33bb6fe81fd6279ff6d6e..081b42a22faee300ad1e5c6ac66dc0771df5fe8d 100644 (file)
@@ -7,27 +7,21 @@
 */
 
 #include "axis-group-element.hh"
-#include "graphical-axis-group.hh"
-
-
+#include "dimension-cache.hh"
+#include "group-interface.hh"
 
 Link_array<Score_element>
 Axis_group_element::get_extra_dependencies() const
 {
-  return elem_l_arr ();
+  Link_array<Score_element> e(elem_l_arr ());
+  return e;
 }
 
 Link_array<Score_element>
 Axis_group_element::elem_l_arr () const
 {  
-  /*
-    ugh. I know
-  */
-  Link_array<Score_element> r;
-  for (int i=0; i < elem_l_arr_.size (); i++)
-    r.push (dynamic_cast<Score_element*>(elem_l_arr_[i]));
-      
-  return r;
+  return
+    Group_interface__extract_elements (this, (Score_element*)0, "elements");
 }
 
 Link_array<Score_element> 
@@ -35,6 +29,7 @@ Axis_group_element::get_children ()
 {
   Link_array<Score_element> childs;
   Link_array<Score_element> elems = elem_l_arr ();
+
   for (int i=0; i < elems.size (); i++) 
     {
       Score_element* e = elems[i];
@@ -47,46 +42,64 @@ Axis_group_element::get_children ()
   return childs;
 }
 
-void
-Axis_group_element::do_print() const
-{
-  Graphical_axis_group::do_print();
-}
-
 Axis_group_element::Axis_group_element()
 {
-  set_elt_property (transparent_scm_sym, SCM_BOOL_T);
-}
+  axes_[0] = (Axis)-1 ; 
+  axes_[1] = (Axis)-1 ;
 
-void
-Axis_group_element::set_axes (Axis a1, Axis a2)
-{
-  Graphical_axis_group::set_axes (a1,a2);
-  dim_cache_[X_AXIS].set_empty ((a1 != X_AXIS && a2 != X_AXIS));
-  dim_cache_[Y_AXIS].set_empty ((a1 != Y_AXIS && a2 != Y_AXIS));
+  set_elt_property ("elements", SCM_EOL);
+  set_elt_property ("transparent", SCM_BOOL_T);
 }
 
-
 void
-Axis_group_element::do_substitute_element_pointer (Score_element*o,
-                                                  Score_element*n)
+Axis_group_element::set_axes (Axis a1, Axis a2)
 {
-  int i;
-  while ((i = elem_l_arr_.find_i (o))>=0) 
-    if (n) 
-      elem_l_arr_[i] = n;
-    else
-      elem_l_arr_.del (i);
+  axes_[0] = a1 ; 
+  axes_[1] = a2 ;
+  if (a1 != X_AXIS && a2 != X_AXIS)
+    set_empty (X_AXIS);
+  if (a1 != Y_AXIS && a2 != Y_AXIS)
+    set_empty (Y_AXIS);
+  
+  dim_cache_[a1]->set_callback(extent_callback);
+  dim_cache_[a2]->set_callback (extent_callback);
 }
 
 Interval
-Axis_group_element::do_height () const
+Axis_group_element::extent_callback (Dimension_cache const *c) 
 {
-  return Graphical_axis_group::extent (Y_AXIS);
+  Axis a = c->axis ();
+  Axis_group_element * me
+    = dynamic_cast<Axis_group_element*> (c->element_l ()); 
+
+  Interval r;
+  for (SCM s = me->get_elt_property ("elements"); gh_pair_p (s); s = gh_cdr (s))
+    {
+      SCM e=gh_car (s); 
+      Score_element * se = SMOB_TO_TYPE (Score_element, e);
+
+      Interval dims = se->extent (a);
+      if (!dims.empty_b ())
+       r.unite (dims + se->relative_coordinate (me, a));
+    }
+
+  return r;
 }
 
-Interval
-Axis_group_element::do_width () const
+
+
+void
+Axis_group_element::add_element (Score_element *e)
 {
-  return Graphical_axis_group::extent (X_AXIS);
+  used_b_ =true;
+  e->used_b_ = true;
+  
+  for (int i = 0; i < 2; i++)
+    {
+      if (!e->parent_l (axes_[i]))
+       e->set_parent (this, axes_[i]);
+    }
+  Group_interface gi (this);
+  gi.add_element (e);
 }
+