]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.1.44
authorfred <fred>
Sun, 24 Mar 2002 20:05:23 +0000 (20:05 +0000)
committerfred <fred>
Sun, 24 Mar 2002 20:05:23 +0000 (20:05 +0000)
init/engraver.ly
init/property.ly
lily/beam-grav.cc
lily/general-script-def.cc
lily/include/plet-engraver.hh
lily/include/plet-spanner.hh
lily/include/text-def.hh
lily/parser.y
lily/plet-engraver.cc
lily/plet-spanner.cc
lily/text-def.cc

index 7553bd0cdefddf391db41386eb63cad4d2a0a701..6b8b41f49b4a1a07f07ed4e226d23c2739fade87 100644 (file)
@@ -24,12 +24,12 @@ Voice = \translator {
        \consists "Dynamic_engraver";
        \consists "Rest_engraver";
        \consists "Stem_engraver";
+       \consists "Plet_engraver";
        \consists "Beam_engraver";
        \consists "Abbreviation_beam_engraver";
        \consists "Script_engraver";
        \consists "Rhythmic_column_engraver";
        \consists "Slur_engraver";
-       \consists "Plet_engraver";
        \accepts "Thread";
 }
 
index 4faeb4c6b5158ee0cfa44e38b15c53fd84deee3b..372567863cb05a1fe35b19a76357c967c1eb39b8 100644 (file)
@@ -12,6 +12,10 @@ name                 value   effect                  shorthand
 ydirection             -1      force stem down         \stemdown
 ydirection             0       stem direction free     \stemboth
 ydirection             1       force stem up           \stemup
+pletvisibility         0       show nothing
+pletvisibility         1       show number
+pletvisibility         2       show number, and bracket-if-no-beam
+pletvisibility         4       show number, and bracket
 
 [Score?]
 beamslopedamping       0       no damping              \beamslopeproportional  
index 6592166fa2de3ebd3dcd38eedb870b8017d9321b..ecb00ee0834b09984235b4f151f958f05c6b7349 100644 (file)
@@ -28,8 +28,7 @@ Beam_engraver::do_try_request(Request*r)
   if (!mus_l)
     return false;
 
-  Beam_req * b = mus_l->beam();
-
+  Beam_req* b = mus_l->beam ();
   if (!b)
     return false;
 
index 2a014cc54205a282802c9ec460833bfe96b41061..66370135f8b66d4a3869f46788a2d73fd5b7286d 100644 (file)
@@ -10,6 +10,7 @@
 #include "general-script-def.hh"
 #include "debug.hh"
 #include "atom.hh"
+
 Direction
 General_script_def::staff_dir() const
 {
index 3a4e4d31c6228f170ce2120e50e2a5384c9eb463..16d0beab3594314e51a0bf47100e2e9b6013812d 100644 (file)
@@ -33,6 +33,8 @@ protected:
   
 private:
   Drul_array<Plet_req*> span_reqs_drul_;
+  Drul_array<Moment> beam_mom_drul_;
+  Drul_array<Moment> span_mom_drul_;
   Plet_spanner* plet_spanner_p_;
 };
 
index 4f2fa66eab3acae6db2637ca154ac5fabbdb44af..8caa2d01473131321cc95d8d67baf0b469fafac1 100644 (file)
@@ -22,6 +22,7 @@ public:
  
   Text_def* tdef_p_;
   Drul_array<Stem *> stem_l_drul_;
+  int visibility_i_;
  
 protected:
   virtual Molecule* brew_molecule_p () const;
index 48faa16f15c53ee98fcc667d39955220f9821993..185ea715c799928ffe233bfa14235b760cf56234 100644 (file)
@@ -30,6 +30,7 @@ public:
     String style_str_;
     
     virtual void do_print() const;
+    virtual Direction staff_dir() const;
     virtual Atom get_atom (Paper_def* p, Direction dir_) const;
     virtual ~Text_def() {};
     virtual bool do_equal_b (const General_script_def*) const;
index 2480a041e6f0f0ecd026e4dd2b4f7a12fb0f2bb1..159978d3dcd8fb0e5c6b3289e498110f9534e509 100644 (file)
@@ -12,7 +12,7 @@
 #include <iostream.h>
 
 // mmm
