]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.0.65
authorfred <fred>
Sun, 24 Mar 2002 19:44:25 +0000 (19:44 +0000)
committerfred <fred>
Sun, 24 Mar 2002 19:44:25 +0000 (19:44 +0000)
lily/include/collision.hh
lily/include/rest-collision.hh
lily/include/script-column.hh
lily/include/stem.hh
lily/script-column.cc
lily/stem.cc

index 9f28738e21b7652208e56e2c55a6da7a1fee57bc..be8d6bd506d05b6e3242f49cde47cf4dffbad917 100644 (file)
@@ -1,7 +1,7 @@
 /*
   collision.hh -- declare Collision
 
-  source file of the LilyPond music typesetter
+  source file of the GNU LilyPond music typesetter
 
   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
 */
 */
 class Collision : public Item {
 protected:
+    virtual void do_substitute_dependency(Score_elem*,Score_elem*);
     virtual void do_pre_processing();
 public:
-    Array<Note_column*> clash_l_arr_;
+    Link_array<Note_column> clash_l_arr_;
     NAME_MEMBERS(Collision);
     void add (Note_column*ncol_l);
     Collision();
index 31a1c8504ba7401b2ed0d4747571250b997a47d4..d470e4178e265bdbfdbb0c0d7a2d37b933a95732 100644 (file)
@@ -1,7 +1,7 @@
 /*
   rest-collision.hh -- declare Rest_collision
 
-  source file of the LilyPond music typesetter
+  source file of the GNU LilyPond music typesetter
 
   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
 */
 #include "item.hh"
 
 class Rest_collision : public Item {
-    Array<Rest_column *> rest_l_arr_;
-    Array<Note_column *> ncol_l_arr_;
+    Link_array<Rest_column> rest_l_arr_;
+    Link_array<Note_column> ncol_l_arr_;
 public:
     void add(Rest_column*);
     void add(Collision*);
     NAME_MEMBERS(Rest_collision);
 protected:
     virtual void do_post_processing();
+    virtual void do_substitute_dependency(Score_elem*,Score_elem*);
 };
 #endif // REST_COLLISION_HH
index f6adf9ffcbe6c20a6200c129c6688aa516afa3ef..22564d480524dab4153aab693a616d945650f3e3 100644 (file)
@@ -1,7 +1,7 @@
 /*
   script-column.hh -- declare Script_column
 
-  source file of the LilyPond music typesetter
+  source file of the GNU LilyPond music typesetter
 
   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
 */
 #ifndef SCRIPT_COLUMN_HH
 #define SCRIPT_COLUMN_HH
 
+#include "elem-group.hh"
 #include "item.hh"
 
 /** a struct for treating a group of noteheads (noteheads, stem
   (chord) and scripts ) as a single entity.  */
-class Script_column : public Item {
+class Script_column : public Item, public Element_group {
+
 protected:
-    virtual Interval do_height()const;
-    virtual Interval do_width()const;
-    virtual void do_print() const ;
-    virtual void do_pre_processing();
+    virtual void do_print() const;
+    virtual void do_substitute_dependency(Score_elem*, Score_elem*);
+    virtual void do_pre_processing() ;
 public:
-    Array<Script *> script_l_arr_;
-    Array<Item *> support_l_arr_;
-    
+    Link_array<Script> script_l_arr_;
+    Link_array<Item> support_l_arr_;
     NAME_MEMBERS(Script_column);
-    virtual void translate(Offset);
+   
     void add(Script *);
     void add_support(Item*);
 };
index 9cabdcd2a0e087f248c7e28ac5a7e034398b1e98..dad7e1660fbf8b2b53cac21f52590f5e002e23f9 100644 (file)
@@ -43,9 +43,9 @@ class Stem : public Item {
     /**
       store the wholes (for vapourware tremolo)
      */
-    Array<Notehead*> whole_l_arr_;
-    Array<Notehead*> head_l_arr_;
-    Array<Notehead*> rest_l_arr_;
+    Link_array<Note_head> whole_l_arr_;
+    Link_array<Note_head> head_l_arr_;
+    Link_array<Note_head> rest_l_arr_;
     
 public:
     /// flagtype? 4 none, 8 8th flag, 0 = beam.
@@ -64,7 +64,7 @@ public:
     Stem(int staff_size_i);
     
     /// ensure that this Stem also encompasses the Notehead #n#
-    void add(Notehead*n);
+    void add(Note_head*n);
 
     NAME_MEMBERS(Stem);
 
@@ -73,6 +73,7 @@ public:
     void do_print() const;
     void set_stemend(Real);
     int get_default_dir();
+    int get_center_distance();
     void set_default_dir();
     void set_default_stemlen();
     void set_default_extents();
@@ -83,12 +84,14 @@ public:
     Real stem_start_f() const;
 
     bool invisible_b()const;
+    bool chord_b()const;
     
     /// heads that the stem encompasses (positions)
     int max_head_i() const;
     int min_head_i() const;
 protected:
-    void do_pre_processing();
+    virtual void do_substitute_dependency(Score_elem*,Score_elem*);
+    virtual void do_pre_processing();
     virtual Interval do_width() const;
     Molecule* brew_molecule_p() const;
 };
index 637eb42dec6cf1ac5ce27ea4b6149f187788b09f..f2e21bd2fbc2ce43a579b0514ac44f23f43fab05 100644 (file)
@@ -1,7 +1,7 @@
 /*
   script-column.cc -- implement Script_column
 
-  source file of the LilyPond music typesetter
+  source file of the GNU LilyPond music typesetter
 
   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
 */
@@ -9,7 +9,7 @@
 #include "script-column.hh"
 #include "debug.hh"
 #include "script.hh"
-#include "notehead.hh"
+#include "note-head.hh"
 #include "stem.hh"
 
 IMPLEMENT_STATIC_NAME(Script_column);
@@ -19,16 +19,7 @@ void
 Script_column::add(Script*s_l)
 {
     script_l_arr_.push(s_l);
-    add_dependency(s_l);
-}
-
-void
-Script_column::translate(Offset o)
-{
-    for (int i=0; i < script_l_arr_.size(); i++) 
-       script_l_arr_[i]->translate(o);
-    for (int i=0; i < support_l_arr_.size(); i++)
-       support_l_arr_[i]->translate(o);
+    add_element(s_l);
 }
 
 
@@ -38,21 +29,6 @@ Script_column::do_print()const
     mtor << "scripts: " << script_l_arr_.size() << '\n'; 
 }
 
-Interval
-Script_column::do_height()const return r
-{
-    for (int i=0; i < script_l_arr_.size(); i++) 
-       r.unite(script_l_arr_[i]->height());
-}
-
-Interval
-Script_column::do_width()const 
-{
-    Interval r;
-    for (int i=0; i < script_l_arr_.size(); i++) 
-       r.unite(script_l_arr_[i]->width());
-    return r;
-}
 
 void
 Script_column::do_pre_processing()
@@ -104,5 +80,15 @@ void
 Script_column::add_support(Item*i_l)
 {
     support_l_arr_.push(i_l);
-    add_dependency(i_l);
+    add_element(i_l);
+}
+
+void
+Script_column::do_substitute_dependency(Score_elem*o,Score_elem*n)
+{
+    Element_group::do_substitute_dependency(o,n);
+    if (o->item()) {
+       script_l_arr_.substitute((Script*)o->item(),(Script*) (n?n->item():0));
+       support_l_arr_.substitute(o->item(), (n?n->item():0));
+    }
 }
index 7c57aa80e676fda64572c1ca0812c036fac0e4ae..33e86f657c8fbb50edc0369fab8be9dfe3513d19 100644 (file)
@@ -2,7 +2,7 @@
 #include "dimen.hh" 
 #include "debug.hh"
 #include "paper-def.hh"
-#include "notehead.hh"
+#include "note-head.hh"
 #include "lookup.hh"
 #include "molecule.hh"
 #include "p-col.hh"
@@ -73,6 +73,7 @@ Stem::stem_end_f() const
     return (dir_i_ < 0)? stem_bottom_f_ : stem_top_f_;
 }
 
