2 tie.cc -- implement Tie
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
9 #include "paper-def.hh"
11 #include "note-head.hh"
17 Tie::set_head (Direction d, Note_head * head_l)
19 assert (!head_l_drul_[d]);
20 head_l_drul_[d] = head_l;
21 set_bounds (d, head_l);
23 add_dependency (head_l);
28 head_l_drul_[RIGHT] =0;
29 head_l_drul_[LEFT] =0;
35 ugh: direction of the Tie is more complicated. See [Ross] p136 and further
38 Tie::set_default_dir()
40 int m= (head_l_drul_[LEFT]->position_i_
41 + head_l_drul_[RIGHT]->position_i_) /2;
42 dir_ = (m < 0)? DOWN : UP;
46 Tie::do_add_processing()
48 if (!(head_l_drul_[LEFT] && head_l_drul_[RIGHT]))
49 warning (_("Lonely tie.. "));
52 Drul_array<Note_head *> new_head_drul = head_l_drul_;
55 new_head_drul[d] = head_l_drul_[(Direction)-d];
56 } while (flip(&d) != LEFT);
57 head_l_drul_ = new_head_drul;
61 Tie::do_post_processing()
63 Real nw_f = paper ()->note_width ();
64 Real interline_f = paper ()->interline_f ();
65 assert (head_l_drul_[LEFT] || head_l_drul_[RIGHT]);
68 [OSU]: slur and tie placement
71 * x = inner raakpunt - d * gap
73 * y = length < 5ss : horizontal raakpunt
74 y = length >= 5ss : y next interline - d * 0.25 ss
75 --> height <= 5 length ?? we use <= 3 length, now...
77 * suggested gap = ss / 5;
79 // jcn: 1/5 seems so small?
80 Real gap_f = interline_f / 2; // 5;
85 dy_f_drul_[d] = .5 * interline_f * (head_l_drul_[d]
86 ? head_l_drul_[d]->position_i_
87 : head_l_drul_[(Direction)-d]->position_i_);
89 while (flip(&d) != LEFT);
93 if (head_l_drul_[d] && head_l_drul_[d]->extremal_i_)
95 /* normal tie between noteheads, with gap of space */
96 dx_f_drul_[d] += -d * (0.5 * nw_f + gap_f);
97 /* attach to outer 3/4 end of head */
98 dy_f_drul_[d] += dir_ * 0.25 * interline_f;
100 else if (head_l_drul_[d])
102 dx_f_drul_[d] += d*0.5 * nw_f;
106 dy_f_drul_[d] = dy_f_drul_[(Direction) -d];
107 dx_f_drul_[d] = -d * (spanned_drul_[d]->width ().length ()
111 while (flip(&d) != LEFT);
115 Tie::do_substitute_dependency (Score_elem*o, Score_elem*n)
117 Note_head *new_l =n?(Note_head*)n->item():0;
118 if (o->item() == head_l_drul_[LEFT])
119 head_l_drul_[LEFT] = new_l;
120 else if (o->item() == head_l_drul_[RIGHT])
121 head_l_drul_[RIGHT] = new_l;
124 IMPLEMENT_IS_TYPE_B1(Tie,Bow);