]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.0.50
authorfred <fred>
Sun, 24 Mar 2002 19:39:01 +0000 (19:39 +0000)
committerfred <fred>
Sun, 24 Mar 2002 19:39:01 +0000 (19:39 +0000)
bin/convert-mudela [new file with mode: 0644]
input/scsii-menuetto.ly
lily/crescendo.cc
lily/include/staff-side.hh [new file with mode: 0644]
lily/include/staff-sym.hh
lily/include/text-item.hh
lily/lyric-item.cc
lily/register-group.cc
lily/script.cc
lily/staff-side.cc [new file with mode: 0644]
lily/staff-sym.cc

diff --git a/bin/convert-mudela b/bin/convert-mudela
new file mode 100644 (file)
index 0000000..d64a7d7
--- /dev/null
@@ -0,0 +1,3 @@
+#!/usr/bin/perl -w
+
+print "todo\n!";
index a2cd75861896fe823a3e5eb2755169ea1880ce21..12183e79e79c4b94bbf7a7c7149f32084f7f6266 100644 (file)
@@ -11,7 +11,7 @@
 % The purpose of this file is to demonstrate features of LilyPond.
 % (there is an accompanying LaTeX file, scsii-menuetto.tex)
 %
-
+\version "0.0.50";
 %% Stuff from MPP version
 % \lefttitle{Menuetto}
 % \tempo{Moderato}