-#define MUDELA_VERSION "0.1.8"
+#define MUDELA_VERSION "0.1.9"
 
 #include "scalar.hh"
 #include "translation-property.hh"
@@ -168,7 +168,7 @@ yylex (YYSTYPE *s,  void * v_l)
 %token E_EXCLAMATION E_SMALLER E_BIGGER E_CHAR
 
 %type <i>      dots
-%token <i>     INT
+%token <i>     DIGIT
 %token <melreq>        NOTENAME_ID
 %token <id>    DURATION_IDENTIFIER
 %token <id>    IDENTIFIER
@@ -188,6 +188,7 @@ yylex (YYSTYPE *s,  void * v_l)
 %token <real>  REAL
 %token <string>        DURATION RESTNAME
 %token <string>        STRING
+%token <i>     UNSIGNED
 %token <i>     POST_QUOTES
 %token <i>     PRE_QUOTES
 
@@ -199,7 +200,7 @@ yylex (YYSTYPE *s,  void * v_l)
 %type <i>      open_plet_parens close_plet_parens
 %type <music>  simple_element music_elt full_element lyrics_elt command_elt
 %type <i>      abbrev_type
-%type <i>      int
+%type <i>      int unsigned
 %type <i>      script_dir
 %type <id>     identifier_init
 %type <duration> explicit_steno_duration notemode_duration
@@ -222,12 +223,13 @@ yylex (YYSTYPE *s,  void * v_l)
 %type <real>   dim real
 %type <real>   unit
 %type <request> abbrev_command_req
-%type <request>        post_request command_req verbose_command_req
+%type <request>        post_request structured_post_request
+%type <request> command_req verbose_command_req
 %type <request>        script_req  dynamic_req
 %type <score>  score_block score_body
 %type <intarr> shape_array
 %type <script> script_definition script_body mudela_script gen_script_def
-%type <textdef> text_def
+%type <textdef> text_def finger
 %type <string> script_abbreviation
 %type <symbol> symboldef
 %type <symtable>       symtable symtable_body
@@ -323,6 +325,7 @@ add_declaration:
            $4->set_spot (THIS->pop_spot ());
        }
        ;
