(most) of the checking is done B<after> 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<only>
detect parse errors.
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.
#include "molecule.hh"
#include "debug.hh"
#include "boxes.hh"
+
NAME_METHOD(Slur);
+
Slur::Slur()
{
- dir = 0;
open_right=open_left=false;
}
/* 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
void
Slur::do_post_processing()
{
- set_default_dir();
+ if (!dir_i_)
+ set_default_dir();
}
Molecule*
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);
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;
--- /dev/null
+/*
+ slurreg.cc -- implement Slur_register
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+#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<Slur*> 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);
+ }
+}
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" <<print_dimen(dx)<< "shrinking (ugh)\n";
+ dx = 400 PT;
+ }
+ int widx = int(floor(dx / 4.0));
dx = widx * 4.0;
if (widx) widx --;
else {
Symbol s;
- s.dim.y = Interval(min(0,0), max(0,0));
+ s.dim.y = Interval(min(0,0), max(0,0)); // todo
s.dim.x = Interval(0,dx);
String f = String("\\hslurchar");
Symbol
Lookup::half_slur(int dy, Real &dx, int dir, int xpart)
{
+ Real orig_dx = dx;
if (!xpart)
return half_slur_middlepart(dx, dir);
int widx;
- if (dx >= 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;
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);
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;
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;