]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/bar-engraver.cc
release: 1.3.18
[lilypond.git] / lily / bar-engraver.cc
index 84ada321e8157fb34bfb7e00f882fe9ace962f5a..45636011c048182d9a6a30caeb9e3c49f678c9be 100644 (file)
@@ -6,13 +6,14 @@
   (c)  1997, 1998, 1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
   Jan Nieuwenhuizen <janneke@gnu.org>
 */
+
 #include "score-engraver.hh"
 #include "bar-engraver.hh"
 #include "staff-bar.hh"
 #include "musical-request.hh"
 #include "multi-measure-rest.hh"
 #include "command-request.hh"
-#include "time-description.hh"
+#include "timing-engraver.hh"
 #include "engraver-group-engraver.hh"
 #include "warn.hh"
 
@@ -22,20 +23,6 @@ Bar_engraver::Bar_engraver()
   do_post_move_processing();
 }
 
-bool
-Bar_engraver::do_try_music (Music*r_l)
-{
-  if (Bar_req  * b= dynamic_cast <Bar_req *> (r_l))
-    {
-      if (bar_req_l_ && bar_req_l_->equal_b (b)) // huh?
-       return false;
-      
-      bar_req_l_ = b;
-      return true;
-    }
-  
-  return false;
-}
 
 
 
@@ -45,30 +32,26 @@ Bar_engraver::create_bar ()
   if (!bar_p_)
     {
       bar_p_ = new Staff_bar;
-      bar_p_->set_elt_property (break_priority_scm_sym, gh_int2scm (0));
+      bar_p_->set_elt_property ("break-aligned", SCM_BOOL_T);
 
       // urg: "" != empty...
-      String default_type = get_property ("defaultBarType", 0);
-      if (default_type.length_i ())
+      SCM default_type = get_property ("defaultBarType", 0);
+      if (gh_string_p (default_type))
        {
-         bar_p_->type_str_ = default_type;
+         bar_p_->set_elt_property ("glyph", default_type); // gu.h
        }
 
+#if 0
       /*
-       urg.  Why did I implement this?
-       */
-      Scalar prop = get_property ("barAtLineStart", 0);
-      if (prop.to_bool ())
+       urg.  Why did I implement this? And did I implement this so
+       clumsily?  */
+      SCM prop = get_property ("barAtLineStart", 0);
+      if (to_boolean (prop))
        {
-         bar_p_->set_elt_property (at_line_start_scm_sym, SCM_BOOL_T);
+         bar_p_->set_elt_property ("at-line-start", SCM_BOOL_T);
        }
-      prop = get_property ("barSize", 0);
-      if (prop.isnum_b ())
-       {
-         bar_p_->set_elt_property (bar_size_scm_sym, 
-                                   gh_double2scm (Real(prop)));
-       }
-      announce_element (Score_element_info (bar_p_, bar_req_l_));
+#endif
+      announce_element (Score_element_info (bar_p_, 0));
     }
 }
 
@@ -80,11 +63,10 @@ Bar_engraver::create_bar ()
 void
 Bar_engraver::request_bar (String requested_type)
 {
-  Scalar prop = get_property ("barAtLineStart", 0);
   if (!now_mom ())
     {
-      Scalar prop = get_property ("barAtLineStart", 0);
-      if (!prop.to_bool ())
+      SCM prop = get_property ("barAtLineStart", 0);
+      if (!to_boolean (prop))
        return;
     }
   bool  bar_existed = bar_p_;
@@ -93,18 +75,21 @@ Bar_engraver::request_bar (String requested_type)
     {
       return;
     }
-  else if (((requested_type == "|:") && (bar_p_->type_str_ == ":|"))
-    || ((requested_type == ":|") && (bar_p_->type_str_ == "|:")))
-    bar_p_->type_str_ = ":|:";
-  else
-    bar_p_->type_str_ = requested_type;
+
+  String current = ly_scm2string (bar_p_->get_elt_property ("glyph"));
+  
+  if ((requested_type == "|:" && current== ":|")
+    || (requested_type == ":|" && current == "|:"))
+    requested_type = ":|:";
+
+  
+  bar_p_->set_elt_property ("glyph",
+                           ly_str02scm (requested_type.ch_C ()));
 }
 
 void 
 Bar_engraver::do_creation_processing ()
 {
-  create_bar ();
-  bar_p_->type_str_ = "";
 }
 
 void
@@ -120,26 +105,15 @@ Bar_engraver::do_removal_processing ()
 void
 Bar_engraver::do_process_requests()
 {  
-  Time_description const *time = get_staff_info().time_C_;
-  if (bar_req_l_) 
-    {
-      create_bar ();    
-      bar_p_->type_str_ = bar_req_l_->type_str_;
-    }
-  else if (!now_mom ())
-    {
-      create_bar ();
-      bar_p_->type_str_ = "|";
-    }
-  else 
+  Translator * t = daddy_grav_l  ()->get_simple_translator ("Timing_engraver");
+
+  Timing_engraver * te = dynamic_cast<Timing_engraver*>(t);
+  String which = (te) ? te->which_bar () : "";
+
+  if (which.length_i ())
     {
-      Scalar nonauto = get_property ("barNonAuto", 0);
-      if (!nonauto.to_bool ())
-       {
-         Scalar always = get_property ("barAlways", 0);
-         if ((time && !time->whole_in_measure_) || always.to_bool ())
-           create_bar ();
-       }
+      create_bar();
+      bar_p_->set_elt_property ("glyph",  ly_str02scm (which.ch_C ()));
     }
   
   if (!bar_p_)
@@ -169,14 +143,7 @@ Bar_engraver::do_pre_move_processing()
     }
 }
 
-void
-Bar_engraver::do_post_move_processing()
-{
-  bar_req_l_ = 0;
-}
-
-
-
 ADD_THIS_TRANSLATOR(Bar_engraver);
 
 
+