From: fred Date: Tue, 26 Mar 2002 22:45:17 +0000 (+0000) Subject: lilypond-1.3.23 X-Git-Tag: release/1.5.59~1906 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=60cd19e2ff2700f4a6d964cb0f8db08227af56a7;p=lilypond.git lilypond-1.3.23 --- diff --git a/lib/include/input.hh b/lib/include/input.hh index 74ee72efe3..1c9e61ccbf 100644 --- a/lib/include/input.hh +++ b/lib/include/input.hh @@ -27,6 +27,7 @@ public: void set_spot (Input const &); Input spot () const; String location_str () const; + String line_number_str () const; Input (Source_file*, char const*); Input (); }; diff --git a/lib/input.cc b/lib/input.cc index db7c10ee1f..9413f7c49e 100644 --- a/lib/input.cc +++ b/lib/input.cc @@ -106,3 +106,11 @@ Input::location_str () const return "(" + _ ("position unknown") + ")"; } +String +Input::line_number_str () const +{ + if (source_file_l_) + return to_str (source_file_l_->line_i (defined_ch_C_)); + else + return "?"; +} diff --git a/lily/command-request.cc b/lily/command-request.cc index 6975762e3e..e73c253d89 100644 --- a/lily/command-request.cc +++ b/lily/command-request.cc @@ -122,16 +122,20 @@ Break_req::Break_req () { } -Mark_req::Mark_req (String s) -{ - str_ = s; -} void Mark_req::do_print () const { DEBUG_OUT << str_; } + +bool +Mark_req::do_equal_b (Request const * r) const +{ + Mark_req const * other = dynamic_cast (r); + return other && other->str_ == str_; +} + void Key_change_req::transpose (Musical_pitch p) { diff --git a/lily/dynamic-engraver.cc b/lily/dynamic-engraver.cc index 5f42b8ba80..c6c35a908f 100644 --- a/lily/dynamic-engraver.cc +++ b/lily/dynamic-engraver.cc @@ -42,6 +42,7 @@ protected: virtual void do_process_requests(); virtual void do_pre_move_processing(); virtual void do_post_move_processing(); + virtual void typeset_element (Score_element*); }; @@ -114,7 +115,6 @@ Dynamic_engraver::do_process_requests() text_p_->set_elt_property ("style", gh_str02scm ("dynamic")); text_p_->set_elt_property ("script-priority", gh_int2scm (100)); - text_p_->set_elt_property ("staff-support", SCM_BOOL_T); Side_position_interface (text_p_).set_axis (Y_AXIS); @@ -170,10 +170,7 @@ Dynamic_engraver::do_process_requests() ->set_elt_property ("grow-direction", gh_int2scm ((span_l->span_type_str_ == "crescendo") ? BIGGER : SMALLER)); - new_cresc_p->set_elt_property ("staff-support", SCM_BOOL_T); - - - Side_position_interface (new_cresc_p).set_axis (Y_AXIS); + side_position (new_cresc_p).set_axis (Y_AXIS); announce_element (Score_element_info (new_cresc_p, span_l)); } } @@ -185,7 +182,6 @@ Dynamic_engraver::do_process_requests() { ::warning (_ ("Too many crescendi here")); - typeset_element (cresc_p_); cresc_p_ = 0; @@ -247,6 +243,12 @@ Dynamic_engraver::typeset_all () } } +void +Dynamic_engraver::typeset_element (Score_element * e) +{ + side_position(e).add_staff_support (); + Engraver::typeset_element (e); +} void Dynamic_engraver::acknowledge_element (Score_element_info i) diff --git a/lily/include/command-request.hh b/lily/include/command-request.hh index 3bb3474ac0..c1efa26c43 100644 --- a/lily/include/command-request.hh +++ b/lily/include/command-request.hh @@ -26,9 +26,9 @@ protected: class Mark_req : public Request { public: - Mark_req (String); String str_; protected: + virtual bool do_equal_b (Request const*) const; virtual void do_print () const; VIRTUAL_COPY_CONS(Music); }; diff --git a/lily/include/musical-request.hh b/lily/include/musical-request.hh index 37f3d6ad09..dbabc86edd 100644 --- a/lily/include/musical-request.hh +++ b/lily/include/musical-request.hh @@ -135,22 +135,6 @@ public: VIRTUAL_COPY_CONS(Music); }; -/** - Part: typeset a measure with the number of measures rest - Score: typeset all individual measures as full rests - */ -class Multi_measure_rest_req : public Rhythmic_req { -public: - VIRTUAL_COPY_CONS(Music); -}; - -/** - Typeset a repetition sign in each bar. - */ -class Repetitions_req : public Rhythmic_req { -public: - VIRTUAL_COPY_CONS(Music); -}; /// an extender line class Extender_req : public Request { diff --git a/lily/include/side-position-interface.hh b/lily/include/side-position-interface.hh index cfa65ffec0..b3a37ae708 100644 --- a/lily/include/side-position-interface.hh +++ b/lily/include/side-position-interface.hh @@ -29,11 +29,13 @@ public: bool supported_b () const; bool has_interface_b () const; void add_support (Score_element*); - + + void add_staff_support (); Direction get_direction () const; void set_direction (Direction); }; +Side_position_interface side_position (Score_element*); #endif /* SIDE_POSITION_INTERFACE_HH */ diff --git a/lily/line-number-engraver.cc b/lily/line-number-engraver.cc new file mode 100644 index 0000000000..fc9f639367 --- /dev/null +++ b/lily/line-number-engraver.cc @@ -0,0 +1,101 @@ +/* + line-number-engraver.cc -- implement Line_number_engraver + + source file of the GNU LilyPond music typesetter + + (c) 2000 Han-Wen Nienhuys + + */ + +#include "engraver.hh" +#include "text-item.hh" +#include "side-position-interface.hh" +#include "note-head.hh" +#include "stem.hh" + +/** + Annotate output with line numbers. Creates text-items when it + catches note heads. */ +class Line_number_engraver : public Engraver +{ + Array interesting_; + Link_array support_; + Item * text_item_p_; + String last_text_; +public: + Line_number_engraver (); + VIRTUAL_COPY_CONS (Translator); +protected: + virtual void do_pre_move_processing (); + virtual void acknowledge_element (Score_element_info); + virtual void process_acknowledged (); +}; + +void +Line_number_engraver::process_acknowledged () +{ + if (!text_item_p_ && interesting_.size ()) + { + text_item_p_ = new Text_item; + Side_position_interface si (text_item_p_); + si.set_axis (Y_AXIS); + text_item_p_->set_parent (interesting_[0].elem_l_, Y_AXIS); + + si.set_direction (UP); + announce_element (Score_element_info (text_item_p_, 0)); + } +} + +void +Line_number_engraver::acknowledge_element (Score_element_info inf) +{ + if (dynamic_cast (inf.elem_l_)) + { + interesting_.push (inf); + support_.push (inf.elem_l_); + } + if (dynamic_cast (inf.elem_l_)) + { + support_.push (inf.elem_l_); + } +} + +void +Line_number_engraver::do_pre_move_processing () +{ + if (text_item_p_) + { + String s; + Side_position_interface si (text_item_p_); + for (int i=0; i < interesting_.size (); i++) + { + if (i) + s += ","; + + s += interesting_[i].req_l_->line_number_str (); + + } + + for (int j= support_.size (); j--; ) + { + si.add_support (support_[j]); + } + if (s != last_text_) + { + text_item_p_->set_elt_property ("text", ly_str02scm (s.ch_C())); + last_text_ =s; + } + + typeset_element (text_item_p_); + text_item_p_ =0; + } + interesting_.clear (); + support_.clear (); +} + +Line_number_engraver::Line_number_engraver () +{ + text_item_p_ =0; +} + +ADD_THIS_TRANSLATOR(Line_number_engraver); diff --git a/lily/mark-engraver.cc b/lily/mark-engraver.cc index 92752b2d9b..6e9dbfdb24 100644 --- a/lily/mark-engraver.cc +++ b/lily/mark-engraver.cc @@ -33,6 +33,11 @@ Mark_engraver::do_try_music (Music* r_l) { if (Mark_req *mr = dynamic_cast (r_l)) { + + if (mark_req_l_ && mr->equal_b (mark_req_l_)) + return true; + if (mark_req_l_) + return false; mark_req_l_ = mr; return true; } diff --git a/lily/multi-measure-rest-engraver.cc b/lily/multi-measure-rest-engraver.cc index 7ac5c3791f..4427d7aa9a 100644 --- a/lily/multi-measure-rest-engraver.cc +++ b/lily/multi-measure-rest-engraver.cc @@ -22,7 +22,6 @@ class Multi_measure_rest_engraver : public Engraver { public: VIRTUAL_COPY_CONS(Translator); - Multi_measure_rest_engraver (); protected: @@ -31,14 +30,16 @@ protected: virtual bool do_try_music (Music*); virtual void do_pre_move_processing (); virtual void do_post_move_processing (); - + virtual void do_removal_processing (); private: - Drul_array rest_moments_; - + Span_req * new_req_l_; + Span_req * busy_span_req_l_; + Span_req * stop_req_l_; int start_measure_i_; - Rhythmic_req* multi_measure_req_l_; - Multi_measure_rest* mmrest_p_; - Multi_measure_rest* lastrest_p_; + Moment start_moment_; + + Multi_measure_rest *mmrest_p_; + Multi_measure_rest *lastrest_p_; }; ADD_THIS_TRANSLATOR (Multi_measure_rest_engraver); @@ -46,12 +47,8 @@ ADD_THIS_TRANSLATOR (Multi_measure_rest_engraver); Multi_measure_rest_engraver::Multi_measure_rest_engraver () { start_measure_i_ = 0; - rest_moments_[START] = - rest_moments_[STOP] =0; - multi_measure_req_l_ = 0; - - lastrest_p_ =0; - mmrest_p_ = 0; + mmrest_p_ = lastrest_p_ =0; + new_req_l_ = busy_span_req_l_ = stop_req_l_ =0; } void @@ -59,7 +56,7 @@ Multi_measure_rest_engraver::acknowledge_element (Score_element_info i) { if (Bar *c = dynamic_cast (i.elem_l_)) { - if (mmrest_p_) + if (mmrest_p_) mmrest_p_->add_column (c); if (lastrest_p_) lastrest_p_->add_column (c); @@ -69,36 +66,49 @@ Multi_measure_rest_engraver::acknowledge_element (Score_element_info i) bool Multi_measure_rest_engraver::do_try_music (Music* req_l) { - Rhythmic_req *r=0; - if (Multi_measure_rest_req *mr = - dynamic_cast (req_l)) - r=mr; - else if (Repetitions_req *rr = - dynamic_cast (req_l)) - r=rr; - if (r) + if (Span_req * sp = dynamic_cast (req_l)) { - if (multi_measure_req_l_) - if (!multi_measure_req_l_->equal_b (r) - || rest_moments_[START] != now_mom ()) - return false; - - multi_measure_req_l_ = r; - rest_moments_[START] = now_mom (); - - rest_moments_[STOP] = rest_moments_[START] + - multi_measure_req_l_->duration_.length_mom (); - return true; + if (sp->span_type_str_ == "rest") + { + if (sp->span_dir_ == STOP) + { + stop_req_l_ = sp; + } + else if (sp->span_dir_ == START && !new_req_l_) + { + new_req_l_ = sp; + } + return true; + } } return false; } + + void Multi_measure_rest_engraver::do_process_requests () { - if (multi_measure_req_l_ && !mmrest_p_) + if (new_req_l_ && stop_req_l_) + stop_req_l_ = 0; + + if (new_req_l_) + start_moment_ = now_mom (); + + if (stop_req_l_) + { + busy_span_req_l_ =0; + stop_req_l_ = 0; + } + + if (new_req_l_) { + busy_span_req_l_ = new_req_l_; + new_req_l_ =0; + } + if (busy_span_req_l_ && !mmrest_p_) + { Translator * tr = daddy_grav_l()->get_simple_translator ("Timing_engraver"); // ugh Timing_translator * time = dynamic_cast (tr); @@ -106,14 +116,7 @@ Multi_measure_rest_engraver::do_process_requests () Staff_symbol_referencer_interface si (mmrest_p_); si.set_interface (); - - /* - UGH. JUNKME - */ - if(dynamic_cast (multi_measure_req_l_)) - mmrest_p_->set_elt_property ("alt-symbol", - ly_str02scm ("scripts-repeatsign")); - announce_element (Score_element_info (mmrest_p_, multi_measure_req_l_)); + announce_element (Score_element_info (mmrest_p_, busy_span_req_l_)); start_measure_i_ = gh_scm2int (time->get_property ("currentBarNumber", 0)); } @@ -126,8 +129,7 @@ Multi_measure_rest_engraver::do_pre_move_processing () Translator * tr = daddy_grav_l()->get_simple_translator ("Timing_engraver"); // ugh Timing_translator * time = dynamic_cast (tr); - - if (mmrest_p_ && (now >= rest_moments_[START]) + if (mmrest_p_ && (now >= start_moment_) && !time->measure_position () && (scm_ilength (mmrest_p_->get_elt_property ("columns")) >= 2)) { @@ -141,6 +143,13 @@ Multi_measure_rest_engraver::do_pre_move_processing () typeset_element (lastrest_p_); lastrest_p_ = 0; } + + if (new_req_l_) + { + busy_span_req_l_ = new_req_l_; + new_req_l_ =0; + } + } void @@ -158,12 +167,14 @@ Multi_measure_rest_engraver::do_post_move_processing () = gh_scm2int (time->get_property ("currentBarNumber", 0)) - start_measure_i_; mmrest_p_ = 0; } - - if (now >= rest_moments_[STOP]) - { - multi_measure_req_l_ = 0; - mmrest_p_ = 0; - } } +void +Multi_measure_rest_engraver::do_removal_processing () +{ + if (mmrest_p_) + typeset_element (mmrest_p_); + if (lastrest_p_) + typeset_element (lastrest_p_); +} diff --git a/lily/my-lily-lexer.cc b/lily/my-lily-lexer.cc index 211a6b8c47..f748aa4d33 100644 --- a/lily/my-lily-lexer.cc +++ b/lily/my-lily-lexer.cc @@ -25,6 +25,7 @@ static Keyword_ent the_key_tab[]={ {"autochange", AUTOCHANGE}, {"spanrequest", SPANREQUEST}, + {"commandspanrequest", COMMANDSPANREQUEST}, {"simultaneous", SIMULTANEOUS}, {"sequential", SEQUENTIAL}, {"accepts", ACCEPTS}, diff --git a/lily/parser.yy b/lily/parser.yy index 606d9a3f17..6b11c89d04 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -179,6 +179,7 @@ yylex (YYSTYPE *s, void * v_l) %token SCRIPT %token SKIP %token SPANREQUEST +%token COMMANDSPANREQUEST %token TEMPO %token TIME_T %token TIMES @@ -873,10 +874,14 @@ scalar: request_chord: pre_requests simple_element post_requests { Music_sequence *l = dynamic_cast($2); - for (int i=0; i < $1->size(); i++) - l->add_music ($1->elem(i)); - for (int i=0; i < $3->size(); i++) - l->add_music ($3->elem(i)); + if (l) { + for (int i=0; i < $1->size(); i++) + l->add_music ($1->elem(i)); + for (int i=0; i < $3->size(); i++) + l->add_music ($3->elem(i)); + } + else + programming_error ("Need Sequence to add music to"); $$ = $2; } @@ -962,15 +967,27 @@ abbrev_command_req: verbose_command_req: + BAR STRING { $$ = new Bar_req (ly_scm2string ($2)); } + | COMMANDSPANREQUEST int STRING { + Span_req * sp_p = new Span_req; + sp_p-> span_dir_ = Direction($2); + sp_p->span_type_str_ = ly_scm2string ($3); + sp_p->set_spot (THIS->here_input ()); + $$ = sp_p; + } | MARK STRING { - $$ = new Mark_req (ly_scm2string ($2)); + Mark_req *m = new Mark_req; + m->str_ = ly_scm2string ($2); + $$ = m; } | MARK unsigned { - $$ = new Mark_req (to_str ($2)); + Mark_req *m = new Mark_req; + m->str_ = to_str ($2); + $$ = m; } | TIME_T unsigned '/' unsigned { Time_signature_change_req *m = new Time_signature_change_req; @@ -1013,7 +1030,6 @@ verbose_command_req: $$ = key_p; delete $2; } - ; post_requests: @@ -1367,9 +1383,7 @@ simple_element: Note_req *n = new Note_req; n->pitch_ = *$1; - delete $1; n->duration_ = *$4; - delete $4; if (THIS->abbrev_beam_type_i_) { if (n->duration_.plet_b ()) @@ -1381,58 +1395,63 @@ simple_element: n->forceacc_b_ = $2 % 2 || n->cautionary_b_; Simultaneous_music*v = new Request_chord; - v->set_spot (THIS->here_input ()); - n->set_spot (THIS->here_input ()); + v->set_spot ($1->spot ()); + n->set_spot ($1->spot ()); v->add_music (n); $$ = v; - } - | RESTNAME optional_notemode_duration { - Simultaneous_music* velt_p = new Request_chord; - velt_p->set_spot (THIS->here_input()); - if (ly_scm2string ($1) =="s") - { /* Space */ - Skip_req * skip_p = new Skip_req; - skip_p->duration_ = *$2; + delete $1; + delete $4; - skip_p->set_spot (THIS->here_input()); - velt_p->add_music (skip_p); - } - else - { - Rest_req * rest_req_p = new Rest_req; - rest_req_p->duration_ = *$2; - rest_req_p->set_spot (THIS->here_input()); + } + | RESTNAME optional_notemode_duration { + Simultaneous_music* velt_p = new Request_chord; + velt_p->set_spot (THIS->here_input()); - velt_p->add_music (rest_req_p); - } + if (ly_scm2string ($1) =="s") + { /* Space */ + Skip_req * skip_p = new Skip_req; + skip_p->duration_ = *$2; - delete $2; - $$ = velt_p; + skip_p->set_spot (THIS->here_input()); + velt_p->add_music (skip_p); + } + else + { + Rest_req * rest_req_p = new Rest_req; + rest_req_p->duration_ = *$2; + rest_req_p->set_spot (THIS->here_input()); + velt_p->add_music (rest_req_p); + } + delete $2; + $$ = velt_p; } | MEASURES optional_notemode_duration { - Multi_measure_rest_req* m = new Multi_measure_rest_req; - m->duration_ = *$2; - delete $2; - - Simultaneous_music*velt_p = new Request_chord; - velt_p->set_spot (THIS->here_input ()); - velt_p->add_music (m); - $$ = velt_p; - } - | REPETITIONS optional_notemode_duration { - Repetitions_req* r = new Repetitions_req; - r->duration_ = *$2; - delete $2; + Skip_req * sk = new Skip_req; + sk->duration_ = *$2; + Music_list * ms = new Music_list; + Request_chord * rqc1 = new Request_chord; + Request_chord * rqc2 = new Request_chord; + Request_chord * rqc3 = new Request_chord; + + Span_req *sp1 = new Span_req; + Span_req *sp2 = new Span_req; + sp1-> span_dir_ = START; + sp2-> span_dir_ = STOP; + sp1->span_type_str_ = sp2->span_type_str_ = "rest"; + rqc1->add_music (sp1); + rqc2->add_music (sk); + rqc3->add_music (sp2); + + ms->add_music (rqc1); + ms->add_music (rqc2); + ms->add_music (rqc3); - Simultaneous_music*velt_p = new Request_chord; - velt_p->set_spot (THIS->here_input ()); - velt_p->add_music (r); - $$ = velt_p; + $$ = new Sequential_music (ms); } | STRING optional_notemode_duration { if (!THIS->lexer_p_->lyric_state_b ()) diff --git a/lily/script-engraver.cc b/lily/script-engraver.cc index 0e6fe2433d..65ca2915be 100644 --- a/lily/script-engraver.cc +++ b/lily/script-engraver.cc @@ -4,7 +4,7 @@ (c) 1997--2000 Han-Wen Nienhuys */ -#include "script-engraver.hh" + #include "script.hh" #include "side-position-interface.hh" #include "musical-request.hh" @@ -13,6 +13,25 @@ #include "rhythmic-head.hh" #include "dimension-cache.hh" +#include "engraver.hh" + +class Script_engraver : public Engraver { + Link_array