]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.0.76
authorfred <fred>
Sun, 24 Mar 2002 19:48:27 +0000 (19:48 +0000)
committerfred <fred>
Sun, 24 Mar 2002 19:48:27 +0000 (19:48 +0000)
lily/include/score-elem.hh
lily/score-elem.cc
lily/span-bar.cc

index 4189057f54618bff45fafedf78ffc10953ba8a13..4bf3efd006213b6931ca3c2ca15542f6cec894ed 100644 (file)
@@ -54,7 +54,7 @@ class Score_elem : private Directed_graph_node {
        DELETED,                // to catch malloc mistakes.
     };
     
-    Status status;
+    Status status_;
 
 public:
     PScore *pscore_l_;    
@@ -74,6 +74,7 @@ public:
     Interval height() const;
     virtual void translate_x(Real);
     virtual void translate_y(Real);
+    Status status() const;
     
      /**
       translate the symbol. The symbol does not have to be created yet. 
@@ -92,6 +93,7 @@ public:
 
     void unlink();
     void unlink_all();
+    void substitute_dependency(Score_elem*,Score_elem*);
     void remove_dependency(Score_elem*);
     /**
       add a dependency. It may be the 0 pointer, in which case, it is ignored.
@@ -104,6 +106,15 @@ public:
     virtual Item * item() { return 0; }
     virtual Line_of_score * line_l() const;
     SCORE_ELEM_CLONE(Score_elem);
+    Score_elem* dependency(int) const;
+    Score_elem* dependent(int) const;
+    int dependent_size() const;
+    int dependency_size() const;
+    
+    /// no dimension, translation is noop
+    bool empty_b_;
+    /// do not print anything black
+    bool transparent_b_;
 protected:
 
     virtual  Interval do_height()const;
@@ -128,16 +139,8 @@ protected:
     virtual void handle_broken_dependencies();
     virtual void handle_prebroken_dependencies();
 
-    Score_elem* dependency(int) const;
-    Score_elem* dependent(int) const;
-    int dependent_size() const;
-    int dependency_size() const;
 
 
-    /// no dimension, translation is noop
-    bool empty_b_;
-    /// do not print anything black
-    bool transparent_b_;
 };
 
 
index 9a554a46efb0f4cc6d3845d002704f97a295c517..7f026d1e88452cf311d1b1a259d6a3f1abff44ba 100644 (file)
@@ -47,7 +47,7 @@ Score_elem::dependent_size() const
 String
 Score_elem::TeX_string() const
 {
-    assert( status > POSTCALCED);
+    assert( status_ > POSTCALCED);
     if (transparent_b_ )
        return "";
     String s( "\\placebox{%}{%}{%}");
@@ -79,7 +79,7 @@ Score_elem::Score_elem(Score_elem const&s)
     copy_edges_out(s);
     x_group_element_i_ = 0;
     y_group_element_i_ = 0;    
-    status = s.status;
+    status_ = s.status_;
     assert(!s.output);
     output = 0;
     pscore_l_ = s.pscore_l_;
@@ -89,9 +89,9 @@ Score_elem::Score_elem(Score_elem const&s)
 Score_elem::~Score_elem()
 {
     // some paranoia to prevent weird segv's
-    assert(status < DELETED);
+    assert(status_ < DELETED);
     delete output;
-    status = DELETED;
+    status_ = DELETED;
     output = 0;
     assert(!x_group_element_i_ && !y_group_element_i_);
 }
@@ -197,7 +197,7 @@ Score_elem::Score_elem()
     pscore_l_=0;
     offset_ = Offset(0,0);
     output = 0;
-    status = ORPHAN;
+    status_ = ORPHAN;
 }
 
 
@@ -211,61 +211,61 @@ Score_elem::paper()  const
 void
 Score_elem::add_processing()
 {
-    if (status >= VIRGIN)
+    if (status_ >= VIRGIN)
        return;
-    status = VIRGIN;
+    status_ = VIRGIN;
     do_add_processing();
 }
 
 void
 Score_elem::pre_processing()
 {
-    if (status >= PRECALCED )
+    if (status_ >= PRECALCED )
        return;
 
-    assert(status != PRECALCING); // cyclic dependency
-    status = PRECALCING;
+    assert(status_ != PRECALCING); // cyclic dependency
+    status_ = PRECALCING;
 
     for (int i=0; i < dependency_size(); i++)
        dependency(i)->pre_processing();
 
     
     do_pre_processing();
-    status = PRECALCED;
+    status_ = PRECALCED;
 }
 
 void
 Score_elem::breakable_col_processing()
 {
-    if (status >= PREBROKEN )
+    if (status_ >= PREBROKEN )
        return;
 
-    assert(status != PREBREAKING); // cyclic dependency
-    status = PREBREAKING;
+    assert(status_ != PREBREAKING); // cyclic dependency
+    status_ = PREBREAKING;
 
     for (int i=0; i < dependency_size(); i++)
        dependency(i)->breakable_col_processing();
 
     
     do_breakable_col_processing();
-    status = PREBROKEN;
+    status_ = PREBROKEN;
 }
 
 void
 Score_elem::break_processing()
 {
-    if (status >= BROKEN )
+    if (status_ >= BROKEN )
        return;
 
-    assert(status != BREAKING); // cyclic dependency
-    status = BREAKING;
+    assert(status_ != BREAKING); // cyclic dependency
+    status_ = BREAKING;
 
     for (int i=0; i < dependency_size(); i++)
        dependency(i)->break_processing();
 
     
     do_break_processing();
-    status = BROKEN;
+    status_ = BROKEN;
 }
 
 void
@@ -278,24 +278,30 @@ Score_elem::do_break_processing()
 void
 Score_elem::post_processing()
 {
-    if (status >= POSTCALCED)
+    if (status_ >= POSTCALCED)
        return;
-    assert(status != POSTCALCING);// cyclic dependency
-    status=POSTCALCING;        
+    assert(status_ != POSTCALCING);// cyclic dependency
+    status_=POSTCALCING;       
 
   
     for (int i=0; i < dependency_size(); i++)
        dependency(i)->post_processing();
     do_post_processing();
-    status=POSTCALCED;
+    status_=POSTCALCED;
+}
+
+Score_elem::Status
+Score_elem::status()const
+{
+    return status_;
 }
 
 void 
 Score_elem::molecule_processing()
 {
-    if (status >= OUTPUT)
+    if (status_ >= OUTPUT)
        return;
-    status = OUTPUT;           // do it only once.
+    status_ = OUTPUT;          // do it only once.
   
     for (int i=0; i < dependency_size(); i++)
        dependency(i)->molecule_processing();
@@ -333,7 +339,8 @@ Score_elem::do_substitute_dependency(Score_elem*,Score_elem*)
 }
 void
 Score_elem::do_substitute_dependent(Score_elem*,Score_elem*)
-{}
+{
+}
 
 
 IMPLEMENT_STATIC_NAME(Score_elem);
@@ -365,8 +372,7 @@ void
 Score_elem::remove_dependency(Score_elem*e)
 {
     remove_edge_out(e);
-    e->do_substitute_dependent(this, 0);
-    do_substitute_dependency(e, 0);
+    substitute_dependency(e, 0);
 }
 
 void
@@ -374,7 +380,12 @@ Score_elem::add_dependency(Score_elem*e)
 {
     Directed_graph_node::add(e);
 }
-
+void
+Score_elem::substitute_dependency(Score_elem* old, Score_elem* new_l)
+{
+    do_substitute_dependency(old,new_l);
+    old->do_substitute_dependent(this, 0);
+}
 
 void
 Score_elem::handle_broken_dependencies()
@@ -390,13 +401,13 @@ Score_elem::handle_broken_dependencies()
            if (elt->spanner()) {
                Spanner * sp = elt->spanner();
                Spanner * broken = sp->find_broken_piece(line);
-               do_substitute_dependency(sp, broken);
+               substitute_dependency(sp, broken);
 
                add_dependency(broken);
            } else if (elt->item() && elt->item()->pcol_l_->breakpoint_b()
                       && elt->item()->break_status_i() == 0) {
                Item * my_item = elt->item()->find_prebroken_piece(line);
-               do_substitute_dependency( elt, my_item);
+               substitute_dependency( elt, my_item);
                if (my_item)
                    add_dependency( my_item);
            }
@@ -412,8 +423,8 @@ Score_elem::handle_broken_dependencies()
 
     /* Reset this. If we are a (broken) copy of a spanner, then
       break_processing() was not called on us (and we are not breaking).  */
