]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.0.30
authorfred <fred>
Sun, 24 Mar 2002 19:31:07 +0000 (19:31 +0000)
committerfred <fred>
Sun, 24 Mar 2002 19:31:07 +0000 (19:31 +0000)
hdr/staffsym.hh [new file with mode: 0644]
src/clef.cc
src/clefitem.cc
src/headreg.cc [new file with mode: 0644]
src/localkeyitem.cc
src/localkeyreg.cc [new file with mode: 0644]
src/spanner.cc

diff --git a/hdr/staffsym.hh b/hdr/staffsym.hh
new file mode 100644 (file)
index 0000000..294a021
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+  staffsym.hh -- declare Staff_symbol
+
+  source file of the LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+
+#ifndef STAFFSYM_HH
+#define STAFFSYM_HH
+#include "spanner.hh"
+/**
+  This spanner draws the lines of a pstaff.
+  The bottom line is position 0.
+  */
+class Staff_symbol : public Spanner
+{
+public:
+    /// this many lines.
+    int no_lines_i_;
+
+    const char *name()const;
+    Staff_symbol(int lines);
+    virtual Molecule* brew_molecule_p() const;
+    void set_extent(PCol* p1, PCol* p2);
+    virtual void do_print()const;
+    virtual Spanner *do_break_at( PCol *c1,  PCol *c2) const;
+};
+#endif // STAFFSYM_HH
index d0fcbe09d9672c811eb20412e348388601fc095b..bf7b924159d7cd272ce11fd479ec39b2dd329d3e 100644 (file)
@@ -1,23 +1,32 @@
+/*
+  clef.cc -- implement  Clef
+
+  source file of the LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>,
+  Mats Bengtsson <matsb@s3.kth.se>
+*/
+
 #include "clef.hh"
+#include "debug.hh"
 
 Clef::Clef()
 {
-    clef_type= "violin";
-    c0_pos = -2;
+    set_type("violin");
 }
 
-void
-Clef::read(Array<Scalar>args)
+void 
+Clef::set_type(String type_str)
 {
-    clef_type = args[0];
-    if (clef_type == "violin") {
-       c0_pos=-2;
-    } else if (clef_type == "alto") {
-       c0_pos = 4;
-    } else if (clef_type == "tenor") {
-       c0_pos = 6;
-    } else if (clef_type == "bass") {
-       c0_pos = 10;
+    clef_type_str_  = type_str;
+    if (clef_type_str_ == "violin") {
+       c0_position_i_= -2;
+    } else if (clef_type_str_ == "alto") {
+       c0_position_i_= 4;
+    } else if (clef_type_str_ == "tenor") {
+       c0_position_i_= 6;
+    } else if (clef_type_str_ == "bass") {
+       c0_position_i_= 10;
     } else
-       assert(false);
+       error("unknown clef type `"+clef_type_str_+"\'");
 }
index 2b451a804d9f16b484b97200aee8675fdb36b3bb..0e0054acd34e4821793affad8737c2039f0b939f 100644 (file)
@@ -29,7 +29,7 @@ Clef_item::read(String t)
 void
 Clef_item::read(Clef k)
 {
-    read(k.clef_type);
+    read(k.clef_type_str_);
 }
 
 Molecule*
@@ -40,7 +40,7 @@ Clef_item::brew_molecule_p()const
        t += "_change";
     Symbol s = paper()->lookup_p_->clef(t);
     Molecule*output = new Molecule(Atom(s));
-    output->translate(Offset(0, paper()->interline()/2 * y_off));
+    output->translate(Offset(0, paper()->internote() * y_off));
     return output;
 }
 
