]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.0.50
authorfred <fred>
Sun, 24 Mar 2002 19:39:04 +0000 (19:39 +0000)
committerfred <fred>
Sun, 24 Mar 2002 19:39:04 +0000 (19:39 +0000)
lily/include/staff-elem.hh
lily/include/staff-regs.hh
lily/note-column.cc [new file with mode: 0644]
lily/script-reg.cc
lily/staff-elem.cc
lily/staff-regs.cc
lily/text-item.cc

index a604385cff466692e07ef72887f8f503a3e6d0e8..c47cd024dc528709c0cf2f6a410cc216738c5447 100644 (file)
@@ -56,7 +56,12 @@ public:
     virtual ~Staff_elem();
     Staff_elem();
     NAME_MEMBERS(Staff_elem);    
-    void translate(Offset);
+
+    /**
+      translate the symbol. The symbol does not have to be created yet. 
+      Overridable, since this staff-elem might act as a pseudo-list.
+     */
+    virtual void translate(Offset);
     void add_processing();
     void pre_processing();
     void post_processing();
@@ -64,15 +69,19 @@ public:
     
     virtual Spanner* spanner()  { return 0; }
     virtual Item * item() { return 0; }
+    /**
+      add a dependency. It may be the 0 pointer, in which case, it is ignored.
+     */
     void add_dependency(Staff_elem* );    
     void substitute_dependency(Staff_elem* old, Staff_elem * newdep);
     
 protected:
-    
+    virtual  Interval do_height()const;
+    virtual Interval do_width()const;
     /// do printing of derived info.
-    virtual void do_print() const=0;
+    virtual void do_print() const {}
     /// generate the molecule    
-    virtual Molecule* brew_molecule_p()const=0;
+    virtual Molecule* brew_molecule_p()const;
     ///executed directly after the item is added to the PScore
     virtual void do_add_processing();
     /// do calculations before determining horizontal spacing
index 344659dff3e1c1307e0c9d0cf6a034c117c0aa70..88c41f89991dbb12d91adb46d05eea2299df495d 100644 (file)
@@ -20,7 +20,12 @@ class Staff_registers : public Register_group_register {
     Input_register const *ireg_C_;
     int base_position_i_;
     Array<Voice_group_registers*> group_l_arr_;
+    Staff_symbol * staff_sym_l_;
+protected:
+    virtual bool try_request(Request * r);
+    virtual Staff_info get_staff_info();
+    virtual bool acceptable_request_b(Request*) const ;
+    virtual void acknowledge_element(Staff_elem_info);
 public:
     
     /* *************** */
@@ -30,10 +35,7 @@ public:
                      Voice_group_registers * old_group);
     Voice_group_registers * get_group(String id);
     void terminate_register(Request_register * reg);
-    virtual bool try_request(Request * r);
-    virtual Staff_info get_staff_info();
     Staff_registers(Input_register const*);
-    virtual bool acceptable_request_b(Request*) const ;
 };
 
 #endif // STAFF_REGS_HH
