]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/grob.cc
release: 1.5.10
[lilypond.git] / lily / grob.cc
index 98f0601722fb5589381a9d97f49786b65e524633..c5cfcbe1747fd0c5b98138fbf7390ca3b71feb39 100644 (file)
@@ -49,39 +49,47 @@ Grob::Grob (SCM basicprops)
    */
 
   pscore_l_=0;
-  status_i_ = 0;
+  status_c_ = 0;
   original_l_ = 0;
   immutable_property_alist_ =  basicprops;
   mutable_property_alist_ = SCM_EOL;
 
   smobify_self ();
 
+  /*
+    TODO:
+
+    destill this into a function, so we can re-init the immutable
+    properties with a new BASICPROPS value after creation. Convenient
+    eg. when using \override with StaffSymbol.  */
+  
   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_grob_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_grob_property (enames[a]);
-
-    /*
-      Should change default to be empty? 
-     */
-    if (cb != SCM_BOOL_F && !gh_procedure_p (cb) && !gh_pair_p (cb))
-      cb = molecule_extent_proc;
+  for (int a = X_AXIS; a <= Y_AXIS; a++)
+    {
+      SCM l = get_grob_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_grob_property (enames[a]);
+
+      /*
+       Should change default to be empty? 
+      */
+      if (cb != SCM_BOOL_F && !gh_procedure_p (cb) && !gh_pair_p (cb))
+       cb = molecule_extent_proc;
     
-    dim_cache_[a].dimension_ = cb;
-  }
+      dim_cache_[a].dimension_ = cb;
+    }
 
   SCM meta = get_grob_property ("meta");
   SCM ifs = scm_assoc (ly_symbol2scm ("interfaces"), meta);
@@ -97,7 +105,7 @@ Grob::Grob (Grob const&s)
   immutable_property_alist_ = s.immutable_property_alist_;
   mutable_property_alist_ = SCM_EOL;
   
-  status_i_ = s.status_i_;
+  status_c_ = s.status_c_;
   pscore_l_ = s.pscore_l_;
 
   smobify_self ();
@@ -222,18 +230,16 @@ Grob::paper_l ()  const
 void
 Grob::calculate_dependencies (int final, int busy, SCM funcname)
 {
-  assert (status_i_ >=0);
-
-  if (status_i_ >= final)
+  if (status_c_ >= final)
     return;
 
-  if (status_i_== busy)
+  if (status_c_== busy)
     {
       programming_error ("Element is busy, come back later");
       return;
     }
   
-  status_i_= busy;
+  status_c_= busy;
 
   for (SCM d=  get_grob_property ("dependencies"); gh_pair_p (d); d = gh_cdr (d))
     {
@@ -247,7 +253,7 @@ Grob::calculate_dependencies (int final, int busy, SCM funcname)
   if (gh_procedure_p (proc))
     gh_call1 (proc, this->self_scm ());
   
-  status_i_= final;
+  status_c_= final;
 
 }
 
@@ -295,8 +301,6 @@ Grob::get_uncached_molecule ()const
 
       m = unsmob_molecule (mol);
     }
-
-
   
   /*
     transparent retains dimensions of element.
@@ -347,9 +351,11 @@ Grob::add_dependency (Grob*e)
       Do break substitution in S, using CRITERION. Return new value.
       CRITERION is either a SMOB pointer to the desired line, or a number
       representing the break direction. Do not modify SRC.
+
+      It is rather tightly coded, since it takes a lot of time.
 */
 SCM
-Grob::handle_broken_smobs (SCM src, SCM criterion)
+Grob::handle_broken_grobs (SCM src, SCM criterion)
 {
  again:
   Grob *sc = unsmob_grob (src);
@@ -395,7 +401,7 @@ Grob::handle_broken_smobs (SCM src, SCM criterion)
       /*
        UGH! breaks on circular lists.
       */
-      SCM newcar = handle_broken_smobs (oldcar, criterion);
+      SCM newcar = handle_broken_grobs (oldcar, criterion);
       SCM oldcdr = gh_cdr (src);
       
       if (newcar == SCM_UNDEFINED
@@ -404,7 +410,7 @@ Grob::handle_broken_smobs (SCM src, SCM criterion)
          /*
            This is tail-recursion, ie. 
            
-           return handle_broken_smobs (cdr, criterion);
+           return handle_broken_grobs (cdr, criterion);
 
            We don't want to rely on the compiler to do this.  Without
            tail-recursion, this easily crashes with a stack overflow.  */
@@ -412,7 +418,7 @@ Grob::handle_broken_smobs (SCM src, SCM criterion)
          goto again;
        }
 
-      SCM newcdr = handle_broken_smobs (oldcdr, criterion);
+      SCM newcdr = handle_broken_grobs (oldcdr, criterion);
       return gh_cons (newcar, newcdr);
     }
   else
@@ -435,7 +441,7 @@ Grob::handle_broken_dependencies ()
          Grob * sc = s->broken_into_l_arr_[i];
          Line_of_score * l = sc->line_l ();
          sc->mutable_property_alist_ =
-           handle_broken_smobs (mutable_property_alist_,
+           handle_broken_grobs (mutable_property_alist_,
                                 l ? l->self_scm () : SCM_UNDEFINED);
        }
     }
@@ -446,12 +452,12 @@ Grob::handle_broken_dependencies ()
   if (line && common_refpoint (line, X_AXIS) && common_refpoint (line, Y_AXIS))
     {
       mutable_property_alist_
-       = handle_broken_smobs (mutable_property_alist_,
+       = handle_broken_grobs (mutable_property_alist_,
                               line ? line->self_scm () : SCM_UNDEFINED);
     }
   else if (dynamic_cast <Line_of_score*> (this))
     {
-      mutable_property_alist_ = handle_broken_smobs (mutable_property_alist_,
+      mutable_property_alist_ = handle_broken_grobs (mutable_property_alist_,
                                            SCM_UNDEFINED);
     }
   else
@@ -868,9 +874,12 @@ init_functions ()
 {
   interfaces_sym = scm_permanent_object (ly_symbol2scm ("interfaces"));
 
-  scm_make_gsubr ("ly-get-grob-property", 2, 0, 0, (Scheme_function_unknown)ly_get_grob_property);
-  scm_make_gsubr ("ly-set-grob-property", 3, 0, 0, (Scheme_function_unknown)ly_set_grob_property);
-  scm_make_gsubr ("ly-get-spanner-bound", 2 , 0, 0, (Scheme_function_unknown) spanner_get_bound);
+  scm_c_define_gsubr ("ly-get-grob-property", 2, 0, 0,
+                     (Scheme_function_unknown)ly_get_grob_property);
+  scm_c_define_gsubr ("ly-set-grob-property", 3, 0, 0,
+                     (Scheme_function_unknown)ly_set_grob_property);
+  scm_c_define_gsubr ("ly-get-spanner-bound", 2 , 0, 0,
+                     (Scheme_function_unknown) spanner_get_bound);
 }
 
 bool