]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.0.21
authorfred <fred>
Sun, 24 Mar 2002 19:27:15 +0000 (19:27 +0000)
committerfred <fred>
Sun, 24 Mar 2002 19:27:15 +0000 (19:27 +0000)
13 files changed:
hdr/accidental.hh
hdr/keyitem.hh
hdr/localkeyitem.hh
hdr/rest.hh
hdr/stem.hh
hdr/textitem.hh [new file with mode: 0644]
src/clefitem.cc
src/keyitem.cc
src/localkeyitem.cc
src/notehead.cc
src/rest.cc
src/simplewalker.cc
src/textitem.cc [new file with mode: 0644]

index ba341a30dfedb71ef1588602c01f7e4726bd676a..8c601863ae82c00ab0565261bf6c20d9b414e77d 100644 (file)
@@ -15,7 +15,7 @@ struct Accidental : Item {
     Accidental(int type, int position);
     void print()const;
 private:
-    void brew_molecole();
+    void brew_molecule();
 };
 #endif // ACCIDENTAL_HH
 
index ba49475ce481628749ebeed4ea7293fa511ab73e..ffd0abeb9da7a4060743f906b44b0d041858d16e 100644 (file)
@@ -9,19 +9,26 @@
 
 #include "item.hh"
 #include "vray.hh"
+
+/// 
 struct Keyitem : Item {
     svec<int> pitch;
     svec<int> acc;
     int c_position;
 
+    
     /****************/
     
     Keyitem(int cposition);
     void add(int pitch, int acc);
     void read(svec<int> k);
+
     void preprocess();
 
-private:
-    void brew_molecole();
+    Molecule* brew_molecule()const;
 };
+/**
+  An item which places accidentals at the start of the line
+  */
+
 #endif // KEYITEM_HH
index cc786e8e7f5b1ff6ca7fc3234d0f288e7b1bb3b0..05a468b973a625a1782588c6e72b5249bc152bbd 100644 (file)
@@ -16,19 +16,16 @@ struct Local_acc {
 
 struct Local_key_item : Item {
     svec<Local_acc> accs;
-
-    int c0_position;
+    svec<Notehead*> group;
+    int c0_position;           // move into walker
 
     /****************/
     
     Local_key_item(int c0position);
-    void add(int oct, int pitch, int acc);
-
-    void preprocess();
-
-private:
-    void brew_molecole();
+    void add(int oct, int pitch, int acc, Notehead*);
 
+    void do_pre_processing();    
+    Molecule* brew_molecule()const;
 };
 #endif // LOCALKEYITEM_HH
 
index c5d0d7f995c8c46a3207620614befac137890866..2280611be8e4c5159907478edc4530534472d564 100644 (file)
@@ -16,11 +16,11 @@ struct Rest : public Item
 
     /****************/
 
-    void preprocess();
+
     Rest(int dur,int dots);
     void print()const;
-private:
-    void brew_molecole();
+
+    Molecule* brew_molecule()const;
 };
 /**
   takes care of:
index 768b614118622cd539a1712b3b49d807a4ba37de..ad2856b0f208d3fbf0b188de3f2e566cf20dadde 100644 (file)
@@ -49,9 +49,11 @@ struct Stem : public Item {
     svec<Notehead*> heads;
 
     /****************/
-
+    Stem(int center, Moment duration);
+    
     /// ensure that this Stem also encompasses the Notehead #n#
     void add(Notehead*n);
+
     Real hpos()const;
     void print() const;
     void set_stemend(Real);
@@ -59,14 +61,13 @@ struct Stem : public Item {
     void set_default_stemlen();
     void set_default_extents();
     void set_noteheads();
-    void postprocess();
-    void preprocess();
-    Stem(int center, Moment duration);
+    
+
+    void do_pre_processing();
 
     Interval width() const;
-private:
 
-    void brew_molecole();
+    Molecule* brew_molecule() const;
 };
 /**
   takes care of:
diff --git a/hdr/textitem.hh b/hdr/textitem.hh
new file mode 100644 (file)
index 0000000..1d37be3
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+  text.hh -- part of LilyPond
+
+  (c) 1996 Han-Wen Nienhuys
+*/
+
+#ifndef TEXT_ITEM_HH
+#define TEXT_ITEM_HH
+
+#include "textdef.hh"
+#include "item.hh"
+  
+struct Text_item : Item{
+    int pos;
+    int staffsize;
+    int dir;
+    Text_def*specs;
+    
+    /****************/
+    
+    void       set_default_pos();
+    Molecule*  brew_molecule()const;
+    void do_pre_processing();
+    
+    Text_item(Text_req*,int);
+};
+
+
+#endif // TEXT_HH
+
index 3e10f88867252d4958548a0898045172882f89b5..4289c643749d412839cf9026816b173c03b37098 100644 (file)
@@ -25,14 +25,15 @@ Clef_item::read(Clef k)
     read(k.clef_type);
 }
 