diff --git a/src/headreg.cc b/src/headreg.cc
new file mode 100644 (file)
index 0000000..ecb2407
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+  headreg.cc -- part of LilyPond
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+#include "rest.hh"
+#include "notehead.hh"
+#include "headreg.hh"
+#include "paper.hh"
+#include "complexwalker.hh"
+
+
+Notehead_register::Notehead_register(Complex_walker*w_l)
+    :Request_register(w_l)
+{
+    note_p_ = 0;
+    set_dir(0);
+}
+
+bool
+Notehead_register::try_request(Request *req_l) 
+{
+    if (req_l->note() || req_l->rest())
+       accepted_req_arr_.push(req_l);
+    else
+       return false;
+
+    return true;
+}
+void
+Notehead_register::set_dir(int d)
+{
+    dir_i_ = d;
+}
+
+void
+Notehead_register::process_request()
+{
+    if (!accepted_req_arr_.size())
+       return;
+    
+    Request* req_l = accepted_req_arr_.top();
+    if (req_l->note()) {
+       Notehead*n_p = new Notehead(8); // ugh
+       note_p_ = n_p;
+       n_p->set_rhythmic(req_l->rhythmic());
+       n_p->position = req_l->note()->height() +
+           walk_l_->clef_.c0_position_i_;
+    } else {
+       note_p_ = new Rest ( req_l->rhythmic()->balltype,
+                            req_l->rhythmic()->dots);
+       if (req_l->rhythmic()->balltype <= 2)
+           note_p_->translate(
+               Offset(0,
+                      6 * paper()->internote()));
+    }
+    Staff_elem_info itinf(note_p_,req_l,this);
+    announce_element(itinf);
+}
+
+void
+Notehead_register::do_pre_move_process()
+{
+    if (note_p_) {
+       if (dir_i_ && note_p_->name() == String("Rest"))
+           note_p_->translate(Offset(0, 4*dir_i_ * paper()->internote()));
+       typeset_element(note_p_);
+       note_p_ = 0;
+    }
+}
index c61f1b91afa3a3366aa63748bac5f83adef7c4f6..6fa9b1dfe3162cb6a8aba97f76a6e5ad5beb2733 100644 (file)
@@ -45,9 +45,10 @@ Local_key_item::brew_molecule_p()const
     Molecule*octmol = 0;
     int lastoct = -100;
     for  (int i = 0; i <  accs.size(); i++) {
+       // do one octave
        if (accs[i].octave != lastoct) {
            if (octmol){
-               Real dy =lastoct*7*paper()->interline()/2;
+               Real dy =lastoct*7*paper()->internote();
                octmol->translate(Offset(0, dy));
                output->add(*octmol);
                delete octmol;
@@ -57,14 +58,14 @@ Local_key_item::brew_molecule_p()const
        lastoct = accs[i].octave;
        Symbol s =paper()->lookup_p_->accidental(accs[i].acc);   
        Atom a(s);
-       Real dy = (accs[i].name + c0_position) * paper()->interline()/2;
+       Real dy = (accs[i].name + c0_position) * paper()->internote();
        a.translate(Offset(0,dy));
 
        octmol->add_right(a);
     }
 
     if (octmol){
-       Real dy =lastoct*7*paper()->interline()/2;
+       Real dy =lastoct*7*paper()->internote();
        octmol->translate(Offset(0, dy));
        output->add(*octmol);
        delete octmol;
diff --git a/src/localkeyreg.cc b/src/localkeyreg.cc
new file mode 100644 (file)
index 0000000..bbd4993
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+  localkeyreg.cc -- implement Local_key_register
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+#include "localkeyreg.hh"
+#include "localkeyitem.hh"
+#include "complexwalker.hh"
+
+Local_key_register::Local_key_register(Complex_walker*w)
+    : Request_register(w)
+{
+    key_item_p_ = 0;    
+}
+bool
+Local_key_register::try_request(Request*)
+
+{
+    return false;
+}
+
+void
+Local_key_register::process_request()
+{
+}
+void
+Local_key_register::do_pre_move_process()
+{
+    if (key_item_p_) {
+       walk_l_->typeset_element(key_item_p_);
+       key_item_p_ = 0;
+    }
+}
+void
+Local_key_register::acknowledge_element(Staff_elem_info info)
+{    
+    if (info.req_l_->melodic()) {
+       Melodic_req * melodic_l_ = info.req_l_->melodic();
+
+       if( melodic_l_->forceacc ||
+           walk_l_->local_key_.oct(melodic_l_->octave).acc(melodic_l_->notename)
+           != melodic_l_->accidental) {
+           Item * support_l_ = info.elem_p_->item();
+       
+
+           if (!key_item_p_) {
+               key_item_p_ = new Local_key_item(walk_l_->clef_.c0_position_i_);
+               key_item_p_->c0_position = walk_l_->clef_.c0_position_i_;
+           }
+           
+           key_item_p_->add(melodic_l_);
+           key_item_p_->add(support_l_);
+           walk_l_->local_key_.oct(melodic_l_->octave)
+               .set(melodic_l_->notename, melodic_l_->accidental);
+       }
+    }
+}
index ad5b2e2552126351f48dc0fad6fa2672f84eeecb..15efb59071a9862f4554a425439155b85c67e747 100644 (file)
@@ -3,6 +3,7 @@
 #include "pcol.hh"
 
 NAME_METHOD(Spanner);
+
 void
 Spanner::do_print()const
 {