2 tie.cc -- implement Tie
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1998 Han-Wen Nienhuys <hanwen@stack.nl>
9 #include "paper-def.hh"
11 #include "note-head.hh"
14 #include "main.hh" // experimental features
16 IMPLEMENT_IS_TYPE_B1(Tie,Bow);
19 Tie::set_head (Direction d, Note_head * head_l)
21 assert (!head_l_drul_[d]);
22 head_l_drul_[d] = head_l;
23 set_bounds (d, head_l);
25 add_dependency (head_l);
30 head_l_drul_[RIGHT] =0;
31 head_l_drul_[LEFT] =0;
37 ugh: direction of the Tie is more complicated. See [Ross] p136 and further
40 Tie::set_default_dir()
42 int m= (head_l_drul_[LEFT]->position_i_
43 + head_l_drul_[RIGHT]->position_i_) /2;
44 dir_ = (m < 0)? DOWN : UP;
48 Tie::do_add_processing()
50 if (!(head_l_drul_[LEFT] && head_l_drul_[RIGHT]))
51 warning (_("Lonely tie.. "));
54 Drul_array<Note_head *> new_head_drul = head_l_drul_;
57 new_head_drul[d] = head_l_drul_[(Direction)-d];
58 } while (flip(&d) != LEFT);
59 head_l_drul_ = new_head_drul;
63 Tie::do_post_processing()
65 assert (head_l_drul_[LEFT] || head_l_drul_[RIGHT]);
67 Real notewidth = paper ()->note_width ();
68 Real interline_f = paper ()->interline_f ();
69 Real tie_min = paper ()->get_var ("tie_x_minimum");
72 [OSU]: slur and tie placement
75 * x = inner raakpunt - d * gap
77 * y = length < 5ss : horizontal raakpunt
78 y = length >= 5ss : y next interline - d * 0.25 ss
79 --> height <= 5 length ?? we use <= 3 length, now...
82 Real gap_f = paper ()->get_var ("slur_x_gap");
87 dy_f_drul_[d] = .5 * interline_f * (head_l_drul_[d]
88 ? head_l_drul_[d]->position_i_
89 : head_l_drul_[(Direction)-d]->position_i_);
91 while (flip(&d) != LEFT);
95 // tie attached to outer notehead
96 if (head_l_drul_[d] && head_l_drul_[d]->extremal_i_)
99 dx_f_drul_[d] += notewidth;
100 dx_f_drul_[d] += -d * gap_f;
101 /* attach to outer 3/4 end of head */
102 dy_f_drul_[d] += dir_ * 0.25 * interline_f;
104 // tie attached to inner notehead
105 else if (head_l_drul_[d])
107 dx_f_drul_[d] += d*0.5 * notewidth;
109 // uhm? loose end of tie // tie attached to stem
112 dx_f_drul_[d] = -d * (spanned_drul_[d]->width ().length ()
116 while (flip(&d) != LEFT);
118 // now that both are set, do dependent
121 // tie attached to outer notehead
122 if (!head_l_drul_[d])
124 if (dx_f_drul_[RIGHT] - dx_f_drul_[LEFT] < tie_min)
126 dx_f_drul_[d] -= d * tie_min
127 - (dx_f_drul_[RIGHT] - dx_f_drul_[LEFT]);
128 dx_f_drul_[d] = dx_f_drul_[(Direction)-d] + d * tie_min;
131 dy_f_drul_[d] = dy_f_drul_[(Direction) -d];
134 while (flip(&d) != LEFT);
138 Tie::do_substitute_dependency (Score_elem*o, Score_elem*n)
140 Note_head *new_l =n?(Note_head*)n->item():0;
141 if (o->item() == head_l_drul_[LEFT])
142 head_l_drul_[LEFT] = new_l;
143 else if (o->item() == head_l_drul_[RIGHT])
144 head_l_drul_[RIGHT] = new_l;