-void
-Clef_item::preprocess()
+Molecule*
+Clef_item::brew_molecule()const
 {
     String t = type;
     if  (change)
        t += "_change";
     Symbol s = paper()->lookup_->clef(t);
-    output = new Molecule(Atom(s));
+    Molecule*output = new Molecule(Atom(s));
     output->translate(Offset(0, paper()->interline()/2 * y_off));
+    return output;
 }
 
index 26ad1745e3ada7a5b2842c9a44184584b311a8d3..3499149352cde1c6f14235781244981276a7e66f 100644 (file)
@@ -21,6 +21,7 @@ Keyitem::read(svec<int> s)
        add(note, acc);
     }
 }
+
 void
 Keyitem::add(int p, int a)
 {
@@ -28,16 +29,11 @@ Keyitem::add(int p, int a)
     acc.add(a);
 }
 
-void
-Keyitem::preprocess()
-{
-    brew_molecole();
-}
 
-void
-Keyitem::brew_molecole()
+Molecule*
+Keyitem::brew_molecule()const
 {
-    output = new Molecule;
+    Molecule*output = new Molecule;
     Real inter = paper()->interline()/2;
     
     for (int i =0; i < pitch.sz(); i++) {
@@ -50,5 +46,6 @@ Keyitem::brew_molecole()
     Molecule m(paper()->lookup_->fill(Box(
        Interval(0, paper()->note_width()),
        Interval(0,0))));
-    output->add_right(m);      
+    output->add_right(m);
+    return output;
 }
index a7de5ae6954e9dff5531aef14367056cfc2d9f30..42bb268df01db8976ef97142470985cdfdd871b7 100644 (file)
@@ -3,34 +3,34 @@
 #include "scalar.hh"
 #include "lookup.hh"
 #include "paper.hh"
-
+#include "notehead.hh"
 Local_key_item::Local_key_item(int i)
 {
     c0_position  = i;
 }
 
 void
-Local_key_item::add (int o, int p , int a)
+Local_key_item::add (int o, int p , int a,Notehead*head_p)
 {
     Local_acc l;
     l.octave = o;
     l.name = p;
     l.acc = a;
     accs.add(l);
+    group.add(head_p);
+    dependencies.add(head_p);
 }
 
 void
-Local_key_item::preprocess()
+Local_key_item::do_pre_processing()
 {
-    brew_molecole();
+    accs.sort(Local_acc::compare);
 }
-
-void
-Local_key_item::brew_molecole()
+Molecule*
+Local_key_item::brew_molecule()const
 {
-    accs.sort(Local_acc::compare);
 
-    output = new Molecule;
+    Molecule*    output = new Molecule;
     Molecule*octmol = 0;
     int lastoct = -100;
     for  (int i = 0; i <  accs.sz(); i++) {
@@ -58,6 +58,7 @@ Local_key_item::brew_molecole()
        output->add(*octmol);
        delete octmol;
     }
+    return output;
 }
 
 int
index 203c5928300ba70ce5dfd5ba5b80b982a7907a68..5db73866004130ab3851effd31c21d177c6ecbf0 100644 (file)
@@ -1,5 +1,4 @@
 #include "misc.hh"
-
 #include "notehead.hh"
 #include "dimen.hh" 
 #include "debug.hh"
@@ -27,11 +26,6 @@ Notehead::print()const
 #endif
 }
 
-void
-Notehead::preprocess()
-{
-    brew_molecole();
-}
 
 int
 Notehead::compare(Notehead*&a, Notehead*&b)
@@ -39,27 +33,24 @@ Notehead::compare(Notehead*&a, Notehead*&b)
     return a->position - b->position;
 }
 