@@ -45,10 +45,10 @@ ii_menuetto = \melodic{
        c'!4-. |
 %%7
        < a4-. f4>
-       < d'4-.-upbow f4 'bes4 >
-       < e'4-.-downbow g4 'g4 > |
+       < d'4-.-\upbow f4 'bes4 >
+       < e'4-.-\downbow g4 'g4 > |
 %%8
-       < cis'2.-upbow e2. 'a2. > 
+       < cis'2.-\upbow e2. 'a2. > 
                \bar ":|:";
 %%9
        \clef "violin";
@@ -69,9 +69,9 @@ ii_menuetto = \melodic{
                 { \stem -1; g4(\stem -1;) f4 e4 }% ugh
        > |
 %%14
-       < [ a f > g a f ] < d'4-$upbow e4 'bes4 > |
+       < [ a f > g a f ] < d'4-\upbow e4 'bes4 > |
 %%15
-       < c'4-$downbow f4 'a4 > [ bes( )a g a ] |
+       < c'4-\downbow f4 'a4 > [ bes( )a g a ] |
 %%16
        [ f( e )f a-. g-. bes-. ] |
 %%17
@@ -79,7 +79,7 @@ ii_menuetto = \melodic{
 %%18
        < { [ c'( )bes c' a ] } { [ es ] } > fis4 |
 %%19
-       < d'4-downbow g4 'bes4 > < c'4-upbow g4 c4 > < [ bes d > a ] |
+       < d'4-\downbow g4 'bes4 > < c'4-\upbow g4 c4 > < [ bes d > a ] |
 %%20
        < { [ c'( bes a )bes g( )bes ] } { [ d ] } { [ g ] } > |
 %%21
@@ -96,7 +96,7 @@ ii_menuetto = \melodic{
 }
 
 \score{
-       \staff{ melodicregs $ii_menuetto }
+       \staff{ melodicregs ii_menuetto }
        \paper{
                \width 195\mm
                \unitspace 9\mm  % to get lily to use only three lines
index e8a36e29a8de635d276bb0dd3913853ae736abdc..4583bdae2f9dd396dfadcbb7f7cf84b640617b0f 100644 (file)
 #include "lookup.hh"
 #include "paper-def.hh"
 #include "debug.hh"
-Crescendo::Crescendo(int s)
+
+Crescendo::Crescendo()
+    : Staff_side(this)
 {
-    staff_size_i_ = s;
     grow_dir_i_ =0;
     dir_i_ = -1 ;
     left_dyn_b_ = right_dyn_b_ =false;
@@ -47,9 +48,7 @@ Crescendo::brew_molecule_p() const return m_p ;
     }
     Symbol s( paper()->lookup_l()->hairpin(w_dim, grow_dir_i_ < 0) );
     m_p->add(Atom(s));
-    int pos = (dir_i_ >0) ? staff_size_i_ + 4 : - 4 ;
-    if(dir_i_<0 )              // should do something better anyway.
-       m_p->translate(Offset(0, -m_p->extent().y.left ));
+    int pos = get_position_i();
     m_p->translate(Offset(x_off_dim,pos * paper()->internote()));
 }
 
diff --git a/lily/include/staff-side.hh b/lily/include/staff-side.hh
new file mode 100644 (file)
index 0000000..bd29c53
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+  staff-side.hh -- declare Staff_side
+
+  source file of the LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+
+#ifndef STAFF_SIDE_HH
+#define STAFF_SIDE_HH
+
+#include "staff-elem.hh"
+
+/// A symbol which sits along  the staff
+class Staff_side  {
+    Array<Staff_elem*> support_l_arr_;
+
+    Staff_symbol * staff_sym_l_;
+    Staff_elem * elem_l_;
+    Interval support_height()const;
+public:
+       /**
+      Vertical dir of symbol relative to staff. -1 = below staff?
+      */
+    int dir_i_;
+    
+    /// follow the support inside the staff?
+    bool inside_staff_b_;
+
+    void set_staffsym(Staff_symbol*);
+  
+    Staff_side(Staff_elem*);
+    void add_support(Staff_elem*);
+    
+protected:
+    int get_position_i()const;
+};
+#endif // STAFF_SIDE_HH
index bcec2bfaff803f148b48fb1e6ac6ba8e16debd39..852771b79e17fa9524360e72e085b8f84ba9ffba 100644 (file)
 #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_;
+public:
 
+    void set_extent(PCol* p1, PCol* p2);
     NAME_MEMBERS(Staff_symbol);
     Staff_symbol(int lines);
+    Real inter_note_f()const;
+    int steps_i()const;
+protected:
     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;
 };
index ba81fce47497de81ae4b8acd3cce6445f587c016..85ff171d6d08b1587548fe664cbca796c3bbb232 100644 (file)
@@ -9,18 +9,18 @@
 
 #include "text-def.hh"
 #include "item.hh"
+#include "staff-side.hh"
 
 /**
   print a fixed width text above or below the staff.
  */
-class Text_item : public Item {
-    void init(Text_def* tdef_l,int staffsize_i); 
+class Text_item : public Item ,public Staff_side{
+    void init(Text_def* tdef_l); 
     Text_def* tdef_p_;
+
 public:
     Text_def * tdef_l();
     int pos_i_;
-    int staffsize_i_;
-    int dir_i_;
         
     /* ***************/
 
@@ -28,8 +28,8 @@ public:
     virtual void set_default_index();
     Molecule* brew_molecule_p() const;
     void do_pre_processing();
-    Text_item(Text_def*,int);
-    Text_item(Text_req*,int);
+    Text_item(Text_def*);
+    Text_item(Text_req*);
     ~Text_item();
 };
 
index 8bca62e9c939ddf7ba4f97d726157e1f30a9cdad..318652393775c40f5e70089b2132af744b2f7469 100644 (file)
@@ -10,7 +10,7 @@
 #include "debug.hh"
 
 Lyric_item::Lyric_item(Lyric_req* lreq_l, int voice_count_i)
-    : Text_item(lreq_l,0)
+    : Text_item(lreq_l)
 {
     pos_i_ = -voice_count_i * 4 ;      // 4 fontsize dependant. TODO
     dir_i_ = -1;
index 18be472825ab366b1d7a76b27f2725e24149faf4..a7573332007163f0bba98f4bf95a94b4c7ebbc7b 100644 (file)
@@ -57,7 +57,8 @@ Register_group_register::post_move_processing()
 void
 Register_group_register::acknowledge_element(Staff_elem_info info)
 {
-    if (!contains_b(info.origin_reg_l_arr_[0]))
+    Request_register* origin = info.origin_reg_l_arr_[0];
+    if (!contains_b(origin) && !origin->contains_b(this))
        return;
     
     for (iter_top(reg_list_, i); i.ok(); i++) 
index b92892de6fde6f1c71d8077f5962a795f22a7db9..2f471e6ef2344f416b22b5954e2c8091feb17702 100644 (file)
@@ -1,3 +1,11 @@
+/*
+  script.cc -- implement Script
+
+  source file of the LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
 #include "musical-request.hh"
 #include "paper-def.hh"
 #include "script.hh"
@@ -11,89 +19,47 @@ void
 Script::set_stem(Stem*st_l)
 {
     stem_l_ = st_l;
-    add_dependency(st_l);
+    add_support(st_l);
 }
 
-void
-Script::set_support(Item*i)
-{
-    support.push(i);
-    add_dependency(i);
-}
 
-Script::Script(Script_req* rq, int staflen)
+Script::Script(Script_req* rq)
+    :Staff_side(this)
 {    
-    staffsize =staflen;
     specs_l_ = rq->scriptdef_p_;
+    inside_staff_b_ = specs_l_->inside_staff_b_;
     stem_l_ = 0;
-    pos = 0;
-    symdir=1;
-    dir =rq->dir_i_;
+    pos_i_ = 0;
+    symdir_i_=1;
+    dir_i_ =rq->dir_i_;
 }
 
 void
 Script::set_symdir()
 {
-    if (specs_l_->invertsym)
-       symdir = (dir < 0) ? -1:1;
+    if (specs_l_->invertsym_b_)
+       symdir_i_ = (dir_i_ < 0) ? -1:1;
 }
 
 void
 Script::set_default_dir()
 {
-    if (specs_l_->stemdir) {
-       if (!stem_l_)
-           dir = 1;
-       else
-           dir = stem_l_->dir * specs_l_->stemdir;
+    int s_i=specs_l_->rel_stem_dir_i_;
+    if (s_i && stem_l_)
+       dir_i_ = stem_l_->dir_i_ * s_i;
+    else {
+       dir_i_ =specs_l_->staff_dir_i_;
     }
 }
 
-Interval
-Script::support_height() const return r;
-{
-    for (int i=0; i < support.size(); i++)
-       r.unite(support[i]->height());
-}
-
 void
 Script::set_default_index()
 {
-    Real inter_f= paper()->internote();
-    Interval dy = symbol().dim.y;
-    
-    int d = specs_l_->staffdir;
-    Real y  ;
-    if (!d) {
-       Interval v= support_height();
-       y = v[dir]  -dy[-dir] + 2*dir*inter_f;
-    } else {
-       y  = (d > 0) ? staffsize + 2: -2; // ug
-       y *=inter_f;
-       Interval v= support_height();
-
-       if (d > 0) {
-           y = y >? v.max();
-       } else if (d < 0) {
-           y = y <? v.min();
-       }
-    }
-    
-    if (stem_l_) {
-       Interval v= stem_l_->height();
-
-       if (d > 0 || (!d && dir > 0)) {
-           y = y >? v.max();
-       }else if (d < 0 || (!d && dir < 0)) {
-           y = y <? v.min();
-       }
-    }
-    
-    pos = int(rint(Real(y)/inter_f));
+    pos_i_ = get_position_i();
 }
 
 Interval
-Script::width() const
+Script::do_width() const
 {
     return symbol().dim.x;
 }
@@ -101,7 +67,7 @@ Script::width() const
 Symbol
 Script::symbol()const
 {
-    String preidx_str = (symdir < 0) ?"-" :"";
+    String preidx_str = (symdir_i_ < 0) ?"-" :"";
     return paper()->lookup_l()->script(preidx_str + specs_l_->symidx);
 }
 
@@ -124,7 +90,14 @@ Script::brew_molecule_p() const
     Real dy = paper()->internote();
     
     Molecule*out = new Molecule(Atom(symbol()));
-    out->translate(Offset(0,dy * pos));
+    out->translate(Offset(0,dy * pos_i_));
     return out;
 }
 IMPLEMENT_STATIC_NAME(Script);
+
+int 
+Script::compare(Script  *const&l1, Script *const&l2) 
+{
+    return l1->specs_l_->priority_i_ - l2->specs_l_->priority_i_;
+}
+    
diff --git a/lily/staff-side.cc b/lily/staff-side.cc
new file mode 100644 (file)
index 0000000..92b7917
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+  staff-side.cc -- implement Staff_side
+
+  source file of the LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+#include "staff-side.hh"
+#include "staff-sym.hh"
+
+void
+Staff_side::set_staffsym(Staff_symbol* s_l)
+{
+    staff_sym_l_ = s_l;
+}
+
+Staff_side::Staff_side(Staff_elem * elem_l)
+{
+    elem_l_ = elem_l;
+    dir_i_ =0;
+    staff_sym_l_ =0;
+    inside_staff_b_ =false;
+}
+
+
+Interval
+Staff_side::support_height() const return r;
+{
+    for (int i=0; i < support_l_arr_.size(); i++)
+       r.unite(support_l_arr_[i]->height());
+}
+
+void
+Staff_side::add_support(Staff_elem*i)
+{
+    support_l_arr_.push(i);
+    elem_l_->add_dependency(i);
+}
+
+int
+Staff_side::get_position_i()const
+{
+    if (!staff_sym_l_)
+       return 0;
+    
+    Real inter_f = staff_sym_l_->inter_note_f();
+    int staff_size_i = staff_sym_l_->steps_i();
+    Real y=0;
+    if (!inside_staff_b_) {
+       y  = (dir_i_ > 0) ? staff_size_i + 2: -2; 
+       y *=inter_f;
+       Interval v= support_height();
+
+       if (dir_i_ > 0) {
+           y = y >? (v.max() + 2*inter_f);
+       } else if (dir_i_ < 0) {
+           y = y <? (v.min() - 2*inter_f);
+       }
+    } else {
+       Interval v= support_height();
+       y = v[dir_i_]  + 2*dir_i_*inter_f;      // ugh
+    }
+    return int(rint(Real(y)/inter_f));
+}
index 9eb0e76899b8ed66b0e86b34ce7cf670c47d9f06..9eb4d6d2ac5d9306875f25d96fda9cd49e41790a 100644 (file)
@@ -46,3 +46,15 @@ Staff_symbol::set_extent(PCol*p1, PCol*p2)
     left_col_l_ = p1;
     right_col_l_ = p2;
 }
+
+Real
+Staff_symbol::inter_note_f()const
+{
+    return paper()->internote();
+}
+
+int
+Staff_symbol::steps_i() const
+{
+    return no_lines_i_*2;
+}