Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1)

Delta Between Two Patch Sets: lily/dynamic-engraver.cc

Issue 573670043: Refactor get/set_property to take the item as first argument
Left Patch Set: Created 4 years, 11 months ago
Right Patch Set: Manual completion of patch set Created 4 years, 11 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « lily/dynamic-align-engraver.cc ('k') | lily/dynamic-performer.cc » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 /* 1 /*
2 This file is part of LilyPond, the GNU music typesetter. 2 This file is part of LilyPond, the GNU music typesetter.
3 3
4 Copyright (C) 2008--2020 Han-Wen Nienhuys <hanwen@lilypond.org> 4 Copyright (C) 2008--2020 Han-Wen Nienhuys <hanwen@lilypond.org>
5 5
6 LilyPond is free software: you can redistribute it and/or modify 6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or 8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 void 75 void
76 Dynamic_engraver::listen_absolute_dynamic (Stream_event *ev) 76 Dynamic_engraver::listen_absolute_dynamic (Stream_event *ev)
77 { 77 {
78 ASSIGN_EVENT_ONCE (script_event_, ev); 78 ASSIGN_EVENT_ONCE (script_event_, ev);
79 } 79 }
80 80
81 void 81 void
82 Dynamic_engraver::listen_span_dynamic (Stream_event *ev) 82 Dynamic_engraver::listen_span_dynamic (Stream_event *ev)
83 { 83 {
84 Direction d = to_dir (ev->get_property ("span-direction")); 84 Direction d = to_dir (get_property (ev, "span-direction"));
85 85
86 ASSIGN_EVENT_ONCE (accepted_spanevents_drul_[d], ev); 86 ASSIGN_EVENT_ONCE (accepted_spanevents_drul_[d], ev);
87 } 87 }
88 88
89 void 89 void
90 Dynamic_engraver::listen_break_span (Stream_event *event) 90 Dynamic_engraver::listen_break_span (Stream_event *event)
91 { 91 {
92 if (event->in_event_class ("break-dynamic-span-event")) 92 if (event->in_event_class ("break-dynamic-span-event"))
93 { 93 {
94 // Case 1: Already have a start dynamic event -> break applies to new 94 // Case 1: Already have a start dynamic event -> break applies to new
95 // spanner (created later) -> set a flag 95 // spanner (created later) -> set a flag
96 // Case 2: no new spanner, but spanner already active -> break it now 96 // Case 2: no new spanner, but spanner already active -> break it now
97 if (accepted_spanevents_drul_[START]) 97 if (accepted_spanevents_drul_[START])
98 end_new_spanner_ = true; 98 end_new_spanner_ = true;
99 else if (current_spanner_) 99 else if (current_spanner_)
100 current_spanner_->set_property ("spanner-broken", SCM_BOOL_T); 100 set_property (current_spanner_, "spanner-broken", SCM_BOOL_T);
101 } 101 }
102 } 102 }
103 103
104 SCM 104 SCM
105 Dynamic_engraver::get_property_setting (Stream_event *evt, 105 Dynamic_engraver::get_property_setting (Stream_event *evt,
106 char const *evprop, 106 char const *evprop,
107 char const *ctxprop) 107 char const *ctxprop)
108 { 108 {
109 SCM spanner_type = evt->get_property (evprop); 109 SCM spanner_type = get_property (evt, evprop);
110 if (scm_is_null (spanner_type)) 110 if (scm_is_null (spanner_type))
111 spanner_type = get_property (ctxprop); 111 spanner_type = get_property (this, ctxprop);
112 return spanner_type; 112 return spanner_type;
113 } 113 }
114 114
115 void 115 void
116 Dynamic_engraver::process_music () 116 Dynamic_engraver::process_music ()
117 { 117 {
118 if (current_spanner_ 118 if (current_spanner_
119 && (accepted_spanevents_drul_[STOP] 119 && (accepted_spanevents_drul_[STOP]
120 || script_event_ 120 || script_event_
121 || accepted_spanevents_drul_[START])) 121 || accepted_spanevents_drul_[START]))
(...skipping 21 matching lines...) Expand all
143 143
144 if (scm_is_eq (cresc_type, ly_symbol2scm ("text"))) 144 if (scm_is_eq (cresc_type, ly_symbol2scm ("text")))
145 { 145 {
146 current_spanner_ 146 current_spanner_
147 = make_spanner ("DynamicTextSpanner", 147 = make_spanner ("DynamicTextSpanner",
148 accepted_spanevents_drul_[START]->self_scm ()); 148 accepted_spanevents_drul_[START]->self_scm ());
149 149
150 SCM text = get_property_setting (current_span_event_, "span-text", 150 SCM text = get_property_setting (current_span_event_, "span-text",
151 (start_type + "Text").c_str ()); 151 (start_type + "Text").c_str ());
152 if (Text_interface::is_markup (text)) 152 if (Text_interface::is_markup (text))
153 current_spanner_->set_property ("text", text); 153 set_property (current_spanner_, "text", text);
154 /* 154 /*
155 If the line of a text spanner is hidden, end the alignment spanner 155 If the line of a text spanner is hidden, end the alignment spanner
156 early: this allows dynamics to be spaced individually instead of 156 early: this allows dynamics to be spaced individually instead of
157 being linked together. 157 being linked together.
158 */ 158 */
159 if (scm_is_eq (current_spanner_->get_property ("style"), 159 if (scm_is_eq (get_property (current_spanner_, "style"),
160 ly_symbol2scm ("none"))) 160 ly_symbol2scm ("none")))
161 current_spanner_->set_property ("spanner-broken", SCM_BOOL_T); 161 set_property (current_spanner_, "spanner-broken", SCM_BOOL_T);
162 } 162 }
163 else 163 else
164 { 164 {
165 if (!scm_is_eq (cresc_type, ly_symbol2scm ("hairpin"))) 165 if (!scm_is_eq (cresc_type, ly_symbol2scm ("hairpin")))
166 { 166 {
167 string as_string = ly_scm_write_string (cresc_type); 167 string as_string = ly_scm_write_string (cresc_type);
168 current_span_event_ 168 current_span_event_
169 ->origin ()->warning (_f ("unknown crescendo style: %s\ndefaulting to hairpin.", as_string.c_str ())); 169 ->origin ()->warning (_f ("unknown crescendo style: %s\ndefaulting to hairpin.", as_string.c_str ()));
170 } 170 }
171 current_spanner_ = make_spanner ("Hairpin", 171 current_spanner_ = make_spanner ("Hairpin",
172 current_span_event_->self_scm ()); 172 current_span_event_->self_scm ());
173 } 173 }
174 // if we have a break-dynamic-span event right after the start dynamic, br eak the new spanner immediately 174 // if we have a break-dynamic-span event right after the start dynamic, br eak the new spanner immediately
175 if (end_new_spanner_) 175 if (end_new_spanner_)
176 { 176 {
177 current_spanner_->set_property ("spanner-broken", SCM_BOOL_T); 177 set_property (current_spanner_, "spanner-broken", SCM_BOOL_T);
178 end_new_spanner_ = false; 178 end_new_spanner_ = false;
179 } 179 }
180 if (finished_spanner_) 180 if (finished_spanner_)
181 { 181 {
182 if (has_interface<Hairpin> (finished_spanner_)) 182 if (has_interface<Hairpin> (finished_spanner_))
183 Pointer_group_interface::add_grob (finished_spanner_, 183 Pointer_group_interface::add_grob (finished_spanner_,
184 ly_symbol2scm ("adjacent-spanners "), 184 ly_symbol2scm ("adjacent-spanners "),
185 current_spanner_); 185 current_spanner_);
186 if (has_interface<Hairpin> (current_spanner_)) 186 if (has_interface<Hairpin> (current_spanner_))
187 Pointer_group_interface::add_grob (current_spanner_, 187 Pointer_group_interface::add_grob (current_spanner_,
188 ly_symbol2scm ("adjacent-spanners "), 188 ly_symbol2scm ("adjacent-spanners "),
189 finished_spanner_); 189 finished_spanner_);
190 } 190 }
191 } 191 }
192 192
193 if (script_event_) 193 if (script_event_)
194 { 194 {
195 script_ = make_item ("DynamicText", script_event_->self_scm ()); 195 script_ = make_item ("DynamicText", script_event_->self_scm ());
196 script_->set_property ("text", 196 set_property (script_, "text",
197 script_event_->get_property ("text")); 197 get_property (script_event_, "text"));
198 198
199 if (finished_spanner_) 199 if (finished_spanner_)
200 finished_spanner_->set_bound (RIGHT, script_); 200 finished_spanner_->set_bound (RIGHT, script_);
201 if (current_spanner_) 201 if (current_spanner_)
202 current_spanner_->set_bound (LEFT, script_); 202 current_spanner_->set_bound (LEFT, script_);
203 } 203 }
204 } 204 }
205 205
206 void 206 void
207 Dynamic_engraver::stop_translation_timestep () 207 Dynamic_engraver::stop_translation_timestep ()
208 { 208 {
209 if (finished_spanner_ && !finished_spanner_->get_bound (RIGHT)) 209 if (finished_spanner_ && !finished_spanner_->get_bound (RIGHT))
210 finished_spanner_ 210 finished_spanner_
211 ->set_bound (RIGHT, 211 ->set_bound (RIGHT,
212 unsmob<Grob> (get_property ("currentMusicalColumn"))); 212 unsmob<Grob> (get_property (this, "currentMusicalColumn")));
213 213
214 if (current_spanner_ && !current_spanner_->get_bound (LEFT)) 214 if (current_spanner_ && !current_spanner_->get_bound (LEFT))
215 current_spanner_ 215 current_spanner_
216 ->set_bound (LEFT, 216 ->set_bound (LEFT,
217 unsmob<Grob> (get_property ("currentMusicalColumn"))); 217 unsmob<Grob> (get_property (this, "currentMusicalColumn")));
218 script_ = 0; 218 script_ = 0;
219 script_event_ = 0; 219 script_event_ = 0;
220 accepted_spanevents_drul_.set (0, 0); 220 accepted_spanevents_drul_.set (0, 0);
221 finished_spanner_ = 0; 221 finished_spanner_ = 0;
222 end_new_spanner_ = false; 222 end_new_spanner_ = false;
223 } 223 }
224 224
225 void 225 void
226 Dynamic_engraver::finalize () 226 Dynamic_engraver::finalize ()
227 { 227 {
228 if (current_spanner_ 228 if (current_spanner_
229 && !current_spanner_->is_live ()) 229 && !current_spanner_->is_live ())
230 current_spanner_ = 0; 230 current_spanner_ = 0;
231 if (current_spanner_) 231 if (current_spanner_)
232 { 232 {
233 current_span_event_ 233 current_span_event_
234 ->origin ()->warning (_f ("unterminated %s", 234 ->origin ()->warning (_f ("unterminated %s",
235 get_spanner_type (current_span_event_) 235 get_spanner_type (current_span_event_)
236 .c_str ())); 236 .c_str ()));
237 current_spanner_->suicide (); 237 current_spanner_->suicide ();
238 current_spanner_ = 0; 238 current_spanner_ = 0;
239 } 239 }
240 } 240 }
241 241
242 string 242 string
243 Dynamic_engraver::get_spanner_type (Stream_event *ev) 243 Dynamic_engraver::get_spanner_type (Stream_event *ev)
244 { 244 {
245 string type; 245 string type;
246 SCM start_sym = scm_car (ev->get_property ("class")); 246 SCM start_sym = scm_car (get_property (ev, "class"));
247 247
248 if (scm_is_eq (start_sym, ly_symbol2scm ("decrescendo-event"))) 248 if (scm_is_eq (start_sym, ly_symbol2scm ("decrescendo-event")))
249 type = "decrescendo"; 249 type = "decrescendo";
250 else if (scm_is_eq (start_sym, ly_symbol2scm ("crescendo-event"))) 250 else if (scm_is_eq (start_sym, ly_symbol2scm ("crescendo-event")))
251 type = "crescendo"; 251 type = "crescendo";
252 else 252 else
253 programming_error ("unknown dynamic spanner type"); 253 programming_error ("unknown dynamic spanner type");
254 254
255 return type; 255 return type;
256 } 256 }
257 257
258 void 258 void
259 Dynamic_engraver::acknowledge_note_column (Grob_info info) 259 Dynamic_engraver::acknowledge_note_column (Grob_info info)
260 { 260 {
261 if (script_ && !script_->get_parent (X_AXIS)) 261 if (script_ && !script_->get_parent (X_AXIS))
262 { 262 {
263 extract_grob_set (info.grob (), "note-heads", heads); 263 extract_grob_set (info.grob (), "note-heads", heads);
264 /* 264 /*
265 Spacing constraints may require dynamics to be attached to rests, 265 Spacing constraints may require dynamics to be attached to rests,
266 so check for a rest if this note column has no note heads. 266 so check for a rest if this note column has no note heads.
267 */ 267 */
268 Grob *x_parent = (heads.size () 268 Grob *x_parent = (heads.size ()
269 ? info.grob () 269 ? info.grob ()
270 : unsmob<Grob> (info.grob ()->get_object ("rest"))); 270 : unsmob<Grob> (get_object (info.grob (), "rest")));
271 if (x_parent) 271 if (x_parent)
272 script_->set_parent (x_parent, X_AXIS); 272 script_->set_parent (x_parent, X_AXIS);
273 } 273 }
274 274
275 if (current_spanner_ && !current_spanner_->get_bound (LEFT)) 275 if (current_spanner_ && !current_spanner_->get_bound (LEFT))
276 current_spanner_->set_bound (LEFT, info.grob ()); 276 current_spanner_->set_bound (LEFT, info.grob ());
277 if (finished_spanner_ && !finished_spanner_->get_bound (RIGHT)) 277 if (finished_spanner_ && !finished_spanner_->get_bound (RIGHT))
278 finished_spanner_->set_bound (RIGHT, info.grob ()); 278 finished_spanner_->set_bound (RIGHT, info.grob ());
279 } 279 }
280 280
(...skipping 18 matching lines...) Expand all
299 /* read */ 299 /* read */
300 "crescendoSpanner " 300 "crescendoSpanner "
301 "crescendoText " 301 "crescendoText "
302 "currentMusicalColumn " 302 "currentMusicalColumn "
303 "decrescendoSpanner " 303 "decrescendoSpanner "
304 "decrescendoText ", 304 "decrescendoText ",
305 305
306 /* write */ 306 /* write */
307 "" 307 ""
308 ); 308 );
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b