From 2c8f5bd808971408b3f7f872335c79a7fb6a9c25 Mon Sep 17 00:00:00 2001 From: fred Date: Sun, 24 Mar 2002 19:31:20 +0000 Subject: [PATCH] lilypond-0.0.30 --- Documentation/error.pod | 2 + Documentation/lilyinput.pod | 2 +- src/slur.cc | 20 ++++---- src/slurreg.cc | 91 +++++++++++++++++++++++++++++++++++++ src/texslur.cc | 48 ++++++++++--------- 5 files changed, 132 insertions(+), 31 deletions(-) create mode 100644 src/slurreg.cc diff --git a/Documentation/error.pod b/Documentation/error.pod index 1888beaf98..0a73c5b627 100644 --- a/Documentation/error.pod +++ b/Documentation/error.pod @@ -10,6 +10,8 @@ A correctly parsed F does not guarantuee output. A lot (most) of the checking is done B parsing (some checks even are done after the break calc!); I'm sorry. +[outdated] + The parser's job is to construct appropriate objects. It will B detect parse errors. diff --git a/Documentation/lilyinput.pod b/Documentation/lilyinput.pod index 6e08669071..dfdd597948 100644 --- a/Documentation/lilyinput.pod +++ b/Documentation/lilyinput.pod @@ -39,7 +39,7 @@ than in "command" mode, eg, identifier = score { .. } -So you have to signal that to the tokenizer. This is done with +So you have to signal this to the tokenizer. This is done with '$'. '$' is a delimiter, which used by the tokenizer only. The same goes for lyrics, it has a '@' delimiter. diff --git a/src/slur.cc b/src/slur.cc index 5b7f99d16e..856ca99035 100644 --- a/src/slur.cc +++ b/src/slur.cc @@ -12,10 +12,11 @@ #include "molecule.hh" #include "debug.hh" #include "boxes.hh" + NAME_METHOD(Slur); + Slur::Slur() { - dir = 0; open_right=open_left=false; } @@ -50,9 +51,9 @@ Slur::set_default_dir() /* should consult stems */ Real meanpos = sumpos/Real(encompass.size()); if (meanpos < 5) // todo - dir = -1; + dir_i_ = -1; else - dir = 1; + dir_i_ = 1; } void @@ -85,7 +86,8 @@ Slur::do_break_at(PCol*l, PCol*r) const void Slur::do_post_processing() { - set_default_dir(); + if (!dir_i_) + set_default_dir(); } Molecule* @@ -104,12 +106,12 @@ Slur::brew_molecule_p() const Notehead *rnote_p =encompass.top(); int lpos_i = lnote_p->position; int rpos_i = rnote_p->position; - Offset left_off(lnote_p->x_dir, lpos_i + 2*dir); - Offset right_off(lnote_p->x_dir, rpos_i + 2*dir); + Offset left_off(lnote_p->x_dir, lpos_i + 2*dir_i_); + Offset right_off(lnote_p->x_dir, rpos_i + 2*dir_i_); if (!lnote_p->extremal) - left_off += Offset(0.5, -dir); + left_off += Offset(0.5, -dir_i_); if (!rnote_p->extremal) - right_off+= Offset(-0.5, -dir); + right_off+= Offset(-0.5, -dir_i_); int dy = int(right_off.y - left_off.y); @@ -120,7 +122,7 @@ Slur::brew_molecule_p() const w+= (right_off.x - left_off.x) * nw_f ; Real round_w = w; // slur lookup rounds the slurwidth . - Symbol sl = paper()->lookup_p_->slur(dy , round_w, dir); + Symbol sl = paper()->lookup_p_->slur(dy , round_w, dir_i_); Real error = w-round_w; diff --git a/src/slurreg.cc b/src/slurreg.cc new file mode 100644 index 0000000000..05a7564490 --- /dev/null +++ b/src/slurreg.cc @@ -0,0 +1,91 @@ +/* + slurreg.cc -- implement Slur_register + + (c) 1997 Han-Wen Nienhuys +*/ + +#include "complexwalker.hh" +#include "slurreg.hh" +#include "slur.hh" +#include "debug.hh" +void +Slur_register::set_dir(int i) +{ + dir_i_ = i; +} + +Slur_register::Slur_register(Complex_walker* w) + : Request_register(w) +{ + set_dir(0); +} + +bool +Slur_register::try_request(Request *req_l) +{ + if(!req_l->slur()) + return false; + + accepted_req_arr_.push(req_l); + return true; +} + +void +Slur_register::acknowledge_element(Staff_elem_info info) +{ + if (info.elem_p_->name() == String("Notehead")) { + Notehead *head_p =(Notehead*) info.elem_p_ ;// ugh + for (int i = 0; i < slur_l_stack_.size(); i++) + slur_l_stack_[i]->add(head_p ); + for (int i = 0; i < end_slur_l_arr_.size(); i++) + end_slur_l_arr_[i]->add(head_p); + } +} +/* + abracadabra + */ +void +Slur_register::process_request() +{ + Array start_slur_l_arr_; + for (int i=0; i< accepted_req_arr_.size(); i++) { + Slur_req* slur_req_l = accepted_req_arr_[i]->slur(); + // end slur: move the slur to other array + if (slur_req_l->spantype == Span_req::STOP) { + if (slur_l_stack_.empty()) + warning("can't find slur to end", + slur_req_l->defined_ch_c_l_m); + else { + end_slur_l_arr_.push(slur_l_stack_.pop()); + requests_arr_.pop(); + } + } else if (slur_req_l->spantype == Span_req::START) { + // push a new slur onto stack. + //(use temp. array to wait for all slur STOPs) + Slur * s_p =new Slur; + requests_arr_.push(slur_req_l); + start_slur_l_arr_.push(s_p); + announce_element(Staff_elem_info(s_p, slur_req_l, this)); + } + } + for (int i=0; i < start_slur_l_arr_.size(); i++) + slur_l_stack_.push(start_slur_l_arr_[i]); +} + +void +Slur_register::do_pre_move_process() +{ + for (int i = 0; i < end_slur_l_arr_.size(); i++) { + if (dir_i_) + end_slur_l_arr_[i]->dir_i_ = dir_i_; + typeset_element(end_slur_l_arr_[i]); + } + end_slur_l_arr_.set_size(0); +} + +Slur_register::~Slur_register() +{ + for (int i=0; i < requests_arr_.size(); i++) { + warning("unterminated slur", requests_arr_[i]->defined_ch_c_l_m); + } +} diff --git a/src/texslur.cc b/src/texslur.cc index a3a29db444..71cded9529 100644 --- a/src/texslur.cc +++ b/src/texslur.cc @@ -28,9 +28,11 @@ char direction_char(int y_sign) Symbol Lookup::half_slur_middlepart(Real &dx, int dir) { - if (dx >= convert_dimen(400,"pt")) // todo - error ("halfslur too large"); - int widx = int(floor(dx / 4.0)); + if (dx >= 400 PT) {// todo + WARN<<"halfslur too large" <= convert_dimen(96,"pt")) { - WARN << "Slur half too wide."; - dx = convert_dimen(96,"pt"); + if (dx >= 96 PT) { + WARN << "Slur half too wide." << print_dimen(orig_dx) << " shrinking (ugh)\n"; + dx = 96 PT; } - + widx = int(rint(dx/12.0)); dx = widx*12.0; if (widx) widx --; else { - WARN << "slur too narrow\n"; + WARN << "slur too narrow " << print_dimen(orig_dx)<<"\n"; } Symbol s; @@ -109,36 +112,36 @@ Lookup::half_slur(int dy, Real &dx, int dir, int xpart) Symbol Lookup::slur (int dy , Real &dx, int dir) -{ // ugh. assuming pt here. - assert(dx >=0); +{ + assert(dx >=0 && abs(dir) <= 1); int y_sign = sign(dy); bool large = dy > 16; if (y_sign) { - large |= dx>= convert_dimen(4*16, "pt"); + large |= dx>= 4*16 PT; } else - large |= dx>= convert_dimen(4*54, "pt"); + large |= dx>= 4*54 PT; if (large) { return big_slur(dy, dx, dir); } - + Real orig_dx = dx; int widx = int(floor(dx/4.0)); // slurs better too small.. dx = 4.0 * widx; if (widx) widx --; else { - WARN << "slur too narrow\n"; + WARN << "slur too narrow: " << print_dimen(orig_dx) << "\n"; } int hidx = dy; if (hidx <0) hidx = -hidx; hidx --; - if (hidx > 16) - error("slur to steep"); - + if (hidx > 16) { + WARN<<"slur to steep: " << dy << " shrinking (ugh)\n"; + } Symbol s; s.dim.x = Interval(0,dx); @@ -152,8 +155,11 @@ Lookup::slur (int dy , Real &dx, int dir) if (dir < 0) idx += 128; } else { - if (dx >= convert_dimen(4*54, "pt")) - error("slur too wide"); + if (dx >= 4*54 PT) { + WARN << "slur too wide: " << print_dimen(dx) << + " shrinking (ugh)\n"; + dx = 4*54 PT; + } idx = widx; if (dir < 0) idx += 54; @@ -172,7 +178,7 @@ Lookup::slur (int dy , Real &dx, int dir) Symbol Lookup::big_slur(int dy , Real &dx, int dir) { - assert(dx >= convert_dimen(24,"pt")); + assert(dx >= 24 PT); Real slur_extra =abs(dy) /2.0 + 2; int l_dy = int(Real (dy)/2 + slur_extra*dir); int r_dy = dy - l_dy; -- 2.39.5