diff --git a/lily/note-column.cc b/lily/note-column.cc
new file mode 100644 (file)
index 0000000..f71d61b
--- /dev/null
@@ -0,0 +1,135 @@
+/*
+  note-column.cc -- implement Note_column
+
+  source file of the LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+#include "note-column.hh"
+#include "debug.hh"
+#include "script.hh"
+#include "notehead.hh"
+#include "stem.hh"
+
+IMPLEMENT_STATIC_NAME(Note_column);
+
+
+void
+Note_column::add(Stem*stem_l)
+{
+    assert(!stem_l_);
+    stem_l_ = stem_l;
+    add_dependency(stem_l);
+}
+
+void
+Note_column::add(Notehead* n_l)
+{
+    head_l_arr_.push(n_l);
+    add_dependency(n_l);
+}
+
+void
+Note_column::add(Script*s_l)
+{
+    script_l_arr_.push(s_l);
+    add_dependency(s_l);
+}
+
+void
+Note_column::translate(Offset o)
+{
+    for (int i=0; i < head_l_arr_.size(); i++)
+       head_l_arr_[i]->translate(o);
+    for (int i=0; i < script_l_arr_.size(); i++) 
+       script_l_arr_[i]->translate(o);
+    if (stem_l_)
+       stem_l_->translate(o);
+}
+
+
+void
+Note_column::do_print()const
+{
+    mtor << "heads: " << head_l_arr_.size() << '\n'; 
+    mtor << "scripts: " << script_l_arr_.size() << '\n'; 
+}
+
+Interval
+Note_column::do_height()const return r
+{
+    if (stem_l_)
+        r.unite(stem_l_->height());
+    for (int i=0; i < head_l_arr_.size(); i++)
+       r.unite(head_l_arr_[i]->height());
+    for (int i=0; i < script_l_arr_.size(); i++) 
+       r.unite(script_l_arr_[i]->height());
+}
+
+Interval
+Note_column::do_width()const return r;
+{
+    if (stem_l_)
+        r.unite(stem_l_->width());
+    for (int i=0; i < head_l_arr_.size(); i++)
+       r.unite(head_l_arr_[i]->width());
+    for (int i=0; i < script_l_arr_.size(); i++) 
+       r.unite(script_l_arr_[i]->width());
+}
+
+void
+Note_column::do_pre_processing()
+{
+    if (!script_l_arr_.size()) 
+       return;
+
+    Array<Script*> placed_l_arr_a[4];
+    for (int i=0; i < script_l_arr_.size(); i++) {
+       Script*s_l = script_l_arr_[i];
+       int j = (s_l->dir_i_ >0) ? 0 : 2;
+       if (!s_l->inside_staff_b_) 
+           j ++;
+       
+       placed_l_arr_a[j].push(s_l);
+    }
+    for (int j =0; j <4; j++) {
+       placed_l_arr_a[j].sort( Script::compare);
+    }
+    
+    Notehead *top_head_l=0;
+    Notehead *bot_head_l=0;
+    for (int i=0; i< head_l_arr_.size(); i++) {
+       if (head_l_arr_[i]->extremal == -1)
+           bot_head_l = head_l_arr_[i];
+       else if (head_l_arr_[i]->extremal == 1)
+           top_head_l = head_l_arr_[i];
+    }
+    /* argh. This sux. */
+    if (!top_head_l) 
+       top_head_l = bot_head_l;
+    if (!bot_head_l) 
+       bot_head_l = top_head_l;
+    assert(bot_head_l && top_head_l);
+    Item *support_l=top_head_l;
+    int j;
+    for (j = 0; j < 2; j++ ) {
+       for (int i=0; i < placed_l_arr_a[j].size(); j++) {
+           placed_l_arr_a[j][i]->add_support(support_l);
+           support_l = placed_l_arr_a[j][i];
+       }
+    }
+    
+    support_l=bot_head_l;
+    for (; j < 4; j++ ) {
+       for (int i=0; i < placed_l_arr_a[j].size(); i++) {
+           placed_l_arr_a[j][i]->add_support(support_l);
+           support_l = placed_l_arr_a[j][i];
+       }
+    }
+}
+Note_column::Note_column()
+{
+    stem_l_ =0;
+}
+    
index cd7b0814297cfa106d81ea349397697fec6d75e8..5fd12bc9f6605303193c2d00542313e59a1697af 100644 (file)
@@ -9,10 +9,10 @@
 #include "musical-request.hh"
 #include "complex-walker.hh"
 #include "stem.hh"
+#include "staff-sym.hh"
 
 Script_register::Script_register()
 {
-    script_p_ = 0;
     post_move_processing();
 }
 