+
 void
 Stem::set_stemend(Real se)
 {
@@ -86,7 +87,7 @@ Stem::set_stemend(Real se)
 }
 
 void
-Stem::add(Notehead *n)
+Stem::add(Note_head *n)
 {
     n->add_dependency(this);
     if (n->rest_b_) {
@@ -104,17 +105,35 @@ Stem::invisible_b()const
 {
     return !head_l_arr_.size();
 }
+bool
+Stem::chord_b() const
+{
+    return head_l_arr_.size() > 1;
+}
+
+// if dir_i_ is set we return a fake value.
+
+int
+Stem::get_center_distance()
+{
+    if (dir_i_)
+      return -dir_i_;
+
+    int staff_center = staff_size_i_ / 2;
+    int min = min_head_i() - staff_center;
+    int max = max_head_i() - staff_center;
+    return (abs(max) > abs(min)) ? max : min;
+}
 
 int
 Stem::get_default_dir()
 {
-    int staff_center = staff_size_i_ /2;
     if (dir_i_)
-       return dir_i_;
-    Real mean = (min_head_i() + max_head_i())/2;
-    return (mean > staff_center) ? -1: 1;
+        return dir_i_;
+    return -sign(get_center_distance());
 }
 
+
 void
 Stem::set_default_dir()
 {
@@ -159,7 +178,7 @@ Stem::set_noteheads()
 {
     if(!head_l_arr_.size())
        return;
-    head_l_arr_.sort(Notehead::compare);
+    head_l_arr_.sort(Note_head::compare);
     head_l_arr_[0]->extremal_i_ = -1;
     head_l_arr_.top()->extremal_i_ = 1;
     int parity=1;
@@ -212,7 +231,7 @@ Stem::brew_molecule_p()const
  
     Paper_def *p =paper();
 
-    Real dy = p->internote();
+    Real dy = p->internote_f();
     Symbol ss =p->lookup_l()->stem(bot*dy,top*dy);
 
     out = new Molecule(Atom(ss));
@@ -239,3 +258,12 @@ Stem::hpos_f()const
 }
 
 
+void
+Stem::do_substitute_dependency(Score_elem*o,Score_elem*n)
+{
+    Item * o_l = o->item();
+    Item * n_l = n? n->item():0;
+    whole_l_arr_.substitute((Note_head*)o_l, (Note_head*)n_l);
+    head_l_arr_.substitute((Note_head*)o_l, (Note_head*)n_l);
+    rest_l_arr_.substitute((Note_head*)o_l, (Note_head*)n_l);
+}