-    if (status < BROKEN)
-       status = BROKEN;
+    if (status_ < BROKEN)
+       status_ = BROKEN;
 }
 
 /*
@@ -460,8 +471,8 @@ Score_elem::handle_prebroken_dependencies()
     /*
       see comment at handle_broken_dependencies()
      */
-    if (status < PREBROKEN)
-       status = PREBROKEN;
+    if (status_ < PREBROKEN)
+       status_ = PREBROKEN;
 }
 
 
index eed9237f653b8bd93af9191c0f7a7e41b649588f..61f6b1b4e6816f986cd90658870fd9710e808f90 100644 (file)
@@ -6,7 +6,7 @@
   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
 */
 
-
+#include "dimen.hh"
 #include "span-bar.hh"
 #include "lookup.hh"
 #include "symbol.hh"
@@ -41,7 +41,16 @@ Span_bar::do_substitute_dependency(Score_elem*o, Score_elem*n)
     }
     
     spanning_l_arr_.substitute( bold , b);
+}
 
+/*
+  A no-op if not yet output: the span_bar slavish follows what it spans
+ */
+void
+Span_bar::translate_y(Real y)
+{
+    if (status() == OUTPUT)
+       Score_elem::translate_y(y);
 }
 
 void
@@ -51,6 +60,11 @@ Span_bar::set(Vertical_align_element *a)
 }
     
 
+Interval
+Span_bar::do_width() const
+{
+    return paper()->lookup_l()->bar(type_str_, 40 PT).dim.x; // ugh
+}
 void
 Span_bar::do_pre_processing()
 {
@@ -58,7 +72,8 @@ Span_bar::do_pre_processing()
        transparent_b_ = true;
        empty_b_ =true;
     } else {
-       type_str_ = spanning_l_arr_[0]->type_str_;
+       if  (type_str_ == "")
+           type_str_ = spanning_l_arr_[0]->type_str_;
        if (type_str_ =="") {
            transparent_b_=true;
            empty_b_ = true;
@@ -66,13 +81,19 @@ Span_bar::do_pre_processing()
     }
 }
 
+Symbol
+Span_bar::get_bar_sym(Real dy) const
+{
+    return paper()->lookup_l()->bar(type_str_, dy);
+}
+
 Molecule*
 Span_bar::brew_molecule_p()const
 {
     Interval y;
     for (int i=0; i < spanning_l_arr_.size(); i++)
        y.unite( spanning_l_arr_[i]->height() );
-    Symbol s = paper()->lookup_l()->bar(type_str_, y.length());
+    Symbol s = get_bar_sym(y.length());
         Molecule*output = new Molecule(Atom(s));
     output->translate_y (  y[-1] );