@@ -21,13 +21,12 @@ Script_register::try_request(Request *r_l)
 {
     if (!r_l->script())
        return false ;
-
-    if (script_req_l_
-       && Script_req::compare(*script_req_l_, *r_l->script()))
+    for (int i=0; i < script_req_l_arr_.size(); i++)
+       if ( !Script_req::compare(*script_req_l_arr_[i], *r_l->script())) {
+           return true;
+       }
        
-       return false;
-
-    script_req_l_ = r_l->script();
+    script_req_l_arr_.push( r_l->script());
     
     return true;
 }
@@ -35,44 +34,58 @@ Script_register::try_request(Request *r_l)
 void
 Script_register::process_requests()
 {
-    if (script_req_l_) {
-       script_p_ = new Script(script_req_l_, 10);
-       announce_element(
-           Staff_elem_info(script_p_, script_req_l_));
+    for (int i=0; i < script_req_l_arr_.size(); i++){
+       Script_req* l=script_req_l_arr_[i];
+       Script *p =new Script( l);
+       script_p_arr_.push(p);
+       announce_element(Staff_elem_info(p, l));
     }
 }
 
+bool
+Script_register::acceptable_elem_b(Staff_elem*s_l)
+{
+    char const *nC = s_l->name();
+    return (nC == Stem::static_name());
+}
+
 void
 Script_register::acknowledge_element(Staff_elem_info info)
 {
-    if (!script_p_)
+    Staff_elem *elem_l = info.elem_l_;
+    if (!acceptable_elem_b(elem_l))
        return;
-    if (info.elem_p_->name() == Stem::static_name())
-       script_p_->set_stem((Stem*)info.elem_p_);
-    else if (info.req_l_->rhythmic())
-       script_p_->set_support(info.elem_p_->item());
+    
+    for (int i=0; i < script_p_arr_.size(); i++) {
+       Script*script_l = script_p_arr_[i];
+       if (elem_l->name() == Stem::static_name())
+           script_l->set_stem((Stem*)elem_l);
+    }
 }
 
 void
 Script_register::pre_move_processing()
 {
-    if (script_p_){
-       script_p_->dir = dir_i_;
-       typeset_element(script_p_);
-       script_p_ = 0;
+    Staff_symbol* s_l = get_staff_info().staff_sym_l_;
+    for (int i=0; i < script_p_arr_.size(); i++) {
+       
+       Script*script_p = script_p_arr_[i];
+       script_p->set_staffsym( s_l);
+       typeset_element(script_p);
     }
+    script_p_arr_.set_size(0);
 }
 void
 Script_register::post_move_processing()
 {
-    script_req_l_ = 0;
+    script_req_l_arr_.set_size(0);
 }
 
 void
-Script_register::set_feature(Features i)
+Script_register::set_feature(Features )
 {
-    if (i.direction_i_|| i.initialiser_b_)
-       dir_i_ = i.direction_i_;
+//    if (i.direction_i_|| i.initialiser_b_)
+    //dir_i_ = i.direction_i_;
 }
 IMPLEMENT_STATIC_NAME(Script_register);
 ADD_THIS_REGISTER(Script_register);
index 4db170e0853f87d14f3fd286c6b16737fb58f102..14a4f63ef40d7591d88352baec7908fca809763e 100644 (file)
@@ -1,3 +1,13 @@
+/*
+  staff-elem.cc -- implement Staff_elem
+
+  source file of the LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+#include "paper-def.hh"
+#include "lookup.hh"
 #include "p-score.hh"
 #include "symbol.hh"
 #include "p-staff.hh"
@@ -23,6 +33,7 @@ Staff_elem::Staff_elem(Staff_elem const&s)
     pstaff_l_ = s.pstaff_l_;
     offset_ = Offset(0,0);
 }
+
 /**
   TODO:
   If deleted, then remove dependant_l_arr_ depency!
@@ -37,35 +48,44 @@ Staff_elem::translate(Offset O)
 {
     offset_ += O;
 }
+
 Interval
-Staff_elem::width() const
+Staff_elem::do_width() const return r;
 {
-    Interval r;
-
+    
     if (!output){
-       Molecule*m      = brew_molecule_p();
+       Molecule*m = brew_molecule_p();
        r = m->extent().x;
        delete m;
     } else
        r = output->extent().x;
-  
+}
+Interval
+Staff_elem::width() const
+{
+    Interval r=do_width();
+
     if (!r.empty_b()) // float exception on DEC Alpha
        r+=offset_.x;
 
     return r;
 }
 Interval
-Staff_elem::height() const
+Staff_elem::do_height() const return r
 {
-    Interval r;
-
     if (!output){
        Molecule*m      = brew_molecule_p();
        r = m->extent().y;
        delete m;
     } else
        r = output->extent().y;
-    
+}
+
+Interval
+Staff_elem::height() const
+{
+    Interval r=do_height();
+
     if (!r.empty_b())
        r+=offset_.y;
 
@@ -199,3 +219,10 @@ Staff_elem::add_dependency(Staff_elem * p)
     p->dependant_l_arr_.push(p);
 }
 IMPLEMENT_STATIC_NAME(Staff_elem);
+
+Molecule*
+Staff_elem::brew_molecule_p()const
+{
+    Atom a(paper()->lookup_l()->fill(Box(Interval(0,0), Interval(0,0))));
+    return new Molecule (a);
+}
index e22d32873c93a6c4688d158f2f015e516130cfff..983c6a6d2e8a2ce1357bede9081f54e29d0115fa 100644 (file)
@@ -18,11 +18,13 @@ Staff_info
 Staff_registers::get_staff_info() return inf;
 {
     inf = Request_register::get_staff_info();
+    inf.staff_sym_l_=staff_sym_l_;
     inf.c0_position_i_l_ = &c0_position_i_;
 }
 
 Staff_registers::Staff_registers(Input_register const*ireg_C)
 {
+    staff_sym_l_ =0;
     c0_position_i_ = 0;
     base_position_i_ =0;
     add( ireg_C->get_nongroup_p_arr());
@@ -116,3 +118,10 @@ Staff_registers::acceptable_request_b(Request*r)const
        (r->command() && r->command()->groupchange());
 }
 
+void
+Staff_registers::acknowledge_element(Staff_elem_info i)
+{
+    Register_group_register::acknowledge_element(i);
+    if ( i.elem_l_->name() == Staff_symbol::static_name())
+       staff_sym_l_ = (Staff_symbol*)i.elem_l_;
+}
index 817dc6a3b72f36f681469b05c9b91edb0b02d1c6..ee10d5e873b393749176d872fc75338038ce899d 100644 (file)
 #include "molecule.hh"
 #include "lookup.hh"
 
-Text_item::Text_item(Text_def *tdef_l, int staffsize_i)
+Text_item::Text_item(Text_def *tdef_l)
+    : Staff_side(this)
 {
     dir_i_ =-1;
-    init(tdef_l, staffsize_i);  
+    init(tdef_l);  
 }
 
 Text_def*
@@ -32,15 +33,15 @@ Text_item::~Text_item()
 }
 
 void
-Text_item::init(Text_def *tdef_l, int staffsize_i)
+Text_item::init(Text_def *tdef_l)
 {
-    staffsize_i_ = staffsize_i;
     tdef_p_ = new Text_def (*tdef_l);
 }
 
-Text_item::Text_item(Text_req* treq_l, int staffsize_i)
+Text_item::Text_item(Text_req* treq_l)
+    : Staff_side(this)
 {
-    init(treq_l->tdef_p_, staffsize_i);
+    init(treq_l->tdef_p_);
     dir_i_ = treq_l->dir_i_;
     if (!dir_i_)
        dir_i_ = -1;
@@ -49,7 +50,7 @@ Text_item::Text_item(Text_req* treq_l, int staffsize_i)
 void
 Text_item::set_default_index()
 {
-    pos_i_  = (dir_i_ > 0) ? staffsize_i_ + 4: -4;
+    pos_i_  = get_position_i();
 }
 
 void