+
 identifier_init:
        score_block {
                $$ = new Score_id ($1, SCORE_IDENTIFIER);
@@ -354,11 +357,9 @@ identifier_init:
        }
        | int   {
                $$ = new Int_id (new int ($1), INT_IDENTIFIER);
-
        }
        | post_request {
                $$ = new Request_id ($1, POST_REQUEST_IDENTIFIER);
-
        }
        | melodic_request {
                $$ = new Request_id ($1, MELODIC_REQUEST_IDENTIFIER);
@@ -541,7 +542,7 @@ midi_body: /* empty */              {
        ;
 
 tempo_request:
-       TEMPO entered_notemode_duration '=' int         {
+       TEMPO entered_notemode_duration '=' unsigned    {
                $$ = new Tempo_req;
                $$->dur_ = *$2;
                delete $2;
@@ -636,7 +637,7 @@ scalar:
 
 Chord:
        '<' Chord_body '>'      { $$  = $2; }
-       | MULTI INT Chord {
+       | MULTI unsigned Chord {
                $$ = $3;
                $$->multi_level_i_=$2;
        }
@@ -709,7 +710,7 @@ verbose_command_req:
                $$ = new Bar_req (*$2);
                delete $2;
        }
-       | METER int '/' int     {
+       | METER unsigned '/' unsigned   {
                Meter_change_req *m = new Meter_change_req;
                m->set ($2,$4);
                $$ = m;
@@ -725,7 +726,7 @@ verbose_command_req:
        | tempo_request {
                $$ = $1;
        }
-       | CADENZA int   {
+       | CADENZA unsigned      {
                $$ = new Cadenza_req ($2);
        }
        | PARTIAL duration_length       {
@@ -751,7 +752,7 @@ post_requests:
        {
                assert (THIS->post_reqs.empty ());
        }
-       | post_requests post_request {
+       | post_requests structured_post_request {
                $2->set_spot (THIS->here_input ());
                THIS->post_reqs.push ($2);
        }
@@ -764,13 +765,18 @@ post_requests:
        }
        ;
 
+structured_post_request:
+       script_req
+       | post_request
+       ;
 
 post_request:
        POST_REQUEST_IDENTIFIER {
                $$ = (Request*)$1->request ();
        }
-       | script_req
-       | dynamic_req
+       | dynamic_req {
+               $$ = $1;
+       }
        | abbrev_type   {
                Abbreviation_req* a = new Abbreviation_req;
                a->type_i_ = $1;
@@ -819,7 +825,7 @@ melodic_request:
        ;
 
 explicit_duration:
-       DURATION '{' int int '}'        {
+       DURATION '{' int unsigned '}'   {
                $$ = new Duration;
                $$-> durlog_i_ = $3;
                $$-> dots_i_ = $4;
@@ -827,7 +833,7 @@ explicit_duration:
        ;
 
 dynamic_req:
-       ABSDYNAMIC '{' int '}'  {
+       ABSDYNAMIC '{' unsigned '}'     {
                Absolute_dynamic_req *ad_p = new Absolute_dynamic_req;
                ad_p ->loudness_ = (Dynamic_req::Loudness)$3;
                $$ =ad_p;
@@ -841,7 +847,7 @@ dynamic_req:
        ;
 
 close_plet_parens:
-       ']' INT '/' INT {
+       ']' unsigned '/' unsigned {
                $$ = MAEBTELP;
                THIS->plet_.type_i_ = $4;
                THIS->plet_.iso_i_ = $2;
@@ -855,7 +861,7 @@ close_plet_parens:
                THIS->default_duration_.plet_.iso_i_ = 1;
                THIS->default_duration_.plet_.type_i_ = 1;
        }
-       | TELP INT '/' INT {
+       | TELP unsigned '/' unsigned {
                $$ = TELP;
                THIS->plet_.type_i_ = $4;
                THIS->plet_.iso_i_ = $2;
@@ -885,10 +891,10 @@ close_request_parens:
        ;
 
 open_abbrev_parens:
-       '[' ':' INT {
+       '[' ':' unsigned {
                $$ = '[';
                if (!Duration::duration_type_b ($3))
-                       THIS->parser_error ("Not a duration");
+                       THIS->parser_error ("1:Not a duration");
                else if ($3 < 8)
                        THIS->parser_error ("Can't abbreviate");
                else
@@ -897,14 +903,14 @@ open_abbrev_parens:
        ;
 
 open_plet_parens:
-       '[' INT '/' INT {
+       '[' unsigned '/' unsigned {
                $$ = BEAMPLET;
                THIS->plet_.type_i_ = $4;
                THIS->plet_.iso_i_ = $2;
                THIS->default_duration_.plet_.type_i_ = $4;
                THIS->default_duration_.plet_.iso_i_ = $2;
        }
-       | PLET INT '/' INT {
+       | PLET unsigned '/' unsigned {
                $$ = PLET;
                THIS->plet_.type_i_ = $4;
                THIS->plet_.iso_i_ = $2;
@@ -945,22 +951,29 @@ script_body:
        ;
 
 script_req:
-       script_dir gen_script_def               {
+       script_dir gen_script_def       {
                Musical_script_req *m = new Musical_script_req;
                $$ = m;
-               m-> scriptdef_p_ = $2;
-               m-> set_spot (THIS->here_input ());
-               m-> dir_  = $1;
+               m->scriptdef_p_ = $2;
+               m->set_spot (THIS->here_input ());
+               if (!m->dir_)
+                 m->dir_  = $1;
        }
        ;
 
 gen_script_def:
-       text_def        { $$ = $1;
+       text_def        { 
+               $$ = $1;
                ((Text_def*) $$)->align_i_ = CENTER; /* UGH */
        }
-       | mudela_script { $$ = $1;
+       | mudela_script { 
+               $$ = $1;
                $$-> set_spot (THIS->here_input ());
        }
+       | finger {
+               $$ = $1;
+               ((Text_def*)$$)->align_i_ = CENTER;
+       }
        ;
 
 text_def:
@@ -974,6 +987,16 @@ text_def:
        }
        ;
 
+finger:
+        DIGIT {
+               Text_def* t  = new Text_def;
+               $$ = t;
+               t->text_str_ = String ($1);
+               t->style_str_ = "finger";
+               $$->set_spot (THIS->here_input ());
+       }
+       ;
+
 script_abbreviation:
        '^'             { $$ = get_scriptdef ('^'); }
        | '+'           { $$ = get_scriptdef ('+'); }
@@ -997,8 +1020,8 @@ mudela_script:
 
 script_dir:
        '_'     { $$ = -1; }
-       |'^'    { $$ = 1; }
-       |'-'    { $$ = 0; }
+       | '^'   { $$ = 1; }
+       | '-'   { $$ = 0; }
        ;
 
 pre_requests:
@@ -1077,10 +1100,10 @@ notemode_duration:
        ;
 
 explicit_steno_duration:
-       int             {
+       unsigned                {
                $$ = new Duration;
                if (!Duration::duration_type_b ($1))
-                       THIS->parser_error ("Not a duration");
+                       THIS->parser_error ("2:Not a duration");
                else {
                        $$->durlog_i_ = Duration_convert::i2_type ($1);
                        $$->set_plet (THIS->default_duration_);
@@ -1092,10 +1115,10 @@ explicit_steno_duration:
        | explicit_steno_duration '.'   {
                $$->dots_i_ ++;
        }
-       | explicit_steno_duration '*' int  {
+       | explicit_steno_duration '*' unsigned  {
                $$->plet_.iso_i_ = $3;
        }
-       | explicit_steno_duration '/' int {
+       | explicit_steno_duration '/' unsigned {
                $$->plet_.type_i_ = $3;
        }
        ;
@@ -1105,9 +1128,9 @@ abbrev_type:
        ':'     {
                $$ =0;
        }
-       | ':' int {
+       | ':' unsigned {
                if (!Duration::duration_type_b ($2))
-                       THIS->parser_error ("Not a duration");
+                       THIS->parser_error ("3:Not a duration");
                else if ($2 < 8)
                        THIS->parser_error ("Can't abbreviate");
                $$ = $2;
@@ -1149,10 +1172,21 @@ pitch_list:                     {
        }
        ;
 
+unsigned:
+       UNSIGNED        {
+               $$ = $1;
+       }
+       | DIGIT {
+               $$ = $1;
+       };
+
 int:
-       INT                     {
+       unsigned {
                $$ = $1;
        }
+       | '-' unsigned {
+               $$ = -$2;
+       }
        | INT_IDENTIFIER        {
                int *i_p = $1->intid ();
                $$ = *i_p;
@@ -1160,7 +1194,6 @@ int:
        }
        ;
 
-
 real:
        REAL            {
                $$ = $1;
index 41f154ed92e2641d8061a05c22feda6a6e0e1fbb..d94a858634ecc83f7647a0a17145fc6245995f32 100644 (file)
@@ -9,6 +9,8 @@
 #include "plet-engraver.hh"
 #include "plet-spanner.hh"
 #include "text-def.hh"
+#include "beam.hh"
+#include "score-column.hh"
 #include "stem.hh"
 
 IMPLEMENT_IS_TYPE_B1 (Plet_engraver,Engraver);
@@ -16,6 +18,8 @@ ADD_THIS_TRANSLATOR (Plet_engraver);
 
 Plet_engraver::Plet_engraver ()
 {
+  beam_mom_drul_[LEFT] = span_mom_drul_[LEFT] = INT_MAX;
+  beam_mom_drul_[RIGHT] = span_mom_drul_[LEFT] = -INT_MAX;
   plet_spanner_p_ = 0;
   span_reqs_drul_[RIGHT] = span_reqs_drul_[LEFT] = 0;
 }
@@ -44,6 +48,17 @@ Plet_engraver::do_try_request (Request* req_l)
   if (!mus_l)
     return false;
 
+  Beam_req* b = mus_l->beam ();
+  if (b)
+    {
+      if (b->spantype)
+        {
+          Direction d = (Direction)(((int)(b->spantype - 1)) * 2 - 1);
+          beam_mom_drul_[d] = get_staff_info ().musical_l ()->when ();
+       }
+      return false;
+    }
+    
   Plet_req* p = mus_l->plet ();
   if (!p)
     return false;
@@ -56,6 +71,7 @@ Plet_engraver::do_try_request (Request* req_l)
     return false;
 
   span_reqs_drul_[d] = p;
+  span_mom_drul_[d] = get_staff_info ().musical_l ()->when ();
   return true;
 }
 
@@ -68,6 +84,7 @@ Plet_engraver::do_removal_processing ()
       plet_spanner_p_->unlink ();
       delete plet_spanner_p_;
       plet_spanner_p_ = 0;
+      span_reqs_drul_[RIGHT] = span_reqs_drul_[LEFT] = 0;
     }
 }
 
@@ -89,7 +106,19 @@ Plet_engraver::do_pre_move_processing ()
   if (!plet_spanner_p_ || !span_reqs_drul_[RIGHT]) 
     return;
 
-  typeset_element (plet_spanner_p_);
+  Scalar prop = get_property ("pletvisibility");
+  if (prop.isnum_b ()) 
+    plet_spanner_p_->visibility_i_ = prop;
+
+  if ((beam_mom_drul_[LEFT] <= span_mom_drul_[LEFT])
+     && (beam_mom_drul_[RIGHT] >= span_mom_drul_[RIGHT]))
+     plet_spanner_p_->visibility_i_ &= ~2;
+
+  if (plet_spanner_p_->visibility_i_)
+    typeset_element (plet_spanner_p_);
+  else
+    plet_spanner_p_->unlink ();
+
   plet_spanner_p_ = 0;
   span_reqs_drul_[RIGHT] = span_reqs_drul_[LEFT] = 0;
 }
index e68bc00079e91aa5e147eab2140748942655ed54..6eebc48f04ca0815f3e0f8e851bf275b4d54253f 100644 (file)
@@ -24,6 +24,7 @@ Plet_spanner::Plet_spanner ()
 {
   stem_l_drul_[RIGHT] =0;
   stem_l_drul_[LEFT] =0;
+  visibility_i_ = 3;
 
   tdef_p_ = new Text_def;
   tdef_p_->align_i_ = CENTER;
@@ -35,6 +36,7 @@ Plet_spanner::Plet_spanner (Plet_spanner const& c)
 {
   tdef_p_ = new Text_def (*c.tdef_p_);
   stem_l_drul_ = c.stem_l_drul_;
+  visibility_i_ = c.visibility_i_;
 }
 
 Plet_spanner::~Plet_spanner ()
@@ -46,6 +48,7 @@ Molecule*
 Plet_spanner::brew_molecule_p () const
 {
   Molecule* mol_p = new Molecule;
+
   Real w = width ().length ();
   
   Real dy_f = dy_f_drul_[RIGHT] - dy_f_drul_[LEFT];
@@ -55,14 +58,18 @@ Plet_spanner::brew_molecule_p () const
   Atom a = paper ()->lookup_l ()->plet (dy_f, w, dir_);
 
   a.translate (Offset (dx_f_drul_[LEFT], dy_f_drul_[LEFT]));
-  mol_p->add (a);
+
+  if (visibility_i_ >= 2)
+      mol_p->add (a);
 
   Real interline_f = paper ()->interline_f ();
   Real numy_f = (dir_ > 0 ? 0 : -interline_f) + dir_ * interline_f / 2;
   Atom num (tdef_p_->get_atom (paper (), CENTER));
   num.translate (Offset (width ().length ()/ 2 + dx_f_drul_[LEFT], 
     dy_f_drul_[LEFT] + dy_f / 2 + numy_f));
-  mol_p->add (num);
+
+  if (visibility_i_ >= 1)
+    mol_p->add (num);
 
   return mol_p;
 }
index 1e75aa83aec358037dd75034f44dc5464b33d715..b81f2f5f967b5b6610765076be035dd58ba607a1 100644 (file)
 #include "text-def.hh"
 #include "dimen.hh"
 
+Direction
+Text_def::staff_dir () const
+{
+  if (style_str_ == "finger")
+    return UP;
+  return DOWN;
+}
+
 Interval
 Text_def::width (Paper_def * p) const
 {