From 3146e04c347b2b57cead3d7ec3c41a027db8a1f5 Mon Sep 17 00:00:00 2001 From: fred Date: Sun, 24 Mar 2002 19:27:15 +0000 Subject: [PATCH] lilypond-0.0.21 --- hdr/accidental.hh | 2 +- hdr/keyitem.hh | 11 +++++++-- hdr/localkeyitem.hh | 13 +++++------ hdr/rest.hh | 6 ++--- hdr/stem.hh | 13 ++++++----- hdr/textitem.hh | 30 +++++++++++++++++++++++++ src/clefitem.cc | 7 +++--- src/keyitem.cc | 15 +++++-------- src/localkeyitem.cc | 19 ++++++++-------- src/notehead.cc | 23 ++++++------------- src/rest.cc | 14 ++++-------- src/simplewalker.cc | 55 ++++++++++++++++++++++++++++++--------------- src/textitem.cc | 40 +++++++++++++++++++++++++++++++++ 13 files changed, 163 insertions(+), 85 deletions(-) create mode 100644 hdr/textitem.hh create mode 100644 src/textitem.cc diff --git a/hdr/accidental.hh b/hdr/accidental.hh index ba341a30df..8c601863ae 100644 --- a/hdr/accidental.hh +++ b/hdr/accidental.hh @@ -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 diff --git a/hdr/keyitem.hh b/hdr/keyitem.hh index ba49475ce4..ffd0abeb9d 100644 --- a/hdr/keyitem.hh +++ b/hdr/keyitem.hh @@ -9,19 +9,26 @@ #include "item.hh" #include "vray.hh" + +/// struct Keyitem : Item { svec pitch; svec acc; int c_position; + /****************/ Keyitem(int cposition); void add(int pitch, int acc); void read(svec 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 diff --git a/hdr/localkeyitem.hh b/hdr/localkeyitem.hh index cc786e8e7f..05a468b973 100644 --- a/hdr/localkeyitem.hh +++ b/hdr/localkeyitem.hh @@ -16,19 +16,16 @@ struct Local_acc { struct Local_key_item : Item { svec accs; - - int c0_position; + svec 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 diff --git a/hdr/rest.hh b/hdr/rest.hh index c5d0d7f995..2280611be8 100644 --- a/hdr/rest.hh +++ b/hdr/rest.hh @@ -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: diff --git a/hdr/stem.hh b/hdr/stem.hh index 768b614118..ad2856b0f2 100644 --- a/hdr/stem.hh +++ b/hdr/stem.hh @@ -49,9 +49,11 @@ struct Stem : public Item { svec 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 index 0000000000..1d37be3286 --- /dev/null +++ b/hdr/textitem.hh @@ -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 + diff --git a/src/clefitem.cc b/src/clefitem.cc index 3e10f88867..4289c64374 100644 --- a/src/clefitem.cc +++ b/src/clefitem.cc @@ -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; } diff --git a/src/keyitem.cc b/src/keyitem.cc index 26ad1745e3..3499149352 100644 --- a/src/keyitem.cc +++ b/src/keyitem.cc @@ -21,6 +21,7 @@ Keyitem::read(svec 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; } diff --git a/src/localkeyitem.cc b/src/localkeyitem.cc index a7de5ae695..42bb268df0 100644 --- a/src/localkeyitem.cc +++ b/src/localkeyitem.cc @@ -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 diff --git a/src/notehead.cc b/src/notehead.cc index 203c592830..5db7386600 100644 --- a/src/notehead.cc +++ b/src/notehead.cc @@ -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)); } diff --git a/src/rest.cc b/src/rest.cc index e448df37bd..edb89c3696 100644 --- a/src/rest.cc +++ b/src/rest.cc @@ -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; } diff --git a/src/simplewalker.cc b/src/simplewalker.cc index 458e071c9a..945f5151de 100644 --- a/src/simplewalker.cc +++ b/src/simplewalker.cc @@ -1,7 +1,8 @@ /* UGR */ - +#include "textspanner.hh" +#include "script.hh" #include "request.hh" #include "voice.hh" #include "clef.hh" @@ -19,11 +20,11 @@ #include "keyitem.hh" #include "slur.hh" #include "localkeyitem.hh" +#include "textitem.hh" Rhythmic_grouping parse_grouping(svec a, Moment one_beat) { - svec 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 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( 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 index 0000000000..d19b4b8132 --- /dev/null +++ b/src/textitem.cc @@ -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; +} -- 2.39.5