-void
-Notehead::brew_molecole()
+Molecule*
+Notehead::brew_molecule() const return out;
 {
-    assert(pstaff_);
-    assert(!output);
-
     Paperdef *p = paper();
 
     Real dy = p->internote();
     Symbol s = p->lookup_->ball(balltype);
     
-    output = new Molecule(Atom(s));
+    out = new Molecule(Atom(s));
     if (dots) {
        Symbol d = p->lookup_->dots(dots);
        Molecule dm;
        dm.add(Atom(d));
        if (!(position %2))
            dm.translate(Offset(0,dy));
-       output->add_right(dm);
+       out->add_right(dm);
     }
-    output->translate(Offset(x_dir * p->note_width(),0));
+    out->translate(Offset(x_dir * p->note_width(),0));
     bool streepjes = (position<-1)||(position > staff_size+1);
     if (streepjes) {
        int dir = sign(position);
@@ -69,10 +60,10 @@ Notehead::brew_molecole()
        sm.add(Atom(str));
        if (position % 2)
            sm.translate(Offset(0,-dy* dir));
-       output->add(sm);            
+       out->add(sm);       
     }
     
 
-    output->translate(Offset(0,dy*position));
+    out->translate(Offset(0,dy*position));
 }
 
index e448df37bdbce8ee3f476cb495076e7579cb882c..edb89c3696f08a795c5f5f5f3b4b50a6c4f370cd 100644 (file)
@@ -19,17 +19,11 @@ Rest::print()const
     Item::print();
 }
 
-void
-Rest::preprocess()
-{
-    brew_molecole();
-}
-
-void
-Rest::brew_molecole()
+Molecule*
+Rest::brew_molecule()const
 {
     assert(pstaff_);
-    assert(!output);
+
     Paperdef *p =paper();
 
     Symbol s;
@@ -42,6 +36,6 @@ Rest::brew_molecole()
        dm.add(Atom(d));
        m->add_right(dm);
     }
-    output = m;
+    return m;
 }
 
index 458e071c9aa86dd9d00bbefc6849edf80f6cc8f2..945f5151decff85f9e46c5f78db10c5f1f2ed5d8 100644 (file)
@@ -1,7 +1,8 @@
 /*
   UGR
   */
-
+#include "textspanner.hh"
+#include "script.hh"
 #include "request.hh"
 #include "voice.hh"
 #include "clef.hh"
 #include "keyitem.hh"
 #include "slur.hh"
 #include "localkeyitem.hh"
+#include "textitem.hh"
 
 Rhythmic_grouping
 parse_grouping(svec<Scalar> a, Moment one_beat)
 {
-    
     svec<int> r;
     for (int i= 0 ; i < a.sz(); i++)
        r.add(a[i]);
@@ -47,13 +48,14 @@ Simple_walker::do_INTERPRET_command(Command*com)
     svec<Scalar> args(com->args);
     args.del(0);
     if (com->args[0] == "GROUPING") {  
-       default_grouping = parse_grouping(args, col()->tdescription_->one_beat);
+       default_grouping = parse_grouping(args,
+                                         col()->tdescription_->one_beat);
     }else if (com->args[0] == "BAR") {
        local_key_.reset(key_);
 
     } else if (com->args[0] == "KEY") {
        
-       if (col()->when()) {
+       if (col()->when() > Moment(0)) {
            assert(!oldkey_undo);
            oldkey_undo = new svec<int>( key_.oldkey_undo(args));
        }
@@ -76,7 +78,7 @@ Simple_walker::do_TYPESET_command(Command*com)
        if (processed_key) 
            return;
        else
-           com->args[0] = "KEY"; 
+           com->args[0] = "KEY"; // urgh
     
     if (com->args[0] == "CURRENTCLEF") {
        if (processed_clef) 
@@ -95,6 +97,7 @@ Simple_walker::do_TYPESET_command(Command*com)
            oldkey_undo = 0;
        }
        processed_key = true;
+       
        ((Keyitem*) i)->read(typesetkey); // ugh        
     }
 
@@ -108,7 +111,7 @@ Simple_walker::do_TYPESET_command(Command*com)
 }
 
 void
-Simple_walker::do_local_key(Note_req*n)
+Simple_walker::do_local_key(Note_req*n,Notehead* head_p)
 {
     if ( local_key_.oct(n->octave).acc(n->name) != n->accidental) {
        if (!local_key_item_) {
@@ -116,26 +119,27 @@ Simple_walker::do_local_key(Note_req*n)
            local_key_item_->c0_position = clef_.c0_pos;
        }
        
-       local_key_item_->add(n->octave, n->name, n->accidental);        
+       local_key_item_->add(n->octave, n->name, n->accidental, head_p);
        local_key_.oct(n->octave).set(n->name, n->accidental);
     }
 }
 
 void
-Simple_walker::do_note(Rhythmic_req*rq)
+Simple_walker::do_note(Note_info n)
 {
     Simple_column*c = col();
     Simple_staff *s = staff();
-    
-    if (rq->note()) {
-       Note_req * req = rq->note() ;
+       Item*rhythmic=0;
+    if (n.rq->note()) {
+       Note_req * req = n.rq->note() ;
        const Voice *v = req->elt->voice_;
-       
+
        Notehead*n = s->get_notehead(req, clef_.c0_pos);
+       rhythmic=n;
        stem_->add(n);
        if (current_grouping) {
            current_grouping->add_child(
-               c->tdescription_->whole_in_measure, rq->duration());
+               c->tdescription_->whole_in_measure, req->duration());
        }
        noteheads.add(n);
        int sidx =find_slur(v);
@@ -144,12 +148,13 @@ Simple_walker::do_note(Rhythmic_req*rq)
        }
 
        if (wantkey)
-           do_local_key(req);
+           do_local_key(req,n);
+    }else if (n.rq->rest()) {
+       rhythmic = s->get_rest(n.rq->rest());
+       c->typeset_item(rhythmic);
     }
-
-    if (rq->rest()) {
-       c->typeset_item( s->get_rest(rq->rest()) );
-    }      
+    for (int i= 0; i < n.scripts.size(); i ++)
+       c->typeset_item(new Script(n.scripts[i], rhythmic, 10, stem_)); // UGR
 }
 
 void
@@ -157,6 +162,7 @@ Simple_walker::process_requests()
 {
     Simple_column*c = col();
     Simple_staff *s = staff();
+
     if (c->beam_&& c->beam_->spantype == Span_req::START) {
        if (beam_)
            error("Too many beams (t = "
@@ -164,6 +170,7 @@ Simple_walker::process_requests()
        beam_ = new Beam;
        current_grouping = new Rhythmic_grouping;
     }
+    
     for (int i=0; i < c->slurs.sz(); i++) {
        Slur_req*sl = c->slurs[i];
 
@@ -175,6 +182,10 @@ Simple_walker::process_requests()
        }
     }
     
+    if (c->text_) {
+       c->typeset_item(new Text_item(c->text_, 10)); // UGR
+    }
+
     if (c->stem_) {
        stem_ = s->get_stem(c->stem_->stem(), c->stem_requester_len);
     }
@@ -200,6 +211,14 @@ Simple_walker::process_requests()
     if (c->beam_&& c->beam_->spantype == Span_req::STOP) {
        beam_->set_grouping(default_grouping, *current_grouping);
        pscore_->typeset_spanner(beam_, s->theline);
+
+       if (c->beam_->nplet) {
+           Text_spanner* t = new Text_spanner(beam_);
+           t->spec.align = 0;
+           t->spec.text = c->beam_->nplet;
+           pscore_->typeset_spanner(t, s->theline);
+       }
+
        beam_ = 0;
        delete current_grouping;
        current_grouping =0;
diff --git a/src/textitem.cc b/src/textitem.cc
new file mode 100644 (file)
index 0000000..d19b4b8
--- /dev/null
@@ -0,0 +1,40 @@
+#include "request.hh"
+#include "paper.hh"
+#include "textitem.hh"
+#include "stem.hh"
+#include "molecule.hh"
+#include "lookup.hh"
+
+Text_item::Text_item(Text_req * r, int s)
+{
+    dir = r->dir;
+    if (!dir)
+       dir = -1;
+    
+    specs = r->spec;
+    staffsize = s;
+    pos = 0;
+}
+
+void
+Text_item::set_default_pos()
+{
+    pos  = (dir > 0) ? staffsize + 2: -4;
+}
+void
+Text_item::do_pre_processing()
+{
+    set_default_pos();
+}
+
+    
+Molecule*
+Text_item::brew_molecule() const
+{
+    Molecule*    output = new Molecule(specs->create(paper()));
+    if(dir <0)
+       output->translate(Offset(0, -output->extent().y.length() ));
+    
+    output->translate(Offset(0, pos * paper()->internote()));
+    return output;
+}