diff options
author | Graham Percival <graham@percival-music.ca> | 2011-08-01 20:19:33 +0100 |
---|---|---|
committer | Graham Percival <graham@percival-music.ca> | 2011-08-01 20:19:33 +0100 |
commit | 4a401ca1c60f428daa242dbdd102fdb3f327ebfb (patch) | |
tree | 5eeb3dd5db897fb88a957a57599999935f208434 /lily | |
parent | 1c72394c0ae30ba289f869059ec2532eac8d4015 (diff) |
Grand fixcc.py run on all .hh .cc files.
Apologies for the inconvenience in patch handling, but getting
this done at once will cause less long-term problems than trying
to do this piecemeal.
Note for future git historians: this patch was created by running
scripts/auxiliar/fixcc.py \
$(find flower lily -name '*cc' -o -name '*hh' | grep -v /out)
with astyle 2.02 installed. No manual changes were made.
Diffstat (limited to 'lily')
578 files changed, 17843 insertions, 18281 deletions
diff --git a/lily/accidental-engraver.cc b/lily/accidental-engraver.cc index 9bd02ee828..bc013f516f 100644 --- a/lily/accidental-engraver.cc +++ b/lily/accidental-engraver.cc @@ -87,14 +87,14 @@ protected: public: SCM last_keysig_; - vector<Grob*> left_objects_; - vector<Grob*> right_objects_; + vector<Grob *> left_objects_; + vector<Grob *> right_objects_; Grob *accidental_placement_; vector<Accidental_entry> accidentals_; - vector<Spanner*> ties_; - vector<Grob*> note_columns_; + vector<Spanner *> ties_; + vector<Grob *> note_columns_; }; /* @@ -102,7 +102,6 @@ public: in grobs should always store ly_deep_copy ()s of those. */ - Accidental_engraver::Accidental_engraver () { accidental_placement_ = 0; @@ -120,8 +119,8 @@ Accidental_engraver::update_local_key_signature (SCM new_sig) { last_keysig_ = new_sig; set_context_property_on_children (context (), - ly_symbol2scm ("localKeySignature"), - new_sig); + ly_symbol2scm ("localKeySignature"), + new_sig); Context *trans = context ()->get_parent_context (); @@ -163,14 +162,14 @@ struct Accidental_result int score () const { return need_acc ? 1 : 0 - + need_restore ? 1 : 0; + + need_restore ? 1 : 0; } }; static Accidental_result check_pitch_against_rules (Pitch const &pitch, Context *origin, - SCM rules, int bar_number, SCM measurepos) + SCM rules, int bar_number, SCM measurepos) { Accidental_result result; SCM pitch_scm = pitch.smobbed_copy (); @@ -178,37 +177,37 @@ check_pitch_against_rules (Pitch const &pitch, Context *origin, if (scm_is_pair (rules) && !scm_is_symbol (scm_car (rules))) warning (_f ("accidental typesetting list must begin with context-name: %s", - ly_scm2string (scm_car (rules)).c_str ())); + ly_scm2string (scm_car (rules)).c_str ())); for (; scm_is_pair (rules) && origin; rules = scm_cdr (rules)) { SCM rule = scm_car (rules); if (ly_is_procedure (rule)) - { - SCM rule_result_scm = scm_call_4 (rule, origin->self_scm (), - pitch_scm, barnum_scm, measurepos); - Accidental_result rule_result (rule_result_scm); + { + SCM rule_result_scm = scm_call_4 (rule, origin->self_scm (), + pitch_scm, barnum_scm, measurepos); + Accidental_result rule_result (rule_result_scm); - result.need_acc |= rule_result.need_acc; - result.need_restore |= rule_result.need_restore; - } + result.need_acc |= rule_result.need_acc; + result.need_restore |= rule_result.need_restore; + } /* - If symbol then it is a context name. Scan parent contexts to - find it. + If symbol then it is a context name. Scan parent contexts to + find it. */ else if (scm_is_symbol (rule)) - { - Context *dad = origin; - while (dad && !dad->is_alias (rule)) - dad = dad->get_parent_context (); - - if (dad) - origin = dad; - } + { + Context *dad = origin; + while (dad && !dad->is_alias (rule)) + dad = dad->get_parent_context (); + + if (dad) + origin = dad; + } else - warning (_f ("procedure or context-name expected for accidental rule, found %s", - print_scm_val (rule).c_str ())); + warning (_f ("procedure or context-name expected for accidental rule, found %s", + print_scm_val (rule).c_str ())); } return result; @@ -222,59 +221,59 @@ Accidental_engraver::process_acknowledged () SCM accidental_rules = get_property ("autoAccidentals"); SCM cautionary_rules = get_property ("autoCautionaries"); SCM measure_position = get_property ("measurePosition"); - int barnum = measure_number (context()); + int barnum = measure_number (context ()); for (vsize i = 0; i < accidentals_.size (); i++) - { - if (accidentals_[i].done_) - continue; - accidentals_[i].done_ = true; - - Stream_event *note = accidentals_[i].melodic_; - Context *origin = accidentals_[i].origin_; - - Pitch *pitch = unsmob_pitch (note->get_property ("pitch")); - if (!pitch) - continue; - - Accidental_result acc = check_pitch_against_rules (*pitch, origin, accidental_rules, - barnum, measure_position); - Accidental_result caut = check_pitch_against_rules (*pitch, origin, cautionary_rules, - barnum, measure_position); - - bool cautionary = to_boolean (note->get_property ("cautionary")); - if (caut.score () > acc.score ()) - { - acc.need_acc |= caut.need_acc; - acc.need_restore |= caut.need_restore; - - cautionary = true; - } - - bool forced = to_boolean (note->get_property ("force-accidental")); - if (!acc.need_acc && forced) - acc.need_acc = true; - - /* - Cannot look for ties: it's not guaranteed that they reach - us before the notes. - */ - if (!note->in_event_class ("trill-span-event")) - { - if (acc.need_acc) - create_accidental (&accidentals_[i], acc.need_restore, cautionary); - - if (forced || cautionary) - accidentals_[i].accidental_->set_property ("forced", SCM_BOOL_T); - } - } + { + if (accidentals_[i].done_) + continue; + accidentals_[i].done_ = true; + + Stream_event *note = accidentals_[i].melodic_; + Context *origin = accidentals_[i].origin_; + + Pitch *pitch = unsmob_pitch (note->get_property ("pitch")); + if (!pitch) + continue; + + Accidental_result acc = check_pitch_against_rules (*pitch, origin, accidental_rules, + barnum, measure_position); + Accidental_result caut = check_pitch_against_rules (*pitch, origin, cautionary_rules, + barnum, measure_position); + + bool cautionary = to_boolean (note->get_property ("cautionary")); + if (caut.score () > acc.score ()) + { + acc.need_acc |= caut.need_acc; + acc.need_restore |= caut.need_restore; + + cautionary = true; + } + + bool forced = to_boolean (note->get_property ("force-accidental")); + if (!acc.need_acc && forced) + acc.need_acc = true; + + /* + Cannot look for ties: it's not guaranteed that they reach + us before the notes. + */ + if (!note->in_event_class ("trill-span-event")) + { + if (acc.need_acc) + create_accidental (&accidentals_[i], acc.need_restore, cautionary); + + if (forced || cautionary) + accidentals_[i].accidental_->set_property ("forced", SCM_BOOL_T); + } + } } } void Accidental_engraver::create_accidental (Accidental_entry *entry, - bool restore_natural, - bool cautionary) + bool restore_natural, + bool cautionary) { Stream_event *note = entry->melodic_; Grob *support = entry->head_; @@ -288,7 +287,7 @@ Accidental_engraver::create_accidental (Accidental_entry *entry, if (restore_natural) { if (to_boolean (get_property ("extraNatural"))) - a->set_property ("restore-first", SCM_BOOL_T); + a->set_property ("restore-first", SCM_BOOL_T); } entry->accidental_ = a; @@ -296,9 +295,9 @@ Accidental_engraver::create_accidental (Accidental_entry *entry, Grob * Accidental_engraver::make_standard_accidental (Stream_event * /* note */, - Grob *note_head, - Engraver *trans, - bool cautionary) + Grob *note_head, + Engraver *trans, + bool cautionary) { /* We construct the accidentals at the originating Voice @@ -318,7 +317,7 @@ Accidental_engraver::make_standard_accidental (Stream_event * /* note */, for (vsize i = 0; i < left_objects_.size (); i++) { if (left_objects_[i]->get_property ("side-axis") == scm_from_int (X_AXIS)) - Side_position_interface::add_support (left_objects_[i], a); + Side_position_interface::add_support (left_objects_[i], a); } for (vsize i = 0; i < right_objects_.size (); i++) @@ -328,7 +327,7 @@ Accidental_engraver::make_standard_accidental (Stream_event * /* note */, if (!accidental_placement_) accidental_placement_ = make_item ("AccidentalPlacement", - a->self_scm ()); + a->self_scm ()); Accidental_placement::add_accidental (accidental_placement_, a); note_head->set_object ("accidental-grob", a->self_scm ()); @@ -338,8 +337,8 @@ Accidental_engraver::make_standard_accidental (Stream_event * /* note */, Grob * Accidental_engraver::make_suggested_accidental (Stream_event * /* note */, - Grob *note_head, - Engraver *trans) + Grob *note_head, + Engraver *trans) { Grob *a = trans->make_item ("AccidentalSuggestion", note_head->self_scm ()); @@ -364,16 +363,16 @@ Accidental_engraver::stop_translation_timestep () { Grob *r = Tie::head (ties_[j], RIGHT); for (vsize i = accidentals_.size (); i--;) - if (accidentals_[i].head_ == r) - { - if (Grob *g = accidentals_[i].accidental_) - { - g->set_object ("tie", ties_[j]->self_scm ()); - accidentals_[i].tied_ = true; - } - ties_.erase (ties_.begin () + j); - break; - } + if (accidentals_[i].head_ == r) + { + if (Grob *g = accidentals_[i].accidental_) + { + g->set_object ("tie", ties_[j]->self_scm ()); + accidentals_[i].tied_ = true; + } + ties_.erase (ties_.begin () + j); + break; + } } for (vsize i = accidentals_.size (); i--;) @@ -385,7 +384,7 @@ Accidental_engraver::stop_translation_timestep () Pitch *pitch = unsmob_pitch (note->get_property ("pitch")); if (!pitch) - continue; + continue; int n = pitch->get_notename (); int o = pitch->get_octave (); @@ -393,42 +392,42 @@ Accidental_engraver::stop_translation_timestep () SCM key = scm_cons (scm_from_int (o), scm_from_int (n)); Moment end_mp = measure_position (context (), - unsmob_duration (note->get_property ("duration"))); + unsmob_duration (note->get_property ("duration"))); SCM position = scm_cons (scm_from_int (barnum), end_mp.smobbed_copy ()); SCM localsig = SCM_EOL; while (origin - && origin->where_defined (ly_symbol2scm ("localKeySignature"), &localsig)) - { - bool change = false; - if (accidentals_[i].tied_ - && !(to_boolean (accidentals_[i].accidental_->get_property ("forced")))) - { - /* - Remember an alteration that is different both from - that of the tied note and of the key signature. - */ - localsig = ly_assoc_prepend_x (localsig, key,scm_cons (ly_symbol2scm ("tied"), - position)); - change = true; - } - else - { - /* - not really correct if there is more than one - note head with the same notename. - */ - localsig = ly_assoc_prepend_x (localsig, key, - scm_cons (ly_rational2scm (a), - position)); - change = true; - } - - if (change) - origin->set_property ("localKeySignature", localsig); - - origin = origin->get_parent_context (); - } + && origin->where_defined (ly_symbol2scm ("localKeySignature"), &localsig)) + { + bool change = false; + if (accidentals_[i].tied_ + && !(to_boolean (accidentals_[i].accidental_->get_property ("forced")))) + { + /* + Remember an alteration that is different both from + that of the tied note and of the key signature. + */ + localsig = ly_assoc_prepend_x (localsig, key, scm_cons (ly_symbol2scm ("tied"), + position)); + change = true; + } + else + { + /* + not really correct if there is more than one + note head with the same notename. + */ + localsig = ly_assoc_prepend_x (localsig, key, + scm_cons (ly_rational2scm (a), + position)); + change = true; + } + + if (change) + origin->set_property ("localKeySignature", localsig); + + origin = origin->get_parent_context (); + } } if (accidental_placement_) @@ -448,22 +447,22 @@ Accidental_engraver::acknowledge_rhythmic_head (Grob_info info) Stream_event *note = info.event_cause (); if (note && (note->in_event_class ("note-event") - || note->in_event_class ("trill-span-event"))) + || note->in_event_class ("trill-span-event"))) { /* - string harmonics usually don't have accidentals. + string harmonics usually don't have accidentals. */ if (info.grob ()->get_property ("style") != ly_symbol2scm ("harmonic") - || to_boolean (get_property ("harmonicAccidentals"))) - { - Accidental_entry entry; - entry.head_ = info.grob (); - entry.origin_engraver_ = dynamic_cast<Engraver *> (info.origin_translator ()); - entry.origin_ = entry.origin_engraver_->context (); - entry.melodic_ = note; - - accidentals_.push_back (entry); - } + || to_boolean (get_property ("harmonicAccidentals"))) + { + Accidental_entry entry; + entry.head_ = info.grob (); + entry.origin_engraver_ = dynamic_cast<Engraver *> (info.origin_translator ()); + entry.origin_ = entry.origin_engraver_->context (); + entry.melodic_ = note; + + accidentals_.push_back (entry); + } } } @@ -506,28 +505,28 @@ ADD_ACKNOWLEDGER (Accidental_engraver, tie); ADD_ACKNOWLEDGER (Accidental_engraver, note_column); ADD_TRANSLATOR (Accidental_engraver, - /* doc */ - "Make accidentals." - " Catch note heads, ties and notices key-change events." - " This engraver usually lives at Staff level, but" - " reads the settings for Accidental at @code{Voice} level," - " so you can @code{\\override} them at @code{Voice}.", - - /* create */ - "Accidental " - "AccidentalCautionary " - "AccidentalPlacement " - "AccidentalSuggestion ", - - /* read */ - "autoAccidentals " - "autoCautionaries " - "internalBarNumber " - "extraNatural " - "harmonicAccidentals " - "keySignature " - "localKeySignature ", - - /* write */ - "localKeySignature " - ); + /* doc */ + "Make accidentals." + " Catch note heads, ties and notices key-change events." + " This engraver usually lives at Staff level, but" + " reads the settings for Accidental at @code{Voice} level," + " so you can @code{\\override} them at @code{Voice}.", + + /* create */ + "Accidental " + "AccidentalCautionary " + "AccidentalPlacement " + "AccidentalSuggestion ", + + /* read */ + "autoAccidentals " + "autoCautionaries " + "internalBarNumber " + "extraNatural " + "harmonicAccidentals " + "keySignature " + "localKeySignature ", + + /* write */ + "localKeySignature " + ); diff --git a/lily/accidental-placement.cc b/lily/accidental-placement.cc index 4a535c7857..e4cf13c10a 100644 --- a/lily/accidental-placement.cc +++ b/lily/accidental-placement.cc @@ -76,20 +76,20 @@ Accidental_placement::add_accidental (Grob *me, Grob *a) */ void Accidental_placement::split_accidentals (Grob *accs, - vector<Grob *> *break_reminder, - vector<Grob *> *real_acc) + vector<Grob *> *break_reminder, + vector<Grob *> *real_acc) { for (SCM acs = accs->get_object ("accidental-grobs"); scm_is_pair (acs); acs = scm_cdr (acs)) for (SCM s = scm_cdar (acs); scm_is_pair (s); s = scm_cdr (s)) { - Grob *a = unsmob_grob (scm_car (s)); + Grob *a = unsmob_grob (scm_car (s)); - if (unsmob_grob (a->get_object ("tie")) - && !to_boolean (a->get_property ("forced"))) - break_reminder->push_back (a); - else - real_acc->push_back (a); + if (unsmob_grob (a->get_object ("tie")) + && !to_boolean (a->get_property ("forced"))) + break_reminder->push_back (a); + else + real_acc->push_back (a); } } @@ -108,7 +108,7 @@ Accidental_placement::get_relevant_accidentals (vector<Grob *> const &elts, Grob ret.insert (ret.end (), ra.begin (), ra.end ()); if (right) - ret.insert (ret.end (), br.begin (), br.end ()); + ret.insert (ret.end (), br.begin (), br.end ()); } return ret; } @@ -128,7 +128,7 @@ Real ape_priority (Accidental_placement_entry const *a) } bool ape_less (Accidental_placement_entry *const &a, - Accidental_placement_entry *const &b) + Accidental_placement_entry *const &b) { return ape_priority (a) < ape_priority (b); } @@ -190,12 +190,12 @@ stagger_apes (vector<Accidental_placement_entry *> *apes) { Accidental_placement_entry *a = 0; if (parity) - { - a = asc.back (); - asc.pop_back (); - } + { + a = asc.back (); + asc.pop_back (); + } else - a = asc[i++]; + a = asc[i++]; apes->push_back (a); parity = !parity; @@ -213,7 +213,7 @@ build_apes (SCM accs) Accidental_placement_entry *ape = new Accidental_placement_entry; for (SCM t = scm_cdar (s); scm_is_pair (t); t = scm_cdr (t)) - ape->grobs_.push_back (unsmob_grob (scm_car (t))); + ape->grobs_.push_back (unsmob_grob (scm_car (t))); apes.push_back (ape); } @@ -223,7 +223,7 @@ build_apes (SCM accs) static void set_ape_skylines (Accidental_placement_entry *ape, - Grob **common, Real padding) + Grob **common, Real padding) { vector<Grob *> accs (ape->grobs_); vector_sort (accs, &acc_less); @@ -243,29 +243,29 @@ set_ape_skylines (Accidental_placement_entry *ape, Pitch *p = accidental_pitch (a); if (!p) - continue; + continue; if (i == accs.size () - 1 || p->get_octave () != last_octave) - { - last_offset = 0; - offset = a->extent (a, X_AXIS)[LEFT] - padding; - } + { + last_offset = 0; + offset = a->extent (a, X_AXIS)[LEFT] - padding; + } else if (p->get_alteration () == last_alteration) - a->translate_axis (last_offset, X_AXIS); + a->translate_axis (last_offset, X_AXIS); else /* Our alteration is different from the last one */ - { - Real this_offset = offset - a->extent (a, X_AXIS)[RIGHT]; - a->translate_axis (this_offset, X_AXIS); + { + Real this_offset = offset - a->extent (a, X_AXIS)[RIGHT]; + a->translate_axis (this_offset, X_AXIS); - last_offset = this_offset; - offset -= a->extent (a, X_AXIS).length () + padding; - } + last_offset = this_offset; + offset -= a->extent (a, X_AXIS).length () + padding; + } vector<Box> boxes = Accidental_interface::accurate_boxes (a, common); ape->extents_.insert (ape->extents_.end (), boxes.begin (), boxes.end ()); for (vsize j = boxes.size (); j--;) - ape->vertical_extent_.unite (boxes[j][Y_AXIS]); + ape->vertical_extent_.unite (boxes[j][Y_AXIS]); last_octave = p->get_octave (); last_alteration = p->get_alteration (); @@ -284,16 +284,16 @@ extract_heads_and_stems (vector<Accidental_placement_entry *> const &apes) { Accidental_placement_entry *ape = apes[i]; for (vsize j = ape->grobs_.size (); j--;) - { - Grob *acc = ape->grobs_[j]; - Grob *head = acc->get_parent (Y_AXIS); - Grob *col = head->get_parent (X_AXIS); - - if (Note_column::has_interface (col)) - note_cols.push_back (col); - else - ret.push_back (head); - } + { + Grob *acc = ape->grobs_[j]; + Grob *head = acc->get_parent (Y_AXIS); + Grob *col = head->get_parent (X_AXIS); + + if (Note_column::has_interface (col)) + note_cols.push_back (col); + else + ret.push_back (head); + } } /* @@ -304,10 +304,10 @@ extract_heads_and_stems (vector<Accidental_placement_entry *> const &apes) { Grob *c = note_cols[i]->get_parent (X_AXIS); if (Note_collision_interface::has_interface (c)) - { - extract_grob_set (c, "elements", columns); - concat (note_cols, columns); - } + { + extract_grob_set (c, "elements", columns); + concat (note_cols, columns); + } } /* Now that we have all of the columns, grab all of the note-heads */ @@ -332,10 +332,10 @@ common_refpoint_of_accidentals (vector<Accidental_placement_entry *> const &apes for (vsize i = apes.size (); i--;) for (vsize j = apes[i]->grobs_.size (); j--;) { - if (!ret) - ret = apes[i]->grobs_[j]; - else - ret = ret->common_refpoint (apes[i]->grobs_[j], a); + if (!ret) + ret = apes[i]->grobs_[j]; + else + ret = ret->common_refpoint (apes[i]->grobs_[j], a); } return ret; @@ -343,12 +343,12 @@ common_refpoint_of_accidentals (vector<Accidental_placement_entry *> const &apes static Skyline build_heads_skyline (vector<Grob *> const &heads_and_stems, - Grob **common) + Grob **common) { vector<Box> head_extents; for (vsize i = heads_and_stems.size (); i--;) head_extents.push_back (Box (heads_and_stems[i]->extent (common[X_AXIS], X_AXIS), - heads_and_stems[i]->pure_height (common[Y_AXIS], 0, INT_MAX))); + heads_and_stems[i]->pure_height (common[Y_AXIS], 0, INT_MAX))); return Skyline (head_extents, 0, Y_AXIS, LEFT); } @@ -359,8 +359,8 @@ build_heads_skyline (vector<Grob *> const &heads_and_stems, */ static Interval position_apes (Grob *me, - vector<Accidental_placement_entry *> const &apes, - Skyline const &heads_skyline) + vector<Accidental_placement_entry *> const &apes, + Skyline const &heads_skyline) { Real padding = robust_scm2double (me->get_property ("padding"), 0.2); Skyline left_skyline = heads_skyline; @@ -377,9 +377,9 @@ position_apes (Grob *me, Real offset = -ape->right_skyline_.distance (left_skyline); if (isinf (offset)) - offset = last_offset; + offset = last_offset; else - offset -= padding; + offset -= padding; Skyline new_left_skyline = ape->left_skyline_; new_left_skyline.raise (offset); @@ -388,10 +388,10 @@ position_apes (Grob *me, /* Shift all of the accidentals in this ape */ for (vsize j = ape->grobs_.size (); j--;) - ape->grobs_[j]->translate_axis (offset, X_AXIS); + ape->grobs_[j]->translate_axis (offset, X_AXIS); for (vsize j = ape->extents_.size (); j--;) - width.unite (offset + ape->extents_[j][X_AXIS]); + width.unite (offset + ape->extents_[j][X_AXIS]); last_offset = offset; } @@ -436,7 +436,6 @@ position_apes (Grob *me, * |_| | * | | * - */ MAKE_SCHEME_CALLBACK (Accidental_placement, calc_positioning_done, 1); @@ -480,13 +479,13 @@ Accidental_placement::calc_positioning_done (SCM smob) } ADD_INTERFACE (Accidental_placement, - "Resolve accidental collisions.", - - /* properties */ - "accidental-grobs " - "direction " - "padding " - "positioning-done " - "right-padding " - "script-priority " - ); + "Resolve accidental collisions.", + + /* properties */ + "accidental-grobs " + "direction " + "padding " + "positioning-done " + "right-padding " + "script-priority " + ); diff --git a/lily/accidental.cc b/lily/accidental.cc index bee99c641d..bdab5d59f7 100644 --- a/lily/accidental.cc +++ b/lily/accidental.cc @@ -29,8 +29,8 @@ Stencil parenthesize (Grob *me, Stencil m) { - Font_metric * font - = Font_interface::get_default_font (me); + Font_metric *font + = Font_interface::get_default_font (me); Stencil open = font->find_by_name ("accidentals.leftparen"); Stencil close @@ -72,18 +72,18 @@ MAKE_SCHEME_CALLBACK (Accidental_interface, pure_height, 3); SCM Accidental_interface::pure_height (SCM smob, SCM start_scm, SCM) { - Item *me = dynamic_cast<Item*> (unsmob_grob (smob)); + Item *me = dynamic_cast<Item *> (unsmob_grob (smob)); int start = scm_to_int (start_scm); int rank = me->get_column ()->get_rank (); if (to_boolean (me->get_property ("forced")) || !unsmob_grob (me->get_object ("tie")) || (rank == start + 1 && /* we are at the start of a line */ - !to_boolean (me->get_property ("hide-tied-accidental-after-break")))) + !to_boolean (me->get_property ("hide-tied-accidental-after-break")))) { Stencil *s = unsmob_stencil (get_stencil (me)); if (s) - return ly_interval2scm (s->extent (Y_AXIS)); + return ly_interval2scm (s->extent (Y_AXIS)); } return ly_interval2scm (Interval ()); @@ -108,51 +108,51 @@ Accidental_interface::accurate_boxes (Grob *me, Grob **common) SCM alist = me->get_property ("glyph-name-alist"); SCM alt = me->get_property ("alteration"); string glyph_name = robust_scm2string (ly_assoc_get (alt, alist, SCM_BOOL_F), - ""); - + ""); + if (glyph_name == "accidentals.flat" - || glyph_name == "accidentals.mirroredflat") - { - Box stem = b; - Box bulb = b; - - /* - we could make the stem thinner, but that places the flats - really close. - */ - Direction bulb_dir = - glyph_name == "accidentals.mirroredflat" ? LEFT : RIGHT; - stem[X_AXIS][bulb_dir] = stem[X_AXIS].center (); - - /* - To prevent vertical alignment for 6ths - */ - stem[Y_AXIS] *= 1.1; - bulb[Y_AXIS][UP] *= .35; - - boxes.push_back (bulb); - boxes.push_back (stem); - } - else if (glyph_name == "accidentals.natural") - { - Box lstem = b; - Box rstem = b; - Box belly = b; - - lstem[Y_AXIS] *= 1.1; - rstem[Y_AXIS] *= 1.1; - - belly[Y_AXIS] *= 0.75; - lstem[X_AXIS][RIGHT] *= .33; - rstem[X_AXIS][LEFT] = rstem[X_AXIS].linear_combination (1.0 / 3.0); - lstem[Y_AXIS][DOWN] = belly[Y_AXIS][DOWN]; - rstem[Y_AXIS][UP] = belly[Y_AXIS][UP]; - boxes.push_back (belly); - boxes.push_back (lstem); - boxes.push_back (rstem); - } + || glyph_name == "accidentals.mirroredflat") + { + Box stem = b; + Box bulb = b; + + /* + we could make the stem thinner, but that places the flats + really close. + */ + Direction bulb_dir + = glyph_name == "accidentals.mirroredflat" ? LEFT : RIGHT; + stem[X_AXIS][bulb_dir] = stem[X_AXIS].center (); + + /* + To prevent vertical alignment for 6ths + */ + stem[Y_AXIS] *= 1.1; + bulb[Y_AXIS][UP] *= .35; + + boxes.push_back (bulb); + boxes.push_back (stem); + } + else if (glyph_name == "accidentals.natural") + { + Box lstem = b; + Box rstem = b; + Box belly = b; + + lstem[Y_AXIS] *= 1.1; + rstem[Y_AXIS] *= 1.1; + + belly[Y_AXIS] *= 0.75; + lstem[X_AXIS][RIGHT] *= .33; + rstem[X_AXIS][LEFT] = rstem[X_AXIS].linear_combination (1.0 / 3.0); + lstem[Y_AXIS][DOWN] = belly[Y_AXIS][DOWN]; + rstem[Y_AXIS][UP] = belly[Y_AXIS][UP]; + boxes.push_back (belly); + boxes.push_back (lstem); + boxes.push_back (rstem); + } /* - TODO: add support for, double flat. + TODO: add support for, double flat. */ } @@ -160,7 +160,7 @@ Accidental_interface::accurate_boxes (Grob *me, Grob **common) boxes.push_back (b); Offset o (me->relative_coordinate (common[X_AXIS], X_AXIS), - me->relative_coordinate (common[Y_AXIS], Y_AXIS)); + me->relative_coordinate (common[Y_AXIS], Y_AXIS)); for (vsize i = boxes.size (); i--;) boxes[i].translate (o); @@ -175,9 +175,9 @@ Accidental_interface::print (SCM smob) Grob *me = unsmob_grob (smob); Grob *tie = unsmob_grob (me->get_object ("tie")); - if (tie && - (to_boolean (me->get_property ("hide-tied-accidental-after-break")) - || (!tie->original () && !to_boolean (me->get_property ("forced"))))) + if (tie + && (to_boolean (me->get_property ("hide-tied-accidental-after-break")) + || (!tie->original () && !to_boolean (me->get_property ("forced"))))) { me->suicide (); return SCM_EOL; @@ -194,46 +194,45 @@ Accidental_interface::get_stencil (Grob *me) SCM alist = me->get_property ("glyph-name-alist"); SCM alt = me->get_property ("alteration"); SCM glyph_name = ly_assoc_get (alt, alist, SCM_BOOL_F); - + if (!scm_is_string (glyph_name)) { me->warning (_f ("Could not find glyph-name for alteration %s", - ly_scm_write_string (alt).c_str ())); + ly_scm_write_string (alt).c_str ())); return SCM_EOL; } - + Stencil mol (fm->find_by_name (ly_scm2string (glyph_name))); if (to_boolean (me->get_property ("restore-first"))) { /* - this isn't correct for ancient accidentals, but they don't - use double flats/sharps anyway. - */ + this isn't correct for ancient accidentals, but they don't + use double flats/sharps anyway. + */ Stencil acc (fm->find_by_name ("accidentals.natural")); if (acc.is_empty ()) - me->warning (_ ("natural alteration glyph not found")); + me->warning (_ ("natural alteration glyph not found")); else - mol.add_at_edge (X_AXIS, LEFT, acc, 0.1); + mol.add_at_edge (X_AXIS, LEFT, acc, 0.1); } - + if (to_boolean (me->get_property ("parenthesized"))) mol = parenthesize (me, mol); return mol.smobbed_copy (); } - ADD_INTERFACE (Accidental_interface, - "A single accidental.", - - /* properties */ - "alteration " - "avoid-slur " - "forced " - "glyph-name-alist " - "hide-tied-accidental-after-break " - "parenthesized " - "restore-first " - "tie " - ); + "A single accidental.", + + /* properties */ + "alteration " + "avoid-slur " + "forced " + "glyph-name-alist " + "hide-tied-accidental-after-break " + "parenthesized " + "restore-first " + "tie " + ); diff --git a/lily/align-interface.cc b/lily/align-interface.cc index cf957449ec..44c30e6013 100644 --- a/lily/align-interface.cc +++ b/lily/align-interface.cc @@ -32,7 +32,6 @@ #include "system.hh" #include "warn.hh" - MAKE_SCHEME_CALLBACK (Align_interface, align_to_minimum_distances, 1); SCM Align_interface::align_to_minimum_distances (SCM smob) @@ -70,99 +69,99 @@ Align_interface::align_to_ideal_distances (SCM smob) // code. Split them into 2 functions, perhaps? static void get_skylines (Grob *me, - vector<Grob*> *const elements, - Axis a, - bool pure, int start, int end, - vector<Skyline_pair> *const ret) + vector<Grob *> *const elements, + Axis a, + bool pure, int start, int end, + vector<Skyline_pair> *const ret) { Grob *other_common = common_refpoint_of_array (*elements, me, other_axis (a)); - + for (vsize i = elements->size (); i--;) { Grob *g = (*elements)[i]; Skyline_pair skylines; if (!pure) - { - Skyline_pair *skys = Skyline_pair::unsmob (g->get_property (a == Y_AXIS - ? "vertical-skylines" - : "horizontal-skylines")); - if (skys) - skylines = *skys; - - /* This skyline was calculated relative to the grob g. In order to compare it to - skylines belonging to other grobs, we need to shift it so that it is relative - to the common reference. */ - Real offset = g->relative_coordinate (other_common, other_axis (a)); - skylines.shift (offset); - } + { + Skyline_pair *skys = Skyline_pair::unsmob (g->get_property (a == Y_AXIS + ? "vertical-skylines" + : "horizontal-skylines")); + if (skys) + skylines = *skys; + + /* This skyline was calculated relative to the grob g. In order to compare it to + skylines belonging to other grobs, we need to shift it so that it is relative + to the common reference. */ + Real offset = g->relative_coordinate (other_common, other_axis (a)); + skylines.shift (offset); + } else - { - assert (a == Y_AXIS); - Interval extent = g->pure_height (g, start, end); - - // This is a hack to get better accuracy on the pure-height of VerticalAlignment. - // It's quite common for a treble clef to be the highest element of one system - // and for a low note (or lyrics) to be the lowest note on another. The two will - // never collide, but the pure-height stuff only works with bounding boxes, so it - // doesn't know that. The result is a significant over-estimation of the pure-height, - // especially on systems with many staves. To correct for this, we build a skyline - // in two parts: the part we did above contains most of the grobs (note-heads, etc.) - // while the bit we're about to do only contains the breakable grobs at the beginning - // of the system. This way, the tall treble clefs are only compared with the treble - // clefs of the other staff and they will be ignored if the staff above is, for example, - // lyrics. - if (Axis_group_interface::has_interface (g) - && !Hara_kiri_group_spanner::request_suicide (g, start, end)) - { - extent = Axis_group_interface::rest_of_line_pure_height (g, start, end); - Interval begin_of_line_extent = Axis_group_interface::begin_of_line_pure_height (g, start); - if (!begin_of_line_extent.is_empty ()) - { - Box b; - b[a] = begin_of_line_extent; - b[other_axis (a)] = Interval (-infinity_f, -1); - skylines.insert (b, 0, other_axis (a)); - } - } - - if (!extent.is_empty ()) - { - Box b; - b[a] = extent; - b[other_axis (a)] = Interval (0, infinity_f); - skylines.insert (b, 0, other_axis (a)); - } - } + { + assert (a == Y_AXIS); + Interval extent = g->pure_height (g, start, end); + + // This is a hack to get better accuracy on the pure-height of VerticalAlignment. + // It's quite common for a treble clef to be the highest element of one system + // and for a low note (or lyrics) to be the lowest note on another. The two will + // never collide, but the pure-height stuff only works with bounding boxes, so it + // doesn't know that. The result is a significant over-estimation of the pure-height, + // especially on systems with many staves. To correct for this, we build a skyline + // in two parts: the part we did above contains most of the grobs (note-heads, etc.) + // while the bit we're about to do only contains the breakable grobs at the beginning + // of the system. This way, the tall treble clefs are only compared with the treble + // clefs of the other staff and they will be ignored if the staff above is, for example, + // lyrics. + if (Axis_group_interface::has_interface (g) + && !Hara_kiri_group_spanner::request_suicide (g, start, end)) + { + extent = Axis_group_interface::rest_of_line_pure_height (g, start, end); + Interval begin_of_line_extent = Axis_group_interface::begin_of_line_pure_height (g, start); + if (!begin_of_line_extent.is_empty ()) + { + Box b; + b[a] = begin_of_line_extent; + b[other_axis (a)] = Interval (-infinity_f, -1); + skylines.insert (b, 0, other_axis (a)); + } + } + + if (!extent.is_empty ()) + { + Box b; + b[a] = extent; + b[other_axis (a)] = Interval (0, infinity_f); + skylines.insert (b, 0, other_axis (a)); + } + } if (skylines.is_empty ()) - elements->erase (elements->begin () + i); + elements->erase (elements->begin () + i); else - ret->push_back (skylines); + ret->push_back (skylines); } reverse (*ret); } vector<Real> Align_interface::get_minimum_translations (Grob *me, - vector<Grob*> const &all_grobs, - Axis a) + vector<Grob *> const &all_grobs, + Axis a) { return internal_get_minimum_translations (me, all_grobs, a, true, false, 0, 0); } vector<Real> Align_interface::get_pure_minimum_translations (Grob *me, - vector<Grob*> const &all_grobs, - Axis a, int start, int end) + vector<Grob *> const &all_grobs, + Axis a, int start, int end) { return internal_get_minimum_translations (me, all_grobs, a, true, true, start, end); } vector<Real> Align_interface::get_minimum_translations_without_min_dist (Grob *me, - vector<Grob*> const &all_grobs, - Axis a) + vector<Grob *> const &all_grobs, + Axis a) { return internal_get_minimum_translations (me, all_grobs, a, false, false, 0, 0); } @@ -178,24 +177,24 @@ Align_interface::get_minimum_translations_without_min_dist (Grob *me, // else centered dynamics will break when there is a fixed alignment). vector<Real> Align_interface::internal_get_minimum_translations (Grob *me, - vector<Grob*> const &all_grobs, - Axis a, - bool include_fixed_spacing, - bool pure, int start, int end) + vector<Grob *> const &all_grobs, + Axis a, + bool include_fixed_spacing, + bool pure, int start, int end) { - if (!pure && a == Y_AXIS && dynamic_cast<Spanner*> (me) && !me->get_system ()) + if (!pure && a == Y_AXIS && dynamic_cast<Spanner *> (me) && !me->get_system ()) me->programming_error ("vertical alignment called before line-breaking"); // If include_fixed_spacing is true, we look at things like system-system-spacing // and alignment-distances, which only make sense for the toplevel VerticalAlignment. // If we aren't toplevel, we're working on something like BassFigureAlignment // and so we definitely don't want to include alignment-distances! - if (!dynamic_cast<System*> (me->get_parent (Y_AXIS))) + if (!dynamic_cast<System *> (me->get_parent (Y_AXIS))) include_fixed_spacing = false; - + Direction stacking_dir = robust_scm2dir (me->get_property ("stacking-dir"), - DOWN); - vector<Grob*> elems (all_grobs); // writable copy + DOWN); + vector<Grob *> elems (all_grobs); // writable copy vector<Skyline_pair> skylines; get_skylines (me, &elems, a, pure, start, end, &skylines); @@ -214,44 +213,44 @@ Align_interface::internal_get_minimum_translations (Grob *me, Real padding = default_padding; if (j == 0) - dy = skylines[j][-stacking_dir].max_height () + padding; + dy = skylines[j][-stacking_dir].max_height () + padding; else - { - SCM spec = Page_layout_problem::get_spacing_spec (elems[j-1], elems[j], pure, start, end); - Page_layout_problem::read_spacing_spec (spec, &padding, ly_symbol2scm ("padding")); - - dy = down_skyline.distance (skylines[j][-stacking_dir]) + padding; - - Real min_distance = 0; - if (Page_layout_problem::read_spacing_spec (spec, &min_distance, ly_symbol2scm ("minimum-distance"))) - dy = max (dy, min_distance); - - if (include_fixed_spacing && Page_layout_problem::is_spaceable (elems[j]) && last_spaceable_element) - { - // Spaceable staves may have - // constraints coming from the previous spaceable staff - // as well as from the previous staff. - spec = Page_layout_problem::get_spacing_spec (last_spaceable_element, elems[j], pure, start, end); - Real spaceable_padding = 0; - Page_layout_problem::read_spacing_spec (spec, - &spaceable_padding, - ly_symbol2scm ("padding")); - dy = max(dy, (last_spaceable_skyline.distance (skylines[j][-stacking_dir]) - + stacking_dir*(last_spaceable_element_pos - where) + spaceable_padding)); - - Real spaceable_min_distance = 0; - if (Page_layout_problem::read_spacing_spec (spec, - &spaceable_min_distance, - ly_symbol2scm ("minimum-distance"))) - dy = max (dy, spaceable_min_distance + stacking_dir*(last_spaceable_element_pos - where)); - - dy = max (dy, Page_layout_problem::get_fixed_spacing (last_spaceable_element, elems[j], spaceable_count, - pure, start, end)); - } - } + { + SCM spec = Page_layout_problem::get_spacing_spec (elems[j - 1], elems[j], pure, start, end); + Page_layout_problem::read_spacing_spec (spec, &padding, ly_symbol2scm ("padding")); + + dy = down_skyline.distance (skylines[j][-stacking_dir]) + padding; + + Real min_distance = 0; + if (Page_layout_problem::read_spacing_spec (spec, &min_distance, ly_symbol2scm ("minimum-distance"))) + dy = max (dy, min_distance); + + if (include_fixed_spacing && Page_layout_problem::is_spaceable (elems[j]) && last_spaceable_element) + { + // Spaceable staves may have + // constraints coming from the previous spaceable staff + // as well as from the previous staff. + spec = Page_layout_problem::get_spacing_spec (last_spaceable_element, elems[j], pure, start, end); + Real spaceable_padding = 0; + Page_layout_problem::read_spacing_spec (spec, + &spaceable_padding, + ly_symbol2scm ("padding")); + dy = max (dy, (last_spaceable_skyline.distance (skylines[j][-stacking_dir]) + + stacking_dir * (last_spaceable_element_pos - where) + spaceable_padding)); + + Real spaceable_min_distance = 0; + if (Page_layout_problem::read_spacing_spec (spec, + &spaceable_min_distance, + ly_symbol2scm ("minimum-distance"))) + dy = max (dy, spaceable_min_distance + stacking_dir * (last_spaceable_element_pos - where)); + + dy = max (dy, Page_layout_problem::get_fixed_spacing (last_spaceable_element, elems[j], spaceable_count, + pure, start, end)); + } + } if (isinf (dy)) /* if the skyline is empty, maybe max_height is infinity_f */ - dy = 0.0; + dy = 0.0; dy = max (0.0, dy); down_skyline.raise (-stacking_dir * dy); @@ -260,12 +259,12 @@ Align_interface::internal_get_minimum_translations (Grob *me, translates.push_back (where); if (Page_layout_problem::is_spaceable (elems[j])) - { - spaceable_count++; - last_spaceable_element = elems[j]; - last_spaceable_element_pos = where; - last_spaceable_skyline = down_skyline; - } + { + spaceable_count++; + last_spaceable_element = elems[j]; + last_spaceable_element_pos = where; + last_spaceable_skyline = down_skyline; + } } // So far, we've computed the translates for all the non-empty elements. @@ -275,12 +274,12 @@ Align_interface::internal_get_minimum_translations (Grob *me, if (!translates.empty ()) { Real w = translates[0]; - for (vsize i = 0, j = 0; j < all_grobs.size (); j++) - { - if (i < elems.size () && all_grobs[j] == elems[i]) - w = translates[i++]; - all_translates.push_back (w); - } + for (vsize i = 0, j = 0; j < all_grobs.size (); j++) + { + if (i < elems.size () && all_grobs[j] == elems[i]) + w = translates[i++]; + all_translates.push_back (w); + } } return all_translates; } @@ -318,8 +317,8 @@ Align_interface::get_pure_child_y_translation (Grob *me, Grob *ch, int start, in if (translates.size ()) { for (vsize i = 0; i < all_grobs.size (); i++) - if (all_grobs[i] == ch) - return translates[i]; + if (all_grobs[i] == ch) + return translates[i]; } else return 0; @@ -340,7 +339,7 @@ Align_interface::add_element (Grob *me, Grob *element) Axis a = Align_interface::axis (me); SCM sym = axis_offset_symbol (a); SCM proc = axis_parent_positioning (a); - + element->set_property (sym, proc); Axis_group_interface::add_element (me, element); } @@ -361,17 +360,17 @@ Align_interface::set_ordered (Grob *me) } ADD_INTERFACE (Align_interface, - "Order grobs from top to bottom, left to right, right to left" - " or bottom to top. For vertical alignments of staves, the" - " @code{break-system-details} of the left" - " @rinternals{NonMusicalPaperColumn} may be set to tune" - " vertical spacing.", - - /* properties */ - "align-dir " - "axes " - "elements " - "padding " - "positioning-done " - "stacking-dir " - ); + "Order grobs from top to bottom, left to right, right to left" + " or bottom to top. For vertical alignments of staves, the" + " @code{break-system-details} of the left" + " @rinternals{NonMusicalPaperColumn} may be set to tune" + " vertical spacing.", + + /* properties */ + "align-dir " + "axes " + "elements " + "padding " + "positioning-done " + "stacking-dir " + ); diff --git a/lily/all-font-metrics-scheme.cc b/lily/all-font-metrics-scheme.cc index 0dd78123ea..87c59c19ba 100644 --- a/lily/all-font-metrics-scheme.cc +++ b/lily/all-font-metrics-scheme.cc @@ -2,7 +2,7 @@ This file is part of LilyPond, the GNU music typesetter. Copyright (C) 2007--2011 Han-Wen Nienhuys <hanwen@lilypond.org> - + LilyPond is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,8 +22,8 @@ #include "main.hh" LY_DEFINE (ly_reset_all_fonts, "ly:reset-all-fonts", 0, 0, 0, - (), - "Forget all about previously loaded fonts.") + (), + "Forget all about previously loaded fonts.") { delete all_fonts_global; all_fonts_global = new All_font_metrics (global_path.to_string ()); @@ -31,23 +31,22 @@ LY_DEFINE (ly_reset_all_fonts, "ly:reset-all-fonts", 0, 0, 0, return SCM_UNSPECIFIED; } - LY_DEFINE (ly_system_font_load, "ly:system-font-load", 1, 0, 0, - (SCM name), - "Load the OpenType system font @file{@var{name}.otf}." - " Fonts loaded with this command must contain three" - " additional SFNT font tables called @code{LILC}," - " @code{LILF}, and @code{LILY}, needed for typesetting" - " musical elements. Currently, only the Emmentaler and" - " the Emmentaler-Brace fonts fulfill these requirements.\n" - "\n" - "Note that only @code{ly:font-get-glyph} and derived" - " code (like @code{\\lookup}) can access glyphs from" - " the system fonts; text strings are handled exclusively" - " via the Pango interface.") + (SCM name), + "Load the OpenType system font @file{@var{name}.otf}." + " Fonts loaded with this command must contain three" + " additional SFNT font tables called @code{LILC}," + " @code{LILF}, and @code{LILY}, needed for typesetting" + " musical elements. Currently, only the Emmentaler and" + " the Emmentaler-Brace fonts fulfill these requirements.\n" + "\n" + "Note that only @code{ly:font-get-glyph} and derived" + " code (like @code{\\lookup}) can access glyphs from" + " the system fonts; text strings are handled exclusively" + " via the Pango interface.") { LY_ASSERT_TYPE (scm_is_string, name, 1); - + string name_str = ly_scm2string (name); Font_metric *fm = all_fonts_global->find_font (name_str); diff --git a/lily/all-font-metrics.cc b/lily/all-font-metrics.cc index 23119125aa..d42811c0a7 100644 --- a/lily/all-font-metrics.cc +++ b/lily/all-font-metrics.cc @@ -27,11 +27,10 @@ #include "scm-hash.hh" #include "warn.hh" - Index_to_charcode_map const * All_font_metrics::get_index_to_charcode_map (string filename, - int face_index, - FT_Face face) + int face_index, + FT_Face face) { string key = filename + String_convert::int_string (face_index); if (filename_charcode_maps_map_.find (key) @@ -41,7 +40,6 @@ All_font_metrics::get_index_to_charcode_map (string filename, return &filename_charcode_maps_map_[key]; } - All_font_metrics::All_font_metrics (string path) { otf_dict_ = new Scheme_hash_table; @@ -53,7 +51,7 @@ All_font_metrics::All_font_metrics (string path) pango_dpi_ = PANGO_RESOLUTION; pango_ft2_font_map_set_resolution (pango_ft2_fontmap_, - pango_dpi_, pango_dpi_); + pango_dpi_, pango_dpi_); pango_dict_ = new Scheme_hash_table; #endif @@ -79,8 +77,8 @@ All_font_metrics::All_font_metrics (All_font_metrics const &) Pango_font * All_font_metrics::find_pango_font (PangoFontDescription const *description, - Real output_scale - ) + Real output_scale + ) { gchar *pango_fn = pango_font_description_to_filename (description); SCM key = ly_symbol2scm (pango_fn); @@ -89,22 +87,22 @@ All_font_metrics::find_pango_font (PangoFontDescription const *description, if (!pango_dict_->try_retrieve (key, &val)) { if (be_verbose_global) - progress_indication ("\n[" + string (pango_fn)); + progress_indication ("\n[" + string (pango_fn)); Pango_font *pf = new Pango_font (pango_ft2_fontmap_, - description, - output_scale - ); - + description, + output_scale + ); + val = pf->self_scm (); pango_dict_->set (key, val); pf->unprotect (); if (be_verbose_global) - progress_indication ("]"); + progress_indication ("]"); pf->description_ = scm_cons (SCM_BOOL_F, - scm_from_double (1.0)); + scm_from_double (1.0)); } g_free (pango_fn); return dynamic_cast<Pango_font *> (unsmob_metrics (val)); @@ -112,7 +110,6 @@ All_font_metrics::find_pango_font (PangoFontDescription const *description, #endif - Open_type_font * All_font_metrics::find_otf (string name) { @@ -123,22 +120,22 @@ All_font_metrics::find_otf (string name) string file_name; if (file_name.empty ()) - file_name = search_path_.find (name + ".otf"); + file_name = search_path_.find (name + ".otf"); if (file_name.empty ()) - return 0; + return 0; if (be_verbose_global) - progress_indication ("\n[" + file_name); + progress_indication ("\n[" + file_name); val = Open_type_font::make_otf (file_name); if (be_verbose_global) - progress_indication ("]"); + progress_indication ("]"); unsmob_metrics (val)->file_name_ = file_name; SCM name_string = ly_string2scm (name); unsmob_metrics (val)->description_ = scm_cons (name_string, - scm_from_double (1.0)); + scm_from_double (1.0)); otf_dict_->set (sname, val); unsmob_metrics (val)->unprotect (); } diff --git a/lily/ambitus-engraver.cc b/lily/ambitus-engraver.cc index 221c1e8881..ae692d380a 100644 --- a/lily/ambitus-engraver.cc +++ b/lily/ambitus-engraver.cc @@ -78,7 +78,7 @@ Ambitus_engraver::create_ambitus () accidentals_[d] = make_item ("AmbitusAccidental", SCM_EOL); accidentals_[d]->set_parent (heads_[d], Y_AXIS); heads_[d]->set_object ("accidental-grob", - accidentals_[d]->self_scm ()); + accidentals_[d]->self_scm ()); Axis_group_interface::add_element (group_, heads_[d]); Axis_group_interface::add_element (group_, accidentals_[d]); } @@ -136,17 +136,17 @@ Ambitus_engraver::acknowledge_note_head (Grob_info info) { SCM p = nr->get_property ("pitch"); /* - If the engraver is added to a percussion context, - filter out unpitched note heads. + If the engraver is added to a percussion context, + filter out unpitched note heads. */ if (!unsmob_pitch (p)) - return; + return; Pitch pitch = *unsmob_pitch (p); Drul_array<bool> expands = pitch_interval_.add_point (pitch); if (expands[UP]) - causes_[UP] = nr; + causes_[UP] = nr; if (expands[DOWN]) - causes_[DOWN] = nr; + causes_[DOWN] = nr; } } @@ -155,50 +155,50 @@ Ambitus_engraver::finalize () { if (ambitus_ && !pitch_interval_.is_empty ()) { - Grob *accidental_placement = - make_item ("AccidentalPlacement", accidentals_[DOWN]->self_scm ()); + Grob *accidental_placement + = make_item ("AccidentalPlacement", accidentals_[DOWN]->self_scm ()); Direction d = DOWN; do - { - Pitch p = pitch_interval_[d]; - heads_[d]->set_property ("cause", causes_[d]->self_scm()); - heads_[d]->set_property ("staff-position", - scm_from_int (start_c0_ + p.steps ())); - - SCM handle = scm_assoc (scm_cons (scm_from_int (p.get_octave ()), - scm_from_int (p.get_notename ())), - start_key_sig_); - - if (handle == SCM_BOOL_F) - handle = scm_assoc (scm_from_int (p.get_notename ()), - start_key_sig_); - - Rational sig_alter = (handle != SCM_BOOL_F) - ? robust_scm2rational (scm_cdr (handle), Rational (0)) - : Rational (0); - - const Pitch other = pitch_interval_[-d]; - - if (sig_alter == p.get_alteration () - && !((p.steps () == other.steps ()) - && (p.get_alteration () != other.get_alteration ()))) - { - accidentals_[d]->suicide (); - heads_[d]->set_object ("accidental-grob", SCM_EOL); - } - else - accidentals_[d]-> - set_property ("alteration", - ly_rational2scm (p.get_alteration ())); - Separation_item::add_conditional_item (heads_[d], - accidental_placement); - Accidental_placement::add_accidental (accidental_placement, - accidentals_[d]); - Pointer_group_interface::add_grob (ambitus_, - ly_symbol2scm ("note-heads"), - heads_[d]); - } + { + Pitch p = pitch_interval_[d]; + heads_[d]->set_property ("cause", causes_[d]->self_scm ()); + heads_[d]->set_property ("staff-position", + scm_from_int (start_c0_ + p.steps ())); + + SCM handle = scm_assoc (scm_cons (scm_from_int (p.get_octave ()), + scm_from_int (p.get_notename ())), + start_key_sig_); + + if (handle == SCM_BOOL_F) + handle = scm_assoc (scm_from_int (p.get_notename ()), + start_key_sig_); + + Rational sig_alter = (handle != SCM_BOOL_F) + ? robust_scm2rational (scm_cdr (handle), Rational (0)) + : Rational (0); + + const Pitch other = pitch_interval_[-d]; + + if (sig_alter == p.get_alteration () + && !((p.steps () == other.steps ()) + && (p.get_alteration () != other.get_alteration ()))) + { + accidentals_[d]->suicide (); + heads_[d]->set_object ("accidental-grob", SCM_EOL); + } + else + accidentals_[d]-> + set_property ("alteration", + ly_rational2scm (p.get_alteration ())); + Separation_item::add_conditional_item (heads_[d], + accidental_placement); + Accidental_placement::add_accidental (accidental_placement, + accidentals_[d]); + Pointer_group_interface::add_grob (ambitus_, + ly_symbol2scm ("note-heads"), + heads_[d]); + } while (flip (&d) != DOWN); Axis_group_interface::add_element (group_, accidental_placement); @@ -207,10 +207,10 @@ Ambitus_engraver::finalize () { Direction d = DOWN; do - { - accidentals_[d]->suicide (); - heads_[d]->suicide (); - } + { + accidentals_[d]->suicide (); + heads_[d]->suicide (); + } while (flip (&d) != DOWN); ambitus_->suicide (); @@ -219,20 +219,20 @@ Ambitus_engraver::finalize () ADD_ACKNOWLEDGER (Ambitus_engraver, note_head); ADD_TRANSLATOR (Ambitus_engraver, - /* doc */ - "Create an ambitus.", - - /* create */ - "AccidentalPlacement " - "Ambitus " - "AmbitusAccidental " - "AmbitusLine " - "AmbitusNoteHead ", - - /* read */ - "keySignature " - "middleCPosition ", - - /* write */ - "" - ); + /* doc */ + "Create an ambitus.", + + /* create */ + "AccidentalPlacement " + "Ambitus " + "AmbitusAccidental " + "AmbitusLine " + "AmbitusNoteHead ", + + /* read */ + "keySignature " + "middleCPosition ", + + /* write */ + "" + ); diff --git a/lily/arpeggio-engraver.cc b/lily/arpeggio-engraver.cc index 62be51d90b..38be529e73 100644 --- a/lily/arpeggio-engraver.cc +++ b/lily/arpeggio-engraver.cc @@ -64,11 +64,11 @@ Arpeggio_engraver::acknowledge_stem (Grob_info info) if (arpeggio_) { if (!arpeggio_->get_parent (Y_AXIS)) - arpeggio_->set_parent (info.grob (), Y_AXIS); + arpeggio_->set_parent (info.grob (), Y_AXIS); Pointer_group_interface::add_grob (arpeggio_, - ly_symbol2scm ("stems"), - info.grob ()); + ly_symbol2scm ("stems"), + info.grob ()); } } void @@ -103,15 +103,15 @@ ADD_ACKNOWLEDGER (Arpeggio_engraver, stem); ADD_ACKNOWLEDGER (Arpeggio_engraver, rhythmic_head); ADD_TRANSLATOR (Arpeggio_engraver, - /* doc */ - "Generate an Arpeggio symbol.", + /* doc */ + "Generate an Arpeggio symbol.", - /* create */ - "Arpeggio", + /* create */ + "Arpeggio", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/arpeggio.cc b/lily/arpeggio.cc index b609f846d7..9b85808a26 100644 --- a/lily/arpeggio.cc +++ b/lily/arpeggio.cc @@ -49,7 +49,7 @@ Arpeggio::get_common_y (Grob *me) { Grob *stem = stems[i]; common = common->common_refpoint (Staff_symbol_referencer::get_staff_symbol (stem), - Y_AXIS); + Y_AXIS); } return common; @@ -94,27 +94,27 @@ Arpeggio::print (SCM smob) { Grob *me = unsmob_grob (smob); Interval heads = robust_scm2interval (me->get_property ("positions"), - Interval ()) - * Staff_symbol_referencer::staff_space (me); + Interval ()) + * Staff_symbol_referencer::staff_space (me); if (heads.is_empty () || heads.length () < 0.5) { if (to_boolean (me->get_property ("transparent"))) - { - /* - This is part of a cross-staff/-voice span-arpeggio, - so we need to ensure `heads' is large enough to encompass - a single trill-element since the span-arpeggio depends on - its children to prevent collisions. - */ - heads.unite (get_squiggle (me).extent (Y_AXIS)); - } + { + /* + This is part of a cross-staff/-voice span-arpeggio, + so we need to ensure `heads' is large enough to encompass + a single trill-element since the span-arpeggio depends on + its children to prevent collisions. + */ + heads.unite (get_squiggle (me).extent (Y_AXIS)); + } else - { - me->warning ("no heads for arpeggio found?"); - me->suicide (); - return SCM_EOL; - } + { + me->warning ("no heads for arpeggio found?"); + me->suicide (); + return SCM_EOL; + } } SCM ad = me->get_property ("arpeggio-direction"); @@ -162,8 +162,8 @@ Arpeggio::brew_chord_bracket (SCM smob) { Grob *me = unsmob_grob (smob); Interval heads = robust_scm2interval (me->get_property ("positions"), - Interval ()) - * Staff_symbol_referencer::staff_space (me); + Interval ()) + * Staff_symbol_referencer::staff_space (me); Real lt = me->layout ()->get_dimension (ly_symbol2scm ("line-thickness")); Real sp = 1.5 * Staff_symbol_referencer::staff_space (me); @@ -182,8 +182,8 @@ Arpeggio::brew_chord_slur (SCM smob) Grob *me = unsmob_grob (smob); SCM dash_definition = me->get_property ("dash-definition"); Interval heads = robust_scm2interval (me->get_property ("positions"), - Interval ()) - * Staff_symbol_referencer::staff_space (me); + Interval ()) + * Staff_symbol_referencer::staff_space (me); Real lt = me->layout ()->get_dimension (ly_symbol2scm ("line-thickness")); Real dy = heads.length (); @@ -222,13 +222,13 @@ Arpeggio::pure_height (SCM smob, SCM, SCM) } ADD_INTERFACE (Arpeggio, - "Functions and settings for drawing an arpeggio symbol.", - - /* properties */ - "arpeggio-direction " - "positions " - "script-priority " // TODO: make around-note-interface - "stems " - "dash-definition " // TODO: make apply to non-slur arpeggios - ); + "Functions and settings for drawing an arpeggio symbol.", + + /* properties */ + "arpeggio-direction " + "positions " + "script-priority " // TODO: make around-note-interface + "stems " + "dash-definition " // TODO: make apply to non-slur arpeggios + ); diff --git a/lily/articulations.cc b/lily/articulations.cc index 93018656a5..a015df6063 100644 --- a/lily/articulations.cc +++ b/lily/articulations.cc @@ -35,8 +35,8 @@ SCM articulation_list (vector<Stream_event *> note_events, - vector<Stream_event *> articulation_events, - char const *articulation_name) + vector<Stream_event *> articulation_events, + char const *articulation_name) { vector<Stream_event *> string_events; SCM articulations = SCM_EOL; @@ -50,35 +50,35 @@ articulation_list (vector<Stream_event *> note_events, Stream_event *articulation_event = 0; /* - For notes inside a chord construct, string indications are - stored as articulations on the note, so we check through - the notes + For notes inside a chord construct, string indications are + stored as articulations on the note, so we check through + the notes */ for (SCM s = event->get_property ("articulations"); - !articulation_event && scm_is_pair (s); s = scm_cdr (s)) - { - Stream_event *art = unsmob_stream_event (scm_car (s)); + !articulation_event && scm_is_pair (s); s = scm_cdr (s)) + { + Stream_event *art = unsmob_stream_event (scm_car (s)); - if (art->in_event_class (articulation_name)) - articulation_event = art; - } + if (art->in_event_class (articulation_name)) + articulation_event = art; + } /* - For string indications listed outside a chord construct, - a string_number_event is generated, so if there was no string - in the articulations, we check for string events outside - the chord construct + For string indications listed outside a chord construct, + a string_number_event is generated, so if there was no string + in the articulations, we check for string events outside + the chord construct */ if (!articulation_event && j < articulation_events.size ()) - { - articulation_event = articulation_events[j]; - if (j + 1 < articulation_events.size ()) - j++; - } + { + articulation_event = articulation_events[j]; + if (j + 1 < articulation_events.size ()) + j++; + } articulations = scm_cons ((articulation_event - ? articulation_event->self_scm () - : SCM_EOL), - articulations); + ? articulation_event->self_scm () + : SCM_EOL), + articulations); } return (scm_reverse (articulations)); diff --git a/lily/audio-column.cc b/lily/audio-column.cc index 105eb1dda8..0b471a097a 100644 --- a/lily/audio-column.cc +++ b/lily/audio-column.cc @@ -51,4 +51,3 @@ Audio_column::offset_when (Moment m) when_ += m; } - diff --git a/lily/audio-element-info.cc b/lily/audio-element-info.cc index e7db515aab..944df8e3d9 100644 --- a/lily/audio-element-info.cc +++ b/lily/audio-element-info.cc @@ -36,11 +36,11 @@ Audio_element_info::Audio_element_info () origin_trans_ = 0; } -vector<Context*> +vector<Context *> Audio_element_info::origin_contexts (Translator *end) const { Context *t = origin_trans_->context (); - vector<Context*> r; + vector<Context *> r; do { r.push_back (t); diff --git a/lily/audio-element.cc b/lily/audio-element.cc index cd3f7c8d18..954cdc7da1 100644 --- a/lily/audio-element.cc +++ b/lily/audio-element.cc @@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License along with LilyPond. If not, see <http://www.gnu.org/licenses/>. */ -#include <cassert> +#include <cassert> #include "audio-element.hh" diff --git a/lily/audio-item.cc b/lily/audio-item.cc index 76a3923848..1cbf7765b7 100644 --- a/lily/audio-item.cc +++ b/lily/audio-item.cc @@ -39,18 +39,18 @@ Audio_item::get_column () const } Audio_item::Audio_item () - : audio_column_ (0) - , channel_ (0) + : audio_column_ (0), + channel_ (0) { } Audio_note::Audio_note (Pitch p, Moment m, bool tie_event, Pitch transposing) - : pitch_ (p) - , length_mom_ (m) - , transposing_ (transposing) - , dynamic_ (0) - , tied_ (0) - , tie_event_ (tie_event) + : pitch_ (p), + length_mom_ (m), + transposing_ (transposing), + dynamic_ (0), + tied_ (0), + tie_event_ (tie_event) { } @@ -74,8 +74,8 @@ Audio_key::Audio_key (int acc, bool major) } Audio_dynamic::Audio_dynamic () - : volume_ (-1) - , silent_ (false) + : volume_ (-1), + silent_ (false) { } @@ -94,8 +94,8 @@ Audio_span_dynamic::add_absolute (Audio_dynamic *d) Moment remap_grace_duration (Moment m) { - return Moment (m.main_part_ + Rational (9,40) * m.grace_part_, - Rational (0)); + return Moment (m.main_part_ + Rational (9, 40) * m.grace_part_, + Rational (0)); } Real @@ -114,13 +114,13 @@ void Audio_span_dynamic::render () { if (dynamics_.size () <= 1) - return ; + return; assert (dynamics_[0]->volume_ >= 0); - while (dynamics_.back ()->volume_ > 0 - && dynamics_.size () > 1 - && sign (dynamics_.back ()->volume_ - dynamics_[0]->volume_) != grow_dir_) + while (dynamics_.back ()->volume_ > 0 + && dynamics_.size () > 1 + && sign (dynamics_.back ()->volume_ - dynamics_[0]->volume_) != grow_dir_) { dynamics_.erase (dynamics_.end () - 1); } @@ -128,7 +128,7 @@ Audio_span_dynamic::render () if (dynamics_.size () <= 1) { programming_error ("Impossible or ambiguous (de)crescendo in MIDI."); - return ; + return; } Real delta_v = grow_dir_ * 0.1; @@ -143,21 +143,19 @@ Audio_span_dynamic::render () Real total_t = moment_to_real (dynamics_.back ()->get_column ()->when () - start); - for (vsize i = 1; i < dynamics_.size (); i ++) + for (vsize i = 1; i < dynamics_.size (); i++) { Moment dt_moment = dynamics_[i]->get_column ()->when () - - start; + - start; - Real dt = moment_to_real (dt_moment); + Real dt = moment_to_real (dt_moment); - Real v = start_v + delta_v * (dt / total_t); + Real v = start_v + delta_v * (dt / total_t); dynamics_[i]->volume_ = v; } } - - Audio_tempo::Audio_tempo (int per_minute_4) { per_minute_4_ = per_minute_4; diff --git a/lily/audio-staff.cc b/lily/audio-staff.cc index ddab7e04bc..0398c894ad 100644 --- a/lily/audio-staff.cc +++ b/lily/audio-staff.cc @@ -44,7 +44,7 @@ Audio_staff::output (Midi_stream &midi_stream, int track, bool port) i.process (); i.finalize (); - + midi_stream.write (midi_track); } diff --git a/lily/auto-beam-engraver.cc b/lily/auto-beam-engraver.cc index 0d5fa60ed2..8d8a4b6c56 100644 --- a/lily/auto-beam-engraver.cc +++ b/lily/auto-beam-engraver.cc @@ -88,11 +88,9 @@ private: Beaming_pattern *finished_grouping_; - Beaming_options beaming_options_; Beaming_options finished_beaming_options_; - void check_bar_property (); }; @@ -127,7 +125,7 @@ Auto_beam_engraver::process_music () if (stems_) { if (extend_mom_ < now) - end_beam (); + end_beam (); } if (scm_is_string (get_property ("whichBar"))) @@ -139,9 +137,9 @@ Auto_beam_engraver::process_music () if (forbid_) { if (stems_) - end_beam (); + end_beam (); else - junk_beam (); + junk_beam (); } } @@ -168,11 +166,11 @@ bool Auto_beam_engraver::test_moment (Direction dir, Moment test_mom, Moment dur) { return scm_call_4 (get_property ("autoBeamCheck"), - context ()->self_scm (), - scm_from_int (dir), + context ()->self_scm (), + scm_from_int (dir), test_mom.smobbed_copy (), - dur.smobbed_copy ()) - != SCM_BOOL_F; + dur.smobbed_copy ()) + != SCM_BOOL_F; } void @@ -184,7 +182,7 @@ Auto_beam_engraver::consider_begin (Moment test_mom, Moment dur) { bool b = test_moment (START, test_mom, dur); if (b) - begin_beam (); + begin_beam (); } } @@ -194,10 +192,10 @@ Auto_beam_engraver::consider_end (Moment test_mom, Moment dur) if (stems_) { /* Allow already started autobeam to end: - don't check for autoBeaming */ + don't check for autoBeaming */ bool b = test_moment (STOP, test_mom, dur); if (b) - end_beam (); + end_beam (); } } @@ -272,14 +270,14 @@ Auto_beam_engraver::end_beam () finished_beam_ = create_beam (); if (finished_beam_) - { - Grob_info i = make_grob_info (finished_beam_, SCM_EOL); - i.rerouting_daddy_context_ = beam_start_context_; - - announce_end_grob (i); - finished_grouping_ = grouping_; - finished_beaming_options_ = beaming_options_; - } + { + Grob_info i = make_grob_info (finished_beam_, SCM_EOL); + i.rerouting_daddy_context_ = beam_start_context_; + + announce_end_grob (i); + finished_grouping_ = grouping_; + finished_beaming_options_ = beaming_options_; + } delete stems_; stems_ = 0; grouping_ = 0; @@ -295,7 +293,7 @@ Auto_beam_engraver::typeset_beam () if (finished_beam_) { if (!finished_beam_->get_bound (RIGHT)) - finished_beam_->set_bound (RIGHT, finished_beam_->get_bound (LEFT)); + finished_beam_->set_bound (RIGHT, finished_beam_->get_bound (LEFT)); finished_grouping_->beamify (finished_beaming_options_); Beam::set_beaming (finished_beam_, finished_grouping_); @@ -324,7 +322,6 @@ Auto_beam_engraver::finalize () junk_beam (); } - void Auto_beam_engraver::acknowledge_beam (Grob_info /* info */) { @@ -375,14 +372,14 @@ Auto_beam_engraver::acknowledge_stem (Grob_info info) if (!Stem::head_count (stem)) { if (stems_) - end_beam (); + end_beam (); return; } if (Stem::get_beam (stem)) { if (stems_) - junk_beam (); + junk_beam (); return; } @@ -391,7 +388,7 @@ Auto_beam_engraver::acknowledge_stem (Grob_info info) if (durlog <= 2) { if (stems_) - end_beam (); + end_beam (); return; } @@ -408,9 +405,9 @@ Auto_beam_engraver::acknowledge_stem (Grob_info info) if (dur < shortest_mom_) { - /* new shortest moment, so store it and set recheck_needed */ - shortest_mom_ = dur; - recheck_needed = true; + /* new shortest moment, so store it and set recheck_needed */ + shortest_mom_ = dur; + recheck_needed = true; } /* end should be based on shortest_mom_, begin should be @@ -422,8 +419,8 @@ Auto_beam_engraver::acknowledge_stem (Grob_info info) return; grouping_->add_stem (now - beam_start_moment_ + beam_start_location_, - durlog - 2, - Stem::is_invisible (stem)); + durlog - 2, + Stem::is_invisible (stem)); stems_->push_back (stem); last_add_mom_ = now; extend_mom_ = max (extend_mom_, now) + get_event_length (ev, now); @@ -447,7 +444,6 @@ Auto_beam_engraver::recheck_beam () bool found_end; - for (vsize i = 0; i < stems_->size () - 1;) { found_end = test_moment (STOP, @@ -506,7 +502,7 @@ Auto_beam_engraver::remove_end_stems (vsize split_index) void Auto_beam_engraver::process_acknowledged () { - Moment now = now_mom(); + Moment now = now_mom (); if (extend_mom_ > now) return; @@ -518,13 +514,13 @@ Auto_beam_engraver::process_acknowledged () else if (process_acknowledged_count_ > 1) { if (stems_) - { - if ((extend_mom_ < now) - || ((extend_mom_ == now) && (last_add_mom_ != now))) - end_beam (); - else if (!stems_->size ()) - junk_beam (); - } + { + if ((extend_mom_ < now) + || ((extend_mom_ == now) && (last_add_mom_ != now))) + end_beam (); + else if (!stems_->size ()) + junk_beam (); + } } process_acknowledged_count_++; @@ -557,4 +553,4 @@ ADD_TRANSLATOR (Auto_beam_engraver, /* write */ "" - ); + ); diff --git a/lily/auto-change-iterator.cc b/lily/auto-change-iterator.cc index 76e43dbccd..6063c57c1f 100644 --- a/lily/auto-change-iterator.cc +++ b/lily/auto-change-iterator.cc @@ -47,7 +47,7 @@ private: void Auto_change_iterator::change_to (Music_iterator *it, SCM to_type_sym, - string to_id) + string to_id) { Context *current = it->get_outlet (); Context *last = 0; @@ -77,22 +77,22 @@ Auto_change_iterator::change_to (Music_iterator *it, SCM to_type_sym, if (current) { if (last) - { - Context *dest - = it->get_outlet ()->find_create_context (to_type_sym, to_id, SCM_EOL); - - send_stream_event (last, "ChangeParent", get_music ()->origin (), - ly_symbol2scm ("context"), dest->self_scm ()); - } + { + Context *dest + = it->get_outlet ()->find_create_context (to_type_sym, to_id, SCM_EOL); + + send_stream_event (last, "ChangeParent", get_music ()->origin (), + ly_symbol2scm ("context"), dest->self_scm ()); + } else - { - /* - We could change the current translator's id, but that would make - errors hard to catch - - */ - ; - } + { + /* + We could change the current translator's id, but that would make + errors hard to catch + + */ + ; + } } } @@ -110,19 +110,19 @@ Auto_change_iterator::process (Moment m) { splitm = unsmob_moment (scm_caar (split_list_)); if ((*splitm + start_moment_) > now) - break; + break; SCM tag = scm_cdar (split_list_); Direction d = to_dir (tag); if (d && d != where_dir_) - { - where_dir_ = d; - string to_id = (d >= 0) ? "up" : "down"; - change_to (child_iter_, - ly_symbol2scm ("Staff"), - to_id); - } + { + where_dir_ = d; + string to_id = (d >= 0) ? "up" : "down"; + change_to (child_iter_, + ly_symbol2scm ("Staff"), + to_id); + } } } @@ -140,17 +140,17 @@ Auto_change_iterator::construct_children () SCM props = get_outlet ()->get_property ("trebleStaffProperties"); Context *up = get_outlet ()->find_create_context (ly_symbol2scm ("Staff"), - "up", props); + "up", props); props = get_outlet ()->get_property ("bassStaffProperties"); Context *down = get_outlet ()->find_create_context (ly_symbol2scm ("Staff"), - "down", props); + "down", props); up_.set_context (up); down_.set_context (down); Context *voice = up->find_create_context (ly_symbol2scm ("Voice"), - "", SCM_EOL); + "", SCM_EOL); set_context (voice); Music_wrapper_iterator::construct_children (); } diff --git a/lily/axis-group-engraver.cc b/lily/axis-group-engraver.cc index 60d16767b0..cde30afebc 100644 --- a/lily/axis-group-engraver.cc +++ b/lily/axis-group-engraver.cc @@ -87,19 +87,19 @@ Axis_group_engraver::process_acknowledged () for (vsize i = 0; i < elts_.size (); i++) { if (!unsmob_grob (elts_[i]->get_object ("axis-group-parent-Y"))) - { - if (staffline_->get_parent (Y_AXIS) - && staffline_->get_parent (Y_AXIS) == elts_[i]) - { - staffline_->warning (_ ("Axis_group_engraver: vertical group already has a parent")); - staffline_->warning (_ ("are there two Axis_group_engravers?")); - staffline_->warning (_ ("removing this vertical group")); - staffline_->suicide (); - staffline_ = 0; - break; - } - add_element (elts_[i]); - } + { + if (staffline_->get_parent (Y_AXIS) + && staffline_->get_parent (Y_AXIS) == elts_[i]) + { + staffline_->warning (_ ("Axis_group_engraver: vertical group already has a parent")); + staffline_->warning (_ ("are there two Axis_group_engravers?")); + staffline_->warning (_ ("removing this vertical group")); + staffline_->suicide (); + staffline_ = 0; + break; + } + add_element (elts_[i]); + } } elts_.clear (); } @@ -113,16 +113,16 @@ Axis_group_engraver::add_element (Grob *e) ADD_ACKNOWLEDGER (Axis_group_engraver, grob); ADD_TRANSLATOR (Axis_group_engraver, - /* doc */ - "Group all objects created in this context in a" - " @code{VerticalAxisGroup} spanner.", + /* doc */ + "Group all objects created in this context in a" + " @code{VerticalAxisGroup} spanner.", - /* create */ - "VerticalAxisGroup ", + /* create */ + "VerticalAxisGroup ", - /* read */ - "currentCommandColumn ", + /* read */ + "currentCommandColumn ", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/axis-group-interface-scheme.cc b/lily/axis-group-interface-scheme.cc index 744bff13aa..fac97c2dee 100644 --- a/lily/axis-group-interface-scheme.cc +++ b/lily/axis-group-interface-scheme.cc @@ -23,9 +23,9 @@ #include "grob-array.hh" LY_DEFINE (ly_relative_group_extent, "ly:relative-group-extent", - 3, 0, 0, (SCM elements, SCM common, SCM axis), - "Determine the extent of @var{elements} relative to @var{common} in the" - " @var{axis} direction.") + 3, 0, 0, (SCM elements, SCM common, SCM axis), + "Determine the extent of @var{elements} relative to @var{common} in the" + " @var{axis} direction.") { Grob_array *ga = unsmob_grob_array (elements); @@ -33,23 +33,23 @@ LY_DEFINE (ly_relative_group_extent, "ly:relative-group-extent", LY_ASSERT_SMOB (Grob, common, 2); LY_ASSERT_TYPE (is_axis, axis, 3); - vector<Grob*> elts; + vector<Grob *> elts; if (!ga) { for (SCM s = elements; scm_is_pair (s); s = scm_cdr (s)) - elts.push_back (unsmob_grob (scm_car (s))); + elts.push_back (unsmob_grob (scm_car (s))); } Interval ext = Axis_group_interface::relative_group_extent (ga ? ga->array () : elts, - unsmob_grob (common), - (Axis) scm_to_int (axis)); + unsmob_grob (common), + (Axis) scm_to_int (axis)); return ly_interval2scm (ext); } LY_DEFINE (ly_axis_group_interface__add_element, "ly:axis-group-interface::add-element", - 2, 0, 0, (SCM grob, SCM grob_element), - "Set @var{grob} the parent of @var{grob-element} on all axes of" - " @var{grob}.") + 2, 0, 0, (SCM grob, SCM grob_element), + "Set @var{grob} the parent of @var{grob-element} on all axes of" + " @var{grob}.") { LY_ASSERT_SMOB (Grob, grob, 1); LY_ASSERT_SMOB (Grob, grob_element, 2); diff --git a/lily/axis-group-interface.cc b/lily/axis-group-interface.cc index e0bd31663f..143534edab 100644 --- a/lily/axis-group-interface.cc +++ b/lily/axis-group-interface.cc @@ -50,12 +50,12 @@ Axis_group_interface::add_element (Grob *me, Grob *e) Axis a = (Axis) scm_to_int (scm_car (ax)); if (!e->get_parent (a)) - e->set_parent (me, a); + e->set_parent (me, a); e->set_object ((a == X_AXIS) - ? ly_symbol2scm ("axis-group-parent-X") - : ly_symbol2scm ("axis-group-parent-Y"), - me->self_scm ()); + ? ly_symbol2scm ("axis-group-parent-X") + : ly_symbol2scm ("axis-group-parent-Y"), + me->self_scm ()); } /* must be ordered, because Align_interface also uses @@ -72,19 +72,19 @@ Axis_group_interface::has_axis (Grob *me, Axis a) } Interval -Axis_group_interface::relative_group_extent (vector<Grob*> const &elts, - Grob *common, Axis a) +Axis_group_interface::relative_group_extent (vector<Grob *> const &elts, + Grob *common, Axis a) { Interval r; for (vsize i = 0; i < elts.size (); i++) { Grob *se = elts[i]; if (!to_boolean (se->get_property ("cross-staff"))) - { - Interval dims = se->extent (common, a); - if (!dims.is_empty ()) - r.unite (dims); - } + { + Interval dims = se->extent (common, a); + if (!dims.is_empty ()) + r.unite (dims); + } } return r; } @@ -101,10 +101,10 @@ Axis_group_interface::sum_partial_pure_heights (Grob *me, int start, int end) Interval Axis_group_interface::part_of_line_pure_height (Grob *me, bool begin, int start, int end) { - Spanner *sp = dynamic_cast<Spanner*> (me); + Spanner *sp = dynamic_cast<Spanner *> (me); SCM cache_symbol = begin - ? ly_symbol2scm ("begin-of-line-pure-height") - : ly_symbol2scm ("rest-of-line-pure-height"); + ? ly_symbol2scm ("begin-of-line-pure-height") + : ly_symbol2scm ("rest-of-line-pure-height"); SCM cached = sp->get_cached_pure_property (cache_symbol, start, end); if (scm_is_pair (cached)) return robust_scm2interval (cached, Interval (0, 0)); @@ -117,13 +117,13 @@ Axis_group_interface::part_of_line_pure_height (Grob *me, bool begin, int start, else { SCM these_pure_heights = begin - ? scm_car (adjacent_pure_heights) - : scm_cdr (adjacent_pure_heights); + ? scm_car (adjacent_pure_heights) + : scm_cdr (adjacent_pure_heights); if (scm_is_vector (these_pure_heights)) - ret = combine_pure_heights (me, these_pure_heights, start, end); + ret = combine_pure_heights (me, these_pure_heights, start, end); else - ret = Interval (0, 0); + ret = Interval (0, 0); } sp->cache_pure_property (cache_symbol, start, end, ly_interval2scm (ret)); @@ -147,17 +147,17 @@ Axis_group_interface::combine_pure_heights (Grob *me, SCM measure_extents, int s { Paper_score *ps = get_root_system (me)->paper_score (); vector<vsize> breaks = ps->get_break_indices (); - vector<Grob*> cols = ps->get_columns (); + vector<Grob *> cols = ps->get_columns (); Interval ext; for (vsize i = 0; i + 1 < breaks.size (); i++) { int r = Paper_column::get_rank (cols[breaks[i]]); if (r >= end) - break; + break; if (r >= start) - ext.unite (ly_scm2interval (scm_c_vector_ref (measure_extents, i))); + ext.unite (ly_scm2interval (scm_c_vector_ref (measure_extents, i))); } return ext; @@ -193,7 +193,7 @@ Axis_group_interface::adjacent_pure_heights (SCM smob) Grob *g = elts[i]; if (to_boolean (g->get_property ("cross-staff"))) - continue; + continue; bool outside_staff = scm_is_number (g->get_property ("outside-staff-priority")); Real padding = robust_scm2double (g->get_property ("outside-staff-padding"), 0.5); @@ -205,10 +205,10 @@ Axis_group_interface::adjacent_pure_heights (SCM smob) // but only the fact that outside-staff grobs may need to be raised above // the staff. if (outside_staff && begin_line_staff_heights.empty ()) - { - begin_line_staff_heights = begin_line_heights; - mid_line_staff_heights = mid_line_heights; - } + { + begin_line_staff_heights = begin_line_heights; + mid_line_staff_heights = mid_line_heights; + } // TODO: consider a pure version of get_grob_direction? Direction d = to_dir (g->get_property_data ("direction")); @@ -217,42 +217,40 @@ Axis_group_interface::adjacent_pure_heights (SCM smob) Interval_t<int> rank_span = g->spanned_rank_interval (); vsize first_break = lower_bound (ranks, (vsize)rank_span[LEFT], less<vsize> ()); if (first_break > 0 && ranks[first_break] >= (vsize)rank_span[LEFT]) - first_break--; - - for (vsize j = first_break; j+1 < ranks.size () && (int)ranks[j] <= rank_span[RIGHT]; ++j) - { - int start = ranks[j]; - int end = ranks[j+1]; - - // Take grobs that are visible with respect to a slightly longer line. - // Otherwise, we will never include grobs at breakpoints which aren't - // end-of-line-visible. - int visibility_end = j + 2 < ranks.size () ? ranks[j+2] : end; - - if (g->pure_is_visible (start, visibility_end)) - { - Interval dims = g->pure_height (common, start, end); - if (!dims.is_empty ()) - { - if (rank_span[LEFT] <= start) - { - if (outside_staff) - begin_line_heights[j].unite ( - begin_line_staff_heights[j].union_disjoint (dims, padding, d)); - else - begin_line_heights[j].unite (dims); - } + first_break--; + + for (vsize j = first_break; j + 1 < ranks.size () && (int)ranks[j] <= rank_span[RIGHT]; ++j) + { + int start = ranks[j]; + int end = ranks[j + 1]; + + // Take grobs that are visible with respect to a slightly longer line. + // Otherwise, we will never include grobs at breakpoints which aren't + // end-of-line-visible. + int visibility_end = j + 2 < ranks.size () ? ranks[j + 2] : end; + + if (g->pure_is_visible (start, visibility_end)) + { + Interval dims = g->pure_height (common, start, end); + if (!dims.is_empty ()) + { + if (rank_span[LEFT] <= start) + { + if (outside_staff) + begin_line_heights[j].unite (begin_line_staff_heights[j].union_disjoint (dims, padding, d)); + else + begin_line_heights[j].unite (dims); + } if (rank_span[RIGHT] > start) - { - if (outside_staff) - mid_line_heights[j].unite ( - mid_line_staff_heights[j].union_disjoint (dims, padding, d)); - else - mid_line_heights[j].unite (dims); - } - } - } - } + { + if (outside_staff) + mid_line_heights[j].unite (mid_line_staff_heights[j].union_disjoint (dims, padding, d)); + else + mid_line_heights[j].unite (dims); + } + } + } + } } // Convert begin_line_heights and min_line_heights to SCM. @@ -291,13 +289,13 @@ Axis_group_interface::relative_pure_height (Grob *me, int start, int end) Grob *g = elts[i]; Interval_t<int> rank_span = g->spanned_rank_interval (); if (rank_span[LEFT] <= end && rank_span[RIGHT] >= start - && g->pure_is_visible (start, end) - && !to_boolean (g->get_property ("cross-staff"))) - { - Interval dims = g->pure_height (common, start, end); - if (!dims.is_empty ()) - r.unite (dims); - } + && g->pure_is_visible (start, end) + && !to_boolean (g->get_property ("cross-staff"))) + { + Interval dims = g->pure_height (common, start, end); + if (!dims.is_empty ()) + r.unite (dims); + } } return r; } @@ -328,13 +326,13 @@ Axis_group_interface::pure_height (SCM smob, SCM start_scm, SCM end_scm) /* Maybe we are in the second pass of a two-pass spacing run. In that case, the Y-extent of a system is already given to us */ - System *system = dynamic_cast<System*> (me); + System *system = dynamic_cast<System *> (me); if (system) { SCM line_break_details = system->column (start)->get_property ("line-break-system-details"); SCM system_y_extent = scm_assq (ly_symbol2scm ("system-Y-extent"), line_break_details); if (scm_is_pair (system_y_extent)) - return scm_cdr (system_y_extent); + return scm_cdr (system_y_extent); } return ly_interval2scm (pure_group_height (me, start, end)); @@ -374,13 +372,13 @@ Axis_group_interface::combine_skylines (SCM smob) { SCM skyline_scm = elements[i]->get_property ("vertical-skylines"); if (Skyline_pair::unsmob (skyline_scm)) - { - Real offset = elements[i]->relative_coordinate (y_common, Y_AXIS); - Skyline_pair other = *Skyline_pair::unsmob (skyline_scm); - other.raise (offset); - other.shift (elements[i]->relative_coordinate (x_common, X_AXIS)); - ret.merge (other); - } + { + Real offset = elements[i]->relative_coordinate (y_common, Y_AXIS); + Skyline_pair other = *Skyline_pair::unsmob (skyline_scm); + other.raise (offset); + other.shift (elements[i]->relative_coordinate (x_common, X_AXIS)); + ret.merge (other); + } } return ret.smobbed_copy (); } @@ -408,7 +406,7 @@ Interval Axis_group_interface::staff_extent (Grob *me, Grob *refp, Axis ext_a, Grob *staff, Axis parent_a) { extract_grob_set (me, "elements", elts); - vector<Grob*> new_elts; + vector<Grob *> new_elts; for (vsize i = 0; i < elts.size (); i++) if (elts[i]->common_refpoint (staff, parent_a) == staff) @@ -417,7 +415,6 @@ Axis_group_interface::staff_extent (Grob *me, Grob *refp, Axis ext_a, Grob *staf return relative_group_extent (new_elts, refp, ext_a); } - MAKE_SCHEME_CALLBACK (Axis_group_interface, calc_pure_relevant_grobs, 1); SCM Axis_group_interface::calc_pure_relevant_grobs (SCM smob) @@ -426,25 +423,25 @@ Axis_group_interface::calc_pure_relevant_grobs (SCM smob) extract_grob_set (me, "elements", elts); - vector<Grob*> relevant_grobs; + vector<Grob *> relevant_grobs; SCM pure_relevant_p = ly_lily_module_constant ("pure-relevant?"); for (vsize i = 0; i < elts.size (); i++) { if (to_boolean (scm_apply_1 (pure_relevant_p, elts[i]->self_scm (), SCM_EOL))) - relevant_grobs.push_back (elts[i]); - - if (Item *it = dynamic_cast<Item*> (elts[i])) - { - Direction d = LEFT; - do - { - Item *piece = it->find_prebroken_piece (d); - if (piece && to_boolean (scm_apply_1 (pure_relevant_p, piece->self_scm (), SCM_EOL))) - relevant_grobs.push_back (piece); - } - while (flip (&d) != LEFT); - } + relevant_grobs.push_back (elts[i]); + + if (Item *it = dynamic_cast<Item *> (elts[i])) + { + Direction d = LEFT; + do + { + Item *piece = it->find_prebroken_piece (d); + if (piece && to_boolean (scm_apply_1 (pure_relevant_p, piece->self_scm (), SCM_EOL))) + relevant_grobs.push_back (piece); + } + while (flip (&d) != LEFT); + } } vector_sort (relevant_grobs, pure_staff_priority_less); @@ -485,7 +482,6 @@ Axis_group_interface::calc_common (Grob *me, Axis axis) return common->self_scm (); } - MAKE_SCHEME_CALLBACK (Axis_group_interface, calc_x_common, 1); SCM Axis_group_interface::calc_x_common (SCM grob) @@ -517,7 +513,7 @@ Axis_group_interface::pure_group_height (Grob *me, int start, int end) } void -Axis_group_interface::get_children (Grob *me, vector<Grob*> *found) +Axis_group_interface::get_children (Grob *me, vector<Grob *> *found) { found->push_back (me); @@ -533,7 +529,7 @@ Axis_group_interface::get_children (Grob *me, vector<Grob*> *found) } static bool -staff_priority_less (Grob * const &g1, Grob * const &g2) +staff_priority_less (Grob *const &g1, Grob *const &g2) { Real priority_1 = robust_scm2double (g1->get_property ("outside-staff-priority"), -infinity_f); Real priority_2 = robust_scm2double (g2->get_property ("outside-staff-priority"), -infinity_f); @@ -557,7 +553,7 @@ staff_priority_less (Grob * const &g1, Grob * const &g2) } static bool -pure_staff_priority_less (Grob * const &g1, Grob * const &g2) +pure_staff_priority_less (Grob *const &g1, Grob *const &g2) { Real priority_1 = robust_scm2double (g1->get_property ("outside-staff-priority"), -infinity_f); Real priority_2 = robust_scm2double (g2->get_property ("outside-staff-priority"), -infinity_f); @@ -579,13 +575,13 @@ add_boxes (Grob *me, Grob *x_common, Grob *y_common, vector<Box> *const boxes, S else if (Grob_array *elements = unsmob_grob_array (me->get_object ("elements"))) { for (vsize i = 0; i < elements->size (); i++) - add_boxes (elements->grob (i), x_common, y_common, boxes, skylines); + add_boxes (elements->grob (i), x_common, y_common, boxes, skylines); } else if (!scm_is_number (me->get_property ("outside-staff-priority")) - && !to_boolean (me->get_property ("cross-staff"))) + && !to_boolean (me->get_property ("cross-staff"))) { boxes->push_back (Box (me->extent (x_common, X_AXIS), - me->extent (y_common, Y_AXIS))); + me->extent (y_common, Y_AXIS))); } } @@ -610,9 +606,9 @@ add_boxes (Grob *me, Grob *x_common, Grob *y_common, vector<Box> *const boxes, S */ static void add_grobs_of_one_priority (Skyline_pair *const skylines, - vector<Grob*> elements, - Grob *x_common, - Grob *y_common) + vector<Grob *> elements, + Grob *x_common, + Grob *y_common) { vector<Box> boxes; Drul_array<Real> last_affected_position; @@ -624,45 +620,45 @@ add_grobs_of_one_priority (Skyline_pair *const skylines, last_affected_position[DOWN] = -infinity_f; /* do one pass */ for (vsize i = elements.size (); i--;) - { - Direction dir = get_grob_direction (elements[i]); - if (dir == CENTER) - { - warning (_ ("an outside-staff object should have a direction, defaulting to up")); - dir = UP; - } - - Box b (elements[i]->extent (x_common, X_AXIS), - elements[i]->extent (y_common, Y_AXIS)); - SCM horizon_padding_scm = elements[i]->get_property ("outside-staff-horizontal-padding"); - Real horizon_padding = robust_scm2double (horizon_padding_scm, 0.0); - - if (b[X_AXIS][LEFT] - 2*horizon_padding < last_affected_position[dir]) - continue; - - if (!b[X_AXIS].is_empty () && !b[Y_AXIS].is_empty ()) - { - boxes.clear (); - boxes.push_back (b); - Skyline other = Skyline (boxes, horizon_padding, X_AXIS, -dir); - Real padding = robust_scm2double (elements[i]->get_property ("outside-staff-padding"), 0.5); - Real dist = (*skylines)[dir].distance (other) + padding; - - if (dist > 0) - { - b.translate (Offset (0, dir*dist)); - elements[i]->translate_axis (dir*dist, Y_AXIS); - } - skylines->insert (b, 0, X_AXIS); - elements[i]->set_property ("outside-staff-priority", SCM_BOOL_F); - last_affected_position[dir] = b[X_AXIS][RIGHT]; - } - - /* - Ugh: quadratic. --hwn - */ - elements.erase (elements.begin () + i); - } + { + Direction dir = get_grob_direction (elements[i]); + if (dir == CENTER) + { + warning (_ ("an outside-staff object should have a direction, defaulting to up")); + dir = UP; + } + + Box b (elements[i]->extent (x_common, X_AXIS), + elements[i]->extent (y_common, Y_AXIS)); + SCM horizon_padding_scm = elements[i]->get_property ("outside-staff-horizontal-padding"); + Real horizon_padding = robust_scm2double (horizon_padding_scm, 0.0); + + if (b[X_AXIS][LEFT] - 2 * horizon_padding < last_affected_position[dir]) + continue; + + if (!b[X_AXIS].is_empty () && !b[Y_AXIS].is_empty ()) + { + boxes.clear (); + boxes.push_back (b); + Skyline other = Skyline (boxes, horizon_padding, X_AXIS, -dir); + Real padding = robust_scm2double (elements[i]->get_property ("outside-staff-padding"), 0.5); + Real dist = (*skylines)[dir].distance (other) + padding; + + if (dist > 0) + { + b.translate (Offset (0, dir * dist)); + elements[i]->translate_axis (dir * dist, Y_AXIS); + } + skylines->insert (b, 0, X_AXIS); + elements[i]->set_property ("outside-staff-priority", SCM_BOOL_F); + last_affected_position[dir] = b[X_AXIS][RIGHT]; + } + + /* + Ugh: quadratic. --hwn + */ + elements.erase (elements.begin () + i); + } } } @@ -685,7 +681,7 @@ Axis_group_interface::has_outside_staff_parent (Grob *me) // that there is no room for the cross-staff grob. It also means, of course, that // we don't get the benefits of skyline placement for cross-staff grobs. Skyline_pair -Axis_group_interface::skyline_spacing (Grob *me, vector<Grob*> elements) +Axis_group_interface::skyline_spacing (Grob *me, vector<Grob *> elements) { /* For grobs with an outside-staff-priority, the sorting function might call extent and cause suicide. This breaks the contract that is required @@ -707,7 +703,7 @@ Axis_group_interface::skyline_spacing (Grob *me, vector<Grob*> elements) Skyline_pair skylines; for (i = 0; i < elements.size () - && !scm_is_number (elements[i]->get_property ("outside-staff-priority")); i++) + && !scm_is_number (elements[i]->get_property ("outside-staff-priority")); i++) if (!(to_boolean (elements[i]->get_property ("cross-staff")) || has_outside_staff_parent (elements[i]))) add_boxes (elements[i], x_common, y_common, &boxes, &skylines); @@ -717,18 +713,18 @@ Axis_group_interface::skyline_spacing (Grob *me, vector<Grob*> elements) for (; i < elements.size (); i++) { if (to_boolean (elements[i]->get_property ("cross-staff"))) - continue; + continue; SCM priority = elements[i]->get_property ("outside-staff-priority"); - vector<Grob*> current_elts; + vector<Grob *> current_elts; current_elts.push_back (elements[i]); while (i + 1 < elements.size () - && scm_eq_p (elements[i+1]->get_property ("outside-staff-priority"), priority)) - { - if (!to_boolean (elements[i+1]->get_property ("cross-staff"))) - current_elts.push_back (elements[i+1]); - ++i; - } + && scm_eq_p (elements[i + 1]->get_property ("outside-staff-priority"), priority)) + { + if (!to_boolean (elements[i + 1]->get_property ("cross-staff"))) + current_elts.push_back (elements[i + 1]); + ++i; + } add_grobs_of_one_priority (&skylines, current_elts, x_common, y_common); } @@ -748,9 +744,9 @@ Axis_group_interface::print (SCM smob) if (Skyline_pair *s = Skyline_pair::unsmob (me->get_property ("vertical-skylines"))) { ret.add_stencil (Lookup::points_to_line_stencil (0.1, (*s)[UP].to_points (X_AXIS)) - .in_color (255, 0, 255)); + .in_color (255, 0, 255)); ret.add_stencil (Lookup::points_to_line_stencil (0.1, (*s)[DOWN].to_points (X_AXIS)) - .in_color (0, 255, 255)); + .in_color (0, 255, 255)); } return ret.smobbed_copy (); } @@ -760,9 +756,9 @@ SCM Axis_group_interface::calc_pure_staff_staff_spacing (SCM smob, SCM start, SCM end) { return calc_maybe_pure_staff_staff_spacing (unsmob_grob (smob), - true, - scm_to_int (start), - scm_to_int (end)); + true, + scm_to_int (start), + scm_to_int (end)); } MAKE_SCHEME_CALLBACK (Axis_group_interface, calc_staff_staff_spacing, 1) @@ -770,9 +766,9 @@ SCM Axis_group_interface::calc_staff_staff_spacing (SCM smob) { return calc_maybe_pure_staff_staff_spacing (unsmob_grob (smob), - false, - 0, - INT_MAX); + false, + 0, + INT_MAX); } SCM @@ -784,9 +780,9 @@ Axis_group_interface::calc_maybe_pure_staff_staff_spacing (Grob *me, bool pure, { bool within_group = Staff_grouper_interface::maybe_pure_within_group (grouper, me, pure, start, end); if (within_group) - return grouper->get_maybe_pure_property ("staff-staff-spacing", pure, start, end); + return grouper->get_maybe_pure_property ("staff-staff-spacing", pure, start, end); else - return grouper->get_maybe_pure_property ("staffgroup-staff-spacing", pure, start, end); + return grouper->get_maybe_pure_property ("staffgroup-staff-spacing", pure, start, end); } return me->get_maybe_pure_property ("default-staff-staff-spacing", pure, start, end); } @@ -804,30 +800,30 @@ Axis_group_interface::minimum_distance (Grob *g1, Grob *g2, Axis a) } ADD_INTERFACE (Axis_group_interface, - "An object that groups other layout objects.", - - // TODO: some of these properties are specific to - // VerticalAxisGroup. We should split off a - // vertical-axis-group-interface. - /* properties */ - "adjacent-pure-heights " - "axes " - "default-staff-staff-spacing " - "elements " - "max-stretch " - "no-alignment " - "nonstaff-nonstaff-spacing " - "nonstaff-relatedstaff-spacing " - "nonstaff-unrelatedstaff-spacing " - "pure-relevant-grobs " - "pure-relevant-items " - "pure-relevant-spanners " - "pure-Y-common " - "staff-affinity " - "staff-grouper " - "staff-staff-spacing " - "system-Y-offset " - "vertical-skylines " - "X-common " - "Y-common " - ); + "An object that groups other layout objects.", + + // TODO: some of these properties are specific to + // VerticalAxisGroup. We should split off a + // vertical-axis-group-interface. + /* properties */ + "adjacent-pure-heights " + "axes " + "default-staff-staff-spacing " + "elements " + "max-stretch " + "no-alignment " + "nonstaff-nonstaff-spacing " + "nonstaff-relatedstaff-spacing " + "nonstaff-unrelatedstaff-spacing " + "pure-relevant-grobs " + "pure-relevant-items " + "pure-relevant-spanners " + "pure-Y-common " + "staff-affinity " + "staff-grouper " + "staff-staff-spacing " + "system-Y-offset " + "vertical-skylines " + "X-common " + "Y-common " + ); diff --git a/lily/balloon-engraver.cc b/lily/balloon-engraver.cc index 95e807339f..566c705283 100644 --- a/lily/balloon-engraver.cc +++ b/lily/balloon-engraver.cc @@ -33,8 +33,8 @@ class Balloon_engraver : public Engraver vector<Stream_event *> events_; void stop_translation_timestep (); - - void balloonify (Grob *, Stream_event *); + + void balloonify (Grob *, Stream_event *); }; IMPLEMENT_TRANSLATOR_LISTENER (Balloon_engraver, annotate_output); @@ -57,7 +57,7 @@ Balloon_engraver::Balloon_engraver () void Balloon_engraver::balloonify (Grob *g, Stream_event *event) { - Grob * b = make_item ("BalloonTextItem", event->self_scm ()); + Grob *b = make_item ("BalloonTextItem", event->self_scm ()); b->set_property ("text", event->get_property ("text")); b->set_parent (g, Y_AXIS); b->set_parent (g, X_AXIS); @@ -67,38 +67,36 @@ void Balloon_engraver::acknowledge_grob (Grob_info info) { Stream_event *cause = info.event_cause (); - + SCM arts = cause ? cause->get_property ("articulations") : SCM_EOL; for (SCM s = arts; scm_is_pair (s); s = scm_cdr (s)) { Stream_event *e = unsmob_stream_event (scm_car (s)); if (e->in_event_class ("annotate-output-event")) - { - balloonify (info.grob (), e); - } + { + balloonify (info.grob (), e); + } } for (vsize i = 0; i < events_.size (); i++) { if (info.grob ()->name () == ly_symbol2string (events_[i]->get_property ("symbol"))) - balloonify (info.grob (), events_[i]); + balloonify (info.grob (), events_[i]); } } - - ADD_ACKNOWLEDGER (Balloon_engraver, grob); - + ADD_TRANSLATOR (Balloon_engraver, - /* doc */ - "Create balloon texts.", + /* doc */ + "Create balloon texts.", - /* create */ - "BalloonTextItem ", + /* create */ + "BalloonTextItem ", - /*read*/ - "", + /*read*/ + "", - /*write*/ - "" - ); + /*write*/ + "" + ); diff --git a/lily/balloon.cc b/lily/balloon.cc index b9872b2cd5..3d3f15c3ca 100644 --- a/lily/balloon.cc +++ b/lily/balloon.cc @@ -51,7 +51,7 @@ Balloon_interface::print (SCM smob) Grob *p = me->get_parent (X_AXIS); Offset off (me->relative_coordinate (p, X_AXIS), - me->relative_coordinate (p, Y_AXIS)); + me->relative_coordinate (p, Y_AXIS)); return internal_balloon_print (me, p, off); } @@ -65,24 +65,23 @@ Balloon_interface::print_spanner (SCM smob) if (orig) { - Direction spanner_placement = robust_scm2dir (me->get_property ("spanner-placement"), LEFT); + Direction spanner_placement = robust_scm2dir (me->get_property ("spanner-placement"), LEFT); Spanner *wanted = (spanner_placement != RIGHT) - ? orig->broken_intos_[0] - : orig->broken_intos_.back (); + ? orig->broken_intos_[0] + : orig->broken_intos_.back (); if (me != wanted) return SCM_EOL; } - Spanner *p = dynamic_cast<Spanner *> (me->get_parent (Y_AXIS)); if (!p) return SCM_EOL; Offset off (me->relative_coordinate (me->get_bound (LEFT), X_AXIS), - me->relative_coordinate (p, Y_AXIS)); + me->relative_coordinate (p, Y_AXIS)); return internal_balloon_print (me, p, off); } @@ -90,7 +89,7 @@ SCM Balloon_interface::internal_balloon_print (Grob *me, Grob *p, Offset off) { Box b (p->extent (p, X_AXIS), - p->extent (p, Y_AXIS)); + p->extent (p, Y_AXIS)); Real padding = robust_scm2double (me->get_property ("padding"), .1); b.widen (padding, padding); @@ -104,7 +103,7 @@ Balloon_interface::internal_balloon_print (Grob *me, Grob *p, Offset off) SCM stencil = Text_interface::interpret_markup (me->layout ()->self_scm (), chain, bt); Stencil *text_stil = unsmob_stencil (stencil); - + Offset z1; for (int i = X_AXIS; i < NO_AXES; i++) @@ -127,14 +126,14 @@ Balloon_interface::internal_balloon_print (Grob *me, Grob *p, Offset off) } ADD_INTERFACE (Balloon_interface, - "A collection of routines to put text balloons around an" - " object.", - - /* properties */ - "annotation-balloon " - "annotation-line " - "padding " - "spanner-placement " - "text " - ); + "A collection of routines to put text balloons around an" + " object.", + + /* properties */ + "annotation-balloon " + "annotation-line " + "padding " + "spanner-placement " + "text " + ); diff --git a/lily/bar-check-iterator.cc b/lily/bar-check-iterator.cc index 09f06b1fc2..a4d8f4c44b 100644 --- a/lily/bar-check-iterator.cc +++ b/lily/bar-check-iterator.cc @@ -51,38 +51,38 @@ Bar_check_iterator::process (Moment m) SCM check = tr->get_property ("ignoreBarChecks"); if (to_boolean (check)) - return; + return; SCM mp = tr->get_property ("measurePosition"); SCM sync = tr->get_property ("barCheckSynchronize"); Moment *where = unsmob_moment (mp); if (!where) - return; + return; if (where->main_part_) - { - bool warn = true; - if (to_boolean (sync)) - { - SCM mp; - tr = tr->where_defined (ly_symbol2scm ("measurePosition"), &mp); - Moment zero; - tr->set_property ("measurePosition", zero.smobbed_copy ()); - } - else - { - SCM lf = tr->get_property ("barCheckLastFail"); - if (unsmob_moment (lf) - && *unsmob_moment (lf) == *where) - warn = false; - else - tr->set_property ("barCheckLastFail", mp); - } + { + bool warn = true; + if (to_boolean (sync)) + { + SCM mp; + tr = tr->where_defined (ly_symbol2scm ("measurePosition"), &mp); + Moment zero; + tr->set_property ("measurePosition", zero.smobbed_copy ()); + } + else + { + SCM lf = tr->get_property ("barCheckLastFail"); + if (unsmob_moment (lf) + && *unsmob_moment (lf) == *where) + warn = false; + else + tr->set_property ("barCheckLastFail", mp); + } - if (warn) - get_music ()->origin ()->warning (_f ("barcheck failed at: %s", - where->to_string ())); - } + if (warn) + get_music ()->origin ()->warning (_f ("barcheck failed at: %s", + where->to_string ())); + } } } diff --git a/lily/bar-engraver.cc b/lily/bar-engraver.cc index badd058e54..8a75d25619 100644 --- a/lily/bar-engraver.cc +++ b/lily/bar-engraver.cc @@ -46,7 +46,7 @@ private: void create_bar (); Item *bar_; - vector<Spanner*> spanners_; + vector<Spanner *> spanners_; }; Bar_engraver::Bar_engraver () @@ -62,7 +62,7 @@ Bar_engraver::create_bar () bar_ = make_item ("BarLine", SCM_EOL); SCM gl = get_property ("whichBar"); if (scm_equal_p (gl, bar_->get_property ("glyph")) != SCM_BOOL_T) - bar_->set_property ("glyph", gl); + bar_->set_property ("glyph", gl); } } @@ -107,23 +107,23 @@ Bar_engraver::acknowledge_end_spanner (Grob_info gi) Grob *g = gi.grob (); if (to_boolean (g->get_property ("to-barline"))) - spanners_.push_back (dynamic_cast<Spanner*> (g)); + spanners_.push_back (dynamic_cast<Spanner *> (g)); } ADD_END_ACKNOWLEDGER (Bar_engraver, spanner); ADD_TRANSLATOR (Bar_engraver, - /* doc */ - "Create barlines. This engraver is controlled through the" - " @code{whichBar} property. If it has no bar line to create," - " it will forbid a linebreak at this point.", + /* doc */ + "Create barlines. This engraver is controlled through the" + " @code{whichBar} property. If it has no bar line to create," + " it will forbid a linebreak at this point.", - /* create */ - "BarLine ", + /* create */ + "BarLine ", - /* read */ - "whichBar ", + /* read */ + "whichBar ", - /* write */ - "forbidBreak " - ); + /* write */ + "forbidBreak " + ); diff --git a/lily/bar-line.cc b/lily/bar-line.cc index a2d6588726..a56c5f6408 100644 --- a/lily/bar-line.cc +++ b/lily/bar-line.cc @@ -68,18 +68,18 @@ Bar_line::print (SCM smob) string str = ly_scm2string (s); Interval ex = ly_scm2interval (extent); if (ex.length () > 0) - { - Stencil result = compound_barline (me, str, ex, false); + { + Stencil result = compound_barline (me, str, ex, false); - return result.smobbed_copy (); - } + return result.smobbed_copy (); + } } return SCM_EOL; } Stencil Bar_line::compound_barline (Grob *me, string str, Interval const &extent, - bool rounded) + bool rounded) { Real kern = robust_scm2double (me->get_property ("kern"), 1); Real thinkern = robust_scm2double (me->get_property ("thin-kern"), 1); @@ -184,10 +184,10 @@ Bar_line::compound_barline (Grob *me, string str, Interval const &extent, else if (str == "||") { /* - should align to other side? this never appears - on the system-start? - m.add_at_edge (X_AXIS, RIGHT, thin, 0); - m.add_at_edge (X_AXIS, RIGHT, thin, thinkern); + should align to other side? this never appears + on the system-start? + m.add_at_edge (X_AXIS, RIGHT, thin, 0); + m.add_at_edge (X_AXIS, RIGHT, thin, thinkern); */ m.add_at_edge (X_AXIS, LEFT, thin, thinkern); m.add_at_edge (X_AXIS, RIGHT, thin, thinkern); @@ -201,72 +201,72 @@ Bar_line::compound_barline (Grob *me, string str, Interval const &extent, segno.add_stencil (Font_interface::get_default_font (me)->find_by_name ("scripts.varsegno")); if (str == "S") - m.add_stencil (segno); + m.add_stencil (segno); else if (str == "S|:" || str == ".S|:") - { - m.add_at_edge (X_AXIS, RIGHT, thick, 0); - m.add_at_edge (X_AXIS, RIGHT, thin, kern); - m.add_at_edge (X_AXIS, RIGHT, colon, kern); - m.add_at_edge (X_AXIS, LEFT, segno, thinkern); - } + { + m.add_at_edge (X_AXIS, RIGHT, thick, 0); + m.add_at_edge (X_AXIS, RIGHT, thin, kern); + m.add_at_edge (X_AXIS, RIGHT, colon, kern); + m.add_at_edge (X_AXIS, LEFT, segno, thinkern); + } else if (str == ":|S" || str == ":|S.") - { - m.add_at_edge (X_AXIS, LEFT, thick, 0); - m.add_at_edge (X_AXIS, LEFT, thin, kern); - m.add_at_edge (X_AXIS, LEFT, colon, kern); - m.add_at_edge (X_AXIS, RIGHT, segno, thinkern); - } + { + m.add_at_edge (X_AXIS, LEFT, thick, 0); + m.add_at_edge (X_AXIS, LEFT, thin, kern); + m.add_at_edge (X_AXIS, LEFT, colon, kern); + m.add_at_edge (X_AXIS, RIGHT, segno, thinkern); + } else if (str == ":|S|:" || str == ":|S.|:") - { - m.add_at_edge (X_AXIS, LEFT, thick, 0); - m.add_at_edge (X_AXIS, LEFT, thin, kern); - m.add_at_edge (X_AXIS, LEFT, colon, kern); - m.add_at_edge (X_AXIS, RIGHT, segno, thinkern); - m.add_at_edge (X_AXIS, RIGHT, thick, thinkern); - m.add_at_edge (X_AXIS, RIGHT, thin, kern); - m.add_at_edge (X_AXIS, RIGHT, colon, kern); - } + { + m.add_at_edge (X_AXIS, LEFT, thick, 0); + m.add_at_edge (X_AXIS, LEFT, thin, kern); + m.add_at_edge (X_AXIS, LEFT, colon, kern); + m.add_at_edge (X_AXIS, RIGHT, segno, thinkern); + m.add_at_edge (X_AXIS, RIGHT, thick, thinkern); + m.add_at_edge (X_AXIS, RIGHT, thin, kern); + m.add_at_edge (X_AXIS, RIGHT, colon, kern); + } else if (str == "|._.|") // :|S|: or :|S.|: without segno and colon - { - // get the width of the segno sign - Real segno_width = segno.extent (X_AXIS).length (); - m.add_at_edge (X_AXIS, LEFT, thick, 0); - m.add_at_edge (X_AXIS, LEFT, thin, kern); - m.add_at_edge (X_AXIS, RIGHT, thick, segno_width + 2 * thinkern); - m.add_at_edge (X_AXIS, RIGHT, thin, kern); - } + { + // get the width of the segno sign + Real segno_width = segno.extent (X_AXIS).length (); + m.add_at_edge (X_AXIS, LEFT, thick, 0); + m.add_at_edge (X_AXIS, LEFT, thin, kern); + m.add_at_edge (X_AXIS, RIGHT, thick, segno_width + 2 * thinkern); + m.add_at_edge (X_AXIS, RIGHT, thin, kern); + } // end varsegno block } else if (str == ":") { if (Grob *staff = Staff_symbol_referencer::get_staff_symbol (me)) - { - Interval staff_extent = staff->extent (staff, Y_AXIS); - - /* - assume staff lines are disposed equally at unit space; - put a dot into each space within extent (may extend staff_extent). - - staff_extent is an interval of two integers or two half-integers; - in the former case dots are to be placed at half-integers, - in the latter at integers. - - these integers are not exact due to staff line thickness. - */ - int const pos = int (rint (staff_extent.at (UP) * 2)); - Real const correction = pos & 1 ? 0.0 : 0.5; - - for (int i = int (rint (extent.at (DOWN) + (0.5 - correction))), - e = int (rint (extent.at (UP) + (0.5 - correction))); - i < e; - ++i) - { - Stencil d (dot); - - d.translate_axis (i + correction, Y_AXIS); - m.add_stencil (d); - } - } + { + Interval staff_extent = staff->extent (staff, Y_AXIS); + + /* + assume staff lines are disposed equally at unit space; + put a dot into each space within extent (may extend staff_extent). + + staff_extent is an interval of two integers or two half-integers; + in the former case dots are to be placed at half-integers, + in the latter at integers. + + these integers are not exact due to staff line thickness. + */ + int const pos = int (rint (staff_extent.at (UP) * 2)); + Real const correction = pos & 1 ? 0.0 : 0.5; + + for (int i = int (rint (extent.at (DOWN) + (0.5 - correction))), + e = int (rint (extent.at (UP) + (0.5 - correction))); + i < e; + ++i) + { + Stencil d (dot); + + d.translate_axis (i + correction, Y_AXIS); + m.add_stencil (d); + } + } } else if (str == "dashed") m = dashed_bar_line (me, extent, hair); @@ -278,14 +278,14 @@ Bar_line::compound_barline (Grob *me, string str, Interval const &extent, Stencil Bar_line::simple_barline (Grob *me, - Real w, - Interval const &extent, - bool rounded) + Real w, + Interval const &extent, + bool rounded) { Real blot = rounded - ? me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter")) - : 0.0; + ? me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter")) + : 0.0; return Lookup::round_filled_box (Box (Interval (0, w), extent), blot); } @@ -298,11 +298,11 @@ Bar_line::tick_bar_line (Grob *me, Real h, bool rounded) Real blot = rounded - ? me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter")) - : 0.0; + ? me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter")) + : 0.0; return Lookup::round_filled_box (Box (Interval (0, line_thick), - Interval (h - th, h + th)), blot); + Interval (h - th, h + th)), blot); } Stencil @@ -330,40 +330,40 @@ Bar_line::dashed_bar_line (Grob *me, Interval const &extent, Real thick) if (fabs (h / ss - dashes) < 0.1) { Real blot - = me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter")); + = me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter")); Real const half_dash = dash_size / 2; Stencil bar; for (int i = 0; i <= dashes; ++i) - { - Real top_y = extent.at (DOWN) - + (i == dashes ? h : (i + half_dash) * ss); - Real bot_y = extent.at (DOWN) + (i ? (i - half_dash) * ss : 0.0); - - bar.add_stencil (Lookup::round_filled_box (Box (Interval (0, thick), - Interval (bot_y, top_y)), - blot)); - } + { + Real top_y = extent.at (DOWN) + + (i == dashes ? h : (i + half_dash) * ss); + Real bot_y = extent.at (DOWN) + (i ? (i - half_dash) * ss : 0.0); + + bar.add_stencil (Lookup::round_filled_box (Box (Interval (0, thick), + Interval (bot_y, top_y)), + blot)); + } return bar; } else { /* - We have to scale the dashing so it starts and ends with half a - dash exactly. + We have to scale the dashing so it starts and ends with half a + dash exactly. */ Real total_dash_size = h / dashes; Real factor = (dash_size - thick) / ss; SCM at = scm_list_n (ly_symbol2scm ("dashed-line"), - scm_from_double (thick), - scm_from_double (factor * total_dash_size), - scm_from_double ((1 - factor) * total_dash_size), - scm_from_double (0), - scm_from_double (h), - scm_from_double (factor * total_dash_size * 0.5), - SCM_UNDEFINED); + scm_from_double (thick), + scm_from_double (factor * total_dash_size), + scm_from_double ((1 - factor) * total_dash_size), + scm_from_double (0), + scm_from_double (h), + scm_from_double (factor * total_dash_size * 0.5), + SCM_UNDEFINED); Box box; box.add_point (Offset (0, 0)); @@ -405,56 +405,56 @@ Bar_line::calc_anchor (SCM smob) } ADD_INTERFACE (Bar_line, - "Bar line.\n" - "\n" - "Print a special bar symbol. It replaces the regular bar" - " symbol with a special symbol. The argument @var{bartype}" - " is a string which specifies the kind of bar line to print." - " Options are @code{|}, @code{:|}, @code{|:}, @code{:|:}, @code{:|.|:}," - " @code{:|.:}, @code{.}, @code{||}, @code{|.}, @code{.|}, @code{.|.}," - " @code{|.|}, @code{:}, @code{dashed}, @code{'} and @code{S}.\n" - "\n" - "These produce, respectively, a normal bar line, a right repeat, a left repeat," - " a thick double repeat, a thin-thick-thin double repeat," - " a thin-thick double repeat, a thick bar, a double bar, a start bar," - " an end bar, a thick double bar, a thin-thick-thin bar," - " a dotted bar, a dashed bar, a tick as bar line and a segno bar.\n" - "\n" - "In addition, there is an option" - " @code{||:} which is equivalent to @code{|:} except at line" - " breaks, where it produces a double bar (@code{||}) at the" - " end of the line and a repeat sign (@code{|:}) at the" - " beginning of the new line.\n" - "\n" - "For segno, @code{S} produces a segno sign except at line breaks," - " where it produces a double bar (@code{||}) at the" - " end of the line and a segno sign at the beginning of the new line." - " @code{|S} is equivalent to @code{S} but produces a simple bar line" - " (@code{|}) instead of a double bar line (@code{||}) at line breaks." - " @code{S|} produces the segno sign at line breaks and starts the following" - " line without special bar lines.\n" - "\n" - "@code{S|:} and @code{:|S} are used for repeat/segno combinations that are" - " separated at line breaks. Alternatively, @code{.S|:} and @code{:|S.}" - " may be used which combine repeat signs and segno at the same line in" - " case of a line break. @code{:|S|:} is a combination of a left repeat" - " (@code{:|}), a segno (@code{S}) and a right repeat @code{|:} which" - " splits before the segno at line breaks; @code{:|S.|:} splits after" - " the segno sign.\n" - "\n" - "If @var{bartype} is set to @code{empty} then nothing is" - " printed, but a line break is allowed at that spot.\n" - "\n" - "@code{gap} is used for the gaps in dashed bar lines.", - - /* properties */ - "allow-span-bar " - "gap " - "kern " - "thin-kern " - "hair-thickness " - "thick-thickness " - "glyph " - "glyph-name " - "bar-extent " - ); + "Bar line.\n" + "\n" + "Print a special bar symbol. It replaces the regular bar" + " symbol with a special symbol. The argument @var{bartype}" + " is a string which specifies the kind of bar line to print." + " Options are @code{|}, @code{:|}, @code{|:}, @code{:|:}, @code{:|.|:}," + " @code{:|.:}, @code{.}, @code{||}, @code{|.}, @code{.|}, @code{.|.}," + " @code{|.|}, @code{:}, @code{dashed}, @code{'} and @code{S}.\n" + "\n" + "These produce, respectively, a normal bar line, a right repeat, a left repeat," + " a thick double repeat, a thin-thick-thin double repeat," + " a thin-thick double repeat, a thick bar, a double bar, a start bar," + " an end bar, a thick double bar, a thin-thick-thin bar," + " a dotted bar, a dashed bar, a tick as bar line and a segno bar.\n" + "\n" + "In addition, there is an option" + " @code{||:} which is equivalent to @code{|:} except at line" + " breaks, where it produces a double bar (@code{||}) at the" + " end of the line and a repeat sign (@code{|:}) at the" + " beginning of the new line.\n" + "\n" + "For segno, @code{S} produces a segno sign except at line breaks," + " where it produces a double bar (@code{||}) at the" + " end of the line and a segno sign at the beginning of the new line." + " @code{|S} is equivalent to @code{S} but produces a simple bar line" + " (@code{|}) instead of a double bar line (@code{||}) at line breaks." + " @code{S|} produces the segno sign at line breaks and starts the following" + " line without special bar lines.\n" + "\n" + "@code{S|:} and @code{:|S} are used for repeat/segno combinations that are" + " separated at line breaks. Alternatively, @code{.S|:} and @code{:|S.}" + " may be used which combine repeat signs and segno at the same line in" + " case of a line break. @code{:|S|:} is a combination of a left repeat" + " (@code{:|}), a segno (@code{S}) and a right repeat @code{|:} which" + " splits before the segno at line breaks; @code{:|S.|:} splits after" + " the segno sign.\n" + "\n" + "If @var{bartype} is set to @code{empty} then nothing is" + " printed, but a line break is allowed at that spot.\n" + "\n" + "@code{gap} is used for the gaps in dashed bar lines.", + + /* properties */ + "allow-span-bar " + "gap " + "kern " + "thin-kern " + "hair-thickness " + "thick-thickness " + "glyph " + "glyph-name " + "bar-extent " + ); diff --git a/lily/bar-number-engraver.cc b/lily/bar-number-engraver.cc index 82bc09f0ed..269ed12620 100644 --- a/lily/bar-number-engraver.cc +++ b/lily/bar-number-engraver.cc @@ -52,18 +52,18 @@ Bar_number_engraver::process_music () { Moment mp (robust_scm2moment (get_property ("measurePosition"), Moment (0))); if (mp.main_part_ == Rational (0)) - { - SCM bn = get_property ("currentBarNumber"); - SCM proc = get_property ("barNumberVisibility"); - if (scm_is_number (bn) && ly_is_procedure (proc) - && to_boolean (scm_call_1 (proc, bn))) - { - create_items (); - // guh. - text_->set_property - ("text", scm_number_to_string (bn, scm_from_int (10))); - } - } + { + SCM bn = get_property ("currentBarNumber"); + SCM proc = get_property ("barNumberVisibility"); + if (scm_is_number (bn) && ly_is_procedure (proc) + && to_boolean (scm_call_1 (proc, bn))) + { + create_items (); + // guh. + text_->set_property + ("text", scm_number_to_string (bn, scm_from_int (10))); + } + } } } @@ -89,7 +89,7 @@ Bar_number_engraver::stop_translation_timestep () if (text_) { text_->set_object ("side-support-elements", - grob_list_to_grob_array (get_property ("stavesFound"))); + grob_list_to_grob_array (get_property ("stavesFound"))); text_ = 0; } } @@ -103,27 +103,26 @@ Bar_number_engraver::create_items () text_ = make_item ("BarNumber", SCM_EOL); } - ADD_ACKNOWLEDGER (Bar_number_engraver, break_alignment); ADD_TRANSLATOR (Bar_number_engraver, - /* doc */ - "A bar number is created whenever @code{measurePosition} is" - " zero and when there is a bar line (i.e., when" - " @code{whichBar} is set). It is put on top of all staves," - " and appears only at the left side of the staff. The staves" - " are taken from @code{stavesFound}, which is maintained by" - " @ref{Staff_collecting_engraver}.", - - /* create */ - "BarNumber ", - - /* read */ - "currentBarNumber " - "whichBar " - "stavesFound " - "barNumberVisibility ", - - /* write */ - "" - ); + /* doc */ + "A bar number is created whenever @code{measurePosition} is" + " zero and when there is a bar line (i.e., when" + " @code{whichBar} is set). It is put on top of all staves," + " and appears only at the left side of the staff. The staves" + " are taken from @code{stavesFound}, which is maintained by" + " @ref{Staff_collecting_engraver}.", + + /* create */ + "BarNumber ", + + /* read */ + "currentBarNumber " + "whichBar " + "stavesFound " + "barNumberVisibility ", + + /* write */ + "" + ); diff --git a/lily/beam-collision-engraver.cc b/lily/beam-collision-engraver.cc index cdb4be6270..fa82932559 100644 --- a/lily/beam-collision-engraver.cc +++ b/lily/beam-collision-engraver.cc @@ -177,15 +177,15 @@ ADD_ACKNOWLEDGER (Beam_collision_engraver, time_signature); ADD_ACKNOWLEDGER (Beam_collision_engraver, beam); ADD_TRANSLATOR (Beam_collision_engraver, - /* doc */ - "Help beams avoid colliding with notes and clefs in other voices.", + /* doc */ + "Help beams avoid colliding with notes and clefs in other voices.", - /* create */ - "", + /* create */ + "", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/beam-concave.cc b/lily/beam-concave.cc index 7ca626b609..501b753d21 100644 --- a/lily/beam-concave.cc +++ b/lily/beam-concave.cc @@ -69,16 +69,16 @@ is_concave_single_notes (vector<int> const &positions, Direction beam_dir) { int inner_dy = positions[i] - positions[i - 1]; if (sign (inner_dy) != sign (dy) - && (beam_dir * positions[i] >= closest - || beam_dir * positions[i - 1] >= closest)) - concave = true; + && (beam_dir * positions[i] >= closest + || beam_dir * positions[i - 1] >= closest)) + concave = true; } bool all_closer = true; for (vsize i = 1; all_closer && i + 1 < positions.size (); i++) { all_closer = all_closer - && (beam_dir * positions[i] > closest); + && (beam_dir * positions[i] > closest); } concave = concave || all_closer; @@ -109,14 +109,13 @@ calc_positions_concaveness (vector<int> const &positions, Direction beam_dir) return concaveness; } - MAKE_SCHEME_CALLBACK (Beam, calc_concaveness, 1); SCM Beam::calc_concaveness (SCM smob) { Grob *me = unsmob_grob (smob); - vector<Grob*> stems + vector<Grob *> stems = extract_grob_array (me, "stems"); if (is_knee (me)) @@ -126,12 +125,12 @@ Beam::calc_concaveness (SCM smob) for (vsize i = stems.size (); i--;) { if (Stem::is_normal_stem (stems[i])) - { - if (Direction dir = get_grob_direction (stems[i])) - beam_dir = dir; - } + { + if (Direction dir = get_grob_direction (stems[i])) + beam_dir = dir; + } else - stems.erase (stems.begin () + i); + stems.erase (stems.begin () + i); } if (stems.size () <= 2) @@ -142,11 +141,11 @@ Beam::calc_concaveness (SCM smob) for (vsize i = 0; i < stems.size (); i++) { /* - For chords, we take the note head that is closest to the beam. + For chords, we take the note head that is closest to the beam. - Hmmm.. wait, for the beams in the last measure of morgenlied, - this doesn't look so good. Let's try the heads farthest from - the beam. + Hmmm.. wait, for the beams in the last measure of morgenlied, + this doesn't look so good. Let's try the heads farthest from + the beam. */ Interval posns = Stem::head_positions (stems[i]); @@ -163,11 +162,9 @@ Beam::calc_concaveness (SCM smob) else { concaveness = (calc_positions_concaveness (far_positions, beam_dir) - + calc_positions_concaveness (close_positions, beam_dir)) / 2; + + calc_positions_concaveness (close_positions, beam_dir)) / 2; } return scm_from_double (concaveness); } - - diff --git a/lily/beam-engraver.cc b/lily/beam-engraver.cc index 04e571f68a..654a7f57d1 100644 --- a/lily/beam-engraver.cc +++ b/lily/beam-engraver.cc @@ -123,7 +123,7 @@ Beam_engraver::listen_beam (Stream_event *ev) Direction updown = to_dir (ev->get_property ("direction")); if (updown) - forced_direction_ = updown; + forced_direction_ = updown; } else if (d == STOP && valid_end_point ()) ASSIGN_EVENT_ONCE (stop_ev_, ev); @@ -143,17 +143,17 @@ Beam_engraver::process_music () if (start_ev_) { if (beam_) - { - start_ev_->origin ()->warning (_ ("already have a beam")); - return; - } + { + start_ev_->origin ()->warning (_ ("already have a beam")); + return; + } set_melisma (true); prev_start_ev_ = start_ev_; beam_ = make_spanner ("Beam", start_ev_->self_scm ()); Moment mp (robust_scm2moment (get_property ("measurePosition"), - Moment (0))); + Moment (0))); beam_start_location_ = mp; beam_start_mom_ = now_mom (); @@ -177,13 +177,13 @@ Beam_engraver::typeset_beam () if (finished_beam_) { if (!finished_beam_->get_bound (RIGHT)) - finished_beam_->set_bound (RIGHT, finished_beam_->get_bound (LEFT)); + finished_beam_->set_bound (RIGHT, finished_beam_->get_bound (LEFT)); if (forced_direction_) - { - Grob *stem = finished_beam_->get_bound (RIGHT); - set_grob_direction (stem, forced_direction_); - forced_direction_ = CENTER; - } + { + Grob *stem = finished_beam_->get_bound (RIGHT); + set_grob_direction (stem, forced_direction_); + forced_direction_ = CENTER; + } finished_beam_info_->beamify (finished_beaming_options_); Beam::set_beaming (finished_beam_, finished_beam_info_); @@ -230,8 +230,8 @@ Beam_engraver::finalize () prev_start_ev_->origin ()->warning (_ ("unterminated beam")); /* - we don't typeset it, (we used to, but it was commented - out. Reason unknown) */ + we don't typeset it, (we used to, but it was commented + out. Reason unknown) */ beam_->suicide (); delete beam_info_; } @@ -243,7 +243,7 @@ Beam_engraver::acknowledge_rest (Grob_info info) if (beam_ && !scm_is_number (info.grob ()->get_property_data ("staff-position"))) chain_offset_callback (info.grob (), - Beam::rest_collision_callback_proc, Y_AXIS); + Beam::rest_collision_callback_proc, Y_AXIS); } void @@ -274,9 +274,9 @@ Beam_engraver::acknowledge_stem (Grob_info info) ev->origin ()->warning (_ ("stem does not fit in beam")); prev_start_ev_->origin ()->warning (_ ("beam was started here")); /* - don't return, since + don't return, since - [r4 c8] can just as well be modern notation. + [r4 c8] can just as well be modern notation. */ } @@ -286,8 +286,8 @@ Beam_engraver::acknowledge_stem (Grob_info info) stem->set_property ("duration-log", scm_from_int (durlog)); Moment stem_location = now - beam_start_mom_ + beam_start_location_; beam_info_->add_stem (stem_location, - max (durlog- 2, 0), - Stem::is_invisible (stem)); + max (durlog - 2, 0), + Stem::is_invisible (stem)); Beam::add_stem (beam_, stem); } @@ -295,22 +295,22 @@ ADD_ACKNOWLEDGER (Beam_engraver, stem); ADD_ACKNOWLEDGER (Beam_engraver, rest); ADD_TRANSLATOR (Beam_engraver, - /* doc */ - "Handle @code{Beam} events by engraving beams. If omitted," - " then notes are printed with flags instead of beams.", + /* doc */ + "Handle @code{Beam} events by engraving beams. If omitted," + " then notes are printed with flags instead of beams.", - /* create */ - "Beam ", + /* create */ + "Beam ", - /* read */ + /* read */ "baseMoment " - "beamMelismaBusy " - "beatStructure " - "subdivideBeams ", + "beamMelismaBusy " + "beatStructure " + "subdivideBeams ", - /* write */ - "forbidBreak" - ); + /* write */ + "forbidBreak" + ); class Grace_beam_engraver : public Beam_engraver { @@ -357,26 +357,25 @@ Grace_beam_engraver::listen_beam (Stream_event *ev) stop_ev_ = ev; } - ADD_ACKNOWLEDGER (Grace_beam_engraver, stem); ADD_ACKNOWLEDGER (Grace_beam_engraver, rest); ADD_TRANSLATOR (Grace_beam_engraver, - /* doc */ - "Handle @code{Beam} events by engraving beams. If omitted," - " then notes are printed with flags instead of beams. Only" - " engraves beams when we are at grace points in time.", + /* doc */ + "Handle @code{Beam} events by engraving beams. If omitted," + " then notes are printed with flags instead of beams. Only" + " engraves beams when we are at grace points in time.", - /* create */ - "Beam ", + /* create */ + "Beam ", - /* read */ + /* read */ "baseMoment " - "beamMelismaBusy " - "beatStructure " - "subdivideBeams ", + "beamMelismaBusy " + "beatStructure " + "subdivideBeams ", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/beam-performer.cc b/lily/beam-performer.cc index d14879bf93..cbd9d206e9 100644 --- a/lily/beam-performer.cc +++ b/lily/beam-performer.cc @@ -104,5 +104,5 @@ ADD_TRANSLATOR (Beam_performer, /* write */ "" - ); + ); diff --git a/lily/beam-quanting.cc b/lily/beam-quanting.cc index c5cafd5cfa..8b0c9f2abc 100644 --- a/lily/beam-quanting.cc +++ b/lily/beam-quanting.cc @@ -21,7 +21,7 @@ #include "beam-scoring-problem.hh" #include <algorithm> -#include <queue> +#include <queue> #include <set> using namespace std; @@ -103,15 +103,15 @@ void Beam_configuration::add (Real demerit, const string &reason) demerits += demerit; #if DEBUG_BEAM_SCORING - if (demerit) + if (demerit) score_card_ += to_string (" %s %.2f", reason.c_str (), demerit); #endif } - -Beam_configuration* Beam_configuration::new_config (Interval start, + +Beam_configuration *Beam_configuration::new_config (Interval start, Interval offset) { - Beam_configuration* qs = new Beam_configuration; + Beam_configuration *qs = new Beam_configuration; qs->y = Interval (int (start[LEFT]) + offset[LEFT], int (start[RIGHT]) + offset[RIGHT]); @@ -120,13 +120,14 @@ Beam_configuration* Beam_configuration::new_config (Interval start, Real start_score = abs (offset[RIGHT]) + abs (offset[LEFT]); qs->demerits = start_score / 1000.0; qs->next_scorer_todo = ORIGINAL_DISTANCE + 1; - + return qs; } Real -Beam_scoring_problem::y_at (Real x, Beam_configuration const* p) const { - return p->y[LEFT] + (x - x_span[LEFT]) * p->y.delta() / x_span.delta(); +Beam_scoring_problem::y_at (Real x, Beam_configuration const *p) const +{ + return p->y[LEFT] + (x - x_span[LEFT]) * p->y.delta () / x_span.delta (); } /****************************************************************/ @@ -144,48 +145,51 @@ Beam_scoring_problem::y_at (Real x, Beam_configuration const* p) const { // priority queue on the beams to score. static int score_count = 0; LY_DEFINE (ly_beam_score_count, "ly:beam-score-count", 0, 0, 0, - (), - "count number of beam scores.") { + (), + "count number of beam scores.") +{ return scm_from_int (score_count); } void Beam_scoring_problem::add_collision (Real x, Interval y, Real score_factor) { - if (edge_dirs[LEFT] == edge_dirs[RIGHT]) { - Direction d = edge_dirs[LEFT]; + if (edge_dirs[LEFT] == edge_dirs[RIGHT]) + { + Direction d = edge_dirs[LEFT]; - Real quant_range_y = quant_range[LEFT][-d] + - (x - x_span[LEFT]) * (quant_range[RIGHT][-d] - quant_range[LEFT][-d]) / x_span.delta(); + Real quant_range_y = quant_range[LEFT][-d] + + (x - x_span[LEFT]) * (quant_range[RIGHT][-d] - quant_range[LEFT][-d]) / x_span.delta (); - if (d*(quant_range_y - minmax(d, y[UP], y[DOWN])) > 0) { - return; + if (d * (quant_range_y - minmax (d, y[UP], y[DOWN])) > 0) + { + return; + } } - } Beam_collision c; c.beam_y_.set_empty (); for (vsize j = 0; j < segments_.size (); j++) { - if (segments_[j].horizontal_.contains(x)) + if (segments_[j].horizontal_.contains (x)) c.beam_y_.add_point (segments_[j].vertical_count_ * beam_translation); if (segments_[j].horizontal_[LEFT] > x) break; } c.beam_y_.widen (0.5 * beam_thickness); - + c.x_ = x; - y *= 1/staff_space; + y *= 1 / staff_space; c.y_ = y; c.base_penalty_ = score_factor; collisions_.push_back (c); } -void Beam_scoring_problem::init_collisions (vector<Grob*> grobs) +void Beam_scoring_problem::init_collisions (vector<Grob *> grobs) { - Grob* common_x = NULL; + Grob *common_x = NULL; segments_ = Beam::get_beam_segments (beam, &common_x); vector_sort (segments_, beam_segment_less); if (common[X_AXIS] != common_x) @@ -194,46 +198,47 @@ void Beam_scoring_problem::init_collisions (vector<Grob*> grobs) return; } - set<Grob*> stems; - for (vsize i = 0; i < grobs.size (); i++) { - Box b; - for (Axis a = X_AXIS; a < NO_AXES; incr (a)) - b[a] = grobs[i]->extent(common[a], a); + set<Grob *> stems; + for (vsize i = 0; i < grobs.size (); i++) + { + Box b; + for (Axis a = X_AXIS; a < NO_AXES; incr (a)) + b[a] = grobs[i]->extent (common[a], a); - Real width = b[X_AXIS].length (); - Real width_factor = sqrt (width / staff_space); + Real width = b[X_AXIS].length (); + Real width_factor = sqrt (width / staff_space); - Direction d = LEFT; - do - add_collision (b[X_AXIS][d], b[Y_AXIS], width_factor); - while (flip (&d) != LEFT); + Direction d = LEFT; + do + add_collision (b[X_AXIS][d], b[Y_AXIS], width_factor); + while (flip (&d) != LEFT); - Grob* stem = unsmob_grob (grobs[i]->get_object ("stem")); - if (stem && Stem::has_interface (stem) && Stem::is_normal_stem (stem)) - { - stems.insert (stem); - } - } - - for (set<Grob*>::const_iterator it(stems.begin ()); it != stems.end (); it++) + Grob *stem = unsmob_grob (grobs[i]->get_object ("stem")); + if (stem && Stem::has_interface (stem) && Stem::is_normal_stem (stem)) + { + stems.insert (stem); + } + } + + for (set<Grob *>::const_iterator it (stems.begin ()); it != stems.end (); it++) { Grob *s = *it; - Real x = s->extent (common[X_AXIS], X_AXIS).center(); + Real x = s->extent (common[X_AXIS], X_AXIS).center (); Direction stem_dir = get_grob_direction (*it); Interval y; y.set_full (); y[-stem_dir] = Stem::chord_start_y (*it) + (*it)->relative_coordinate (common[Y_AXIS], Y_AXIS) - - beam->relative_coordinate (common[Y_AXIS], Y_AXIS); + - beam->relative_coordinate (common[Y_AXIS], Y_AXIS); Real factor = parameters.STEM_COLLISION_FACTOR; if (!unsmob_grob (s->get_object ("beam")) && !Stem::flag (s).is_empty ()) - factor = 1.0; + factor = 1.0; add_collision (x, y, factor); } } - + void Beam_scoring_problem::init_stems () { extract_grob_set (beam, "covered-grobs", collisions); @@ -243,49 +248,49 @@ void Beam_scoring_problem::init_stems () common[a] = common_refpoint_of_array (stems, beam, Axis (a)); common[a] = common_refpoint_of_array (collisions, common[a], Axis (a)); } - - Drul_array<Grob *> edge_stems(Beam::first_normal_stem (beam), - Beam::last_normal_stem (beam)); + + Drul_array<Grob *> edge_stems (Beam::first_normal_stem (beam), + Beam::last_normal_stem (beam)); Direction d = LEFT; do x_span[d] = edge_stems[d] ? edge_stems[d]->relative_coordinate (common[X_AXIS], X_AXIS) : 0.0; while (flip (&d) != LEFT); - + Drul_array<bool> dirs_found (0, 0); for (vsize i = 0; i < stems.size (); i++) { Grob *s = stems[i]; if (!Stem::is_normal_stem (s)) continue; - + Stem_info si (Stem::get_stem_info (s)); si.scale (1 / staff_space); stem_infos.push_back (si); dirs_found[si.dir_] = true; bool f = to_boolean (s->get_property ("french-beaming")) - && s != edge_stems[LEFT] && s != edge_stems[RIGHT]; + && s != edge_stems[LEFT] && s != edge_stems[RIGHT]; - Real y = Beam::calc_stem_y (beam, s, common, x_span[LEFT], x_span[RIGHT], CENTER, + Real y = Beam::calc_stem_y (beam, s, common, x_span[LEFT], x_span[RIGHT], CENTER, Interval (0, 0), f); base_lengths.push_back (y / staff_space); stem_xpositions.push_back (s->relative_coordinate (common[X_AXIS], X_AXIS)); } - + edge_dirs = Drul_array<Direction> (CENTER, CENTER); if (stem_infos.size ()) { edge_dirs = Drul_array<Direction> (stem_infos[0].dir_, - stem_infos.back().dir_); + stem_infos.back ().dir_); } is_xstaff = Align_interface::has_interface (common[Y_AXIS]); is_knee = dirs_found[LEFT] && dirs_found[RIGHT]; - + staff_radius = Staff_symbol_referencer::staff_radius (beam); - edge_beam_counts = Drul_array<int> - (Stem::beam_multiplicity (stems[0]).length () + 1, - Stem::beam_multiplicity (stems.back ()).length () + 1); + edge_beam_counts = Drul_array<int> + (Stem::beam_multiplicity (stems[0]).length () + 1, + Stem::beam_multiplicity (stems.back ()).length () + 1); // TODO - why are we dividing by staff_space? beam_translation = Beam::get_beam_translation (beam) / staff_space; @@ -296,14 +301,14 @@ void Beam_scoring_problem::init_stems () quant_range[d].set_full (); if (!edge_stems[d]) continue; - + Real stem_offset = edge_stems[d]->relative_coordinate (common[Y_AXIS], Y_AXIS) - - beam->relative_coordinate (common[Y_AXIS], Y_AXIS); - Interval heads = Stem::head_positions(edge_stems[d]) * 0.5 * staff_space; + - beam->relative_coordinate (common[Y_AXIS], Y_AXIS); + Interval heads = Stem::head_positions (edge_stems[d]) * 0.5 * staff_space; Direction ed = edge_dirs[d]; - heads.widen(0.5 * staff_space - + (edge_beam_counts[d] - 1) * beam_translation + beam_thickness * .5); + heads.widen (0.5 * staff_space + + (edge_beam_counts[d] - 1) * beam_translation + beam_thickness * .5); quant_range[d][-ed] = heads[ed] + stem_offset; } while (flip (&d) != LEFT); @@ -315,7 +320,7 @@ Beam_scoring_problem::Beam_scoring_problem (Grob *me, Drul_array<Real> ys) { beam = me; unquanted_y = ys; - + /* Calculations are relative to a unit-scaled staff, i.e. the quants are divided by the current staff_space. @@ -332,7 +337,7 @@ Beam_scoring_problem::Beam_scoring_problem (Grob *me, Drul_array<Real> ys) } void -Beam_scoring_problem::generate_quants (vector<Beam_configuration*> *scores) const +Beam_scoring_problem::generate_quants (vector<Beam_configuration *> *scores) const { int region_size = (int) parameters.REGION_SIZE; @@ -341,7 +346,7 @@ Beam_scoring_problem::generate_quants (vector<Beam_configuration*> *scores) cons region_size += 2; if (collisions_.size ()) region_size += 2; - + Real straddle = 0.0; Real sit = (beam_thickness - line_thickness) / 2; Real inter = 0.5; @@ -362,11 +367,11 @@ Beam_scoring_problem::generate_quants (vector<Beam_configuration*> *scores) cons for (vsize i = 0; i < unshifted_quants.size (); i++) for (vsize j = 0; j < unshifted_quants.size (); j++) { - Beam_configuration *c = - Beam_configuration::new_config (unquanted_y, - Interval (unshifted_quants[i], - unshifted_quants[j])); - + Beam_configuration *c + = Beam_configuration::new_config (unquanted_y, + Interval (unshifted_quants[i], + unshifted_quants[j])); + Direction d = LEFT; do { @@ -378,57 +383,56 @@ Beam_scoring_problem::generate_quants (vector<Beam_configuration*> *scores) cons } } while (flip (&d) != LEFT); - if (c) + if (c) scores->push_back (c); } - -} +} -void Beam_scoring_problem::one_scorer (Beam_configuration* config) const +void Beam_scoring_problem::one_scorer (Beam_configuration *config) const { - score_count ++; - switch (config->next_scorer_todo) { - case SLOPE_IDEAL: - score_slope_ideal (config); - break; - case SLOPE_DIRECTION: - score_slope_direction (config); - break; - case SLOPE_MUSICAL: - score_slope_musical (config); - break; - case FORBIDDEN: - score_forbidden_quants (config); - break; - case STEM_LENGTHS: - score_stem_lengths (config); - break; - case COLLISIONS: - score_collisions (config); - break; - case HORIZONTAL_INTER: - score_horizontal_inter_quants (config); - break; - - case NUM_SCORERS: - case ORIGINAL_DISTANCE: - default: - assert (false); - } + score_count++; + switch (config->next_scorer_todo) + { + case SLOPE_IDEAL: + score_slope_ideal (config); + break; + case SLOPE_DIRECTION: + score_slope_direction (config); + break; + case SLOPE_MUSICAL: + score_slope_musical (config); + break; + case FORBIDDEN: + score_forbidden_quants (config); + break; + case STEM_LENGTHS: + score_stem_lengths (config); + break; + case COLLISIONS: + score_collisions (config); + break; + case HORIZONTAL_INTER: + score_horizontal_inter_quants (config); + break; + + case NUM_SCORERS: + case ORIGINAL_DISTANCE: + default: + assert (false); + } config->next_scorer_todo++; -} - +} Beam_configuration * -Beam_scoring_problem::force_score (SCM inspect_quants, const vector<Beam_configuration*> &configs) const +Beam_scoring_problem::force_score (SCM inspect_quants, const vector<Beam_configuration *> &configs) const { Drul_array<Real> ins = ly_scm2interval (inspect_quants); Real mindist = 1e6; - Beam_configuration *best = NULL; + Beam_configuration *best = NULL; for (vsize i = 0; i < configs.size (); i++) { - Real d = fabs (configs[i]->y[LEFT]- ins[LEFT]) + fabs (configs[i]->y[RIGHT] - ins[RIGHT]); + Real d = fabs (configs[i]->y[LEFT] - ins[LEFT]) + fabs (configs[i]->y[RIGHT] - ins[RIGHT]); if (d < mindist) { best = configs[i]; @@ -440,13 +444,14 @@ Beam_scoring_problem::force_score (SCM inspect_quants, const vector<Beam_configu while (!best->done ()) one_scorer (best); - + return best; } Drul_array<Real> -Beam_scoring_problem::solve () const { - vector<Beam_configuration*> configs; +Beam_scoring_problem::solve () const +{ + vector<Beam_configuration *> configs; generate_quants (&configs); if (configs.empty ()) @@ -455,22 +460,22 @@ Beam_scoring_problem::solve () const { return unquanted_y; } - Beam_configuration *best = NULL; + Beam_configuration *best = NULL; - bool debug = - to_boolean (beam->layout ()->lookup_variable (ly_symbol2scm ("debug-beam-scoring"))); + bool debug + = to_boolean (beam->layout ()->lookup_variable (ly_symbol2scm ("debug-beam-scoring"))); SCM inspect_quants = beam->get_property ("inspect-quants"); - if (scm_is_pair (inspect_quants)) + if (scm_is_pair (inspect_quants)) { debug = true; best = force_score (inspect_quants, configs); } else { - std::priority_queue<Beam_configuration*, std::vector<Beam_configuration*>, - Beam_configuration_less> queue; - for (vsize i = 0; i < configs.size(); i++) - queue.push(configs[i]); + std::priority_queue < Beam_configuration *, std::vector<Beam_configuration *>, + Beam_configuration_less > queue; + for (vsize i = 0; i < configs.size (); i++) + queue.push (configs[i]); /* TODO @@ -488,15 +493,16 @@ Beam_scoring_problem::solve () const { that would allow us to do away with region_size altogether. */ - while (true) { - best = queue.top (); - if (best->done ()) - break; - - queue.pop (); - one_scorer (best); - queue.push (best); - } + while (true) + { + best = queue.top (); + if (best->done ()) + break; + + queue.pop (); + one_scorer (best); + queue.push (best); + } } Interval final_positions = best->y; @@ -512,7 +518,7 @@ Beam_scoring_problem::solve () const { completed++; } - string card = best->score_card_ + to_string (" c%d/%d", completed, configs.size()); + string card = best->score_card_ + to_string (" c%d/%d", completed, configs.size ()); beam->set_property ("annotation", ly_string2scm (card)); } #endif @@ -522,7 +528,7 @@ Beam_scoring_problem::solve () const { } void -Beam_scoring_problem::score_stem_lengths (Beam_configuration* config) const +Beam_scoring_problem::score_stem_lengths (Beam_configuration *config) const { Real limit_penalty = parameters.STEM_LENGTH_LIMIT_PENALTY; Drul_array<Real> score (0, 0); @@ -533,8 +539,8 @@ Beam_scoring_problem::score_stem_lengths (Beam_configuration* config) const Real x = stem_xpositions[i]; Real dx = x_span.delta (); Real beam_y = dx - ? config->y[RIGHT] * (x - x_span[LEFT]) / dx + config->y[LEFT] * (x_span[RIGHT] - x) / dx - : (config->y[RIGHT] + config->y[LEFT]) / 2; + ? config->y[RIGHT] * (x - x_span[LEFT]) / dx + config->y[LEFT] * (x_span[RIGHT] - x) / dx + : (config->y[RIGHT] + config->y[LEFT]) / 2; Real current_y = beam_y + base_lengths[i]; Real length_pen = parameters.STEM_LENGTH_DEMERIT_FACTOR; @@ -550,7 +556,7 @@ Beam_scoring_problem::score_stem_lengths (Beam_configuration* config) const convex. Otherwise a symmetric knee beam (up/down/up/down) does not have an optimum in the middle. */ if (is_knee) - ideal_score = pow (ideal_score, 1.1); + ideal_score = pow (ideal_score, 1.1); score[d] += length_pen * ideal_score; count[d]++; @@ -569,7 +575,7 @@ void Beam_scoring_problem::score_slope_direction (Beam_configuration *config) const { Real dy = config->y.delta (); - Real damped_dy = unquanted_y.delta(); + Real damped_dy = unquanted_y.delta (); Real dem = 0.0; /* DAMPING_DIRECTION_PENALTY is a very harsh measure, while for @@ -581,26 +587,26 @@ Beam_scoring_problem::score_slope_direction (Beam_configuration *config) const if (sign (damped_dy) != sign (dy)) { if (!dy) - { - if (fabs (damped_dy / x_span.delta ()) > parameters.ROUND_TO_ZERO_SLOPE) - dem += parameters.DAMPING_DIRECTION_PENALTY; - else - dem += parameters.HINT_DIRECTION_PENALTY; - } + { + if (fabs (damped_dy / x_span.delta ()) > parameters.ROUND_TO_ZERO_SLOPE) + dem += parameters.DAMPING_DIRECTION_PENALTY; + else + dem += parameters.HINT_DIRECTION_PENALTY; + } else - dem += parameters.DAMPING_DIRECTION_PENALTY; + dem += parameters.DAMPING_DIRECTION_PENALTY; } config->add (dem, "Sd"); } -// Score for going against the direction of the musical pattern +// Score for going against the direction of the musical pattern void Beam_scoring_problem::score_slope_musical (Beam_configuration *config) const { Real dy = config->y.delta (); Real dem = parameters.MUSICAL_DIRECTION_FACTOR - * max (0.0, (fabs (dy) - fabs (musical_dy))); + * max (0.0, (fabs (dy) - fabs (musical_dy))); config->add (dem, "Sm"); } @@ -609,9 +615,9 @@ void Beam_scoring_problem::score_slope_ideal (Beam_configuration *config) const { Real dy = config->y.delta (); - Real damped_dy = unquanted_y.delta(); + Real damped_dy = unquanted_y.delta (); Real dem = 0.0; - + Real slope_penalty = parameters.IDEAL_SLOPE_FACTOR; /* Xstaff beams tend to use extreme slopes to get short stems. We @@ -621,7 +627,7 @@ Beam_scoring_problem::score_slope_ideal (Beam_configuration *config) const /* Huh, why would a too steep beam be better than a too flat one ? */ dem += shrink_extra_weight (fabs (damped_dy) - fabs (dy), 1.5) - * slope_penalty; + * slope_penalty; config->add (dem, "Si"); } @@ -657,48 +663,48 @@ Beam_scoring_problem::score_forbidden_quants (Beam_configuration *config) const { Real dy = config->y.delta (); - Real extra_demerit = parameters.SECONDARY_BEAM_DEMERIT / - max (edge_beam_counts[LEFT], edge_beam_counts[RIGHT]); + Real extra_demerit = parameters.SECONDARY_BEAM_DEMERIT + / max (edge_beam_counts[LEFT], edge_beam_counts[RIGHT]); Direction d = LEFT; Real dem = 0.0; Real eps = parameters.BEAM_EPS; - + do { for (int j = 1; j <= edge_beam_counts[d]; j++) - { - Direction stem_dir = edge_dirs[d]; - - /* - The 2.2 factor is to provide a little leniency for - borderline cases. If we do 2.0, then the upper outer line - will be in the gap of the (2, sit) quant, leading to a - false demerit. - */ - Real gap1 = config->y[d] - stem_dir * ((j - 1) * beam_translation + beam_thickness / 2 - line_thickness / 2.2); - Real gap2 = config->y[d] - stem_dir * (j * beam_translation - beam_thickness / 2 + line_thickness / 2.2); - - Interval gap; - gap.add_point (gap1); - gap.add_point (gap2); - - for (Real k = -staff_radius; - k <= staff_radius + eps; k += 1.0) - if (gap.contains (k)) - { - Real dist = min (fabs (gap[UP] - k), fabs (gap[DOWN] - k)); - - /* - this parameter is tuned to grace-stem-length.ly - */ - Real fixed_demerit = 0.4; - - dem += extra_demerit - * (fixed_demerit - + (1 - fixed_demerit) * (dist / gap.length ()) * 2); - } - } + { + Direction stem_dir = edge_dirs[d]; + + /* + The 2.2 factor is to provide a little leniency for + borderline cases. If we do 2.0, then the upper outer line + will be in the gap of the (2, sit) quant, leading to a + false demerit. + */ + Real gap1 = config->y[d] - stem_dir * ((j - 1) * beam_translation + beam_thickness / 2 - line_thickness / 2.2); + Real gap2 = config->y[d] - stem_dir * (j * beam_translation - beam_thickness / 2 + line_thickness / 2.2); + + Interval gap; + gap.add_point (gap1); + gap.add_point (gap2); + + for (Real k = -staff_radius; + k <= staff_radius + eps; k += 1.0) + if (gap.contains (k)) + { + Real dist = min (fabs (gap[UP] - k), fabs (gap[DOWN] - k)); + + /* + this parameter is tuned to grace-stem-length.ly + */ + Real fixed_demerit = 0.4; + + dem += extra_demerit + * (fixed_demerit + + (1 - fixed_demerit) * (dist / gap.length ()) * 2); + } + } } while ((flip (&d)) != LEFT); @@ -711,33 +717,33 @@ Beam_scoring_problem::score_forbidden_quants (Beam_configuration *config) const Direction d = LEFT; do - { - if (edge_beam_counts[d] >= 2 - && fabs (config->y[d] - edge_dirs[d] * beam_translation) < staff_radius + inter) - { + { + if (edge_beam_counts[d] >= 2 + && fabs (config->y[d] - edge_dirs[d] * beam_translation) < staff_radius + inter) + { // TODO up/down symmetry. - if (edge_dirs[d] == UP && dy <= eps - && fabs (my_modf (config->y[d]) - sit) < eps) - dem += extra_demerit; - - if (edge_dirs[d] == DOWN && dy >= eps - && fabs (my_modf (config->y[d]) - hang) < eps) - dem += extra_demerit; - } - - if (edge_beam_counts[d] >= 3 - && fabs (config->y[d] - 2 * edge_dirs[d] * beam_translation) < staff_radius + inter) - { + if (edge_dirs[d] == UP && dy <= eps + && fabs (my_modf (config->y[d]) - sit) < eps) + dem += extra_demerit; + + if (edge_dirs[d] == DOWN && dy >= eps + && fabs (my_modf (config->y[d]) - hang) < eps) + dem += extra_demerit; + } + + if (edge_beam_counts[d] >= 3 + && fabs (config->y[d] - 2 * edge_dirs[d] * beam_translation) < staff_radius + inter) + { // TODO up/down symmetry. - if (edge_dirs[d] == UP && dy <= eps - && fabs (my_modf (config->y[d]) - straddle) < eps) - dem += extra_demerit; - - if (edge_dirs[d] == DOWN && dy >= eps - && fabs (my_modf (config->y[d]) - straddle) < eps) - dem += extra_demerit; - } - } + if (edge_dirs[d] == UP && dy <= eps + && fabs (my_modf (config->y[d]) - straddle) < eps) + dem += extra_demerit; + + if (edge_dirs[d] == DOWN && dy >= eps + && fabs (my_modf (config->y[d]) - straddle) < eps) + dem += extra_demerit; + } + } while (flip (&d) != LEFT); } @@ -746,7 +752,7 @@ Beam_scoring_problem::score_forbidden_quants (Beam_configuration *config) const void Beam_scoring_problem::score_collisions (Beam_configuration *config) const -{ +{ Real demerits = 0.0; for (vsize i = 0; i < collisions_.size (); i++) { @@ -763,13 +769,13 @@ Beam_scoring_problem::score_collisions (Beam_configuration *config) const dist = min (beam_y.distance (collision_y[DOWN]), beam_y.distance (collision_y[UP])); - Real scale_free = - max (parameters.COLLISION_PADDING - dist, 0.0)/ - parameters.COLLISION_PADDING; - demerits += - collisions_[i].base_penalty_ * - pow (scale_free, 3) * parameters.COLLISION_PENALTY; + Real scale_free + = max (parameters.COLLISION_PADDING - dist, 0.0) / + parameters.COLLISION_PADDING; + demerits + += collisions_[i].base_penalty_ * + pow (scale_free, 3) * parameters.COLLISION_PENALTY; } config->add (demerits, "C"); -} +} diff --git a/lily/beam.cc b/lily/beam.cc index 1bb0a209a8..2d973246cf 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -65,10 +65,9 @@ #include <map> - Beam_stem_segment::Beam_stem_segment () { - max_connect_ = 1000; // infinity + max_connect_ = 1000; // infinity stem_ = 0; width_ = 0.0; stem_x_ = 0.0; @@ -78,7 +77,7 @@ Beam_stem_segment::Beam_stem_segment () } bool -beam_segment_less (Beam_segment const& a, Beam_segment const& b) +beam_segment_less (Beam_segment const &a, Beam_segment const &b) { return a.horizontal_[LEFT] < b.horizontal_[LEFT]; } @@ -94,7 +93,7 @@ Beam::add_stem (Grob *me, Grob *s) if (Stem::get_beam (s)) { programming_error ("Stem already has beam"); - return ; + return; } Pointer_group_interface::add_grob (me, ly_symbol2scm ("stems"), s); @@ -106,7 +105,7 @@ Real Beam::get_beam_thickness (Grob *me) { return robust_scm2double (me->get_property ("beam-thickness"), 0) - * Staff_symbol_referencer::staff_space (me); + * Staff_symbol_referencer::staff_space (me); } /* Return the translation between 2 adjoining beams. */ @@ -120,8 +119,8 @@ Beam::get_beam_translation (Grob *me) Real fract = robust_scm2double (me->get_property ("length-fraction"), 1.0); Real beam_translation = beam_count < 4 - ? (2 * staff_space + line - beam_thickness) / 2.0 - : (3 * staff_space + line - beam_thickness) / 3.0; + ? (2 * staff_space + line - beam_thickness) / 2.0 + : (3 * staff_space + line - beam_thickness) / 3.0; return fract * beam_translation; } @@ -150,7 +149,7 @@ Beam::calc_normal_stems (SCM smob) extract_grob_set (me, "stems", stems); SCM val = Grob_array::make_array (); Grob_array *ga = unsmob_grob_array (val); - for (vsize i = 0; i < stems.size (); i++) + for (vsize i = 0; i < stems.size (); i++) if (Stem::is_normal_stem (stems[i])) ga->add (stems[i]); @@ -177,33 +176,33 @@ Beam::calc_direction (SCM smob) { extract_grob_set (me, "stems", stems); if (stems.size () == 0) - { - me->warning (_ ("removing beam with no stems")); - me->suicide (); + { + me->warning (_ ("removing beam with no stems")); + me->suicide (); - return SCM_UNSPECIFIED; - } + return SCM_UNSPECIFIED; + } else - { - Grob *stem = first_normal_stem (me); - - /* - This happens for chord tremolos. - */ - if (!stem) - stem = stems[0]; - - if (is_direction (stem->get_property_data ("direction"))) - dir = to_dir (stem->get_property_data ("direction")); - else - dir = to_dir (stem->get_property ("default-direction")); - } + { + Grob *stem = first_normal_stem (me); + + /* + This happens for chord tremolos. + */ + if (!stem) + stem = stems[0]; + + if (is_direction (stem->get_property_data ("direction"))) + dir = to_dir (stem->get_property_data ("direction")); + else + dir = to_dir (stem->get_property ("default-direction")); + } } if (count >= 1) { if (!dir) - dir = get_default_dir (me); + dir = get_default_dir (me); consider_auto_knees (me); } @@ -216,8 +215,6 @@ Beam::calc_direction (SCM smob) return scm_from_int (dir); } - - /* We want a maximal number of shared beams, but if there is choice, we * take the one that is closest to the end of the stem. This is for * situations like @@ -232,8 +229,8 @@ Beam::calc_direction (SCM smob) */ int position_with_maximal_common_beams (SCM left_beaming, SCM right_beaming, - Direction left_dir, - Direction right_dir) + Direction left_dir, + Direction right_dir) { Slice lslice = int_list_to_slice (scm_cdr (left_beaming)); @@ -244,17 +241,17 @@ position_with_maximal_common_beams (SCM left_beaming, SCM right_beaming, { int count = 0; for (SCM s = scm_car (right_beaming); scm_is_pair (s); s = scm_cdr (s)) - { - int k = -right_dir * scm_to_int (scm_car (s)) + i; - if (scm_c_memq (scm_from_int (k), left_beaming) != SCM_BOOL_F) - count++; - } + { + int k = -right_dir * scm_to_int (scm_car (s)) + i; + if (scm_c_memq (scm_from_int (k), left_beaming) != SCM_BOOL_F) + count++; + } if (count >= best_count) - { - best_count = count; - best_start = i; - } + { + best_count = count; + best_start = i; + } } return best_start; @@ -280,51 +277,51 @@ Beam::calc_beaming (SCM smob) Direction this_dir = get_grob_direction (this_stem); if (scm_is_pair (last_beaming) && scm_is_pair (this_beaming)) - { - int start_point = position_with_maximal_common_beams - (last_beaming, this_beaming, - last_dir ? last_dir : this_dir, - this_dir); - - Direction d = LEFT; - Slice new_slice; - do - { - new_slice.set_empty (); - SCM s = index_get_cell (this_beaming, d); - for (; scm_is_pair (s); s = scm_cdr (s)) - { - int new_beam_pos - = start_point - this_dir * scm_to_int (scm_car (s)); - - new_slice.add_point (new_beam_pos); - scm_set_car_x (s, scm_from_int (new_beam_pos)); - } - } - while (flip (&d) != LEFT); - - if (!new_slice.is_empty ()) - last_int = new_slice; - } + { + int start_point = position_with_maximal_common_beams + (last_beaming, this_beaming, + last_dir ? last_dir : this_dir, + this_dir); + + Direction d = LEFT; + Slice new_slice; + do + { + new_slice.set_empty (); + SCM s = index_get_cell (this_beaming, d); + for (; scm_is_pair (s); s = scm_cdr (s)) + { + int new_beam_pos + = start_point - this_dir * scm_to_int (scm_car (s)); + + new_slice.add_point (new_beam_pos); + scm_set_car_x (s, scm_from_int (new_beam_pos)); + } + } + while (flip (&d) != LEFT); + + if (!new_slice.is_empty ()) + last_int = new_slice; + } else - { - /* - FIXME: what's this for? - */ - SCM s = scm_cdr (this_beaming); - for (; scm_is_pair (s); s = scm_cdr (s)) - { - int np = -this_dir * scm_to_int (scm_car (s)); - scm_set_car_x (s, scm_from_int (np)); - last_int.add_point (np); - } - } + { + /* + FIXME: what's this for? + */ + SCM s = scm_cdr (this_beaming); + for (; scm_is_pair (s); s = scm_cdr (s)) + { + int np = -this_dir * scm_to_int (scm_car (s)); + scm_set_car_x (s, scm_from_int (np)); + last_int.add_point (np); + } + } if (scm_ilength (scm_cdr (this_beaming)) > 0) - { - last_beaming = this_beaming; - last_dir = this_dir; - } + { + last_beaming = this_beaming; + last_dir = this_dir; + } } return SCM_EOL; @@ -332,12 +329,12 @@ Beam::calc_beaming (SCM smob) bool operator <(Beam_stem_segment const &a, - Beam_stem_segment const &b) + Beam_stem_segment const &b) { return a.rank_ < b.rank_; } -typedef map<int, vector<Beam_stem_segment> > Position_stem_segments_map; +typedef map<int, vector<Beam_stem_segment> > Position_stem_segments_map; // TODO - should store result in a property? vector<Beam_segment> @@ -347,7 +344,7 @@ Beam::get_beam_segments (Grob *me_grob, Grob **common) Stem #'beaming is correct */ (void) me_grob->get_property ("beaming"); - Spanner *me = dynamic_cast<Spanner*> (me_grob); + Spanner *me = dynamic_cast<Spanner *> (me_grob); extract_grob_set (me, "stems", stems); Grob *commonx = common_refpoint_of_array (stems, me, X_AXIS); @@ -378,50 +375,50 @@ Beam::get_beam_segments (Grob *me_grob, Grob **common) SCM beaming = stem->get_property ("beaming"); Direction d = LEFT; do - { - // Find the maximum and minimum beam ranks. - // Given that RANKS is never reset to empty, the interval will always be - // smallest for the left beamlet of the first stem, and then it might grow. - // Do we really want this? (It only affects the tremolo gaps) --jneem - for (SCM s = index_get_cell (beaming, d); - scm_is_pair (s); s = scm_cdr (s)) - { - if (!scm_is_integer (scm_car (s))) - continue; - - int beam_rank = scm_to_int (scm_car (s)); - ranks.add_point (beam_rank); - } - - for (SCM s = index_get_cell (beaming, d); - scm_is_pair (s); s = scm_cdr (s)) - { - if (!scm_is_integer (scm_car (s))) - continue; - - int beam_rank = scm_to_int (scm_car (s)); - Beam_stem_segment seg; - seg.stem_ = stem; - seg.stem_x_ = stem_x; - seg.rank_ = 2 * i + (d+1)/2; - seg.width_ = stem_width; - seg.stem_index_ = i; - seg.dir_ = d; - seg.max_connect_ = robust_scm2int (stem->get_property ("max-beam-connect"), 1000); - - Direction stem_dir = get_grob_direction (stem); - - seg.gapped_ - = (stem_dir * beam_rank < (stem_dir * ranks[-stem_dir] + gap_count)); - stem_segments[beam_rank].push_back (seg); - } - } + { + // Find the maximum and minimum beam ranks. + // Given that RANKS is never reset to empty, the interval will always be + // smallest for the left beamlet of the first stem, and then it might grow. + // Do we really want this? (It only affects the tremolo gaps) --jneem + for (SCM s = index_get_cell (beaming, d); + scm_is_pair (s); s = scm_cdr (s)) + { + if (!scm_is_integer (scm_car (s))) + continue; + + int beam_rank = scm_to_int (scm_car (s)); + ranks.add_point (beam_rank); + } + + for (SCM s = index_get_cell (beaming, d); + scm_is_pair (s); s = scm_cdr (s)) + { + if (!scm_is_integer (scm_car (s))) + continue; + + int beam_rank = scm_to_int (scm_car (s)); + Beam_stem_segment seg; + seg.stem_ = stem; + seg.stem_x_ = stem_x; + seg.rank_ = 2 * i + (d + 1) / 2; + seg.width_ = stem_width; + seg.stem_index_ = i; + seg.dir_ = d; + seg.max_connect_ = robust_scm2int (stem->get_property ("max-beam-connect"), 1000); + + Direction stem_dir = get_grob_direction (stem); + + seg.gapped_ + = (stem_dir * beam_rank < (stem_dir * ranks[-stem_dir] + gap_count)); + stem_segments[beam_rank].push_back (seg); + } + } while (flip (&d) != LEFT); } Drul_array<Real> break_overshoot = robust_scm2drul (me->get_property ("break-overshoot"), - Drul_array<Real> (-0.5, 0.0)); + Drul_array<Real> (-0.5, 0.0)); vector<Beam_segment> segments; for (Position_stem_segments_map::const_iterator i (stem_segments.begin ()); @@ -435,113 +432,113 @@ Beam::get_beam_segments (Grob *me_grob, Grob **common) // Iterate over all of the segments of the current beam rank, // merging the adjacent Beam_stem_segments into one Beam_segment // when appropriate. - int vertical_count = (*i).first; + int vertical_count = (*i).first; for (vsize j = 0; j < segs.size (); j++) - { - // Keeping track of the different directions here is a little tricky. - // segs[j].dir_ is the direction of the beam segment relative to the stem - // (ie. segs[j].dir_ == LEFT if the beam segment sticks out to the left of - // its stem) whereas event_dir refers to the edge of the beam segment that - // we are currently looking at (ie. if segs[j].dir_ == event_dir then we - // are looking at that edge of the beam segment that is furthest from its - // stem). - Direction event_dir = LEFT; - Beam_stem_segment const& seg = segs[j]; - do - { - Beam_stem_segment const& neighbor_seg = segs[j + event_dir]; - // TODO: make names clearer? --jneem - // on_line_bound: whether the current segment is on the boundary of the WHOLE beam - // on_beam_bound: whether the current segment is on the boundary of just that part - // of the beam with the current beam_rank - bool on_line_bound = (seg.dir_ == LEFT) ? seg.stem_index_ == 0 - : seg.stem_index_ == stems.size() - 1; - bool on_beam_bound = (event_dir == LEFT) ? j == 0 : - j == segs.size () - 1; - bool inside_stem = (event_dir == LEFT) - ? seg.stem_index_ > 0 - : seg.stem_index_ + 1 < stems.size () ; - - bool event = on_beam_bound - || abs (seg.rank_ - neighbor_seg.rank_) > 1 - || (abs (vertical_count) >= seg.max_connect_ - || abs (vertical_count) >= neighbor_seg.max_connect_); - - if (!event) - // Then this edge of the current segment is irrelevent because it will - // be connected with the next segment in the event_dir direction. - continue; - - current.vertical_count_ = vertical_count; - current.horizontal_[event_dir] = seg.stem_x_; - if (seg.dir_ == event_dir) - // then we are examining the edge of a beam segment that is furthest - // from its stem. - { - if (on_line_bound - && me->get_bound (event_dir)->break_status_dir ()) - { - current.horizontal_[event_dir] - = (robust_relative_extent (me->get_bound (event_dir), - commonx, X_AXIS)[RIGHT] - + event_dir * break_overshoot[event_dir]); - } - else - { - Grob *stem = stems[seg.stem_index_]; - Drul_array<Real> beamlet_length = - robust_scm2interval (stem->get_property ("beamlet-default-length"), Interval (1.1, 1.1)); - Drul_array<Real> max_proportion = - robust_scm2interval (stem->get_property ("beamlet-max-length-proportion"), Interval (0.75, 0.75)); - Real length = beamlet_length[seg.dir_]; - - if (inside_stem) - { - Grob *neighbor_stem = stems[seg.stem_index_ + event_dir]; - Real neighbor_stem_x = neighbor_stem->relative_coordinate (commonx, X_AXIS); - - length = min (length, - fabs (neighbor_stem_x - seg.stem_x_) * max_proportion[seg.dir_]); - } - current.horizontal_[event_dir] += event_dir * length; - } - } - else - // we are examining the edge of a beam segment that is closest - // (ie. touching, unless there is a gap) its stem. - { - current.horizontal_[event_dir] += event_dir * seg.width_/2; - if (seg.gapped_) - { - current.horizontal_[event_dir] -= event_dir * gap_length; - - if (Stem::is_invisible (seg.stem_)) - { - /* - Need to do this in case of whole notes. We don't want the - heads to collide with the beams. - */ - extract_grob_set (seg.stem_, "note-heads", heads); - - for (vsize k = 0; k < heads.size (); k ++) - current.horizontal_[event_dir] - = event_dir * min (event_dir * current.horizontal_[event_dir], - - gap_length/2 - + event_dir - * heads[k]->extent (commonx, - X_AXIS)[-event_dir]); - } - } - } - - if (event_dir == RIGHT) - { - segments.push_back (current); - current = Beam_segment (); - } - } - while (flip (&event_dir) != LEFT); - } + { + // Keeping track of the different directions here is a little tricky. + // segs[j].dir_ is the direction of the beam segment relative to the stem + // (ie. segs[j].dir_ == LEFT if the beam segment sticks out to the left of + // its stem) whereas event_dir refers to the edge of the beam segment that + // we are currently looking at (ie. if segs[j].dir_ == event_dir then we + // are looking at that edge of the beam segment that is furthest from its + // stem). + Direction event_dir = LEFT; + Beam_stem_segment const &seg = segs[j]; + do + { + Beam_stem_segment const &neighbor_seg = segs[j + event_dir]; + // TODO: make names clearer? --jneem + // on_line_bound: whether the current segment is on the boundary of the WHOLE beam + // on_beam_bound: whether the current segment is on the boundary of just that part + // of the beam with the current beam_rank + bool on_line_bound = (seg.dir_ == LEFT) ? seg.stem_index_ == 0 + : seg.stem_index_ == stems.size () - 1; + bool on_beam_bound = (event_dir == LEFT) ? j == 0 + : j == segs.size () - 1; + bool inside_stem = (event_dir == LEFT) + ? seg.stem_index_ > 0 + : seg.stem_index_ + 1 < stems.size (); + + bool event = on_beam_bound + || abs (seg.rank_ - neighbor_seg.rank_) > 1 + || (abs (vertical_count) >= seg.max_connect_ + || abs (vertical_count) >= neighbor_seg.max_connect_); + + if (!event) + // Then this edge of the current segment is irrelevent because it will + // be connected with the next segment in the event_dir direction. + continue; + + current.vertical_count_ = vertical_count; + current.horizontal_[event_dir] = seg.stem_x_; + if (seg.dir_ == event_dir) + // then we are examining the edge of a beam segment that is furthest + // from its stem. + { + if (on_line_bound + && me->get_bound (event_dir)->break_status_dir ()) + { + current.horizontal_[event_dir] + = (robust_relative_extent (me->get_bound (event_dir), + commonx, X_AXIS)[RIGHT] + + event_dir * break_overshoot[event_dir]); + } + else + { + Grob *stem = stems[seg.stem_index_]; + Drul_array<Real> beamlet_length + = robust_scm2interval (stem->get_property ("beamlet-default-length"), Interval (1.1, 1.1)); + Drul_array<Real> max_proportion + = robust_scm2interval (stem->get_property ("beamlet-max-length-proportion"), Interval (0.75, 0.75)); + Real length = beamlet_length[seg.dir_]; + + if (inside_stem) + { + Grob *neighbor_stem = stems[seg.stem_index_ + event_dir]; + Real neighbor_stem_x = neighbor_stem->relative_coordinate (commonx, X_AXIS); + + length = min (length, + fabs (neighbor_stem_x - seg.stem_x_) * max_proportion[seg.dir_]); + } + current.horizontal_[event_dir] += event_dir * length; + } + } + else + // we are examining the edge of a beam segment that is closest + // (ie. touching, unless there is a gap) its stem. + { + current.horizontal_[event_dir] += event_dir * seg.width_ / 2; + if (seg.gapped_) + { + current.horizontal_[event_dir] -= event_dir * gap_length; + + if (Stem::is_invisible (seg.stem_)) + { + /* + Need to do this in case of whole notes. We don't want the + heads to collide with the beams. + */ + extract_grob_set (seg.stem_, "note-heads", heads); + + for (vsize k = 0; k < heads.size (); k++) + current.horizontal_[event_dir] + = event_dir * min (event_dir * current.horizontal_[event_dir], + - gap_length / 2 + + event_dir + * heads[k]->extent (commonx, + X_AXIS)[-event_dir]); + } + } + } + + if (event_dir == RIGHT) + { + segments.push_back (current); + current = Beam_segment (); + } + } + while (flip (&event_dir) != LEFT); + } } @@ -586,7 +583,7 @@ Beam::print (SCM grob) scale_drul (&pos, Staff_symbol_referencer::staff_space (me)); Real dy = pos[RIGHT] - pos[LEFT]; - Real slope = (dy && span.length ()) ? dy / span.length () : 0; + Real slope = (dy && span.length ()) ? dy / span.length () : 0; Real beam_thickness = get_beam_thickness (me); Real beam_dy = get_beam_translation (me); @@ -601,7 +598,7 @@ Beam::print (SCM grob) ? segments[0].vertical_count_ : segments.back ().vertical_count_); - for (vsize i = 0; i < segments.size (); i ++) + for (vsize i = 0; i < segments.size (); i++) { Real local_slope = slope; /* @@ -610,8 +607,8 @@ Beam::print (SCM grob) */ if (feather_dir) local_slope += (feather_dir * segments[i].vertical_count_ - * beam_dy - * placements.length () + * beam_dy + * placements.length () / span.length ()); Stencil b = Lookup::beam (local_slope, segments[i].horizontal_.length (), beam_thickness, blot); @@ -668,15 +665,15 @@ Beam::print (SCM grob) extract_grob_set (me, "stems", stems); /* - This code prints the demerits for each beam. Perhaps this - should be switchable for those who want to twiddle with the - parameters. + This code prints the demerits for each beam. Perhaps this + should be switchable for those who want to twiddle with the + parameters. */ string str; SCM properties = Font_interface::text_font_alist_chain (me); - properties = scm_cons(scm_acons (ly_symbol2scm ("font-size"), scm_from_int (-5), SCM_EOL), - properties); + properties = scm_cons (scm_acons (ly_symbol2scm ("font-size"), scm_from_int (-5), SCM_EOL), + properties); Direction stem_dir = stems.size () ? to_dir (stems[0]->get_property ("direction")) : UP; @@ -684,10 +681,10 @@ Beam::print (SCM grob) (me->layout ()->self_scm (), properties, annotation)); if (!score.is_empty ()) - { - score.translate_axis (me->relative_coordinate(commonx, X_AXIS), X_AXIS); - the_beam.add_at_edge (Y_AXIS, stem_dir, score, 1.0); - } + { + score.translate_axis (me->relative_coordinate (commonx, X_AXIS), X_AXIS); + the_beam.add_at_edge (Y_AXIS, stem_dir, score, 1.0); + } } #endif @@ -706,10 +703,10 @@ Beam::get_default_dir (Grob *me) Interval positions = Stem::head_positions (*s); Direction d = DOWN; do - { - if (sign (positions[d]) == d) - extremes[d] = d * max (d * positions[d], d * extremes[d]); - } + { + if (sign (positions[d]) == d) + extremes[d] = d * max (d * positions[d], d * extremes[d]); + } while (flip (&d) != DOWN); } @@ -723,30 +720,29 @@ Beam::get_default_dir (Grob *me) Direction stem_dir = CENTER; SCM stem_dir_scm = s->get_property_data ("direction"); if (is_direction (stem_dir_scm)) - { - stem_dir = to_dir (stem_dir_scm); - force_dir = true; - } + { + stem_dir = to_dir (stem_dir_scm); + force_dir = true; + } else - stem_dir = to_dir (s->get_property ("default-direction")); + stem_dir = to_dir (s->get_property ("default-direction")); if (!stem_dir) - stem_dir = to_dir (s->get_property ("neutral-direction")); + stem_dir = to_dir (s->get_property ("neutral-direction")); if (stem_dir) - { - count[stem_dir] ++; - total[stem_dir] += max (int (- stem_dir * Stem::head_positions (s) [-stem_dir]), 0); - } + { + count[stem_dir]++; + total[stem_dir] += max (int (- stem_dir * Stem::head_positions (s) [-stem_dir]), 0); + } } - if (!force_dir) { if (abs (extremes[UP]) > -extremes[DOWN]) - return DOWN; + return DOWN; else if (extremes[UP] < -extremes[DOWN]) - return UP; + return UP; } Direction dir = CENTER; @@ -754,10 +750,10 @@ Beam::get_default_dir (Grob *me) if ((d = (Direction) sign (count[UP] - count[DOWN]))) dir = d; else if (count[UP] - && count[DOWN] - && (d = (Direction) sign (total[UP] / count[UP] - total[DOWN]/count[DOWN]))) + && count[DOWN] + && (d = (Direction) sign (total[UP] / count[UP] - total[DOWN] / count[DOWN]))) dir = d; - else if ((d = (Direction) sign (total[UP] - total[DOWN]))) + else if ((d = (Direction) sign (total[UP] - total[DOWN]))) dir = d; else dir = to_dir (me->get_property ("neutral-direction")); @@ -779,7 +775,7 @@ Beam::set_stem_directions (Grob *me, Direction d) SCM forcedir = s->get_property_data ("direction"); if (!to_dir (forcedir)) - set_grob_direction (s, d); + set_grob_direction (s, d); } } @@ -818,24 +814,24 @@ Beam::consider_auto_knees (Grob *me) Interval head_extents = Stem::head_positions (stem); if (!head_extents.is_empty ()) - { - head_extents[LEFT] += -1; - head_extents[RIGHT] += 1; - head_extents *= staff_space * 0.5; - - /* - We could subtract beam Y position, but this routine only - sets stem directions, a constant shift does not have an - influence. - */ - head_extents += stem->pure_relative_y_coordinate (common, 0, INT_MAX); - - if (to_dir (stem->get_property_data ("direction"))) - { - Direction stemdir = to_dir (stem->get_property ("direction")); - head_extents[-stemdir] = -stemdir * infinity_f; - } - } + { + head_extents[LEFT] += -1; + head_extents[RIGHT] += 1; + head_extents *= staff_space * 0.5; + + /* + We could subtract beam Y position, but this routine only + sets stem directions, a constant shift does not have an + influence. + */ + head_extents += stem->pure_relative_y_coordinate (common, 0, INT_MAX); + + if (to_dir (stem->get_property_data ("direction"))) + { + Direction stemdir = to_dir (stem->get_property ("direction")); + head_extents[-stemdir] = -stemdir * infinity_f; + } + } head_extents_array.push_back (head_extents); gaps.remove_interval (head_extents); @@ -844,46 +840,46 @@ Beam::consider_auto_knees (Grob *me) Interval max_gap; Real max_gap_len = 0.0; - for (vsize i = gaps.allowed_regions_.size () -1; i != VPOS ;i--) + for (vsize i = gaps.allowed_regions_.size () - 1; i != VPOS; i--) { Interval gap = gaps.allowed_regions_[i]; /* - the outer gaps are not knees. + the outer gaps are not knees. */ if (isinf (gap[LEFT]) || isinf (gap[RIGHT])) - continue; + continue; if (gap.length () >= max_gap_len) - { - max_gap_len = gap.length (); - max_gap = gap; - } + { + max_gap_len = gap.length (); + max_gap = gap; + } } Real beam_translation = get_beam_translation (me); Real beam_thickness = Beam::get_beam_thickness (me); int beam_count = Beam::get_beam_count (me); Real height_of_beams = beam_thickness / 2 - + (beam_count - 1) * beam_translation; + + (beam_count - 1) * beam_translation; Real threshold = scm_to_double (scm) + height_of_beams; if (max_gap_len > threshold) { int j = 0; for (vsize i = 0; i < stems.size (); i++) - { - Grob *stem = stems[i]; - Interval head_extents = head_extents_array[j++]; + { + Grob *stem = stems[i]; + Interval head_extents = head_extents_array[j++]; - Direction d = (head_extents.center () < max_gap.center ()) - ? UP : DOWN; + Direction d = (head_extents.center () < max_gap.center ()) + ? UP : DOWN; - stem->set_property ("direction", scm_from_int (d)); + stem->set_property ("direction", scm_from_int (d)); - head_extents.intersect (max_gap); - assert (head_extents.is_empty () || head_extents.length () < 1e-6); - } + head_extents.intersect (max_gap); + assert (head_extents.is_empty () || head_extents.length () < 1e-6); + } } } @@ -897,16 +893,14 @@ This is done in beam because the shorten has to be uniform over the entire beam. */ - - void set_minimum_dy (Grob *me, Real *dy) { if (*dy) { /* - If dy is smaller than the smallest quant, we - get absurd direction-sign penalties. + If dy is smaller than the smallest quant, we + get absurd direction-sign penalties. */ Real ss = Staff_symbol_referencer::staff_space (me); @@ -917,12 +911,10 @@ set_minimum_dy (Grob *me, Real *dy) Real hang = 1.0 - (beam_thickness - slt) / 2; *dy = sign (*dy) * max (fabs (*dy), - min (min (sit, inter), hang)); + min (min (sit, inter), hang)); } } - - MAKE_SCHEME_CALLBACK (Beam, calc_stem_shorten, 1) SCM Beam::calc_stem_shorten (SCM smob) @@ -936,7 +928,7 @@ Beam::calc_stem_shorten (SCM smob) return scm_from_int (0); Real forced_fraction = 1.0 * forced_stem_count (me) - / normal_stem_count (me); + / normal_stem_count (me); int beam_count = get_beam_count (me); @@ -947,19 +939,17 @@ Beam::calc_stem_shorten (SCM smob) Real staff_space = Staff_symbol_referencer::staff_space (me); SCM shorten_elt - = robust_list_ref (beam_count -1, shorten_list); + = robust_list_ref (beam_count - 1, shorten_list); Real shorten = scm_to_double (shorten_elt) * staff_space; shorten *= forced_fraction; - if (shorten) return scm_from_double (shorten); return scm_from_double (0.0); } - Interval Beam::no_visible_stem_positions (Grob *me, Interval default_value) { @@ -969,7 +959,7 @@ Beam::no_visible_stem_positions (Grob *me, Interval default_value) Interval head_positions; Slice multiplicity; - for (vsize i = 0; i < stems.size(); i++) + for (vsize i = 0; i < stems.size (); i++) { head_positions.unite (Stem::head_positions (stems[i])); multiplicity.unite (Stem::beam_multiplicity (stems[i])); @@ -981,14 +971,13 @@ Beam::no_visible_stem_positions (Grob *me, Interval default_value) programming_error ("The beam should have a direction by now."); Real y = head_positions.linear_combination (dir) - * 0.5 * Staff_symbol_referencer::staff_space (me) - + dir * get_beam_translation (me) * (multiplicity.length () + 1); + * 0.5 * Staff_symbol_referencer::staff_space (me) + + dir * get_beam_translation (me) * (multiplicity.length () + 1); y /= Staff_symbol_referencer::staff_space (me); - return Interval (y,y); + return Interval (y, y); } - /* Compute a first approximation to the beam slope. */ @@ -999,7 +988,7 @@ Beam::calc_least_squares_positions (SCM smob, SCM /* posns */) Grob *me = unsmob_grob (smob); int count = normal_stem_count (me); - Interval pos (0,0); + Interval pos (0, 0); if (count < 1) return ly_interval2scm (no_visible_stem_positions (me, pos)); @@ -1014,9 +1003,9 @@ Beam::calc_least_squares_positions (SCM smob, SCM /* posns */) Grob *lvs = last_normal_stem (me); Interval ideal (Stem::get_stem_info (fvs).ideal_y_ - + fvs->relative_coordinate (commony, Y_AXIS) - my_y, - Stem::get_stem_info (lvs).ideal_y_ - + lvs->relative_coordinate (commony, Y_AXIS) - my_y); + + fvs->relative_coordinate (commony, Y_AXIS) - my_y, + Stem::get_stem_info (lvs).ideal_y_ + + lvs->relative_coordinate (commony, Y_AXIS) - my_y); Real x0 = first_normal_stem (me)->relative_coordinate (commonx, X_AXIS); for (vsize i = 0; i < stems.size (); i++) @@ -1035,29 +1024,29 @@ Beam::calc_least_squares_positions (SCM smob, SCM /* posns */) if (!ideal.delta ()) { Interval chord (Stem::chord_start_y (stems[0]), - Stem::chord_start_y (stems.back ())); + Stem::chord_start_y (stems.back ())); /* Simple beams (2 stems) on middle line should be allowed to be - slightly sloped. + slightly sloped. - However, if both stems reach middle line, - ideal[LEFT] == ideal[RIGHT] and ideal.delta () == 0. + However, if both stems reach middle line, + ideal[LEFT] == ideal[RIGHT] and ideal.delta () == 0. - For that case, we apply artificial slope */ + For that case, we apply artificial slope */ if (!ideal[LEFT] && chord.delta () && count == 2) - { - /* FIXME. -> UP */ - Direction d = (Direction) (sign (chord.delta ()) * UP); - pos[d] = get_beam_thickness (me) / 2; - pos[-d] = -pos[d]; - } + { + /* FIXME. -> UP */ + Direction d = (Direction) (sign (chord.delta ()) * UP); + pos[d] = get_beam_thickness (me) / 2; + pos[-d] = -pos[d]; + } else - pos = ideal; + pos = ideal; /* - For broken beams this doesn't work well. In this case, the - slope esp. of the first part of a broken beam should predict - where the second part goes. + For broken beams this doesn't work well. In this case, the + slope esp. of the first part of a broken beam should predict + where the second part goes. */ ldy = pos[RIGHT] - pos[LEFT]; } @@ -1065,13 +1054,13 @@ Beam::calc_least_squares_positions (SCM smob, SCM /* posns */) { vector<Offset> ideals; for (vsize i = 0; i < stems.size (); i++) - { - Grob *s = stems[i]; - ideals.push_back (Offset (x_posns[i], - Stem::get_stem_info (s).ideal_y_ - + s->relative_coordinate (commony, Y_AXIS) - - my_y)); - } + { + Grob *s = stems[i]; + ideals.push_back (Offset (x_posns[i], + Stem::get_stem_info (s).ideal_y_ + + s->relative_coordinate (commony, Y_AXIS) + - my_y)); + } minimise_least_squares (&slope, &y, ideals); @@ -1088,11 +1077,10 @@ Beam::calc_least_squares_positions (SCM smob, SCM /* posns */) */ scale_drul (&pos, 1 / Staff_symbol_referencer::staff_space (me)); - me->set_property ("least-squares-dy", scm_from_double (ldy)); + me->set_property ("least-squares-dy", scm_from_double (ldy)); return ly_interval2scm (pos); } - // Assuming V is not empty, pick a 'reasonable' point inside V. static Real point_in_interval (Interval v, Real dist) @@ -1126,10 +1114,11 @@ Beam::shift_region_to_valid (SCM grob, SCM posns) extract_grob_set (me, "covered-grobs", covered); Grob *common[NO_AXES] = { me, me }; - for (Axis a = X_AXIS; a < NO_AXES; incr (a)) { - common[a] = common_refpoint_of_array (stems, me, a); - common[a] = common_refpoint_of_array (covered, common[a], a); - } + for (Axis a = X_AXIS; a < NO_AXES; incr (a)) + { + common[a] = common_refpoint_of_array (stems, me, a); + common[a] = common_refpoint_of_array (covered, common[a], a); + } Grob *fvs = first_normal_stem (me); if (!fvs) @@ -1166,20 +1155,20 @@ Beam::shift_region_to_valid (SCM grob, SCM posns) { Grob *s = stems[i]; if (Stem::is_invisible (s)) - continue; + continue; Direction d = get_grob_direction (s); Real left_y - = Stem::get_stem_info (s).shortest_y_ - - slope * x_posns [i]; + = Stem::get_stem_info (s).shortest_y_ + - slope * x_posns [i]; /* - left_y is now relative to the stem S. We want relative to - ourselves, so translate: + left_y is now relative to the stem S. We want relative to + ourselves, so translate: */ left_y - += + s->relative_coordinate (common[Y_AXIS], Y_AXIS) - - me->relative_coordinate (common[Y_AXIS], Y_AXIS); + += + s->relative_coordinate (common[Y_AXIS], Y_AXIS) + - me->relative_coordinate (common[Y_AXIS], Y_AXIS); Interval flp; flp.set_full (); @@ -1188,7 +1177,7 @@ Beam::shift_region_to_valid (SCM grob, SCM posns) feasible_left_point.intersect (flp); } - vector<Grob*> filtered; + vector<Grob *> filtered; /* We only update these for objects that are too large for quanting to find a workaround. Typically, these are notes with @@ -1204,9 +1193,9 @@ Beam::shift_region_to_valid (SCM grob, SCM posns) // A list of intervals into which beams may not fall vector<Interval> forbidden_intervals; - for (vsize i = 0; i < covered.size(); i++) + for (vsize i = 0; i < covered.size (); i++) { - if (!covered[i]->is_live()) + if (!covered[i]->is_live ()) continue; if (Beam::has_interface (covered[i]) && is_cross_staff (covered[i])) @@ -1240,13 +1229,13 @@ Beam::shift_region_to_valid (SCM grob, SCM posns) would resolve the problem, eg. x x - | | + | | ===== ===== - | | + | | x x - + Such beams would need a coordinating grob to resolve the collision, since both will likely want to occupy the centerline. @@ -1289,9 +1278,9 @@ Beam::shift_region_to_valid (SCM grob, SCM posns) while (flip (&d) != LEFT); } - Grob_array *arr = - Pointer_group_interface::get_grob_array (me, - ly_symbol2scm ("covered-grobs")); + Grob_array *arr + = Pointer_group_interface::get_grob_array (me, + ly_symbol2scm ("covered-grobs")); arr->set_array (filtered); vector_sort (forbidden_intervals, Interval::left_less); @@ -1337,7 +1326,7 @@ Beam::shift_region_to_valid (SCM grob, SCM posns) do { if (!feasible_left_point.contains (feasible_beam_placements[d])) - feasible_beam_placements[d] = d*infinity_f; + feasible_beam_placements[d] = d * infinity_f; } while (flip (&d) != DOWN); @@ -1402,7 +1391,7 @@ Beam::slope_damping (SCM smob, SCM posns) Grob *commonx = fvs->common_refpoint (lvs, X_AXIS); Real dx = last_normal_stem (me)->relative_coordinate (commonx, X_AXIS) - - first_normal_stem (me)->relative_coordinate (commonx, X_AXIS); + - first_normal_stem (me)->relative_coordinate (commonx, X_AXIS); Real slope = dy && dx ? dy / dx : 0; @@ -1421,13 +1410,12 @@ Beam::slope_damping (SCM smob, SCM posns) return ly_interval2scm (pos); } - MAKE_SCHEME_CALLBACK (Beam, quanting, 2); SCM Beam::quanting (SCM smob, SCM posns) { Grob *me = unsmob_grob (smob); - Drul_array<Real> ys(0, 0); + Drul_array<Real> ys (0, 0); ys = robust_scm2drul (posns, ys); Beam_scoring_problem problem (me, ys); @@ -1435,7 +1423,6 @@ Beam::quanting (SCM smob, SCM posns) return ly_interval2scm (ys); } - /* Report slice containing the numbers that are both in (car BEAMING) and (cdr BEAMING) @@ -1449,7 +1436,7 @@ where_are_the_whole_beams (SCM beaming) { if (scm_c_memq (scm_car (s), scm_cdr (beaming)) != SCM_BOOL_F) - l.add_point (scm_to_int (scm_car (s))); + l.add_point (scm_to_int (scm_car (s))); } return l; @@ -1459,27 +1446,27 @@ where_are_the_whole_beams (SCM beaming) in POS for stem S. This Y position is relative to S. */ Real Beam::calc_stem_y (Grob *me, Grob *stem, Grob **common, - Real xl, Real xr, Direction feather_dir, - Drul_array<Real> pos, bool french) + Real xl, Real xr, Direction feather_dir, + Drul_array<Real> pos, bool french) { Real beam_translation = get_beam_translation (me); Direction stem_dir = get_grob_direction (stem); Real dx = xr - xl; - Real relx = dx ? (stem->relative_coordinate (common[X_AXIS], X_AXIS) - xl)/dx : 0; - Real xdir = 2*relx-1; + Real relx = dx ? (stem->relative_coordinate (common[X_AXIS], X_AXIS) - xl) / dx : 0; + Real xdir = 2 * relx - 1; - Real stem_y = linear_combination(pos, xdir); + Real stem_y = linear_combination (pos, xdir); SCM beaming = stem->get_property ("beaming"); Slice beam_slice (french - ? where_are_the_whole_beams (beaming) - : Stem::beam_multiplicity (stem)); + ? where_are_the_whole_beams (beaming) + : Stem::beam_multiplicity (stem)); if (beam_slice.is_empty ()) - beam_slice = Slice (0,0); - Interval beam_multiplicity(beam_slice[LEFT], - beam_slice[RIGHT]); + beam_slice = Slice (0, 0); + Interval beam_multiplicity (beam_slice[LEFT], + beam_slice[RIGHT]); /* feather dir = 1 , relx 0->1 : factor 0 -> 1 @@ -1493,9 +1480,9 @@ Beam::calc_stem_y (Grob *me, Grob *stem, Grob **common, feather_factor = 1 - relx; stem_y += feather_factor * beam_translation - * beam_multiplicity[Direction(((french) ? DOWN : UP)*stem_dir)]; + * beam_multiplicity[Direction (((french) ? DOWN : UP) * stem_dir)]; Real id = me->relative_coordinate (common[Y_AXIS], Y_AXIS) - - stem->relative_coordinate (common[Y_AXIS], Y_AXIS); + - stem->relative_coordinate (common[Y_AXIS], Y_AXIS); return stem_y + id; } @@ -1549,20 +1536,20 @@ Beam::set_stem_lengths (SCM smob) bool french = to_boolean (s->get_property ("french-beaming")); Real stem_y = calc_stem_y (me, s, common, - xl, xr, feather_dir, - pos, french && s != lvs && s!= fvs); + xl, xr, feather_dir, + pos, french && s != lvs && s != fvs); /* - Make the stems go up to the end of the beam. This doesn't matter - for normal beams, but for tremolo beams it looks silly otherwise. + Make the stems go up to the end of the beam. This doesn't matter + for normal beams, but for tremolo beams it looks silly otherwise. */ if (gap - && !Stem::is_invisible (s)) - stem_y += thick * 0.5 * get_grob_direction (s); + && !Stem::is_invisible (s)) + stem_y += thick * 0.5 * get_grob_direction (s); /* - Do set_stemend for invisible stems too, so tuplet brackets - have a reference point for sloping + Do set_stemend for invisible stems too, so tuplet brackets + have a reference point for sloping */ Stem::set_stemend (s, 2 * stem_y / staff_space); } @@ -1579,30 +1566,30 @@ Beam::set_beaming (Grob *me, Beaming_pattern const *beaming) for (vsize i = 0; i < stems.size (); i++) { /* - Don't overwrite user settings. + Don't overwrite user settings. */ do - { - Grob *stem = stems[i]; - SCM beaming_prop = stem->get_property ("beaming"); - if (beaming_prop == SCM_EOL - || index_get_cell (beaming_prop, d) == SCM_EOL) - { - int count = beaming->beamlet_count (i, d); - if (i > 0 - && i + 1 < stems.size () - && Stem::is_invisible (stem)) - count = min (count, beaming->beamlet_count (i,-d)); - - if ( ((i == 0 && d == LEFT) - || (i == stems.size ()-1 && d == RIGHT)) - && stems.size () > 1 - && to_boolean (me->get_property ("clip-edges"))) - count = 0; - - Stem::set_beaming (stem, count, d); - } - } + { + Grob *stem = stems[i]; + SCM beaming_prop = stem->get_property ("beaming"); + if (beaming_prop == SCM_EOL + || index_get_cell (beaming_prop, d) == SCM_EOL) + { + int count = beaming->beamlet_count (i, d); + if (i > 0 + && i + 1 < stems.size () + && Stem::is_invisible (stem)) + count = min (count, beaming->beamlet_count (i, -d)); + + if ( ((i == 0 && d == LEFT) + || (i == stems.size () - 1 && d == RIGHT)) + && stems.size () > 1 + && to_boolean (me->get_property ("clip-edges"))) + count = 0; + + Stem::set_beaming (stem, count, d); + } + } while (flip (&d) != LEFT); } } @@ -1618,13 +1605,13 @@ Beam::forced_stem_count (Grob *me) Grob *s = stems[i]; /* I can imagine counting those boundaries as a half forced stem, - but let's count them full for now. */ + but let's count them full for now. */ Direction defdir = to_dir (s->get_property ("default-direction")); if (abs (Stem::chord_start_y (s)) > 0.1 - && defdir - && get_grob_direction (s) != defdir) - f++; + && defdir + && get_grob_direction (s) != defdir) + f++; } return f; } @@ -1681,7 +1668,7 @@ Beam::rest_collision_callback (SCM smob, SCM prev_offset) return scm_from_double (0.0); Drul_array<Real> pos (robust_scm2drul (beam->get_property ("positions"), - Drul_array<Real> (0,0))); + Drul_array<Real> (0, 0))); Real staff_space = Staff_symbol_referencer::staff_space (rest); @@ -1689,8 +1676,8 @@ Beam::rest_collision_callback (SCM smob, SCM prev_offset) Real dy = pos[RIGHT] - pos[LEFT]; - Drul_array<Grob*> visible_stems (first_normal_stem (beam), - last_normal_stem (beam)); + Drul_array<Grob *> visible_stems (first_normal_stem (beam), + last_normal_stem (beam)); extract_grob_set (beam, "stems", stems); Grob *common = common_refpoint_of_array (stems, beam, X_AXIS); @@ -1701,7 +1688,7 @@ Beam::rest_collision_callback (SCM smob, SCM prev_offset) Direction d = get_grob_direction (stem); Real stem_y = pos[LEFT] - + (stem->relative_coordinate (common, X_AXIS) - x0) * slope; + + (stem->relative_coordinate (common, X_AXIS) - x0) * slope; Real beam_translation = get_beam_translation (beam); Real beam_thickness = Beam::get_beam_thickness (beam); @@ -1713,7 +1700,7 @@ Beam::rest_collision_callback (SCM smob, SCM prev_offset) = Stem::beam_multiplicity (stem).length () + 1; Real height_of_my_beams = beam_thickness / 2 - + (beam_count - 1) * beam_translation; + + (beam_count - 1) * beam_translation; Real beam_y = stem_y - d * height_of_my_beams; Grob *common_y = rest->common_refpoint (beam, Y_AXIS); @@ -1724,7 +1711,7 @@ Beam::rest_collision_callback (SCM smob, SCM prev_offset) Real rest_dim = rest_extent[d]; Real minimum_distance = staff_space * (robust_scm2double (stem->get_property ("stemlet-length"), 0.0) - + robust_scm2double (rest->get_property ("minimum-distance"), 0.0)); + + robust_scm2double (rest->get_property ("minimum-distance"), 0.0)); Real shift = d * min (d * (beam_y - d * minimum_distance - rest_dim), 0.0); @@ -1758,10 +1745,10 @@ Beam::is_knee (Grob *me) { Direction dir = get_grob_direction (stems[i]); if (d && d != dir) - { - knee = true; - break; - } + { + knee = true; + break; + } d = dir; } @@ -1797,22 +1784,22 @@ Beam::get_direction_beam_count (Grob *me, Direction d) for (vsize i = stems.size (); i--;) { /* - Should we take invisible stems into account? + Should we take invisible stems into account? */ if (get_grob_direction (stems[i]) == d) - bc = max (bc, (Stem::beam_multiplicity (stems[i]).length () + 1)); + bc = max (bc, (Stem::beam_multiplicity (stems[i]).length () + 1)); } return bc; } ADD_INTERFACE (Beam, - "A beam.\n" - "\n" - "The @code{beam-thickness} property is the weight of beams," - " measured in staffspace. The @code{direction} property is" - " not user-serviceable. Use the @code{direction} property" - " of @code{Stem} instead.\n" + "A beam.\n" + "\n" + "The @code{beam-thickness} property is the weight of beams," + " measured in staffspace. The @code{direction} property is" + " not user-serviceable. Use the @code{direction} property" + " of @code{Stem} instead.\n" "\n" "The following properties may be set in the @code{details}" " list.\n" @@ -1848,32 +1835,32 @@ ADD_INTERFACE (Beam, " calculating direction penalties.\n" "@end table\n", - /* properties */ - "annotation " - "auto-knee-gap " - "beamed-stem-shorten " - "beaming " - "beam-thickness " - "break-overshoot " - "clip-edges " - "concaveness " - "collision-interfaces " - "collision-voice-only " - "covered-grobs " - "damping " - "details " - "direction " - "gap " - "gap-count " - "grow-direction " - "inspect-quants " - "knee " - "length-fraction " - "least-squares-dy " - "neutral-direction " - "normal-stems " - "positions " - "quantized-positions " - "shorten " - "stems " - ); + /* properties */ + "annotation " + "auto-knee-gap " + "beamed-stem-shorten " + "beaming " + "beam-thickness " + "break-overshoot " + "clip-edges " + "concaveness " + "collision-interfaces " + "collision-voice-only " + "covered-grobs " + "damping " + "details " + "direction " + "gap " + "gap-count " + "grow-direction " + "inspect-quants " + "knee " + "length-fraction " + "least-squares-dy " + "neutral-direction " + "normal-stems " + "positions " + "quantized-positions " + "shorten " + "stems " + ); diff --git a/lily/beaming-pattern.cc b/lily/beaming-pattern.cc index b823d2ecda..a0fa25e7f7 100644 --- a/lily/beaming-pattern.cc +++ b/lily/beaming-pattern.cc @@ -82,17 +82,17 @@ Beaming_pattern::flag_direction (Beaming_options const &options, vsize i) const return CENTER; int count = infos_[i].count (LEFT); // Both directions should still be the same - int left_count = infos_[i-1].count (RIGHT); - int right_count = infos_[i+1].count (LEFT); + int left_count = infos_[i - 1].count (RIGHT); + int right_count = infos_[i + 1].count (LEFT); // If we are told to subdivide beams and we are next to a beat, point the // beamlet away from the beat. if (options.subdivide_beams_) { if (infos_[i].rhythmic_importance_ < 0) - return RIGHT; - else if (infos_[i+1].rhythmic_importance_ < 0) - return LEFT; + return RIGHT; + else if (infos_[i + 1].rhythmic_importance_ < 0) + return LEFT; } if (count <= left_count && count <= right_count) @@ -106,13 +106,13 @@ Beaming_pattern::flag_direction (Beaming_options const &options, vsize i) const return LEFT; // If all else fails, point the beamlet away from the important moment. - return (infos_[i].rhythmic_importance_ <= infos_[i+1].rhythmic_importance_) ? RIGHT : LEFT; + return (infos_[i].rhythmic_importance_ <= infos_[i + 1].rhythmic_importance_) ? RIGHT : LEFT; } void Beaming_pattern::de_grace () { - for (vsize i = 0; i < infos_.size (); i ++) + for (vsize i = 0; i < infos_.size (); i++) { infos_[i].de_grace (); } @@ -139,15 +139,15 @@ Beaming_pattern::beamify (Beaming_options const &options) { Direction non_flag_dir = other_dir (flag_direction (options, i)); if (non_flag_dir) - { - int importance = (non_flag_dir == LEFT) - ? infos_[i].rhythmic_importance_ : infos_[i+1].rhythmic_importance_; - int count = (importance < 0 && options.subdivide_beams_) - ? 1 : min (infos_[i].count (non_flag_dir), - infos_[i+non_flag_dir].count (-non_flag_dir)); - - infos_[i].beam_count_drul_[non_flag_dir] = count; - } + { + int importance = (non_flag_dir == LEFT) + ? infos_[i].rhythmic_importance_ : infos_[i + 1].rhythmic_importance_; + int count = (importance < 0 && options.subdivide_beams_) + ? 1 : min (infos_[i].count (non_flag_dir), + infos_[i + non_flag_dir].count (-non_flag_dir)); + + infos_[i].beam_count_drul_[non_flag_dir] = count; + } } } @@ -164,44 +164,43 @@ Beaming_pattern::find_rhythmic_importance (Beaming_options const &options) // If a beat grouping is not specified, default to 2 beats per group. int count = 2; if (scm_is_pair (grouping)) - { - count = scm_to_int (scm_car (grouping)); - grouping = scm_cdr (grouping); - } + { + count = scm_to_int (scm_car (grouping)); + grouping = scm_cdr (grouping); + } // Mark the start of this beat group if (infos_[i].start_moment_ == measure_pos) - infos_[i].rhythmic_importance_ = -2; + infos_[i].rhythmic_importance_ = -2; // Mark the start of each unit up to the end of this beat group. for (int unit = 1; unit <= count; unit++) - { - Moment next_measure_pos = measure_pos + options.base_moment_; - - while (i < infos_.size () && infos_[i].start_moment_ < next_measure_pos) - { - Moment dt = infos_[i].start_moment_ - measure_pos; - - // The rhythmic importance of a stem between beats depends on its fraction - // of a beat: those stems with a lower denominator are deemed more - // important. - // FIXME: This is not the right way to do things for tuplets. For example, - // in an 8th-note triplet with a quarter-note beat, 1/3 of a beat should be - // more important than 1/2. - if (infos_[i].rhythmic_importance_ >= 0) - infos_[i].rhythmic_importance_ = (int) (dt / options.base_moment_).den (); - - i++; - } - - measure_pos = next_measure_pos; - if (i < infos_.size () && infos_[i].start_moment_ == measure_pos) - infos_[i].rhythmic_importance_ = -1; - } + { + Moment next_measure_pos = measure_pos + options.base_moment_; + + while (i < infos_.size () && infos_[i].start_moment_ < next_measure_pos) + { + Moment dt = infos_[i].start_moment_ - measure_pos; + + // The rhythmic importance of a stem between beats depends on its fraction + // of a beat: those stems with a lower denominator are deemed more + // important. + // FIXME: This is not the right way to do things for tuplets. For example, + // in an 8th-note triplet with a quarter-note beat, 1/3 of a beat should be + // more important than 1/2. + if (infos_[i].rhythmic_importance_ >= 0) + infos_[i].rhythmic_importance_ = (int) (dt / options.base_moment_).den (); + + i++; + } + + measure_pos = next_measure_pos; + if (i < infos_.size () && infos_[i].start_moment_ == measure_pos) + infos_[i].rhythmic_importance_ = -1; + } } } - /* Invisible stems should be treated as though they have the same number of beams as their least-beamed neighbour. Here we go through the stems and @@ -213,21 +212,20 @@ Beaming_pattern::unbeam_invisible_stems () for (vsize i = 1; i < infos_.size (); i++) if (infos_[i].invisible_) { - int b = min (infos_[i].count (LEFT), infos_[i-1].count (LEFT)); - infos_[i].beam_count_drul_[LEFT] = b; - infos_[i].beam_count_drul_[RIGHT] = b; + int b = min (infos_[i].count (LEFT), infos_[i - 1].count (LEFT)); + infos_[i].beam_count_drul_[LEFT] = b; + infos_[i].beam_count_drul_[RIGHT] = b; } for (vsize i = infos_.size (); i--;) if (infos_[i].invisible_) { - int b = min (infos_[i].count (LEFT), infos_[i+1].count (LEFT)); - infos_[i].beam_count_drul_[LEFT] = b; - infos_[i].beam_count_drul_[RIGHT] = b; + int b = min (infos_[i].count (LEFT), infos_[i + 1].count (LEFT)); + infos_[i].beam_count_drul_[LEFT] = b; + infos_[i].beam_count_drul_[RIGHT] = b; } } - void Beaming_pattern::add_stem (Moment m, int b, bool invisible) { @@ -254,10 +252,10 @@ Moment Beaming_pattern::end_moment (int i) const { Duration *dur = new Duration (2 + max (beamlet_count (i, LEFT), - beamlet_count (i, RIGHT)), - 0); + beamlet_count (i, RIGHT)), + 0); - return infos_.at (i).start_moment_ + dur->get_length(); + return infos_.at (i).start_moment_ + dur->get_length (); } bool @@ -273,18 +271,18 @@ Beaming_pattern::invisibility (int i) const Beaming_pattern * Beaming_pattern::split_pattern (int i) { - Beaming_pattern* new_pattern=0; + Beaming_pattern *new_pattern = 0; int count; new_pattern = new Beaming_pattern (); - for (vsize j=i+1; j<infos_.size (); j++) + for (vsize j = i + 1; j < infos_.size (); j++) { - count = max(beamlet_count (j, LEFT), beamlet_count(j, RIGHT)); + count = max (beamlet_count (j, LEFT), beamlet_count (j, RIGHT)); new_pattern->add_stem (start_moment (j), count, invisibility (j)); } - for (vsize j=i+1; j<infos_.size (); ) + for (vsize j = i + 1; j < infos_.size ();) infos_.pop_back (); return (new_pattern); } diff --git a/lily/bend-engraver.cc b/lily/bend-engraver.cc index cd2d47a9d7..1d8eced4f6 100644 --- a/lily/bend-engraver.cc +++ b/lily/bend-engraver.cc @@ -38,7 +38,7 @@ protected: void stop_translation_timestep (); void start_translation_timestep (); void stop_fall (); - + private: Moment stop_moment_; Stream_event *fall_event_; @@ -60,11 +60,10 @@ void Bend_engraver::stop_fall () { bool bar = scm_is_string (get_property ("whichBar")); - - + fall_->set_bound (RIGHT, unsmob_grob (bar - ? get_property ("currentCommandColumn") - : get_property ("currentMusicalColumn"))); + ? get_property ("currentCommandColumn") + : get_property ("currentMusicalColumn"))); last_fall_ = fall_; fall_ = 0; note_head_ = 0; @@ -74,10 +73,10 @@ Bend_engraver::stop_fall () void Bend_engraver::stop_translation_timestep () { - if (fall_ && !fall_->get_bound (LEFT)) + if (fall_ && !fall_->get_bound (LEFT)) { fall_->set_bound (LEFT, note_head_); - fall_->set_parent (note_head_, Y_AXIS); + fall_->set_parent (note_head_, Y_AXIS); } } @@ -97,7 +96,7 @@ Bend_engraver::acknowledge_note_head (Grob_info info) { if (!fall_event_) return; - + if (note_head_ && fall_) { stop_fall (); @@ -105,7 +104,7 @@ Bend_engraver::acknowledge_note_head (Grob_info info) note_head_ = info.grob (); stop_moment_ = now_mom () + get_event_length (info.event_cause (), - now_mom ()); + now_mom ()); } Bend_engraver::Bend_engraver () @@ -130,22 +129,22 @@ Bend_engraver::process_music () { fall_ = make_spanner ("BendAfter", fall_event_->self_scm ()); fall_->set_property ("delta-position", - scm_from_double (robust_scm2double (fall_event_->get_property ("delta-step"), 0))); + scm_from_double (robust_scm2double (fall_event_->get_property ("delta-step"), 0))); } } ADD_ACKNOWLEDGER (Bend_engraver, note_head); ADD_TRANSLATOR (Bend_engraver, - /* doc */ - "Create fall spanners.", + /* doc */ + "Create fall spanners.", - /* create */ - "BendAfter ", + /* create */ + "BendAfter ", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/bezier-bow.cc b/lily/bezier-bow.cc index 587d3d65db..6103770b84 100644 --- a/lily/bezier-bow.cc +++ b/lily/bezier-bow.cc @@ -23,7 +23,7 @@ static Real F0_1 (Real x) { - return 2 / M_PI *atan (M_PI *x / 2); + return 2 / M_PI * atan (M_PI * x / 2); } Real @@ -101,7 +101,7 @@ slur_height (Real width, Real h_inf, Real r_0) void get_slur_indent_height (Real *indent, Real *height, - Real width, Real h_inf, Real r_0) + Real width, Real h_inf, Real r_0) { Real max_fraction = 1.0 / 3.1; *height = slur_height (width, h_inf, r_0); @@ -117,7 +117,7 @@ slur_shape (Real width, Real h_inf, Real r_0) Real height; get_slur_indent_height (&indent, &height, - width, h_inf, r_0); + width, h_inf, r_0); Bezier curve; curve.control_[0] = Offset (0, 0); diff --git a/lily/bezier.cc b/lily/bezier.cc index e15b04827a..f230d1057d 100644 --- a/lily/bezier.cc +++ b/lily/bezier.cc @@ -21,7 +21,8 @@ #include "warn.hh" #include "libc-extension.hh" -Real binomial_coefficient_3[] = { +Real binomial_coefficient_3[] = +{ 1, 3, 3, 1 }; @@ -62,7 +63,7 @@ translate (vector<Offset> *array, Offset o) Real Bezier::get_other_coordinate (Axis a, Real x) const { - Axis other = Axis ((a +1) % NO_AXES); + Axis other = Axis ((a + 1) % NO_AXES); vector<Real> ts = solve_point (a, x); if (ts.size () == 0) @@ -93,7 +94,7 @@ Bezier::curve_coordinate (Real t, Axis a) const for (int j = 0; j < 4; j++) { r += control_[j][a] * binomial_coefficient_3[j] - * tj * one_min_tj[3 - j]; + * tj * one_min_tj[3 - j]; tj *= t; } @@ -114,7 +115,7 @@ Bezier::curve_point (Real t) const for (int j = 0; j < 4; j++) { o += control_[j] * binomial_coefficient_3[j] - * tj * one_min_tj[3 - j]; + * tj * one_min_tj[3 - j]; tj *= t; } @@ -130,15 +131,16 @@ Bezier::curve_point (Real t) const /* Cache binom (3, j) t^j (1-t)^{3-j} */ -struct Polynomial_cache { +struct Polynomial_cache +{ Polynomial terms_[4]; Polynomial_cache () { for (int j = 0; j <= 3; j++) terms_[j] - = binomial_coefficient_3[j] - * Polynomial::power (j, Polynomial (0, 1)) - * Polynomial::power (3 - j, Polynomial (1, -1)); + = binomial_coefficient_3[j] + * Polynomial::power (j, Polynomial (0, 1)) + * Polynomial::power (3 - j, Polynomial (1, -1)); } }; @@ -206,7 +208,7 @@ Bezier::solve_point (Axis ax, Real coordinate) const Interval Bezier::extent (Axis a) const { - int o = (a + 1)%NO_AXES; + int o = (a + 1) % NO_AXES; Offset d; d[Axis (o)] = 1.0; Interval iv; @@ -228,10 +230,9 @@ Bezier::control_point_extent (Axis a) const for (int i = CONTROL_COUNT; i--;) ext.add_point (control_[i][a]); - return ext; + return ext; } - /** Flip around axis A */ @@ -265,7 +266,7 @@ Bezier::assert_sanity () const { for (int i = 0; i < CONTROL_COUNT; i++) assert (!isnan (control_[i].length ()) - && !isinf (control_[i].length ())); + && !isinf (control_[i].length ())); } void @@ -277,7 +278,6 @@ Bezier::reverse () *this = b2; } - /* Subdivide a bezier at T into LEFT_PART and RIGHT_PART using deCasteljau's algorithm. @@ -287,15 +287,15 @@ Bezier::subdivide (Real t, Bezier *left_part, Bezier *right_part) const { Offset p[CONTROL_COUNT][CONTROL_COUNT]; - for (int i = 0; i < CONTROL_COUNT ; i++) + for (int i = 0; i < CONTROL_COUNT; i++) p[i][CONTROL_COUNT - 1 ] = control_[i]; - for (int j = CONTROL_COUNT - 2; j >= 0 ; j--) - for (int i = 0; i < CONTROL_COUNT -1; i++) - p[i][j] = p[i][j+1] + t * (p[i+1][j+1] - p[i][j+1]); + for (int j = CONTROL_COUNT - 2; j >= 0; j--) + for (int i = 0; i < CONTROL_COUNT - 1; i++) + p[i][j] = p[i][j + 1] + t * (p[i + 1][j + 1] - p[i][j + 1]); for (int i = 0; i < CONTROL_COUNT; i++) { - left_part->control_[i]=p[0][CONTROL_COUNT - 1 - i]; - right_part->control_[i]=p[i][i]; + left_part->control_[i] = p[0][CONTROL_COUNT - 1 - i]; + right_part->control_[i] = p[i][i]; } } @@ -308,20 +308,20 @@ Bezier::extract (Real t_min, Real t_max) const { if ((t_min < 0) || (t_max) > 1) programming_error - ("bezier extract arguments outside of limits: curve may have bad shape"); + ("bezier extract arguments outside of limits: curve may have bad shape"); if (t_min >= t_max) - programming_error - ("lower bezier extract value not less than upper value: curve may have bad shape"); + programming_error + ("lower bezier extract value not less than upper value: curve may have bad shape"); Bezier bez1, bez2, bez3, bez4; if (t_min == 0.0) bez2 = *this; else - subdivide (t_min, &bez1, &bez2); + subdivide (t_min, &bez1, &bez2); if (t_max == 1.0) - return bez2; + return bez2; else - { - bez2.subdivide ((t_max-t_min)/(1-t_min), &bez3, &bez4); - return bez3; - } + { + bez2.subdivide ((t_max - t_min) / (1 - t_min), &bez3, &bez4); + return bez3; + } } diff --git a/lily/book-scheme.cc b/lily/book-scheme.cc index 339e2c2829..0fe4322c35 100644 --- a/lily/book-scheme.cc +++ b/lily/book-scheme.cc @@ -25,9 +25,9 @@ #include "ly-module.hh" LY_DEFINE (ly_make_book, "ly:make-book", - 2, 0, 1, (SCM paper, SCM header, SCM scores), - "Make a @code{\\book} of @var{paper} and @var{header}" - " (which may be @code{#f} as well) containing @code{\\scores}.") + 2, 0, 1, (SCM paper, SCM header, SCM scores), + "Make a @code{\\book} of @var{paper} and @var{header}" + " (which may be @code{#f} as well) containing @code{\\scores}.") { Output_def *odef = unsmob_output_def (paper); LY_ASSERT_SMOB (Output_def, paper, 1); @@ -46,8 +46,8 @@ LY_DEFINE (ly_make_book, "ly:make-book", } LY_DEFINE (ly_make_book_part, "ly:make-book-part", - 1, 0, 0, (SCM scores), - "Make a @code{\\bookpart} containing @code{\\scores}.") + 1, 0, 0, (SCM scores), + "Make a @code{\\bookpart} containing @code{\\scores}.") { Book *book = new Book; book->scores_ = scm_append (scm_list_2 (scores, book->scores_)); @@ -58,13 +58,13 @@ LY_DEFINE (ly_make_book_part, "ly:make-book-part", } LY_DEFINE (ly_book_process, "ly:book-process", - 4, 0, 0, (SCM book_smob, - SCM default_paper, - SCM default_layout, - SCM output), - "Print book. @var{output} is passed to the backend unchanged." - " For example, it may be a string (for file based outputs)" - " or a socket (for network based output).") + 4, 0, 0, (SCM book_smob, + SCM default_paper, + SCM default_layout, + SCM output), + "Print book. @var{output} is passed to the backend unchanged." + " For example, it may be a string (for file based outputs)" + " or a socket (for network based output).") { Book *book = unsmob_book (book_smob); @@ -73,7 +73,7 @@ LY_DEFINE (ly_book_process, "ly:book-process", LY_ASSERT_SMOB (Output_def, default_layout, 3); Paper_book *pb = book->process (unsmob_output_def (default_paper), - unsmob_output_def (default_layout)); + unsmob_output_def (default_layout)); if (pb) { pb->output (output); @@ -83,24 +83,23 @@ LY_DEFINE (ly_book_process, "ly:book-process", return SCM_UNSPECIFIED; } - LY_DEFINE (ly_book_process_to_systems, "ly:book-process-to-systems", - 4, 0, 0, (SCM book_smob, - SCM default_paper, - SCM default_layout, - SCM output), - "Print book. @var{output} is passed to the backend unchanged." - " For example, it may be a string (for file based outputs)" - " or a socket (for network based output).") + 4, 0, 0, (SCM book_smob, + SCM default_paper, + SCM default_layout, + SCM output), + "Print book. @var{output} is passed to the backend unchanged." + " For example, it may be a string (for file based outputs)" + " or a socket (for network based output).") { LY_ASSERT_SMOB (Book, book_smob, 1); LY_ASSERT_SMOB (Output_def, default_paper, 2); LY_ASSERT_SMOB (Output_def, default_layout, 3); - Book *book = unsmob_book (book_smob); + Book *book = unsmob_book (book_smob); Paper_book *pb = book->process (unsmob_output_def (default_paper), - unsmob_output_def (default_layout)); + unsmob_output_def (default_layout)); if (pb) { pb->classic_output (output); @@ -111,28 +110,28 @@ LY_DEFINE (ly_book_process_to_systems, "ly:book-process-to-systems", } LY_DEFINE (ly_book_add_score_x, "ly:book-add-score!", - 2, 0, 0, (SCM book_smob, SCM score), - "Add @var{score} to @var{book-smob} score list.") + 2, 0, 0, (SCM book_smob, SCM score), + "Add @var{score} to @var{book-smob} score list.") { LY_ASSERT_SMOB (Book, book_smob, 1); - Book *book = unsmob_book (book_smob); + Book *book = unsmob_book (book_smob); book->add_score (score); return SCM_UNSPECIFIED; } LY_DEFINE (ly_book_add_bookpart_x, "ly:book-add-bookpart!", - 2, 0, 0, (SCM book_smob, SCM book_part), - "Add @var{book-part} to @var{book-smob} book part list.") + 2, 0, 0, (SCM book_smob, SCM book_part), + "Add @var{book-part} to @var{book-smob} book part list.") { LY_ASSERT_SMOB (Book, book_smob, 1); - Book *book = unsmob_book (book_smob); + Book *book = unsmob_book (book_smob); book->add_bookpart (book_part); return SCM_UNSPECIFIED; } LY_DEFINE (ly_book_book_parts, "ly:book-book-parts", - 1, 0, 0, (SCM book), - "Return book parts in @var{book}.") + 1, 0, 0, (SCM book), + "Return book parts in @var{book}.") { LY_ASSERT_SMOB (Book, book, 1); Book *b = unsmob_book (book); @@ -140,8 +139,8 @@ LY_DEFINE (ly_book_book_parts, "ly:book-book-parts", } LY_DEFINE (ly_book_paper, "ly:book-paper", - 1, 0, 0, (SCM book), - "Return paper in @var{book}.") + 1, 0, 0, (SCM book), + "Return paper in @var{book}.") { LY_ASSERT_SMOB (Book, book, 1); Book *b = unsmob_book (book); @@ -149,8 +148,8 @@ LY_DEFINE (ly_book_paper, "ly:book-paper", } LY_DEFINE (ly_book_header, "ly:book-header", - 1, 0, 0, (SCM book), - "Return header in @var{book}.") + 1, 0, 0, (SCM book), + "Return header in @var{book}.") { LY_ASSERT_SMOB (Book, book, 1); Book *b = unsmob_book (book); @@ -158,8 +157,8 @@ LY_DEFINE (ly_book_header, "ly:book-header", } LY_DEFINE (ly_book_scores, "ly:book-scores", - 1, 0, 0, (SCM book), - "Return scores in @var{book}.") + 1, 0, 0, (SCM book), + "Return scores in @var{book}.") { LY_ASSERT_SMOB (Book, book, 1); Book *b = unsmob_book (book); diff --git a/lily/book.cc b/lily/book.cc index e1fdef644d..5ec33e7b9a 100644 --- a/lily/book.cc +++ b/lily/book.cc @@ -73,14 +73,14 @@ Book::Book (Book const &s) SCM entry = scm_car (p); if (Score *newscore = unsmob_score (entry)) - *t = scm_cons (newscore->clone ()->unprotect (), SCM_EOL); + * t = scm_cons (newscore->clone ()->unprotect (), SCM_EOL); else if (Page_marker *marker = unsmob_page_marker (entry)) - *t = scm_cons (marker->clone ()->unprotect (), SCM_EOL); + * t = scm_cons (marker->clone ()->unprotect (), SCM_EOL); else - { - /* This entry is a markup list */ - *t = scm_cons (entry, SCM_EOL); - } + { + /* This entry is a markup list */ + *t = scm_cons (entry, SCM_EOL); + } t = SCM_CDRLOC (*t); } @@ -123,7 +123,7 @@ Book::mark_smob (SCM s) } int -Book::print_smob (SCM, SCM p, scm_print_state*) +Book::print_smob (SCM, SCM p, scm_print_state *) { scm_puts ("#<Book>", p); return 1; @@ -190,19 +190,19 @@ Book::error_found () for (SCM s = scores_; scm_is_pair (s); s = scm_cdr (s)) if (Score *score = unsmob_score (scm_car (s))) if (score->error_found_) - return true; + return true; for (SCM part = bookparts_; scm_is_pair (part); part = scm_cdr (part)) if (Book *bookpart = unsmob_book (scm_car (part))) if (bookpart->error_found ()) - return true; + return true; return false; } Paper_book * Book::process (Output_def *default_paper, - Output_def *default_layout) + Output_def *default_layout) { return process (default_paper, default_layout, 0); } @@ -217,10 +217,10 @@ Book::process_bookparts (Paper_book *output_paper_book, Output_def *paper, Outpu { Paper_book *paper_book_part = book->process (paper, layout, output_paper_book); if (paper_book_part) - { - output_paper_book->add_bookpart (paper_book_part->self_scm ()); - paper_book_part->unprotect (); - } + { + output_paper_book->add_bookpart (paper_book_part->self_scm ()); + paper_book_part->unprotect (); + } } } /* In a Paper_book, bookparts are stored in straight order */ @@ -233,26 +233,26 @@ Book::process_score (SCM s, Paper_book *output_paper_book, Output_def *layout) if (Score *score = unsmob_score (scm_car (s))) { SCM outputs = score - ->book_rendering (output_paper_book->paper_, layout); + ->book_rendering (output_paper_book->paper_, layout); while (scm_is_pair (outputs)) - { - Music_output *output = unsmob_music_output (scm_car (outputs)); - - if (Performance *perf = dynamic_cast<Performance *> (output)) - output_paper_book->add_performance (perf->self_scm ()); - else if (Paper_score *pscore = dynamic_cast<Paper_score *> (output)) - { - if (ly_is_module (score->get_header ())) - output_paper_book->add_score (score->get_header ()); - output_paper_book->add_score (pscore->self_scm ()); - } - - outputs = scm_cdr (outputs); - } + { + Music_output *output = unsmob_music_output (scm_car (outputs)); + + if (Performance *perf = dynamic_cast<Performance *> (output)) + output_paper_book->add_performance (perf->self_scm ()); + else if (Paper_score *pscore = dynamic_cast<Paper_score *> (output)) + { + if (ly_is_module (score->get_header ())) + output_paper_book->add_score (score->get_header ()); + output_paper_book->add_score (pscore->self_scm ()); + } + + outputs = scm_cdr (outputs); + } } else if (Text_interface::is_markup_list (scm_car (s)) - || unsmob_page_marker (scm_car (s))) + || unsmob_page_marker (scm_car (s))) output_paper_book->add_score (scm_car (s)); else assert (0); @@ -263,8 +263,8 @@ Book::process_score (SCM s, Paper_book *output_paper_book, Output_def *layout) */ Paper_book * Book::process (Output_def *default_paper, - Output_def *default_layout, - Paper_book *parent_part) + Output_def *default_layout, + Paper_book *parent_part) { Output_def *paper = paper_ ? paper_ : default_paper; diff --git a/lily/box.cc b/lily/box.cc index 6b6088bf19..648c7f7da2 100644 --- a/lily/box.cc +++ b/lily/box.cc @@ -80,7 +80,7 @@ Offset Box::center () const { return Offset (interval_a_[X_AXIS].center (), - interval_a_[Y_AXIS].center ()); + interval_a_[Y_AXIS].center ()); } void @@ -105,7 +105,7 @@ Box::mark_smob (SCM /* x */) } int -Box::print_smob (SCM /* x */, SCM p, scm_print_state*) +Box::print_smob (SCM /* x */, SCM p, scm_print_state *) { scm_puts ("#<Box>", p); return 1; diff --git a/lily/break-align-engraver.cc b/lily/break-align-engraver.cc index 76d6e891f6..3004b53393 100644 --- a/lily/break-align-engraver.cc +++ b/lily/break-align-engraver.cc @@ -91,20 +91,20 @@ Break_align_engraver::acknowledge_break_aligned (Grob_info inf) if (Item *item = dynamic_cast<Item *> (inf.grob ())) { /* - Removed check for item->empty (X_AXIS). --hwn 20/1/04 + Removed check for item->empty (X_AXIS). --hwn 20/1/04 */ if (item->get_parent (X_AXIS)) - return; + return; if (!Item::is_non_musical (item)) - return; + return; SCM align_name = item->get_property ("break-align-symbol"); if (!scm_is_symbol (align_name)) - return; + return; if (!align_) - create_alignment (inf); + create_alignment (inf); add_to_group (align_name, item); } @@ -127,7 +127,7 @@ Break_align_engraver::create_alignment (Grob_info inf) */ left_edge_ = random_source->make_item ("LeftEdge", SCM_EOL); add_to_group (left_edge_->get_property ("break-align-symbol"), - left_edge_); + left_edge_); } void @@ -158,20 +158,20 @@ Break_align_engraver::add_to_group (SCM align_name, Item *item) ADD_ACKNOWLEDGER (Break_align_engraver, break_aligned); ADD_ACKNOWLEDGER (Break_align_engraver, break_alignable); ADD_TRANSLATOR (Break_align_engraver, - /* doc */ - "Align grobs with corresponding @code{break-align-symbols}" - " into groups, and order the groups according to" - " @code{breakAlignOrder}. The left edge of the alignment gets" - " a separate group, with a symbol @code{left-edge}.", - - /* create */ - "BreakAlignment " - "BreakAlignGroup " - "LeftEdge ", - - /* read */ - "", - - /* write */ - "" - ); + /* doc */ + "Align grobs with corresponding @code{break-align-symbols}" + " into groups, and order the groups according to" + " @code{breakAlignOrder}. The left edge of the alignment gets" + " a separate group, with a symbol @code{left-edge}.", + + /* create */ + "BreakAlignment " + "BreakAlignGroup " + "LeftEdge ", + + /* read */ + "", + + /* write */ + "" + ); diff --git a/lily/break-alignment-interface.cc b/lily/break-alignment-interface.cc index 18f0ae8404..a471a7ba9f 100644 --- a/lily/break-alignment-interface.cc +++ b/lily/break-alignment-interface.cc @@ -17,7 +17,6 @@ along with LilyPond. If not, see <http://www.gnu.org/licenses/>. */ - #include "break-align-interface.hh" #include "align-interface.hh" @@ -31,8 +30,6 @@ #include "side-position-interface.hh" #include "warn.hh" - - /* This is tricky: we cannot modify 'elements, since callers are iterating the same list. Reordering the list in-place, or resetting @@ -49,43 +46,40 @@ Break_alignment_interface::break_align_order (Item *me) return SCM_BOOL_F; SCM order = scm_vector_ref (order_vec, - scm_from_int (me->break_status_dir () + 1)); - + scm_from_int (me->break_status_dir () + 1)); return order; } - -vector<Grob*> +vector<Grob *> Break_alignment_interface::ordered_elements (Grob *grob) { Item *me = dynamic_cast<Item *> (grob); extract_grob_set (me, "elements", elts); - SCM order = break_align_order (me); if (order == SCM_BOOL_F) return elts; - - vector<Grob*> writable_elts (elts); - /* - Copy in order specified in BREAK-ALIGN-ORDER. + + vector<Grob *> writable_elts (elts); + /* + Copy in order specified in BREAK-ALIGN-ORDER. */ - vector<Grob*> new_elts; + vector<Grob *> new_elts; for (; scm_is_pair (order); order = scm_cdr (order)) { SCM sym = scm_car (order); for (vsize i = writable_elts.size (); i--;) - { - Grob *g = writable_elts[i]; - if (g && sym == g->get_property ("break-align-symbol")) - { - new_elts.push_back (g); - writable_elts.erase (writable_elts.begin () + i); - } - } + { + Grob *g = writable_elts[i]; + if (g && sym == g->get_property ("break-align-symbol")) + { + new_elts.push_back (g); + writable_elts.erase (writable_elts.begin () + i); + } + } } return new_elts; @@ -101,13 +95,12 @@ MAKE_SCHEME_CALLBACK (Break_alignment_interface, calc_positioning_done, 1) SCM Break_alignment_interface::calc_positioning_done (SCM smob) { - Grob *grob = unsmob_grob (smob); + Grob *grob = unsmob_grob (smob); Item *me = dynamic_cast<Item *> (grob); - me->set_property ("positioning-done", SCM_BOOL_T); - vector<Grob*> elems = ordered_elements (me); + vector<Grob *> elems = ordered_elements (me); vector<Interval> extents; int last_nonempty = -1; @@ -116,7 +109,7 @@ Break_alignment_interface::calc_positioning_done (SCM smob) Interval y = elems[i]->extent (elems[i], X_AXIS); extents.push_back (y); if (!y.is_empty ()) - last_nonempty = i; + last_nonempty = i; } vsize idx = 0; @@ -125,7 +118,7 @@ Break_alignment_interface::calc_positioning_done (SCM smob) vector<Real> offsets; offsets.resize (elems.size ()); - for (vsize i = 0; i < offsets.size ();i++) + for (vsize i = 0; i < offsets.size (); i++) offsets[i] = 0.0; Real extra_right_space = 0.0; @@ -134,106 +127,106 @@ Break_alignment_interface::calc_positioning_done (SCM smob) { vsize next_idx = idx + 1; while (next_idx < elems.size () - && extents[next_idx].is_empty ()) - next_idx++; + && extents[next_idx].is_empty ()) + next_idx++; Grob *l = elems[idx]; Grob *r = 0; if (next_idx < elems.size ()) - r = elems[next_idx]; + r = elems[next_idx]; SCM alist = SCM_EOL; /* - Find the first grob with a space-alist entry. + Find the first grob with a space-alist entry. */ extract_grob_set (l, "elements", elts); for (vsize i = elts.size (); i--;) - { - Grob *elt = elts[i]; - - if (edge_idx == VPOS - && (elt->get_property ("break-align-symbol") - == ly_symbol2scm ("left-edge"))) - edge_idx = idx; - - SCM l = elt->get_property ("space-alist"); - if (scm_is_pair (l)) - { - alist = l; - break; - } - } + { + Grob *elt = elts[i]; + + if (edge_idx == VPOS + && (elt->get_property ("break-align-symbol") + == ly_symbol2scm ("left-edge"))) + edge_idx = idx; + + SCM l = elt->get_property ("space-alist"); + if (scm_is_pair (l)) + { + alist = l; + break; + } + } SCM rsym = r ? SCM_EOL : ly_symbol2scm ("right-edge"); /* - We used to use #'cause to find out the symbol and the spacing - table, but that gets icky when that grob is suicided for some - reason. + We used to use #'cause to find out the symbol and the spacing + table, but that gets icky when that grob is suicided for some + reason. */ if (r) - { - extract_grob_set (r, "elements", elts); - for (vsize i = elts.size (); - !scm_is_symbol (rsym) && i--;) - { - Grob *elt = elts[i]; - rsym = elt->get_property ("break-align-symbol"); - } - } + { + extract_grob_set (r, "elements", elts); + for (vsize i = elts.size (); + !scm_is_symbol (rsym) && i--;) + { + Grob *elt = elts[i]; + rsym = elt->get_property ("break-align-symbol"); + } + } if (rsym == ly_symbol2scm ("left-edge")) - edge_idx = next_idx; + edge_idx = next_idx; SCM entry = SCM_EOL; if (scm_is_symbol (rsym)) - entry = scm_assq (rsym, alist); + entry = scm_assq (rsym, alist); bool entry_found = scm_is_pair (entry); if (!entry_found) - { - string sym_string; - if (scm_is_symbol (rsym)) - sym_string = ly_symbol2string (rsym); + { + string sym_string; + if (scm_is_symbol (rsym)) + sym_string = ly_symbol2string (rsym); - string orig_string; - if (unsmob_grob (l->get_property ("cause"))) - orig_string = unsmob_grob (l->get_property ("cause"))->name (); + string orig_string; + if (unsmob_grob (l->get_property ("cause"))) + orig_string = unsmob_grob (l->get_property ("cause"))->name (); - programming_error (_f ("No spacing entry from %s to `%s'", - orig_string.c_str (), - sym_string.c_str ())); - } + programming_error (_f ("No spacing entry from %s to `%s'", + orig_string.c_str (), + sym_string.c_str ())); + } Real distance = 1.0; SCM type = ly_symbol2scm ("extra-space"); if (entry_found) - { - entry = scm_cdr (entry); + { + entry = scm_cdr (entry); - distance = scm_to_double (scm_cdr (entry)); - type = scm_car (entry); - } + distance = scm_to_double (scm_cdr (entry)); + type = scm_car (entry); + } if (r) - { - if (type == ly_symbol2scm ("extra-space")) - offsets[next_idx] = extents[idx][RIGHT] + distance - - extents[next_idx][LEFT]; - /* should probably junk minimum-space */ - else if (type == ly_symbol2scm ("minimum-space")) - offsets[next_idx] = max (extents[idx][RIGHT], distance); - } + { + if (type == ly_symbol2scm ("extra-space")) + offsets[next_idx] = extents[idx][RIGHT] + distance + - extents[next_idx][LEFT]; + /* should probably junk minimum-space */ + else if (type == ly_symbol2scm ("minimum-space")) + offsets[next_idx] = max (extents[idx][RIGHT], distance); + } else - { - extra_right_space = distance; - if (idx + 1 < offsets.size ()) - offsets[idx+1] = extents[idx][RIGHT] + distance; - } + { + extra_right_space = distance; + if (idx + 1 < offsets.size ()) + offsets[idx + 1] = extents[idx][RIGHT] + distance; + } idx = next_idx; } @@ -246,7 +239,7 @@ Break_alignment_interface::calc_positioning_done (SCM smob) { here += offsets[i]; if (i == edge_idx) - alignment_off = -here; + alignment_off = -here; total_extent.unite (extents[i] + here); } @@ -268,40 +261,38 @@ Break_alignment_interface::calc_positioning_done (SCM smob) return SCM_BOOL_T; } - - MAKE_SCHEME_CALLBACK (Break_alignable_interface, self_align_callback, 1) SCM Break_alignable_interface::self_align_callback (SCM grob) { Grob *me = unsmob_grob (grob); - Item *alignment = dynamic_cast<Item*> (me->get_parent (X_AXIS)); + Item *alignment = dynamic_cast<Item *> (me->get_parent (X_AXIS)); if (!Break_alignment_interface::has_interface (alignment)) return scm_from_int (0); SCM symbol_list = me->get_property ("break-align-symbols"); - vector<Grob*> elements = Break_alignment_interface::ordered_elements (alignment); + vector<Grob *> elements = Break_alignment_interface::ordered_elements (alignment); if (elements.size () == 0) return scm_from_int (0); - + int break_aligned_grob = -1; for (; scm_is_pair (symbol_list); symbol_list = scm_cdr (symbol_list)) { SCM sym = scm_car (symbol_list); for (vsize i = 0; i < elements.size (); i++) - { - if (elements[i]->get_property ("break-align-symbol") == sym) - { - if (Item::break_visible (elements[i]) - && !elements[i]->extent (elements[i], X_AXIS).is_empty ()) - { - break_aligned_grob = i; - goto found_break_aligned_grob; /* ugh. need to break out of 2 loops */ - } - else if (break_aligned_grob == -1) - break_aligned_grob = i; - } - } + { + if (elements[i]->get_property ("break-align-symbol") == sym) + { + if (Item::break_visible (elements[i]) + && !elements[i]->extent (elements[i], X_AXIS).is_empty ()) + { + break_aligned_grob = i; + goto found_break_aligned_grob; /* ugh. need to break out of 2 loops */ + } + else if (break_aligned_grob == -1) + break_aligned_grob = i; + } + } } found_break_aligned_grob: @@ -313,8 +304,8 @@ found_break_aligned_grob: Real anchor = robust_scm2double (alignment_parent->get_property ("break-align-anchor"), 0); return scm_from_double (alignment_parent->relative_coordinate (common, X_AXIS) - - me->relative_coordinate (common, X_AXIS) - + anchor); + - me->relative_coordinate (common, X_AXIS) + + anchor); } MAKE_SCHEME_CALLBACK (Break_aligned_interface, calc_average_anchor, 1) @@ -331,10 +322,10 @@ Break_aligned_interface::calc_average_anchor (SCM grob) { SCM anchor = elts[i]->get_property ("break-align-anchor"); if (scm_is_number (anchor)) - { - count++; - avg += scm_to_double (anchor); - } + { + count++; + avg += scm_to_double (anchor); + } } return scm_from_double (count > 0 ? avg / count : 0); @@ -366,63 +357,63 @@ Break_aligned_interface::calc_break_visibility (SCM smob) { bool visible = false; for (vsize i = 0; i < elts.size (); i++) - { - SCM vis = elts[i]->get_property ("break-visibility"); - if (scm_is_vector (vis) && to_boolean (scm_c_vector_ref (vis, dir))) - visible = true; - } + { + SCM vis = elts[i]->get_property ("break-visibility"); + if (scm_is_vector (vis) && to_boolean (scm_c_vector_ref (vis, dir))) + visible = true; + } scm_c_vector_set_x (ret, dir, scm_from_bool (visible)); } return ret; } ADD_INTERFACE (Break_alignable_interface, - "Object that is aligned on a break alignment.", + "Object that is aligned on a break alignment.", - /* properties */ - "break-align-symbols " - "non-break-align-symbols " - ); + /* properties */ + "break-align-symbols " + "non-break-align-symbols " + ); ADD_INTERFACE (Break_aligned_interface, - "Items that are aligned in prefatory matter.\n" - "\n" - "The spacing of these items is controlled by the" - " @code{space-alist} property. It contains a list" - " @code{break-align-symbol}s with a specification of the" - " associated space. The space specification can be\n" - "\n" - "@table @code\n" - "@item (minimum-space . @var{spc}))\n" - "Pad space until the distance is @var{spc}.\n" - "@item (fixed-space . @var{spc})\n" - "Set a fixed space.\n" - "@item (semi-fixed-space . @var{spc})\n" - "Set a space. Half of it is fixed and half is stretchable." - " (does not work at start of line. fixme)\n" - "@item (extra-space . @var{spc})\n" - "Add @var{spc} amount of space.\n" - "@end table\n" - "\n" - "Special keys for the alist are @code{first-note} and" - " @code{next-note}, signifying the first note on a line, and" - " the next note halfway a line.\n" - "\n" - "Rules for this spacing are much more complicated than this." - " See [Wanske] page 126--134, [Ross] page 143--147.", - - /* properties */ - "break-align-anchor " - "break-align-anchor-alignment " - "break-align-symbol " - "space-alist " - ); + "Items that are aligned in prefatory matter.\n" + "\n" + "The spacing of these items is controlled by the" + " @code{space-alist} property. It contains a list" + " @code{break-align-symbol}s with a specification of the" + " associated space. The space specification can be\n" + "\n" + "@table @code\n" + "@item (minimum-space . @var{spc}))\n" + "Pad space until the distance is @var{spc}.\n" + "@item (fixed-space . @var{spc})\n" + "Set a fixed space.\n" + "@item (semi-fixed-space . @var{spc})\n" + "Set a space. Half of it is fixed and half is stretchable." + " (does not work at start of line. fixme)\n" + "@item (extra-space . @var{spc})\n" + "Add @var{spc} amount of space.\n" + "@end table\n" + "\n" + "Special keys for the alist are @code{first-note} and" + " @code{next-note}, signifying the first note on a line, and" + " the next note halfway a line.\n" + "\n" + "Rules for this spacing are much more complicated than this." + " See [Wanske] page 126--134, [Ross] page 143--147.", + + /* properties */ + "break-align-anchor " + "break-align-anchor-alignment " + "break-align-symbol " + "space-alist " + ); ADD_INTERFACE (Break_alignment_interface, - "The object that performs break alignment. See" - " @ref{break-aligned-interface}.", + "The object that performs break alignment. See" + " @ref{break-aligned-interface}.", - /* properties */ - "positioning-done " - "break-align-orders " - ); + /* properties */ + "positioning-done " + "break-align-orders " + ); diff --git a/lily/break-substitution.cc b/lily/break-substitution.cc index 2cd29707d6..74314b39c0 100644 --- a/lily/break-substitution.cc +++ b/lily/break-substitution.cc @@ -43,39 +43,39 @@ substitute_grob (Grob *sc) Item *i = dynamic_cast<Item *> (sc); Direction d = to_dir (break_criterion); if (i && i->break_status_dir () != d) - { - Item *br = i->find_prebroken_piece (d); - return br; - } + { + Item *br = i->find_prebroken_piece (d); + return br; + } } else { System *line - = dynamic_cast<System *> (unsmob_grob (break_criterion)); + = dynamic_cast<System *> (unsmob_grob (break_criterion)); if (sc->get_system () != line) - sc = sc->find_broken_piece (line); + sc = sc->find_broken_piece (line); /* now: !sc || (sc && sc->get_system () == line) */ if (!sc) - return 0; + return 0; /* now: sc && sc->get_system () == line */ if (!line) - return sc; + return sc; /* - We don't return SCM_UNDEFINED for - suicided grobs, for two reasons + We don't return SCM_UNDEFINED for + suicided grobs, for two reasons - - it doesn't work (strange disappearing objects) + - it doesn't work (strange disappearing objects) - - it forces us to mark the parents of a grob, leading to - a huge recursion in the GC routine. + - it forces us to mark the parents of a grob, leading to + a huge recursion in the GC routine. */ if (sc->common_refpoint (line, X_AXIS) - && sc->common_refpoint (line, Y_AXIS)) - return sc; + && sc->common_refpoint (line, Y_AXIS)) + return sc; return 0; } @@ -99,7 +99,7 @@ substitute_grob (Grob *sc) SCM do_break_substitution (SCM src) { - again: +again: if (unsmob_grob (src)) { @@ -111,33 +111,33 @@ do_break_substitution (SCM src) int len = scm_c_vector_length (src); SCM nv = scm_c_make_vector (len, SCM_UNDEFINED); for (int i = 0; i < len; i++) - { - SCM si = scm_from_int (i); - scm_vector_set_x (nv, si, - do_break_substitution (scm_vector_ref (src, si))); - } + { + SCM si = scm_from_int (i); + scm_vector_set_x (nv, si, + do_break_substitution (scm_vector_ref (src, si))); + } } else if (scm_is_pair (src)) { /* - UGH! breaks on circular lists. + UGH! breaks on circular lists. */ SCM newcar = do_break_substitution (scm_car (src)); SCM oldcdr = scm_cdr (src); if (newcar == SCM_UNDEFINED - && (scm_is_pair (oldcdr) || oldcdr == SCM_EOL)) - { - /* - This is tail-recursion, ie. + && (scm_is_pair (oldcdr) || oldcdr == SCM_EOL)) + { + /* + This is tail-recursion, ie. - return do_break_substution (cdr); + return do_break_substution (cdr); - We don't want to rely on the compiler to do this. Without - tail-recursion, this easily crashes with a stack overflow. */ - src = oldcdr; - goto again; - } + We don't want to rely on the compiler to do this. Without + tail-recursion, this easily crashes with a stack overflow. */ + src = oldcdr; + goto again; + } return scm_cons (newcar, do_break_substitution (oldcdr)); } @@ -150,14 +150,14 @@ do_break_substitution (SCM src) /* Perform substitution on GROB_LIST using a constant amount of stack. */ -vector<Grob*> temporary_substition_array; +vector<Grob *> temporary_substition_array; void substitute_grob_array (Grob_array *grob_arr, Grob_array *new_arr) { - vector<Grob*> &old_grobs (grob_arr->array_reference ()); - vector<Grob*> *new_grobs (new_arr == grob_arr - ? & temporary_substition_array - : &new_arr->array_reference ()); + vector<Grob *> &old_grobs (grob_arr->array_reference ()); + vector<Grob *> *new_grobs (new_arr == grob_arr + ? & temporary_substition_array + : &new_arr->array_reference ()); new_grobs->resize (old_grobs.size ()); Grob **array = (Grob **) new_grobs->data (); @@ -167,7 +167,7 @@ substitute_grob_array (Grob_array *grob_arr, Grob_array *new_arr) Grob *orig = old_grobs[i]; Grob *new_grob = substitute_grob (orig); if (new_grob) - *ptr++ = new_grob; + *ptr++ = new_grob; } new_grobs->resize (ptr - array); @@ -235,8 +235,8 @@ spanner_system_range (Spanner *sp) else { if (sp->broken_intos_.size ()) - rv = Slice (sp->broken_intos_[0]->get_system ()->get_rank (), - sp->broken_intos_.back ()->get_system ()->get_rank ()); + rv = Slice (sp->broken_intos_[0]->get_system ()->get_rank (), + sp->broken_intos_.back ()->get_system ()->get_rank ()); } return rv; } @@ -253,7 +253,7 @@ item_system_range (Item *it) { Item *bi = it->find_prebroken_piece (d); if (bi && bi->get_system ()) - sr.add_point (bi->get_system ()->get_rank ()); + sr.add_point (bi->get_system ()->get_rank ()); } while (flip (&d) != LEFT); @@ -287,16 +287,16 @@ struct Substitution_entry */ if (sr.is_empty ()) { - /* - overflow if we don't treat this specially. - */ - left_ = 1; - right_ = -1; + /* + overflow if we don't treat this specially. + */ + left_ = 1; + right_ = -1; } else { - left_ = (short) sr[LEFT]; - right_ = (short) sr[RIGHT]; + left_ = (short) sr[LEFT]; + right_ = (short) sr[RIGHT]; } } Substitution_entry () @@ -310,20 +310,20 @@ struct Substitution_entry item_compare (void const *a, void const *b) { return ((Substitution_entry *)a)->left_ - - ((Substitution_entry *)b)->left_; + - ((Substitution_entry *)b)->left_; } static int spanner_compare (void const *a, void const *b) { return ((Substitution_entry *)a)->length () - - ((Substitution_entry *)b)->length (); + - ((Substitution_entry *)b)->length (); } }; bool Spanner::fast_substitute_grob_array (SCM sym, - Grob_array *grob_array) + Grob_array *grob_array) { int len = grob_array->size (); @@ -361,15 +361,15 @@ Spanner::fast_substitute_grob_array (SCM sym, int idx = 0; if (dynamic_cast<Spanner *> (g)) - idx = --spanner_index; + idx = --spanner_index; else if (dynamic_cast<Item *> (g)) - idx = item_index++; + idx = item_index++; vec[idx].set (g, sr); } qsort (vec, item_index, - sizeof (Substitution_entry), &Substitution_entry::item_compare); + sizeof (Substitution_entry), &Substitution_entry::item_compare); vector<Slice> item_indices; vector<Slice> spanner_indices; @@ -380,14 +380,15 @@ Spanner::fast_substitute_grob_array (SCM sym, } vector<Slice> *arrs[] - = { + = + { &item_indices, &spanner_indices }; - for (int i = 0; i < item_index;i++) + for (int i = 0; i < item_index; i++) { for (int j = vec[i].left_; j <= vec[i].right_; j++) - item_indices[j - system_range[LEFT]].add_point (i); + item_indices[j - system_range[LEFT]].add_point (i); } /* @@ -401,7 +402,7 @@ Spanner::fast_substitute_grob_array (SCM sym, assert (item_index <= spanner_index); assert ((broken_intos_.size () == (vsize)system_range.length () + 1) - || (broken_intos_.empty () && system_range.length () == 0)); + || (broken_intos_.empty () && system_range.length () == 0)); for (vsize i = 0; i < broken_intos_.size (); i++) { Grob *sc = broken_intos_[i]; @@ -410,28 +411,28 @@ Spanner::fast_substitute_grob_array (SCM sym, SCM newval = sc->internal_get_object (sym); if (!unsmob_grob_array (newval)) - { - newval = Grob_array::make_array (); - sc->set_object (sym, newval); - } + { + newval = Grob_array::make_array (); + sc->set_object (sym, newval); + } Grob_array *new_array = unsmob_grob_array (newval); - for (int k = 0; k < 2;k++) - for (int j = (*arrs[k])[i][LEFT]; j <= (*arrs[k])[i][RIGHT]; j++) - { - Grob *substituted = substitute_grob (vec[j].grob_); - if (substituted) - new_array->add (substituted); - } + for (int k = 0; k < 2; k++) + for (int j = (*arrs[k])[i][LEFT]; j <= (*arrs[k])[i][RIGHT]; j++) + { + Grob *substituted = substitute_grob (vec[j].grob_); + if (substituted) + new_array->add (substituted); + } #ifdef PARANOIA printf ("%d (%d), sp %d (%d)\n", - item_indices [i].length (), item_index, - spanner_indices[i].length (), len -spanner_index); + item_indices [i].length (), item_index, + spanner_indices[i].length (), len - spanner_index); { - SCM l1 = substitute_grob_list (grob_list); - assert (scm_ilength (l1) == scm_ilength (newval)); + SCM l1 = substitute_grob_list (grob_list); + assert (scm_ilength (l1) == scm_ilength (newval)); } #endif } @@ -463,37 +464,37 @@ substitute_object_alist (SCM alist, SCM dest) SCM val = scm_cdar (s); if (Grob_array *orig = unsmob_grob_array (val)) - { - SCM handle = scm_assq (sym, dest); - SCM newval - = (scm_is_pair (handle)) - ? scm_cdr (handle) - : Grob_array::make_array (); - - Grob_array *new_arr = unsmob_grob_array (newval); - - substitute_grob_array (orig, new_arr); - val = newval; - } + { + SCM handle = scm_assq (sym, dest); + SCM newval + = (scm_is_pair (handle)) + ? scm_cdr (handle) + : Grob_array::make_array (); + + Grob_array *new_arr = unsmob_grob_array (newval); + + substitute_grob_array (orig, new_arr); + val = newval; + } else - val = do_break_substitution (val); + val = do_break_substitution (val); if (val != SCM_UNDEFINED) - { - /* - for ly:grob? properties, SCM_UNDEFINED could leak out - through ly:grob-property - */ - *tail = scm_cons (scm_cons (sym, val), SCM_EOL); - tail = SCM_CDRLOC (*tail); - } + { + /* + for ly:grob? properties, SCM_UNDEFINED could leak out + through ly:grob-property + */ + *tail = scm_cons (scm_cons (sym, val), SCM_EOL); + tail = SCM_CDRLOC (*tail); + } } return l; } void Spanner::substitute_one_mutable_property (SCM sym, - SCM val) + SCM val) { Spanner *s = this; @@ -505,25 +506,25 @@ Spanner::substitute_one_mutable_property (SCM sym, if (!fast_done) for (vsize i = 0; i < s->broken_intos_.size (); i++) { - Grob *sc = s->broken_intos_[i]; - System *l = sc->get_system (); - set_break_subsititution (l ? l->self_scm () : SCM_UNDEFINED); - - if (grob_array) - { - SCM newval = sc->internal_get_object (sym); - if (!unsmob_grob_array (newval)) - { - newval = Grob_array::make_array (); - sc->set_object (sym, newval); - } - substitute_grob_array (grob_array, unsmob_grob_array (newval)); - } - else - { - SCM newval = do_break_substitution (val); - sc->set_object (sym, newval); - } + Grob *sc = s->broken_intos_[i]; + System *l = sc->get_system (); + set_break_subsititution (l ? l->self_scm () : SCM_UNDEFINED); + + if (grob_array) + { + SCM newval = sc->internal_get_object (sym); + if (!unsmob_grob_array (newval)) + { + newval = Grob_array::make_array (); + sc->set_object (sym, newval); + } + substitute_grob_array (grob_array, unsmob_grob_array (newval)); + } + else + { + SCM newval = do_break_substitution (val); + sc->set_object (sym, newval); + } } } diff --git a/lily/breathing-sign-engraver.cc b/lily/breathing-sign-engraver.cc index 4e583881c0..3a74b88d5b 100644 --- a/lily/breathing-sign-engraver.cc +++ b/lily/breathing-sign-engraver.cc @@ -75,15 +75,15 @@ Breathing_sign_engraver::stop_translation_timestep () } ADD_TRANSLATOR (Breathing_sign_engraver, - /* doc */ - "Create a breathing sign.", + /* doc */ + "Create a breathing sign.", - /* create */ - "BreathingSign ", + /* create */ + "BreathingSign ", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/breathing-sign.cc b/lily/breathing-sign.cc index a59bd65070..85da75c961 100644 --- a/lily/breathing-sign.cc +++ b/lily/breathing-sign.cc @@ -185,8 +185,8 @@ Breathing_sign::offset_callback (SCM smob) } ADD_INTERFACE (Breathing_sign, - "A breathing sign.", + "A breathing sign.", - /* properties */ - "direction " - ); + /* properties */ + "direction " + ); diff --git a/lily/change-iterator.cc b/lily/change-iterator.cc index 04647c111c..4a07d498b5 100644 --- a/lily/change-iterator.cc +++ b/lily/change-iterator.cc @@ -32,14 +32,14 @@ Change_iterator::error (string reason) string to_id = ly_scm2string (get_music ()->get_property ("change-to-id")); string warn1 = _f ("cannot change `%s' to `%s'", to_type, to_id) - + ": " + reason; + + ": " + reason; /* GUHG! */ - string warn2= "Change_iterator::process (): " - + get_outlet ()->context_name () + " = `" - + get_outlet ()->id_string () + "': "; + string warn2 = "Change_iterator::process (): " + + get_outlet ()->context_name () + " = `" + + get_outlet ()->id_string () + "': "; warning (warn2); get_music ()->origin ()->warning (warn1); } @@ -75,31 +75,31 @@ Change_iterator::process (Moment m) if (current) if (last) { - Context *dest = 0; - Context *where = get_outlet (); - while (!dest && where) - { - dest = find_context_below (where, to_type, to_id); - where = where->get_parent_context (); - } - - if (dest) - { - send_stream_event (last, "ChangeParent", get_music ()->origin (), - ly_symbol2scm ("context"), dest->self_scm ()); - } - else - /* FIXME: constant error message. */ - get_music ()->origin ()->warning (_ ("cannot find context to switch to")); + Context *dest = 0; + Context *where = get_outlet (); + while (!dest && where) + { + dest = find_context_below (where, to_type, to_id); + where = where->get_parent_context (); + } + + if (dest) + { + send_stream_event (last, "ChangeParent", get_music ()->origin (), + ly_symbol2scm ("context"), dest->self_scm ()); + } + else + /* FIXME: constant error message. */ + get_music ()->origin ()->warning (_ ("cannot find context to switch to")); } else { - /* We could change the current translator's id, but that would make - errors hard to catch. + /* We could change the current translator's id, but that would make + errors hard to catch. - last->translator_id_string () = get_change - ()->change_to_id_string (); */ - error (_f ("not changing to same context type: %s", ly_symbol2string (to_type).c_str ())); + last->translator_id_string () = get_change + ()->change_to_id_string (); */ + error (_f ("not changing to same context type: %s", ly_symbol2string (to_type).c_str ())); } else /* FIXME: uncomprehensable message */ diff --git a/lily/chord-name-engraver.cc b/lily/chord-name-engraver.cc index d0ced5a395..e2281400d0 100644 --- a/lily/chord-name-engraver.cc +++ b/lily/chord-name-engraver.cc @@ -44,8 +44,8 @@ protected: DECLARE_TRANSLATOR_LISTENER (rest); private: Item *chord_name_; - vector<Stream_event*> notes_; - + vector<Stream_event *> notes_; + SCM last_chord_; Stream_event *rest_event_; }; @@ -70,7 +70,7 @@ Chord_name_engraver::Chord_name_engraver () void Chord_name_engraver::process_music () -{ +{ SCM markup; SCM bass = SCM_EOL; SCM inversion = SCM_EOL; @@ -84,60 +84,60 @@ Chord_name_engraver::process_music () markup = no_chord_markup; } else - { + { if (!notes_.size ()) return; Stream_event *inversion_event = 0; for (vsize i = 0; i < notes_.size (); i++) - { - Stream_event *n = notes_[i]; - SCM p = n->get_property ("pitch"); - if (!unsmob_pitch (p)) - continue; - - if (n->get_property ("inversion") == SCM_BOOL_T) { - inversion_event = n; - inversion = p; + Stream_event *n = notes_[i]; + SCM p = n->get_property ("pitch"); + if (!unsmob_pitch (p)) + continue; + + if (n->get_property ("inversion") == SCM_BOOL_T) + { + inversion_event = n; + inversion = p; + } + else if (n->get_property ("bass") == SCM_BOOL_T) + bass = p; + else + pitches = scm_cons (p, pitches); } - else if (n->get_property ("bass") == SCM_BOOL_T) - bass = p; - else - pitches = scm_cons (p, pitches); - } if (inversion_event) - { - SCM oct = inversion_event->get_property ("octavation"); - if (scm_is_number (oct)) { - Pitch *p = unsmob_pitch (inversion_event->get_property ("pitch")); - int octavation = scm_to_int (oct); - Pitch orig = p->transposed (Pitch (-octavation, 0, 0)); - - pitches = scm_cons (orig.smobbed_copy (), pitches); + SCM oct = inversion_event->get_property ("octavation"); + if (scm_is_number (oct)) + { + Pitch *p = unsmob_pitch (inversion_event->get_property ("pitch")); + int octavation = scm_to_int (oct); + Pitch orig = p->transposed (Pitch (-octavation, 0, 0)); + + pitches = scm_cons (orig.smobbed_copy (), pitches); + } + else + programming_error ("inversion does not have original pitch"); } - else - programming_error ("inversion does not have original pitch"); - } pitches = scm_sort_list (pitches, Pitch::less_p_proc); SCM name_proc = get_property ("chordNameFunction"); markup = scm_call_4 (name_proc, pitches, bass, inversion, - context ()->self_scm ()); + context ()->self_scm ()); } /* Ugh. */ SCM chord_as_scm = scm_cons (pitches, scm_cons (bass, inversion)); - chord_name_ = make_item ("ChordName", - rest_event_ ? rest_event_->self_scm () : notes_[0]->self_scm ()); + chord_name_ = make_item ("ChordName", + rest_event_ ? rest_event_->self_scm () : notes_[0]->self_scm ()); chord_name_->set_property ("text", markup); - SCM chord_changes = get_property("chordChanges"); + SCM chord_changes = get_property ("chordChanges"); if (to_boolean (chord_changes) && scm_is_pair (last_chord_) && ly_is_equal (chord_as_scm, last_chord_)) chord_name_->set_property ("begin-of-line-visible", SCM_BOOL_T); @@ -156,9 +156,9 @@ IMPLEMENT_TRANSLATOR_LISTENER (Chord_name_engraver, rest); void Chord_name_engraver::listen_rest (Stream_event *ev) { - ASSIGN_EVENT_ONCE(rest_event_, ev); + ASSIGN_EVENT_ONCE (rest_event_, ev); } - + void Chord_name_engraver::stop_translation_timestep () { @@ -172,22 +172,22 @@ Chord_name_engraver::stop_translation_timestep () which properties are read depend on the chord naming function active. */ ADD_TRANSLATOR (Chord_name_engraver, - /* doc */ - "Catch note and rest events and generate the appropriate chordname.", - - /* create */ - "ChordName ", - - /* read */ - "chordChanges " - "chordNameExceptions " - "chordNameFunction " - "chordNoteNamer " - "chordRootNamer " - "chordNameExceptions " - "majorSevenSymbol " + /* doc */ + "Catch note and rest events and generate the appropriate chordname.", + + /* create */ + "ChordName ", + + /* read */ + "chordChanges " + "chordNameExceptions " + "chordNameFunction " + "chordNoteNamer " + "chordRootNamer " + "chordNameExceptions " + "majorSevenSymbol " "noChordSymbol ", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/chord-name.cc b/lily/chord-name.cc index ad0d91d3db..35428983c5 100644 --- a/lily/chord-name.cc +++ b/lily/chord-name.cc @@ -37,15 +37,15 @@ Chord_name::after_line_breaking (SCM smob) if (to_boolean (s)) { if (me->get_column ()->get_rank () - - me->get_system ()->spanned_rank_interval ()[LEFT] > 1) - me->suicide (); + - me->get_system ()->spanned_rank_interval ()[LEFT] > 1) + me->suicide (); } return SCM_UNSPECIFIED; } ADD_INTERFACE (Chord_name, - "A chord label (name or fretboard).", + "A chord label (name or fretboard).", - /* properties */ - "begin-of-line-visible " - ); + /* properties */ + "begin-of-line-visible " + ); diff --git a/lily/chord-tremolo-engraver.cc b/lily/chord-tremolo-engraver.cc index 1cd9147839..97e85087f1 100644 --- a/lily/chord-tremolo-engraver.cc +++ b/lily/chord-tremolo-engraver.cc @@ -2,7 +2,7 @@ This file is part of LilyPond, the GNU music typesetter. Copyright (C) 2000--2011 Han-Wen Nienhuys <hanwen@xs4all.nl> - Erik Sandberg <mandolaerik@gmail.com> + Erik Sandberg <mandolaerik@gmail.com> LilyPond is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -142,17 +142,16 @@ Chord_tremolo_engraver::acknowledge_stem (Grob_info info) if (Stem::duration_log (s) != 1) beam_->set_property ("gap-count", scm_from_int (gap_count)); - if (info.ultimate_event_cause ()->in_event_class ("rhythmic-event")) - Beam::add_stem (beam_, s); + Beam::add_stem (beam_, s); else - { - string s = _ ("stem must have Rhythmic structure"); - if (info.event_cause ()) - info.event_cause ()->origin ()->warning (s); - else - ::warning (s); - } + { + string s = _ ("stem must have Rhythmic structure"); + if (info.event_cause ()) + info.event_cause ()->origin ()->warning (s); + else + ::warning (s); + } // Store current grob, so we can possibly end the spanner here (and // reset the beam direction to RIGHT) previous_stem_ = s; @@ -161,15 +160,15 @@ Chord_tremolo_engraver::acknowledge_stem (Grob_info info) ADD_ACKNOWLEDGER (Chord_tremolo_engraver, stem); ADD_TRANSLATOR (Chord_tremolo_engraver, - /* doc */ - "Generate beams for tremolo repeats.", + /* doc */ + "Generate beams for tremolo repeats.", - /* create */ - "Beam ", + /* create */ + "Beam ", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/chord-tremolo-iterator.cc b/lily/chord-tremolo-iterator.cc index c4454544b6..1658e55782 100644 --- a/lily/chord-tremolo-iterator.cc +++ b/lily/chord-tremolo-iterator.cc @@ -2,7 +2,7 @@ This file is part of LilyPond, the GNU music typesetter. Copyright (C) 2000--2011 Han-Wen Nienhuys <hanwen@xs4all.nl> - Erik Sandberg <mandolaerik@gmail.com> + Erik Sandberg <mandolaerik@gmail.com> LilyPond is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/lily/clef-engraver.cc b/lily/clef-engraver.cc index 5ddfea627e..b41ce6d3d6 100644 --- a/lily/clef-engraver.cc +++ b/lily/clef-engraver.cc @@ -106,30 +106,30 @@ Clef_engraver::create_clef () SCM cpos = get_property ("clefPosition"); if (scm_is_number (cpos)) - clef_->set_property ("staff-position", cpos); + clef_->set_property ("staff-position", cpos); SCM oct = get_property ("clefOctavation"); if (scm_is_number (oct) && scm_to_int (oct)) - { - Item *g = make_item ("OctavateEight", SCM_EOL); - - int abs_oct = scm_to_int (oct); - int dir = sign (abs_oct); - abs_oct = abs (abs_oct) + 1; - - SCM txt = scm_number_to_string (scm_from_int (abs_oct), - scm_from_int (10)); - - g->set_property ("text", - scm_list_n (ly_lily_module_constant ("vcenter-markup"), - txt, SCM_UNDEFINED)); - Side_position_interface::add_support (g, clef_); - - g->set_parent (clef_, Y_AXIS); - g->set_parent (clef_, X_AXIS); - g->set_property ("direction", scm_from_int (dir)); - octavate_ = g; - } + { + Item *g = make_item ("OctavateEight", SCM_EOL); + + int abs_oct = scm_to_int (oct); + int dir = sign (abs_oct); + abs_oct = abs (abs_oct) + 1; + + SCM txt = scm_number_to_string (scm_from_int (abs_oct), + scm_from_int (10)); + + g->set_property ("text", + scm_list_n (ly_lily_module_constant ("vcenter-markup"), + txt, SCM_UNDEFINED)); + Side_position_interface::add_support (g, clef_); + + g->set_parent (clef_, Y_AXIS); + g->set_parent (clef_, X_AXIS); + g->set_property ("direction", scm_from_int (dir)); + octavate_ = g; + } } } void @@ -140,12 +140,11 @@ Clef_engraver::process_music () static void apply_on_children (Context *context, SCM fun) { - scm_call_1(fun, context->self_scm()); + scm_call_1 (fun, context->self_scm ()); for (SCM s = context->children_contexts (); - scm_is_pair(s); s = scm_cdr (s)) - apply_on_children(unsmob_context (scm_car(s)), fun); + scm_is_pair (s); s = scm_cdr (s)) + apply_on_children (unsmob_context (scm_car (s)), fun); } - void Clef_engraver::inspect_clef_properties () @@ -161,15 +160,15 @@ Clef_engraver::inspect_clef_properties () || scm_equal_p (octavation, prev_octavation_) == SCM_BOOL_F || to_boolean (force_clef)) { - apply_on_children(context (), - ly_lily_module_constant ("invalidate-alterations")); - + apply_on_children (context (), + ly_lily_module_constant ("invalidate-alterations")); + set_glyph (); if (prev_cpos_ != SCM_BOOL_F || to_boolean (get_property ("firstClef"))) - create_clef (); + create_clef (); if (clef_) - clef_->set_property ("non-default", SCM_BOOL_T); + clef_->set_property ("non-default", SCM_BOOL_T); prev_cpos_ = clefpos; prev_glyph_ = glyph; @@ -191,10 +190,10 @@ Clef_engraver::stop_translation_timestep () { SCM vis = 0; if (to_boolean (clef_->get_property ("non-default"))) - vis = get_property ("explicitClefVisibility"); + vis = get_property ("explicitClefVisibility"); if (vis) - clef_->set_property ("break-visibility", vis); + clef_->set_property ("break-visibility", vis); clef_ = 0; @@ -204,20 +203,20 @@ Clef_engraver::stop_translation_timestep () ADD_ACKNOWLEDGER (Clef_engraver, bar_line); ADD_TRANSLATOR (Clef_engraver, - /* doc */ - "Determine and set reference point for pitches.", - - /* create */ - "Clef " - "OctavateEight ", - - /* read */ - "clefGlyph " - "clefOctavation " - "clefPosition " - "explicitClefVisibility " - "forceClef ", - - /* write */ - "" - ); + /* doc */ + "Determine and set reference point for pitches.", + + /* create */ + "Clef " + "OctavateEight ", + + /* read */ + "clefGlyph " + "clefOctavation " + "clefPosition " + "explicitClefVisibility " + "forceClef ", + + /* write */ + "" + ); diff --git a/lily/clef.cc b/lily/clef.cc index c6ad530e41..ff993f9bb0 100644 --- a/lily/clef.cc +++ b/lily/clef.cc @@ -36,11 +36,11 @@ Clef::calc_glyph_name (SCM smob) string str = ly_scm2string (glyph); if (to_boolean (s->get_property ("non-default")) - && s->break_status_dir () != RIGHT - && !to_boolean (s->get_property ("full-size-change"))) - { - str += "_change"; - } + && s->break_status_dir () != RIGHT + && !to_boolean (s->get_property ("full-size-change"))) + { + str += "_change"; + } return ly_string2scm (str); } @@ -67,12 +67,12 @@ Clef::print (SCM smob) } ADD_INTERFACE (Clef, - "A clef sign.", - - /* properties */ - "full-size-change " - "glyph " - "glyph-name " - "non-default " - ); + "A clef sign.", + + /* properties */ + "full-size-change " + "glyph " + "glyph-name " + "non-default " + ); diff --git a/lily/cluster-engraver.cc b/lily/cluster-engraver.cc index 7ef6b63477..bbf71cc175 100644 --- a/lily/cluster-engraver.cc +++ b/lily/cluster-engraver.cc @@ -40,7 +40,7 @@ protected: virtual void process_music (); virtual void finalize (); private: - vector<Stream_event*> cluster_notes_; + vector<Stream_event *> cluster_notes_; Item *beacon_; void typeset_grobs (); @@ -70,12 +70,12 @@ Cluster_spanner_engraver::typeset_grobs () if (finished_spanner_) { if (!finished_spanner_->get_bound (RIGHT)) - { - finished_spanner_->set_bound (RIGHT, - finished_spanner_->get_bound (LEFT)); - - } - + { + finished_spanner_->set_bound (RIGHT, + finished_spanner_->get_bound (LEFT)); + + } + finished_spanner_ = 0; } beacon_ = 0; @@ -100,19 +100,19 @@ Cluster_spanner_engraver::process_music () int pmin = INT_MAX; for (vsize i = 0; i < cluster_notes_.size (); i++) - { - Pitch *pit = unsmob_pitch (cluster_notes_[i]->get_property ("pitch")); + { + Pitch *pit = unsmob_pitch (cluster_notes_[i]->get_property ("pitch")); - int p = (pit ? pit->steps () : 0) + c0; + int p = (pit ? pit->steps () : 0) + c0; - pmax = max (pmax, p); - pmin = min (pmin, p); - } + pmax = max (pmax, p); + pmin = min (pmin, p); + } beacon_ = make_item ("ClusterSpannerBeacon", cluster_notes_[0]->self_scm ()); beacon_->set_property ("positions", - scm_cons (scm_from_int (pmin), - scm_from_int (pmax))); + scm_cons (scm_from_int (pmin), + scm_from_int (pmax))); } if (beacon_ && !spanner_) @@ -144,17 +144,17 @@ Cluster_spanner_engraver::acknowledge_note_column (Grob_info info) ADD_ACKNOWLEDGER (Cluster_spanner_engraver, note_column); ADD_TRANSLATOR (Cluster_spanner_engraver, - /* doc */ - "Engrave a cluster using @code{Spanner} notation.", + /* doc */ + "Engrave a cluster using @code{Spanner} notation.", - /* create */ - "ClusterSpanner " - "ClusterSpannerBeacon ", + /* create */ + "ClusterSpanner " + "ClusterSpannerBeacon ", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/cluster.cc b/lily/cluster.cc index 9922839099..a9c9c5654b 100644 --- a/lily/cluster.cc +++ b/lily/cluster.cc @@ -62,57 +62,57 @@ brew_cluster_piece (Grob *me, vector<Offset> bottom_points, vector<Offset> top_p if (shape == "leftsided-stairs") { for (int i = 0; i < size - 1; i++) - { - Box box; - box.add_point (bottom_points[i] - hvpadding); - box.add_point (Offset (top_points[i + 1][X_AXIS], - top_points[i][Y_AXIS]) + hvpadding); - out.add_stencil (Lookup::round_filled_box (box, blotdiameter)); - } + { + Box box; + box.add_point (bottom_points[i] - hvpadding); + box.add_point (Offset (top_points[i + 1][X_AXIS], + top_points[i][Y_AXIS]) + hvpadding); + out.add_stencil (Lookup::round_filled_box (box, blotdiameter)); + } } else if (shape == "rightsided-stairs") { for (int i = 0; i < size - 1; i++) - { - Box box; - box.add_point (Offset (bottom_points[i][X_AXIS], - bottom_points[i + 1][Y_AXIS]) - hvpadding); - box.add_point (top_points[i + 1] + hvpadding); - out.add_stencil (Lookup::round_filled_box (box, blotdiameter)); - } + { + Box box; + box.add_point (Offset (bottom_points[i][X_AXIS], + bottom_points[i + 1][Y_AXIS]) - hvpadding); + box.add_point (top_points[i + 1] + hvpadding); + out.add_stencil (Lookup::round_filled_box (box, blotdiameter)); + } } else if (shape == "centered-stairs") { Real left_xmid = bottom_points[0][X_AXIS]; for (int i = 0; i < size - 1; i++) - { - Real right_xmid - = 0.5 * (bottom_points[i][X_AXIS] + bottom_points[i + 1][X_AXIS]); - Box box; - box.add_point (Offset (left_xmid, bottom_points[i][Y_AXIS]) - - hvpadding); - box.add_point (Offset (right_xmid, top_points[i][Y_AXIS]) - + hvpadding); - out.add_stencil (Lookup::round_filled_box (box, blotdiameter)); - left_xmid = right_xmid; - } + { + Real right_xmid + = 0.5 * (bottom_points[i][X_AXIS] + bottom_points[i + 1][X_AXIS]); + Box box; + box.add_point (Offset (left_xmid, bottom_points[i][Y_AXIS]) + - hvpadding); + box.add_point (Offset (right_xmid, top_points[i][Y_AXIS]) + + hvpadding); + out.add_stencil (Lookup::round_filled_box (box, blotdiameter)); + left_xmid = right_xmid; + } Real right_xmid = bottom_points[size - 1][X_AXIS]; Box box; box.add_point (Offset (left_xmid, bottom_points[size - 1][Y_AXIS]) - - hvpadding); + - hvpadding); box.add_point (Offset (right_xmid, top_points[size - 1][Y_AXIS]) - + hvpadding); + + hvpadding); out.add_stencil (Lookup::round_filled_box (box, blotdiameter)); } else if (shape == "ramp") { points.push_back (bottom_points[0] - vpadding + hpadding); for (int i = 1; i < size - 1; i++) - points.push_back (bottom_points[i] - vpadding); + points.push_back (bottom_points[i] - vpadding); points.push_back (bottom_points[size - 1] - vpadding - hpadding); points.push_back (top_points[size - 1] + vpadding - hpadding); for (int i = size - 2; i > 0; i--) - points.push_back (top_points[i] + vpadding); + points.push_back (top_points[i] + vpadding); points.push_back (top_points[0] + vpadding + hpadding); out.add_stencil (Lookup::round_filled_polygon (points, blotdiameter)); } @@ -151,7 +151,7 @@ Cluster::print (SCM smob) Grob *commonx = left_bound->common_refpoint (right_bound, X_AXIS); - vector<Grob*> const &cols = extract_grob_array (me, "columns"); + vector<Grob *> const &cols = extract_grob_array (me, "columns"); if (cols.empty ()) { me->warning (_ ("junking empty cluster")); @@ -190,16 +190,16 @@ Cluster::print (SCM smob) { extract_grob_set (next, "columns", next_cols); if (next_cols.size () > 0) - { - Grob *next_commony = common_refpoint_of_array (next_cols, next, Y_AXIS); - Grob *col = next_cols[0]; + { + Grob *next_commony = common_refpoint_of_array (next_cols, next, Y_AXIS); + Grob *col = next_cols[0]; - Interval v = col->extent (next_commony, Y_AXIS); - Real x = right_bound->relative_coordinate (commonx, X_AXIS) - left_coord; + Interval v = col->extent (next_commony, Y_AXIS); + Real x = right_bound->relative_coordinate (commonx, X_AXIS) - left_coord; - bottom_points.push_back (Offset (x, v[DOWN])); - top_points.push_back (Offset (x, v[UP])); - } + bottom_points.push_back (Offset (x, v[DOWN])); + top_points.push_back (Offset (x, v[UP])); + } } Stencil out = brew_cluster_piece (me, bottom_points, top_points); @@ -208,21 +208,21 @@ Cluster::print (SCM smob) } ADD_INTERFACE (Cluster, - "A graphically drawn musical cluster.\n" - "\n" - "@code{padding} adds to the vertical extent of the shape (top" - " and bottom).\n" - "\n" - "The property @code{style} controls the shape of cluster" - " segments. Valid values include @code{leftsided-stairs}," - " @code{rightsided-stairs}, @code{centered-stairs}, and" - " @code{ramp}.\n", - - /* properties */ - "style " - "padding " - "columns " - ); + "A graphically drawn musical cluster.\n" + "\n" + "@code{padding} adds to the vertical extent of the shape (top" + " and bottom).\n" + "\n" + "The property @code{style} controls the shape of cluster" + " segments. Valid values include @code{leftsided-stairs}," + " @code{rightsided-stairs}, @code{centered-stairs}, and" + " @code{ramp}.\n", + + /* properties */ + "style " + "padding " + "columns " + ); struct Cluster_beacon { @@ -237,15 +237,15 @@ Cluster_beacon::height (SCM g) { Grob *me = unsmob_grob (g); Interval v = robust_scm2interval (me->get_property ("positions"), - Interval (0, 0)); + Interval (0, 0)); return ly_interval2scm (Staff_symbol_referencer::staff_space (me) * 0.5 * v); } ADD_INTERFACE (Cluster_beacon, - "A place holder for the cluster spanner to determine the" - " vertical extents of a cluster spanner at this" - " X@tie{}position.", + "A place holder for the cluster spanner to determine the" + " vertical extents of a cluster spanner at this" + " X@tie{}position.", - /* properties */ - "positions " - ); + /* properties */ + "positions " + ); diff --git a/lily/coherent-ligature-engraver.cc b/lily/coherent-ligature-engraver.cc index eb8fcaabb1..3250304c2d 100644 --- a/lily/coherent-ligature-engraver.cc +++ b/lily/coherent-ligature-engraver.cc @@ -83,7 +83,6 @@ * example, Ligature_bracket_engraver does not share any of this code. */ - /* * TODO: move this function to class Item? */ @@ -98,21 +97,21 @@ Coherent_ligature_engraver::move_related_items_to_column { Item *sibling = elements[i]; if (!sibling) - // should not occur, but who knows... -jr - continue; + // should not occur, but who knows... -jr + continue; if (Staff_symbol_referencer::get_staff_symbol (sibling) != staff_symbol) - // sibling is from a staff different than that of the item of - // interest - continue; + // sibling is from a staff different than that of the item of + // interest + continue; #if 0 /* experimental code to collapse spacing after ligature */ Grob *sibling_parent = sibling->get_parent (X_AXIS); sibling_parent->warning (_f ("Coherent_ligature_engraver: " - "setting `spacing-increment=" - "0.01': ptr=%ul", parent)); + "setting `spacing-increment=" + "0.01': ptr=%ul", parent)); sibling_parent->set_property ("forced-spacing", - scm_from_double (0.01)); + scm_from_double (0.01)); #endif sibling->set_parent (target_column, X_AXIS); @@ -148,13 +147,13 @@ compute_delta_pitches (vector<Grob_info> primitives) primitive = dynamic_cast<Item *> (primitives[i].grob ()); Stream_event *cause = primitives[i].event_cause (); int pitch - = unsmob_pitch (cause->get_property ("pitch"))->steps (); + = unsmob_pitch (cause->get_property ("pitch"))->steps (); if (prev_primitive) - { - delta_pitch = pitch - prev_pitch; - prev_primitive->set_property ("delta-position", - scm_from_int (delta_pitch)); - } + { + delta_pitch = pitch - prev_pitch; + prev_primitive->set_property ("delta-position", + scm_from_int (delta_pitch)); + } prev_pitch = pitch; prev_primitive = primitive; } @@ -163,7 +162,7 @@ compute_delta_pitches (vector<Grob_info> primitives) void Coherent_ligature_engraver::typeset_ligature (Spanner *ligature, - vector<Grob_info> primitives) + vector<Grob_info> primitives) { // compute some commonly needed context info stored as grob // properties diff --git a/lily/collision-engraver.cc b/lily/collision-engraver.cc index a92a2a7171..816451aa3e 100644 --- a/lily/collision-engraver.cc +++ b/lily/collision-engraver.cc @@ -26,7 +26,7 @@ class Collision_engraver : public Engraver { Item *col_; - vector<Grob*> note_columns_; + vector<Grob *> note_columns_; protected: DECLARE_ACKNOWLEDGER (note_column); @@ -55,11 +55,11 @@ Collision_engraver::acknowledge_note_column (Grob_info i) { /*should check Y axis? */ if (Note_column::has_rests (i.grob ()) || i.grob ()->get_parent (X_AXIS)) - return; + return; if (to_boolean (i.grob ()->get_property ("ignore-collision"))) - return; - + return; + note_columns_.push_back (i.grob ()); } } @@ -81,16 +81,16 @@ Collision_engraver::Collision_engraver () ADD_ACKNOWLEDGER (Collision_engraver, note_column); ADD_TRANSLATOR (Collision_engraver, - /* doc */ - "Collect @code{NoteColumns}, and as soon as there are two or" - " more, put them in a @code{NoteCollision} object.", + /* doc */ + "Collect @code{NoteColumns}, and as soon as there are two or" + " more, put them in a @code{NoteCollision} object.", - /* create */ - "NoteCollision ", + /* create */ + "NoteCollision ", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/completion-note-heads-engraver.cc b/lily/completion-note-heads-engraver.cc index a2c606f472..ab25e271c0 100644 --- a/lily/completion-note-heads-engraver.cc +++ b/lily/completion-note-heads-engraver.cc @@ -153,13 +153,13 @@ Completion_heads_engraver::process_music () if (left_to_do_) { /* - note that note_dur may be strictly less than left_to_do_ - (say, if left_to_do_ == 5/8) + note that note_dur may be strictly less than left_to_do_ + (say, if left_to_do_ == 5/8) */ if (factor_.denominator () == 1 && factor_ > Rational (1, 1)) - note_dur = Duration (left_to_do_, false); + note_dur = Duration (left_to_do_, false); else - note_dur = Duration (left_to_do_ / factor_, false).compressed (factor_); + note_dur = Duration (left_to_do_ / factor_, false).compressed (factor_); } else { @@ -172,9 +172,9 @@ Completion_heads_engraver::process_music () if (nb.main_part_ && nb < note_dur.get_length ()) { if (factor_.denominator () == 1 && factor_ > Rational (1, 1)) - note_dur = Duration (nb.main_part_, false); + note_dur = Duration (nb.main_part_, false); else - note_dur = Duration (nb.main_part_ / factor_, false).compressed (factor_); + note_dur = Duration (nb.main_part_ / factor_, false).compressed (factor_); } do_nothing_until_ = now.main_part_ + note_dur.get_length (); @@ -185,7 +185,7 @@ Completion_heads_engraver::process_music () Stream_event *event = note_events_[i]; if (need_clone) - event = event->clone (); + event = event->clone (); SCM pits = note_events_[i]->get_property ("pitch"); event->set_property ("pitch", pits); @@ -194,24 +194,24 @@ Completion_heads_engraver::process_music () event->set_property ("duration-log", scm_from_int (note_dur.duration_log ())); /* - The Completion_heads_engraver splits an event into a group of consecutive events. - For each event in the group, the property "autosplit-end" denotes whether the current event - was truncated during splitting. Based on "autosplit-end", the Tie_engraver decides whether a - tie event should be processed. + The Completion_heads_engraver splits an event into a group of consecutive events. + For each event in the group, the property "autosplit-end" denotes whether the current event + was truncated during splitting. Based on "autosplit-end", the Tie_engraver decides whether a + tie event should be processed. */ event->set_property ("autosplit-end", - ly_bool2scm (left_to_do_ - note_dur.get_length () > Rational (0))); + ly_bool2scm (left_to_do_ - note_dur.get_length () > Rational (0))); Item *note = make_note_head (event); if (need_clone) - event->unprotect (); + event->unprotect (); notes_.push_back (note); } if (prev_notes_.size () == notes_.size ()) { for (vsize i = 0; i < notes_.size (); i++) - make_tie (prev_notes_[i], notes_[i]); + make_tie (prev_notes_[i], notes_[i]); } if (ties_.size () && !tie_column_) @@ -264,7 +264,7 @@ Completion_heads_engraver::start_translation_timestep () prev_notes_.clear (); } context ()->set_property ("completionBusy", - ly_bool2scm (note_events_.size ())); + ly_bool2scm (note_events_.size ())); } Completion_heads_engraver::Completion_heads_engraver () @@ -273,22 +273,22 @@ Completion_heads_engraver::Completion_heads_engraver () } ADD_TRANSLATOR (Completion_heads_engraver, - /* doc */ - "This engraver replaces @code{Note_heads_engraver}. It plays" - " some trickery to break long notes and automatically tie them" - " into the next measure.", - - /* create */ - "NoteHead " - "Tie " - "TieColumn ", - - /* read */ - "measureLength " - "measurePosition " - "middleCPosition " - "timing ", - - /* write */ - "completionBusy " - ); + /* doc */ + "This engraver replaces @code{Note_heads_engraver}. It plays" + " some trickery to break long notes and automatically tie them" + " into the next measure.", + + /* create */ + "NoteHead " + "Tie " + "TieColumn ", + + /* read */ + "measureLength " + "measurePosition " + "middleCPosition " + "timing ", + + /* write */ + "completionBusy " + ); diff --git a/lily/completion-rest-engraver.cc b/lily/completion-rest-engraver.cc index 3d8d7211ff..b6e2d5fc4a 100644 --- a/lily/completion-rest-engraver.cc +++ b/lily/completion-rest-engraver.cc @@ -56,9 +56,9 @@ using namespace std; class Completion_rest_engraver : public Engraver { - vector<Item*> rests_; - vector<Item*> prev_rests_; - vector<Stream_event*> rest_events_; + vector<Item *> rests_; + vector<Item *> prev_rests_; + vector<Stream_event *> rest_events_; Moment rest_end_mom_; bool is_first_; Rational left_to_do_; @@ -66,7 +66,7 @@ class Completion_rest_engraver : public Engraver Rational factor_; Moment next_barline_moment (); - Item *make_rest (Stream_event*); + Item *make_rest (Stream_event *); public: TRANSLATOR_DECLARATIONS (Completion_rest_engraver); @@ -90,7 +90,7 @@ void Completion_rest_engraver::listen_rest (Stream_event *ev) { rest_events_.push_back (ev); - + is_first_ = true; Moment now = now_mom (); Moment musiclen = get_event_length (ev, now); @@ -115,7 +115,7 @@ Completion_rest_engraver::next_barline_moment () return (*l - *e); } -Item* +Item * Completion_rest_engraver::make_rest (Stream_event *ev) { Item *rest = make_item ("Rest", ev->self_scm ()); @@ -124,7 +124,7 @@ Completion_rest_engraver::make_rest (Stream_event *ev) int pos = p->steps (); SCM c0 = get_property ("middleCPosition"); if (scm_is_number (c0)) - pos += scm_to_int (c0); + pos += scm_to_int (c0); rest->set_property ("staff-position", scm_from_int (pos)); } @@ -149,13 +149,13 @@ Completion_rest_engraver::process_music () if (left_to_do_) { /* - rest that rest_dur may be strictly less than left_to_do_ - (say, if left_to_do_ == 5/8) + rest that rest_dur may be strictly less than left_to_do_ + (say, if left_to_do_ == 5/8) */ if (factor_.denominator () == 1 && factor_ > Rational (1, 1)) - rest_dur = Duration (left_to_do_, false); + rest_dur = Duration (left_to_do_, false); else - rest_dur = Duration (left_to_do_ / factor_, false).compressed (factor_); + rest_dur = Duration (left_to_do_ / factor_, false).compressed (factor_); appearance = Duration (left_to_do_, false); } else @@ -169,9 +169,9 @@ Completion_rest_engraver::process_music () if (nb.main_part_ && nb < rest_dur.get_length ()) { if (factor_.denominator () == 1 && factor_ > Rational (1, 1)) - rest_dur = Duration (nb.main_part_, false); + rest_dur = Duration (nb.main_part_, false); else - rest_dur = Duration (nb.main_part_ / factor_, false).compressed (factor_); + rest_dur = Duration (nb.main_part_ / factor_, false).compressed (factor_); } do_nothing_until_ = now.main_part_ + rest_dur.get_length (); @@ -182,7 +182,7 @@ Completion_rest_engraver::process_music () Stream_event *event = rest_events_[i]; if (need_clone) - event = event->clone (); + event = event->clone (); SCM pits = rest_events_[i]->get_property ("pitch"); event->set_property ("pitch", pits); @@ -192,13 +192,13 @@ Completion_rest_engraver::process_music () Item *rest = make_rest (event); if (need_clone) - event->unprotect (); + event->unprotect (); rests_.push_back (rest); } - + left_to_do_ -= rest_dur.get_length (); if (left_to_do_) - get_global_context ()->add_moment_to_process (now.main_part_ + rest_dur.get_length()); + get_global_context ()->add_moment_to_process (now.main_part_ + rest_dur.get_length ()); /* don't do complicated arithmetic with grace rests. */ @@ -224,7 +224,7 @@ Completion_rest_engraver::start_translation_timestep () prev_rests_.clear (); } context ()->set_property ("restCompletionBusy", - ly_bool2scm (rest_events_.size ())); + ly_bool2scm (rest_events_.size ())); } Completion_rest_engraver::Completion_rest_engraver () @@ -232,18 +232,18 @@ Completion_rest_engraver::Completion_rest_engraver () } ADD_TRANSLATOR (Completion_rest_engraver, - /* doc */ - "This engraver replaces @code{Rest_engraver}. It plays" - " some trickery to break long rests into the next measure." - , - /* create */ - "Rest " - , - /* read */ - "middleCPosition " - "measurePosition " - "measureLength " - , - /* write */ - "restCompletionBusy " - ); + /* doc */ + "This engraver replaces @code{Rest_engraver}. It plays" + " some trickery to break long rests into the next measure.", + + /* create */ + "Rest ", + + /* read */ + "middleCPosition " + "measurePosition " + "measureLength ", + + /* write */ + "restCompletionBusy " + ); diff --git a/lily/constrained-breaking.cc b/lily/constrained-breaking.cc index 233011587f..bff8e79df9 100644 --- a/lily/constrained-breaking.cc +++ b/lily/constrained-breaking.cc @@ -87,22 +87,22 @@ Constrained_breaking::calc_subproblem (vsize start, vsize sys, vsize brk) vsize start_col = starting_breakpoints_[start]; Matrix<Constrained_break_node> &st = state_[start]; vsize max_index = brk - start_col; - for (vsize j=max_index; j-- > sys;) + for (vsize j = max_index; j-- > sys;) { if (0 == sys && j > 0) continue; /* the first line cannot have its first break after the beginning */ Line_details const &cur = lines_.at (brk, j + start_col); if (isinf (cur.force_)) - break; + break; Real prev_f = 0; Real prev_dem = 0; if (sys > 0) { - prev_f = st.at (j, sys-1).details_.force_; - prev_dem = st.at (j, sys-1).demerits_; + prev_f = st.at (j, sys - 1).details_.force_; + prev_dem = st.at (j, sys - 1).demerits_; } if (isinf (prev_dem)) continue; @@ -120,15 +120,14 @@ Constrained_breaking::calc_subproblem (vsize start, vsize sys, vsize brk) return found_something; } - Column_x_positions Constrained_breaking::space_line (vsize i, vsize j) { bool ragged_right = to_boolean (pscore_->layout ()->c_variable ("ragged-right")); bool ragged_last = to_boolean (pscore_->layout ()->c_variable ("ragged-last")); - vector<Grob*> line (all_.begin () + breaks_[i], - all_.begin () + breaks_[j] + 1); + vector<Grob *> line (all_.begin () + breaks_[i], + all_.begin () + breaks_[j] + 1); Interval line_dims = line_dimensions_int (pscore_->layout (), i); bool last = j == breaks_.size () - 1; bool ragged = ragged_right || (last && ragged_last); @@ -175,7 +174,7 @@ Constrained_breaking::solve (vsize start, vsize end, vsize sys_count) vector<Column_x_positions> ret; /* find the first solution that satisfies constraints */ - for (vsize sys = sys_count-1; sys != VPOS; sys--) + for (vsize sys = sys_count - 1; sys != VPOS; sys--) { for (vsize brk = end_brk; brk != VPOS; brk--) { @@ -183,8 +182,8 @@ Constrained_breaking::solve (vsize start, vsize end, vsize sys_count) { if (brk != end_brk) { - brk = st.at (brk, sys).prev_; - sys--; + brk = st.at (brk, sys).prev_; + sys--; warning (_ ("cannot find line breaking that satisfies constraints")); ret.push_back (space_line (brk, end_brk)); } @@ -192,7 +191,7 @@ Constrained_breaking::solve (vsize start, vsize end, vsize sys_count) /* build up the good part of the solution */ for (vsize cur_sys = sys; cur_sys != VPOS; cur_sys--) { - vsize prev_brk = st.at (brk, cur_sys).prev_; + vsize prev_brk = st.at (brk, cur_sys).prev_; assert (brk != VPOS); ret.push_back (space_line (prev_brk + start_brk, brk + start_brk)); brk = prev_brk; @@ -219,27 +218,27 @@ Constrained_breaking::best_solution (vsize start, vsize end) for (vsize i = min_systems; i <= max_systems; i++) { vsize brk = prepare_solution (start, end, i); - Real dem = state_[start].at (brk, i-1).demerits_; + Real dem = state_[start].at (brk, i - 1).demerits_; if (dem < best_demerits) - { - best_demerits = dem; - best_so_far = solve (start, end, i); - } + { + best_demerits = dem; + best_so_far = solve (start, end, i); + } else - { - vector<Column_x_positions> cur = solve (start, end, i); - bool too_many_lines = true; - - for (vsize j = 0; j < cur.size (); j++) - if (cur[j].force_ < 0) - { - too_many_lines = false; - break; - } - if (too_many_lines) - return best_so_far; - } + { + vector<Column_x_positions> cur = solve (start, end, i); + bool too_many_lines = true; + + for (vsize j = 0; j < cur.size (); j++) + if (cur[j].force_ < 0) + { + too_many_lines = false; + break; + } + if (too_many_lines) + return best_so_far; + } } if (best_so_far.size ()) return best_so_far; @@ -255,32 +254,32 @@ Constrained_breaking::line_details (vsize start, vsize end, vsize sys_count) /* This loop structure is C&Ped from solve(). */ /* find the first solution that satisfies constraints */ - for (vsize sys = sys_count-1; sys != VPOS; sys--) + for (vsize sys = sys_count - 1; sys != VPOS; sys--) { for (vsize brk = end_brk; brk != VPOS; brk--) { if (!isinf (st.at (brk, sys).details_.force_)) { if (brk != end_brk) - { - /* - During initialize(), we only fill out a - Line_details for lines that are valid (ie. not too - long), otherwise line breaking becomes O(n^3). - In case sys_count is such that no valid solution - is found, we need to fill in the Line_details. - */ - Line_details details; - brk = st.at (brk, sys).prev_; - sys--; - fill_line_details (&details, brk, end_brk); - ret.push_back (details); - } + { + /* + During initialize(), we only fill out a + Line_details for lines that are valid (ie. not too + long), otherwise line breaking becomes O(n^3). + In case sys_count is such that no valid solution + is found, we need to fill in the Line_details. + */ + Line_details details; + brk = st.at (brk, sys).prev_; + sys--; + fill_line_details (&details, brk, end_brk); + ret.push_back (details); + } /* build up the good part of the solution */ for (vsize cur_sys = sys; cur_sys != VPOS; cur_sys--) { - vsize prev_brk = st.at (brk, cur_sys).prev_; + vsize prev_brk = st.at (brk, cur_sys).prev_; assert (brk != VPOS); ret.push_back (st.at (brk, cur_sys).details_); brk = prev_brk; @@ -365,7 +364,7 @@ min_permission (SCM perm1, SCM perm2) if (perm1 == ly_symbol2scm ("force")) return perm2; if (perm1 == ly_symbol2scm ("allow") - && perm2 != ly_symbol2scm ("force")) + && perm2 != ly_symbol2scm ("force")) return perm2; return SCM_EOL; } @@ -396,40 +395,40 @@ Constrained_breaking::initialize () SCM page_breaking_spacing_spec = l->c_variable ("page-breaking-system-system-spacing"); Page_layout_problem::read_spacing_spec (spacing_spec, - &system_system_space_, - ly_symbol2scm ("basic-distance")); + &system_system_space_, + ly_symbol2scm ("basic-distance")); Page_layout_problem::read_spacing_spec (page_breaking_spacing_spec, - &system_system_space_, - ly_symbol2scm ("basic-distance")); + &system_system_space_, + ly_symbol2scm ("basic-distance")); Page_layout_problem::read_spacing_spec (title_spec, - &system_markup_space_, - ly_symbol2scm ("basic-distance")); + &system_markup_space_, + ly_symbol2scm ("basic-distance")); Page_layout_problem::read_spacing_spec (spacing_spec, - &system_system_padding_, - ly_symbol2scm ("padding")); + &system_system_padding_, + ly_symbol2scm ("padding")); Page_layout_problem::read_spacing_spec (between_scores_spec, - &score_system_padding_, - ly_symbol2scm ("padding")); + &score_system_padding_, + ly_symbol2scm ("padding")); Page_layout_problem::read_spacing_spec (page_breaking_spacing_spec, - &system_system_padding_, - ly_symbol2scm ("padding")); + &system_system_padding_, + ly_symbol2scm ("padding")); Page_layout_problem::read_spacing_spec (title_spec, - &score_markup_padding_, - ly_symbol2scm ("padding")); + &score_markup_padding_, + ly_symbol2scm ("padding")); Page_layout_problem::read_spacing_spec (between_scores_spec, - &score_system_min_distance_, - ly_symbol2scm ("minimum-distance")); + &score_system_min_distance_, + ly_symbol2scm ("minimum-distance")); Page_layout_problem::read_spacing_spec (spacing_spec, - &system_system_min_distance_, - ly_symbol2scm ("minimum-distance")); + &system_system_min_distance_, + ly_symbol2scm ("minimum-distance")); Page_layout_problem::read_spacing_spec (page_breaking_spacing_spec, - &system_system_min_distance_, - ly_symbol2scm ("minimum-distance")); + &system_system_min_distance_, + ly_symbol2scm ("minimum-distance")); Page_layout_problem::read_spacing_spec (title_spec, - &score_markup_min_distance_, - ly_symbol2scm ("minimum-distance")); + &score_markup_min_distance_, + ly_symbol2scm ("minimum-distance")); Interval first_line = line_dimensions_int (pscore_->layout (), 0); Interval other_lines = line_dimensions_int (pscore_->layout (), 1); @@ -438,25 +437,25 @@ Constrained_breaking::initialize () all_ = pscore_->root_system ()->used_columns (); lines_.resize (breaks_.size (), breaks_.size (), Line_details ()); vector<Real> forces = get_line_forces (all_, - other_lines.length (), - other_lines.length () - first_line.length (), - ragged_right_); + other_lines.length (), + other_lines.length () - first_line.length (), + ragged_right_); for (vsize i = 0; i + 1 < breaks_.size (); i++) { for (vsize j = i + 1; j < breaks_.size (); j++) - { - bool last = j == breaks_.size () - 1; - bool ragged = ragged_right_ || (last && ragged_last_); - Line_details &line = lines_.at (j, i); - - line.force_ = forces[i*breaks_.size () + j]; - if (ragged && last && !isinf (line.force_)) - line.force_ = (line.force_ < 0 && j > i + 1) ? infinity_f : 0; - if (isinf (line.force_)) - break; - - fill_line_details (&line, i, j); - } + { + bool last = j == breaks_.size () - 1; + bool ragged = ragged_right_ || (last && ragged_last_); + Line_details &line = lines_.at (j, i); + + line.force_ = forces[i * breaks_.size () + j]; + if (ragged && last && !isinf (line.force_)) + line.force_ = (line.force_ < 0 && j > i + 1) ? infinity_f : 0; + if (isinf (line.force_)) + break; + + fill_line_details (&line, i, j); + } } /* work out all the starting indices */ @@ -464,7 +463,7 @@ Constrained_breaking::initialize () { vsize j; for (j = 0; j + 1 < breaks_.size () && breaks_[j] < start_[i]; j++) - ; + ; starting_breakpoints_.push_back (j); start_[i] = breaks_[j]; } @@ -497,18 +496,18 @@ Constrained_breaking::fill_line_details (Line_details *const out, vsize start, v /* turn permission should always be stricter than page permission and page permission should always be stricter than line permission */ out->page_permission_ = min_permission (out->break_permission_, - out->page_permission_); + out->page_permission_); out->turn_permission_ = min_permission (out->page_permission_, - out->turn_permission_); + out->turn_permission_); begin_of_line_extent = (begin_of_line_extent.is_empty () - || isnan (begin_of_line_extent[LEFT]) - || isnan (begin_of_line_extent[RIGHT])) - ? Interval (0, 0) : begin_of_line_extent; + || isnan (begin_of_line_extent[LEFT]) + || isnan (begin_of_line_extent[RIGHT])) + ? Interval (0, 0) : begin_of_line_extent; rest_of_line_extent = (rest_of_line_extent.is_empty () - || isnan (rest_of_line_extent[LEFT]) - || isnan (rest_of_line_extent[RIGHT])) - ? Interval (0, 0) : rest_of_line_extent; + || isnan (rest_of_line_extent[LEFT]) + || isnan (rest_of_line_extent[RIGHT])) + ? Interval (0, 0) : rest_of_line_extent; out->shape_ = Line_shape (begin_of_line_extent, rest_of_line_extent); out->padding_ = last ? score_system_padding_ : system_system_padding_; out->title_padding_ = score_markup_padding_; @@ -573,8 +572,8 @@ Line_details::Line_details (Prob *pb, Output_def *paper) title_ = to_boolean (pb->get_property ("is-title")); compressed_lines_count_ = 1; compressed_nontitle_lines_count_ = title_ ? 0 : 1; - SCM last_scm = pb->get_property ("last-markup-line"); - last_markup_line_ = to_boolean (last_scm); + SCM last_scm = pb->get_property ("last-markup-line"); + last_markup_line_ = to_boolean (last_scm); SCM first_scm = pb->get_property ("first-markup-line"); first_markup_line_ = to_boolean (first_scm); tight_spacing_ = to_boolean (pb->get_property ("tight-spacing")); @@ -585,9 +584,9 @@ Real Line_details::full_height () const { Interval ret; - ret.unite(shape_.begin_); - ret.unite(shape_.rest_); - return ret.length(); + ret.unite (shape_.begin_); + ret.unite (shape_.rest_); + return ret.length (); } Real @@ -617,7 +616,7 @@ Line_shape::Line_shape (Interval begin, Interval rest) Line_shape Line_shape::piggyback (Line_shape mount, Real padding) const { - Real elevation = max (begin_[UP]-mount.begin_[DOWN], rest_[UP]-mount.rest_[DOWN]); + Real elevation = max (begin_[UP] - mount.begin_[DOWN], rest_[UP] - mount.rest_[DOWN]); Interval begin = Interval (begin_[DOWN], elevation + mount.begin_[UP] + padding); Interval rest = Interval (rest_[DOWN], elevation + mount.rest_[UP] + padding); return Line_shape (begin, rest); diff --git a/lily/context-def.cc b/lily/context-def.cc index 26e79f56ab..5dd1684a83 100644 --- a/lily/context-def.cc +++ b/lily/context-def.cc @@ -85,7 +85,7 @@ IMPLEMENT_SMOBS (Context_def); IMPLEMENT_DEFAULT_EQUAL_P (Context_def); int -Context_def::print_smob (SCM smob, SCM port, scm_print_state*) +Context_def::print_smob (SCM smob, SCM port, scm_print_state *) { Context_def *me = (Context_def *) SCM_CELL_WORD_1 (smob); @@ -134,17 +134,17 @@ Context_def::add_context_mod (SCM mod) if (ly_symbol2scm ("default-child") == tag) default_child_ = sym; else if (ly_symbol2scm ("consists") == tag - || ly_symbol2scm ("remove") == tag) + || ly_symbol2scm ("remove") == tag) { translator_mods_ = scm_cons (scm_list_2 (tag, sym), translator_mods_); } else if (ly_symbol2scm ("accepts") == tag - || ly_symbol2scm ("denies") == tag) + || ly_symbol2scm ("denies") == tag) accept_mods_ = scm_cons (scm_list_2 (tag, sym), accept_mods_); else if (ly_symbol2scm ("pop") == tag - || ly_symbol2scm ("push") == tag - || ly_symbol2scm ("assign") == tag - || ly_symbol2scm ("unset") == tag) + || ly_symbol2scm ("push") == tag + || ly_symbol2scm ("assign") == tag + || ly_symbol2scm ("unset") == tag) property_ops_ = scm_cons (mod, property_ops_); else if (ly_symbol2scm ("alias") == tag) context_aliases_ = scm_cons (sym, context_aliases_); @@ -166,16 +166,16 @@ Context_def::get_accepted (SCM user_mod) const SCM tag = scm_caar (s); SCM sym = scm_cadar (s); if (tag == ly_symbol2scm ("accepts")) - acc = scm_cons (sym, acc); + acc = scm_cons (sym, acc); else if (tag == ly_symbol2scm ("denies")) - acc = scm_delete_x (sym, acc); + acc = scm_delete_x (sym, acc); } SCM def = get_default_child (user_mod); if (scm_is_symbol (def)) { if (scm_memq (def, acc)) - acc = scm_delete_x (def, acc); + acc = scm_delete_x (def, acc); acc = scm_cons (def, acc); } @@ -190,10 +190,10 @@ Context_def::get_default_child (SCM user_mod) const { SCM entry = scm_car (s); if (scm_car (entry) == ly_symbol2scm ("default-child")) - { - name = scm_cadr (entry); - break; - } + { + name = scm_cadr (entry); + break; + } } return name; @@ -213,8 +213,8 @@ Context_def::get_default_child (SCM user_mod) const */ vector<Context_def *> Context_def::path_to_acceptable_context (SCM type_sym, - Output_def *odef, - SCM additional_accepts) const + Output_def *odef, + SCM additional_accepts) const { set<const Context_def *> seen; return internal_path_to_acceptable_context (type_sym, odef, additional_accepts, &seen); @@ -224,32 +224,32 @@ Context_def::path_to_acceptable_context (SCM type_sym, The SEEN parameter is a set which keeps track of visited contexts, allowing contexts of the same type to be nested. */ -vector<Context_def*> +vector<Context_def *> Context_def::internal_path_to_acceptable_context (SCM type_sym, - Output_def *odef, - SCM additional_accepts, - set<const Context_def *> *seen) const + Output_def *odef, + SCM additional_accepts, + set<const Context_def *> *seen) const { assert (scm_is_symbol (type_sym)); SCM accepted = get_accepted (additional_accepts); - vector<Context_def*> accepteds; + vector<Context_def *> accepteds; for (SCM s = accepted; scm_is_pair (s); s = scm_cdr (s)) if (Context_def *t = unsmob_context_def (find_context_def (odef, - scm_car (s)))) + scm_car (s)))) accepteds.push_back (t); - vector<Context_def*> best_result; + vector<Context_def *> best_result; for (vsize i = 0; i < accepteds.size (); i++) { /* do not check aliases, because \context Staff should not - create RhythmicStaff. */ + create RhythmicStaff. */ if (ly_is_equal (accepteds[i]->get_context_name (), type_sym)) - { - best_result.push_back (accepteds[i]); - return best_result; - } + { + best_result.push_back (accepteds[i]); + return best_result; + } } seen->insert (this); @@ -259,16 +259,16 @@ Context_def::internal_path_to_acceptable_context (SCM type_sym, Context_def *g = accepteds[i]; if (!seen->count (g)) - { - vector<Context_def*> result - = g->internal_path_to_acceptable_context (type_sym, odef, SCM_EOL, seen); - if (result.size () && result.size () < best_depth) - { - best_depth = result.size (); - result.insert (result.begin (), g); - best_result = result; - } - } + { + vector<Context_def *> result + = g->internal_path_to_acceptable_context (type_sym, odef, SCM_EOL, seen); + if (result.size () && result.size () < best_depth) + { + best_depth = result.size (); + result.insert (result.begin (), g); + best_result = result; + } + } } seen->erase (this); @@ -288,13 +288,13 @@ Context_def::get_translator_names (SCM user_mod) const SCM arg = scm_cadar (s); if (scm_is_string (arg)) - arg = scm_string_to_symbol (arg); + arg = scm_string_to_symbol (arg); if (ly_symbol2scm ("consists") == tag) - l1 = scm_cons (arg, l1); + l1 = scm_cons (arg, l1); else if (ly_symbol2scm ("remove") == tag - && get_translator (arg)) - l1 = scm_delete_x (arg, l1); + && get_translator (arg)) + l1 = scm_delete_x (arg, l1); } return l1; @@ -332,19 +332,19 @@ Context_def::to_alist () const SCM ell = SCM_EOL; ell = scm_cons (scm_cons (ly_symbol2scm ("consists"), - get_translator_names (SCM_EOL)), ell); + get_translator_names (SCM_EOL)), ell); ell = scm_cons (scm_cons (ly_symbol2scm ("description"), description_), ell); ell = scm_cons (scm_cons (ly_symbol2scm ("aliases"), context_aliases_), ell); ell = scm_cons (scm_cons (ly_symbol2scm ("accepts"), get_accepted (SCM_EOL)), - ell); + ell); ell = scm_cons (scm_cons (ly_symbol2scm ("property-ops"), property_ops_), - ell); + ell); ell = scm_cons (scm_cons (ly_symbol2scm ("context-name"), context_name_), - ell); + ell); if (scm_is_symbol (translator_group_type_)) ell = scm_cons (scm_cons (ly_symbol2scm ("group-type"), - translator_group_type_), ell); + translator_group_type_), ell); return ell; } diff --git a/lily/context-mod-scheme.cc b/lily/context-mod-scheme.cc index bf1432be6d..b993a7de8f 100644 --- a/lily/context-mod-scheme.cc +++ b/lily/context-mod-scheme.cc @@ -22,10 +22,10 @@ #include "context-mod.hh" LY_DEFINE (ly_get_context_mods, - "ly:get-context-mods", - 1, 0, 0, (SCM contextmod), - "Returns the list of context modifications stored in" - " @var{contextmod}.") + "ly:get-context-mods", + 1, 0, 0, (SCM contextmod), + "Returns the list of context modifications stored in" + " @var{contextmod}.") { Context_mod *tr = unsmob_context_mod (contextmod); LY_ASSERT_SMOB (Context_mod, contextmod, 1); @@ -33,10 +33,10 @@ LY_DEFINE (ly_get_context_mods, } LY_DEFINE (ly_add_context_mod, - "ly:add-context-mod", - 2, 0, 0, (SCM contextmods, SCM modification), - "Adds the given context @var{modification} to the list" - " @var{contextmods} of context modifications.") + "ly:add-context-mod", + 2, 0, 0, (SCM contextmods, SCM modification), + "Adds the given context @var{modification} to the list" + " @var{contextmods} of context modifications.") { Context_mod *ctxmod = unsmob_context_mod (contextmods); LY_ASSERT_SMOB (Context_mod, contextmods, 1); diff --git a/lily/context-mod.cc b/lily/context-mod.cc index a028930c2b..200ba7c6dc 100644 --- a/lily/context-mod.cc +++ b/lily/context-mod.cc @@ -34,7 +34,7 @@ IMPLEMENT_SIMPLE_SMOBS (Context_mod); IMPLEMENT_DEFAULT_EQUAL_P (Context_mod); int -Context_mod::print_smob (SCM smob, SCM port, scm_print_state*) +Context_mod::print_smob (SCM smob, SCM port, scm_print_state *) { Context_mod *me = (Context_mod *) SCM_CELL_WORD_1 (smob); diff --git a/lily/context-property.cc b/lily/context-property.cc index 4d1de24034..7ee4b904d9 100644 --- a/lily/context-property.cc +++ b/lily/context-property.cc @@ -32,23 +32,22 @@ */ void general_pushpop_property (Context *context, - SCM context_property, - SCM grob_property_path, - SCM new_value) + SCM context_property, + SCM grob_property_path, + SCM new_value) { if (!scm_is_symbol (context_property) || !scm_is_symbol (scm_car (grob_property_path))) { warning (_ ("need symbol arguments for \\override and \\revert")); if (do_internal_type_checking_global) - assert (false); + assert (false); } sloppy_general_pushpop_property (context, context_property, - grob_property_path, new_value); + grob_property_path, new_value); } - /* Grob descriptions (ie. alists with layout properties) are represented as a (ALIST . BASED-ON) pair, where BASED-ON is the @@ -58,18 +57,17 @@ general_pushpop_property (Context *context, Push or pop (depending on value of VAL) a single entry from a translator property list by name of PROP. GROB_PROPERTY_PATH indicates nested alists, eg. '(beamed-stem-lengths details) - */ void execute_override_property (Context *context, - SCM context_property, - SCM grob_property_path, - SCM new_value) + SCM context_property, + SCM grob_property_path, + SCM new_value) { SCM current_context_val = SCM_EOL; Context *where = context->where_defined (context_property, - ¤t_context_val); + ¤t_context_val); /* Don't mess with MIDI. @@ -103,9 +101,9 @@ execute_override_property (Context *context, if (scm_is_pair (scm_cdr (grob_property_path))) { new_value = nested_property_alist (ly_assoc_get (symbol, target_alist, - SCM_EOL), - scm_cdr (grob_property_path), - new_value); + SCM_EOL), + scm_cdr (grob_property_path), + new_value); } /* it's tempting to replace the head of the list if it's the same @@ -118,7 +116,7 @@ execute_override_property (Context *context, if (!ly_is_procedure (new_value) && !is_simple_closure (new_value)) ok = type_check_assignment (symbol, new_value, - ly_symbol2scm ("backend-type?")); + ly_symbol2scm ("backend-type?")); /* tack onto alist. We can use set_car, since @@ -136,17 +134,17 @@ execute_override_property (Context *context, */ void sloppy_general_pushpop_property (Context *context, - SCM context_property, - SCM grob_property_path, - SCM new_value) + SCM context_property, + SCM grob_property_path, + SCM new_value) { if (new_value == SCM_UNDEFINED) execute_revert_property (context, context_property, - grob_property_path); + grob_property_path); else execute_override_property (context, context_property, - grob_property_path, - new_value); + grob_property_path, + new_value); } /* @@ -154,8 +152,8 @@ sloppy_general_pushpop_property (Context *context, */ void execute_revert_property (Context *context, - SCM context_property, - SCM grob_property_path) + SCM context_property, + SCM grob_property_path) { SCM current_context_val = SCM_EOL; if (context->where_defined (context_property, ¤t_context_val) @@ -165,38 +163,38 @@ execute_revert_property (Context *context, SCM daddy = scm_cdr (current_context_val); if (!scm_is_pair (grob_property_path) - || !scm_is_symbol (scm_car (grob_property_path))) - { - programming_error ("Grob property path should be list of symbols."); - return; - } + || !scm_is_symbol (scm_car (grob_property_path))) + { + programming_error ("Grob property path should be list of symbols."); + return; + } SCM symbol = scm_car (grob_property_path); if (scm_is_pair (scm_cdr (grob_property_path))) - { - SCM current_sub_alist = ly_assoc_get (symbol, current_alist, SCM_EOL); - SCM new_val - = nested_property_revert_alist (current_sub_alist, - scm_cdr (grob_property_path)); - - if (scm_is_pair (current_alist) - && scm_caar (current_alist) == symbol - && current_alist != daddy) - current_alist = scm_cdr (current_alist); - - current_alist = scm_acons (symbol, new_val, current_alist); - scm_set_car_x (current_context_val, current_alist); - } + { + SCM current_sub_alist = ly_assoc_get (symbol, current_alist, SCM_EOL); + SCM new_val + = nested_property_revert_alist (current_sub_alist, + scm_cdr (grob_property_path)); + + if (scm_is_pair (current_alist) + && scm_caar (current_alist) == symbol + && current_alist != daddy) + current_alist = scm_cdr (current_alist); + + current_alist = scm_acons (symbol, new_val, current_alist); + scm_set_car_x (current_context_val, current_alist); + } else - { - SCM new_alist = evict_from_alist (symbol, current_alist, daddy); - - if (new_alist == daddy) - context->unset_property (context_property); - else - context->set_property (context_property, - scm_cons (new_alist, daddy)); - } + { + SCM new_alist = evict_from_alist (symbol, current_alist, daddy); + + if (new_alist == daddy) + context->unset_property (context_property); + else + context->set_property (context_property, + scm_cons (new_alist, daddy)); + } } } /* @@ -205,13 +203,13 @@ execute_revert_property (Context *context, */ void execute_pushpop_property (Context *context, - SCM context_property, - SCM grob_property, - SCM new_value) + SCM context_property, + SCM grob_property, + SCM new_value) { general_pushpop_property (context, context_property, - scm_list_1 (grob_property), - new_value); + scm_list_1 (grob_property), + new_value); } /* @@ -228,21 +226,21 @@ apply_property_operations (Context *tg, SCM pre_init_ops) entry = scm_cdr (entry); if (type == ly_symbol2scm ("push")) - { - SCM context_prop = scm_car (entry); - SCM val = scm_cadr (entry); - SCM grob_prop_path = scm_cddr (entry); - sloppy_general_pushpop_property (tg, context_prop, grob_prop_path, val); - } + { + SCM context_prop = scm_car (entry); + SCM val = scm_cadr (entry); + SCM grob_prop_path = scm_cddr (entry); + sloppy_general_pushpop_property (tg, context_prop, grob_prop_path, val); + } else if (type == ly_symbol2scm ("pop")) - { - SCM context_prop = scm_car (entry); - SCM val = SCM_UNDEFINED; - SCM grob_prop_path = scm_cdr (entry); - sloppy_general_pushpop_property (tg, context_prop, grob_prop_path, val); - } + { + SCM context_prop = scm_car (entry); + SCM val = SCM_UNDEFINED; + SCM grob_prop_path = scm_cdr (entry); + sloppy_general_pushpop_property (tg, context_prop, grob_prop_path, val); + } else if (type == ly_symbol2scm ("assign")) - tg->set_property (scm_car (entry), scm_cadr (entry)); + tg->set_property (scm_car (entry), scm_cadr (entry)); } } @@ -262,8 +260,8 @@ updated_grob_properties (Context *tg, SCM sym) SCM daddy_props = (tg->get_parent_context ()) - ? updated_grob_properties (tg->get_parent_context (), sym) - : SCM_EOL; + ? updated_grob_properties (tg->get_parent_context (), sym) + : SCM_EOL; if (!scm_is_pair (props)) { @@ -280,11 +278,11 @@ updated_grob_properties (Context *tg, SCM sym) SCM *tail = © SCM p = scm_car (props); while (p != based_on) - { - *tail = scm_cons (scm_car (p), daddy_props); - tail = SCM_CDRLOC (*tail); - p = scm_cdr (p); - } + { + *tail = scm_cons (scm_car (p), daddy_props); + tail = SCM_CDRLOC (*tail); + p = scm_cdr (p); + } scm_set_car_x (props, copy); scm_set_cdr_x (props, daddy_props); diff --git a/lily/context-scheme.cc b/lily/context-scheme.cc index 043bfaa924..b62a83f239 100644 --- a/lily/context-scheme.cc +++ b/lily/context-scheme.cc @@ -23,9 +23,9 @@ #include "dispatcher.hh" LY_DEFINE (ly_context_current_moment, - "ly:context-current-moment", - 1, 0, 0, (SCM context), - "Return the current moment of @var{context}.") + "ly:context-current-moment", + 1, 0, 0, (SCM context), + "Return the current moment of @var{context}.") { Context *tr = unsmob_context (context); @@ -35,10 +35,10 @@ LY_DEFINE (ly_context_current_moment, } LY_DEFINE (ly_context_id, "ly:context-id", - 1, 0, 0, (SCM context), - "Return the ID string of @var{context}," - " i.e., for @code{\\context Voice = \"one\" @dots{}}" - " return the string @code{one}.") + 1, 0, 0, (SCM context), + "Return the ID string of @var{context}," + " i.e., for @code{\\context Voice = \"one\" @dots{}}" + " return the string @code{one}.") { Context *tr = unsmob_context (context); @@ -48,10 +48,10 @@ LY_DEFINE (ly_context_id, "ly:context-id", } LY_DEFINE (ly_context_name, "ly:context-name", - 1, 0, 0, (SCM context), - "Return the name of @var{context}," - " i.e., for @code{\\context Voice = \"one\" @dots{}}" - " return the symbol @code{Voice}.") + 1, 0, 0, (SCM context), + "Return the name of @var{context}," + " i.e., for @code{\\context Voice = \"one\" @dots{}}" + " return the symbol @code{Voice}.") { LY_ASSERT_SMOB (Context, context, 1); @@ -61,9 +61,9 @@ LY_DEFINE (ly_context_name, "ly:context-name", } LY_DEFINE (ly_context_grob_definition, "ly:context-grob-definition", - 2, 0, 0, (SCM context, SCM name), - "Return the definition of @var{name} (a symbol) within" - " @var{context} as an alist.") + 2, 0, 0, (SCM context, SCM name), + "Return the definition of @var{name} (a symbol) within" + " @var{context} as an alist.") { Context *tr = unsmob_context (context); @@ -74,11 +74,11 @@ LY_DEFINE (ly_context_grob_definition, "ly:context-grob-definition", } LY_DEFINE (ly_context_pushpop_property, "ly:context-pushpop-property", - 3, 1, 0, (SCM context, SCM grob, SCM eltprop, SCM val), - "Do a single @code{\\override} or @code{\\revert} operation" - " in @var{context}. The grob definition @var{grob} is extended" - " with @var{eltprop} (if @var{val} is specified) or reverted" - " (if unspecified).") + 3, 1, 0, (SCM context, SCM grob, SCM eltprop, SCM val), + "Do a single @code{\\override} or @code{\\revert} operation" + " in @var{context}. The grob definition @var{grob} is extended" + " with @var{eltprop} (if @var{val} is specified) or reverted" + " (if unspecified).") { Context *tg = unsmob_context (context); @@ -106,9 +106,9 @@ LY_DEFINE (ly_context_property, "ly:context-property", } LY_DEFINE (ly_context_set_property_x, "ly:context-set-property!", - 3, 0, 0, (SCM context, SCM name, SCM val), - "Set value of property @var{name} in context @var{context}" - " to @var{val}.") + 3, 0, 0, (SCM context, SCM name, SCM val), + "Set value of property @var{name} in context @var{context}" + " to @var{val}.") { LY_ASSERT_SMOB (Context, context, 1); LY_ASSERT_TYPE (ly_is_symbol, name, 2); @@ -121,9 +121,9 @@ LY_DEFINE (ly_context_set_property_x, "ly:context-set-property!", } LY_DEFINE (ly_context_property_where_defined, "ly:context-property-where-defined", - 2, 0, 0, (SCM context, SCM name), - "Return the context above @var{context}" - " where @var{name} is defined.") + 2, 0, 0, (SCM context, SCM name), + "Return the context above @var{context}" + " where @var{name} is defined.") { LY_ASSERT_SMOB (Context, context, 1); LY_ASSERT_TYPE (ly_is_symbol, name, 2); @@ -139,8 +139,8 @@ LY_DEFINE (ly_context_property_where_defined, "ly:context-property-where-defined } LY_DEFINE (ly_context_unset_property, "ly:context-unset-property", 2, 0, 0, - (SCM context, SCM name), - "Unset value of property @var{name} in context @var{context}.") + (SCM context, SCM name), + "Unset value of property @var{name} in context @var{context}.") { LY_ASSERT_SMOB (Context, context, 1); LY_ASSERT_TYPE (ly_is_symbol, name, 2); @@ -151,8 +151,8 @@ LY_DEFINE (ly_context_unset_property, "ly:context-unset-property", 2, 0, 0, } LY_DEFINE (ly_context_parent, "ly:context-parent", - 1, 0, 0, (SCM context), - "Return the parent of @var{context}, @code{#f} if none.") + 1, 0, 0, (SCM context), + "Return the parent of @var{context}, @code{#f} if none.") { LY_ASSERT_SMOB (Context, context, 1); Context *tr = unsmob_context (context); @@ -166,9 +166,9 @@ LY_DEFINE (ly_context_parent, "ly:context-parent", /* FIXME: todo: should support translator IDs, and creation? */ LY_DEFINE (ly_context_find, "ly:context-find", - 2, 0, 0, (SCM context, SCM name), - "Find a parent of @var{context} that has name or alias @var{name}." - " Return @code{#f} if not found.") + 2, 0, 0, (SCM context, SCM name), + "Find a parent of @var{context} that has name or alias @var{name}." + " Return @code{#f} if not found.") { LY_ASSERT_SMOB (Context, context, 1); LY_ASSERT_TYPE (ly_is_symbol, name, 2); @@ -177,7 +177,7 @@ LY_DEFINE (ly_context_find, "ly:context-find", while (tr) { if (tr->is_alias (name)) - return tr->self_scm (); + return tr->self_scm (); tr = tr->get_parent_context (); } @@ -185,8 +185,8 @@ LY_DEFINE (ly_context_find, "ly:context-find", } LY_DEFINE (ly_context_now, "ly:context-now", - 1, 0, 0, (SCM context), - "Return @code{now-moment} of context @var{context}.") + 1, 0, 0, (SCM context), + "Return @code{now-moment} of context @var{context}.") { LY_ASSERT_SMOB (Context, context, 1); Context *ctx = unsmob_context (context); diff --git a/lily/context-specced-music-iterator.cc b/lily/context-specced-music-iterator.cc index b02d023545..c1775e48d5 100644 --- a/lily/context-specced-music-iterator.cc +++ b/lily/context-specced-music-iterator.cc @@ -21,7 +21,6 @@ #include "context.hh" #include "music.hh" - class Context_specced_music_iterator : public Music_wrapper_iterator { public: diff --git a/lily/context.cc b/lily/context.cc index 4dbb6e5657..758bcdfda8 100644 --- a/lily/context.cc +++ b/lily/context.cc @@ -36,7 +36,7 @@ bool Context::is_removable () const { return context_list_ == SCM_EOL && ! iterator_count_ - && !dynamic_cast<Global_context const *> (daddy_context_); + && !dynamic_cast<Global_context const *> (daddy_context_); } void @@ -48,12 +48,12 @@ Context::check_removal () ctx->check_removal (); if (ctx->is_removable ()) - { - recurse_over_translators (ctx, &Translator::finalize, - &Translator_group::finalize, - UP); - send_stream_event (ctx, "RemoveContext", 0, 0); - } + { + recurse_over_translators (ctx, &Translator::finalize, + &Translator_group::finalize, + UP); + send_stream_event (ctx, "RemoveContext", 0, 0); + } } } @@ -72,13 +72,12 @@ void Context::add_context (Context *child) { context_list_ = ly_append2 (context_list_, - scm_cons (child->self_scm (), SCM_EOL)); + scm_cons (child->self_scm (), SCM_EOL)); child->daddy_context_ = this; this->events_below_->register_as_listener (child->events_below_); } - Context::Context () { daddy_context_ = 0; @@ -121,18 +120,18 @@ Context::create_unique_context (SCM name, string id, SCM operations) // Iterate through the path and create all of the implicit contexts. for (vsize i = 0; i < path.size (); i++) - { - SCM ops = SCM_EOL; - string id_str = "\\new"; - if (i == path.size () - 1) - { - ops = operations; - id_str = id; - } - current = current->create_context (path[i], - id_str, - ops); - } + { + SCM ops = SCM_EOL; + string id_str = "\\new"; + if (i == path.size () - 1) + { + ops = operations; + id_str = id; + } + current = current->create_context (path[i], + id_str, + ops); + } return current; } @@ -147,7 +146,7 @@ Context::create_unique_context (SCM name, string id, SCM operations) else { warning (_f ("cannot find or create new `%s'", - ly_symbol2string (name).c_str ())); + ly_symbol2string (name).c_str ())); ret = 0; } return ret; @@ -172,7 +171,7 @@ Context::find_create_context (SCM n, string id, SCM operations) return tg; } - vector<Context_def*> path = path_to_acceptable_context (n); + vector<Context_def *> path = path_to_acceptable_context (n); if (path.size ()) { @@ -180,17 +179,17 @@ Context::find_create_context (SCM n, string id, SCM operations) // start at 1. The first one (index 0) will be us. for (vsize i = 0; i < path.size (); i++) - { - SCM ops = (i == path.size () -1) ? operations : SCM_EOL; + { + SCM ops = (i == path.size () - 1) ? operations : SCM_EOL; - string this_id = ""; - if (i == path.size () -1) - this_id = id; + string this_id = ""; + if (i == path.size () - 1) + this_id = id; - current = current->create_context (path[i], - this_id, - ops); - } + current = current->create_context (path[i], + this_id, + ops); + } return current; } @@ -205,7 +204,7 @@ Context::find_create_context (SCM n, string id, SCM operations) else { warning (_f ("cannot find or create `%s' called `%s'", - ly_symbol2string (n).c_str (), id)); + ly_symbol2string (n).c_str (), id)); ret = 0; } return ret; @@ -223,16 +222,16 @@ void Context::set_property_from_event (SCM sev) { Stream_event *ev = unsmob_stream_event (sev); - + SCM sym = ev->get_property ("symbol"); if (scm_is_symbol (sym)) { SCM val = ev->get_property ("value"); bool ok = true; if (val != SCM_EOL) - ok = type_check_assignment (sym, val, ly_symbol2scm ("translation-type?")); + ok = type_check_assignment (sym, val, ly_symbol2scm ("translation-type?")); if (ok) - set_property (sym, val); + set_property (sym, val); } } @@ -241,7 +240,7 @@ void Context::unset_property_from_event (SCM sev) { Stream_event *ev = unsmob_stream_event (sev); - + SCM sym = ev->get_property ("symbol"); type_check_assignment (sym, SCM_EOL, ly_symbol2scm ("translation-type?")); unset_property (sym); @@ -256,13 +255,13 @@ void Context::create_context_from_event (SCM sev) { Stream_event *ev = unsmob_stream_event (sev); - + string id = ly_scm2string (ev->get_property ("id")); SCM ops = ev->get_property ("ops"); SCM type_scm = ev->get_property ("type"); string type = ly_symbol2string (type_scm); - - vector<Context_def*> path = path_to_acceptable_context (type_scm); + + vector<Context_def *> path = path_to_acceptable_context (type_scm); if (path.size () != 1) { @@ -270,31 +269,31 @@ Context::create_context_from_event (SCM sev) return; } Context_def *cdef = path[0]; - + Context *new_context = cdef->instantiate (ops); new_context->id_string_ = id; - + /* Register various listeners: - Make the new context hear events that universally affect contexts - connect events_below etc. properly */ /* We want to be the first ones to hear our own events. Therefore, wait before registering events_below_ */ new_context->event_source ()-> - add_listener (GET_LISTENER (new_context->create_context_from_event), - ly_symbol2scm ("CreateContext")); + add_listener (GET_LISTENER (new_context->create_context_from_event), + ly_symbol2scm ("CreateContext")); new_context->event_source ()-> - add_listener (GET_LISTENER (new_context->remove_context), - ly_symbol2scm ("RemoveContext")); + add_listener (GET_LISTENER (new_context->remove_context), + ly_symbol2scm ("RemoveContext")); new_context->event_source ()-> - add_listener (GET_LISTENER (new_context->change_parent), - ly_symbol2scm ("ChangeParent")); + add_listener (GET_LISTENER (new_context->change_parent), + ly_symbol2scm ("ChangeParent")); new_context->event_source ()-> - add_listener (GET_LISTENER (new_context->set_property_from_event), - ly_symbol2scm ("SetProperty")); + add_listener (GET_LISTENER (new_context->set_property_from_event), + ly_symbol2scm ("SetProperty")); new_context->event_source ()-> - add_listener (GET_LISTENER (new_context->unset_property_from_event), - ly_symbol2scm ("UnsetProperty")); + add_listener (GET_LISTENER (new_context->unset_property_from_event), + ly_symbol2scm ("UnsetProperty")); new_context->events_below_->register_as_listener (new_context->event_source_); this->add_context (new_context); @@ -309,11 +308,11 @@ Context::create_context_from_event (SCM sev) apply_property_operations (new_context, ops); send_stream_event (this, "AnnounceNewContext", 0, - ly_symbol2scm ("context"), new_context->self_scm (), - ly_symbol2scm ("creator"), sev); + ly_symbol2scm ("context"), new_context->self_scm (), + ly_symbol2scm ("creator"), sev); } -vector<Context_def*> +vector<Context_def *> Context::path_to_acceptable_context (SCM name) const { // The 'accepts elements in definition_mods_ is a list of ('accepts string), @@ -322,27 +321,27 @@ Context::path_to_acceptable_context (SCM name) const for (SCM s = scm_reverse (definition_mods_); scm_is_pair (s); s = scm_cdr (s)) if (scm_caar (s) == ly_symbol2scm ("accepts")) { - SCM elt = scm_list_2 (scm_caar (s), scm_string_to_symbol (scm_cadar (s))); - accepts = scm_cons (elt, accepts); + SCM elt = scm_list_2 (scm_caar (s), scm_string_to_symbol (scm_cadar (s))); + accepts = scm_cons (elt, accepts); } return unsmob_context_def (definition_)->path_to_acceptable_context (name, - get_output_def (), - accepts); - + get_output_def (), + accepts); + } Context * Context::create_context (Context_def *cdef, - string id, - SCM ops) + string id, + SCM ops) { infant_event_ = 0; /* TODO: This is fairly misplaced. We can fix this when we have taken out all iterator specific stuff from the Context class */ event_source_-> - add_listener (GET_LISTENER (acknowledge_infant), - ly_symbol2scm ("AnnounceNewContext")); + add_listener (GET_LISTENER (acknowledge_infant), + ly_symbol2scm ("AnnounceNewContext")); /* The CreateContext creates a new context, and sends an announcement of the new context through another event. That event will be stored in infant_event_ to create a return value. */ @@ -351,8 +350,8 @@ Context::create_context (Context_def *cdef, ly_symbol2scm ("type"), cdef->get_context_name (), ly_symbol2scm ("id"), ly_string2scm (id)); event_source_-> - remove_listener (GET_LISTENER (acknowledge_infant), - ly_symbol2scm ("AnnounceNewContext")); + remove_listener (GET_LISTENER (acknowledge_infant), + ly_symbol2scm ("AnnounceNewContext")); assert (infant_event_); SCM infant_scm = infant_event_->get_property ("context"); @@ -375,8 +374,8 @@ SCM Context::default_child_context_name () const { return scm_is_pair (accepts_list_) - ? scm_car (accepts_list_) - : SCM_EOL; + ? scm_car (accepts_list_) + : SCM_EOL; } bool @@ -396,10 +395,10 @@ Context::get_default_interpreter (string context_id) string name = ly_symbol2string (nm); Context_def *t = unsmob_context_def (st); if (!t) - { - warning (_f ("cannot find or create: `%s'", name.c_str ())); - t = unsmob_context_def (this->definition_); - } + { + warning (_f ("cannot find or create: `%s'", name.c_str ())); + t = unsmob_context_def (this->definition_); + } Context *tg = create_context (t, context_id, SCM_EOL); return tg->get_default_interpreter (context_id); @@ -456,7 +455,7 @@ Context::internal_send_stream_event (SCM type, Input *origin, SCM props[]) Stream_event *e = new Stream_event (type, origin); for (int i = 0; props[i]; i += 2) { - e->set_property (props[i], props[i+1]); + e->set_property (props[i], props[i + 1]); } event_source_->broadcast (e); e->unprotect (); @@ -482,7 +481,7 @@ Context::add_alias (SCM sym) /* we don't (yet) instrument context properties */ void -Context::instrumented_set_property (SCM sym, SCM val, const char*, int, const char*) +Context::instrumented_set_property (SCM sym, SCM val, const char *, int, const char *) { internal_set_property (sym, val); } @@ -543,12 +542,12 @@ Context::disconnect_from_parent () */ Context * find_context_below (Context *where, - SCM type, string id) + SCM type, string id) { if (where->is_alias (type)) { if (id == "" || where->id_string () == id) - return where; + return where; } Context *found = 0; @@ -709,11 +708,11 @@ measure_position (Context const *context) m = *unsmob_moment (sm); if (m.main_part_ < Rational (0)) - { - Rational length (measure_length (context)); - while (m.main_part_ < Rational (0)) - m.main_part_ += length; - } + { + Rational length (measure_length (context)); + while (m.main_part_ < Rational (0)) + m.main_part_ += length; + } } return m; @@ -727,9 +726,9 @@ measure_position (Context const *context, Duration const *dur) Moment pos = measure_position (context); Rational dur_length = dur ? dur->get_length () : Rational (0); - Moment end_pos = pos.grace_part_ < Rational(0) - ? Moment(pos.main_part_, pos.grace_part_ + dur_length) - : Moment(pos.main_part_ + dur_length, 0); + Moment end_pos = pos.grace_part_ < Rational (0) + ? Moment (pos.main_part_, pos.grace_part_ + dur_length) + : Moment (pos.main_part_ + dur_length, 0); return end_pos; } @@ -748,7 +747,6 @@ measure_number (Context const *context) return bn; } - void set_context_property_on_children (Context *trans, SCM sym, SCM val) { @@ -778,7 +776,7 @@ check_repeat_count_visibility (Context const *context, SCM count) { SCM proc = context->get_property ("repeatCountVisibility"); return (ly_is_procedure (proc) - && to_boolean (scm_call_2 (proc, - count, - context->self_scm ()))); + && to_boolean (scm_call_2 (proc, + count, + context->self_scm ()))); } diff --git a/lily/control-track-performer.cc b/lily/control-track-performer.cc index 611bd6b48b..84f8044b47 100644 --- a/lily/control-track-performer.cc +++ b/lily/control-track-performer.cc @@ -21,7 +21,6 @@ protected: virtual void acknowledge_audio_element (Audio_element_info info); }; - Control_track_performer::Control_track_performer () { control_track_ = 0; @@ -30,11 +29,11 @@ Control_track_performer::Control_track_performer () void Control_track_performer::acknowledge_audio_element (Audio_element_info info) { - if (Audio_tempo *tempo = dynamic_cast<Audio_tempo*> (info.elem_)) + if (Audio_tempo *tempo = dynamic_cast<Audio_tempo *> (info.elem_)) { control_track_->add_audio_item (tempo); } - if (Audio_time_signature * sig = dynamic_cast<Audio_time_signature *> (info.elem_)) + if (Audio_time_signature *sig = dynamic_cast<Audio_time_signature *> (info.elem_)) { control_track_->add_audio_item (sig); } @@ -47,7 +46,7 @@ Control_track_performer::add_text (Audio_text::Type text_type, string str) control_track_->add_audio_item (text); announce_element (Audio_element_info (text, 0)); - + } void @@ -57,22 +56,22 @@ Control_track_performer::initialize () announce_element (Audio_element_info (control_track_, 0)); string id_string = String_convert::pad_to (gnu_lilypond_version_string (), 30); - + add_text (Audio_text::TRACK_NAME, "control track"); add_text (Audio_text::TEXT, "creator: "); add_text (Audio_text::TEXT, id_string); } ADD_TRANSLATOR (Control_track_performer, - /* doc */ - "", + /* doc */ + "", - /* create */ - "", + /* create */ + "", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/cue-clef-engraver.cc b/lily/cue-clef-engraver.cc index c597b368e1..28e11e17df 100644 --- a/lily/cue-clef-engraver.cc +++ b/lily/cue-clef-engraver.cc @@ -112,11 +112,11 @@ Cue_clef_engraver::create_octavate_eight (SCM oct) abs_oct = abs (abs_oct) + 1; SCM txt = scm_number_to_string (scm_from_int (abs_oct), - scm_from_int (10)); + scm_from_int (10)); g->set_property ("text", - scm_list_n (ly_lily_module_constant ("vcenter-markup"), - txt, SCM_UNDEFINED)); + scm_list_n (ly_lily_module_constant ("vcenter-markup"), + txt, SCM_UNDEFINED)); Side_position_interface::add_support (g, clef_); g->set_parent (clef_, Y_AXIS); @@ -136,7 +136,7 @@ Cue_clef_engraver::create_clef () clef_ = c; SCM cpos = get_property ("cueClefPosition"); if (scm_is_number (cpos)) - clef_->set_property ("staff-position", cpos); + clef_->set_property ("staff-position", cpos); create_octavate_eight (get_property ("cueClefOctavation")); } @@ -150,7 +150,7 @@ Cue_clef_engraver::create_end_clef () clef_ = make_item ("CueEndClef", SCM_EOL); SCM cpos = get_property ("clefPosition"); if (scm_is_number (cpos)) - clef_->set_property ("staff-position", cpos); + clef_->set_property ("staff-position", cpos); create_octavate_eight (get_property ("clefOctavation")); } @@ -175,11 +175,11 @@ Cue_clef_engraver::inspect_clef_properties () { set_glyph (); if (scm_is_string (glyph)) - { - create_clef (); - if (clef_) - clef_->set_property ("non-default", SCM_BOOL_T); - } + { + create_clef (); + if (clef_) + clef_->set_property ("non-default", SCM_BOOL_T); + } else create_end_clef (); @@ -197,10 +197,10 @@ Cue_clef_engraver::stop_translation_timestep () { SCM vis = 0; if (to_boolean (clef_->get_property ("non-default"))) - vis = get_property ("explicitCueClefVisibility"); + vis = get_property ("explicitCueClefVisibility"); if (vis) - clef_->set_property ("break-visibility", vis); + clef_->set_property ("break-visibility", vis); clef_ = 0; octavate_ = 0; @@ -209,22 +209,22 @@ Cue_clef_engraver::stop_translation_timestep () ADD_ACKNOWLEDGER (Cue_clef_engraver, bar_line); ADD_TRANSLATOR (Cue_clef_engraver, - /* doc */ - "Determine and set reference point for pitches in cued voices.", - - /* create */ - "CueClef " - "CueEndClef " - "OctavateEight ", - - /* read */ - "cueClefGlyph " - "cueClefOctavation " - "cueClefPosition " - "explicitCueClefVisibility " - "middleCCuePosition " - "clefOctavation ", - - /* write */ - "" - ); + /* doc */ + "Determine and set reference point for pitches in cued voices.", + + /* create */ + "CueClef " + "CueEndClef " + "OctavateEight ", + + /* read */ + "cueClefGlyph " + "cueClefOctavation " + "cueClefPosition " + "explicitCueClefVisibility " + "middleCCuePosition " + "clefOctavation ", + + /* write */ + "" + ); diff --git a/lily/custos-engraver.cc b/lily/custos-engraver.cc index f1111e829e..2922a04018 100644 --- a/lily/custos-engraver.cc +++ b/lily/custos-engraver.cc @@ -49,7 +49,7 @@ public: private: Item *create_custos (); bool custos_permitted_; - vector<Grob*> custodes_; + vector<Grob *> custodes_; vector<Pitch> pitches_; }; @@ -89,12 +89,12 @@ Custos_engraver::acknowledge_note_head (Grob_info info) { /* - ideally, we'd do custos->set_parent (Y_AXIS, notehead), - but since the note head lives on the other system, we can't + ideally, we'd do custos->set_parent (Y_AXIS, notehead), + but since the note head lives on the other system, we can't - So we copy the position from the note head pitch. We - don't look at the staff-position, since we can't be sure - whether Clef_engraver already applied a vertical shift. + So we copy the position from the note head pitch. We + don't look at the staff-position, since we can't be sure + whether Clef_engraver already applied a vertical shift. */ pitches_.push_back (*unsmob_pitch (ev->get_property ("pitch"))); } @@ -109,17 +109,17 @@ Custos_engraver::process_acknowledged () if (custos_permitted_) { for (vsize i = pitches_.size (); i--;) - { - Item *c = create_custos (); + { + Item *c = create_custos (); - int p = pitches_[i].steps (); - SCM c0 = get_property ("middleCPosition"); - if (scm_is_number (c0)) - p += scm_to_int (c0); + int p = pitches_[i].steps (); + SCM c0 = get_property ("middleCPosition"); + if (scm_is_number (c0)) + p += scm_to_int (c0); - c->set_property ("staff-position", - scm_from_int (p)); - } + c->set_property ("staff-position", + scm_from_int (p)); + } pitches_.clear (); } @@ -147,15 +147,15 @@ ADD_ACKNOWLEDGER (Custos_engraver, bar); ADD_ACKNOWLEDGER (Custos_engraver, note_head); ADD_TRANSLATOR (Custos_engraver, - /* doc */ - "Engrave custodes.", + /* doc */ + "Engrave custodes.", - /* create */ - "Custos ", + /* create */ + "Custos ", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/custos.cc b/lily/custos.cc index f312e4a8ab..d3fd23928d 100644 --- a/lily/custos.cc +++ b/lily/custos.cc @@ -93,12 +93,12 @@ Custos::print (SCM smob) } ADD_INTERFACE (Custos, - "A custos object. @code{style} can have four valid values:" - " @code{mensural}, @code{vaticana}, @code{medicaea}, and" - " @code{hufnagel}. @code{mensural} is the default style.", - - /* properties */ - "style " - "neutral-position " - "neutral-direction " - ); + "A custos object. @code{style} can have four valid values:" + " @code{mensural}, @code{vaticana}, @code{medicaea}, and" + " @code{hufnagel}. @code{mensural} is the default style.", + + /* properties */ + "style " + "neutral-position " + "neutral-direction " + ); diff --git a/lily/default-bar-line-engraver.cc b/lily/default-bar-line-engraver.cc index 5bd1232e30..5c87f7d7b5 100644 --- a/lily/default-bar-line-engraver.cc +++ b/lily/default-bar-line-engraver.cc @@ -38,25 +38,25 @@ public: #include "translator.icc" ADD_TRANSLATOR (Default_bar_line_engraver, - /* doc */ - "This engraver determines what kind of automatic bar lines" - " should be produced, and sets @code{whichBar} accordingly." - " It should be at the same level as @ref{Timing_translator}.", - - /* create */ - "", - - /* read */ - "automaticBars " - "barAlways " - "defaultBarType " - "measureLength " - "whichBar " - "measurePosition ", - - /* write */ - "automaticBars " - ); + /* doc */ + "This engraver determines what kind of automatic bar lines" + " should be produced, and sets @code{whichBar} accordingly." + " It should be at the same level as @ref{Timing_translator}.", + + /* create */ + "", + + /* read */ + "automaticBars " + "barAlways " + "defaultBarType " + "measureLength " + "whichBar " + "measurePosition ", + + /* write */ + "automaticBars " + ); Default_bar_line_engraver::Default_bar_line_engraver () { @@ -76,18 +76,18 @@ Default_bar_line_engraver::start_translation_timestep () Moment mp = measure_position (context ()); bool start_of_measure = (last_moment_.main_part_ != now.main_part_ - && !mp.main_part_); + && !mp.main_part_); if (!scm_is_string (which) && to_boolean (automatic_bars)) { SCM always = get_property ("barAlways"); if ((start_of_measure && last_moment_.main_part_ >= Moment (0)) - || to_boolean (always)) - { - /* should this work, or be junked? See input/bugs/no-bars.ly */ - which = get_property ("defaultBarType"); - } + || to_boolean (always)) + { + /* should this work, or be junked? See input/bugs/no-bars.ly */ + which = get_property ("defaultBarType"); + } } context ()->set_property ("whichBar", which); diff --git a/lily/dimension-cache.cc b/lily/dimension-cache.cc index 8f0022957a..524899b28b 100644 --- a/lily/dimension-cache.cc +++ b/lily/dimension-cache.cc @@ -17,7 +17,6 @@ along with LilyPond. If not, see <http://www.gnu.org/licenses/>. */ - #include "dimension-cache.hh" #include "warn.hh" diff --git a/lily/dimensions-scheme.cc b/lily/dimensions-scheme.cc index 3524faf49b..278610780f 100644 --- a/lily/dimensions-scheme.cc +++ b/lily/dimensions-scheme.cc @@ -22,46 +22,46 @@ #include "warn.hh" LY_DEFINE (ly_pt, "ly:pt", - 1, 0, 0, (SCM num), - "@var{num} printer points.") + 1, 0, 0, (SCM num), + "@var{num} printer points.") { LY_ASSERT_TYPE (scm_is_number, num, 1); return scm_from_double (point_constant - * scm_to_double (num)); + * scm_to_double (num)); } LY_DEFINE (ly_cm, "ly:cm", - 1, 0, 0, (SCM num), - "@var{num} cm.") + 1, 0, 0, (SCM num), + "@var{num} cm.") { LY_ASSERT_TYPE (scm_is_number, num, 1); return scm_from_double (cm_constant - * scm_to_double (num)); + * scm_to_double (num)); } LY_DEFINE (ly_inch, "ly:inch", - 1, 0, 0, (SCM num), - "@var{num} inches.") + 1, 0, 0, (SCM num), + "@var{num} inches.") { LY_ASSERT_TYPE (scm_is_number, num, 1); return scm_from_double (inch_constant - * scm_to_double (num)); + * scm_to_double (num)); } LY_DEFINE (ly_mm, "ly:mm", - 1, 0, 0, (SCM num), - "@var{num} mm.") + 1, 0, 0, (SCM num), + "@var{num} mm.") { LY_ASSERT_TYPE (scm_is_number, num, 1); return scm_from_double (mm_constant - * scm_to_double (num)); + * scm_to_double (num)); } LY_DEFINE (ly_bp, "ly:bp", - 1, 0, 0, (SCM num), - "@var{num} bigpoints (1/72th inch).") + 1, 0, 0, (SCM num), + "@var{num} bigpoints (1/72th inch).") { LY_ASSERT_TYPE (scm_is_number, num, 1); return scm_from_double (bigpoint_constant - * scm_to_double (num)); + * scm_to_double (num)); } diff --git a/lily/dispatcher-scheme.cc b/lily/dispatcher-scheme.cc index bd928173d4..39e35eefb4 100644 --- a/lily/dispatcher-scheme.cc +++ b/lily/dispatcher-scheme.cc @@ -20,21 +20,21 @@ #include "dispatcher.hh" LY_DEFINE (ly_make_dispatcher, "ly:make-dispatcher", - 0, 0, 0, (), - "Return a newly created dispatcher.") + 0, 0, 0, (), + "Return a newly created dispatcher.") { return (new Dispatcher ())->unprotect (); } LY_DEFINE (ly_connect_dispatchers, "ly:connect-dispatchers", - 2, 0, 0, (SCM to, SCM from), - "Make the dispatcher @var{to} listen to events from @var{from}.") + 2, 0, 0, (SCM to, SCM from), + "Make the dispatcher @var{to} listen to events from @var{from}.") { Dispatcher *t = unsmob_dispatcher (to); Dispatcher *f = unsmob_dispatcher (from); - - LY_ASSERT_SMOB (Dispatcher, to, 1); - LY_ASSERT_SMOB (Dispatcher, from, 2); + + LY_ASSERT_SMOB (Dispatcher, to, 1); + LY_ASSERT_SMOB (Dispatcher, from, 2); t->register_as_listener (f); @@ -42,17 +42,17 @@ LY_DEFINE (ly_connect_dispatchers, "ly:connect-dispatchers", } LY_DEFINE (ly_add_listener, "ly:add-listener", - 2, 0, 1, (SCM list, SCM disp, SCM cl), - "Add the listener @var{list} to the dispatcher @var{disp}." - " Whenever @var{disp} hears an event of class @var{cl}," - " it is forwarded to @var{list}.") + 2, 0, 1, (SCM list, SCM disp, SCM cl), + "Add the listener @var{list} to the dispatcher @var{disp}." + " Whenever @var{disp} hears an event of class @var{cl}," + " it is forwarded to @var{list}.") { Listener *l = unsmob_listener (list); Dispatcher *d = unsmob_dispatcher (disp); - LY_ASSERT_SMOB (Listener, list, 1); - LY_ASSERT_SMOB (Dispatcher, disp, 2); - + LY_ASSERT_SMOB (Listener, list, 1); + LY_ASSERT_SMOB (Dispatcher, disp, 2); + for (int arg = SCM_ARG3; scm_is_pair (cl); cl = scm_cdr (cl), arg++) { SCM sym = scm_car (cl); @@ -64,15 +64,15 @@ LY_DEFINE (ly_add_listener, "ly:add-listener", } LY_DEFINE (ly_broadcast, "ly:broadcast", - 2, 0, 0, (SCM disp, SCM ev), - "Send the stream event @var{ev} to the dispatcher @var{disp}.") + 2, 0, 0, (SCM disp, SCM ev), + "Send the stream event @var{ev} to the dispatcher @var{disp}.") { Dispatcher *d = unsmob_dispatcher (disp); Stream_event *e = unsmob_stream_event (ev); - + LY_ASSERT_SMOB (Dispatcher, disp, 1); - LY_ASSERT_SMOB (Stream_event, ev, 2); + LY_ASSERT_SMOB (Stream_event, ev, 2); d->broadcast (e); return SCM_UNDEFINED; } diff --git a/lily/dispatcher.cc b/lily/dispatcher.cc index 856090fdb1..a6cee709ce 100644 --- a/lily/dispatcher.cc +++ b/lily/dispatcher.cc @@ -54,7 +54,7 @@ Dispatcher::mark_smob (SCM sm) } int -Dispatcher::print_smob (SCM s, SCM p, scm_print_state*) +Dispatcher::print_smob (SCM s, SCM p, scm_print_state *) { Dispatcher *me = (Dispatcher *) SCM_CELL_WORD_1 (s); scm_puts ("#<Dispatcher ", p); @@ -109,23 +109,23 @@ Dispatcher::dispatch (SCM sev) The first step is to collect all listener lists and to initially insert them in the priority queue. */ - struct { int prio; SCM list; } lists[num_classes+1]; + struct { int prio; SCM list; } lists[num_classes + 1]; int i = 0; for (SCM cl = class_list; scm_is_pair (cl); cl = scm_cdr (cl)) { SCM list = scm_hashq_ref (listeners_, scm_car (cl), SCM_EOL); if (!scm_is_pair (list)) - num_classes--; + num_classes--; else - { + { // bubblesort. int prio = scm_to_int (scm_caar (list)); - int j; - for (j = i; j > 0 && lists[j-1].prio > prio; j--) - lists[j] = lists[j-1]; - lists[j].prio = prio; - lists[j].list = list; - i++; + int j; + for (j = i; j > 0 && lists[j - 1].prio > prio; j--) + lists[j] = lists[j - 1]; + lists[j].prio = prio; + lists[j].list = list; + i++; } } lists[num_classes].prio = INT_MAX; @@ -155,16 +155,16 @@ Dispatcher::dispatch (SCM sev) if (!scm_is_pair (next)) num_classes--; int prio = (scm_is_pair (next)) ? scm_to_int (scm_caar (next)) : INT_MAX; - for (i = 0; prio > lists[i+1].prio; i++) - lists[i] = lists[i+1]; + for (i = 0; prio > lists[i + 1].prio; i++) + lists[i] = lists[i + 1]; lists[i].prio = prio; lists[i].list = next; } -/* TODO: Uncomment. - if (!sent) - warning (_f ("Junking event: %s", ly_symbol2string (class_symbol).c_str ())); -*/ + /* TODO: Uncomment. + if (!sent) + warning (_f ("Junking event: %s", ly_symbol2string (class_symbol).c_str ())); + */ } void @@ -188,11 +188,11 @@ Dispatcher::internal_add_listener (Listener l, SCM ev_class, int priority) /* Tell all dispatchers that we listen to, that we want to hear ev_class events */ for (SCM disp = dispatchers_; scm_is_pair (disp); disp = scm_cdr (disp)) - { - int priority = scm_to_int (scm_cdar (disp)); - Dispatcher *d = unsmob_dispatcher (scm_caar (disp)); - d->internal_add_listener (GET_LISTENER (dispatch), ev_class, priority); - } + { + int priority = scm_to_int (scm_cdar (disp)); + Dispatcher *d = unsmob_dispatcher (scm_caar (disp)); + d->internal_add_listener (GET_LISTENER (dispatch), ev_class, priority); + } listen_classes_ = scm_cons (ev_class, listen_classes_); } SCM entry = scm_cons (scm_from_int (priority), l.smobbed_copy ()); @@ -219,9 +219,9 @@ Dispatcher::remove_listener (Listener l, SCM ev_class) while (scm_is_pair (scm_cdr (e))) if (*unsmob_listener (scm_cdadr (e)) == l && first) { - scm_set_cdr_x (e, scm_cddr (e)); - first = false; - break; + scm_set_cdr_x (e, scm_cddr (e)); + first = false; + break; } else e = scm_cdr (e); @@ -234,10 +234,10 @@ Dispatcher::remove_listener (Listener l, SCM ev_class) { /* Unregister with all dispatchers. */ for (SCM disp = dispatchers_; scm_is_pair (disp); disp = scm_cdr (disp)) - { - Dispatcher *d = unsmob_dispatcher (scm_caar (disp)); - d->remove_listener (GET_LISTENER (dispatch), ev_class); - } + { + Dispatcher *d = unsmob_dispatcher (scm_caar (disp)); + d->remove_listener (GET_LISTENER (dispatch), ev_class); + } listen_classes_ = scm_delq_x (ev_class, listen_classes_); } } diff --git a/lily/dot-column-engraver.cc b/lily/dot-column-engraver.cc index e83011281b..de34eff525 100644 --- a/lily/dot-column-engraver.cc +++ b/lily/dot-column-engraver.cc @@ -55,25 +55,24 @@ Dot_column_engraver::acknowledge_rhythmic_head (Grob_info info) if (d) { if (!dotcol_) - dotcol_ = make_item ("DotColumn", SCM_EOL); + dotcol_ = make_item ("DotColumn", SCM_EOL); Dot_column::add_head (dotcol_, info.grob ()); } } - ADD_ACKNOWLEDGER (Dot_column_engraver, rhythmic_head); ADD_TRANSLATOR (Dot_column_engraver, - /* doc */ - "Engrave dots on dotted notes shifted to the right of the" - " note. If omitted, then dots appear on top of the notes.", + /* doc */ + "Engrave dots on dotted notes shifted to the right of the" + " note. If omitted, then dots appear on top of the notes.", - /* create */ - "DotColumn ", + /* create */ + "DotColumn ", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/dot-column.cc b/lily/dot-column.cc index 17d7effd7c..fff2359cc0 100644 --- a/lily/dot-column.cc +++ b/lily/dot-column.cc @@ -45,7 +45,7 @@ MAKE_SCHEME_CALLBACK (Dot_column, calc_positioning_done, 1); SCM Dot_column::calc_positioning_done (SCM smob) { - Grob *me = unsmob_grob (smob); + Grob *me = unsmob_grob (smob); /* Trigger note collision resolution first, since that may kill off @@ -56,10 +56,10 @@ Dot_column::calc_positioning_done (SCM smob) me->set_property ("positioning-done", SCM_BOOL_T); - vector<Grob*> dots + vector<Grob *> dots = extract_grob_array (me, "dots"); - vector<Grob*> main_heads; + vector<Grob *> main_heads; Real ss = 0; Grob *commonx = me; @@ -67,56 +67,56 @@ Dot_column::calc_positioning_done (SCM smob) { Grob *n = dots[i]->get_parent (Y_AXIS); commonx = n->common_refpoint (commonx, X_AXIS); - - if (Grob *stem = unsmob_grob (n->get_object("stem"))) - { - commonx = stem->common_refpoint (commonx, X_AXIS); - - if (Stem::first_head (stem) == n) - main_heads.push_back (n); - } + + if (Grob *stem = unsmob_grob (n->get_object ("stem"))) + { + commonx = stem->common_refpoint (commonx, X_AXIS); + + if (Stem::first_head (stem) == n) + main_heads.push_back (n); + } } vector<Box> boxes; - set<Grob*> stems; + set<Grob *> stems; - extract_grob_set(me, "side-support-elements", support); + extract_grob_set (me, "side-support-elements", support); Interval base_x; for (vsize i = 0; i < main_heads.size (); i++) base_x.unite (main_heads[i]->extent (commonx, X_AXIS)); - + for (vsize i = 0; i < support.size (); i++) { Grob *s = support[i]; if (!ss) - ss = Staff_symbol_referencer::staff_space (s); + ss = Staff_symbol_referencer::staff_space (s); /* can't inspect Y extent of rest. - - Rest collisions should wait after line breaking. + + Rest collisions should wait after line breaking. */ Interval y; if (Rest::has_interface (s)) - { - base_x.unite (s->extent (commonx, X_AXIS)); - continue; - } + { + base_x.unite (s->extent (commonx, X_AXIS)); + continue; + } else if (Stem::has_interface (s)) - { - Real y1 = Stem::head_positions (s)[-get_grob_direction (s)]; - Real y2 = y1 + get_grob_direction (s) * 7; + { + Real y1 = Stem::head_positions (s)[-get_grob_direction (s)]; + Real y2 = y1 + get_grob_direction (s) * 7; - y.add_point (y1); - y.add_point (y2); - } + y.add_point (y1); + y.add_point (y2); + } else if (Note_head::has_interface (s)) - y = Interval (-1, 1); + y = Interval (-1, 1); else - { - programming_error ("unknown grob in dot col support"); - continue; - } + { + programming_error ("unknown grob in dot col support"); + continue; + } y *= 2 / ss; y += Staff_symbol_referencer::get_position (s); @@ -125,35 +125,35 @@ Dot_column::calc_positioning_done (SCM smob) boxes.push_back (b); if (Grob *stem = unsmob_grob (s->get_object ("stem"))) - stems.insert (stem); + stems.insert (stem); } - for (set<Grob*>::const_iterator i (stems.begin()); + for (set<Grob *>::const_iterator i (stems.begin ()); i != stems.end (); i++) { Grob *stem = (*i); Stencil flag = Stem::flag (stem); if (!flag.is_empty ()) - { - Interval y = flag.extent (Y_AXIS) - * (2 / ss) - + Stem::stem_end_position (stem); + { + Interval y = flag.extent (Y_AXIS) + * (2 / ss) + + Stem::stem_end_position (stem); - Interval x = stem->relative_coordinate (commonx, X_AXIS) - + flag.extent (X_AXIS); + Interval x = stem->relative_coordinate (commonx, X_AXIS) + + flag.extent (X_AXIS); - boxes.push_back (Box (x,y)); - } + boxes.push_back (Box (x, y)); + } } - + vector_sort (dots, position_less); for (vsize i = dots.size (); i--;) { if (!dots[i]->is_live ()) - dots.erase (dots.begin () + i); + dots.erase (dots.begin () + i); else - // Undo any fake translations that were done in add_head. - dots[i]->translate_axis (-dots[i]->relative_coordinate (me, X_AXIS), X_AXIS); + // Undo any fake translations that were done in add_head. + dots[i]->translate_axis (-dots[i]->relative_coordinate (me, X_AXIS), X_AXIS); } Dot_formatting_problem problem (boxes, base_x); @@ -166,27 +166,27 @@ Dot_column::calc_positioning_done (SCM smob) Grob *note = dots[i]->get_parent (Y_AXIS); if (note) - { - Grob *stem = unsmob_grob (note->get_object ("stem")); - if (stem) - dp.extremal_head_ = Stem::first_head (stem) == note; - - dp.x_extent_ = note->extent (commonx, X_AXIS); - } + { + Grob *stem = unsmob_grob (note->get_object ("stem")); + if (stem) + dp.extremal_head_ = Stem::first_head (stem) == note; + + dp.x_extent_ = note->extent (commonx, X_AXIS); + } int p = Staff_symbol_referencer::get_rounded_position (dp.dot_); /* icky, since this should go via a Staff_symbol_referencer - offset callback but adding a dot overwrites Y-offset. */ + offset callback but adding a dot overwrites Y-offset. */ p += (int) robust_scm2double (dp.dot_->get_property ("staff-position"), 0.0); dp.pos_ = p; if (dp.extremal_head_) - dp.dir_ = to_dir (dp.dot_->get_property ("direction")); + dp.dir_ = to_dir (dp.dot_->get_property ("direction")); cfg.remove_collision (p); cfg[p] = dp; if (Staff_symbol_referencer::on_line (dp.dot_, p)) - cfg.remove_collision (p); + cfg.remove_collision (p); } problem.register_configuration (cfg); @@ -195,13 +195,13 @@ Dot_column::calc_positioning_done (SCM smob) i != cfg.end (); i++) { /* - Junkme? + Junkme? */ Staff_symbol_referencer::set_position (i->second.dot_, i->first); } - + me->translate_axis (cfg.x_offset () - me->relative_coordinate (commonx, X_AXIS), - X_AXIS); + X_AXIS); return SCM_BOOL_T; } @@ -221,20 +221,20 @@ Dot_column::add_head (Grob *me, Grob *head) // The translation here is undone in calc_positioning_done, where we // do the X-offset properly. if (Rest::has_interface (head)) - d->translate_axis (head->extent (head, X_AXIS).length (), X_AXIS); + d->translate_axis (head->extent (head, X_AXIS).length (), X_AXIS); else - d->set_property ("X-offset", Grob::x_parent_positioning_proc); + d->set_property ("X-offset", Grob::x_parent_positioning_proc); Axis_group_interface::add_element (me, d); } } ADD_INTERFACE (Dot_column, - "Group dot objects so they form a column, and position" - " dots so they do not clash with staff lines.", - - /* properties */ - "dots " - "positioning-done " - "direction " - ); + "Group dot objects so they form a column, and position" + " dots so they do not clash with staff lines.", + + /* properties */ + "dots " + "positioning-done " + "direction " + ); diff --git a/lily/dot-configuration.cc b/lily/dot-configuration.cc index b72bd54ef7..fefb983433 100644 --- a/lily/dot-configuration.cc +++ b/lily/dot-configuration.cc @@ -22,7 +22,6 @@ #include "dot-formatting-problem.hh" #include "staff-symbol-referencer.hh" - int Dot_configuration::badness () const { @@ -35,15 +34,15 @@ Dot_configuration::badness () const int dot_move_dir = sign (p - i->second.pos_); if (i->second.extremal_head_) - { - if (i->second.dir_ - && dot_move_dir != i->second.dir_) - demerit += 3; - else if (dot_move_dir != UP) - demerit += 2; - } + { + if (i->second.dir_ + && dot_move_dir != i->second.dir_) + demerit += 3; + else if (dot_move_dir != UP) + demerit += 2; + } else if (dot_move_dir != UP) - demerit += 1; + demerit += 1; t += demerit; } @@ -77,55 +76,55 @@ Dot_configuration::shifted (int k, Direction d) const if (d > 0) { for (Dot_configuration::const_iterator i (begin ()); - i != end (); i++) - { - int p = i->first; - if (p == k) - { - if (Staff_symbol_referencer::on_line (i->second.dot_, p)) - p += d; - else - p += 2* d; - - offset = 2*d; - - new_cfg[p] = i->second; - } - else - { - if (new_cfg.find (p) == new_cfg.end ()) - offset = 0; - new_cfg[p + offset] = i->second; - } - } + i != end (); i++) + { + int p = i->first; + if (p == k) + { + if (Staff_symbol_referencer::on_line (i->second.dot_, p)) + p += d; + else + p += 2 * d; + + offset = 2 * d; + + new_cfg[p] = i->second; + } + else + { + if (new_cfg.find (p) == new_cfg.end ()) + offset = 0; + new_cfg[p + offset] = i->second; + } + } } else { Dot_configuration::const_iterator i (end ()); do - { - i--; - - int p = i->first; - if (p == k) - { - if (Staff_symbol_referencer::on_line (i->second.dot_, p)) - p += d; - else - p += 2* d; - - offset = 2*d; - - new_cfg[p] = i->second; - } - else - { - if (new_cfg.find (p) == new_cfg.end ()) - offset = 0; - - new_cfg[p + offset] = i->second; - } - } + { + i--; + + int p = i->first; + if (p == k) + { + if (Staff_symbol_referencer::on_line (i->second.dot_, p)) + p += d; + else + p += 2 * d; + + offset = 2 * d; + + new_cfg[p] = i->second; + } + else + { + if (new_cfg.find (p) == new_cfg.end ()) + offset = 0; + + new_cfg[p + offset] = i->second; + } + } while (i != begin ()); } diff --git a/lily/dot-formatting-problem.cc b/lily/dot-formatting-problem.cc index 1d83f64b31..0277c94ecf 100644 --- a/lily/dot-formatting-problem.cc +++ b/lily/dot-formatting-problem.cc @@ -21,7 +21,7 @@ #include "dot-configuration.hh" #include "skyline.hh" -Dot_formatting_problem::~Dot_formatting_problem() +Dot_formatting_problem::~Dot_formatting_problem () { delete best_; } @@ -44,7 +44,7 @@ Dot_formatting_problem::best () const } Dot_formatting_problem::Dot_formatting_problem (vector<Box> const &boxes, - Interval base_x) + Interval base_x) : head_skyline_ (boxes, 0.0, Y_AXIS, RIGHT) { best_ = 0; diff --git a/lily/dots-engraver.cc b/lily/dots-engraver.cc index efe927e0ec..0401051ce0 100644 --- a/lily/dots-engraver.cc +++ b/lily/dots-engraver.cc @@ -25,8 +25,7 @@ #include "translator.icc" - -class Dots_engraver : public Engraver +class Dots_engraver : public Engraver { DECLARE_ACKNOWLEDGER (rhythmic_head); TRANSLATOR_DECLARATIONS (Dots_engraver); @@ -46,7 +45,7 @@ Dots_engraver::acknowledge_rhythmic_head (Grob_info gi) Grob *note = gi.grob (); if (unsmob_grob (note->get_object ("dot"))) return; - + Duration *dur = unsmob_duration (cause->get_property ("duration")); if (dur && dur->dot_count ()) { @@ -57,19 +56,18 @@ Dots_engraver::acknowledge_rhythmic_head (Grob_info gi) } } - ADD_ACKNOWLEDGER (Dots_engraver, rhythmic_head); ADD_TRANSLATOR (Dots_engraver, - "Create @ref{Dots} objects for" - " @ref{rhythmic-head-interface}s.", - - /* create */ - "Dots ", - - /* read */ - "", - - /* write */ - "" - ); + "Create @ref{Dots} objects for" + " @ref{rhythmic-head-interface}s.", + + /* create */ + "Dots ", + + /* read */ + "", + + /* write */ + "" + ); diff --git a/lily/dots.cc b/lily/dots.cc index 8319118752..7993308ae0 100644 --- a/lily/dots.cc +++ b/lily/dots.cc @@ -38,46 +38,46 @@ Dots::print (SCM d) if (scm_is_number (c)) { SCM scm_style = sc->get_property ("style"); - string style =""; + string style = ""; if (scm_is_symbol (scm_style)) - style = ly_symbol2string (scm_style); - string idx = "dots.dot" + style; + style = ly_symbol2string (scm_style); + string idx = "dots.dot" + style; Stencil d = Font_interface::get_default_font (sc)->find_by_name (idx); if (d.is_empty ()) - { - sc->warning (_f ("dot `%s' not found", idx.c_str ())); - return SCM_EOL; - } + { + sc->warning (_f ("dot `%s' not found", idx.c_str ())); + return SCM_EOL; + } Real dw = d.extent (X_AXIS).length (); /* - we need to add a real blank box, to assure that - side-positioning doth not cancel the left-most padding. */ + we need to add a real blank box, to assure that + side-positioning doth not cancel the left-most padding. */ /* - TODO: this should be handled by side-position padding. + TODO: this should be handled by side-position padding. */ mol = Lookup::blank (Box (Interval (0, 0), - Interval (0, 0))); + Interval (0, 0))); for (int i = scm_to_int (c); i--;) - { - d.translate_axis (2 * dw, X_AXIS); - mol.add_at_edge (X_AXIS, RIGHT, d, dw); - } + { + d.translate_axis (2 * dw, X_AXIS); + mol.add_at_edge (X_AXIS, RIGHT, d, dw); + } } return mol.smobbed_copy (); } ADD_INTERFACE (Dots, - "The dots to go with a notehead or rest. @code{direction}" - " sets the preferred direction to move in case of staff line" - " collisions. @code{style} defaults to undefined, which is" - " normal 19th/20th century traditional style. Set" - " @code{style} to @code{vaticana} for ancient type dots.", + "The dots to go with a notehead or rest. @code{direction}" + " sets the preferred direction to move in case of staff line" + " collisions. @code{style} defaults to undefined, which is" + " normal 19th/20th century traditional style. Set" + " @code{style} to @code{vaticana} for ancient type dots.", - /* properties */ - "direction " - "dot-count " - "style " - ); + /* properties */ + "direction " + "dot-count " + "style " + ); diff --git a/lily/double-percent-repeat-engraver.cc b/lily/double-percent-repeat-engraver.cc index ad64657e97..5d775a1756 100644 --- a/lily/double-percent-repeat-engraver.cc +++ b/lily/double-percent-repeat-engraver.cc @@ -55,7 +55,7 @@ Double_percent_repeat_engraver::listen_double_percent (Stream_event *ev) if (!percent_event_) { Moment meas_len (robust_scm2moment (get_property ("measureLength"), - Moment (1))); + Moment (1))); start_mom_ = now_mom () + meas_len; get_global_context ()->add_moment_to_process (start_mom_); percent_event_ = ev; @@ -70,44 +70,44 @@ Double_percent_repeat_engraver::process_music () if (percent_event_ && now_mom ().main_part_ == start_mom_.main_part_) { Item *double_percent = make_item ("DoublePercentRepeat", - percent_event_->self_scm ()); + percent_event_->self_scm ()); SCM count = percent_event_->get_property ("repeat-count"); if (count != SCM_EOL && to_boolean (get_property ("countPercentRepeats")) - && check_repeat_count_visibility (context (), count)) - { - Item *double_percent_counter - = make_item ("DoublePercentRepeatCounter", - percent_event_->self_scm ()); - - SCM text = scm_number_to_string (count, scm_from_int (10)); - double_percent_counter->set_property ("text", text); - - Side_position_interface::add_support (double_percent_counter, - double_percent); - double_percent_counter->set_parent (double_percent, Y_AXIS); - double_percent_counter->set_parent (double_percent, X_AXIS); - } + && check_repeat_count_visibility (context (), count)) + { + Item *double_percent_counter + = make_item ("DoublePercentRepeatCounter", + percent_event_->self_scm ()); + + SCM text = scm_number_to_string (count, scm_from_int (10)); + double_percent_counter->set_property ("text", text); + + Side_position_interface::add_support (double_percent_counter, + double_percent); + double_percent_counter->set_parent (double_percent, Y_AXIS); + double_percent_counter->set_parent (double_percent, X_AXIS); + } // forbid breaks on a % line context ()->get_score_context ()->set_property ("forbidBreak", - SCM_BOOL_T); + SCM_BOOL_T); percent_event_ = 0; } } ADD_TRANSLATOR (Double_percent_repeat_engraver, - /* doc */ - "Make double measure repeats.", + /* doc */ + "Make double measure repeats.", - /* create */ - "DoublePercentRepeat " - "DoublePercentRepeatCounter ", + /* create */ + "DoublePercentRepeat " + "DoublePercentRepeatCounter ", - /* read */ - "countPercentRepeats " - "measureLength " - "repeatCountVisibility ", + /* read */ + "countPercentRepeats " + "measureLength " + "repeatCountVisibility ", - /* write */ - "forbidBreak " - ); + /* write */ + "forbidBreak " + ); diff --git a/lily/drum-note-engraver.cc b/lily/drum-note-engraver.cc index 605876ef60..c8dbabca1c 100644 --- a/lily/drum-note-engraver.cc +++ b/lily/drum-note-engraver.cc @@ -67,7 +67,7 @@ Drum_notes_engraver::process_music () for (vsize i = 0; i < events_.size (); i++) { if (!tab) - tab = get_property ("drumStyleTable"); + tab = get_property ("drumStyleTable"); Stream_event *ev = events_[i]; Item *note = make_item ("NoteHead", ev->self_scm ()); @@ -77,30 +77,30 @@ Drum_notes_engraver::process_music () SCM defn = SCM_EOL; if (scm_hash_table_p (tab) == SCM_BOOL_T) - defn = scm_hashq_ref (tab, drum_type, SCM_EOL); + defn = scm_hashq_ref (tab, drum_type, SCM_EOL); if (scm_is_pair (defn)) - { - SCM pos = scm_caddr (defn); - SCM style = scm_car (defn); - SCM script = scm_cadr (defn); - - if (scm_integer_p (pos) == SCM_BOOL_T) - note->set_property ("staff-position", pos); - if (scm_is_symbol (style)) - note->set_property ("style", style); - - if (scm_is_string (script)) - { - Item *p = make_item ("Script", ev->self_scm ()); - make_script_from_event (p, context (), script, - 0); - - p->set_parent (note, Y_AXIS); - Side_position_interface::add_support (p, note); - scripts_.push_back (p); - } - } + { + SCM pos = scm_caddr (defn); + SCM style = scm_car (defn); + SCM script = scm_cadr (defn); + + if (scm_integer_p (pos) == SCM_BOOL_T) + note->set_property ("staff-position", pos); + if (scm_is_symbol (style)) + note->set_property ("style", style); + + if (scm_is_string (script)) + { + Item *p = make_item ("Script", ev->self_scm ()); + make_script_from_event (p, context (), script, + 0); + + p->set_parent (note, Y_AXIS); + Side_position_interface::add_support (p, note); + scripts_.push_back (p); + } + } } } @@ -112,7 +112,7 @@ Drum_notes_engraver::acknowledge_stem (Grob_info inf) Grob *e = scripts_[i]; if (to_dir (e->get_property ("side-relative-direction"))) - e->set_object ("direction-source", inf.grob ()->self_scm ()); + e->set_object ("direction-source", inf.grob ()->self_scm ()); Side_position_interface::add_support (e, inf.grob ()); } @@ -126,8 +126,8 @@ Drum_notes_engraver::acknowledge_note_column (Grob_info inf) Grob *e = scripts_[i]; if (!e->get_parent (X_AXIS) - && Side_position_interface::get_axis (e) == Y_AXIS) - e->set_parent (inf.grob (), X_AXIS); + && Side_position_interface::get_axis (e) == Y_AXIS) + e->set_parent (inf.grob (), X_AXIS); } } @@ -142,16 +142,16 @@ ADD_ACKNOWLEDGER (Drum_notes_engraver, stem); ADD_ACKNOWLEDGER (Drum_notes_engraver, note_column); ADD_TRANSLATOR (Drum_notes_engraver, - /* doc */ - "Generate drum note heads.", + /* doc */ + "Generate drum note heads.", - /* create */ - "NoteHead " - "Script ", + /* create */ + "NoteHead " + "Script ", - /* read */ - "drumStyleTable ", + /* read */ + "drumStyleTable ", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/drum-note-performer.cc b/lily/drum-note-performer.cc index b28a7cd9ec..4feb11730b 100644 --- a/lily/drum-note-performer.cc +++ b/lily/drum-note-performer.cc @@ -55,11 +55,11 @@ Drum_note_performer::process_music () SCM defn = SCM_EOL; if (scm_is_symbol (sym) - && (scm_hash_table_p (tab) == SCM_BOOL_T)) - defn = scm_hashq_ref (tab, sym, SCM_EOL); + && (scm_hash_table_p (tab) == SCM_BOOL_T)) + defn = scm_hashq_ref (tab, sym, SCM_EOL); if (Pitch *pit = unsmob_pitch (defn)) - { + { SCM articulations = n->get_property ("articulations"); Stream_event *tie_event = 0; for (SCM s = articulations; @@ -69,18 +69,18 @@ Drum_note_performer::process_music () Stream_event *ev = unsmob_stream_event (scm_car (s)); if (!ev) continue; - + if (ev->in_event_class ("tie-event")) tie_event = ev; } - Moment len = get_event_length (n, now_mom ()); + Moment len = get_event_length (n, now_mom ()); - Audio_note *p = new Audio_note (*pit, len, + Audio_note *p = new Audio_note (*pit, len, tie_event, Pitch (0, 0, 0)); - Audio_element_info info (p, n); - announce_element (info); - } + Audio_element_info info (p, n); + announce_element (info); + } } note_evs_.clear (); @@ -100,15 +100,15 @@ Drum_note_performer::listen_note (Stream_event *ev) } ADD_TRANSLATOR (Drum_note_performer, - /* doc */ - "Play drum notes.", + /* doc */ + "Play drum notes.", - /* create */ - "", + /* create */ + "", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/duration-scheme.cc b/lily/duration-scheme.cc index 439362bf82..0aec4a15ca 100644 --- a/lily/duration-scheme.cc +++ b/lily/duration-scheme.cc @@ -35,8 +35,8 @@ Duration::less_p (SCM p1, SCM p2) } LY_DEFINE (ly_duration_less_p, "ly:duration<?", - 2, 0, 0, (SCM p1, SCM p2), - "Is @var{p1} shorter than @var{p2}?") + 2, 0, 0, (SCM p1, SCM p2), + "Is @var{p1} shorter than @var{p2}?") { LY_ASSERT_SMOB (Duration, p1, 1); LY_ASSERT_SMOB (Duration, p2, 2); @@ -51,18 +51,18 @@ LY_DEFINE (ly_duration_less_p, "ly:duration<?", } LY_DEFINE (ly_make_duration, "ly:make-duration", - 1, 3, 0, (SCM length, SCM dotcount, SCM num, SCM den), - "@var{length} is the negative logarithm (base 2) of the duration:" - " 1@tie{}is a half note, 2@tie{}is a quarter note, 3@tie{}is an" - " eighth note, etc. The number of dots after the note is given by" - " the optional argument @var{dotcount}.\n" - "\n" - "The duration factor is optionally given by @var{num} and" - " @var{den}.\n" - "\n" - "A duration is a musical duration, i.e., a length of time" - " described by a power of two (whole, half, quarter, etc.) and a" - " number of augmentation dots.") + 1, 3, 0, (SCM length, SCM dotcount, SCM num, SCM den), + "@var{length} is the negative logarithm (base 2) of the duration:" + " 1@tie{}is a half note, 2@tie{}is a quarter note, 3@tie{}is an" + " eighth note, etc. The number of dots after the note is given by" + " the optional argument @var{dotcount}.\n" + "\n" + "The duration factor is optionally given by @var{num} and" + " @var{den}.\n" + "\n" + "A duration is a musical duration, i.e., a length of time" + " described by a power of two (whole, half, quarter, etc.) and a" + " number of augmentation dots.") { LY_ASSERT_TYPE (scm_is_integer, length, 1); @@ -98,24 +98,24 @@ LY_DEFINE (ly_make_duration, "ly:make-duration", } LY_DEFINE (ly_duration_log, "ly:duration-log", - 1, 0, 0, (SCM dur), - "Extract the duration log from @var{dur}.") + 1, 0, 0, (SCM dur), + "Extract the duration log from @var{dur}.") { LY_ASSERT_SMOB (Duration, dur, 1); return scm_from_int (unsmob_duration (dur)->duration_log ()); } LY_DEFINE (ly_duration_dot_count, "ly:duration-dot-count", - 1, 0, 0, (SCM dur), - "Extract the dot count from @var{dur}.") + 1, 0, 0, (SCM dur), + "Extract the dot count from @var{dur}.") { LY_ASSERT_SMOB (Duration, dur, 1); return scm_from_int (unsmob_duration (dur)->dot_count ()); } LY_DEFINE (ly_intlog2, "ly:intlog2", - 1, 0, 0, (SCM d), - "The 2-logarithm of 1/@var{d}.") + 1, 0, 0, (SCM d), + "The 2-logarithm of 1/@var{d}.") { LY_ASSERT_TYPE (scm_is_number, d, 1); int log = intlog2 (scm_to_int (d)); @@ -123,25 +123,25 @@ LY_DEFINE (ly_intlog2, "ly:intlog2", } LY_DEFINE (ly_duration_length, "ly:duration-length", - 1, 0, 0, (SCM dur), - "The length of the duration as a @code{moment}.") + 1, 0, 0, (SCM dur), + "The length of the duration as a @code{moment}.") { LY_ASSERT_SMOB (Duration, dur, 1); return Moment (unsmob_duration (dur)->get_length ()).smobbed_copy (); } LY_DEFINE (ly_duration_2_string, "ly:duration->string", - 1, 0, 0, (SCM dur), - "Convert @var{dur} to a string.") + 1, 0, 0, (SCM dur), + "Convert @var{dur} to a string.") { LY_ASSERT_SMOB (Duration, dur, 1); return ly_string2scm (unsmob_duration (dur)->to_string ()); } LY_DEFINE (ly_duration_factor, "ly:duration-factor", - 1, 0, 0, (SCM dur), - "Extract the compression factor from @var{dur}." - " Return it as a pair.") + 1, 0, 0, (SCM dur), + "Extract the compression factor from @var{dur}." + " Return it as a pair.") { LY_ASSERT_SMOB (Duration, dur, 1); Rational r = unsmob_duration (dur)->factor (); diff --git a/lily/duration.cc b/lily/duration.cc index 194ce3a89e..75905db6b6 100644 --- a/lily/duration.cc +++ b/lily/duration.cc @@ -57,41 +57,41 @@ Duration::Duration (Rational r, bool scale) else { /* we want to find the integer k for which 2q/p > 2^k >= q/p. - It's simple to check that k' = \floor \log q - \floor \log p - satisfies the left inequality and is within a factor of 2 of - satistying the right one. Therefore either k = k' or k = k'+1 */ + It's simple to check that k' = \floor \log q - \floor \log p + satisfies the left inequality and is within a factor of 2 of + satistying the right one. Therefore either k = k' or k = k'+1 */ int p = (int) r.num (); int q = (int) r.den (); int k = intlog2 (q) - intlog2 (p); - if (shift_left(p, k) < q) - k++; + if (shift_left (p, k) < q) + k++; - assert (shift_left(p, k) >= q && shift_left(p, (k-1)) < q); + assert (shift_left (p, k) >= q && shift_left (p, (k - 1)) < q); /* If we were to write out log (p/q) in base 2, then the position of the - first non-zero bit (ie. k in our notation) would be the durlog - and the number of consecutive 1s after that bit would be the number of - dots */ - p = shift_left(p, k) - q; + first non-zero bit (ie. k in our notation) would be the durlog + and the number of consecutive 1s after that bit would be the number of + dots */ + p = shift_left (p, k) - q; dots_ = 0; while ((p *= 2) >= q) - { - p -= q; - dots_++; - } + { + p -= q; + dots_++; + } /* we only go up to 64th notes */ if (k > 6) - { - durlog_ = 6; - dots_ = 0; - } + { + durlog_ = 6; + dots_ = 0; + } else - durlog_ = k; + durlog_ = k; if (scale || k > 6) - factor_ = r / get_length (); + factor_ = r / get_length (); } } @@ -165,8 +165,8 @@ Duration::equal_p (SCM a, SCM b) Duration *q = (Duration *) SCM_CELL_WORD_1 (b); bool eq = p->dots_ == q->dots_ - && p->durlog_ == q->durlog_ - && p->factor_ == q->factor_; + && p->durlog_ == q->durlog_ + && p->factor_ == q->factor_; return eq ? SCM_BOOL_T : SCM_BOOL_F; } diff --git a/lily/dynamic-align-engraver.cc b/lily/dynamic-align-engraver.cc index 766b63ed54..92736e0316 100644 --- a/lily/dynamic-align-engraver.cc +++ b/lily/dynamic-align-engraver.cc @@ -73,7 +73,7 @@ Dynamic_align_engraver::create_line_spanner (Stream_event *event) { if (!line_) line_ = make_spanner ("DynamicLineSpanner", - event ? event->self_scm () : SCM_EOL); + event ? event->self_scm () : SCM_EOL); } void @@ -83,10 +83,10 @@ Dynamic_align_engraver::acknowledge_end_dynamic (Grob_info info) ended_.push_back (info.spanner ()); /* If the break flag is set, store the current spanner and let new dynamics - * create a new spanner + * create a new spanner */ - bool spanner_broken = current_dynamic_spanner_ == info.spanner () && - to_boolean (current_dynamic_spanner_->get_property ("spanner-broken")); + bool spanner_broken = current_dynamic_spanner_ == info.spanner () + && to_boolean (current_dynamic_spanner_->get_property ("spanner-broken")); if (spanner_broken && line_) { if (ended_line_) @@ -149,7 +149,7 @@ Dynamic_align_engraver::acknowledge_dynamic (Grob_info info) if (cause) { if (Direction d = to_dir (cause->get_property ("direction"))) - set_grob_direction (line_, d); + set_grob_direction (line_, d); } } @@ -161,25 +161,25 @@ Dynamic_align_engraver::set_spanner_bounds (Spanner *line, bool end) Direction d = LEFT; do { - if ((d == LEFT && !line->get_bound (LEFT)) || - (end && d == RIGHT && !line->get_bound (RIGHT))) - { - vector<Spanner *> const &spanners - = (d == LEFT) ? started_ : ended_; - - Grob *bound = 0; - if (scripts_.size ()) - bound = scripts_[0]; - else if (spanners.size ()) - bound = spanners[0]->get_bound (d); - else - { - bound = unsmob_grob (get_property ("currentMusicalColumn")); - programming_error ("started DynamicLineSpanner but have no left bound"); - } - - line->set_bound (d, bound); - } + if ((d == LEFT && !line->get_bound (LEFT)) + || (end && d == RIGHT && !line->get_bound (RIGHT))) + { + vector<Spanner *> const &spanners + = (d == LEFT) ? started_ : ended_; + + Grob *bound = 0; + if (scripts_.size ()) + bound = scripts_[0]; + else if (spanners.size ()) + bound = spanners[0]->get_bound (d); + else + { + bound = unsmob_grob (get_property ("currentMusicalColumn")); + programming_error ("started DynamicLineSpanner but have no left bound"); + } + + line->set_bound (d, bound); + } } while (flip (&d) != LEFT); } @@ -195,9 +195,9 @@ Dynamic_align_engraver::stop_translation_timestep () set<Spanner *>::iterator it = running_.find (sp); if (it != running_.end ()) - running_.erase (it); + running_.erase (it); else - started_[i]->programming_error ("lost track of this dynamic spanner"); + started_[i]->programming_error ("lost track of this dynamic spanner"); } bool end = line_ && running_.empty (); @@ -206,11 +206,11 @@ Dynamic_align_engraver::stop_translation_timestep () // is ended now set_spanner_bounds (ended_line_, true); set_spanner_bounds (line_, end); - // If the flag is set to break the spanner after the current child, don't + // If the flag is set to break the spanner after the current child, don't // add any more support points (needed e.g. for style=none, where the // invisible spanner should NOT be shifted since we don't have a line). - bool spanner_broken = current_dynamic_spanner_ && - to_boolean (current_dynamic_spanner_->get_property ("spanner-broken")); + bool spanner_broken = current_dynamic_spanner_ + && to_boolean (current_dynamic_spanner_->get_property ("spanner-broken")); for (vsize i = 0; line_ && !spanner_broken && i < support_.size (); i++) Side_position_interface::add_support (line_, support_[i]); @@ -227,15 +227,15 @@ Dynamic_align_engraver::stop_translation_timestep () } ADD_TRANSLATOR (Dynamic_align_engraver, - /* doc */ - "Align hairpins and dynamic texts on a horizontal line.", + /* doc */ + "Align hairpins and dynamic texts on a horizontal line.", - /* create */ - "DynamicLineSpanner ", + /* create */ + "DynamicLineSpanner ", - /* read */ - "currentMusicalColumn ", + /* read */ + "currentMusicalColumn ", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/dynamic-engraver.cc b/lily/dynamic-engraver.cc index 14522c6376..0107e7f436 100644 --- a/lily/dynamic-engraver.cc +++ b/lily/dynamic-engraver.cc @@ -70,8 +70,8 @@ class Dynamic_engraver : public Engraver Drul_array<Stream_event *> accepted_spanevents_drul_; - vector<Note_column*> pending_columns_; - vector<Grob*> pending_elements_; + vector<Note_column *> pending_columns_; + vector<Grob *> pending_elements_; void typeset_all (); @@ -118,7 +118,7 @@ Dynamic_engraver::listen_span_dynamic (Stream_event *ev) if (d == START) ASSIGN_EVENT_ONCE (accepted_spanevents_drul_[START], ev); - + /* Cancel any ongoing crescendo, either explicitly by \! or implicitly by a new crescendo. Also avoid warning if cresc is cancelled both implicitly and explicitly. */ @@ -132,12 +132,12 @@ Dynamic_engraver::process_music () if (accepted_spanevents_drul_[START] || accepted_spanevents_drul_[STOP] || script_ev_) { if (!line_spanner_) - { - Stream_event *rq = accepted_spanevents_drul_[START]; - line_spanner_ = make_spanner ("DynamicLineSpanner", rq ? rq->self_scm () : SCM_EOL); - if (script_ev_) - rq = script_ev_; - } + { + Stream_event *rq = accepted_spanevents_drul_[START]; + line_spanner_ = make_spanner ("DynamicLineSpanner", rq ? rq->self_scm () : SCM_EOL); + if (script_ev_) + rq = script_ev_; + } } /* @@ -157,140 +157,140 @@ Dynamic_engraver::process_music () { script_ = make_item ("DynamicText", script_ev_->self_scm ()); script_->set_property ("text", - script_ev_->get_property ("text")); + script_ev_->get_property ("text")); if (Direction d = to_dir (script_ev_->get_property ("direction"))) - set_grob_direction (line_spanner_, d); + set_grob_direction (line_spanner_, d); else if (Direction d = to_dir (line_spanner_->get_property ("direction"))) - set_grob_direction (script_, d); + set_grob_direction (script_, d); Axis_group_interface::add_element (line_spanner_, script_); } Stream_event *stop_ev = accepted_spanevents_drul_ [STOP] - ? accepted_spanevents_drul_[STOP] : script_ev_; + ? accepted_spanevents_drul_[STOP] : script_ev_; if (accepted_spanevents_drul_[STOP] || script_ev_) { /* - finish side position alignment if the (de)cresc ends here, and - there are no new dynamics. + finish side position alignment if the (de)cresc ends here, and + there are no new dynamics. */ if (cresc_) - { - assert (!finished_cresc_ && cresc_); - - if (script_) - { - cresc_->set_bound (RIGHT, script_); - add_bound_item (line_spanner_, script_); - } - - finished_cresc_ = cresc_; - announce_end_grob (finished_cresc_, SCM_EOL); - cresc_ = 0; - current_cresc_ev_ = 0; - } + { + assert (!finished_cresc_ && cresc_); + + if (script_) + { + cresc_->set_bound (RIGHT, script_); + add_bound_item (line_spanner_, script_); + } + + finished_cresc_ = cresc_; + announce_end_grob (finished_cresc_, SCM_EOL); + cresc_ = 0; + current_cresc_ev_ = 0; + } else if (accepted_spanevents_drul_[STOP]) - { - accepted_spanevents_drul_[STOP]->origin ()->warning (_ ("cannot find start of (de)crescendo")); - stop_ev = 0; - } + { + accepted_spanevents_drul_[STOP]->origin ()->warning (_ ("cannot find start of (de)crescendo")); + stop_ev = 0; + } } if (accepted_spanevents_drul_[START]) { if (current_cresc_ev_) - { - string msg = _ ("already have a decrescendo"); - if (current_cresc_ev_->in_event_class ("crescendo-event")) - msg = _ ("already have a crescendo"); - - accepted_spanevents_drul_[START]->origin ()->warning (msg); - current_cresc_ev_->origin ()->warning (_ ("cresc starts here")); - } + { + string msg = _ ("already have a decrescendo"); + if (current_cresc_ev_->in_event_class ("crescendo-event")) + msg = _ ("already have a crescendo"); + + accepted_spanevents_drul_[START]->origin ()->warning (msg); + current_cresc_ev_->origin ()->warning (_ ("cresc starts here")); + } else - { - current_cresc_ev_ = accepted_spanevents_drul_[START]; - - if (Direction d = to_dir (current_cresc_ev_->get_property ("direction"))) - set_grob_direction (line_spanner_, d); - - /* - TODO: Use symbols. - */ - - SCM start_sym = current_cresc_ev_->get_property ("class"); - string start_type; - - if (start_sym == ly_symbol2scm ("decrescendo-event")) - start_type = "decrescendo"; - else if (start_sym == ly_symbol2scm ("crescendo-event")) - start_type = "crescendo"; - else - { - programming_error ("unknown dynamic spanner type"); - return; - } - - /* - UGH. TODO: should read from original event, so appearance - may be altered with \tweak. - */ - SCM s = get_property ((start_type + "Spanner").c_str ()); - if (!scm_is_symbol (s) || s == ly_symbol2scm ("hairpin")) - { - cresc_ = make_spanner ("Hairpin", accepted_spanevents_drul_[START]->self_scm ()); - if (finished_cresc_) - { - Pointer_group_interface::add_grob (finished_cresc_, - ly_symbol2scm ("adjacent-hairpins"), - cresc_); - - Pointer_group_interface::add_grob (cresc_, - ly_symbol2scm ("adjacent-hairpins"), - finished_cresc_); - } - } - - /* - This is a convenient (and legacy) interface to TextSpanners - for use in (de)crescendi. - Hmm. - */ - else - { - cresc_ = make_spanner ("DynamicTextSpanner", accepted_spanevents_drul_[START]->self_scm ()); - cresc_->set_property ("style", s); - context ()->set_property ((start_type - + "Spanner").c_str (), SCM_EOL); - s = get_property ((start_type + "Text").c_str ()); - if (Text_interface::is_markup (s)) - { - cresc_->set_property ("text", s); - context ()->set_property ((start_type + "Text").c_str (), - SCM_EOL); - } - - if (script_) - { - set_nested_property (cresc_, - scm_list_3 (ly_symbol2scm ("bound-details"), - ly_symbol2scm ("left"), - ly_symbol2scm ("attach-dir") - ), - scm_from_int (RIGHT)); - } - } - - if (script_) - { - cresc_->set_bound (LEFT, script_); - add_bound_item (line_spanner_, cresc_->get_bound (LEFT)); - } - Axis_group_interface::add_element (line_spanner_, cresc_); - } + { + current_cresc_ev_ = accepted_spanevents_drul_[START]; + + if (Direction d = to_dir (current_cresc_ev_->get_property ("direction"))) + set_grob_direction (line_spanner_, d); + + /* + TODO: Use symbols. + */ + + SCM start_sym = current_cresc_ev_->get_property ("class"); + string start_type; + + if (start_sym == ly_symbol2scm ("decrescendo-event")) + start_type = "decrescendo"; + else if (start_sym == ly_symbol2scm ("crescendo-event")) + start_type = "crescendo"; + else + { + programming_error ("unknown dynamic spanner type"); + return; + } + + /* + UGH. TODO: should read from original event, so appearance + may be altered with \tweak. + */ + SCM s = get_property ((start_type + "Spanner").c_str ()); + if (!scm_is_symbol (s) || s == ly_symbol2scm ("hairpin")) + { + cresc_ = make_spanner ("Hairpin", accepted_spanevents_drul_[START]->self_scm ()); + if (finished_cresc_) + { + Pointer_group_interface::add_grob (finished_cresc_, + ly_symbol2scm ("adjacent-hairpins"), + cresc_); + + Pointer_group_interface::add_grob (cresc_, + ly_symbol2scm ("adjacent-hairpins"), + finished_cresc_); + } + } + + /* + This is a convenient (and legacy) interface to TextSpanners + for use in (de)crescendi. + Hmm. + */ + else + { + cresc_ = make_spanner ("DynamicTextSpanner", accepted_spanevents_drul_[START]->self_scm ()); + cresc_->set_property ("style", s); + context ()->set_property ((start_type + + "Spanner").c_str (), SCM_EOL); + s = get_property ((start_type + "Text").c_str ()); + if (Text_interface::is_markup (s)) + { + cresc_->set_property ("text", s); + context ()->set_property ((start_type + "Text").c_str (), + SCM_EOL); + } + + if (script_) + { + set_nested_property (cresc_, + scm_list_3 (ly_symbol2scm ("bound-details"), + ly_symbol2scm ("left"), + ly_symbol2scm ("attach-dir") + ), + scm_from_int (RIGHT)); + } + } + + if (script_) + { + cresc_->set_bound (LEFT, script_); + add_bound_item (line_spanner_, cresc_->get_bound (LEFT)); + } + Axis_group_interface::add_element (line_spanner_, cresc_); + } } } @@ -348,18 +348,18 @@ Dynamic_engraver::typeset_all () if (finished_cresc_) { if (!finished_cresc_->get_bound (RIGHT)) - { - - Grob *column_bound = unsmob_grob (get_property ("currentMusicalColumn")); - - finished_cresc_->set_bound (RIGHT, script_ - ? script_ - : column_bound); - - if (finished_line_spanner_) - add_bound_item (finished_line_spanner_, - finished_cresc_->get_bound (RIGHT)); - } + { + + Grob *column_bound = unsmob_grob (get_property ("currentMusicalColumn")); + + finished_cresc_->set_bound (RIGHT, script_ + ? script_ + : column_bound); + + if (finished_line_spanner_) + add_bound_item (finished_line_spanner_, + finished_cresc_->get_bound (RIGHT)); + } finished_cresc_ = 0; } @@ -367,33 +367,33 @@ Dynamic_engraver::typeset_all () if (finished_line_spanner_) { /* - We used to have + We used to have - extend-spanner-over-elements (finished_line_spanner_); + extend-spanner-over-elements (finished_line_spanner_); - but this is rather kludgy, since finished_line_spanner_ - typically has a staff-symbol field set , extending it over the - entire staff. + but this is rather kludgy, since finished_line_spanner_ + typically has a staff-symbol field set , extending it over the + entire staff. */ Grob *l = finished_line_spanner_->get_bound (LEFT); Grob *r = finished_line_spanner_->get_bound (RIGHT); if (!r && l) - finished_line_spanner_->set_bound (RIGHT, l); + finished_line_spanner_->set_bound (RIGHT, l); else if (!l && r) - finished_line_spanner_->set_bound (LEFT, r); + finished_line_spanner_->set_bound (LEFT, r); else if (!r && !l) - { - /* - This is a isolated dynamic apparently, and does not even have - any interesting support item. - */ - Grob *cc = unsmob_grob (get_property ("currentMusicalColumn")); - Item *ci = dynamic_cast<Item *> (cc); - finished_line_spanner_->set_bound (RIGHT, ci); - finished_line_spanner_->set_bound (LEFT, ci); - } + { + /* + This is a isolated dynamic apparently, and does not even have + any interesting support item. + */ + Grob *cc = unsmob_grob (get_property ("currentMusicalColumn")); + Item *ci = dynamic_cast<Item *> (cc); + finished_line_spanner_->set_bound (RIGHT, ci); + finished_line_spanner_->set_bound (LEFT, ci); + } finished_line_spanner_ = 0; } } @@ -416,20 +416,20 @@ Dynamic_engraver::acknowledge_note_column (Grob_info info) { extract_grob_set (info.grob (), "note-heads", heads); if (heads.size ()) - { - Grob *head = heads[0]; - script_->set_parent (head, X_AXIS); - Self_alignment_interface::set_center_parent (script_, X_AXIS); - } + { + Grob *head = heads[0]; + script_->set_parent (head, X_AXIS); + Self_alignment_interface::set_center_parent (script_, X_AXIS); + } } if (cresc_) { if (!cresc_->get_bound (LEFT)) - { - cresc_->set_bound (LEFT, info.grob ()); - add_bound_item (line_spanner_, cresc_->get_bound (LEFT)); - } + { + cresc_->set_bound (LEFT, info.grob ()); + add_bound_item (line_spanner_, cresc_->get_bound (LEFT)); + } } if (finished_cresc_ && !finished_cresc_->get_bound (RIGHT)) @@ -439,21 +439,21 @@ Dynamic_engraver::acknowledge_note_column (Grob_info info) ADD_ACKNOWLEDGER (Dynamic_engraver, note_column); ADD_TRANSLATOR (Dynamic_engraver, - /* doc */ - "Create hairpins, dynamic texts, and their vertical" - " alignments. The symbols are collected onto a" - " @code{DynamicLineSpanner} grob which takes care of vertical" - " positioning.", - - /* create */ - "DynamicLineSpanner " - "DynamicTextSpanner " - "DynamicText " - "Hairpin ", - - /* read */ - "", - - /* write */ - "" - ); + /* doc */ + "Create hairpins, dynamic texts, and their vertical" + " alignments. The symbols are collected onto a" + " @code{DynamicLineSpanner} grob which takes care of vertical" + " positioning.", + + /* create */ + "DynamicLineSpanner " + "DynamicTextSpanner " + "DynamicText " + "Hairpin ", + + /* read */ + "", + + /* write */ + "" + ); diff --git a/lily/dynamic-performer.cc b/lily/dynamic-performer.cc index d96545af95..3977a77c30 100644 --- a/lily/dynamic-performer.cc +++ b/lily/dynamic-performer.cc @@ -37,8 +37,8 @@ protected: DECLARE_TRANSLATOR_LISTENER (absolute_dynamic); private: Stream_event *script_event_; - Drul_array<Stream_event*> span_events_; - Drul_array<Direction> grow_dir_; + Drul_array<Stream_event *> span_events_; + Drul_array<Direction> grow_dir_; Real last_volume_; Audio_dynamic *absolute_; Audio_span_dynamic *span_dynamic_; @@ -50,8 +50,8 @@ Dynamic_performer::Dynamic_performer () last_volume_ = 0.5; script_event_ = 0; absolute_ = 0; - span_events_[LEFT] = - span_events_[RIGHT] = 0; + span_events_[LEFT] + = span_events_[RIGHT] = 0; span_dynamic_ = 0; finished_span_dynamic_ = 0; } @@ -68,38 +68,37 @@ Dynamic_performer::equalize_volume (Real volume) { Interval iv (0, 1); if (scm_is_number (min)) - iv[MIN] = scm_to_double (min); + iv[MIN] = scm_to_double (min); if (scm_is_number (max)) - iv[MAX] = scm_to_double (max); + iv[MAX] = scm_to_double (max); volume = iv[MIN] + iv.length () * volume; } else { /* - urg, code duplication:: staff_performer + urg, code duplication:: staff_performer */ SCM s = get_property ("midiInstrument"); if (!scm_is_string (s)) - s = get_property ("instrumentName"); + s = get_property ("instrumentName"); if (!scm_is_string (s)) - s = scm_from_locale_string ("piano"); + s = scm_from_locale_string ("piano"); SCM eq = get_property ("instrumentEqualizer"); if (ly_is_procedure (eq)) - s = scm_call_1 (eq, s); + s = scm_call_1 (eq, s); if (is_number_pair (s)) - { - Interval iv = ly_scm2interval (s); - volume = iv[MIN] + iv.length () * volume; - } + { + Interval iv = ly_scm2interval (s); + volume = iv[MIN] + iv.length () * volume; + } } return volume; } - void Dynamic_performer::process_music () { @@ -124,22 +123,22 @@ Dynamic_performer::process_music () absolute_ = new Audio_dynamic (); if (script_event_) - { - SCM proc = get_property ("dynamicAbsoluteVolumeFunction"); - - SCM svolume = SCM_EOL; - if (ly_is_procedure (proc)) - { - // urg - svolume = scm_call_1 (proc, script_event_->get_property ("text")); - } - - Real volume = robust_scm2double (svolume, 0.5); - - last_volume_ - = absolute_->volume_ = equalize_volume (volume); - } - + { + SCM proc = get_property ("dynamicAbsoluteVolumeFunction"); + + SCM svolume = SCM_EOL; + if (ly_is_procedure (proc)) + { + // urg + svolume = scm_call_1 (proc, script_event_->get_property ("text")); + } + + Real volume = robust_scm2double (svolume, 0.5); + + last_volume_ + = absolute_->volume_ = equalize_volume (volume); + } + Audio_element_info info (absolute_, script_event_); announce_element (info); } @@ -159,7 +158,7 @@ Dynamic_performer::stop_translation_timestep () finished_span_dynamic_->render (); finished_span_dynamic_ = 0; } - + if (absolute_ && absolute_->volume_ < 0) { absolute_->volume_ = last_volume_; @@ -168,11 +167,11 @@ Dynamic_performer::stop_translation_timestep () { last_volume_ = absolute_->volume_; } - + absolute_ = 0; script_event_ = 0; - span_events_[LEFT] = - span_events_[RIGHT] = 0; + span_events_[LEFT] + = span_events_[RIGHT] = 0; } IMPLEMENT_TRANSLATOR_LISTENER (Dynamic_performer, decrescendo); @@ -202,19 +201,19 @@ Dynamic_performer::listen_absolute_dynamic (Stream_event *r) } ADD_TRANSLATOR (Dynamic_performer, - /* doc */ - "", - - /* create */ - "", - - /* read */ - "dynamicAbsoluteVolumeFunction " - "instrumentEqualizer " - "midiMaximumVolume " - "midiMinimumVolume " - "midiInstrument ", - - /* write */ - "" - ); + /* doc */ + "", + + /* create */ + "", + + /* read */ + "dynamicAbsoluteVolumeFunction " + "instrumentEqualizer " + "midiMaximumVolume " + "midiMinimumVolume " + "midiInstrument ", + + /* write */ + "" + ); diff --git a/lily/enclosing-bracket.cc b/lily/enclosing-bracket.cc index d7cd672843..2b1412d2f0 100644 --- a/lily/enclosing-bracket.cc +++ b/lily/enclosing-bracket.cc @@ -27,27 +27,25 @@ struct Enclosing_bracket { DECLARE_GROB_INTERFACE (); - + public: DECLARE_SCHEME_CALLBACK (print, (SCM)); DECLARE_SCHEME_CALLBACK (width, (SCM)); }; - ADD_INTERFACE (Enclosing_bracket, - "Brackets alongside bass figures.", - - /* properties */ - "bracket-flare " - "edge-height " - "elements " - "padding " - "shorten-pair " - "thickness " - ); + "Brackets alongside bass figures.", -/* ugh: should make bracket interface. */ + /* properties */ + "bracket-flare " + "edge-height " + "elements " + "padding " + "shorten-pair " + "thickness " + ); +/* ugh: should make bracket interface. */ MAKE_SCHEME_CALLBACK (Enclosing_bracket, width, 1); SCM @@ -64,13 +62,12 @@ Enclosing_bracket::width (SCM grob) return SCM_EOL; } - Grob *common_x = common_refpoint_of_array (elements, me, X_AXIS); + Grob *common_x = common_refpoint_of_array (elements, me, X_AXIS); Interval xext = Axis_group_interface::relative_group_extent (elements, common_x, X_AXIS); Stencil left_br = Horizontal_bracket::make_bracket (me, 10.0, Y_AXIS, LEFT); Stencil right_br = Horizontal_bracket::make_bracket (me, 10.0, Y_AXIS, LEFT); - xext.widen (robust_scm2double (me->get_property ("padding"), 0.25)); left_br.translate_axis (xext[LEFT], X_AXIS); right_br.translate_axis (xext[RIGHT], X_AXIS); @@ -93,7 +90,7 @@ Enclosing_bracket::print (SCM grob) return SCM_EOL; } - Grob *common_x = common_refpoint_of_array (elements, me, X_AXIS); + Grob *common_x = common_refpoint_of_array (elements, me, X_AXIS); Interval xext = Axis_group_interface::relative_group_extent (elements, common_x, X_AXIS); if (xext.is_empty ()) { @@ -102,14 +99,14 @@ Enclosing_bracket::print (SCM grob) } Stencil left_br = Horizontal_bracket::make_enclosing_bracket (me, me, elements, - Y_AXIS, LEFT); + Y_AXIS, LEFT); Stencil right_br = Horizontal_bracket::make_enclosing_bracket (me, me, elements, - Y_AXIS, RIGHT); + Y_AXIS, RIGHT); xext.widen (robust_scm2double (me->get_property ("padding"), 0.25)); left_br.translate_axis (xext[LEFT], X_AXIS); right_br.translate_axis (xext[RIGHT], X_AXIS); - + left_br.add_stencil (right_br); left_br.translate_axis (-me->relative_coordinate (common_x, X_AXIS), X_AXIS); diff --git a/lily/engraver-group.cc b/lily/engraver-group.cc index a5782d23b0..d7921ce0b4 100644 --- a/lily/engraver-group.cc +++ b/lily/engraver-group.cc @@ -30,11 +30,11 @@ void Engraver_group::override (SCM sev) { Stream_event *ev = unsmob_stream_event (sev); - + sloppy_general_pushpop_property (context (), - ev->get_property ("symbol"), - ev->get_property ("property-path"), - ev->get_property ("value")); + ev->get_property ("symbol"), + ev->get_property ("property-path"), + ev->get_property ("value")); } IMPLEMENT_LISTENER (Engraver_group, revert); @@ -42,11 +42,11 @@ void Engraver_group::revert (SCM sev) { Stream_event *ev = unsmob_stream_event (sev); - + sloppy_general_pushpop_property (context (), - ev->get_property ("symbol"), - ev->get_property ("property-path"), - SCM_UNDEFINED); + ev->get_property ("symbol"), + ev->get_property ("property-path"), + SCM_UNDEFINED); } void @@ -79,8 +79,8 @@ Engraver_group::announce_grob (Grob_info info) Engraver_group *dad_eng = dad_con - ? dynamic_cast<Engraver_group *> (dad_con->implementation ()) - : 0; + ? dynamic_cast<Engraver_group *> (dad_con->implementation ()) + : 0; if (dad_eng) dad_eng->announce_grob (info); @@ -98,35 +98,35 @@ Engraver_group::acknowledge_grobs () for (vsize j = 0; j < announce_infos_.size (); j++) { Grob_info info = announce_infos_[j]; - + SCM meta = info.grob ()->internal_get_property (meta_sym); SCM nm = scm_assoc (name_sym, meta); if (scm_is_pair (nm)) - nm = scm_cdr (nm); + nm = scm_cdr (nm); else - continue; + continue; SCM acklist = scm_hashq_ref (acknowledge_hash_table_drul_[info.start_end ()], - nm, SCM_BOOL_F); - + nm, SCM_BOOL_F); + Engraver_dispatch_list *dispatch - = Engraver_dispatch_list::unsmob (acklist); + = Engraver_dispatch_list::unsmob (acklist); if (acklist == SCM_BOOL_F) - { - SCM ifaces - = scm_cdr (scm_assoc (ly_symbol2scm ("interfaces"), meta)); - acklist = Engraver_dispatch_list::create (get_simple_trans_list (), - ifaces, info.start_end ()); + { + SCM ifaces + = scm_cdr (scm_assoc (ly_symbol2scm ("interfaces"), meta)); + acklist = Engraver_dispatch_list::create (get_simple_trans_list (), + ifaces, info.start_end ()); - dispatch - = Engraver_dispatch_list::unsmob (acklist); + dispatch + = Engraver_dispatch_list::unsmob (acklist); - scm_hashq_set_x (acknowledge_hash_table_drul_[info.start_end ()], nm, acklist); - } + scm_hashq_set_x (acknowledge_hash_table_drul_[info.start_end ()], nm, acklist); + } if (dispatch) - dispatch->apply (info); + dispatch->apply (info); } } @@ -143,10 +143,10 @@ Engraver_group::pending_grob_count () const { Context *c = unsmob_context (scm_car (s)); Engraver_group *group - = dynamic_cast<Engraver_group *> (c->implementation ()); + = dynamic_cast<Engraver_group *> (c->implementation ()); if (group) - count += group->pending_grob_count (); + count += group->pending_grob_count (); } return count; } @@ -157,38 +157,37 @@ Engraver_group::do_announces () do { /* - DOCME: why is this inside the loop? + DOCME: why is this inside the loop? */ for (SCM s = context ()->children_contexts (); - scm_is_pair (s); s = scm_cdr (s)) - { - Context *c = unsmob_context (scm_car (s)); - Engraver_group *group - = dynamic_cast<Engraver_group *> (c->implementation ()); - if (group) - group->do_announces (); - } - - + scm_is_pair (s); s = scm_cdr (s)) + { + Context *c = unsmob_context (scm_car (s)); + Engraver_group *group + = dynamic_cast<Engraver_group *> (c->implementation ()); + if (group) + group->do_announces (); + } + while (1) - { - precomputed_translator_foreach (PROCESS_ACKNOWLEDGED); - if (announce_infos_.size () == 0) - break; - - acknowledge_grobs (); - announce_infos_.clear (); - } + { + precomputed_translator_foreach (PROCESS_ACKNOWLEDGED); + if (announce_infos_.size () == 0) + break; + + acknowledge_grobs (); + announce_infos_.clear (); + } } while (pending_grob_count () > 0); } Engraver_group::Engraver_group () { - acknowledge_hash_table_drul_[LEFT] - = acknowledge_hash_table_drul_[RIGHT] - = SCM_EOL; - + acknowledge_hash_table_drul_[LEFT] + = acknowledge_hash_table_drul_[RIGHT] + = SCM_EOL; + acknowledge_hash_table_drul_[LEFT] = scm_c_make_hash_table (61); acknowledge_hash_table_drul_[RIGHT] = scm_c_make_hash_table (61); } @@ -196,18 +195,18 @@ Engraver_group::Engraver_group () #include "translator.icc" ADD_TRANSLATOR_GROUP (Engraver_group, - /* doc */ - "A group of engravers taken together.", + /* doc */ + "A group of engravers taken together.", - /* create */ - "", + /* create */ + "", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); void Engraver_group::derived_mark () const diff --git a/lily/engraver-scheme.cc b/lily/engraver-scheme.cc index fa71a1444b..a6e98b8c79 100644 --- a/lily/engraver-scheme.cc +++ b/lily/engraver-scheme.cc @@ -21,36 +21,36 @@ #include "grob.hh" LY_DEFINE (ly_engraver_make_grob, "ly:engraver-make-grob", - 3, 0, 0, (SCM engraver, SCM grob_name, SCM cause), - "Create a grob originating from given @var{engraver} instance," - " with given @var{grob-name}, a symbol." - " @var{cause} should either be another grob" - " or a music event.") + 3, 0, 0, (SCM engraver, SCM grob_name, SCM cause), + "Create a grob originating from given @var{engraver} instance," + " with given @var{grob-name}, a symbol." + " @var{cause} should either be another grob" + " or a music event.") { LY_ASSERT_TYPE (unsmob_engraver, engraver, 1); LY_ASSERT_TYPE (ly_is_symbol, grob_name, 2); LY_ASSERT_TYPE (ly_is_grob_cause, cause, 3); Grob *g = unsmob_engraver (engraver)-> - internal_make_grob(grob_name, cause, - ly_symbol2string (grob_name).c_str (), - "scheme", 0, "scheme"); + internal_make_grob (grob_name, cause, + ly_symbol2string (grob_name).c_str (), + "scheme", 0, "scheme"); return g->self_scm (); } LY_DEFINE (ly_engraver_announce_end_grob, "ly:engraver-announce-end-grob", - 3, 0, 0, (SCM engraver, SCM grob, SCM cause), - "Announce the end of a grob (i.e., the end of a spanner)" - " originating from given @var{engraver} instance, with" - " @var{grob} being a grob. @var{cause} should either" - " be another grob or a music event.") + 3, 0, 0, (SCM engraver, SCM grob, SCM cause), + "Announce the end of a grob (i.e., the end of a spanner)" + " originating from given @var{engraver} instance, with" + " @var{grob} being a grob. @var{cause} should either" + " be another grob or a music event.") { LY_ASSERT_TYPE (unsmob_engraver, engraver, 1); LY_ASSERT_SMOB (Grob, grob, 2); LY_ASSERT_TYPE (ly_is_grob_cause, cause, 3); unsmob_engraver (engraver)-> - announce_end_grob (unsmob_grob (grob), cause); + announce_end_grob (unsmob_grob (grob), cause); return SCM_UNSPECIFIED; } diff --git a/lily/engraver.cc b/lily/engraver.cc index 12615eb8d6..d8ece19ee2 100644 --- a/lily/engraver.cc +++ b/lily/engraver.cc @@ -48,7 +48,7 @@ Engraver::announce_end_grob (Grob_info inf) } Grob_info -Engraver::make_grob_info(Grob *e, SCM cause) +Engraver::make_grob_info (Grob *e, SCM cause) { /* TODO: Remove Music code when it's no longer needed */ if (Music *m = unsmob_music (cause)) @@ -72,7 +72,6 @@ Engraver::announce_grob (Grob *e, SCM cause) announce_grob (make_grob_info (e, cause)); } - /* CAUSE is the object (typically a grob or stream-event object) that was the reason for ending E. */ @@ -82,7 +81,6 @@ Engraver::announce_end_grob (Grob *e, SCM cause) announce_end_grob (make_grob_info (e, cause)); } - Engraver::Engraver () { } @@ -90,12 +88,12 @@ Engraver::Engraver () #ifndef NDEBUG static SCM creation_callback = SCM_EOL; LY_DEFINE (ly_set_grob_creation_callback, "ly:set-grob-creation-callback", - 1, 0, 0, (SCM cb), - "Specify a procedure that will be called every time a new grob" - " is created. The callback will receive as arguments the grob" - " that was created, the name of the C++ source file that caused" - " the grob to be created, and the corresponding line number in" - " the C++ source file.") + 1, 0, 0, (SCM cb), + "Specify a procedure that will be called every time a new grob" + " is created. The callback will receive as arguments the grob" + " that was created, the name of the C++ source file that caused" + " the grob to be created, and the corresponding line number in" + " the C++ source file.") { LY_ASSERT_TYPE (ly_is_procedure, cb, 1); @@ -107,11 +105,11 @@ LY_DEFINE (ly_set_grob_creation_callback, "ly:set-grob-creation-callback", Grob * Engraver::internal_make_grob (SCM symbol, - SCM cause, - char const * /* name */, - char const *file, - int line, - char const *fun) + SCM cause, + char const * /* name */, + char const *file, + int line, + char const *fun) { #ifdef NDEBUG (void)file; @@ -139,8 +137,8 @@ Engraver::internal_make_grob (SCM symbol, #ifndef NDEBUG if (ly_is_procedure (creation_callback)) scm_apply_0 (creation_callback, - scm_list_n (grob->self_scm (), scm_from_locale_string (file), - scm_from_int (line), scm_from_locale_string (fun), SCM_UNDEFINED)); + scm_list_n (grob->self_scm (), scm_from_locale_string (file), + scm_from_int (line), scm_from_locale_string (fun), SCM_UNDEFINED)); #endif return grob; @@ -148,8 +146,8 @@ Engraver::internal_make_grob (SCM symbol, Item * Engraver::internal_make_item (SCM x, SCM cause, - char const *name, - char const *file, int line, char const *fun) + char const *name, + char const *file, int line, char const *fun) { Item *it = dynamic_cast<Item *> (internal_make_grob (x, cause, name, file, line, fun)); assert (it); @@ -158,24 +156,24 @@ Engraver::internal_make_item (SCM x, SCM cause, Paper_column * Engraver::internal_make_column (SCM x, char const *name, - char const *file, int line, char const *fun) + char const *file, int line, char const *fun) { return dynamic_cast<Paper_column *> (internal_make_grob (x, SCM_EOL, name, file, line, fun)); } Spanner * Engraver::internal_make_spanner (SCM x, SCM cause, char const *name, - char const *file, int line, char const *fun) + char const *file, int line, char const *fun) { Spanner *sp = dynamic_cast<Spanner *> (internal_make_grob (x, cause, name, file, line, fun)); assert (sp); return sp; } -Engraver* +Engraver * unsmob_engraver (SCM eng) { - return dynamic_cast<Engraver*> (unsmob_translator (eng)); + return dynamic_cast<Engraver *> (unsmob_translator (eng)); } bool @@ -187,17 +185,16 @@ ly_is_grob_cause (SCM obj) #include "translator.icc" ADD_TRANSLATOR (Engraver, - /* doc */ - "Base class for engravers. Does nothing, so it is not used.", - - /* create */ - "", + /* doc */ + "Base class for engravers. Does nothing, so it is not used.", - /* read */ - "", + /* create */ + "", - /* write */ - "" - ); + /* read */ + "", + /* write */ + "" + ); diff --git a/lily/episema-engraver.cc b/lily/episema-engraver.cc index 38d3950848..bcb48f53fa 100644 --- a/lily/episema-engraver.cc +++ b/lily/episema-engraver.cc @@ -72,28 +72,28 @@ Episema_engraver::process_music () if (event_drul_[START]) { if (current_event_) - event_drul_[START]->origin ()->warning (_ ("already have an episema")); + event_drul_[START]->origin ()->warning (_ ("already have an episema")); else - { - current_event_ = event_drul_[START]; - span_ = make_spanner ("Episema", event_drul_[START]->self_scm ()); + { + current_event_ = event_drul_[START]; + span_ = make_spanner ("Episema", event_drul_[START]->self_scm ()); - event_drul_[START] = 0; - } + event_drul_[START] = 0; + } } if (event_drul_[STOP]) { if (!span_) - event_drul_[STOP] - ->origin ()->warning (_ ("cannot find start of episema")); + event_drul_[STOP] + ->origin ()->warning (_ ("cannot find start of episema")); else - { - finished_ = span_; - announce_end_grob (finished_, SCM_EOL); - span_ = 0; - current_event_ = 0; - note_columns_.clear (); - } + { + finished_ = span_; + announce_end_grob (finished_, SCM_EOL); + span_ = 0; + current_event_ = 0; + note_columns_.clear (); + } } } @@ -103,12 +103,12 @@ Episema_engraver::typeset_all () if (finished_) { if (!finished_->get_bound (RIGHT)) - { - Grob *col = (note_columns_.size () - ? note_columns_.back () - : unsmob_grob (get_property ("currentMusicalColumn"))); - finished_->set_bound (RIGHT, col); - } + { + Grob *col = (note_columns_.size () + ? note_columns_.back () + : unsmob_grob (get_property ("currentMusicalColumn"))); + finished_->set_bound (RIGHT, col); + } finished_ = 0; } } @@ -119,8 +119,8 @@ Episema_engraver::stop_translation_timestep () if (span_ && !span_->get_bound (LEFT)) { Grob *col = (note_columns_.size () - ? note_columns_.front () - : unsmob_grob (get_property ("currentMusicalColumn"))); + ? note_columns_.front () + : unsmob_grob (get_property ("currentMusicalColumn"))); span_->set_bound (LEFT, col); } @@ -165,15 +165,15 @@ ADD_ACKNOWLEDGER (Episema_engraver, note_column); ADD_ACKNOWLEDGER (Episema_engraver, note_head); ADD_TRANSLATOR (Episema_engraver, - /* doc */ - "Create an @emph{Editio Vaticana}-style episema line.", + /* doc */ + "Create an @emph{Editio Vaticana}-style episema line.", - /* create */ - "Episema ", + /* create */ + "Episema ", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/event-chord-iterator.cc b/lily/event-chord-iterator.cc index a22c9ace6b..4cda2d62bc 100644 --- a/lily/event-chord-iterator.cc +++ b/lily/event-chord-iterator.cc @@ -44,17 +44,17 @@ Event_chord_iterator::process (Moment m) if (last_processed_mom_ < Moment (0)) { for (SCM s = get_music ()->get_property ("elements"); - scm_is_pair (s); s = scm_cdr (s)) - { - Music *mus = unsmob_music (scm_car (s)); - report_event (mus); - } + scm_is_pair (s); s = scm_cdr (s)) + { + Music *mus = unsmob_music (scm_car (s)); + report_event (mus); + } for (SCM s = get_music ()->get_property ("events"); - scm_is_pair (s); s = scm_cdr (s)) - { - Stream_event *ev = unsmob_stream_event (scm_car (s)); - get_outlet ()->event_source ()->broadcast (ev); - } + scm_is_pair (s); s = scm_cdr (s)) + { + Stream_event *ev = unsmob_stream_event (scm_car (s)); + get_outlet ()->event_source ()->broadcast (ev); + } } Simple_music_iterator::process (m); } diff --git a/lily/extender-engraver.cc b/lily/extender-engraver.cc index 49fcbcaf3f..a31a793ff1 100644 --- a/lily/extender-engraver.cc +++ b/lily/extender-engraver.cc @@ -67,7 +67,6 @@ Extender_engraver::listen_extender (Stream_event *ev) ASSIGN_EVENT_ONCE (ev_, ev); } - /* A CompletizeExtenderEvent is sent at the end of each lyrics block to ensure any pending extender can be correctly terminated if the lyrics @@ -116,33 +115,33 @@ Extender_engraver::stop_translation_timestep () Grob *h = voice ? get_current_note_head (voice, to_boolean (get_property ("includeGraceNotes"))) : 0; if (h) - { - if (extender_) - { - Pointer_group_interface::add_grob (extender_, - ly_symbol2scm ("heads"), h); - } - - if (pending_extender_) - { - Pointer_group_interface::add_grob (pending_extender_, - ly_symbol2scm ("heads"), h); - } - } + { + if (extender_) + { + Pointer_group_interface::add_grob (extender_, + ly_symbol2scm ("heads"), h); + } + + if (pending_extender_) + { + Pointer_group_interface::add_grob (pending_extender_, + ly_symbol2scm ("heads"), h); + } + } else - { - if (pending_extender_ - && !get_property ("extendersOverRests")) - { - completize_extender (pending_extender_); - pending_extender_ = 0; - } - } + { + if (pending_extender_ + && !get_property ("extendersOverRests")) + { + completize_extender (pending_extender_); + pending_extender_ = 0; + } + } if (extender_) - { - pending_extender_ = extender_; - extender_ = 0; - } + { + pending_extender_ = extender_; + extender_ = 0; + } } ev_ = 0; @@ -155,7 +154,7 @@ completize_extender (Spanner *sp) { extract_item_set (sp, "heads", heads); if (heads.size ()) - sp->set_bound (RIGHT, heads.back ()); + sp->set_bound (RIGHT, heads.back ()); } } @@ -167,7 +166,7 @@ Extender_engraver::finalize () completize_extender (extender_); if (!extender_->get_bound (RIGHT)) - extender_->warning (_ ("unterminated extender")); + extender_->warning (_ ("unterminated extender")); extender_ = 0; } @@ -176,23 +175,23 @@ Extender_engraver::finalize () completize_extender (pending_extender_); if (!pending_extender_->get_bound (RIGHT)) - pending_extender_->warning (_ ("unterminated extender")); + pending_extender_->warning (_ ("unterminated extender")); pending_extender_ = 0; } } ADD_ACKNOWLEDGER (Extender_engraver, lyric_syllable); ADD_TRANSLATOR (Extender_engraver, - /* doc */ - "Create lyric extenders.", + /* doc */ + "Create lyric extenders.", - /* create */ - "LyricExtender ", + /* create */ + "LyricExtender ", - /* read */ - "extendersOverRests " - "includeGraceNotes ", + /* read */ + "extendersOverRests " + "includeGraceNotes ", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/figured-bass-continuation.cc b/lily/figured-bass-continuation.cc index 7fd868c559..0278c9f3d3 100644 --- a/lily/figured-bass-continuation.cc +++ b/lily/figured-bass-continuation.cc @@ -26,13 +26,12 @@ #include "pointer-group-interface.hh" #include "axis-group-interface.hh" - #include "horizontal-bracket.hh" struct Figured_bass_continuation { DECLARE_GROB_INTERFACE (); - + public: DECLARE_SCHEME_CALLBACK (print, (SCM)); DECLARE_SCHEME_CALLBACK (center_on_figures, (SCM)); @@ -42,7 +41,7 @@ MAKE_SCHEME_CALLBACK (Figured_bass_continuation, center_on_figures, 1); SCM Figured_bass_continuation::center_on_figures (SCM grob) { - Spanner *me = dynamic_cast<Spanner*> (unsmob_grob (grob)); + Spanner *me = dynamic_cast<Spanner *> (unsmob_grob (grob)); extract_grob_set (me, "figures", figures); if (figures.empty ()) return scm_from_double (0.0); @@ -58,45 +57,45 @@ MAKE_SCHEME_CALLBACK (Figured_bass_continuation, print, 1); SCM Figured_bass_continuation::print (SCM grob) { - Spanner *me = dynamic_cast<Spanner*> (unsmob_grob (grob)); + Spanner *me = dynamic_cast<Spanner *> (unsmob_grob (grob)); + + Real thick + = me->layout ()->get_dimension (ly_symbol2scm ("line-thickness")) + * robust_scm2double (me->get_property ("thickness"), 1); - Real thick = - me->layout ()->get_dimension (ly_symbol2scm ("line-thickness")) - * robust_scm2double (me->get_property ("thickness"), 1); - Interval spanned; Direction d = LEFT; Grob *common = me->get_bound (LEFT)->common_refpoint (me->get_bound (RIGHT), - X_AXIS); + X_AXIS); do { Item *bound = me->get_bound (d); - Direction extdir = - (d == LEFT && to_boolean (bound->get_property ("implicit"))) - ? LEFT : RIGHT; + Direction extdir + = (d == LEFT && to_boolean (bound->get_property ("implicit"))) + ? LEFT : RIGHT; - spanned[d] - = robust_relative_extent (bound, common, X_AXIS)[extdir] - - me->relative_coordinate (common, X_AXIS); + spanned[d] + = robust_relative_extent (bound, common, X_AXIS)[extdir] + - me->relative_coordinate (common, X_AXIS); } - while (flip (&d) != LEFT); + while (flip (&d) != LEFT); spanned.widen (- robust_scm2double (me->get_property ("padding"), 0.2)); - + Stencil extender; if (!spanned.is_empty ()) extender = Line_interface::make_line (thick, - Offset (spanned[LEFT], 0), - Offset (spanned[RIGHT], 0)); - + Offset (spanned[LEFT], 0), + Offset (spanned[RIGHT], 0)); + return extender.smobbed_copy (); } ADD_INTERFACE (Figured_bass_continuation, - "Simple extender line between bounds.", - - /* properties */ - "thickness " - "padding " - "figures " - ); - + "Simple extender line between bounds.", + + /* properties */ + "thickness " + "padding " + "figures " + ); + diff --git a/lily/figured-bass-engraver.cc b/lily/figured-bass-engraver.cc index c0b4c09b92..18b895660f 100644 --- a/lily/figured-bass-engraver.cc +++ b/lily/figured-bass-engraver.cc @@ -110,7 +110,7 @@ struct Figured_bass_engraver : public Engraver void add_brackets (); void create_grobs (); - void center_continuations (vector<Spanner*> const &consecutive_lines); + void center_continuations (vector<Spanner *> const &consecutive_lines); void center_repeated_continuations (); protected: vector<Figure_group> groups_; @@ -154,7 +154,7 @@ Figured_bass_engraver::start_translation_timestep () { if (now_mom ().main_part_ < stop_moment_.main_part_ || now_mom ().grace_part_ < Rational (0)) - return ; + return; have_rest_ = 0; new_events_.clear (); @@ -170,11 +170,11 @@ Figured_bass_engraver::stop_translation_timestep () if (groups_.empty () || now_mom ().main_part_ < stop_moment_.main_part_ || now_mom ().grace_part_ < Rational (0)) - return ; + return; bool found = false; for (vsize i = 0; !found && i < groups_.size (); i++) - found = found || groups_[i].current_event_; + found = found || groups_[i].current_event_; if (!found) clear_spanners (); @@ -192,7 +192,7 @@ void Figured_bass_engraver::listen_bass_figure (Stream_event *ev) { new_event_found_ = true; - Moment stop = now_mom () + get_event_length (ev, now_mom ()); + Moment stop = now_mom () + get_event_length (ev, now_mom ()); stop_moment_ = max (stop_moment_, stop); // Handle no-continuation here, don't even add it to the already existing @@ -215,15 +215,15 @@ Figured_bass_engraver::listen_bass_figure (Stream_event *ev) } void -Figured_bass_engraver::center_continuations (vector<Spanner*> const &consecutive_lines) +Figured_bass_engraver::center_continuations (vector<Spanner *> const &consecutive_lines) { if (consecutive_lines.size () == 2) { - vector<Grob*> left_figs; + vector<Grob *> left_figs; for (vsize j = consecutive_lines.size (); j--;) left_figs.push_back (consecutive_lines[j]->get_bound (LEFT)); - SCM ga = Grob_array::make_array (); + SCM ga = Grob_array::make_array (); unsmob_grob_array (ga)->set_array (left_figs); for (vsize j = consecutive_lines.size (); j--;) @@ -235,7 +235,7 @@ Figured_bass_engraver::center_continuations (vector<Spanner*> const &consecutive void Figured_bass_engraver::center_repeated_continuations () { - vector<Spanner*> consecutive_lines; + vector<Spanner *> consecutive_lines; for (vsize i = 0; i <= groups_.size (); i++) { if (i < groups_.size () @@ -270,13 +270,13 @@ Figured_bass_engraver::clear_spanners () { if (groups_[i].group_) { - announce_end_grob (groups_[i].group_ , SCM_EOL); + announce_end_grob (groups_[i].group_, SCM_EOL); groups_[i].group_ = 0; } if (groups_[i].continuation_line_) { - announce_end_grob (groups_[i].continuation_line_ , SCM_EOL); + announce_end_grob (groups_[i].continuation_line_, SCM_EOL); groups_[i].continuation_line_ = 0; } } @@ -293,8 +293,8 @@ Figured_bass_engraver::process_music () // If we have a rest, or we have no new or continued events, clear all spanners bool ignore_rest = to_boolean (get_property ("ignoreFiguredBassRest")); - if ((ignore_rest && have_rest_) || - (!continuation_ && new_events_.empty ())) + if ((ignore_rest && have_rest_) + || (!continuation_ && new_events_.empty ())) { clear_spanners (); groups_.clear (); @@ -358,9 +358,9 @@ Figured_bass_engraver::process_music () { if (!group.continuation_line_) { - Spanner * line + Spanner *line = make_spanner ("BassFigureContinuation", SCM_EOL); - Item * item = group.figure_item_; + Item *item = group.figure_item_; group.continuation_line_ = line; line->set_bound (LEFT, item); @@ -381,13 +381,13 @@ Figured_bass_engraver::process_music () /* Ugh, repeated code. */ - vector<Spanner*> consecutive; + vector<Spanner *> consecutive; if (to_boolean (get_property ("figuredBassCenterContinuations"))) { for (vsize i = 0; i <= junk_continuations.size (); i++) { if (i < junk_continuations.size () - && (i == 0 || junk_continuations[i-1] == junk_continuations[i] - 1)) + && (i == 0 || junk_continuations[i - 1] == junk_continuations[i] - 1)) consecutive.push_back (groups_[junk_continuations[i]].continuation_line_); else { @@ -410,7 +410,7 @@ void Figured_bass_engraver::create_grobs () { Grob *muscol - = dynamic_cast<Item*> (unsmob_grob (get_property ("currentMusicalColumn"))); + = dynamic_cast<Item *> (unsmob_grob (get_property ("currentMusicalColumn"))); if (!alignment_) { alignment_ = make_spanner ("BassFigureAlignment", SCM_EOL); @@ -478,9 +478,9 @@ Figured_bass_engraver::create_grobs () void Figured_bass_engraver::add_brackets () { - vector<Grob*> encompass; + vector<Grob *> encompass; bool inside = false; - for (vsize i = 0; i < groups_.size (); i ++) + for (vsize i = 0; i < groups_.size (); i++) { if (!groups_[i].current_event_) continue; @@ -491,11 +491,11 @@ Figured_bass_engraver::add_brackets () if (inside && groups_[i].figure_item_) encompass.push_back (groups_[i].figure_item_); - if (to_boolean (groups_[i].current_event_->get_property ("bracket-stop"))) + if (to_boolean (groups_[i].current_event_->get_property ("bracket-stop"))) { inside = false; - Item * brack = make_item ("BassFigureBracket", groups_[i].current_event_->self_scm ()); + Item *brack = make_item ("BassFigureBracket", groups_[i].current_event_->self_scm ()); for (vsize j = 0; j < encompass.size (); j++) { Pointer_group_interface::add_grob (brack, @@ -528,4 +528,4 @@ ADD_TRANSLATOR (Figured_bass_engraver, /* write */ "" - ); + ); diff --git a/lily/figured-bass-position-engraver.cc b/lily/figured-bass-position-engraver.cc index 6db165a9ba..a564a9eec2 100644 --- a/lily/figured-bass-position-engraver.cc +++ b/lily/figured-bass-position-engraver.cc @@ -33,8 +33,8 @@ class Figured_bass_position_engraver : public Engraver Spanner *bass_figure_alignment_; Spanner *positioner_; - vector<Grob*> support_; - vector<Grob*> span_support_; + vector<Grob *> support_; + vector<Grob *> span_support_; protected: DECLARE_ACKNOWLEDGER (note_column); DECLARE_ACKNOWLEDGER (slur); @@ -72,13 +72,13 @@ Figured_bass_position_engraver::stop_spanner () { positioner_->set_bound (RIGHT, bass_figure_alignment_->get_bound (RIGHT)); } - + positioner_ = 0; bass_figure_alignment_ = 0; } void -Figured_bass_position_engraver::finalize () +Figured_bass_position_engraver::finalize () { stop_spanner (); } @@ -92,8 +92,8 @@ Figured_bass_position_engraver::acknowledge_note_column (Grob_info info) void Figured_bass_position_engraver::acknowledge_end_slur (Grob_info info) { - vector<Grob*>::iterator i = find (span_support_.begin (), span_support_.end (), - info.grob ()); + vector<Grob *>::iterator i = find (span_support_.begin (), span_support_.end (), + info.grob ()); if (i < span_support_.end ()) span_support_.erase (i); @@ -117,9 +117,9 @@ Figured_bass_position_engraver::stop_translation_timestep () if (positioner_) { for (vsize i = 0; i < span_support_.size (); i++) - Side_position_interface::add_support (positioner_, span_support_[i]); + Side_position_interface::add_support (positioner_, span_support_[i]); for (vsize i = 0; i < support_.size (); i++) - Side_position_interface::add_support (positioner_, support_[i]); + Side_position_interface::add_support (positioner_, support_[i]); } support_.clear (); @@ -134,11 +134,10 @@ Figured_bass_position_engraver::acknowledge_end_bass_figure_alignment (Grob_info void Figured_bass_position_engraver::acknowledge_bass_figure_alignment (Grob_info info) { - bass_figure_alignment_ = dynamic_cast<Spanner*> (info.grob ()); + bass_figure_alignment_ = dynamic_cast<Spanner *> (info.grob ()); start_spanner (); } - ADD_ACKNOWLEDGER (Figured_bass_position_engraver, note_column); ADD_ACKNOWLEDGER (Figured_bass_position_engraver, slur); ADD_END_ACKNOWLEDGER (Figured_bass_position_engraver, slur); @@ -148,15 +147,15 @@ ADD_ACKNOWLEDGER (Figured_bass_position_engraver, bass_figure_alignment); ADD_END_ACKNOWLEDGER (Figured_bass_position_engraver, bass_figure_alignment); ADD_TRANSLATOR (Figured_bass_position_engraver, - /* doc */ - "Position figured bass alignments over notes.", - - /* create */ - "BassFigureAlignmentPositioning ", - - /* read */ - "", - - /* write */ - "" - ); + /* doc */ + "Position figured bass alignments over notes.", + + /* create */ + "BassFigureAlignmentPositioning ", + + /* read */ + "", + + /* write */ + "" + ); diff --git a/lily/file-name-map.cc b/lily/file-name-map.cc index e0fd5d5fba..6074f3a1da 100644 --- a/lily/file-name-map.cc +++ b/lily/file-name-map.cc @@ -34,8 +34,8 @@ map_file_name (string s) } LY_DEFINE (ly_add_file_name_alist, "ly:add-file-name-alist", - 1, 0, 0, (SCM alist), - "Add mappings for error messages from @var{alist}.") + 1, 0, 0, (SCM alist), + "Add mappings for error messages from @var{alist}.") { for (SCM s = alist; scm_is_pair (s); s = scm_cdr (s)) { diff --git a/lily/fingering-engraver.cc b/lily/fingering-engraver.cc index 8002378698..8537e09ab4 100644 --- a/lily/fingering-engraver.cc +++ b/lily/fingering-engraver.cc @@ -30,8 +30,8 @@ class Fingering_engraver : public Engraver { - vector<Stream_event*> events_; - vector<Item*> fingerings_; + vector<Stream_event *> events_; + vector<Item *> fingerings_; public: TRANSLATOR_DECLARATIONS (Fingering_engraver); @@ -60,7 +60,7 @@ Fingering_engraver::listen_stroke_finger (Stream_event * /* ev */) { /* FIXME: should do something. - + This function is mainly here to shut up a warning */ } @@ -80,7 +80,7 @@ Fingering_engraver::acknowledge_rhythmic_head (Grob_info inf) Grob *t = fingerings_[i]; Side_position_interface::add_support (t, inf.grob ()); if (!t->get_parent (X_AXIS)) - t->set_parent (inf.grob (), X_AXIS); + t->set_parent (inf.grob (), X_AXIS); } } @@ -130,9 +130,9 @@ Fingering_engraver::make_script (Direction d, Stream_event *r, int i) if (!is_direction (fingering->get_property_data ("direction"))) { if (d) - fingering->set_property ("direction", scm_from_int (d)); + fingering->set_property ("direction", scm_from_int (d)); else - fingering->set_property ("direction", scm_from_int (RIGHT)); + fingering->set_property ("direction", scm_from_int (RIGHT)); } fingerings_.push_back (fingering); @@ -153,15 +153,15 @@ ADD_ACKNOWLEDGER (Fingering_engraver, rhythmic_head); ADD_ACKNOWLEDGER (Fingering_engraver, stem); ADD_TRANSLATOR (Fingering_engraver, - /* doc */ - "Create fingering scripts.", + /* doc */ + "Create fingering scripts.", - /* create */ - "Fingering ", + /* create */ + "Fingering ", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/font-config-scheme.cc b/lily/font-config-scheme.cc index cc01f20692..993e52568e 100644 --- a/lily/font-config-scheme.cc +++ b/lily/font-config-scheme.cc @@ -38,14 +38,14 @@ display_fontset (FcFontSet *fs) font = FcNameUnparse (fs->fonts[j]); if (FcPatternGetString (fs->fonts[j], FC_FILE, 0, &str) == FcResultMatch) - retval += String_convert::form_string ("FILE %s\n", str); + retval += String_convert::form_string ("FILE %s\n", str); if (FcPatternGetString (fs->fonts[j], FC_INDEX, 0, &str) == FcResultMatch) - retval += String_convert::form_string ("INDEX %s\n", str); + retval += String_convert::form_string ("INDEX %s\n", str); if (FcPatternGetString (fs->fonts[j], FC_FAMILY, 0, &str) == FcResultMatch) - retval += String_convert::form_string ("family %s\n ", str); + retval += String_convert::form_string ("family %s\n ", str); if (FcPatternGetString (fs->fonts[j], - "designsize", 0, &str) == FcResultMatch) - retval += String_convert::form_string ("designsize %s\n ", str); + "designsize", 0, &str) == FcResultMatch) + retval += String_convert::form_string ("designsize %s\n ", str); retval += String_convert::form_string ("%s\n", (const char *)font); free (font); @@ -98,10 +98,9 @@ display_list (FcConfig *fcc) return retval; } - LY_DEFINE (ly_font_config_get_font_file, "ly:font-config-get-font-file", 1, 0, 0, - (SCM name), - "Get the file for font @var{name}.") + (SCM name), + "Get the file for font @var{name}.") { LY_ASSERT_TYPE (scm_is_string, name, 1); @@ -127,10 +126,10 @@ LY_DEFINE (ly_font_config_get_font_file, "ly:font-config-get-font-file", 1, 0, 0 return scm_result; } - + LY_DEFINE (ly_font_config_display_fonts, "ly:font-config-display-fonts", 0, 0, 0, - (), - "Dump a list of all fonts visible to FontConfig.") + (), + "Dump a list of all fonts visible to FontConfig.") { string str = display_list (NULL); str += display_config (NULL); @@ -141,8 +140,8 @@ LY_DEFINE (ly_font_config_display_fonts, "ly:font-config-display-fonts", 0, 0, 0 } LY_DEFINE (ly_font_config_add_directory, "ly:font-config-add-directory", 1, 0, 0, - (SCM dir), - "Add directory @var{dir} to FontConfig.") + (SCM dir), + "Add directory @var{dir} to FontConfig.") { LY_ASSERT_TYPE (scm_is_string, dir, 1); @@ -157,8 +156,8 @@ LY_DEFINE (ly_font_config_add_directory, "ly:font-config-add-directory", 1, 0, 0 } LY_DEFINE (ly_font_config_add_font, "ly:font-config-add-font", 1, 0, 0, - (SCM font), - "Add font @var{font} to FontConfig.") + (SCM font), + "Add font @var{font} to FontConfig.") { LY_ASSERT_TYPE (scm_is_string, font, 1); diff --git a/lily/font-config.cc b/lily/font-config.cc index 54f04bee8e..63cb66fc35 100644 --- a/lily/font-config.cc +++ b/lily/font-config.cc @@ -30,7 +30,6 @@ #include "main.hh" #include "warn.hh" - FcConfig *font_config_global = 0; void @@ -41,22 +40,22 @@ init_fontconfig () /* TODO: Find a way for Fontconfig to update its cache, if needed. */ font_config_global = FcInitLoadConfig (); - + vector<string> dirs; /* Extra trailing slash suddenly breaks fontconfig (fc-cache 2.5.0) on windows. */ dirs.push_back (lilypond_datadir + "/fonts/otf"); - + for (vsize i = 0; i < dirs.size (); i++) { string dir = dirs[i]; if (!FcConfigAppFontAddDir (font_config_global, (FcChar8 *)dir.c_str ())) - error (_f ("failed adding font directory: %s", dir.c_str ())); + error (_f ("failed adding font directory: %s", dir.c_str ())); else if (be_verbose_global) - message (_f ("adding font directory: %s", dir.c_str ())); + message (_f ("adding font directory: %s", dir.c_str ())); } - + if (be_verbose_global) message (_ ("Building font database...")); diff --git a/lily/font-interface.cc b/lily/font-interface.cc index 4085140311..09b933ea46 100644 --- a/lily/font-interface.cc +++ b/lily/font-interface.cc @@ -61,15 +61,15 @@ Font_interface::text_font_alist_chain (Grob *g) } ADD_INTERFACE (Font_interface, - "Any symbol that is typeset through fixed sets of glyphs," - " (i.e., fonts).", + "Any symbol that is typeset through fixed sets of glyphs," + " (i.e., fonts).", - /* properties */ - "font " - "font-encoding " - "font-family " - "font-name " - "font-series " - "font-shape " - "font-size " - ); + /* properties */ + "font " + "font-encoding " + "font-family " + "font-name " + "font-series " + "font-shape " + "font-size " + ); diff --git a/lily/font-metric-scheme.cc b/lily/font-metric-scheme.cc index fda67e11ba..15e4a8d57f 100644 --- a/lily/font-metric-scheme.cc +++ b/lily/font-metric-scheme.cc @@ -24,17 +24,17 @@ #include "modified-font-metric.hh" LY_DEFINE (ly_font_get_glyph, "ly:font-get-glyph", - 2, 0, 0, - (SCM font, SCM name), - "Return a stencil from @var{font} for the glyph named @var{name}." - " If the glyph is not available, return an empty stencil.\n" - "\n" - "Note that this command can only be used to access glyphs from" - " fonts loaded with @code{ly:system-font-load}; currently, this" - " means either the Emmentaler or Emmentaler-Brace " + 2, 0, 0, + (SCM font, SCM name), + "Return a stencil from @var{font} for the glyph named @var{name}." + " If the glyph is not available, return an empty stencil.\n" + "\n" + "Note that this command can only be used to access glyphs from" + " fonts loaded with @code{ly:system-font-load}; currently, this" + " means either the Emmentaler or Emmentaler-Brace " " fonts, corresponding" - " to the font encodings @code{fetaMusic} and @code{fetaBraces}," - " respectively.") + " to the font encodings @code{fetaMusic} and @code{fetaBraces}," + " respectively.") { Font_metric *fm = unsmob_metrics (font); LY_ASSERT_SMOB (Font_metric, font, 1); @@ -47,15 +47,15 @@ LY_DEFINE (ly_font_get_glyph, "ly:font-get-glyph", } LY_DEFINE (ly_font_glyph_name_to_index, "ly:font-glyph-name-to-index", - 2, 0, 0, - (SCM font, SCM name), - "Return the index for @var{name} in @var{font}.\n" - "\n" - "Note that this command can only be used to access glyphs from" - " fonts loaded with @code{ly:system-font-load}; currently, this" - " means either the Emmentaler or Emmentaler-Brace fonts, corresponding" - " to the font encodings @code{fetaMusic} and @code{fetaBraces}," - " respectively.") + 2, 0, 0, + (SCM font, SCM name), + "Return the index for @var{name} in @var{font}.\n" + "\n" + "Note that this command can only be used to access glyphs from" + " fonts loaded with @code{ly:system-font-load}; currently, this" + " means either the Emmentaler or Emmentaler-Brace fonts, corresponding" + " to the font encodings @code{fetaMusic} and @code{fetaBraces}," + " respectively.") { Font_metric *fm = unsmob_metrics (font); LY_ASSERT_SMOB (Font_metric, font, 1); @@ -65,15 +65,15 @@ LY_DEFINE (ly_font_glyph_name_to_index, "ly:font-glyph-name-to-index", } LY_DEFINE (ly_font_index_to_charcode, "ly:font-index-to-charcode", - 2, 0, 0, - (SCM font, SCM index), - "Return the character code for @var{index} in @var{font}.\n" - "\n" - "Note that this command can only be used to access glyphs from" - " fonts loaded with @code{ly:system-font-load}; currently, this" - " means either the Emmentaler or Emmentaler-Brace fonts, corresponding" - " to the font encodings @code{fetaMusic} and @code{fetaBraces}," - " respectively.") + 2, 0, 0, + (SCM font, SCM index), + "Return the character code for @var{index} in @var{font}.\n" + "\n" + "Note that this command can only be used to access glyphs from" + " fonts loaded with @code{ly:system-font-load}; currently, this" + " means either the Emmentaler or Emmentaler-Brace fonts, corresponding" + " to the font encodings @code{fetaMusic} and @code{fetaBraces}," + " respectively.") { Font_metric *fm = unsmob_metrics (font); LY_ASSERT_SMOB (Font_metric, font, 1); @@ -83,15 +83,15 @@ LY_DEFINE (ly_font_index_to_charcode, "ly:font-index-to-charcode", } LY_DEFINE (ly_font_glyph_name_to_charcode, "ly:font-glyph-name-to-charcode", - 2, 0, 0, - (SCM font, SCM name), - "Return the character code for glyph @var{name} in @var{font}.\n" - "\n" - "Note that this command can only be used to access glyphs from" - " fonts loaded with @code{ly:system-font-load}; currently, this" - " means either the Emmentaler or Emmentaler-Brace fonts, corresponding" - " to the font encodings @code{fetaMusic} and @code{fetaBraces}," - " respectively.") + 2, 0, 0, + (SCM font, SCM name), + "Return the character code for glyph @var{name} in @var{font}.\n" + "\n" + "Note that this command can only be used to access glyphs from" + " fonts loaded with @code{ly:system-font-load}; currently, this" + " means either the Emmentaler or Emmentaler-Brace fonts, corresponding" + " to the font encodings @code{fetaMusic} and @code{fetaBraces}," + " respectively.") { Font_metric *fm = unsmob_metrics (font); LY_ASSERT_SMOB (Font_metric, font, 1); @@ -104,10 +104,10 @@ LY_DEFINE (ly_font_glyph_name_to_charcode, "ly:font-glyph-name-to-charcode", TODO: when are non string retvals allowed? */ LY_DEFINE (ly_font_file_name, "ly:font-file-name", - 1, 0, 0, - (SCM font), - "Given the font metric @var{font}," - " return the corresponding file name.") + 1, 0, 0, + (SCM font), + "Given the font metric @var{font}," + " return the corresponding file name.") { LY_ASSERT_SMOB (Font_metric, font, 1); @@ -118,10 +118,10 @@ LY_DEFINE (ly_font_file_name, "ly:font-file-name", } LY_DEFINE (ly_font_name, "ly:font-name", - 1, 0, 0, - (SCM font), - "Given the font metric @var{font}," - " return the corresponding name.") + 1, 0, 0, + (SCM font), + "Given the font metric @var{font}," + " return the corresponding name.") { LY_ASSERT_SMOB (Font_metric, font, 1); Font_metric *fm = unsmob_metrics (font); @@ -130,9 +130,9 @@ LY_DEFINE (ly_font_name, "ly:font-name", } LY_DEFINE (ly_font_magnification, "ly:font-magnification", 1, 0, 0, - (SCM font), - "Given the font metric @var{font}, return the" - " magnification, relative to the current output-scale.") + (SCM font), + "Given the font metric @var{font}, return the" + " magnification, relative to the current output-scale.") { LY_ASSERT_SMOB (Font_metric, font, 1); @@ -141,9 +141,9 @@ LY_DEFINE (ly_font_magnification, "ly:font-magnification", 1, 0, 0, } LY_DEFINE (ly_font_design_size, "ly:font-design-size", 1, 0, 0, - (SCM font), - "Given the font metric @var{font}, return the" - " design size, relative to the current output-scale.") + (SCM font), + "Given the font metric @var{font}, return the" + " design size, relative to the current output-scale.") { LY_ASSERT_SMOB (Font_metric, font, 1); diff --git a/lily/font-metric.cc b/lily/font-metric.cc index 458528dd2e..9e762cb367 100644 --- a/lily/font-metric.cc +++ b/lily/font-metric.cc @@ -48,8 +48,8 @@ Font_metric::find_by_name (string s) const if (idx >= 0) { expr = scm_list_3 (ly_symbol2scm ("named-glyph"), - self_scm (), - ly_string2scm (s)); + self_scm (), + ly_string2scm (s)); b = get_indexed_char_dimensions (idx); } @@ -87,7 +87,7 @@ Font_metric::get_indexed_char_dimensions (size_t) const size_t Font_metric::name_to_index (string) const { - return (size_t)-1; + return (size_t) - 1; } Offset @@ -161,7 +161,7 @@ Font_metric::text_stencil (Output_def *state, string, bool) const { (void) state; - + programming_error ("Cannot get a text stencil from this font"); return Stencil (Box (), SCM_EOL); } diff --git a/lily/font-select.cc b/lily/font-select.cc index f9f42ae25e..3de5a2a454 100644 --- a/lily/font-select.cc +++ b/lily/font-select.cc @@ -17,7 +17,6 @@ along with LilyPond. If not, see <http://www.gnu.org/licenses/>. */ - #include "dimensions.hh" #include "all-font-metrics.hh" #include "output-def.hh" @@ -28,7 +27,7 @@ Font_metric * get_font_by_design_size (Output_def *layout, Real requested, - SCM font_vector) + SCM font_vector) { int n = scm_c_vector_length (font_vector); Real size = 1e6; @@ -42,23 +41,23 @@ get_font_by_design_size (Output_def *layout, Real requested, SCM entry = scm_c_vector_ref (font_vector, i); if (scm_promise_p (entry) == SCM_BOOL_T) - { - Font_metric *fm = unsmob_metrics (scm_force (entry)); - size = fm->design_size (); - } + { + Font_metric *fm = unsmob_metrics (scm_force (entry)); + size = fm->design_size (); + } #if HAVE_PANGO_FT2 else if (scm_is_pair (entry) - && scm_is_number (scm_car (entry)) - && scm_is_string (scm_cdr (entry))) - { - size = scm_to_double (scm_car (entry)); - pango_description_string - = scm_cdr (entry); - } + && scm_is_number (scm_car (entry)) + && scm_is_string (scm_cdr (entry))) + { + size = scm_to_double (scm_car (entry)); + pango_description_string + = scm_cdr (entry); + } #endif if (size > requested) - break; + break; last_size = size; last_pango_description_string = pango_description_string; } @@ -68,11 +67,11 @@ get_font_by_design_size (Output_def *layout, Real requested, else if (i > 0) { if ((requested / last_size) < (size / requested)) - { - i--; - size = last_size; - pango_description_string = last_pango_description_string; - } + { + i--; + size = last_size; + pango_description_string = last_pango_description_string; + } } Font_metric *fm = 0; @@ -80,8 +79,8 @@ get_font_by_design_size (Output_def *layout, Real requested, { #if HAVE_PANGO_FT2 return find_pango_font (layout, - pango_description_string, - requested / size); + pango_description_string, + requested / size); #else error ("Trying to retrieve pango font without HAVE_PANGO_FT2."); #endif @@ -94,18 +93,18 @@ get_font_by_design_size (Output_def *layout, Real requested, Font_metric * get_font_by_mag_step (Output_def *layout, Real requested_step, - SCM font_vector, Real default_size) + SCM font_vector, Real default_size) { return get_font_by_design_size (layout, default_size - * pow (2.0, requested_step / 6.0), - font_vector); + * pow (2.0, requested_step / 6.0), + font_vector); } SCM properties_to_font_size_family (SCM fonts, SCM alist_chain) { return scm_call_2 (ly_lily_module_constant ("lookup-font"), fonts, - alist_chain); + alist_chain); } Font_metric * @@ -126,14 +125,14 @@ select_encoded_font (Output_def *layout, SCM chain) #endif if (scm_instance_p (name)) { - SCM base_size = scm_slot_ref (name, ly_symbol2scm ("default-size")); - SCM vec = scm_slot_ref (name, ly_symbol2scm ("size-vector")); + SCM base_size = scm_slot_ref (name, ly_symbol2scm ("default-size")); + SCM vec = scm_slot_ref (name, ly_symbol2scm ("size-vector")); - Real req = robust_scm2double (ly_chain_assoc_get (ly_symbol2scm ("font-size"), chain, SCM_BOOL_F), - 0.0); + Real req = robust_scm2double (ly_chain_assoc_get (ly_symbol2scm ("font-size"), chain, SCM_BOOL_F), + 0.0); - return get_font_by_mag_step (layout, req, vec, - scm_to_double (base_size)); + return get_font_by_mag_step (layout, req, vec, + scm_to_double (base_size)); } assert (0); diff --git a/lily/font-size-engraver.cc b/lily/font-size-engraver.cc index c95e104c87..7c41f4a123 100644 --- a/lily/font-size-engraver.cc +++ b/lily/font-size-engraver.cc @@ -55,7 +55,7 @@ Font_size_engraver::acknowledge_font (Grob_info gi) return; Real font_size = size - + robust_scm2double (gi.grob ()->get_property ("font-size"), 0); + + robust_scm2double (gi.grob ()->get_property ("font-size"), 0); gi.grob ()->set_property ("font-size", scm_from_double (font_size)); } @@ -63,15 +63,15 @@ Font_size_engraver::acknowledge_font (Grob_info gi) ADD_ACKNOWLEDGER (Font_size_engraver, font); ADD_TRANSLATOR (Font_size_engraver, - /* doc */ - "Put @code{fontSize} into @code{font-size} grob property.", + /* doc */ + "Put @code{fontSize} into @code{font-size} grob property.", - /* create */ - "", + /* create */ + "", - /* read */ - "fontSize ", + /* read */ + "fontSize ", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/footnote-engraver.cc b/lily/footnote-engraver.cc index 7539bf9503..6b62af0d47 100644 --- a/lily/footnote-engraver.cc +++ b/lily/footnote-engraver.cc @@ -70,7 +70,7 @@ Footnote_engraver::footnotify (Grob *g, Stream_event *event) b->set_parent (s, X_AXIS); Grob *bound = unsmob_grob (get_property ("currentMusicalColumn")); b->set_bound (LEFT, bound); - annotated_spanners_.push_back (Drul_array<Spanner *> (s,b)); + annotated_spanners_.push_back (Drul_array<Spanner *> (s, b)); } else { @@ -90,13 +90,13 @@ Footnote_engraver::acknowledge_grob (Grob_info info) { Stream_event *e = unsmob_stream_event (scm_car (s)); if (e->in_event_class ("footnote-event")) - footnotify (info.grob (), e); + footnotify (info.grob (), e); } for (vsize i = 0; i < events_.size (); i++) { if (info.grob ()->name () == ly_symbol2string (events_[i]->get_property ("symbol"))) - footnotify (info.grob (), events_[i]); + footnotify (info.grob (), events_[i]); } } @@ -121,16 +121,16 @@ ADD_ACKNOWLEDGER (Footnote_engraver, grob); ADD_END_ACKNOWLEDGER (Footnote_engraver, grob); ADD_TRANSLATOR (Footnote_engraver, - /* doc */ - "Create footnote texts.", + /* doc */ + "Create footnote texts.", - /* create */ - "FootnoteItem " - "FootnoteSpanner ", + /* create */ + "FootnoteItem " + "FootnoteSpanner ", - /*read*/ - "currentMusicalColumn ", + /*read*/ + "currentMusicalColumn ", - /*write*/ - "" - ); + /*write*/ + "" + ); diff --git a/lily/forbid-break-engraver.cc b/lily/forbid-break-engraver.cc index 81c03e15be..b1d89ddf24 100644 --- a/lily/forbid-break-engraver.cc +++ b/lily/forbid-break-engraver.cc @@ -59,16 +59,16 @@ Forbid_line_break_engraver::start_translation_timestep () } ADD_TRANSLATOR (Forbid_line_break_engraver, - /* doc */ - "Forbid line breaks when note heads are still playing at some" - " point.", + /* doc */ + "Forbid line breaks when note heads are still playing at some" + " point.", - /* create */ - "", + /* create */ + "", - /* read */ - "busyGrobs ", + /* read */ + "busyGrobs ", - /* write */ - "forbidBreak " - ); + /* write */ + "forbidBreak " + ); diff --git a/lily/freetype-error.cc b/lily/freetype-error.cc index 21cec33111..ea4b41652e 100644 --- a/lily/freetype-error.cc +++ b/lily/freetype-error.cc @@ -2,7 +2,7 @@ This file is part of LilyPond, the GNU music typesetter. Copyright (C) 2007--2011 Han-Wen Nienhuys <hanwen@lilypond.org> - + LilyPond is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,34 +20,33 @@ #include "freetype.hh" -#undef __FTERRORS_H__ -#define FT_ERRORDEF(e, v, s) { e, s }, -#define FT_ERROR_START_LIST { -#define FT_ERROR_END_LIST { 0, 0 } }; - +#undef __FTERRORS_H__ +#define FT_ERRORDEF(e, v, s) { e, s }, +#define FT_ERROR_START_LIST { +#define FT_ERROR_END_LIST { 0, 0 } }; + const struct Freetype_error_message -{ - FT_Error err_code; - const char* err_msg; -} ft_errors[] = - +{ + FT_Error err_code; + const char *err_msg; +} ft_errors[] = + #include <freetype/fterrors.h> ; - #include <string> string freetype_error_string (FT_Error code) { for (Freetype_error_message const *p = ft_errors; - p->err_msg; p ++) + p->err_msg; p++) { if (p->err_code == code) - return p->err_msg; + return p->err_msg; } - return "<unknown error>"; + return "<unknown error>"; } - + diff --git a/lily/fretboard-engraver.cc b/lily/fretboard-engraver.cc index cb4345ccad..0d6cd18ae3 100644 --- a/lily/fretboard-engraver.cc +++ b/lily/fretboard-engraver.cc @@ -96,20 +96,20 @@ Fretboard_engraver::process_music () return; SCM tab_strings = articulation_list (note_events_, - tabstring_events_, - "string-number-event"); + tabstring_events_, + "string-number-event"); SCM fingers = articulation_list (note_events_, - fingering_events_, - "fingering-event"); + fingering_events_, + "fingering-event"); fret_board_ = make_item ("FretBoard", note_events_[0]->self_scm ()); SCM fret_notes = ly_cxx_vector_to_list (note_events_); SCM proc = get_property ("noteToFretFunction"); if (ly_is_procedure (proc)) scm_call_4 (proc, - context ()->self_scm (), - fret_notes, - scm_list_2 (tab_strings, fingers), - fret_board_->self_scm ()); + context ()->self_scm (), + fret_notes, + scm_list_2 (tab_strings, fingers), + fret_board_->self_scm ()); SCM changes = get_property ("chordChanges"); if (to_boolean (changes) && scm_is_pair (last_fret_notes_) && ly_is_equal (last_fret_notes_, fret_notes)) @@ -128,25 +128,25 @@ Fretboard_engraver::stop_translation_timestep () } ADD_TRANSLATOR (Fretboard_engraver, - /* doc */ - "Generate fret diagram from one or more events of type" - " @code{NoteEvent}.", - - /* create */ - "FretBoard ", - - /* read */ - "chordChanges " - "defaultStrings " - "highStringOne " - "maximumFretStretch " - "minimumFret " - "noteToFretFunction " - "predefinedDiagramTable " - "stringTunings " - "tablatureFormat ", - - /* write */ - "" - ); + /* doc */ + "Generate fret diagram from one or more events of type" + " @code{NoteEvent}.", + + /* create */ + "FretBoard ", + + /* read */ + "chordChanges " + "defaultStrings " + "highStringOne " + "maximumFretStretch " + "minimumFret " + "noteToFretFunction " + "predefinedDiagramTable " + "stringTunings " + "tablatureFormat ", + + /* write */ + "" + ); diff --git a/lily/function-documentation.cc b/lily/function-documentation.cc index 8d7c14b999..480ea6b089 100644 --- a/lily/function-documentation.cc +++ b/lily/function-documentation.cc @@ -24,7 +24,6 @@ using namespace std; #include "lily-guile.hh" #include "warn.hh" - static SCM doc_hash_table; void @@ -33,16 +32,15 @@ ly_check_name (string cxx, string scm_name) string mangle = mangle_cxx_identifier (cxx); if (mangle != scm_name) { - programming_error ("wrong cxx name: " + mangle + ", " + cxx + ", " + scm_name); + programming_error ("wrong cxx name: " + mangle + ", " + cxx + ", " + scm_name); } } - void ly_add_function_documentation (SCM func, - string fname, - string varlist, - string doc) + string fname, + string varlist, + string doc) { if (doc == "") return; @@ -51,31 +49,30 @@ ly_add_function_documentation (SCM func, doc_hash_table = scm_permanent_object (scm_c_make_hash_table (59)); string s = string (" - ") + "LilyPond procedure: " + fname + " " + varlist - + "\n" + doc; + + "\n" + doc; scm_set_procedure_property_x (func, ly_symbol2scm ("documentation"), - ly_string2scm (s)); + ly_string2scm (s)); SCM entry = scm_cons (ly_string2scm (varlist), ly_string2scm (doc)); scm_hashq_set_x (doc_hash_table, ly_symbol2scm (fname.c_str ()), entry); } LY_DEFINE (ly_get_all_function_documentation, "ly:get-all-function-documentation", - 0, 0, 0, (), - "Get a hash table with all LilyPond Scheme extension functions.") + 0, 0, 0, (), + "Get a hash table with all LilyPond Scheme extension functions.") { return doc_hash_table; } - #include <map> map<void *, string> type_names; - + void ly_add_type_predicate (void *ptr, - string name) + string name) { - type_names[ptr] = name; + type_names[ptr] = name; } string @@ -104,32 +101,32 @@ predicate_to_typename (void *ptr) void init_func_doc () { - ly_add_type_predicate ((void*) &is_direction, "direction"); - ly_add_type_predicate ((void*) &is_music_function, "Music_function"); - ly_add_type_predicate ((void*) &ly_is_port, "port"); - ly_add_type_predicate ((void*) &ly_cheap_is_list, "list"); - ly_add_type_predicate ((void*) &unsmob_global_context, "Global_context"); - ly_add_type_predicate ((void*) &unsmob_input, "Input"); - ly_add_type_predicate ((void*) &unsmob_moment, "Moment"); - ly_add_type_predicate ((void*) &unsmob_paper_score, "Paper_score"); - ly_add_type_predicate ((void*) &unsmob_performance, "Performance"); - - ly_add_type_predicate ((void*) &is_axis, "axis"); - ly_add_type_predicate ((void*) &is_number_pair, "number pair"); - ly_add_type_predicate ((void*) &ly_is_list, "list"); - ly_add_type_predicate ((void*) &ly_is_procedure, "procedure"); - ly_add_type_predicate ((void*) &ly_is_symbol, "symbol"); - ly_add_type_predicate ((void*) &scm_is_bool, "boolean"); - ly_add_type_predicate ((void*) &scm_is_integer, "integer"); - ly_add_type_predicate ((void*) &scm_is_number, "number"); - ly_add_type_predicate ((void*) &scm_is_pair, "pair"); - ly_add_type_predicate ((void*) &scm_is_rational, "rational"); - ly_add_type_predicate ((void*) &scm_is_string, "string"); - ly_add_type_predicate ((void*) &scm_is_vector, "vector"); - ly_add_type_predicate ((void*) &unsmob_item, "Item"); - ly_add_type_predicate ((void*) &unsmob_music, "Music"); - ly_add_type_predicate ((void*) &unsmob_spanner, "Spanner"); - ly_add_type_predicate ((void*) &unsmob_stream_event, "Stream_event"); + ly_add_type_predicate ((void *) &is_direction, "direction"); + ly_add_type_predicate ((void *) &is_music_function, "Music_function"); + ly_add_type_predicate ((void *) &ly_is_port, "port"); + ly_add_type_predicate ((void *) &ly_cheap_is_list, "list"); + ly_add_type_predicate ((void *) &unsmob_global_context, "Global_context"); + ly_add_type_predicate ((void *) &unsmob_input, "Input"); + ly_add_type_predicate ((void *) &unsmob_moment, "Moment"); + ly_add_type_predicate ((void *) &unsmob_paper_score, "Paper_score"); + ly_add_type_predicate ((void *) &unsmob_performance, "Performance"); + + ly_add_type_predicate ((void *) &is_axis, "axis"); + ly_add_type_predicate ((void *) &is_number_pair, "number pair"); + ly_add_type_predicate ((void *) &ly_is_list, "list"); + ly_add_type_predicate ((void *) &ly_is_procedure, "procedure"); + ly_add_type_predicate ((void *) &ly_is_symbol, "symbol"); + ly_add_type_predicate ((void *) &scm_is_bool, "boolean"); + ly_add_type_predicate ((void *) &scm_is_integer, "integer"); + ly_add_type_predicate ((void *) &scm_is_number, "number"); + ly_add_type_predicate ((void *) &scm_is_pair, "pair"); + ly_add_type_predicate ((void *) &scm_is_rational, "rational"); + ly_add_type_predicate ((void *) &scm_is_string, "string"); + ly_add_type_predicate ((void *) &scm_is_vector, "vector"); + ly_add_type_predicate ((void *) &unsmob_item, "Item"); + ly_add_type_predicate ((void *) &unsmob_music, "Music"); + ly_add_type_predicate ((void *) &unsmob_spanner, "Spanner"); + ly_add_type_predicate ((void *) &unsmob_stream_event, "Stream_event"); } ADD_SCM_INIT_FUNC (func_doc, init_func_doc); diff --git a/lily/general-scheme.cc b/lily/general-scheme.cc index ae31e1eb9f..fa838e3189 100644 --- a/lily/general-scheme.cc +++ b/lily/general-scheme.cc @@ -41,9 +41,9 @@ using namespace std; #include "warn.hh" LY_DEFINE (ly_start_environment, "ly:start-environment", - 0, 0, 0, (), - "Return the environment (a list of strings) that was in" - " effect at program start.") + 0, 0, 0, (), + "Return the environment (a list of strings) that was in" + " effect at program start.") { SCM l = SCM_EOL; SCM *tail = &l; @@ -51,18 +51,17 @@ LY_DEFINE (ly_start_environment, "ly:start-environment", for (vsize i = 0; i < start_environment_global.size (); i++) { *tail = scm_cons (ly_string2scm (start_environment_global[i]), - SCM_EOL); - tail = SCM_CDRLOC(*tail); + SCM_EOL); + tail = SCM_CDRLOC (*tail); } return l; } - LY_DEFINE (ly_find_file, "ly:find-file", - 1, 0, 0, (SCM name), - "Return the absolute file name of @var{name}," - " or @code{#f} if not found.") + 1, 0, 0, (SCM name), + "Return the absolute file name of @var{name}," + " or @code{#f} if not found.") { LY_ASSERT_TYPE (scm_is_string, name, 1); @@ -79,11 +78,11 @@ LY_DEFINE (ly_find_file, "ly:find-file", buffering.) */ LY_DEFINE (ly_gulp_file, "ly:gulp-file", - 1, 1, 0, (SCM name, SCM size), - "Read @var{size} characters from the file @var{name}," + 1, 1, 0, (SCM name, SCM size), + "Read @var{size} characters from the file @var{name}," " and return its contents in a string." " If @var{size} is undefined, the entire file is read." - " The file is looked up using the search path.") + " The file is looked up using the search path.") { LY_ASSERT_TYPE (scm_is_string, name, 1); int sz = INT_MAX; @@ -98,9 +97,9 @@ LY_DEFINE (ly_gulp_file, "ly:gulp-file", } LY_DEFINE (ly_error, "ly:error", - 1, 0, 1, (SCM str, SCM rest), - "A Scheme callable function to issue the error @var{str}." - " The error is formatted with @code{format} and @var{rest}.") + 1, 0, 1, (SCM str, SCM rest), + "A Scheme callable function to issue the error @var{str}." + " The error is formatted with @code{format} and @var{rest}.") { LY_ASSERT_TYPE (scm_is_string, str, 1); str = scm_simple_format (SCM_BOOL_F, str, rest); @@ -109,9 +108,9 @@ LY_DEFINE (ly_error, "ly:error", } LY_DEFINE (ly_message, "ly:message", - 1, 0, 1, (SCM str, SCM rest), - "A Scheme callable function to issue the message @var{str}." - " The message is formatted with @code{format} and @var{rest}.") + 1, 0, 1, (SCM str, SCM rest), + "A Scheme callable function to issue the message @var{str}." + " The message is formatted with @code{format} and @var{rest}.") { LY_ASSERT_TYPE (scm_is_string, str, 1); str = scm_simple_format (SCM_BOOL_F, str, rest); @@ -120,9 +119,9 @@ LY_DEFINE (ly_message, "ly:message", } LY_DEFINE (ly_progress, "ly:progress", - 1, 0, 1, (SCM str, SCM rest), - "A Scheme callable function to print progress @var{str}." - " The message is formatted with @code{format} and @var{rest}.") + 1, 0, 1, (SCM str, SCM rest), + "A Scheme callable function to print progress @var{str}." + " The message is formatted with @code{format} and @var{rest}.") { LY_ASSERT_TYPE (scm_is_string, str, 1); str = scm_simple_format (SCM_BOOL_F, str, rest); @@ -131,10 +130,10 @@ LY_DEFINE (ly_progress, "ly:progress", } LY_DEFINE (ly_programming_error, "ly:programming-error", - 1, 0, 1, (SCM str, SCM rest), - "A Scheme callable function to issue the internal warning" - " @var{str}. The message is formatted with @code{format}" - " and @var{rest}.") + 1, 0, 1, (SCM str, SCM rest), + "A Scheme callable function to issue the internal warning" + " @var{str}. The message is formatted with @code{format}" + " and @var{rest}.") { LY_ASSERT_TYPE (scm_is_string, str, 1); str = scm_simple_format (SCM_BOOL_F, str, rest); @@ -148,9 +147,9 @@ LY_DEFINE (ly_programming_error, "ly:programming-error", } LY_DEFINE (ly_success, "ly:success", - 1, 0, 1, (SCM str, SCM rest), - "A Scheme callable function to issue a success message @var{str}." - " The message is formatted with @code{format} and @var{rest}.") + 1, 0, 1, (SCM str, SCM rest), + "A Scheme callable function to issue a success message @var{str}." + " The message is formatted with @code{format} and @var{rest}.") { LY_ASSERT_TYPE (scm_is_string, str, 1); str = scm_simple_format (SCM_BOOL_F, str, rest); @@ -159,9 +158,9 @@ LY_DEFINE (ly_success, "ly:success", } LY_DEFINE (ly_warning, "ly:warning", - 1, 0, 1, (SCM str, SCM rest), - "A Scheme callable function to issue the warning @var{str}." - " The message is formatted with @code{format} and @var{rest}.") + 1, 0, 1, (SCM str, SCM rest), + "A Scheme callable function to issue the warning @var{str}." + " The message is formatted with @code{format} and @var{rest}.") { LY_ASSERT_TYPE (scm_is_string, str, 1); str = scm_simple_format (SCM_BOOL_F, str, rest); @@ -175,11 +174,11 @@ LY_DEFINE (ly_warning, "ly:warning", } LY_DEFINE (ly_dir_p, "ly:dir?", - 1, 0, 0, (SCM s), - "Is @var{s} a direction? Valid directions are @code{-1}," - " @code{0}, or@tie{}@code{1}, where @code{-1} represents" - " left or down, @code{1}@tie{}represents right or up, and @code{0}" - " represents a neutral direction.") + 1, 0, 0, (SCM s), + "Is @var{s} a direction? Valid directions are @code{-1}," + " @code{0}, or@tie{}@code{1}, where @code{-1} represents" + " left or down, @code{1}@tie{}represents right or up, and @code{0}" + " represents a neutral direction.") { if (scm_is_number (s)) { @@ -190,14 +189,14 @@ LY_DEFINE (ly_dir_p, "ly:dir?", } LY_DEFINE (ly_assoc_get, "ly:assoc-get", - 2, 2, 0, - (SCM key, SCM alist, SCM default_value, SCM strict_checking), - "Return value if @var{key} in @var{alist}, else @var{default-value}" - " (or @code{#f} if not specified). If @var{strict-checking} is set" + 2, 2, 0, + (SCM key, SCM alist, SCM default_value, SCM strict_checking), + "Return value if @var{key} in @var{alist}, else @var{default-value}" + " (or @code{#f} if not specified). If @var{strict-checking} is set" " to @code{#t} and @var{key} is not in @var{alist}, a programming_error" " is output.") { - LY_ASSERT_TYPE(ly_cheap_is_list, alist, 2); + LY_ASSERT_TYPE (ly_cheap_is_list, alist, 2); SCM handle = scm_assoc (key, alist); if (scm_is_pair (handle)) @@ -209,23 +208,23 @@ LY_DEFINE (ly_assoc_get, "ly:assoc-get", if (strict_checking == SCM_BOOL_T) { string key_string = ly_scm2string - (scm_object_to_string (key, SCM_UNDEFINED)); + (scm_object_to_string (key, SCM_UNDEFINED)); string default_value_string = ly_scm2string - (scm_object_to_string (default_value, - SCM_UNDEFINED)); - programming_error ("Cannot find key `" + - key_string + - "' in alist, setting to `" + - default_value_string + "'."); + (scm_object_to_string (default_value, + SCM_UNDEFINED)); + programming_error ("Cannot find key `" + + key_string + + "' in alist, setting to `" + + default_value_string + "'."); } return default_value; } LY_DEFINE (ly_string_substitute, "ly:string-substitute", - 3, 0, 0, (SCM a, SCM b, SCM s), - "Replace string@tie{}@var{a} by string@tie{}@var{b} in" - " string@tie{}@var{s}.") + 3, 0, 0, (SCM a, SCM b, SCM s), + "Replace string@tie{}@var{a} by string@tie{}@var{b} in" + " string@tie{}@var{s}.") { LY_ASSERT_TYPE (scm_is_string, s, 1); LY_ASSERT_TYPE (scm_is_string, b, 2); @@ -233,7 +232,7 @@ LY_DEFINE (ly_string_substitute, "ly:string-substitute", string ss = ly_scm2string (s); replace_all (&ss, ly_scm2string (a), - ly_scm2string (b)); + ly_scm2string (b)); return ly_string2scm (ss); } @@ -258,11 +257,11 @@ is_not_escape_character (Byte c) } LY_DEFINE (ly_string_percent_encode, "ly:string-percent-encode", - 1, 0, 0, (SCM str), - "Encode all characters in string @var{str} with hexadecimal" - " percent escape sequences, with the following exceptions:" - " characters @code{-}, @code{.}, @code{/}, and @code{_}; and" - " characters in ranges @code{0-9}, @code{A-Z}, and @code{a-z}.") + 1, 0, 0, (SCM str), + "Encode all characters in string @var{str} with hexadecimal" + " percent escape sequences, with the following exceptions:" + " characters @code{-}, @code{.}, @code{/}, and @code{_}; and" + " characters in ranges @code{0-9}, @code{A-Z}, and @code{a-z}.") { LY_ASSERT_TYPE (scm_is_string, str, 1); @@ -277,12 +276,12 @@ LY_DEFINE (ly_string_percent_encode, "ly:string-percent-encode", Byte cur = orig_str[i]; if (is_not_escape_character (cur)) - new_str += cur; + new_str += cur; else - { - new_str += '%'; - new_str += String_convert::bin2hex (cur); - } + { + new_str += '%'; + new_str += String_convert::bin2hex (cur); + } i++; } @@ -291,23 +290,23 @@ LY_DEFINE (ly_string_percent_encode, "ly:string-percent-encode", } LY_DEFINE (ly_number_2_string, "ly:number->string", - 1, 0, 0, (SCM s), - "Convert @var{s} to a string without generating many decimals.") + 1, 0, 0, (SCM s), + "Convert @var{s} to a string without generating many decimals.") { LY_ASSERT_TYPE (scm_is_number, s, 1); - char str[400]; // ugh. + char str[400]; // ugh. if (scm_exact_p (s) == SCM_BOOL_F) { Real r (scm_to_double (s)); - if (isinf (r) || isnan (r)) - { - programming_error (_ ("infinity or NaN encountered while converting Real number")); - programming_error (_ ("setting to zero")); + if (isinf (r) || isnan (r)) + { + programming_error (_ ("infinity or NaN encountered while converting Real number")); + programming_error (_ ("setting to zero")); - r = 0.0; - } + r = 0.0; + } snprintf (str, sizeof (str), "%.4f", r); } @@ -318,8 +317,8 @@ LY_DEFINE (ly_number_2_string, "ly:number->string", } LY_DEFINE (ly_version, "ly:version", 0, 0, 0, (), - "Return the current lilypond version as a list, e.g.," - " @code{(1 3 127 uu1)}.") + "Return the current lilypond version as a list, e.g.," + " @code{(1 3 127 uu1)}.") { char const *vs = "\'(" MAJOR_VERSION " " MINOR_VERSION " " PATCH_LEVEL " " MY_PATCH_LEVEL ")"; @@ -327,14 +326,14 @@ LY_DEFINE (ly_version, "ly:version", 0, 0, 0, (), } LY_DEFINE (ly_unit, "ly:unit", 0, 0, 0, (), - "Return the unit used for lengths as a string.") + "Return the unit used for lengths as a string.") { return scm_from_locale_string (INTERNAL_UNIT); } LY_DEFINE (ly_dimension_p, "ly:dimension?", 1, 0, 0, (SCM d), - "Return @var{d} as a number. Used to distinguish length" - " variables from normal numbers.") + "Return @var{d} as a number. Used to distinguish length" + " variables from normal numbers.") { return scm_number_p (d); } @@ -343,24 +342,24 @@ LY_DEFINE (ly_dimension_p, "ly:dimension?", 1, 0, 0, (SCM d), Debugging mem leaks: */ LY_DEFINE (ly_protects, "ly:protects", - 0, 0, 0, (), - "Return hash of protected objects.") + 0, 0, 0, (), + "Return hash of protected objects.") { return scm_protects; } LY_DEFINE (ly_gettext, "ly:gettext", - 1, 0, 0, (SCM original), - "A Scheme wrapper function for @code{gettext}.") + 1, 0, 0, (SCM original), + "A Scheme wrapper function for @code{gettext}.") { LY_ASSERT_TYPE (scm_is_string, original, 1); return ly_string2scm (_ (ly_scm2string (original).c_str ())); } LY_DEFINE (ly_output_formats, "ly:output-formats", - 0, 0, 0, (), - "Formats passed to @option{--format} as a list of strings," - " used for the output.") + 0, 0, 0, (), + "Formats passed to @option{--format} as a list of strings," + " used for the output.") { vector<string> output_formats = string_split (output_format_global, ','); @@ -373,8 +372,8 @@ LY_DEFINE (ly_output_formats, "ly:output-formats", } LY_DEFINE (ly_wide_char_2_utf_8, "ly:wide-char->utf-8", - 1, 0, 0, (SCM wc), - "Encode the Unicode codepoint @var{wc}, an integer, as UTF-8.") + 1, 0, 0, (SCM wc), + "Encode the Unicode codepoint @var{wc}, an integer, as UTF-8.") { char buf[5]; @@ -408,48 +407,47 @@ LY_DEFINE (ly_wide_char_2_utf_8, "ly:wide-char->utf-8", } LY_DEFINE (ly_effective_prefix, "ly:effective-prefix", - 0, 0, 0, (), - "Return effective prefix.") + 0, 0, 0, (), + "Return effective prefix.") { return ly_string2scm (lilypond_datadir); } LY_DEFINE (ly_chain_assoc_get, "ly:chain-assoc-get", - 2, 2, 0, (SCM key, SCM achain, SCM default_value, SCM strict_checking), - "Return value for @var{key} from a list of alists @var{achain}." - " If no entry is found, return @var{default-value} or @code{#f} if" - " @var{default-value} is not specified. With @var{strict-checking}" + 2, 2, 0, (SCM key, SCM achain, SCM default_value, SCM strict_checking), + "Return value for @var{key} from a list of alists @var{achain}." + " If no entry is found, return @var{default-value} or @code{#f} if" + " @var{default-value} is not specified. With @var{strict-checking}" " set to @code{#t}, a programming_error is output in such cases.") { if (scm_is_pair (achain)) { SCM handle = scm_assoc (key, scm_car (achain)); if (scm_is_pair (handle)) - return scm_cdr (handle); + return scm_cdr (handle); else - return ly_chain_assoc_get (key, scm_cdr (achain), default_value); + return ly_chain_assoc_get (key, scm_cdr (achain), default_value); } if (strict_checking == SCM_BOOL_T) { string key_string = ly_scm2string - (scm_object_to_string (key, SCM_UNDEFINED)); + (scm_object_to_string (key, SCM_UNDEFINED)); string default_value_string = ly_scm2string - (scm_object_to_string (default_value, - SCM_UNDEFINED)); - programming_error ("Cannot find key `" + - key_string + - "' in achain, setting to `" + - default_value_string + "'."); + (scm_object_to_string (default_value, + SCM_UNDEFINED)); + programming_error ("Cannot find key `" + + key_string + + "' in achain, setting to `" + + default_value_string + "'."); } return default_value == SCM_UNDEFINED ? SCM_BOOL_F : default_value; } - LY_DEFINE (ly_stderr_redirect, "ly:stderr-redirect", - 1, 1, 0, (SCM file_name, SCM mode), - "Redirect stderr to @var{file-name}, opened with @var{mode}.") + 1, 1, 0, (SCM file_name, SCM mode), + "Redirect stderr to @var{file-name}, opened with @var{mode}.") { LY_ASSERT_TYPE (scm_is_string, file_name, 1); @@ -466,24 +464,24 @@ LY_DEFINE (ly_stderr_redirect, "ly:stderr-redirect", static SCM accumulate_symbol (void * /* closure */, - SCM key, - SCM /* val */, - SCM result) + SCM key, + SCM /* val */, + SCM result) { return scm_cons (key, result); } LY_DEFINE (ly_hash_table_keys, "ly:hash-table-keys", - 1,0,0, (SCM tab), - "Return a list of keys in @var{tab}.") + 1, 0, 0, (SCM tab), + "Return a list of keys in @var{tab}.") { return scm_internal_hash_fold ((scm_t_hash_fold_fn) &accumulate_symbol, - NULL, SCM_EOL, tab); + NULL, SCM_EOL, tab); } LY_DEFINE (ly_camel_case_2_lisp_identifier, "ly:camel-case->lisp-identifier", - 1, 0, 0, (SCM name_sym), - "Convert @code{FooBar_Bla} to @code{foo-bar-bla} style symbol.") + 1, 0, 0, (SCM name_sym), + "Convert @code{FooBar_Bla} to @code{foo-bar-bla} style symbol.") { LY_ASSERT_TYPE (ly_is_symbol, name_sym, 1); @@ -498,18 +496,17 @@ LY_DEFINE (ly_camel_case_2_lisp_identifier, "ly:camel-case->lisp-identifier", } LY_DEFINE (ly_expand_environment, "ly:expand-environment", - 1, 0, 0, (SCM str), - "Expand @code{$VAR} and @code{$@{VAR@}} in @var{str}.") + 1, 0, 0, (SCM str), + "Expand @code{$VAR} and @code{$@{VAR@}} in @var{str}.") { LY_ASSERT_TYPE (scm_is_string, str, 1); return ly_string2scm (expand_environment_variables (ly_scm2string (str))); } - LY_DEFINE (ly_truncate_list_x, "ly:truncate-list!", - 2, 0, 0, (SCM lst, SCM i), - "Take at most the first @var{i} of list @var{lst}.") + 2, 0, 0, (SCM lst, SCM i), + "Take at most the first @var{i} of list @var{lst}.") { LY_ASSERT_TYPE (scm_is_integer, i, 1); @@ -521,10 +518,10 @@ LY_DEFINE (ly_truncate_list_x, "ly:truncate-list!", SCM s = lst; k--; for (; scm_is_pair (s) && k--; s = scm_cdr (s)) - ; + ; if (scm_is_pair (s)) - scm_set_cdr_x (s, SCM_EOL); + scm_set_cdr_x (s, SCM_EOL); } return lst; } @@ -539,14 +536,14 @@ format_single_argument (SCM arg, int precision, bool escape = false) Real val = scm_to_double (arg); if (isnan (val) || isinf (val)) - { - warning (_ ("Found infinity or nan in output. Substituting 0.0")); - return ("0.0"); - if (strict_infinity_checking) - abort (); - } + { + warning (_ ("Found infinity or nan in output. Substituting 0.0")); + return ("0.0"); + if (strict_infinity_checking) + abort (); + } else - return (String_convert::form_string ("%.*lf", precision, val)); + return (String_convert::form_string ("%.*lf", precision, val)); } else if (scm_is_string (arg)) { @@ -568,17 +565,16 @@ format_single_argument (SCM arg, int precision, bool escape = false) else { ly_progress (scm_from_locale_string ("\nUnsupported SCM value for format: ~a"), - scm_list_1 (arg)); + scm_list_1 (arg)); } - return ""; } LY_DEFINE (ly_format, "ly:format", - 1, 0, 1, (SCM str, SCM rest), - "LilyPond specific format, supporting @code{~a} and @code{~[0-9]f}." - " Basic support for @code{~s} is also provided.") + 1, 0, 1, (SCM str, SCM rest), + "LilyPond specific format, supporting @code{~a} and @code{~[0-9]f}." + " Basic support for @code{~s} is also provided.") { LY_ASSERT_TYPE (scm_is_string, str, 1); @@ -590,70 +586,70 @@ LY_DEFINE (ly_format, "ly:format", { vsize tilde = format.find ('~', i); - results.push_back (format.substr (i, (tilde-i))); + results.push_back (format.substr (i, (tilde - i))); if (tilde == NPOS) - break ; + break; - tilde ++; + tilde++; - char spec = format.at (tilde ++); + char spec = format.at (tilde++); if (spec == '~') - results.push_back ("~"); + results.push_back ("~"); else - { - if (!scm_is_pair (rest)) - { - programming_error (string (__FUNCTION__) - + ": not enough arguments for format."); - return ly_string2scm (""); - } - - SCM arg = scm_car (rest); - rest = scm_cdr (rest); - - int precision = 8; - - if (spec == '$') - precision = 2; - else if (isdigit (spec)) - { - precision = spec - '0'; - spec = format.at (tilde ++); - } - - if (spec == 'a' || spec == 'A' || spec == 'f' || spec == '$') - results.push_back (format_single_argument (arg, precision)); - else if (spec == 's' || spec == 'S') - results.push_back (format_single_argument (arg, precision, true)); - else if (spec == 'l') - { - SCM s = arg; - for (; scm_is_pair (s); s = scm_cdr (s)) - { - results.push_back (format_single_argument (scm_car (s), precision)); - if (scm_cdr (s) != SCM_EOL) - results.push_back (" "); - } - - if (s != SCM_EOL) - results.push_back (format_single_argument (s, precision)); - - } - } + { + if (!scm_is_pair (rest)) + { + programming_error (string (__FUNCTION__) + + ": not enough arguments for format."); + return ly_string2scm (""); + } + + SCM arg = scm_car (rest); + rest = scm_cdr (rest); + + int precision = 8; + + if (spec == '$') + precision = 2; + else if (isdigit (spec)) + { + precision = spec - '0'; + spec = format.at (tilde++); + } + + if (spec == 'a' || spec == 'A' || spec == 'f' || spec == '$') + results.push_back (format_single_argument (arg, precision)); + else if (spec == 's' || spec == 'S') + results.push_back (format_single_argument (arg, precision, true)); + else if (spec == 'l') + { + SCM s = arg; + for (; scm_is_pair (s); s = scm_cdr (s)) + { + results.push_back (format_single_argument (scm_car (s), precision)); + if (scm_cdr (s) != SCM_EOL) + results.push_back (" "); + } + + if (s != SCM_EOL) + results.push_back (format_single_argument (s, precision)); + + } + } i = tilde; } if (scm_is_pair (rest)) programming_error (string (__FUNCTION__) - + ": too many arguments"); + + ": too many arguments"); vsize len = 0; for (vsize i = 0; i < results.size (); i++) len += results[i].size (); - char *result = (char*) scm_malloc (len + 1); + char *result = (char *) scm_malloc (len + 1); char *ptr = result; for (vsize i = 0; i < results.size (); i++) { @@ -676,14 +672,14 @@ ly_run_command (char *argv[], char **standard_output, char **standard_error) if (!standard_error) flags |= G_SPAWN_STDERR_TO_DEV_NULL; if (!g_spawn_sync (0, argv, 0, GSpawnFlags (flags), - 0, 0, - standard_output, standard_error, - &exit_status, &error)) + 0, 0, + standard_output, standard_error, + &exit_status, &error)) { fprintf (stderr, "failed (%d): %s: %s\n", exit_status, argv[0], error->message); g_error_free (error); if (!exit_status) - exit_status = -1; + exit_status = -1; } return exit_status; @@ -699,10 +695,10 @@ ly_scm2utf8 (SCM str) } LY_DEFINE (ly_spawn, "ly:spawn", - 1, 0, 1, (SCM command, SCM rest), - "Simple interface to g_spawn_sync" - " @var{str}." - " The error is formatted with @code{format} and @var{rest}.") + 1, 0, 1, (SCM command, SCM rest), + "Simple interface to g_spawn_sync" + " @var{str}." + " The error is formatted with @code{format} and @var{rest}.") { LY_ASSERT_TYPE (scm_is_string, command, 1); @@ -719,15 +715,15 @@ LY_DEFINE (ly_spawn, "ly:spawn", char *standard_output = 0; char *standard_error = 0; int exit_status = be_verbose_global - ? ly_run_command (argv, &standard_output, &standard_error) - : ly_run_command (argv, 0, 0); + ? ly_run_command (argv, &standard_output, &standard_error) + : ly_run_command (argv, 0, 0); if (be_verbose_global) { fprintf (stderr, "\n%s", standard_output); fprintf (stderr, "%s", standard_error); } - + for (int i = 0; i < n; i++) free (argv[i]); delete[] argv; diff --git a/lily/glissando-engraver.cc b/lily/glissando-engraver.cc index 26b869dd51..38270f446f 100644 --- a/lily/glissando-engraver.cc +++ b/lily/glissando-engraver.cc @@ -82,7 +82,7 @@ Glissando_engraver::acknowledge_note_column (Grob_info info) { extract_grob_set (g, "note-heads", note_heads); int glissando_index = 0; - for (vsize i=0; i < note_column_1.size (); i++) + for (vsize i = 0; i < note_column_1.size (); i++) { if (note_column_2[i] >= note_heads.size ()) { @@ -101,7 +101,7 @@ Glissando_engraver::acknowledge_note_column (Grob_info info) note_column_1.clear (); note_column_2.clear (); stop_glissandi = false; - } + } if (start_glissandi) { @@ -126,7 +126,7 @@ Glissando_engraver::acknowledge_note_column (Grob_info info) note_column_1.push_back (vsize (n1)); note_column_2.push_back (vsize (n2)); } - for (vsize i=0; i < note_column_1.size (); i++) + for (vsize i = 0; i < note_column_1.size (); i++) { lines_.push_back (make_spanner ("Glissando", event_->self_scm ())); lines_.back ()->set_bound (LEFT, note_heads[note_column_1[i]]); @@ -141,7 +141,7 @@ Glissando_engraver::stop_translation_timestep () if (start_glissandi) { if (stop_glissandi) - programming_error ("overwriting glissando"); + programming_error ("overwriting glissando"); stop_glissandi = true; start_glissandi = false; } @@ -156,29 +156,29 @@ Glissando_engraver::finalize () string msg = _ ("unterminated glissando"); if (event_) - event_->origin ()->warning (msg); + event_->origin ()->warning (msg); else - warning (msg); + warning (msg); - for (vsize i=0; i < lines_.size (); i++) + for (vsize i = 0; i < lines_.size (); i++) lines_[i]->suicide (); } - for (vsize i=0; i < kill_me_.size (); i++) + for (vsize i = 0; i < kill_me_.size (); i++) kill_me_[i]->suicide (); } ADD_ACKNOWLEDGER (Glissando_engraver, note_column); ADD_TRANSLATOR (Glissando_engraver, - /* doc */ - "Engrave glissandi.", + /* doc */ + "Engrave glissandi.", - /* create */ - "Glissando ", + /* create */ + "Glissando ", - /* read */ - "glissandoMap ", + /* read */ + "glissandoMap ", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/global-context-scheme.cc b/lily/global-context-scheme.cc index 46bdae7b90..2b02da2b2a 100644 --- a/lily/global-context-scheme.cc +++ b/lily/global-context-scheme.cc @@ -29,10 +29,10 @@ #include "warn.hh" LY_DEFINE (ly_format_output, "ly:format-output", - 1, 0, 0, (SCM context), - "Given a global context in its final state," - " process it and return the @code{Music_output} object" - " in its final state.") + 1, 0, 0, (SCM context), + "Given a global context in its final state," + " process it and return the @code{Music_output} object" + " in its final state.") { Global_context *g = dynamic_cast<Global_context *> (unsmob_context (context)); @@ -48,9 +48,9 @@ LY_DEFINE (ly_format_output, "ly:format-output", } LY_DEFINE (ly_make_global_translator, "ly:make-global-translator", - 1, 0, 0, (SCM global), - "Create a translator group and connect it to the global context" - " @var{global}. The translator group is returned.") + 1, 0, 0, (SCM global), + "Create a translator group and connect it to the global context" + " @var{global}. The translator group is returned.") { Global_context *g = dynamic_cast<Global_context *> (unsmob_context (global)); LY_ASSERT_TYPE (unsmob_global_context, global, 1); @@ -63,9 +63,9 @@ LY_DEFINE (ly_make_global_translator, "ly:make-global-translator", } LY_DEFINE (ly_make_global_context, "ly:make-global-context", - 1, 0, 0, (SCM output_def), - "Set up a global interpretation context, using the output" - " block @var{output-def}. The context is returned.") + 1, 0, 0, (SCM output_def), + "Set up a global interpretation context, using the output" + " block @var{output-def}. The context is returned.") { LY_ASSERT_SMOB (Output_def, output_def, 1); Output_def *odef = unsmob_output_def (output_def); @@ -82,9 +82,9 @@ LY_DEFINE (ly_make_global_context, "ly:make-global-context", } LY_DEFINE (ly_interpret_music_expression, "ly:interpret-music-expression", - 2, 0, 0, (SCM mus, SCM ctx), - "Interpret the music expression @var{mus} in the global context" - " @var{ctx}. The context is returned in its final state.") + 2, 0, 0, (SCM mus, SCM ctx), + "Interpret the music expression @var{mus} in the global context" + " @var{ctx}. The context is returned in its final state.") { LY_ASSERT_SMOB (Music, mus, 1); LY_ASSERT_TYPE (unsmob_global_context, ctx, 2); @@ -130,14 +130,14 @@ LY_DEFINE (ly_interpret_music_expression, "ly:interpret-music-expression", } LY_DEFINE (ly_run_translator, "ly:run-translator", - 2, 1, 0, (SCM mus, SCM output_def), - "Process @var{mus} according to @var{output-def}. An" - " interpretation context is set up, and @var{mus} is" - " interpreted with it. The context is returned in its" - " final state.\n" - "\n" - "Optionally, this routine takes an object-key to" - " to uniquely identify the score block containing it.") + 2, 1, 0, (SCM mus, SCM output_def), + "Process @var{mus} according to @var{output-def}. An" + " interpretation context is set up, and @var{mus} is" + " interpreted with it. The context is returned in its" + " final state.\n" + "\n" + "Optionally, this routine takes an object-key to" + " to uniquely identify the score block containing it.") { LY_ASSERT_SMOB (Music, mus, 1); LY_ASSERT_SMOB (Output_def, output_def, 2); diff --git a/lily/global-context.cc b/lily/global-context.cc index 8d4164c4b2..26de82b68a 100644 --- a/lily/global-context.cc +++ b/lily/global-context.cc @@ -41,9 +41,9 @@ Global_context::Global_context (Output_def *o) /* We only need the most basic stuff to bootstrap the context tree */ event_source ()->add_listener (GET_LISTENER (create_context_from_event), - ly_symbol2scm ("CreateContext")); + ly_symbol2scm ("CreateContext")); event_source ()->add_listener (GET_LISTENER (prepare), - ly_symbol2scm ("Prepare")); + ly_symbol2scm ("Prepare")); events_below ()->register_as_listener (event_source_); Context_def *globaldef = unsmob_context_def (definition_); @@ -112,14 +112,14 @@ Context * Global_context::get_score_context () const { return (scm_is_pair (context_list_)) - ? unsmob_context (scm_car (context_list_)) - : 0; + ? unsmob_context (scm_car (context_list_)) + : 0; } SCM Global_context::get_output () { - Context * c = get_score_context (); + Context *c = get_score_context (); if (c) return c->get_property ("output"); else @@ -139,33 +139,32 @@ Global_context::run_iterator_on_me (Music_iterator *iter) Moment w; w.set_infinite (1); if (iter->ok ()) - w = iter->pending_moment (); + w = iter->pending_moment (); w = sneaky_insert_extra_moment (w); if (w.main_part_.is_infinity () || w > final_mom) - break; + break; if (w == prev_mom_) - { - programming_error ("Moment is not increasing. Aborting interpretation."); - break ; - } + { + programming_error ("Moment is not increasing. Aborting interpretation."); + break; + } - if (first) - { - /* - Need this to get grace notes at start of a piece correct. - */ - first = false; - set_property ("measurePosition", w.smobbed_copy ()); - } + { + /* + Need this to get grace notes at start of a piece correct. + */ + first = false; + set_property ("measurePosition", w.smobbed_copy ()); + } send_stream_event (this, "Prepare", 0, - ly_symbol2scm ("moment"), w.smobbed_copy ()); + ly_symbol2scm ("moment"), w.smobbed_copy ()); if (iter->ok ()) - iter->process (w); + iter->process (w); send_stream_event (this, "OneTimeStep", 0, 0); apply_finalizations (); diff --git a/lily/grace-engraver.cc b/lily/grace-engraver.cc index 5055b86807..b9115dc96e 100644 --- a/lily/grace-engraver.cc +++ b/lily/grace-engraver.cc @@ -54,15 +54,15 @@ Grace_engraver::consider_change_grace_settings () if (last_moment_.grace_part_ && !now.grace_part_) { for (SCM s = grace_settings_; scm_is_pair (s); s = scm_cdr (s)) - { - SCM context = scm_caar (s); - SCM entry = scm_cdar (s); - SCM grob = scm_cadr (entry); - SCM sym = scm_caddr (entry); + { + SCM context = scm_caar (s); + SCM entry = scm_cdar (s); + SCM grob = scm_cadr (entry); + SCM sym = scm_caddr (entry); - execute_pushpop_property (unsmob_context (context), - grob, sym, SCM_UNDEFINED); - } + execute_pushpop_property (unsmob_context (context), + grob, sym, SCM_UNDEFINED); + } grace_settings_ = SCM_EOL; } @@ -72,28 +72,28 @@ Grace_engraver::consider_change_grace_settings () grace_settings_ = SCM_EOL; for (SCM s = settings; scm_is_pair (s); s = scm_cdr (s)) - { - SCM entry = scm_car (s); - SCM context_name = scm_car (entry); - SCM grob = scm_cadr (entry); - SCM sym = scm_caddr (entry); - SCM val = scm_cadr (scm_cddr (entry)); - - Context *c = context (); - while (c && !c->is_alias (context_name)) - c = c->get_parent_context (); - - if (c) - { - execute_pushpop_property (c, - grob, sym, val); - grace_settings_ - = scm_cons (scm_cons (c->self_scm (), entry), grace_settings_); - } - else - programming_error ("cannot find context from graceSettings: " - + ly_symbol2string (context_name)); - } + { + SCM entry = scm_car (s); + SCM context_name = scm_car (entry); + SCM grob = scm_cadr (entry); + SCM sym = scm_caddr (entry); + SCM val = scm_cadr (scm_cddr (entry)); + + Context *c = context (); + while (c && !c->is_alias (context_name)) + c = c->get_parent_context (); + + if (c) + { + execute_pushpop_property (c, + grob, sym, val); + grace_settings_ + = scm_cons (scm_cons (c->self_scm (), entry), grace_settings_); + } + else + programming_error ("cannot find context from graceSettings: " + + ly_symbol2string (context_name)); + } } last_moment_ = now_mom (); @@ -115,15 +115,15 @@ Grace_engraver::start_translation_timestep () #include "translator.icc" ADD_TRANSLATOR (Grace_engraver, - /* doc */ - "Set font size and other properties for grace notes.", + /* doc */ + "Set font size and other properties for grace notes.", - /* create */ - "", + /* create */ + "", - /* read */ - "graceSettings ", + /* read */ + "graceSettings ", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/grace-spacing-engraver.cc b/lily/grace-spacing-engraver.cc index 45c2bb7e7c..2abb182c7e 100644 --- a/lily/grace-spacing-engraver.cc +++ b/lily/grace-spacing-engraver.cc @@ -33,12 +33,11 @@ protected: Moment last_moment_; Spanner *grace_spacing_; - + void process_music (); void stop_translation_timestep (); }; - Grace_spacing_engraver::Grace_spacing_engraver () { grace_spacing_ = 0; @@ -53,20 +52,19 @@ Grace_spacing_engraver::process_music () grace_spacing_ = make_spanner ("GraceSpacing", SCM_EOL); } - if (grace_spacing_ && (now.grace_part_ || last_moment_.grace_part_)) { Grob *column = unsmob_grob (get_property ("currentMusicalColumn")); Pointer_group_interface::add_grob (grace_spacing_, - ly_symbol2scm ("columns"), - column); + ly_symbol2scm ("columns"), + column); column->set_object ("grace-spacing", grace_spacing_->self_scm ()); if (!grace_spacing_->get_bound (LEFT)) - grace_spacing_->set_bound (LEFT, column); + grace_spacing_->set_bound (LEFT, column); else - grace_spacing_->set_bound (RIGHT, column); + grace_spacing_->set_bound (RIGHT, column); } } @@ -79,17 +77,16 @@ Grace_spacing_engraver::stop_translation_timestep () grace_spacing_ = 0; } - ADD_TRANSLATOR (Grace_spacing_engraver, - "Bookkeeping of shortest starting and playing notes in grace" - " note runs.", - - /* create */ - "GraceSpacing ", - - /* read */ - "currentMusicalColumn ", - - /* write */ - "" - ); + "Bookkeeping of shortest starting and playing notes in grace" + " note runs.", + + /* create */ + "GraceSpacing ", + + /* read */ + "currentMusicalColumn ", + + /* write */ + "" + ); diff --git a/lily/gregorian-ligature-engraver.cc b/lily/gregorian-ligature-engraver.cc index fccf35355f..30ac2728dc 100644 --- a/lily/gregorian-ligature-engraver.cc +++ b/lily/gregorian-ligature-engraver.cc @@ -54,8 +54,8 @@ Gregorian_ligature_engraver::listen_pes_or_flexa (Stream_event *ev) } void fix_prefix (char const *name, int mask, - int *current_set, int min_set, int max_set, - Grob *primitive) + int *current_set, int min_set, int max_set, + Grob *primitive) { bool current = *current_set & mask; bool min = min_set & mask; @@ -102,99 +102,99 @@ void check_and_fix_all_prefixes (vector<Grob_info> primitives) /* compute head prefix set by inspecting primitive grob properties */ int prefix_set - = (VIRGA *to_boolean (primitive->get_property ("virga"))) - | (STROPHA *to_boolean (primitive->get_property ("stropha"))) - | (INCLINATUM *to_boolean (primitive->get_property ("inclinatum"))) - | (AUCTUM *to_boolean (primitive->get_property ("auctum"))) - | (DESCENDENS *to_boolean (primitive->get_property ("descendens"))) - | (ASCENDENS *to_boolean (primitive->get_property ("ascendens"))) - | (ORISCUS *to_boolean (primitive->get_property ("oriscus"))) - | (QUILISMA *to_boolean (primitive->get_property ("quilisma"))) - | (DEMINUTUM *to_boolean (primitive->get_property ("deminutum"))) - | (CAVUM *to_boolean (primitive->get_property ("cavum"))) - | (LINEA *to_boolean (primitive->get_property ("linea"))) - | (PES_OR_FLEXA *to_boolean (primitive->get_property ("pes-or-flexa"))); + = (VIRGA * to_boolean (primitive->get_property ("virga"))) + | (STROPHA * to_boolean (primitive->get_property ("stropha"))) + | (INCLINATUM * to_boolean (primitive->get_property ("inclinatum"))) + | (AUCTUM * to_boolean (primitive->get_property ("auctum"))) + | (DESCENDENS * to_boolean (primitive->get_property ("descendens"))) + | (ASCENDENS * to_boolean (primitive->get_property ("ascendens"))) + | (ORISCUS * to_boolean (primitive->get_property ("oriscus"))) + | (QUILISMA * to_boolean (primitive->get_property ("quilisma"))) + | (DEMINUTUM * to_boolean (primitive->get_property ("deminutum"))) + | (CAVUM * to_boolean (primitive->get_property ("cavum"))) + | (LINEA * to_boolean (primitive->get_property ("linea"))) + | (PES_OR_FLEXA * to_boolean (primitive->get_property ("pes-or-flexa"))); /* check: ascendens and descendens exclude each other; same with - auctum and deminutum */ + auctum and deminutum */ if (prefix_set & DESCENDENS) - { - fix_prefix_set (&prefix_set, - prefix_set & ~ASCENDENS, - prefix_set & ~ASCENDENS, - primitive); - } + { + fix_prefix_set (&prefix_set, + prefix_set & ~ASCENDENS, + prefix_set & ~ASCENDENS, + primitive); + } if (prefix_set & AUCTUM) - { - fix_prefix_set (&prefix_set, - prefix_set & ~DEMINUTUM, - prefix_set & ~DEMINUTUM, - primitive); - } + { + fix_prefix_set (&prefix_set, + prefix_set & ~DEMINUTUM, + prefix_set & ~DEMINUTUM, + primitive); + } /* check: virga, quilisma and oriscus cannot be combined with any - other prefix, but may be part of a pes or flexa */ + other prefix, but may be part of a pes or flexa */ if (prefix_set & VIRGA) - { - fix_prefix_set (&prefix_set, - VIRGA, - VIRGA | PES_OR_FLEXA, - primitive); - } + { + fix_prefix_set (&prefix_set, + VIRGA, + VIRGA | PES_OR_FLEXA, + primitive); + } if (prefix_set & QUILISMA) - { - fix_prefix_set (&prefix_set, - QUILISMA, - QUILISMA | PES_OR_FLEXA, - primitive); - } + { + fix_prefix_set (&prefix_set, + QUILISMA, + QUILISMA | PES_OR_FLEXA, + primitive); + } if (prefix_set & ORISCUS) - { - fix_prefix_set (&prefix_set, - ORISCUS, - ORISCUS | PES_OR_FLEXA, - primitive); - } + { + fix_prefix_set (&prefix_set, + ORISCUS, + ORISCUS | PES_OR_FLEXA, + primitive); + } /* check: auctum is the only valid optional prefix for stropha */ if (prefix_set & STROPHA) - { - fix_prefix_set (&prefix_set, - STROPHA, - STROPHA | AUCTUM, - primitive); - } + { + fix_prefix_set (&prefix_set, + STROPHA, + STROPHA | AUCTUM, + primitive); + } /* check: inclinatum may be prefixed with auctum or deminutum only */ if (prefix_set & INCLINATUM) - { - fix_prefix_set (&prefix_set, - INCLINATUM, - INCLINATUM | AUCTUM | DEMINUTUM, - primitive); - } + { + fix_prefix_set (&prefix_set, + INCLINATUM, + INCLINATUM | AUCTUM | DEMINUTUM, + primitive); + } /* check: semivocalis (deminutum but not inclinatum) must occur in - combination with and only with pes or flexa */ + combination with and only with pes or flexa */ else if (prefix_set & DEMINUTUM) - { - fix_prefix_set (&prefix_set, - DEMINUTUM | PES_OR_FLEXA, - DEMINUTUM | PES_OR_FLEXA, - primitive); - } + { + fix_prefix_set (&prefix_set, + DEMINUTUM | PES_OR_FLEXA, + DEMINUTUM | PES_OR_FLEXA, + primitive); + } /* check: cavum and linea (either or both) may be applied only - upon core punctum */ + upon core punctum */ if (prefix_set & (CAVUM | LINEA)) - { - fix_prefix_set (&prefix_set, - 0, - CAVUM | LINEA, - primitive); - } + { + fix_prefix_set (&prefix_set, + 0, + CAVUM | LINEA, + primitive); + } /* all other combinations should be valid (unless I made a - mistake) */ + mistake) */ primitive->set_property ("prefix-set", scm_from_int (prefix_set)); } @@ -219,28 +219,28 @@ provide_context_info (vector<Grob_info> primitives) int prefix_set = scm_to_int (primitive->get_property ("prefix-set")); if (prefix_set & PES_OR_FLEXA) - { - if (!i) // ligature may not start with 2nd head of pes or flexa - primitive->warning (_ ("cannot apply `\\~' on first head of ligature")); - else if (pitch > prev_pitch) // pes - { - prev_context_info |= PES_LOWER; - context_info |= PES_UPPER; - } - else if (pitch < prev_pitch) // flexa - { - prev_context_info |= FLEXA_LEFT; - context_info |= FLEXA_RIGHT; - } - else // (pitch == prev_pitch) - primitive->warning (_ ("cannot apply `\\~' on heads with identical pitch")); - } + { + if (!i) // ligature may not start with 2nd head of pes or flexa + primitive->warning (_ ("cannot apply `\\~' on first head of ligature")); + else if (pitch > prev_pitch) // pes + { + prev_context_info |= PES_LOWER; + context_info |= PES_UPPER; + } + else if (pitch < prev_pitch) // flexa + { + prev_context_info |= FLEXA_LEFT; + context_info |= FLEXA_RIGHT; + } + else // (pitch == prev_pitch) + primitive->warning (_ ("cannot apply `\\~' on heads with identical pitch")); + } if (prev_prefix_set & DEMINUTUM) - context_info |= AFTER_DEMINUTUM; + context_info |= AFTER_DEMINUTUM; if (prev_primitive) - prev_primitive->set_property ("context-info", - scm_from_int (prev_context_info)); + prev_primitive->set_property ("context-info", + scm_from_int (prev_context_info)); prev_primitive = primitive; prev_prefix_set = prefix_set; prev_context_info = context_info; @@ -248,12 +248,12 @@ provide_context_info (vector<Grob_info> primitives) } if (prev_primitive) prev_primitive->set_property ("context-info", - scm_from_int (prev_context_info)); + scm_from_int (prev_context_info)); } void Gregorian_ligature_engraver::build_ligature (Spanner *ligature, - vector<Grob_info> primitives) + vector<Grob_info> primitives) { // apply style-independent checking and transformation check_and_fix_all_prefixes (primitives); diff --git a/lily/gregorian-ligature.cc b/lily/gregorian-ligature.cc index f0606102cb..03f890e3c6 100644 --- a/lily/gregorian-ligature.cc +++ b/lily/gregorian-ligature.cc @@ -26,7 +26,7 @@ void check_prefix (string name, int mask, int prefix_set, string *str) if (prefix_set & mask) { if (!str->empty ()) - *str += ", "; + *str += ", "; *str += name; } } @@ -60,21 +60,21 @@ Gregorian_ligature::prefixes_to_str (Grob *primitive) read by the associated item class, such as VaticanaLigature.--jr */ ADD_INTERFACE (Gregorian_ligature, - "A gregorian ligature.", + "A gregorian ligature.", - /* properties */ - "virga " - "stropha " - "inclinatum " - "auctum " - "descendens " - "ascendens " - "oriscus " - "quilisma " - "deminutum " - "cavum " - "linea " - "pes-or-flexa " - "context-info " - "prefix-set " - ); + /* properties */ + "virga " + "stropha " + "inclinatum " + "auctum " + "descendens " + "ascendens " + "oriscus " + "quilisma " + "deminutum " + "cavum " + "linea " + "pes-or-flexa " + "context-info " + "prefix-set " + ); diff --git a/lily/grid-line-interface.cc b/lily/grid-line-interface.cc index e942cb0a0e..2b4b57e2f9 100644 --- a/lily/grid-line-interface.cc +++ b/lily/grid-line-interface.cc @@ -50,11 +50,11 @@ Grid_line_interface::print (SCM smobbed_me) Real staffline = me->layout ()->get_dimension (ly_symbol2scm ("line-thickness")); Real thick = robust_scm2double (me->get_property ("thickness"), 1.0) - * staffline; + * staffline; iv += -me->relative_coordinate (refp, Y_AXIS); Stencil st = Lookup::filled_box (Box (Interval (0, thick), - iv)); + iv)); return st.smobbed_copy (); } @@ -67,7 +67,7 @@ Grid_line_interface::width (SCM smob) Real staffline = me->layout ()->get_dimension (ly_symbol2scm ("line-thickness")); Real thick = robust_scm2double (me->get_property ("thickness"), 1.0) - * staffline; + * staffline; return ly_interval2scm (Interval (0, thick)); } @@ -79,16 +79,16 @@ Grid_line_interface::add_grid_point (Grob *me, Grob *b) } ADD_INTERFACE (Grid_line_interface, - "A line that is spanned between grid-points.", + "A line that is spanned between grid-points.", - /* properties */ - "elements " - "thickness " - ); + /* properties */ + "elements " + "thickness " + ); ADD_INTERFACE (Grid_point_interface, - "A spanning point for grid lines.", + "A spanning point for grid lines.", - /* properties */ - "" - ); + /* properties */ + "" + ); diff --git a/lily/grid-line-span-engraver.cc b/lily/grid-line-span-engraver.cc index ad80c9ea7e..aa4d4eb3b4 100644 --- a/lily/grid-line-span-engraver.cc +++ b/lily/grid-line-span-engraver.cc @@ -24,7 +24,7 @@ class Grid_line_span_engraver : public Engraver { Item *spanline_; - vector<Item*> lines_; + vector<Item *> lines_; public: TRANSLATOR_DECLARATIONS (Grid_line_span_engraver); @@ -48,10 +48,10 @@ Grid_line_span_engraver::acknowledge_grid_point (Grob_info i) lines_.push_back (it); if (lines_.size () >= 2 && !spanline_) - { - spanline_ = make_item ("GridLine", SCM_EOL); - spanline_->set_parent (lines_[0], X_AXIS); - } + { + spanline_ = make_item ("GridLine", SCM_EOL); + spanline_->set_parent (lines_[0], X_AXIS); + } } } @@ -61,7 +61,7 @@ Grid_line_span_engraver::stop_translation_timestep () if (spanline_) { for (vsize i = 0; i < lines_.size (); i++) - Grid_line_interface::add_grid_point (spanline_, lines_[i]); + Grid_line_interface::add_grid_point (spanline_, lines_[i]); spanline_ = 0; } @@ -71,16 +71,16 @@ Grid_line_span_engraver::stop_translation_timestep () #include "translator.icc" ADD_ACKNOWLEDGER (Grid_line_span_engraver, grid_point); ADD_TRANSLATOR (Grid_line_span_engraver, - /* doc */ - "This engraver makes cross-staff lines: It catches all normal" - " lines and draws a single span line across them.", + /* doc */ + "This engraver makes cross-staff lines: It catches all normal" + " lines and draws a single span line across them.", - /* create */ - "GridLine ", + /* create */ + "GridLine ", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/grid-point-engraver.cc b/lily/grid-point-engraver.cc index eb6376e98e..c54f607cf3 100644 --- a/lily/grid-point-engraver.cc +++ b/lily/grid-point-engraver.cc @@ -40,7 +40,7 @@ Grid_point_engraver::process_music () Moment now = now_mom (); if (!now.main_part_.mod_rat (mom->main_part_)) - make_item ("GridPoint", SCM_EOL); + make_item ("GridPoint", SCM_EOL); } } @@ -49,16 +49,16 @@ Grid_point_engraver::Grid_point_engraver () } ADD_TRANSLATOR (Grid_point_engraver, - /* doc */ - "Generate grid points.", + /* doc */ + "Generate grid points.", - /* create */ - "GridPoint ", + /* create */ + "GridPoint ", - /* read */ - "gridInterval ", + /* read */ + "gridInterval ", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/grob-array-scheme.cc b/lily/grob-array-scheme.cc index 5326626e0e..f48e3bb8b8 100644 --- a/lily/grob-array-scheme.cc +++ b/lily/grob-array-scheme.cc @@ -22,21 +22,20 @@ #include "grob.hh" LY_DEFINE (ly_grob_array_length, "ly:grob-array-length", - 1, 0, 0, - (SCM grob_arr), - "Return the length of @var{grob-arr}.") + 1, 0, 0, + (SCM grob_arr), + "Return the length of @var{grob-arr}.") { LY_ASSERT_SMOB (Grob_array, grob_arr, 1); Grob_array *me = unsmob_grob_array (grob_arr); - return scm_from_int (me->size ()); + return scm_from_int (me->size ()); } - LY_DEFINE (ly_grob_array_ref, "ly:grob-array-ref", - 2, 0, 0, - (SCM grob_arr, SCM index), - "Retrieve the @var{index}th element of @var{grob-arr}.") + 2, 0, 0, + (SCM grob_arr, SCM index), + "Retrieve the @var{index}th element of @var{grob-arr}.") { Grob_array *me = unsmob_grob_array (grob_arr); LY_ASSERT_SMOB (Grob_array, grob_arr, 1); @@ -44,15 +43,15 @@ LY_DEFINE (ly_grob_array_ref, "ly:grob-array-ref", vsize i = scm_to_uint (index); if (i == VPOS || i >= me->size ()) - scm_out_of_range (NULL, scm_from_unsigned_integer (i)); - + scm_out_of_range (NULL, scm_from_unsigned_integer (i)); + return me->grob (i)->self_scm (); } LY_DEFINE (ly_grob_array_2_list, "ly:grob-array->list", - 1, 0, 0, - (SCM grob_arr), - "Return the elements of @var{grob-arr} as a Scheme list.") + 1, 0, 0, + (SCM grob_arr), + "Return the elements of @var{grob-arr} as a Scheme list.") { Grob_array *me = unsmob_grob_array (grob_arr); LY_ASSERT_SMOB (Grob_array, grob_arr, 1); diff --git a/lily/grob-array.cc b/lily/grob-array.cc index 217ea78aa9..4df4c34b54 100644 --- a/lily/grob-array.cc +++ b/lily/grob-array.cc @@ -40,13 +40,13 @@ Grob_array::Grob_array () ordered_ = true; } -vector<Grob*> & +vector<Grob *> & Grob_array::array_reference () { return grobs_; } -vector<Grob*> const & +vector<Grob *> const & Grob_array::array () const { return grobs_; @@ -66,7 +66,7 @@ Grob_array::mark_smob (SCM s) } int -Grob_array::print_smob (SCM arr, SCM port, scm_print_state*) +Grob_array::print_smob (SCM arr, SCM port, scm_print_state *) { scm_puts ("#<Grob_array", port); @@ -97,8 +97,8 @@ void Grob_array::remove_duplicates () { assert (!ordered_); - - vector_sort (grobs_, less<Grob*> ()); + + vector_sort (grobs_, less<Grob *> ()); ::uniq (grobs_); } @@ -109,7 +109,7 @@ Grob_array::empty () const } void -Grob_array::set_array (vector<Grob*> const &src) +Grob_array::set_array (vector<Grob *> const &src) { grobs_ = src; } diff --git a/lily/grob-closure.cc b/lily/grob-closure.cc index 124d143793..4f6c0adc81 100644 --- a/lily/grob-closure.cc +++ b/lily/grob-closure.cc @@ -5,20 +5,18 @@ SCM axis_offset_symbol (Axis a) { return a == X_AXIS - ? ly_symbol2scm ("X-offset") - : ly_symbol2scm ("Y-offset"); + ? ly_symbol2scm ("X-offset") + : ly_symbol2scm ("Y-offset"); } SCM axis_parent_positioning (Axis a) { return (a == X_AXIS) - ? Grob::x_parent_positioning_proc - : Grob::y_parent_positioning_proc; + ? Grob::x_parent_positioning_proc + : Grob::y_parent_positioning_proc; } - - /* Replace @@ -27,7 +25,6 @@ axis_parent_positioning (Axis a) by (+ (PROC GROB) (orig-proc GROB)) - */ void add_offset_callback (Grob *g, SCM proc, Axis a) @@ -38,11 +35,11 @@ add_offset_callback (Grob *g, SCM proc, Axis a) && !is_simple_closure (data)) { g->set_property (axis_offset_symbol (a), proc); - return ; + return; } if (ly_is_procedure (data)) - data = ly_make_simple_closure (scm_list_1 (data)); + data = ly_make_simple_closure (scm_list_1 (data)); else if (is_simple_closure (data)) data = simple_closure_expression (data); @@ -50,12 +47,11 @@ add_offset_callback (Grob *g, SCM proc, Axis a) if (ly_is_procedure (proc)) proc = ly_make_simple_closure (scm_list_1 (proc)); - + SCM expr = scm_list_3 (plus, proc, data); g->set_property (axis_offset_symbol (a), ly_make_simple_closure (expr)); } - /* replace @@ -63,8 +59,7 @@ add_offset_callback (Grob *g, SCM proc, Axis a) by - (PROC GROB (orig-proc GROB)) - + (PROC GROB (orig-proc GROB)) */ void chain_callback (Grob *g, SCM proc, SCM sym) @@ -72,7 +67,7 @@ chain_callback (Grob *g, SCM proc, SCM sym) SCM data = g->get_property_data (sym); if (ly_is_procedure (data)) - data = ly_make_simple_closure (scm_list_1 (data)); + data = ly_make_simple_closure (scm_list_1 (data)); else if (is_simple_closure (data)) data = simple_closure_expression (data); else @@ -85,10 +80,10 @@ chain_callback (Grob *g, SCM proc, SCM sym) SCM expr = scm_list_2 (proc, data); g->set_property (sym, - - // twice: one as a wrapper for grob property routines, - // once for the actual delayed binding. - ly_make_simple_closure (ly_make_simple_closure (expr))); + + // twice: one as a wrapper for grob property routines, + // once for the actual delayed binding. + ly_make_simple_closure (ly_make_simple_closure (expr))); } void diff --git a/lily/grob-info.cc b/lily/grob-info.cc index b710477a8e..48af876153 100644 --- a/lily/grob-info.cc +++ b/lily/grob-info.cc @@ -53,11 +53,11 @@ Grob_info::event_cause () const return unsmob_stream_event (cause); } -vector<Context*> +vector<Context *> Grob_info::origin_contexts (Translator *end) const { Context *t = origin_trans_->context (); - vector<Context*> r; + vector<Context *> r; do { r.push_back (t); diff --git a/lily/grob-interface-scheme.cc b/lily/grob-interface-scheme.cc index 75755994d3..3caab844fd 100644 --- a/lily/grob-interface-scheme.cc +++ b/lily/grob-interface-scheme.cc @@ -31,18 +31,18 @@ internal_add_interface (SCM a, SCM b, SCM c) all_ifaces = tab; scm_permanent_object (tab); } - + SCM entry = scm_list_n (a, b, c, SCM_UNDEFINED); scm_hashq_set_x (all_ifaces, a, entry); } LY_DEFINE (ly_add_interface, "ly:add-interface", - 3, 0, 0, (SCM iface, SCM desc, SCM props), - "Add a new grob interface. @var{iface} is the" - " interface name, @var{desc} is the interface" - " description, and @var{props} is the list of" - " user-settable properties for the interface.") + 3, 0, 0, (SCM iface, SCM desc, SCM props), + "Add a new grob interface. @var{iface} is the" + " interface name, @var{desc} is the interface" + " description, and @var{props} is the list of" + " user-settable properties for the interface.") { LY_ASSERT_TYPE (ly_is_symbol, iface, 1); LY_ASSERT_TYPE (scm_is_string, desc, 2); @@ -54,8 +54,8 @@ LY_DEFINE (ly_add_interface, "ly:add-interface", } LY_DEFINE (ly_all_grob_interfaces, "ly:all-grob-interfaces", - 0, 0, 0, (), - "Return the hash table with all grob interface descriptions.") + 0, 0, 0, (), + "Return the hash table with all grob interface descriptions.") { return all_ifaces; } diff --git a/lily/grob-interface.cc b/lily/grob-interface.cc index 2771a8001c..c649ded5b4 100644 --- a/lily/grob-interface.cc +++ b/lily/grob-interface.cc @@ -27,8 +27,8 @@ #include "misc.hh" SCM add_interface (char const *cxx_name, - char const *descr, - char const *vars) + char const *descr, + char const *vars) { string suffix ("-interface"); string lispy_name = camel_case_to_lisp_identifier (cxx_name); @@ -51,7 +51,7 @@ check_interfaces_for_property (Grob const *me, SCM sym) if (sym == ly_symbol2scm ("meta")) { /* - otherwise we get in a nasty recursion loop. + otherwise we get in a nasty recursion loop. */ return; } @@ -64,12 +64,12 @@ check_interfaces_for_property (Grob const *me, SCM sym) { SCM iface = scm_hashq_ref (all_ifaces, scm_car (ifs), SCM_BOOL_F); if (iface == SCM_BOOL_F) - { - string msg = to_string (_f ("Unknown interface `%s'", - ly_symbol2string (scm_car (ifs)).c_str ())); - programming_error (msg); - continue; - } + { + string msg = to_string (_f ("Unknown interface `%s'", + ly_symbol2string (scm_car (ifs)).c_str ())); + programming_error (msg); + continue; + } found = found || (scm_c_memq (sym, scm_caddr (iface)) != SCM_BOOL_F); } @@ -77,8 +77,8 @@ check_interfaces_for_property (Grob const *me, SCM sym) if (!found) { string str = to_string (_f ("Grob `%s' has no interface for property `%s'", - me->name ().c_str (), - ly_symbol2string (sym).c_str ())); + me->name ().c_str (), + ly_symbol2string (sym).c_str ())); programming_error (str); } } diff --git a/lily/grob-pq-engraver.cc b/lily/grob-pq-engraver.cc index 57ba04f9c9..36459af47b 100644 --- a/lily/grob-pq-engraver.cc +++ b/lily/grob-pq-engraver.cc @@ -29,7 +29,7 @@ struct Grob_pq_entry }; bool -operator< (Grob_pq_entry const &a, Grob_pq_entry const &b) +operator < (Grob_pq_entry const &a, Grob_pq_entry const &b) { return a.end_ < b.end_; } @@ -44,7 +44,7 @@ protected: void start_translation_timestep (); void stop_translation_timestep (); void process_acknowledged (); - + vector<Grob_pq_entry> started_now_; }; @@ -59,12 +59,12 @@ Grob_pq_engraver::initialize () } LY_DEFINE (ly_grob_pq_less_p, "ly:grob-pq<?", - 2, 0, 0, (SCM a, SCM b), - "Compare two grob priority queue entries." - " This is an internal function.") + 2, 0, 0, (SCM a, SCM b), + "Compare two grob priority queue entries." + " This is an internal function.") { if (Moment::compare (*unsmob_moment (scm_car (a)), - *unsmob_moment (scm_car (b))) < 0) + *unsmob_moment (scm_car (b))) < 0) return SCM_BOOL_T; else return SCM_BOOL_F; @@ -82,7 +82,7 @@ Grob_pq_engraver::acknowledge_grob (Grob_info gi) Moment l = get_event_length (ev, n); if (!l.to_bool ()) - return; + return; Moment end = n + l; @@ -103,8 +103,8 @@ Grob_pq_engraver::process_acknowledged () for (vsize i = 0; i < started_now_.size (); i++) { *tail = scm_acons (started_now_[i].end_.smobbed_copy (), - started_now_[i].grob_->self_scm (), - SCM_EOL); + started_now_[i].grob_->self_scm (), + SCM_EOL); tail = SCM_CDRLOC (*tail); } @@ -136,8 +136,8 @@ Grob_pq_engraver::start_translation_timestep () while (scm_is_pair (busy) && *unsmob_moment (scm_caar (busy)) < now) { /* - The grob-pq-engraver is not water tight, and stuff like - tupletSpannerDuration confuses it. + The grob-pq-engraver is not water tight, and stuff like + tupletSpannerDuration confuses it. */ busy = scm_cdr (busy); } @@ -149,16 +149,16 @@ Grob_pq_engraver::start_translation_timestep () #include "translator.icc" ADD_ACKNOWLEDGER (Grob_pq_engraver, grob); ADD_TRANSLATOR (Grob_pq_engraver, - /* doc */ - "Administrate when certain grobs (e.g., note heads) stop" - " playing.", + /* doc */ + "Administrate when certain grobs (e.g., note heads) stop" + " playing.", - /* create */ - "", + /* create */ + "", - /* read */ - "busyGrobs ", + /* read */ + "busyGrobs ", - /* write */ - "busyGrobs " - ); + /* write */ + "busyGrobs " + ); diff --git a/lily/grob-property.cc b/lily/grob-property.cc index f174f7ee01..2a4368f9ab 100644 --- a/lily/grob-property.cc +++ b/lily/grob-property.cc @@ -38,62 +38,58 @@ print_property_callback_stack () static SCM modification_callback = SCM_EOL; static SCM cache_callback = SCM_EOL; - /* - FIXME: this should use ly:set-option interface instead. - */ LY_DEFINE (ly_set_grob_modification_callback, "ly:set-grob-modification-callback", - 1, 0, 0, (SCM cb), - "Specify a procedure that will be called every time LilyPond" - " modifies a grob property. The callback will receive as" - " arguments the grob that is being modified, the name of the" - " C++ file in which the modification was requested, the line" - " number in the C++ file in which the modification was requested," - " the name of the function in which the modification was" - " requested, the property to be changed, and the new value for" - " the property.") + 1, 0, 0, (SCM cb), + "Specify a procedure that will be called every time LilyPond" + " modifies a grob property. The callback will receive as" + " arguments the grob that is being modified, the name of the" + " C++ file in which the modification was requested, the line" + " number in the C++ file in which the modification was requested," + " the name of the function in which the modification was" + " requested, the property to be changed, and the new value for" + " the property.") { - modification_callback = (ly_is_procedure (cb)) ? cb : SCM_BOOL_F; + modification_callback = (ly_is_procedure (cb)) ? cb : SCM_BOOL_F; return SCM_UNSPECIFIED; } LY_DEFINE (ly_set_property_cache_callback, "ly:set-property-cache-callback", - 1, 0, 0, (SCM cb), - "Specify a procedure that will be called whenever lilypond" - " calculates a callback function and caches the result. The" - " callback will receive as arguments the grob whose property it" - " is, the name of the property, the name of the callback that" - " calculated the property, and the new (cached) value of the" - " property.") + 1, 0, 0, (SCM cb), + "Specify a procedure that will be called whenever lilypond" + " calculates a callback function and caches the result. The" + " callback will receive as arguments the grob whose property it" + " is, the name of the property, the name of the callback that" + " calculated the property, and the new (cached) value of the" + " property.") { - cache_callback = (ly_is_procedure (cb)) ? cb : SCM_BOOL_F; + cache_callback = (ly_is_procedure (cb)) ? cb : SCM_BOOL_F; return SCM_UNSPECIFIED; } - void Grob::instrumented_set_property (SCM sym, SCM v, - char const *file, - int line, - char const *fun) + char const *file, + int line, + char const *fun) { #ifndef NDEBUG if (ly_is_procedure (modification_callback)) scm_apply_0 (modification_callback, - scm_list_n (self_scm (), - scm_from_locale_string (file), - scm_from_int (line), - scm_from_locale_string (fun), - sym, v, SCM_UNDEFINED)); + scm_list_n (self_scm (), + scm_from_locale_string (file), + scm_from_int (line), + scm_from_locale_string (fun), + sym, v, SCM_UNDEFINED)); #else (void) file; (void) line; (void) fun; #endif - + internal_set_property (sym, v); } @@ -101,9 +97,9 @@ SCM Grob::get_property_alist_chain (SCM def) const { return scm_list_n (mutable_property_alist_, - immutable_property_alist_, - def, - SCM_UNDEFINED); + immutable_property_alist_, + def, + SCM_UNDEFINED); } extern void check_interfaces_for_property (Grob const *me, SCM sym); @@ -112,7 +108,7 @@ void Grob::internal_set_property (SCM sym, SCM v) { internal_set_value_on_alist (&mutable_property_alist_, - sym, v); + sym, v); } @@ -126,9 +122,9 @@ Grob::internal_set_value_on_alist (SCM *alist, SCM sym, SCM v) if (do_internal_type_checking_global) { if (!ly_is_procedure (v) - && !is_simple_closure (v) - && v != ly_symbol2scm ("calculation-in-progress")) - type_check_assignment (sym, v, ly_symbol2scm ("backend-type?")); + && !is_simple_closure (v) + && v != ly_symbol2scm ("calculation-in-progress")) + type_check_assignment (sym, v, ly_symbol2scm ("backend-type?")); check_interfaces_for_property (this, sym); } @@ -143,7 +139,7 @@ Grob::internal_get_property_data (SCM sym) const if (profile_property_accesses) note_property_access (&grob_property_lookup_table, sym); #endif - + SCM handle = scm_sloppy_assq (sym, mutable_property_alist_); if (handle != SCM_BOOL_F) return scm_cdr (handle); @@ -154,11 +150,11 @@ Grob::internal_get_property_data (SCM sym) const { SCM val = scm_cdr (handle); if (!ly_is_procedure (val) && !is_simple_closure (val)) - type_check_assignment (sym, val, ly_symbol2scm ("backend-type?")); + type_check_assignment (sym, val, ly_symbol2scm ("backend-type?")); check_interfaces_for_property (this, sym); } - + return (handle == SCM_BOOL_F) ? SCM_EOL : scm_cdr (handle); } @@ -171,23 +167,23 @@ Grob::internal_get_property (SCM sym) const if (val == ly_symbol2scm ("calculation-in-progress")) { programming_error (_f ("cyclic dependency: calculation-in-progress encountered for #'%s (%s)", - ly_symbol2string (sym).c_str (), - name ().c_str ())); + ly_symbol2string (sym).c_str (), + name ().c_str ())); if (debug_property_callbacks) - { - message ("backtrace: "); - print_property_callback_stack (); - } + { + message ("backtrace: "); + print_property_callback_stack (); + } } #endif - + if (ly_is_procedure (val) || is_simple_closure (val)) { - Grob *me = ((Grob*)this); + Grob *me = ((Grob *)this); val = me->try_callback_on_alist (&me->mutable_property_alist_, sym, val); } - + return val; } @@ -200,8 +196,8 @@ Grob::internal_get_pure_property (SCM sym, int start, int end) const return call_pure_function (val, scm_list_1 (self_scm ()), start, end); if (is_simple_closure (val)) return evaluate_with_simple_closure (self_scm (), - simple_closure_expression (val), - true, start, end); + simple_closure_expression (val), + true, start, end); return val; } @@ -213,7 +209,7 @@ Grob::internal_get_maybe_pure_property (SCM sym, bool pure, int start, int end) SCM Grob::try_callback_on_alist (SCM *alist, SCM sym, SCM proc) -{ +{ SCM marker = ly_symbol2scm ("calculation-in-progress"); /* need to put a value in SYM to ensure that we don't get a @@ -232,15 +228,15 @@ Grob::try_callback_on_alist (SCM *alist, SCM sym, SCM proc) else if (is_simple_closure (proc)) { value = evaluate_with_simple_closure (self_scm (), - simple_closure_expression (proc), - false, 0, 0); + simple_closure_expression (proc), + false, 0, 0); } - + #ifndef NDEBUG if (debug_property_callbacks) grob_property_callback_stack = scm_cdr (grob_property_callback_stack); #endif - + /* If the function returns SCM_UNSPECIFIED, we assume the property has been set with an explicit set_property () @@ -251,22 +247,22 @@ Grob::try_callback_on_alist (SCM *alist, SCM sym, SCM proc) value = get_property_data (sym); assert (value == SCM_EOL || value == marker); if (value == marker) - *alist = scm_assq_remove_x (*alist, marker); + *alist = scm_assq_remove_x (*alist, marker); } else { #ifndef NDEBUG if (ly_is_procedure (cache_callback)) - scm_apply_0 (cache_callback, - scm_list_n (self_scm (), - sym, - proc, - value, - SCM_UNDEFINED)); + scm_apply_0 (cache_callback, + scm_list_n (self_scm (), + sym, + proc, + value, + SCM_UNDEFINED)); #endif internal_set_value_on_alist (alist, sym, value); } - + return value; } @@ -293,17 +289,17 @@ Grob::internal_get_object (SCM sym) const note_property_access (&grob_property_lookup_table, sym); SCM s = scm_sloppy_assq (sym, object_alist_); - + if (s != SCM_BOOL_F) { SCM val = scm_cdr (s); if (ly_is_procedure (val) - || is_simple_closure (val)) - { - Grob *me = ((Grob*)this); - val = me->try_callback_on_alist (&me->object_alist_, sym, val); - } - + || is_simple_closure (val)) + { + Grob *me = ((Grob *)this); + val = me->try_callback_on_alist (&me->object_alist_, sym, val); + } + return val; } @@ -328,6 +324,6 @@ call_pure_function (SCM unpure, SCM args, int start, int end) SCM scm_call_pure_function = ly_lily_module_constant ("call-pure-function"); return scm_apply_0 (scm_call_pure_function, - scm_list_4 (unpure, args, scm_from_int (start), scm_from_int (end))); + scm_list_4 (unpure, args, scm_from_int (start), scm_from_int (end))); } diff --git a/lily/grob-scheme.cc b/lily/grob-scheme.cc index f10ee2106f..1709cb7e92 100644 --- a/lily/grob-scheme.cc +++ b/lily/grob-scheme.cc @@ -25,12 +25,12 @@ #include "paper-score.hh" #include "simple-closure.hh" #include "system.hh" -#include "warn.hh" // error () +#include "warn.hh" // error () LY_DEFINE (ly_grob_property_data, "ly:grob-property-data", - 2, 0, 0, (SCM grob, SCM sym), - "Return the value for property @var{sym} of @var{grob}," - " but do not process callbacks.") + 2, 0, 0, (SCM grob, SCM sym), + "Return the value for property @var{sym} of @var{grob}," + " but do not process callbacks.") { Grob *sc = unsmob_grob (grob); @@ -41,11 +41,11 @@ LY_DEFINE (ly_grob_property_data, "ly:grob-property-data", } LY_DEFINE (ly_grob_set_property_x, "ly:grob-set-property!", - 3, 0, 0, (SCM grob, SCM sym, SCM val), - "Set @var{sym} in grob @var{grob} to value @var{val}.") + 3, 0, 0, (SCM grob, SCM sym, SCM val), + "Set @var{sym} in grob @var{grob} to value @var{val}.") { Grob *sc = unsmob_grob (grob); - + LY_ASSERT_SMOB (Grob, grob, 1); LY_ASSERT_TYPE (ly_is_symbol, sym, 2); @@ -59,8 +59,8 @@ LY_DEFINE (ly_grob_set_property_x, "ly:grob-set-property!", } LY_DEFINE (ly_grob_set_nested_property_x, "ly:grob-set-nested-property!", - 3, 0, 0, (SCM grob, SCM symlist, SCM val), - "Set nested property @var{symlist} in grob @var{grob} to value @var{val}.") + 3, 0, 0, (SCM grob, SCM symlist, SCM val), + "Set nested property @var{symlist} in grob @var{grob} to value @var{val}.") { Grob *sc = unsmob_grob (grob); @@ -78,12 +78,11 @@ LY_DEFINE (ly_grob_set_nested_property_x, "ly:grob-set-nested-property!", return SCM_UNSPECIFIED; } - LY_DEFINE (ly_grob_property, "ly:grob-property", - 2, 1, 0, (SCM grob, SCM sym, SCM val), - "Return the value for property @var{sym} of @var{grob}." - " If no value is found, return @var{val} or @code{'()}" - " if @var{val} is not specified.") + 2, 1, 0, (SCM grob, SCM sym, SCM val), + "Return the value for property @var{sym} of @var{grob}." + " If no value is found, return @var{val} or @code{'()}" + " if @var{val} is not specified.") { Grob *sc = unsmob_grob (grob); @@ -95,43 +94,41 @@ LY_DEFINE (ly_grob_property, "ly:grob-property", SCM retval = sc->internal_get_property (sym); if (retval == SCM_EOL) retval = val; - + return retval; } - LY_DEFINE (ly_grob_interfaces, "ly:grob-interfaces", - 1, 0, 0, (SCM grob), - "Return the interfaces list of grob @var{grob}.") + 1, 0, 0, (SCM grob), + "Return the interfaces list of grob @var{grob}.") { Grob *sc = unsmob_grob (grob); - + LY_ASSERT_SMOB (Grob, grob, 1); return sc->interfaces (); } LY_DEFINE (ly_grob_object, "ly:grob-object", - 2, 0, 0, (SCM grob, SCM sym), - "Return the value of a pointer in grob @var{grob} of property" - " @var{sym}. It returns @code{'()} (end-of-list) if @var{sym}" - " is undefined in @var{grob}.") + 2, 0, 0, (SCM grob, SCM sym), + "Return the value of a pointer in grob @var{grob} of property" + " @var{sym}. It returns @code{'()} (end-of-list) if @var{sym}" + " is undefined in @var{grob}.") { Grob *sc = unsmob_grob (grob); - + LY_ASSERT_SMOB (Grob, grob, 1); LY_ASSERT_TYPE (ly_is_symbol, sym, 2); return sc->internal_get_object (sym); } - LY_DEFINE (ly_grob_set_object_x, "ly:grob-set-object!", - 3, 0, 0, (SCM grob, SCM sym, SCM val), - "Set @var{sym} in grob @var{grob} to value @var{val}.") + 3, 0, 0, (SCM grob, SCM sym, SCM val), + "Set @var{sym} in grob @var{grob} to value @var{val}.") { Grob *sc = unsmob_grob (grob); - + LY_ASSERT_SMOB (Grob, grob, 1); LY_ASSERT_TYPE (ly_is_symbol, sym, 2); @@ -142,52 +139,50 @@ LY_DEFINE (ly_grob_set_object_x, "ly:grob-set-object!", /* TODO: make difference between scaled and unscalead variable in calling (i.e different funcs.) */ LY_DEFINE (ly_grob_layout, "ly:grob-layout", - 1, 0, 0, (SCM grob), - "Get @code{\\layout} definition from grob @var{grob}.") + 1, 0, 0, (SCM grob), + "Get @code{\\layout} definition from grob @var{grob}.") { Grob *sc = unsmob_grob (grob); - + LY_ASSERT_SMOB (Grob, grob, 1); return sc->layout ()->self_scm (); } LY_DEFINE (ly_grob_alist_chain, "ly:grob-alist-chain", - 1, 1, 0, (SCM grob, SCM global), - "Get an alist chain for grob @var{grob}, with @var{global} as" - " the global default. If unspecified, @code{font-defaults}" - " from the layout block is taken.") + 1, 1, 0, (SCM grob, SCM global), + "Get an alist chain for grob @var{grob}, with @var{global} as" + " the global default. If unspecified, @code{font-defaults}" + " from the layout block is taken.") { Grob *sc = unsmob_grob (grob); - + LY_ASSERT_SMOB (Grob, grob, 1); if (global == SCM_UNDEFINED) { global = sc->layout ()->lookup_variable (ly_symbol2scm ("font-defaults")); if (global == SCM_UNDEFINED) - global = SCM_EOL; + global = SCM_EOL; } return sc->get_property_alist_chain (global); } LY_DEFINE (ly_grob_extent, "ly:grob-extent", - 3, 0, 0, (SCM grob, SCM refp, SCM axis), - "Get the extent in @var{axis} direction of @var{grob} relative to" - " the grob @var{refp}.") + 3, 0, 0, (SCM grob, SCM refp, SCM axis), + "Get the extent in @var{axis} direction of @var{grob} relative to" + " the grob @var{refp}.") { Grob *sc = unsmob_grob (grob); Grob *ref = unsmob_grob (refp); - - + LY_ASSERT_SMOB (Grob, grob, 1); LY_ASSERT_SMOB (Grob, refp, 2); LY_ASSERT_TYPE (is_axis, axis, 3); Axis a = Axis (scm_to_int (axis)); - if (ref->common_refpoint (sc, a) != ref) { // ugh. should use other error message @@ -197,20 +192,19 @@ LY_DEFINE (ly_grob_extent, "ly:grob-extent", } LY_DEFINE (ly_grob_robust_relative_extent, "ly:grob-robust-relative-extent", - 3, 0, 0, (SCM grob, SCM refp, SCM axis), - "Get the extent in @var{axis} direction of @var{grob} relative to" - " the grob @var{refp}, or @code{(0,0)} if empty.") + 3, 0, 0, (SCM grob, SCM refp, SCM axis), + "Get the extent in @var{axis} direction of @var{grob} relative to" + " the grob @var{refp}, or @code{(0,0)} if empty.") { Grob *sc = unsmob_grob (grob); Grob *ref = unsmob_grob (refp); - - + LY_ASSERT_SMOB (Grob, grob, 1); LY_ASSERT_SMOB (Grob, refp, 2); LY_ASSERT_TYPE (is_axis, axis, 3); Axis a = Axis (scm_to_int (axis)); - + if (ref->common_refpoint (sc, a) != ref) { // ugh. should use other error message @@ -221,21 +215,19 @@ LY_DEFINE (ly_grob_robust_relative_extent, "ly:grob-robust-relative-extent", } LY_DEFINE (ly_grob_relative_coordinate, "ly:grob-relative-coordinate", - 3, 0, 0, (SCM grob, SCM refp, SCM axis), - "Get the coordinate in @var{axis} direction of @var{grob} relative" - " to the grob @var{refp}.") + 3, 0, 0, (SCM grob, SCM refp, SCM axis), + "Get the coordinate in @var{axis} direction of @var{grob} relative" + " to the grob @var{refp}.") { Grob *sc = unsmob_grob (grob); Grob *ref = unsmob_grob (refp); - - + LY_ASSERT_SMOB (Grob, grob, 1); LY_ASSERT_SMOB (Grob, refp, 2); LY_ASSERT_TYPE (is_axis, axis, 3); Axis a = Axis (scm_to_int (axis)); - if (ref->common_refpoint (sc, a) != ref) { // ugh. should use other error message @@ -245,14 +237,13 @@ LY_DEFINE (ly_grob_relative_coordinate, "ly:grob-relative-coordinate", return scm_from_double (sc->relative_coordinate (ref, a)); } - LY_DEFINE (ly_grob_parent, "ly:grob-parent", - 2, 0, 0, (SCM grob, SCM axis), - "Get the parent of @var{grob}. @var{axis} is 0 for the X-axis," - " 1@tie{}for the Y-axis.") + 2, 0, 0, (SCM grob, SCM axis), + "Get the parent of @var{grob}. @var{axis} is 0 for the X-axis," + " 1@tie{}for the Y-axis.") { Grob *sc = unsmob_grob (grob); - + LY_ASSERT_SMOB (Grob, grob, 1); LY_ASSERT_TYPE (is_axis, axis, 2); @@ -261,8 +252,8 @@ LY_DEFINE (ly_grob_parent, "ly:grob-parent", } LY_DEFINE (ly_grob_set_parent_x, "ly:grob-set-parent!", - 3, 0, 0, (SCM grob, SCM axis, SCM parent_grob), - "Set @var{parent-grob} the parent of grob @var{grob} in axis @var{axis}.") + 3, 0, 0, (SCM grob, SCM axis, SCM parent_grob), + "Set @var{parent-grob} the parent of grob @var{grob} in axis @var{axis}.") { Grob *gr = unsmob_grob (grob); Grob *parent = unsmob_grob (parent_grob); @@ -277,11 +268,11 @@ LY_DEFINE (ly_grob_set_parent_x, "ly:grob-set-parent!", } LY_DEFINE (ly_grob_properties, "ly:grob-properties", - 1, 0, 0, (SCM grob), - "Get the mutable properties of @var{grob}.") + 1, 0, 0, (SCM grob), + "Get the mutable properties of @var{grob}.") { Grob *g = unsmob_grob (grob); - + LY_ASSERT_SMOB (Grob, grob, 1); /* FIXME: uhg? copy/read only? */ @@ -289,11 +280,11 @@ LY_DEFINE (ly_grob_properties, "ly:grob-properties", } LY_DEFINE (ly_grob_basic_properties, "ly:grob-basic-properties", - 1, 0, 0, (SCM grob), - "Get the immutable properties of @var{grob}.") + 1, 0, 0, (SCM grob), + "Get the immutable properties of @var{grob}.") { Grob *g = unsmob_grob (grob); - + LY_ASSERT_SMOB (Grob, grob, 1); /* FIXME: uhg? copy/read only? */ @@ -301,11 +292,11 @@ LY_DEFINE (ly_grob_basic_properties, "ly:grob-basic-properties", } LY_DEFINE (ly_grob_system, "ly:grob-system", - 1, 0, 0, (SCM grob), - "Return the system grob of @var{grob}.") + 1, 0, 0, (SCM grob), + "Return the system grob of @var{grob}.") { Grob *me = unsmob_grob (grob); - + LY_ASSERT_SMOB (Grob, grob, 1); if (System *g = me->get_system ()) @@ -315,22 +306,21 @@ LY_DEFINE (ly_grob_system, "ly:grob-system", } LY_DEFINE (ly_grob_original, "ly:grob-original", - 1, 0, 0, (SCM grob), - "Return the unbroken original grob of @var{grob}.") + 1, 0, 0, (SCM grob), + "Return the unbroken original grob of @var{grob}.") { Grob *me = unsmob_grob (grob); - + LY_ASSERT_SMOB (Grob, grob, 1); return me->original () ? me->original ()->self_scm () : me->self_scm (); } - LY_DEFINE (ly_grob_suicide_x, "ly:grob-suicide!", - 1, 0, 0, (SCM grob), - "Kill @var{grob}.") + 1, 0, 0, (SCM grob), + "Kill @var{grob}.") { Grob *me = unsmob_grob (grob); - + LY_ASSERT_SMOB (Grob, grob, 1); me->suicide (); @@ -338,12 +328,12 @@ LY_DEFINE (ly_grob_suicide_x, "ly:grob-suicide!", } LY_DEFINE (ly_grob_translate_axis_x, "ly:grob-translate-axis!", - 3, 0, 0, (SCM grob, SCM d, SCM a), - "Translate @var{grob} on axis@tie{}@var{a} over" - " distance@tie{}@var{d}.") + 3, 0, 0, (SCM grob, SCM d, SCM a), + "Translate @var{grob} on axis@tie{}@var{a} over" + " distance@tie{}@var{d}.") { Grob *me = unsmob_grob (grob); - + LY_ASSERT_SMOB (Grob, grob, 1); LY_ASSERT_TYPE (scm_is_number, d, 2); LY_ASSERT_TYPE (is_axis, a, 3); @@ -353,30 +343,29 @@ LY_DEFINE (ly_grob_translate_axis_x, "ly:grob-translate-axis!", } LY_DEFINE (ly_grob_default_font, "ly:grob-default-font", - 1, 0, 0, (SCM grob), - "Return the default font for grob @var{grob}.") + 1, 0, 0, (SCM grob), + "Return the default font for grob @var{grob}.") { Grob *gr = unsmob_grob (grob); - + LY_ASSERT_SMOB (Grob, grob, 1); return Font_interface::get_default_font (gr)->self_scm (); } - /* TODO: consider swapping order, so we can do (grob-common-refpoint a b c d e) */ LY_DEFINE (ly_grob_common_refpoint, "ly:grob-common-refpoint", - 3, 0, 0, (SCM grob, SCM other, SCM axis), - "Find the common refpoint of @var{grob} and @var{other}" - " for @var{axis}.") + 3, 0, 0, (SCM grob, SCM other, SCM axis), + "Find the common refpoint of @var{grob} and @var{other}" + " for @var{axis}.") { - + Grob *gr = unsmob_grob (grob); - + LY_ASSERT_SMOB (Grob, grob, 1); LY_ASSERT_SMOB (Grob, other, 2); @@ -384,17 +373,17 @@ LY_DEFINE (ly_grob_common_refpoint, "ly:grob-common-refpoint", LY_ASSERT_TYPE (is_axis, axis, 3); - Grob *refp = gr->common_refpoint (o, Axis (scm_to_int (axis))); + Grob *refp = gr->common_refpoint (o, Axis (scm_to_int (axis))); return refp ? refp->self_scm () : SCM_BOOL_F; } LY_DEFINE (ly_grob_common_refpoint_of_array, "ly:grob-common-refpoint-of-array", - 3, 0, 0, (SCM grob, SCM others, SCM axis), - "Find the common refpoint of @var{grob} and @var{others}" - " (a grob-array) for @var{axis}.") + 3, 0, 0, (SCM grob, SCM others, SCM axis), + "Find the common refpoint of @var{grob} and @var{others}" + " (a grob-array) for @var{axis}.") { Grob *gr = unsmob_grob (grob); - + LY_ASSERT_SMOB (Grob, grob, 1); LY_ASSERT_SMOB (Grob_array, others, 2); @@ -406,11 +395,11 @@ LY_DEFINE (ly_grob_common_refpoint_of_array, "ly:grob-common-refpoint-of-array", } LY_DEFINE (ly_grob_chain_callback, "ly:grob-chain-callback", - 3, 0, 0, (SCM grob, SCM proc, SCM sym), - "Find the callback that is stored as property" - " @var{sym} of grob @var{grob} and chain @var{proc}" - " to the head of this, meaning that it is called" - " using @var{grob} and the previous callback's result.") + 3, 0, 0, (SCM grob, SCM proc, SCM sym), + "Find the callback that is stored as property" + " @var{sym} of grob @var{grob} and chain @var{proc}" + " to the head of this, meaning that it is called" + " using @var{grob} and the previous callback's result.") { Grob *gr = unsmob_grob (grob); diff --git a/lily/grob-smob.cc b/lily/grob-smob.cc index edebcbe95e..4772e62159 100644 --- a/lily/grob-smob.cc +++ b/lily/grob-smob.cc @@ -32,7 +32,7 @@ SCM Grob::mark_smob (SCM ses) { ASSERT_LIVE_IS_ALLOWED (); - + Grob *s = (Grob *) SCM_CELL_WORD_1 (ses); scm_gc_mark (s->immutable_property_alist_); diff --git a/lily/grob.cc b/lily/grob.cc index c613effccc..993b18a31b 100644 --- a/lily/grob.cc +++ b/lily/grob.cc @@ -45,9 +45,9 @@ Grob::clone () const return new Grob (*this); } -Grob::Grob (SCM basicprops) +Grob::Grob (SCM basicprops) { - + /* FIXME: default should be no callback. */ self_scm_ = SCM_EOL; layout_ = 0; @@ -56,7 +56,7 @@ Grob::Grob (SCM basicprops) immutable_property_alist_ = basicprops; mutable_property_alist_ = SCM_EOL; object_alist_ = SCM_EOL; - + /* We do smobify_self () as the first step. Since the object lives on the heap, none of its SCM variables are protected from GC. After smobify_self (), they are. */ @@ -69,12 +69,12 @@ Grob::Grob (SCM basicprops) SCM object_cbs = scm_assq (ly_symbol2scm ("object-callbacks"), meta); if (scm_is_pair (object_cbs)) - { - for (SCM s = scm_cdr (object_cbs); scm_is_pair (s); s = scm_cdr (s)) - set_object (scm_caar (s), scm_cdar (s)); - } + { + for (SCM s = scm_cdr (object_cbs); scm_is_pair (s); s = scm_cdr (s)) + set_object (scm_caar (s), scm_cdar (s)); + } } - + if (get_property_data ("X-extent") == SCM_EOL) set_property ("X-extent", Grob::stencil_width_proc); if (get_property_data ("Y-extent") == SCM_EOL) @@ -126,36 +126,36 @@ Grob::get_print_stencil () const bool transparent = to_boolean (get_property ("transparent")); if (transparent) - retval = Stencil (m->extent_box (), SCM_EOL); + retval = Stencil (m->extent_box (), SCM_EOL); else - { - SCM expr = m->expr (); - expr = scm_list_3 (ly_symbol2scm ("grob-cause"), - self_scm (), expr); + { + SCM expr = m->expr (); + expr = scm_list_3 (ly_symbol2scm ("grob-cause"), + self_scm (), expr); - retval = Stencil (m->extent_box (), expr); - } + retval = Stencil (m->extent_box (), expr); + } SCM rot = get_property ("rotation"); if (scm_is_pair (rot)) - { - Real angle = scm_to_double (scm_car (rot)); - Real x = scm_to_double (scm_cadr (rot)); - Real y = scm_to_double (scm_caddr (rot)); + { + Real angle = scm_to_double (scm_car (rot)); + Real x = scm_to_double (scm_cadr (rot)); + Real y = scm_to_double (scm_caddr (rot)); - retval.rotate_degrees (angle, Offset (x, y)); - } + retval.rotate_degrees (angle, Offset (x, y)); + } /* color support... see interpret_stencil_expression () for more... */ SCM color = get_property ("color"); if (scm_is_pair (color)) - { - SCM expr = scm_list_3 (ly_symbol2scm ("color"), - color, - retval.expr ()); + { + SCM expr = scm_list_3 (ly_symbol2scm ("color"), + color, + retval.expr ()); - retval = Stencil (retval.extent_box (), expr); - } + retval = Stencil (retval.extent_box (), expr); + } /* process whiteout */ /* a grob has to be visible, otherwise the whiteout property has no effect */ @@ -165,7 +165,7 @@ Grob::get_print_stencil () const /* to add a round-filled-box stencil to the stencil list */ retval = *unsmob_stencil (scm_call_1 (ly_lily_module_constant ("stencil-whiteout"), - retval.smobbed_copy())); + retval.smobbed_copy ())); } } @@ -196,7 +196,7 @@ Grob::get_system () const one system in the whole score and we can find it just by following parent pointers. */ System * -Grob::get_system(Grob *me) +Grob::get_system (Grob *me) { Grob *p = me->get_parent (X_AXIS); return p ? get_system (p) : dynamic_cast<System *>(me); @@ -215,7 +215,7 @@ Grob::handle_broken_dependencies () properties, and a special function fixes FOO */ { for (SCM s = object_alist_; scm_is_pair (s); s = scm_cdr (s)) - sp->substitute_one_mutable_property (scm_caar (s), scm_cdar (s)); + sp->substitute_one_mutable_property (scm_caar (s), scm_cdar (s)); } System *system = get_system (); @@ -264,7 +264,7 @@ Grob::handle_prebroken_dependencies () { Item *it = dynamic_cast<Item *> (this); substitute_object_links (scm_from_int (it->break_status_dir ()), - original ()->object_alist_); + original ()->object_alist_); } } @@ -284,13 +284,13 @@ Grob::translate_axis (Real y, Axis a) if (isinf (y) || isnan (y)) { programming_error (_ ("Infinity or NaN encountered")); - return ; + return; } - + if (!dim_cache_[a].offset_) dim_cache_[a].offset_ = new Real (y); else - *dim_cache_[a].offset_ += y; + *dim_cache_[a].offset_ += y; } /* Find the offset relative to D. If D equals THIS, then it is 0. @@ -309,7 +309,7 @@ Grob::relative_coordinate (Grob const *refp, Axis a) const Real off = get_offset (a); if (refp == dim_cache_[a].parent_) return off; - + off += dim_cache_[a].parent_->relative_coordinate (refp, a); return off; @@ -326,7 +326,7 @@ Grob::pure_relative_y_coordinate (Grob const *refp, int start, int end) if (dim_cache_[Y_AXIS].offset_) { if (to_boolean (get_property ("pure-Y-offset-in-progress"))) - programming_error ("cyclic chain in pure-Y-offset callbacks"); + programming_error ("cyclic chain in pure-Y-offset callbacks"); off = *dim_cache_[Y_AXIS].offset_; } @@ -337,9 +337,9 @@ Grob::pure_relative_y_coordinate (Grob const *refp, int start, int end) dim_cache_[Y_AXIS].offset_ = new Real (0.0); set_property ("pure-Y-offset-in-progress", SCM_BOOL_T); off = robust_scm2double (call_pure_function (proc, - scm_list_1 (self_scm ()), - start, end), - 0.0); + scm_list_1 (self_scm ()), + start, end), + 0.0); del_property ("pure-Y-offset-in-progress"); delete dim_cache_[Y_AXIS].offset_; dim_cache_[Y_AXIS].offset_ = 0; @@ -354,7 +354,7 @@ Grob::pure_relative_y_coordinate (Grob const *refp, int start, int end) { Real trans = 0; if (Align_interface::has_interface (p) && !dim_cache_[Y_AXIS].offset_) - trans = Align_interface::get_pure_child_y_translation (p, this, start, end); + trans = Align_interface::get_pure_child_y_translation (p, this, start, end); return off + trans + p->pure_relative_y_coordinate (refp, start, end); } @@ -394,7 +394,7 @@ Grob::maybe_pure_coordinate (Grob const *refp, Axis a, bool pure, int start, int if (pure && a != Y_AXIS) programming_error ("tried to get pure X-offset"); return (pure && a == Y_AXIS) ? pure_relative_y_coordinate (refp, start, end) - : relative_coordinate (refp, a); + : relative_coordinate (refp, a); } /**************************************************************** @@ -407,18 +407,17 @@ Grob::flush_extent_cache (Axis axis) if (dim_cache_[axis].extent_) { /* - Ugh, this is not accurate; will flush property, causing - callback to be called if. + Ugh, this is not accurate; will flush property, causing + callback to be called if. */ del_property ((axis == X_AXIS) ? ly_symbol2scm ("X-extent") : ly_symbol2scm ("Y-extent")); delete dim_cache_[axis].extent_; dim_cache_[axis].extent_ = 0; if (get_parent (axis)) - get_parent (axis)->flush_extent_cache (axis); + get_parent (axis)->flush_extent_cache (axis); } } - Interval Grob::extent (Grob *refp, Axis a) const { @@ -431,30 +430,30 @@ Grob::extent (Grob *refp, Axis a) const else { /* - Order is significant: ?-extent may trigger suicide. + Order is significant: ?-extent may trigger suicide. */ - SCM ext_sym = - (a == X_AXIS) - ? ly_symbol2scm ("X-extent") - : ly_symbol2scm ("Y-extent"); - + SCM ext_sym + = (a == X_AXIS) + ? ly_symbol2scm ("X-extent") + : ly_symbol2scm ("Y-extent"); + SCM ext = internal_get_property (ext_sym); if (is_number_pair (ext)) - real_ext.unite (ly_scm2interval (ext)); + real_ext.unite (ly_scm2interval (ext)); - SCM min_ext_sym = - (a == X_AXIS) - ? ly_symbol2scm ("minimum-X-extent") - : ly_symbol2scm ("minimum-Y-extent"); + SCM min_ext_sym + = (a == X_AXIS) + ? ly_symbol2scm ("minimum-X-extent") + : ly_symbol2scm ("minimum-Y-extent"); SCM min_ext = internal_get_property (min_ext_sym); if (is_number_pair (min_ext)) - real_ext.unite (ly_scm2interval (min_ext)); + real_ext.unite (ly_scm2interval (min_ext)); - ((Grob*)this)->dim_cache_[a].extent_ = new Interval (real_ext); + ((Grob *)this)->dim_cache_[a].extent_ = new Interval (real_ext); } - + real_ext.translate (offset); - + return real_ext; } @@ -519,7 +518,7 @@ Grob::common_refpoint (Grob const *s, Axis a) const for (Grob const *c = this; c; c = c->dim_cache_[a].parent_) for (Grob const *d = s; d; d = d->dim_cache_[a].parent_) if (d == c) - return (Grob *) d; + return (Grob *) d; return 0; } @@ -536,7 +535,6 @@ Grob::get_parent (Axis a) const return dim_cache_[a].parent_; } - void Grob::fixup_refpoint () { @@ -546,32 +544,31 @@ Grob::fixup_refpoint () Grob *parent = get_parent (ax); if (!parent) - continue; + continue; if (parent->get_system () != get_system () && get_system ()) - { - Grob *newparent = parent->find_broken_piece (get_system ()); - set_parent (newparent, ax); - } + { + Grob *newparent = parent->find_broken_piece (get_system ()); + set_parent (newparent, ax); + } if (Item *i = dynamic_cast<Item *> (this)) - { - Item *parenti = dynamic_cast<Item *> (parent); - - if (parenti && i) - { - Direction my_dir = i->break_status_dir (); - if (my_dir != parenti->break_status_dir ()) - { - Item *newparent = parenti->find_prebroken_piece (my_dir); - set_parent (newparent, ax); - } - } - } + { + Item *parenti = dynamic_cast<Item *> (parent); + + if (parenti && i) + { + Direction my_dir = i->break_status_dir (); + if (my_dir != parenti->break_status_dir ()) + { + Item *newparent = parenti->find_prebroken_piece (my_dir); + set_parent (newparent, ax); + } + } + } } } - /**************************************************************** MESSAGES ****************************************************************/ @@ -594,7 +591,6 @@ Grob::warning (string s) const ::warning (s); } - string Grob::name () const { @@ -625,77 +621,76 @@ Grob::programming_error (string s) const ::message (s); } - ADD_INTERFACE (Grob, - "A grob represents a piece of music notation.\n" - "\n" - "All grobs have an X and Y@tie{}position on the page. These" - " X and Y@tie{}positions are stored in a relative format, thus" - " they can easily be combined by stacking them, hanging one" - " grob to the side of another, or coupling them into grouping" - " objects.\n" - "\n" - "Each grob has a reference point (a.k.a.@: parent): The" - " position of a grob is stored relative to that reference" - " point. For example, the X@tie{}reference point of a staccato" - " dot usually is the note head that it applies to. When the" - " note head is moved, the staccato dot moves along" - " automatically.\n" - "\n" - "A grob is often associated with a symbol, but some grobs do" - " not print any symbols. They take care of grouping objects." - " For example, there is a separate grob that stacks staves" - " vertically. The @ref{NoteCollision} object is also an" - " abstract grob: It only moves around chords, but doesn't print" - " anything.\n" - "\n" - "Grobs have properties (Scheme variables) that can be read and" - " set. Two types of them exist: immutable and mutable." - " Immutable variables define the default style and behavior." - " They are shared between many objects. They can be changed" - " using @code{\\override} and @code{\\revert}. Mutable" - " properties are variables that are specific to one grob." - " Typically, lists of other objects, or results from" - " computations are stored in mutable properties. In" - " particular, every call to @code{ly:grob-set-property!}" - " (or its C++ equivalent) sets a mutable property.\n" - "\n" - "The properties @code{after-line-breaking} and" - " @code{before-line-breaking} are dummies that are not" - " user-serviceable.", - - /* properties */ - "X-extent " - "X-offset " - "Y-extent " - "Y-offset " - "after-line-breaking " - "avoid-slur " - "axis-group-parent-X " - "axis-group-parent-Y " - "before-line-breaking " - "cause " - "color " - "cross-staff " - "extra-X-extent " - "extra-Y-extent " - "extra-offset " - "interfaces " - "layer " - "meta " - "minimum-X-extent " - "minimum-Y-extent " - "outside-staff-horizontal-padding " - "outside-staff-padding " - "outside-staff-priority " - "pure-Y-offset-in-progress " - "rotation " - "springs-and-rods " - "staff-symbol " - "stencil " - "transparent " - "whiteout " - ); + "A grob represents a piece of music notation.\n" + "\n" + "All grobs have an X and Y@tie{}position on the page. These" + " X and Y@tie{}positions are stored in a relative format, thus" + " they can easily be combined by stacking them, hanging one" + " grob to the side of another, or coupling them into grouping" + " objects.\n" + "\n" + "Each grob has a reference point (a.k.a.@: parent): The" + " position of a grob is stored relative to that reference" + " point. For example, the X@tie{}reference point of a staccato" + " dot usually is the note head that it applies to. When the" + " note head is moved, the staccato dot moves along" + " automatically.\n" + "\n" + "A grob is often associated with a symbol, but some grobs do" + " not print any symbols. They take care of grouping objects." + " For example, there is a separate grob that stacks staves" + " vertically. The @ref{NoteCollision} object is also an" + " abstract grob: It only moves around chords, but doesn't print" + " anything.\n" + "\n" + "Grobs have properties (Scheme variables) that can be read and" + " set. Two types of them exist: immutable and mutable." + " Immutable variables define the default style and behavior." + " They are shared between many objects. They can be changed" + " using @code{\\override} and @code{\\revert}. Mutable" + " properties are variables that are specific to one grob." + " Typically, lists of other objects, or results from" + " computations are stored in mutable properties. In" + " particular, every call to @code{ly:grob-set-property!}" + " (or its C++ equivalent) sets a mutable property.\n" + "\n" + "The properties @code{after-line-breaking} and" + " @code{before-line-breaking} are dummies that are not" + " user-serviceable.", + + /* properties */ + "X-extent " + "X-offset " + "Y-extent " + "Y-offset " + "after-line-breaking " + "avoid-slur " + "axis-group-parent-X " + "axis-group-parent-Y " + "before-line-breaking " + "cause " + "color " + "cross-staff " + "extra-X-extent " + "extra-Y-extent " + "extra-offset " + "interfaces " + "layer " + "meta " + "minimum-X-extent " + "minimum-Y-extent " + "outside-staff-horizontal-padding " + "outside-staff-padding " + "outside-staff-priority " + "pure-Y-offset-in-progress " + "rotation " + "springs-and-rods " + "staff-symbol " + "stencil " + "transparent " + "whiteout " + ); /**************************************************************** CALLBACKS @@ -711,7 +706,6 @@ grob_stencil_extent (Grob *me, Axis a) return ly_interval2scm (e); } - MAKE_SCHEME_CALLBACK (Grob, stencil_height, 1); SCM Grob::stencil_height (SCM smob) @@ -732,13 +726,12 @@ Grob::y_parent_positioning (SCM smob) return scm_from_double (0.0); } - MAKE_SCHEME_CALLBACK (Grob, x_parent_positioning, 1); SCM Grob::x_parent_positioning (SCM smob) { Grob *me = unsmob_grob (smob); - + Grob *par = me->get_parent (X_AXIS); if (par) (void) par->get_property ("positioning-done"); @@ -754,24 +747,23 @@ Grob::stencil_width (SCM smob) return grob_stencil_extent (me, X_AXIS); } - Grob * common_refpoint_of_list (SCM elist, Grob *common, Axis a) { for (; scm_is_pair (elist); elist = scm_cdr (elist)) if (Grob *s = unsmob_grob (scm_car (elist))) { - if (common) - common = common->common_refpoint (s, a); - else - common = s; + if (common) + common = common->common_refpoint (s, a); + else + common = s; } return common; } Grob * -common_refpoint_of_array (vector<Grob*> const &arr, Grob *common, Axis a) +common_refpoint_of_array (vector<Grob *> const &arr, Grob *common, Axis a) { for (vsize i = 0; i < arr.size (); i++) if (common) diff --git a/lily/guile-init.cc b/lily/guile-init.cc index 5f1bb6e27f..df2f192538 100644 --- a/lily/guile-init.cc +++ b/lily/guile-init.cc @@ -2,7 +2,7 @@ This file is part of LilyPond, the GNU music typesetter. Copyright (C) 2006--2011 Han-Wen Nienhuys <hanwen@lilypond.org> - + LilyPond is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,15 +18,14 @@ along with LilyPond. If not, see <http://www.gnu.org/licenses/>. */ -#include "lily-guile.hh" -#include "main.hh" -#include "warn.hh" +#include "lily-guile.hh" +#include "main.hh" +#include "warn.hh" /* INIT */ - typedef void (*Void_fptr) (); vector<Void_fptr> *scm_init_funcs_; @@ -48,7 +47,7 @@ ly_init_ly_module (void *) { progress_indication ("["); scm_display (scm_c_eval_string ("(%search-load-path \"lily.scm\")"), - scm_current_error_port ()); + scm_current_error_port ()); progress_indication ("]\n"); } diff --git a/lily/hairpin.cc b/lily/hairpin.cc index 399b5d995e..3962b5e14d 100644 --- a/lily/hairpin.cc +++ b/lily/hairpin.cc @@ -37,10 +37,10 @@ Hairpin::pure_height (SCM smob, SCM, SCM) { Grob *me = unsmob_grob (smob); Real height = robust_scm2double (me->get_property ("height"), 0.0) - * Staff_symbol_referencer::staff_space (me); + * Staff_symbol_referencer::staff_space (me); Real thickness = robust_scm2double (me->get_property ("thickness"), 1) - * Staff_symbol_referencer::line_thickness (me); + * Staff_symbol_referencer::line_thickness (me); height += thickness / 2; return ly_interval2scm (Interval (-height, height)); @@ -80,7 +80,7 @@ Hairpin::print (SCM smob) Spanner *next = me->broken_neighbor (RIGHT); Stencil *s = next->get_stencil (); if (!s || s->is_empty ()) - broken[RIGHT] = false; + broken[RIGHT] = false; } Grob *common = bounds[LEFT]->common_refpoint (bounds[RIGHT], X_AXIS); @@ -91,7 +91,7 @@ Hairpin::print (SCM smob) */ bool circled_tip = ly_scm2bool (me->get_property ("circled-tip")); Real height = robust_scm2double (me->get_property ("height"), 0.2) - * Staff_symbol_referencer::staff_space (me); + * Staff_symbol_referencer::staff_space (me); /* FIXME: 0.525 is still just a guess... */ @@ -99,84 +99,84 @@ Hairpin::print (SCM smob) Real thick = 1.0; if (circled_tip) thick = robust_scm2double (me->get_property ("thickness"), 1.0) - * Staff_symbol_referencer::line_thickness (me); + * Staff_symbol_referencer::line_thickness (me); do { Item *b = bounds[d]; x_points[d] = b->relative_coordinate (common, X_AXIS); if (broken [d]) - { - if (d == LEFT) - x_points[d] = b->extent (common, X_AXIS)[RIGHT]; - } + { + if (d == LEFT) + x_points[d] = b->extent (common, X_AXIS)[RIGHT]; + } else - { - if (Text_interface::has_interface (b)) - { - Interval e = b->extent (common, X_AXIS); - if (!e.is_empty ()) - x_points[d] = e[-d] - d * padding; - } - else - { - bool neighbor_found = false; - Spanner *adjacent; - extract_grob_set (me, "adjacent-spanners", neighbors); - for (vsize i = 0; i < neighbors.size (); i++) - { - /* - FIXME: this will fuck up in case of polyphonic - notes in other voices. Need to look at note-columns - in the current staff/voice. - */ - adjacent = dynamic_cast<Spanner *> (neighbors[i]); - if (adjacent - && (adjacent->get_bound (-d)->get_column () - == b->get_column ())) - { - neighbor_found = true; - break; - } - } + { + if (Text_interface::has_interface (b)) + { + Interval e = b->extent (common, X_AXIS); + if (!e.is_empty ()) + x_points[d] = e[-d] - d * padding; + } + else + { + bool neighbor_found = false; + Spanner *adjacent; + extract_grob_set (me, "adjacent-spanners", neighbors); + for (vsize i = 0; i < neighbors.size (); i++) + { + /* + FIXME: this will fuck up in case of polyphonic + notes in other voices. Need to look at note-columns + in the current staff/voice. + */ + adjacent = dynamic_cast<Spanner *> (neighbors[i]); + if (adjacent + && (adjacent->get_bound (-d)->get_column () + == b->get_column ())) + { + neighbor_found = true; + break; + } + } - Interval e = robust_relative_extent (b, common, X_AXIS); - if (neighbor_found) - { - if (Hairpin::has_interface (adjacent)) - { - /* - Handle back-to-back hairpins with a circle in the middle - */ - if (circled_tip && (grow_dir != d)) - x_points[d] = e.center () + d * (rad - thick / 2.0); - /* - If we're hung on a paper column, that means we're not - adjacent to a text-dynamic, and we may move closer. We - make the padding a little smaller, here. - */ - else - x_points[d] = e.center () - d * padding / 3; - } - // Our neighbor is a dynamic text spanner, so add the - // same amount of padding as for text dynamics - else - x_points[d] = e[-d] - d * padding; - } - else - { - if (Note_column::has_interface (b) - && Note_column::has_rests (b)) - x_points[d] = e[-d]; - else - x_points[d] = e[d]; + Interval e = robust_relative_extent (b, common, X_AXIS); + if (neighbor_found) + { + if (Hairpin::has_interface (adjacent)) + { + /* + Handle back-to-back hairpins with a circle in the middle + */ + if (circled_tip && (grow_dir != d)) + x_points[d] = e.center () + d * (rad - thick / 2.0); + /* + If we're hung on a paper column, that means we're not + adjacent to a text-dynamic, and we may move closer. We + make the padding a little smaller, here. + */ + else + x_points[d] = e.center () - d * padding / 3; + } + // Our neighbor is a dynamic text spanner, so add the + // same amount of padding as for text dynamics + else + x_points[d] = e[-d] - d * padding; + } + else + { + if (Note_column::has_interface (b) + && Note_column::has_rests (b)) + x_points[d] = e[-d]; + else + x_points[d] = e[d]; - Item *bound = me->get_bound (d); - if (bound->is_non_musical (bound)) - x_points[d] -= d * padding; - } - } - } + Item *bound = me->get_bound (d); + if (bound->is_non_musical (bound)) + x_points[d] -= d * padding; + } + } + } } while (flip (&d) != LEFT); @@ -184,7 +184,7 @@ Hairpin::print (SCM smob) if (width < 0) { me->warning (_ ((grow_dir < 0) ? "decrescendo too small" - : "crescendo too small")); + : "crescendo too small")); width = 0; } @@ -216,14 +216,14 @@ Hairpin::print (SCM smob) if (circled_tip && !broken[tip_dir]) { if (grow_dir > 0) - x = rad * 2.0; + x = rad * 2.0; else if (grow_dir < 0) - width -= rad *2.0; + width -= rad * 2.0; } mol = Line_interface::line (me, Offset (x, starth), Offset (width, endh)); mol.add_stencil (Line_interface::line (me, - Offset (x, -starth), - Offset (width, -endh))); + Offset (x, -starth), + Offset (width, -endh))); /* Support al/del niente notation by putting a circle at the @@ -235,31 +235,31 @@ Hairpin::print (SCM smob) /* Hmmm, perhaps we should have a Lookup::circle () method? */ Stencil circle (extent, - scm_list_4 (ly_symbol2scm ("circle"), - scm_from_double (rad), - scm_from_double (thick), - SCM_BOOL_F)); + scm_list_4 (ly_symbol2scm ("circle"), + scm_from_double (rad), + scm_from_double (thick), + SCM_BOOL_F)); /* - don't add another circle if the hairpin is broken + don't add another circle if the hairpin is broken */ if (!broken[tip_dir]) - mol.add_at_edge (X_AXIS, tip_dir, Stencil (circle), 0); + mol.add_at_edge (X_AXIS, tip_dir, Stencil (circle), 0); } mol.translate_axis (x_points[LEFT] - - bounds[LEFT]->relative_coordinate (common, X_AXIS), - X_AXIS); + - bounds[LEFT]->relative_coordinate (common, X_AXIS), + X_AXIS); return mol.smobbed_copy (); } ADD_INTERFACE (Hairpin, - "A hairpin crescendo or decrescendo.", + "A hairpin crescendo or decrescendo.", - /* properties */ - "adjacent-spanners " - "circled-tip " - "bound-padding " - "grow-direction " - "height " - ); + /* properties */ + "adjacent-spanners " + "circled-tip " + "bound-padding " + "grow-direction " + "height " + ); diff --git a/lily/hara-kiri-engraver.cc b/lily/hara-kiri-engraver.cc index b8cd0cb9da..fcf4b86716 100644 --- a/lily/hara-kiri-engraver.cc +++ b/lily/hara-kiri-engraver.cc @@ -25,7 +25,7 @@ #include "translator.icc" /* - TODO: fold together with axis_group_engraver? + TODO: fold together with axis_group_engraver? */ class Hara_kiri_engraver : public Axis_group_engraver @@ -41,7 +41,6 @@ public: TRANSLATOR_DECLARATIONS (Hara_kiri_engraver); }; - Hara_kiri_engraver::Hara_kiri_engraver () { interesting_ = SCM_EOL; @@ -80,28 +79,27 @@ Hara_kiri_engraver::acknowledge_grob (Grob_info i) if (staffline_) { for (SCM s = interesting_; scm_is_pair (s); s = scm_cdr (s)) - { - if (i.grob ()->internal_has_interface (scm_car (s))) - Hara_kiri_group_spanner::add_interesting_item (staffline_, i.grob ()); - } + { + if (i.grob ()->internal_has_interface (scm_car (s))) + Hara_kiri_group_spanner::add_interesting_item (staffline_, i.grob ()); + } } } - ADD_ACKNOWLEDGER (Hara_kiri_engraver, grob); ADD_TRANSLATOR (Hara_kiri_engraver, - /* doc */ - "Like @code{Axis_group_engraver}, but make a hara-kiri" - " spanner, and add interesting items (i.e., note heads, lyric" - " syllables, and normal rests).", + /* doc */ + "Like @code{Axis_group_engraver}, but make a hara-kiri" + " spanner, and add interesting items (i.e., note heads, lyric" + " syllables, and normal rests).", - /* create */ - "VerticalAxisGroup ", + /* create */ + "VerticalAxisGroup ", - /* read */ - "keepAliveInterfaces ", + /* read */ + "keepAliveInterfaces ", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/hara-kiri-group-spanner.cc b/lily/hara-kiri-group-spanner.cc index c32735aa8e..751870ba05 100644 --- a/lily/hara-kiri-group-spanner.cc +++ b/lily/hara-kiri-group-spanner.cc @@ -70,7 +70,7 @@ bool find_in_range (SCM vector, int low, int hi, int min, int max) if (val >= min && val <= max) return true; else if (val < min) - return find_in_range (vector, mid+1, hi, min, max); + return find_in_range (vector, mid + 1, hi, min, max); return find_in_range (vector, low, mid, min, max); } @@ -103,7 +103,7 @@ Hara_kiri_group_spanner::request_suicide_alone (Grob *me, int start, int end) { int len = scm_c_vector_length (important); if (find_in_range (important, 0, len, start, end)) - return false; + return false; } else /* build the important-columns-cache */ { @@ -111,17 +111,17 @@ Hara_kiri_group_spanner::request_suicide_alone (Grob *me, int start, int end) vector<int> ranks; for (vsize i = 0; i < worth.size (); i++) - { - Interval_t<int> iv = worth[i]->spanned_rank_interval (); - for (int j = iv[LEFT]; j <= iv[RIGHT]; j++) - ranks.push_back (j); - } + { + Interval_t<int> iv = worth[i]->spanned_rank_interval (); + for (int j = iv[LEFT]; j <= iv[RIGHT]; j++) + ranks.push_back (j); + } vector_sort (ranks, less<int> ()); uniq (ranks); SCM scm_vec = scm_c_make_vector (ranks.size (), SCM_EOL); for (vsize i = 0; i < ranks.size (); i++) - scm_vector_set_x (scm_vec, scm_from_int (i), scm_from_int (ranks[i])); + scm_vector_set_x (scm_vec, scm_from_int (i), scm_from_int (ranks[i])); me->set_property ("important-column-ranks", scm_vec); return request_suicide (me, start, end); @@ -133,13 +133,13 @@ Hara_kiri_group_spanner::request_suicide_alone (Grob *me, int start, int end) void Hara_kiri_group_spanner::consider_suicide (Grob *me) { - Spanner *sp = dynamic_cast<Spanner*> (me); + Spanner *sp = dynamic_cast<Spanner *> (me); int left = sp->get_bound (LEFT)->get_column ()->get_rank (); int right = sp->get_bound (RIGHT)->get_column ()->get_rank (); if (!request_suicide (me, left, right)) return; - vector<Grob*> childs; + vector<Grob *> childs; Axis_group_interface::get_children (me, &childs); for (vsize i = 0; i < childs.size (); i++) childs[i]->suicide (); @@ -179,16 +179,15 @@ Hara_kiri_group_spanner::add_interesting_item (Grob *me, Grob *n) } ADD_INTERFACE (Hara_kiri_group_spanner, - "A group spanner that keeps track of interesting items. If it" - " doesn't contain any after line breaking, it removes itself" - " and all its children.", - - /* properties */ - "items-worth-living " - "important-column-ranks " - "keep-alive-with " - "remove-empty " - "remove-first " - ); - + "A group spanner that keeps track of interesting items. If it" + " doesn't contain any after line breaking, it removes itself" + " and all its children.", + + /* properties */ + "items-worth-living " + "important-column-ranks " + "keep-alive-with " + "remove-empty " + "remove-first " + ); diff --git a/lily/horizontal-bracket-engraver.cc b/lily/horizontal-bracket-engraver.cc index 9d5c00503d..78bba9cf15 100644 --- a/lily/horizontal-bracket-engraver.cc +++ b/lily/horizontal-bracket-engraver.cc @@ -59,7 +59,7 @@ Horizontal_bracket_engraver::listen_note_grouping (Stream_event *ev) { pop_count_++; if (pop_count_ > bracket_stack_.size ()) - ev->origin ()->warning (_ ("do not have that many brackets")); + ev->origin ()->warning (_ ("do not have that many brackets")); } else { @@ -78,9 +78,9 @@ Horizontal_bracket_engraver::acknowledge_note_column (Grob_info gi) { Side_position_interface::add_support (bracket_stack_[i], gi.grob ()); Pointer_group_interface::add_grob (bracket_stack_[i], - ly_symbol2scm ("columns"), gi.grob ()); + ly_symbol2scm ("columns"), gi.grob ()); add_bound_item (bracket_stack_[i], - gi.grob ()); + gi.grob ()); } } @@ -92,8 +92,8 @@ Horizontal_bracket_engraver::process_music () Spanner *sp = make_spanner ("HorizontalBracket", events_[k]->self_scm ()); for (vsize i = 0; i < bracket_stack_.size (); i++) - /* sp is the smallest, it should be added to the bigger brackets. */ - Side_position_interface::add_support (bracket_stack_[i], sp); + /* sp is the smallest, it should be added to the bigger brackets. */ + Side_position_interface::add_support (bracket_stack_[i], sp); bracket_stack_.push_back (sp); } } @@ -111,16 +111,16 @@ Horizontal_bracket_engraver::stop_translation_timestep () ADD_ACKNOWLEDGER (Horizontal_bracket_engraver, note_column); ADD_TRANSLATOR (Horizontal_bracket_engraver, - /* doc */ - "Create horizontal brackets over notes for musical analysis" - " purposes.", + /* doc */ + "Create horizontal brackets over notes for musical analysis" + " purposes.", - /* create */ - "HorizontalBracket ", + /* create */ + "HorizontalBracket ", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/horizontal-bracket.cc b/lily/horizontal-bracket.cc index f7a0337a3b..2ad243a1d9 100644 --- a/lily/horizontal-bracket.cc +++ b/lily/horizontal-bracket.cc @@ -17,7 +17,7 @@ along with LilyPond. If not, see <http://www.gnu.org/licenses/>. */ -#include "horizontal-bracket.hh" +#include "horizontal-bracket.hh" #include "lookup.hh" #include "side-position-interface.hh" @@ -30,55 +30,52 @@ #include "spanner.hh" #include "item.hh" - Stencil Horizontal_bracket::make_bracket (Grob *me, - Real length, - Axis a, Direction dir) + Real length, + Axis a, Direction dir) { Drul_array<Real> edge_height = robust_scm2interval (me->get_property ("edge-height"), - Interval (1.0, 1.0)); + Interval (1.0, 1.0)); Drul_array<Real> flare = robust_scm2interval (me->get_property ("bracket-flare"), - Interval (0, 0)); + Interval (0, 0)); Drul_array<Real> shorten = robust_scm2interval (me->get_property ("shorten-pair"), - Interval (0, 0)); + Interval (0, 0)); - // Make sure that it points in the correct direction: scale_drul (&edge_height, Real (-dir)); - + Interval empty; Offset start; start[a] = length; - Drul_array<bool> connect_to_other = - robust_scm2booldrul (me->get_property ("connect-to-neighbor"), - Drul_array<bool> (false, false)); + Drul_array<bool> connect_to_other + = robust_scm2booldrul (me->get_property ("connect-to-neighbor"), + Drul_array<bool> (false, false)); Direction d = LEFT; do { if (connect_to_other[d]) - { - edge_height[d] = 0.0; - flare[d] = 0.0; - shorten[d] = 0.0; - } + { + edge_height[d] = 0.0; + flare[d] = 0.0; + shorten[d] = 0.0; + } } while (flip (&d) != LEFT); - + /* - ugh, Tuplet_bracket should use Horizontal_bracket, not the other way around. + ugh, Tuplet_bracket should use Horizontal_bracket, not the other way around. */ - return Tuplet_bracket::make_bracket (me, other_axis (a), start, - edge_height, empty, flare, shorten); + return Tuplet_bracket::make_bracket (me, other_axis (a), start, + edge_height, empty, flare, shorten); } - Stencil Horizontal_bracket::make_enclosing_bracket (Grob *me, Grob *refpoint, - vector<Grob*> grobs, - Axis a, Direction dir) + vector<Grob *> grobs, + Axis a, Direction dir) { Grob *common = common_refpoint_of_array (grobs, refpoint, a); Interval ext = Axis_group_interface::relative_group_extent (grobs, common, a); @@ -109,7 +106,7 @@ Horizontal_bracket::print (SCM smob) Spanner *me = unsmob_spanner (smob); extract_grob_set (me, "columns", gs); - vector<Grob*> enclosed = gs; + vector<Grob *> enclosed = gs; if (!gs.size ()) { me->suicide (); @@ -121,22 +118,22 @@ Horizontal_bracket::print (SCM smob) { Item *b = me->get_bound (d); if (b->break_status_dir ()) - enclosed.push_back (b); + enclosed.push_back (b); } while (flip (&d) != LEFT); - + Stencil b = make_enclosing_bracket (me, me, enclosed, X_AXIS, get_grob_direction (me)); return b.smobbed_copy (); } ADD_INTERFACE (Horizontal_bracket, - "A horizontal bracket encompassing notes.", - - /* properties */ - "bracket-flare " - "columns " - "edge-height " - "shorten-pair " - "connect-to-neighbor " - ); + "A horizontal bracket encompassing notes.", + + /* properties */ + "bracket-flare " + "columns " + "edge-height " + "shorten-pair " + "connect-to-neighbor " + ); diff --git a/lily/hyphen-engraver.cc b/lily/hyphen-engraver.cc index 55696e9315..6a55ec64cd 100644 --- a/lily/hyphen-engraver.cc +++ b/lily/hyphen-engraver.cc @@ -88,7 +88,7 @@ completize_hyphen (Spanner *sp) { extract_item_set (sp, "heads", heads); if (heads.size ()) - sp->set_bound (RIGHT, heads.back ()); + sp->set_bound (RIGHT, heads.back ()); } } @@ -100,10 +100,10 @@ Hyphen_engraver::finalize () completize_hyphen (hyphen_); if (!hyphen_->get_bound (RIGHT)) - { - hyphen_->warning (_ ("removing unterminated hyphen")); - hyphen_->suicide (); - } + { + hyphen_->warning (_ ("removing unterminated hyphen")); + hyphen_->suicide (); + } hyphen_ = 0; } @@ -113,11 +113,11 @@ Hyphen_engraver::finalize () completize_hyphen (finished_hyphen_); if (!finished_hyphen_->get_bound (RIGHT)) - { - if (finished_ev_) - finished_hyphen_->warning (_ ("unterminated hyphen; removing")); - finished_hyphen_->suicide (); - } + { + if (finished_ev_) + finished_hyphen_->warning (_ ("unterminated hyphen; removing")); + finished_hyphen_->suicide (); + } finished_hyphen_ = 0; } } @@ -158,16 +158,16 @@ Hyphen_engraver::stop_translation_timestep () ADD_ACKNOWLEDGER (Hyphen_engraver, lyric_syllable); ADD_TRANSLATOR (Hyphen_engraver, - /* doc */ - "Create lyric hyphens and distance constraints between words.", + /* doc */ + "Create lyric hyphens and distance constraints between words.", - /* create */ - "LyricHyphen " - "LyricSpace ", + /* create */ + "LyricHyphen " + "LyricSpace ", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/identifier-smob.cc b/lily/identifier-smob.cc index d0e9f6e473..a9b198f6bc 100644 --- a/lily/identifier-smob.cc +++ b/lily/identifier-smob.cc @@ -37,9 +37,9 @@ print_box (SCM b, SCM port, scm_print_state *) /* This defines the primitve `make-box', which returns a new smob of type `box', initialized to `#f'. */ LY_DEFINE (ly_export, "ly:export", - 1, 0, 0, (SCM arg), - "Export a Scheme object to the parser" - " so it is treated as an identifier.") + 1, 0, 0, (SCM arg), + "Export a Scheme object to the parser" + " so it is treated as an identifier.") { SCM_RETURN_NEWSMOB (package_tag, arg); } diff --git a/lily/includable-lexer.cc b/lily/includable-lexer.cc index 4c6766c7fd..6fb6e2054c 100644 --- a/lily/includable-lexer.cc +++ b/lily/includable-lexer.cc @@ -37,14 +37,14 @@ using namespace std; #endif #ifndef YY_START -#define YY_START \ +#define YY_START \ ((yy_start - 1) / 2) #define YYSTATE YY_START #endif /* Flex >= 2.5.29 has include stack; but we don't use that yet. */ #if !HAVE_FLEXLEXER_YY_CURRENT_BUFFER -#define yy_current_buffer \ +#define yy_current_buffer \ (yy_buffer_stack != 0 ? yy_buffer_stack[yy_buffer_stack_top] : 0) #endif @@ -71,7 +71,7 @@ Includable_lexer::new_input (string name, Sources *sources) string msg = _f ("cannot find file: `%s'", name); msg += "\n"; msg += _f ("(search path: `%s')", - (current_dir.length () ? (current_dir + PATHSEP) : "") + sources->path_->to_string ().c_str ()); + (current_dir.length () ? (current_dir + PATHSEP) : "") + sources->path_->to_string ().c_str ()); LexerError (msg.c_str ()); return; } @@ -85,7 +85,7 @@ Includable_lexer::new_input (string name, Sources *sources) { string spaces = ""; for (size_t i = 0; i < state_stack_.size (); i++) - spaces += " "; + spaces += " "; progress_indication (string ("\n") + spaces + string ("[") + file->name_string ()); } @@ -113,7 +113,7 @@ Includable_lexer::new_input (string name, string data, Sources *sources) { string spaces = ""; for (size_t i = 0; i < state_stack_.size (); i++) - spaces += " "; + spaces += " "; progress_indication (string ("\n") + spaces + string ("[") + name); } include_stack_.push_back (file); diff --git a/lily/include/accidental-interface.hh b/lily/include/accidental-interface.hh index c3e6f51667..5b1dc796dd 100644 --- a/lily/include/accidental-interface.hh +++ b/lily/include/accidental-interface.hh @@ -33,8 +33,8 @@ public: DECLARE_SCHEME_CALLBACK (height, (SCM)); DECLARE_SCHEME_CALLBACK (width, (SCM)); DECLARE_SCHEME_CALLBACK (pure_height, (SCM, SCM, SCM)); - - DECLARE_GROB_INTERFACE(); + + DECLARE_GROB_INTERFACE (); static string get_fontcharname (string style, int alteration); static vector<Box> accurate_boxes (Grob *me, Grob **common); static SCM get_stencil (Grob *me); diff --git a/lily/include/accidental-placement.hh b/lily/include/accidental-placement.hh index 6f9696ef5e..6a92ce4783 100644 --- a/lily/include/accidental-placement.hh +++ b/lily/include/accidental-placement.hh @@ -29,13 +29,13 @@ public: DECLARE_SCHEME_CALLBACK (alignment_callback, (SCM element)); static void add_accidental (Grob *, Grob *); - static vector<Grob*> get_relevant_accidentals (vector<Grob*> const &elts, Grob *left); + static vector<Grob *> get_relevant_accidentals (vector<Grob *> const &elts, Grob *left); static void split_accidentals (Grob *accs, - vector<Grob*> *break_reminder, - vector<Grob*> *real_acc); + vector<Grob *> *break_reminder, + vector<Grob *> *real_acc); - DECLARE_SCHEME_CALLBACK(calc_positioning_done, (SCM)); - DECLARE_GROB_INTERFACE(); + DECLARE_SCHEME_CALLBACK (calc_positioning_done, (SCM)); + DECLARE_GROB_INTERFACE (); }; #endif /* ACCIDENTAL_PLACEMENT_HH */ diff --git a/lily/include/align-interface.hh b/lily/include/align-interface.hh index 0cc63b2ad1..b7ef1d5f01 100644 --- a/lily/include/align-interface.hh +++ b/lily/include/align-interface.hh @@ -29,26 +29,26 @@ class Align_interface public: DECLARE_SCHEME_CALLBACK (align_to_minimum_distances, (SCM)); DECLARE_SCHEME_CALLBACK (align_to_ideal_distances, (SCM)); - static void align_elements_to_minimum_distances(Grob *, Axis a); - static void align_elements_to_ideal_distances(Grob *); - static vector<Real> get_minimum_translations (Grob *, vector<Grob*> const&, Axis a); - static vector<Real> get_minimum_translations_without_min_dist (Grob *, vector<Grob*> const&, Axis a); - static vector<Real> get_pure_minimum_translations (Grob *, vector<Grob*> const&, - Axis a, int start, int end); + static void align_elements_to_minimum_distances (Grob *, Axis a); + static void align_elements_to_ideal_distances (Grob *); + static vector<Real> get_minimum_translations (Grob *, vector<Grob *> const &, Axis a); + static vector<Real> get_minimum_translations_without_min_dist (Grob *, vector<Grob *> const &, Axis a); + static vector<Real> get_pure_minimum_translations (Grob *, vector<Grob *> const &, + Axis a, int start, int end); static void set_ordered (Grob *); static Axis axis (Grob *); static void add_element (Grob *, Grob *); static int get_count (Grob *, Grob *); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); static Real get_pure_child_y_translation (Grob *, Grob *child, int start, int end); protected: - static vector<Real> internal_get_minimum_translations (Grob *, vector<Grob*> const&, - Axis a, - bool include_fixed_spacing, - bool pure, int start, int end); + static vector<Real> internal_get_minimum_translations (Grob *, vector<Grob *> const &, + Axis a, + bool include_fixed_spacing, + bool pure, int start, int end); }; #endif /* ALIGN_INTERFACE_HH */ diff --git a/lily/include/all-font-metrics.hh b/lily/include/all-font-metrics.hh index d170e818a7..cf0d24d6de 100644 --- a/lily/include/all-font-metrics.hh +++ b/lily/include/all-font-metrics.hh @@ -29,7 +29,6 @@ #include <pango/pangoft2.h> #endif - /* Interface to all fonts (both system fonts and fonts loaded via Pango). @@ -46,19 +45,19 @@ class All_font_metrics #endif map<string, Index_to_charcode_map > filename_charcode_maps_map_; - + All_font_metrics (All_font_metrics const &); public: Index_to_charcode_map const *get_index_to_charcode_map (string filename, - int face_index, - FT_Face face); + int face_index, + FT_Face face); All_font_metrics (string search_path); ~All_font_metrics (); Pango_font *find_pango_font (PangoFontDescription const *description, - Real scale); + Real scale); Font_metric *find_font (string name); Open_type_font *find_otf (string name); diff --git a/lily/include/arpeggio.hh b/lily/include/arpeggio.hh index 094afe687b..f9096432c4 100644 --- a/lily/include/arpeggio.hh +++ b/lily/include/arpeggio.hh @@ -23,7 +23,6 @@ #include "lily-proto.hh" #include "grob-interface.hh" - class Arpeggio { public: @@ -34,7 +33,7 @@ public: DECLARE_SCHEME_CALLBACK (brew_chord_slur, (SCM)); DECLARE_SCHEME_CALLBACK (width, (SCM)); DECLARE_SCHEME_CALLBACK (pure_height, (SCM, SCM, SCM)); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); }; #endif /* ARPEGGIO_HH */ diff --git a/lily/include/articulations.hh b/lily/include/articulations.hh index f30c3bfac7..00a68e587b 100644 --- a/lily/include/articulations.hh +++ b/lily/include/articulations.hh @@ -24,8 +24,8 @@ #include "stream-event.hh" SCM articulation_list (vector<Stream_event *> notes, - vector<Stream_event *> articulations, - char const *articulation_name); + vector<Stream_event *> articulations, + char const *articulation_name); #endif /* ARTICULATIONS_HH */ diff --git a/lily/include/audio-column.hh b/lily/include/audio-column.hh index 4f51d8c00c..8a979f58cd 100644 --- a/lily/include/audio-column.hh +++ b/lily/include/audio-column.hh @@ -37,9 +37,9 @@ public: void add_audio_item (Audio_item *i); Moment when () const; - vector<Audio_item*> audio_items_; + vector<Audio_item *> audio_items_; Moment when_; - int ticks () const ; + int ticks () const; protected: void offset_when (Moment m); friend class Score_performer; diff --git a/lily/include/audio-element-info.hh b/lily/include/audio-element-info.hh index 9f58f4ea0d..9ffca6a008 100644 --- a/lily/include/audio-element-info.hh +++ b/lily/include/audio-element-info.hh @@ -33,7 +33,7 @@ public: Stream_event *event_; Translator *origin_trans_; - vector<Context*> origin_contexts (Translator *) const; + vector<Context *> origin_contexts (Translator *) const; Audio_element_info (Audio_element *, Stream_event *); Audio_element_info (); diff --git a/lily/include/audio-element.hh b/lily/include/audio-element.hh index fac2068773..876de1f6a3 100644 --- a/lily/include/audio-element.hh +++ b/lily/include/audio-element.hh @@ -28,7 +28,7 @@ public: Audio_element (); virtual ~Audio_element (); - DECLARE_CLASSNAME(Audio_element); + DECLARE_CLASSNAME (Audio_element); virtual char const *name () const; }; diff --git a/lily/include/audio-item.hh b/lily/include/audio-item.hh index da0abbce38..dc4bb6efbd 100644 --- a/lily/include/audio-item.hh +++ b/lily/include/audio-item.hh @@ -34,7 +34,7 @@ public: Audio_column *get_column () const; virtual void render (); - + private: Audio_item (Audio_item const &); Audio_item &operator = (Audio_item const &); @@ -53,15 +53,13 @@ class Audio_span_dynamic : public Audio_element { public: Direction grow_dir_; - vector<Audio_dynamic*> dynamics_; - + vector<Audio_dynamic *> dynamics_; virtual void render (); - void add_absolute (Audio_dynamic*); + void add_absolute (Audio_dynamic *); Audio_span_dynamic (); }; - class Audio_key : public Audio_item { public: @@ -90,8 +88,8 @@ public: Pitch pitch_; Moment length_mom_; Pitch transposing_; - Audio_dynamic* dynamic_; - + Audio_dynamic *dynamic_; + Audio_note *tied_; bool tie_event_; }; @@ -107,10 +105,10 @@ class Audio_text : public Audio_item { public: enum Type - { - TEXT = 1, COPYRIGHT, TRACK_NAME, INSTRUMENT_NAME, LYRIC, - MARKER, CUE_POINT - }; + { + TEXT = 1, COPYRIGHT, TRACK_NAME, INSTRUMENT_NAME, LYRIC, + MARKER, CUE_POINT + }; Audio_text (Audio_text::Type type, string text_string); diff --git a/lily/include/audio-staff.hh b/lily/include/audio-staff.hh index 665593edd6..fe570c3ad1 100644 --- a/lily/include/audio-staff.hh +++ b/lily/include/audio-staff.hh @@ -30,10 +30,10 @@ struct Audio_staff : public Audio_element void output (Midi_stream &midi_stream_r, int track, bool port); Audio_staff (); - + bool percussion_; bool merge_unisons_; - vector<Audio_item*> audio_items_; + vector<Audio_item *> audio_items_; }; #endif // AUDIO_STAFF_HH diff --git a/lily/include/axis-group-engraver.hh b/lily/include/axis-group-engraver.hh index 2f63de076c..b9719efefd 100644 --- a/lily/include/axis-group-engraver.hh +++ b/lily/include/axis-group-engraver.hh @@ -30,7 +30,7 @@ class Axis_group_engraver : public Engraver { protected: Spanner *staffline_; - vector<Grob*> elts_; + vector<Grob *> elts_; void process_music (); virtual void finalize (); DECLARE_ACKNOWLEDGER (grob); @@ -38,7 +38,7 @@ protected: virtual Spanner *get_spanner (); virtual void add_element (Grob *); virtual bool must_be_last () const; - + public: TRANSLATOR_DECLARATIONS (Axis_group_engraver); }; diff --git a/lily/include/axis-group-interface.hh b/lily/include/axis-group-interface.hh index 1537f1d358..6eb52c4df2 100644 --- a/lily/include/axis-group-interface.hh +++ b/lily/include/axis-group-interface.hh @@ -44,8 +44,8 @@ struct Axis_group_interface DECLARE_SCHEME_CALLBACK (calc_pure_relevant_items, (SCM)); DECLARE_SCHEME_CALLBACK (calc_pure_relevant_spanners, (SCM)); DECLARE_SCHEME_CALLBACK (calc_pure_y_common, (SCM)); - static Interval relative_group_extent (vector<Grob*> const &list, - Grob *common, Axis); + static Interval relative_group_extent (vector<Grob *> const &list, + Grob *common, Axis); static Interval relative_pure_height (Grob *me, int start, int end); static Interval combine_pure_heights (Grob *me, SCM, int, int); static Interval sum_partial_pure_heights (Grob *me, int, int); @@ -54,16 +54,16 @@ struct Axis_group_interface static Interval part_of_line_pure_height (Grob *me, bool begin, int, int); static bool has_outside_staff_parent (Grob *me); - static Skyline_pair skyline_spacing (Grob *me, vector<Grob*> elements); + static Skyline_pair skyline_spacing (Grob *me, vector<Grob *> elements); static void add_element (Grob *me, Grob *); static void set_axes (Grob *, Axis, Axis); static bool has_axis (Grob *, Axis); - static void get_children (Grob *, vector<Grob*> *); + static void get_children (Grob *, vector<Grob *> *); static Interval staff_extent (Grob *me, Grob *ref, Axis, Grob *staff, Axis); static SCM calc_common (Grob *, Axis); - static Real minimum_distance (Grob*, Grob*, Axis); - static SCM calc_maybe_pure_staff_staff_spacing (Grob*, bool, int, int); - DECLARE_GROB_INTERFACE(); + static Real minimum_distance (Grob *, Grob *, Axis); + static SCM calc_maybe_pure_staff_staff_spacing (Grob *, bool, int, int); + DECLARE_GROB_INTERFACE (); }; #endif /* AXIS_GROUP_INTERFACE_HH */ diff --git a/lily/include/bar-line.hh b/lily/include/bar-line.hh index 442fe27770..fce15c3e8a 100644 --- a/lily/include/bar-line.hh +++ b/lily/include/bar-line.hh @@ -26,14 +26,14 @@ class Bar_line { public: - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); static Stencil dashed_bar_line (Grob *me, Interval const &extent, Real thick); static Stencil tick_bar_line (Grob *me, Real h, bool rounded); static Stencil compound_barline (Grob *, string, Interval const &extent, - bool rounded); + bool rounded); static Stencil simple_barline (Grob *, Real wid, Interval const &extent, - bool rounded); + bool rounded); static Interval bar_y_extent (Grob *, Grob *); static bool non_empty_barline (Grob *me); diff --git a/lily/include/beam-scoring-problem.hh b/lily/include/beam-scoring-problem.hh index 08664049e8..1ba4fcb7cc 100644 --- a/lily/include/beam-scoring-problem.hh +++ b/lily/include/beam-scoring-problem.hh @@ -23,13 +23,14 @@ #include "beam.hh" #include "interval.hh" -#include "lily-guile.hh" -#include "lily-proto.hh" +#include "lily-guile.hh" +#include "lily-proto.hh" #include "main.hh" // DEBUG_BEAM_SCORING -#include "std-vector.hh" -#include "stem-info.hh" +#include "std-vector.hh" +#include "stem-info.hh" -enum Scorers { +enum Scorers +{ // Should be ordered by increasing expensiveness. ORIGINAL_DISTANCE, SLOPE_IDEAL, @@ -55,22 +56,21 @@ struct Beam_configuration Beam_configuration (); bool done () const; void add (Real demerit, const string &reason); - static Beam_configuration* new_config(Interval start, - Interval offset); + static Beam_configuration *new_config (Interval start, + Interval offset); }; // Comparator for a queue of Beam_configuration*. class Beam_configuration_less { public: - bool operator() (Beam_configuration* const& l, Beam_configuration* const& r) + bool operator () (Beam_configuration *const &l, Beam_configuration *const &r) { // Invert return l->demerits > r->demerits; } }; - struct Beam_quant_parameters { Real SECONDARY_BEAM_DEMERIT; @@ -93,11 +93,12 @@ struct Beam_quant_parameters Real COLLISION_PADDING; Real HORIZONTAL_INTER_QUANT_PENALTY; Real STEM_COLLISION_FACTOR; - + void fill (Grob *him); }; -struct Beam_collision { +struct Beam_collision +{ Real x_; Interval y_; Real base_penalty_; @@ -105,33 +106,32 @@ struct Beam_collision { // Need to add beam_config->y to get actual offsets. Interval beam_y_; }; - /* Parameters for a single beam. Precomputed to save time in scoring individual configurations. TODO - use trailing _ on data members. - + */ class Beam_scoring_problem { public: Beam_scoring_problem (Grob *me, Drul_array<Real> ys); - Drul_array<Real> solve() const; + Drul_array<Real> solve () const; private: Grob *beam; Interval unquanted_y; - + Real staff_space; Real beam_thickness; Real line_thickness; Real musical_dy; Interval x_span; - + vector<Stem_info> stem_infos; /* @@ -144,7 +144,7 @@ private: */ vector<Real> base_lengths; vector<Real> stem_xpositions; - + Grob *common[2]; bool is_xstaff; bool is_knee; @@ -163,15 +163,15 @@ private: Real beam_translation; vector<Beam_collision> collisions_; vector<Beam_segment> segments_; - + void init_stems (); - void init_collisions (vector<Grob*> grobs); + void init_collisions (vector<Grob *> grobs); void add_collision (Real x, Interval y, Real factor); - - void one_scorer (Beam_configuration* config) const; + + void one_scorer (Beam_configuration *config) const; Beam_configuration *force_score (SCM inspect_quants, - const vector<Beam_configuration*> &configs) const; - Real y_at (Real x, Beam_configuration const* c) const; + const vector<Beam_configuration *> &configs) const; + Real y_at (Real x, Beam_configuration const *c) const; // Scoring functions: void score_forbidden_quants (Beam_configuration *config) const; @@ -179,8 +179,8 @@ private: void score_slope_ideal (Beam_configuration *config) const; void score_slope_direction (Beam_configuration *config) const; void score_slope_musical (Beam_configuration *config) const; - void score_stem_lengths (Beam_configuration* config) const; - void generate_quants(vector<Beam_configuration*>* scores) const; + void score_stem_lengths (Beam_configuration *config) const; + void generate_quants (vector<Beam_configuration *>* scores) const; void score_collisions (Beam_configuration *config) const; }; diff --git a/lily/include/beam.hh b/lily/include/beam.hh index f541a216be..d89c35d6b2 100644 --- a/lily/include/beam.hh +++ b/lily/include/beam.hh @@ -29,13 +29,13 @@ struct Beam_segment { int vertical_count_; - Interval horizontal_; + Interval horizontal_; Beam_segment (); }; -bool beam_segment_less (Beam_segment const& a, Beam_segment const& b); +bool beam_segment_less (Beam_segment const &a, Beam_segment const &b); -struct Beam_stem_segment +struct Beam_stem_segment { Beam_stem_segment (); @@ -49,7 +49,6 @@ struct Beam_stem_segment int max_connect_; }; - bool operator <(Beam_stem_segment const &a, Beam_stem_segment const &b); class Beam @@ -58,7 +57,7 @@ public: static int normal_stem_count (Grob *); static Grob *first_normal_stem (Grob *); static Grob *last_normal_stem (Grob *); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); static void add_stem (Grob *, Grob *); static bool is_cross_staff (Grob *); static bool is_knee (Grob *); @@ -68,9 +67,9 @@ public: static Real get_beam_translation (Grob *me); static Real get_beam_thickness (Grob *me); static void connect_beams (Grob *me); - static vector<Beam_segment> get_beam_segments (Grob *me_grob, Grob **common); + static vector<Beam_segment> get_beam_segments (Grob *me_grob, Grob **common); static Interval no_visible_stem_positions (Grob *me, Interval default_value); - + DECLARE_SCHEME_CALLBACK (rest_collision_callback, (SCM element, SCM prev_off)); DECLARE_SCHEME_CALLBACK (print, (SCM)); DECLARE_SCHEME_CALLBACK (calc_beaming, (SCM)); @@ -78,7 +77,7 @@ public: DECLARE_SCHEME_CALLBACK (calc_direction, (SCM)); DECLARE_SCHEME_CALLBACK (calc_positions, (SCM)); DECLARE_SCHEME_CALLBACK (calc_least_squares_positions, (SCM, SCM)); - DECLARE_SCHEME_CALLBACK (calc_normal_stems, (SCM)); + DECLARE_SCHEME_CALLBACK (calc_normal_stems, (SCM)); DECLARE_SCHEME_CALLBACK (calc_concaveness, (SCM)); DECLARE_SCHEME_CALLBACK (set_stem_lengths, (SCM)); DECLARE_SCHEME_CALLBACK (calc_cross_staff, (SCM)); @@ -87,22 +86,21 @@ public: DECLARE_SCHEME_CALLBACK (shift_region_to_valid, (SCM, SCM)); DECLARE_SCHEME_CALLBACK (slope_damping, (SCM, SCM)); DECLARE_SCHEME_CALLBACK (quanting, (SCM, SCM)); - + static int get_direction_beam_count (Grob *me, Direction d); private: friend class Beam_scoring_problem; - + static Direction get_default_dir (Grob *); static void set_stem_directions (Grob *, Direction); static void consider_auto_knees (Grob *); static void set_stem_shorten (Grob *); static int forced_stem_count (Grob *); static Real calc_stem_y (Grob *, Grob *s, Grob **c, - Real, Real, Direction, - Drul_array<Real> pos, bool french); + Real, Real, Direction, + Drul_array<Real> pos, bool french); }; - #endif /* BEAM_HH */ diff --git a/lily/include/beaming-pattern.hh b/lily/include/beaming-pattern.hh index 6eed0606b3..58ec08443b 100644 --- a/lily/include/beaming-pattern.hh +++ b/lily/include/beaming-pattern.hh @@ -32,7 +32,7 @@ struct Beaming_options Moment measure_length_; Beaming_options (); - void from_context (Context*); + void from_context (Context *); }; struct Beam_rhythmic_element @@ -59,19 +59,19 @@ class Beaming_pattern public: Beaming_pattern (); - void beamify (Beaming_options const&); + void beamify (Beaming_options const &); void de_grace (); void add_stem (Moment d, int beams, bool invisible); int beamlet_count (int idx, Direction d) const; bool invisibility (int idx) const; Moment start_moment (int idx) const; Moment end_moment (int idx) const; - Beaming_pattern* split_pattern(int idx); + Beaming_pattern *split_pattern (int idx); private: vector<Beam_rhythmic_element> infos_; - Direction flag_direction (Beaming_options const&, vsize) const; - void find_rhythmic_importance (Beaming_options const&); + Direction flag_direction (Beaming_options const &, vsize) const; + void find_rhythmic_importance (Beaming_options const &); void unbeam_invisible_stems (); }; diff --git a/lily/include/bezier.hh b/lily/include/bezier.hh index bd66558a19..a144e4a755 100644 --- a/lily/include/bezier.hh +++ b/lily/include/bezier.hh @@ -43,7 +43,7 @@ public: vector<Real> solve_derivative (Offset) const; Interval extent (Axis) const; Interval control_point_extent (Axis) const; - + Polynomial polynomial (Axis)const; Offset curve_point (Real t) const; Real curve_coordinate (Real t, Axis) const; @@ -63,7 +63,7 @@ void rotate (vector<Offset> *array, Real phi); void translate (vector<Offset> *array, Offset o); Bezier slur_shape (Real width, Real height_limit, - Real height_proportion); + Real height_proportion); Real slur_height (Real width, Real height_limit, Real height_proportion); void get_slur_indent_height (Real *indent, Real *height, Real width, Real h_inf, Real r_0); diff --git a/lily/include/book.hh b/lily/include/book.hh index fa74cd5654..7431b22dfb 100644 --- a/lily/include/book.hh +++ b/lily/include/book.hh @@ -44,10 +44,10 @@ public: void add_score (SCM); void add_bookpart (SCM); Paper_book *process (Output_def *def_paper, - Output_def *def_layout); + Output_def *def_layout); Paper_book *process (Output_def *default_paper, - Output_def *default_layout, - Paper_book *parent_part); + Output_def *default_layout, + Paper_book *parent_part); void set_keys (); protected: @@ -55,11 +55,11 @@ protected: void add_scores_to_bookpart (); bool error_found (); void process_score (SCM score, - Paper_book *output_paper_book, - Output_def *layout); + Paper_book *output_paper_book, + Output_def *layout); void process_bookparts (Paper_book *output_paper_book, - Output_def *paper, - Output_def *layout); + Output_def *paper, + Output_def *layout); }; DECLARE_UNSMOB (Book, book); diff --git a/lily/include/box.hh b/lily/include/box.hh index baa4ce0b76..f08dea2ca2 100644 --- a/lily/include/box.hh +++ b/lily/include/box.hh @@ -15,9 +15,9 @@ class Box DECLARE_SIMPLE_SMOBS (Box); public: Interval &x () {return interval_a_[X_AXIS]; } - Interval &y (){ return interval_a_[Y_AXIS]; } - Interval x () const{ return interval_a_[X_AXIS]; } - Interval y () const{return interval_a_[Y_AXIS]; } + Interval &y () { return interval_a_[Y_AXIS]; } + Interval x () const { return interval_a_[X_AXIS]; } + Interval y () const {return interval_a_[Y_AXIS]; } Interval operator [] (Axis a) const; Interval &operator [] (Axis a); diff --git a/lily/include/break-align-interface.hh b/lily/include/break-align-interface.hh index c3c594ba96..e841d4b252 100644 --- a/lily/include/break-align-interface.hh +++ b/lily/include/break-align-interface.hh @@ -26,8 +26,8 @@ class Break_alignment_interface { public: - static vector<Grob*> ordered_elements (Grob *me); - DECLARE_GROB_INTERFACE(); + static vector<Grob *> ordered_elements (Grob *me); + DECLARE_GROB_INTERFACE (); static void add_element (Grob *me, Grob *add); static SCM break_align_order (Item *me); DECLARE_SCHEME_CALLBACK (calc_positioning_done, (SCM element)); @@ -39,13 +39,13 @@ struct Break_aligned_interface DECLARE_SCHEME_CALLBACK (calc_average_anchor, (SCM)); DECLARE_SCHEME_CALLBACK (calc_extent_aligned_anchor, (SCM)); DECLARE_SCHEME_CALLBACK (calc_break_visibility, (SCM)); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); }; struct Break_alignable_interface { DECLARE_SCHEME_CALLBACK (self_align_callback, (SCM element)); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); }; #endif // BREAK_ALIGN_INTERFACE_HH diff --git a/lily/include/breathing-sign.hh b/lily/include/breathing-sign.hh index 948dd09d75..f473dbcaac 100644 --- a/lily/include/breathing-sign.hh +++ b/lily/include/breathing-sign.hh @@ -29,7 +29,7 @@ public: DECLARE_SCHEME_CALLBACK (finalis, (SCM)); DECLARE_SCHEME_CALLBACK (offset_callback, (SCM element)); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); }; #endif // BREATHING_SIGN_HH diff --git a/lily/include/change-iterator.hh b/lily/include/change-iterator.hh index 99a3dde190..f6cf400bc1 100644 --- a/lily/include/change-iterator.hh +++ b/lily/include/change-iterator.hh @@ -28,7 +28,7 @@ public: /* constructor is public */ virtual void process (Moment); DECLARE_SCHEME_CALLBACK (constructor, ()); - DECLARE_CLASSNAME(Change_iterator); + DECLARE_CLASSNAME (Change_iterator); private: void error (string); diff --git a/lily/include/chord-name.hh b/lily/include/chord-name.hh index 91e6593361..9addbc4a1e 100644 --- a/lily/include/chord-name.hh +++ b/lily/include/chord-name.hh @@ -27,7 +27,7 @@ class Chord_name { public: DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM)); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); }; #endif // CHORD_NAME_HH diff --git a/lily/include/chord-tremolo-iterator.hh b/lily/include/chord-tremolo-iterator.hh index 9ab96ec5d4..476c972858 100644 --- a/lily/include/chord-tremolo-iterator.hh +++ b/lily/include/chord-tremolo-iterator.hh @@ -27,7 +27,7 @@ class Chord_tremolo_iterator : public Sequential_iterator public: DECLARE_SCHEME_CALLBACK (constructor, ()); /* construction */ - DECLARE_CLASSNAME(Chord_tremolo_iterator); + DECLARE_CLASSNAME (Chord_tremolo_iterator); Chord_tremolo_iterator (); protected: virtual SCM get_music_list () const; diff --git a/lily/include/clef.hh b/lily/include/clef.hh index 50cd925f70..9d26780b7b 100644 --- a/lily/include/clef.hh +++ b/lily/include/clef.hh @@ -27,7 +27,7 @@ struct Clef { DECLARE_SCHEME_CALLBACK (calc_glyph_name, (SCM)); DECLARE_SCHEME_CALLBACK (print, (SCM)); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); }; #endif /* CLEF_HH */ diff --git a/lily/include/cluster.hh b/lily/include/cluster.hh index 2c7bc1dac8..cb24182395 100644 --- a/lily/include/cluster.hh +++ b/lily/include/cluster.hh @@ -28,7 +28,7 @@ class Cluster public: DECLARE_SCHEME_CALLBACK (print, (SCM)); DECLARE_SCHEME_CALLBACK (calc_cross_staff, (SCM)); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); }; #endif // CLUSTER_HH diff --git a/lily/include/coherent-ligature-engraver.hh b/lily/include/coherent-ligature-engraver.hh index c109a69ce9..cecbef47a5 100644 --- a/lily/include/coherent-ligature-engraver.hh +++ b/lily/include/coherent-ligature-engraver.hh @@ -29,9 +29,9 @@ public: protected: virtual void build_ligature (Spanner *ligature, - vector<Grob_info> primitives) = 0; + vector<Grob_info> primitives) = 0; virtual void typeset_ligature (Spanner *ligature, - vector<Grob_info> primitives); + vector<Grob_info> primitives); virtual void move_related_items_to_column (Item *, Paper_column *, Real); private: void collect_accidentals (Spanner *, vector<Grob_info>); diff --git a/lily/include/column-x-positions.hh b/lily/include/column-x-positions.hh index 3b6410b646..a3de552c2c 100644 --- a/lily/include/column-x-positions.hh +++ b/lily/include/column-x-positions.hh @@ -25,8 +25,8 @@ struct Column_x_positions { - vector<Grob*> cols_; - vector<Grob*> loose_cols_; + vector<Grob *> cols_; + vector<Grob *> loose_cols_; vector<Real> config_; Real force_; diff --git a/lily/include/constrained-breaking.hh b/lily/include/constrained-breaking.hh index d0e631d901..1887d87273 100644 --- a/lily/include/constrained-breaking.hh +++ b/lily/include/constrained-breaking.hh @@ -40,7 +40,8 @@ struct Line_shape Line_shape piggyback (Line_shape mount, Real padding) const; }; -struct Line_details { +struct Line_details +{ Grob *last_column_; Real force_; Line_shape shape_; @@ -48,14 +49,14 @@ struct Line_details { page, where each stencil represents a different footnote. */ Interval refpoint_extent_; /* The refpoints of the first and last - spaceable staff in this line. min-distance - should be measured from the bottom - refpoint_extent of one line to the - top refpoint_extent of the next. */ + spaceable staff in this line. min-distance + should be measured from the bottom + refpoint_extent of one line to the + top refpoint_extent of the next. */ Real tallness_; /* Y-extent, adjusted according to begin/rest-of-line*/ Real padding_; /* compulsory space after this system (if we're not - last on a page) */ + last on a page) */ Real title_padding_; Real min_distance_; Real title_min_distance_; @@ -187,7 +188,7 @@ private: vector<vsize> start_; /* the columns at which we might be asked to start breaking */ vector<vsize> starting_breakpoints_; /* the corresponding index in breaks_ */ - vector<Grob*> all_; + vector<Grob *> all_; vector<vsize> breaks_; void initialize (); diff --git a/lily/include/context-def.hh b/lily/include/context-def.hh index 6024c68e06..21ab4a7c20 100644 --- a/lily/include/context-def.hh +++ b/lily/include/context-def.hh @@ -27,7 +27,6 @@ #include "virtual-methods.hh" #include <set> - /* The definition of a interpretation context as given in the input. The lists are stored in order of definition. @@ -58,15 +57,15 @@ public: SCM get_translator_group_type () const { return translator_group_type_; } void set_acceptor (SCM accepts, bool add); - VIRTUAL_COPY_CONSTRUCTOR(Context_def, Context_def); + VIRTUAL_COPY_CONSTRUCTOR (Context_def, Context_def); - vector<Context_def*> path_to_acceptable_context (SCM type_string, - Output_def *, - SCM) const; - vector<Context_def*> internal_path_to_acceptable_context (SCM type_string, - Output_def *, - SCM, - set<const Context_def *> *seen) const; + vector<Context_def *> path_to_acceptable_context (SCM type_string, + Output_def *, + SCM) const; + vector<Context_def *> internal_path_to_acceptable_context (SCM type_string, + Output_def *, + SCM, + set<const Context_def *> *seen) const; Context *instantiate (SCM extra_ops); SCM to_alist () const; diff --git a/lily/include/context-handle.hh b/lily/include/context-handle.hh index c9980eb46c..aa5850afc8 100644 --- a/lily/include/context-handle.hh +++ b/lily/include/context-handle.hh @@ -22,7 +22,6 @@ #include "lily-proto.hh" - class Context_handle { public: diff --git a/lily/include/context-mod.hh b/lily/include/context-mod.hh index 3bcb987263..36c8885bbc 100644 --- a/lily/include/context-mod.hh +++ b/lily/include/context-mod.hh @@ -30,7 +30,6 @@ #include "smobs.hh" #include "virtual-methods.hh" - /* Modifications for an interpretation context as given in the input. diff --git a/lily/include/context.hh b/lily/include/context.hh index 4121f84c78..9cf21cbce4 100644 --- a/lily/include/context.hh +++ b/lily/include/context.hh @@ -34,13 +34,13 @@ class Context Context (Context const &src); DECLARE_SMOBS (Context); - DECLARE_CLASSNAME(Context); + DECLARE_CLASSNAME (Context); void terminate (); private: friend class Context_handle; int iterator_count_; - + /* Used internally by create_context */ Stream_event *infant_event_; @@ -50,14 +50,14 @@ protected: SCM definition_; /* Additions to the Context_def, given by \with */ SCM definition_mods_; - + SCM properties_scm_; SCM context_list_; SCM accepts_list_; SCM aliases_; Translator_group *implementation_; string id_string_; - + /* Events reported in the context is sent to this dispatcher. */ Dispatcher *event_source_; @@ -74,7 +74,7 @@ protected: DECLARE_LISTENER (set_property_from_event); DECLARE_LISTENER (unset_property_from_event); - + public: string id_string () const { return id_string_; } SCM children_contexts () const { return context_list_; } @@ -97,7 +97,7 @@ public: Context *where_defined (SCM name_sym, SCM *value) const; void unset_property (SCM var_sym); - void instrumented_set_property (SCM, SCM, const char*, int, const char*); + void instrumented_set_property (SCM, SCM, const char *, int, const char *); void internal_set_property (SCM var_sym, SCM value); Context *create_context (Context_def *, string, SCM); @@ -123,10 +123,10 @@ public: bool is_removable () const; Context *find_create_context (SCM context_name, - string id, SCM ops); + string id, SCM ops); Context *create_unique_context (SCM context_name, string context_id, - SCM ops); - vector<Context_def*> path_to_acceptable_context (SCM alias) const; + SCM ops); + vector<Context_def *> path_to_acceptable_context (SCM alias) const; }; /* @@ -135,14 +135,14 @@ public: void apply_property_operations (Context *tg, SCM pre_init_ops); void execute_revert_property (Context *context, - SCM context_property, - SCM grob_property_path); + SCM context_property, + SCM grob_property_path); void execute_pushpop_property (Context *trg, SCM prop, SCM eltprop, SCM val); void sloppy_general_pushpop_property (Context *context, - SCM context_property, SCM grob_property_path, SCM val); + SCM context_property, SCM grob_property_path, SCM val); SCM updated_grob_properties (Context *tg, SCM sym); Context *find_context_below (Context *where, - SCM type_sym, string id); + SCM type_sym, string id); bool melisma_busy (Context *); Context *get_voice_to_lyrics (Context *lyrics); @@ -160,10 +160,10 @@ bool check_repeat_count_visibility (Context const *context, SCM count); void set_context_property_on_children (Context *trans, SCM sym, SCM val); /* Shorthand for creating and broadcasting stream events. */ -#define send_stream_event(ctx, type, origin, ...) \ -{ \ - SCM props[] = { __VA_ARGS__, 0 }; \ - ctx->internal_send_stream_event (ly_symbol2scm (type), origin, props); \ +#define send_stream_event(ctx, type, origin, ...) \ +{ \ + SCM props[] = { __VA_ARGS__, 0 }; \ + ctx->internal_send_stream_event (ly_symbol2scm (type), origin, props); \ } SCM nested_property_alist (SCM alist, SCM prop_path, SCM value); diff --git a/lily/include/custos.hh b/lily/include/custos.hh index 9638a51657..907d71183c 100644 --- a/lily/include/custos.hh +++ b/lily/include/custos.hh @@ -26,7 +26,7 @@ struct Custos { DECLARE_SCHEME_CALLBACK (print, (SCM)); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); private: static void add_streepjes (Grob *me, int pos, int interspaces, Stencil *custos_); diff --git a/lily/include/dimension-cache.hh b/lily/include/dimension-cache.hh index 84ea317d53..320d1fdca2 100644 --- a/lily/include/dimension-cache.hh +++ b/lily/include/dimension-cache.hh @@ -32,9 +32,9 @@ class Dimension_cache Grob *parent_; void init (); void clear (); - + friend class Grob; - + Dimension_cache (Dimension_cache const &); ~Dimension_cache (); Dimension_cache (); diff --git a/lily/include/dot-column.hh b/lily/include/dot-column.hh index 5337c85d6e..f047703f80 100644 --- a/lily/include/dot-column.hh +++ b/lily/include/dot-column.hh @@ -23,7 +23,6 @@ #include "lily-proto.hh" #include "grob-interface.hh" - class Grob; /** @@ -35,7 +34,7 @@ public: static int compare (Grob *const &, Grob *const &); static void add_head (Grob *dotcol, Grob *rh); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); DECLARE_SCHEME_CALLBACK (side_position, (SCM)); DECLARE_SCHEME_CALLBACK (calc_positioning_done, (SCM)); }; diff --git a/lily/include/dot-configuration.hh b/lily/include/dot-configuration.hh index b6b39dd41d..82fea8b5ba 100644 --- a/lily/include/dot-configuration.hh +++ b/lily/include/dot-configuration.hh @@ -34,7 +34,7 @@ struct Dot_position Box dot_extents_; bool extremal_head_; Interval x_extent_; - + Dot_position () { dot_ = 0; @@ -47,7 +47,7 @@ struct Dot_position struct Dot_configuration : public map<int, Dot_position> { Dot_formatting_problem const *problem_; - + Dot_configuration (Dot_formatting_problem const &); Real x_offset () const; int badness () const; diff --git a/lily/include/dot-formatting-problem.hh b/lily/include/dot-formatting-problem.hh index da248545bb..fcb6d19a22 100644 --- a/lily/include/dot-formatting-problem.hh +++ b/lily/include/dot-formatting-problem.hh @@ -1,7 +1,6 @@ #ifndef DOT_FORMATTING_PROBLEM_HH #define DOT_FORMATTING_PROBLEM_HH - #include "skyline.hh" #include "std-vector.hh" @@ -16,7 +15,7 @@ struct Dot_formatting_problem void register_configuration (Dot_configuration const &); Dot_configuration *best () const; Dot_formatting_problem (vector<Box> const &boxes, Interval base_x); - ~Dot_formatting_problem(); + ~Dot_formatting_problem (); }; #endif diff --git a/lily/include/dots.hh b/lily/include/dots.hh index 366e4f13e2..2fbec514dd 100644 --- a/lily/include/dots.hh +++ b/lily/include/dots.hh @@ -27,7 +27,7 @@ class Dots { public: DECLARE_SCHEME_CALLBACK (print, (SCM)); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); }; #endif // DOTS_HH diff --git a/lily/include/engraver-group.hh b/lily/include/engraver-group.hh index 9bb3aba0c3..190e9c3f32 100644 --- a/lily/include/engraver-group.hh +++ b/lily/include/engraver-group.hh @@ -50,4 +50,3 @@ void engraver_each (SCM list, Engraver_method method); #endif /* ENGRAVERGROUP_HH */ - diff --git a/lily/include/engraver.hh b/lily/include/engraver.hh index 162724b808..56c0f50026 100644 --- a/lily/include/engraver.hh +++ b/lily/include/engraver.hh @@ -30,7 +30,7 @@ class Engraver : public Translator { Grob *internal_make_grob (SCM sym, SCM cause, char const *name, - char const *f, int l, char const *fun); + char const *f, int l, char const *fun); friend SCM ly_engraver_make_grob (SCM, SCM, SCM); friend class Engraver_group; protected: @@ -55,11 +55,11 @@ public: Grob_info make_grob_info (Grob *, SCM cause); Item *internal_make_item (SCM sym, SCM cause, char const *name, - char const *f, int l, char const *fun); + char const *f, int l, char const *fun); Spanner *internal_make_spanner (SCM sym, SCM cause, char const *name, - char const *f, int l, char const *fun); + char const *f, int l, char const *fun); Paper_column *internal_make_column (SCM sym, char const *name, - char const *f, int l, char const *fun); + char const *f, int l, char const *fun); /** override other ctor @@ -71,7 +71,7 @@ public: #define make_spanner(x, cause) internal_make_spanner (ly_symbol2scm (x), cause, x, __FILE__, __LINE__, __FUNCTION__) #define make_paper_column(x) internal_make_column (ly_symbol2scm (x), x, __FILE__, __LINE__, __FUNCTION__) -Engraver* unsmob_engraver (SCM eng); +Engraver *unsmob_engraver (SCM eng); bool ly_is_grob_cause (SCM obj); #endif // ENGRAVER_HH diff --git a/lily/include/event-chord-iterator.hh b/lily/include/event-chord-iterator.hh index 7c902f863d..c35e23d9f1 100644 --- a/lily/include/event-chord-iterator.hh +++ b/lily/include/event-chord-iterator.hh @@ -30,7 +30,7 @@ class Event_chord_iterator : public Simple_music_iterator /** Find a bottom notation context to deliver events to. */ - DECLARE_CLASSNAME(Event_chord_iterator); + DECLARE_CLASSNAME (Event_chord_iterator); public: DECLARE_SCHEME_CALLBACK (constructor, ()); diff --git a/lily/include/event-iterator.hh b/lily/include/event-iterator.hh index adabf9d704..e88f4aa75a 100644 --- a/lily/include/event-iterator.hh +++ b/lily/include/event-iterator.hh @@ -2,7 +2,7 @@ This file is part of LilyPond, the GNU music typesetter. Copyright (C) 2006--2011 Han-Wen Nienhuys <hanwen@xs4all.nl> - Erik Sandberg <mandolaerik@gmail.com> + Erik Sandberg <mandolaerik@gmail.com> LilyPond is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ class Event_iterator : public Simple_music_iterator { - DECLARE_CLASSNAME(Event_iterator); + DECLARE_CLASSNAME (Event_iterator); public: DECLARE_SCHEME_CALLBACK (constructor, ()); diff --git a/lily/include/font-interface.hh b/lily/include/font-interface.hh index 5e9fb5ecee..e37aa6b743 100644 --- a/lily/include/font-interface.hh +++ b/lily/include/font-interface.hh @@ -28,7 +28,7 @@ struct Font_interface static SCM text_font_alist_chain (Grob *); static SCM music_font_alist_chain (Grob *); static Font_metric *get_default_font (Grob *); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); }; #endif /* FONT_INTERFACE_HH */ diff --git a/lily/include/font-metric.hh b/lily/include/font-metric.hh index 8c287da18b..4d9ddbbe99 100644 --- a/lily/include/font-metric.hh +++ b/lily/include/font-metric.hh @@ -32,7 +32,7 @@ typedef std::map<FT_UInt, FT_ULong> Index_to_charcode_map; class Font_metric { - DECLARE_CLASSNAME(Font_metric); + DECLARE_CLASSNAME (Font_metric); public: SCM description_; diff --git a/lily/include/global-context.hh b/lily/include/global-context.hh index c814b61c07..c5013129a9 100644 --- a/lily/include/global-context.hh +++ b/lily/include/global-context.hh @@ -28,7 +28,7 @@ class Global_context : public virtual Context PQueue<Moment> extra_mom_pq_; Output_def *output_def_; - DECLARE_CLASSNAME(Global_context); + DECLARE_CLASSNAME (Global_context); friend class Output_def; public: diff --git a/lily/include/global-ctor.hh b/lily/include/global-ctor.hh index 4e4b3b3da2..7a7fe101af 100644 --- a/lily/include/global-ctor.hh +++ b/lily/include/global-ctor.hh @@ -20,15 +20,15 @@ #ifndef GLOBAL_CTOR_HH #define GLOBAL_CTOR_HH -#define ADD_GLOBAL_CTOR_WITHNAME(y, x) \ - class Global_ctor_ ## y \ - { \ - public: \ - Global_ctor_ ## y () \ - { \ - add_constructor (x); \ - } \ - } \ +#define ADD_GLOBAL_CTOR_WITHNAME(y, x) \ + class Global_ctor_ ## y \ + { \ + public: \ + Global_ctor_ ## y () \ + { \ + add_constructor (x); \ + } \ + } \ _ ## y ## _ctor_init; #define ADD_GLOBAL_CTOR(x) ADD_GLOBAL_CTOR_WITHNAME (x, x); diff --git a/lily/include/grace-iterator.hh b/lily/include/grace-iterator.hh index 2efb1754e3..e1b7d2b7e4 100644 --- a/lily/include/grace-iterator.hh +++ b/lily/include/grace-iterator.hh @@ -27,7 +27,7 @@ class Grace_iterator : public Music_wrapper_iterator public: virtual void process (Moment); DECLARE_SCHEME_CALLBACK (constructor, ()); - DECLARE_CLASSNAME(Grace_iterator); + DECLARE_CLASSNAME (Grace_iterator); Moment pending_moment () const; }; diff --git a/lily/include/gregorian-ligature-engraver.hh b/lily/include/gregorian-ligature-engraver.hh index 790de04a8c..36dc551fcd 100644 --- a/lily/include/gregorian-ligature-engraver.hh +++ b/lily/include/gregorian-ligature-engraver.hh @@ -35,7 +35,7 @@ protected: virtual void listen_pes_or_flexa (Stream_event *ev); virtual void build_ligature (Spanner *ligature, vector<Grob_info> primitives); virtual void transform_heads (Spanner *ligature, - vector<Grob_info> primitives) = 0; + vector<Grob_info> primitives) = 0; void stop_translation_timestep (); }; diff --git a/lily/include/gregorian-ligature.hh b/lily/include/gregorian-ligature.hh index cfe81bcf94..b8a24507a8 100644 --- a/lily/include/gregorian-ligature.hh +++ b/lily/include/gregorian-ligature.hh @@ -24,11 +24,10 @@ class Grob; #include "std-string.hh" #include "grob-interface.hh" - class Gregorian_ligature { public: - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); static string prefixes_to_str (Grob *); }; diff --git a/lily/include/grid-line-interface.hh b/lily/include/grid-line-interface.hh index 9adfea1480..5aac0c00b6 100644 --- a/lily/include/grid-line-interface.hh +++ b/lily/include/grid-line-interface.hh @@ -23,20 +23,19 @@ #include "lily-proto.hh" #include "grob-interface.hh" - class Grid_line_interface { public: static void add_grid_point (Grob *me, Grob *b); DECLARE_SCHEME_CALLBACK (print, (SCM)); DECLARE_SCHEME_CALLBACK (width, (SCM)); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); }; class Grid_point_interface { public: - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); }; #endif /* GRID_LINE_INTERFACE_HH */ diff --git a/lily/include/grob-array.hh b/lily/include/grob-array.hh index f33bc82f71..1ef883110c 100644 --- a/lily/include/grob-array.hh +++ b/lily/include/grob-array.hh @@ -26,7 +26,7 @@ class Grob_array { - vector<Grob*> grobs_; + vector<Grob *> grobs_; bool ordered_; DECLARE_SIMPLE_SMOBS (Grob_array); @@ -43,15 +43,15 @@ public: void remove_duplicates (); void clear (); void add (Grob *x) { grobs_.push_back (x); } - void set_array (vector<Grob*> const &src); - vector<Grob*> &array_reference (); - vector<Grob*> const &array () const; + void set_array (vector<Grob *> const &src); + vector<Grob *> &array_reference (); + vector<Grob *> const &array () const; static SCM make_array (); }; DECLARE_UNSMOB (Grob_array, grob_array); -vector<Grob*> const &ly_scm2link_array (SCM x); +vector<Grob *> const &ly_scm2link_array (SCM x); SCM grob_list_to_grob_array (SCM lst); SCM grob_array_to_list (Grob_array *array); diff --git a/lily/include/grob-info.hh b/lily/include/grob-info.hh index 56a49170a4..fa0e11559f 100644 --- a/lily/include/grob-info.hh +++ b/lily/include/grob-info.hh @@ -33,7 +33,6 @@ class Grob_info Grob *grob_; Direction start_end_; - friend class Engraver; public: Direction start_end () const { return start_end_; } @@ -43,7 +42,7 @@ public: Context *context () const; Stream_event *event_cause () const; Stream_event *ultimate_event_cause () const; - vector<Context*> origin_contexts (Translator *) const; + vector<Context *> origin_contexts (Translator *) const; Grob_info (Translator *, Grob *); Grob_info (); diff --git a/lily/include/grob-interface.hh b/lily/include/grob-interface.hh index 2c476bbb94..2102260945 100644 --- a/lily/include/grob-interface.hh +++ b/lily/include/grob-interface.hh @@ -23,24 +23,24 @@ #include "lily-guile.hh" #define DECLARE_GROB_INTERFACE() \ - static SCM interface_symbol_; \ + static SCM interface_symbol_; \ static bool has_interface (Grob*) -#define ADD_INTERFACE(cl, b, c) \ +#define ADD_INTERFACE(cl, b, c) \ SCM cl::interface_symbol_; \ - bool cl::has_interface (Grob *me) \ - { \ - return me->internal_has_interface (interface_symbol_); \ - } \ - void cl ## _init_ifaces () \ - { \ - cl::interface_symbol_ = add_interface (#cl, b, c); \ - } \ + bool cl::has_interface (Grob *me) \ + { \ + return me->internal_has_interface (interface_symbol_); \ + } \ + void cl ## _init_ifaces () \ + { \ + cl::interface_symbol_ = add_interface (#cl, b, c); \ + } \ ADD_SCM_INIT_FUNC (cl ## ifaces, cl ## _init_ifaces); SCM add_interface (char const *cxx_name, - char const *descr, - char const *vars); + char const *descr, + char const *vars); SCM ly_add_interface (SCM, SCM, SCM); void internal_add_interface (SCM, SCM, SCM); diff --git a/lily/include/grob.hh b/lily/include/grob.hh index eda94b6d58..5ca85402e0 100644 --- a/lily/include/grob.hh +++ b/lily/include/grob.hh @@ -29,8 +29,8 @@ class Grob { private: DECLARE_SMOBS (Grob); - DECLARE_CLASSNAME(Grob); - + DECLARE_CLASSNAME (Grob); + void init (); protected: @@ -43,13 +43,13 @@ protected: SCM immutable_property_alist_; SCM mutable_property_alist_; SCM object_alist_; - + /* If this is a property, it accounts for 25% of the property lookups. */ SCM interfaces_; - + void substitute_object_links (SCM, SCM); Real get_offset (Axis a) const; SCM try_callback (SCM, SCM); @@ -57,7 +57,7 @@ protected: void internal_set_value_on_alist (SCM *alist, SCM sym, SCM val); public: - + /* friends */ friend class Spanner; friend class System; @@ -75,7 +75,7 @@ public: Grob *original () const { return original_; } SCM interfaces () const { return interfaces_; } - /* life & death */ + /* life & death */ Grob (SCM basic_props); Grob (Grob const &); virtual Grob *clone () const; @@ -97,14 +97,13 @@ public: SCM internal_get_object (SCM symbol) const; void internal_set_object (SCM sym, SCM val); void internal_del_property (SCM symbol); - void instrumented_set_property (SCM, SCM, char const*, int, char const*); + void instrumented_set_property (SCM, SCM, char const *, int, char const *); void internal_set_property (SCM sym, SCM val); - /* messages */ + /* messages */ void warning (string) const; void programming_error (string) const; - /* class hierarchy */ virtual System *get_system () const; static System *get_system (Grob *); @@ -121,7 +120,7 @@ public: /* interfaces */ bool internal_has_interface (SCM intf); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); /* offsets */ void translate_axis (Real, Axis); @@ -154,10 +153,10 @@ Item *unsmob_item (SCM); /* refpoints */ Grob *common_refpoint_of_list (SCM elt_list, Grob *, Axis a); -Grob *common_refpoint_of_array (vector<Grob*> const &, Grob *, Axis a); +Grob *common_refpoint_of_array (vector<Grob *> const &, Grob *, Axis a); System *get_root_system (Grob *me); -/* extents */ +/* extents */ Interval robust_relative_extent (Grob *, Grob *, Axis); /* offset/extent callbacks. */ diff --git a/lily/include/hairpin.hh b/lily/include/hairpin.hh index 9e636f6e8c..c6cfb7dcd4 100644 --- a/lily/include/hairpin.hh +++ b/lily/include/hairpin.hh @@ -28,7 +28,7 @@ struct Hairpin public: DECLARE_SCHEME_CALLBACK (print, (SCM)); DECLARE_SCHEME_CALLBACK (pure_height, (SCM, SCM, SCM)); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); }; #endif // HAIRPIN_HH diff --git a/lily/include/hara-kiri-group-spanner.hh b/lily/include/hara-kiri-group-spanner.hh index 294415577b..67aa187838 100644 --- a/lily/include/hara-kiri-group-spanner.hh +++ b/lily/include/hara-kiri-group-spanner.hh @@ -32,7 +32,7 @@ public: DECLARE_SCHEME_CALLBACK (pure_height, (SCM smob, SCM start, SCM end)); DECLARE_SCHEME_CALLBACK (force_hara_kiri_in_y_parent_callback, (SCM)); DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM)); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); static bool request_suicide (Grob *me, int start, int end); static bool request_suicide_alone (Grob *me, int start, int end); static void consider_suicide (Grob *me); diff --git a/lily/include/horizontal-bracket.hh b/lily/include/horizontal-bracket.hh index 3d140ae839..f7081d50df 100644 --- a/lily/include/horizontal-bracket.hh +++ b/lily/include/horizontal-bracket.hh @@ -29,9 +29,9 @@ struct Horizontal_bracket DECLARE_SCHEME_CALLBACK (print, (SCM)); static Stencil make_bracket (Grob *, Real, Axis, Direction); static Stencil make_enclosing_bracket (Grob *me, Grob *refpoint, - vector<Grob*> grobs, - Axis a, Direction dir); - DECLARE_GROB_INTERFACE(); + vector<Grob *> grobs, + Axis a, Direction dir); + DECLARE_GROB_INTERFACE (); }; #endif /* HORIZONTAL_BRACKET_HH */ diff --git a/lily/include/includable-lexer.hh b/lily/include/includable-lexer.hh index a7ca04ca24..3c0fe8b9fa 100644 --- a/lily/include/includable-lexer.hh +++ b/lily/include/includable-lexer.hh @@ -40,7 +40,7 @@ class Includable_lexer : public yyFlexLexer protected: bool close_input (); - vector<Source_file*> include_stack_; + vector<Source_file *> include_stack_; vector<int> char_count_stack_; vector<string> pending_string_includes_; @@ -55,10 +55,10 @@ public: Source_file *get_source_file () const; virtual void new_input (string s, Sources *); - + void new_input (string name, string data, Sources *); void add_string_include (string data); - + char const *here_str0 () const; }; diff --git a/lily/include/input.hh b/lily/include/input.hh index b8dc7384ca..af9dcff3e6 100644 --- a/lily/include/input.hh +++ b/lily/include/input.hh @@ -62,7 +62,6 @@ public: Input (); }; - #include "smobs.hh" SCM make_input (Input spot); diff --git a/lily/include/item.hh b/lily/include/item.hh index d3478245dd..3fa1fcddc2 100644 --- a/lily/include/item.hh +++ b/lily/include/item.hh @@ -31,7 +31,7 @@ class Item : public Grob { Drul_array<Item *> broken_to_drul_; - DECLARE_CLASSNAME(Item); + DECLARE_CLASSNAME (Item); public: Item (SCM); Item (Item const &); @@ -39,7 +39,7 @@ public: virtual Grob *clone () const; static bool is_non_musical (Grob *); - static bool break_visible(Grob *); + static bool break_visible (Grob *); bool is_broken () const; virtual bool pure_is_visible (int start, int end) const; @@ -52,7 +52,7 @@ public: virtual void handle_prebroken_dependencies (); virtual Interval_t<int> spanned_rank_interval () const; virtual Interval pure_height (Grob *ref, int start, int end); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); protected: virtual void discretionary_processing (); void copy_breakable_items (); diff --git a/lily/include/ligature-engraver.hh b/lily/include/ligature-engraver.hh index 4a2da856c2..c777196a9d 100644 --- a/lily/include/ligature-engraver.hh +++ b/lily/include/ligature-engraver.hh @@ -36,7 +36,7 @@ protected: void process_music (); virtual Spanner *create_ligature_spanner () = 0; virtual void typeset_ligature (Spanner *ligature, - vector<Grob_info> primitives) = 0; + vector<Grob_info> primitives) = 0; virtual Spanner *current_ligature (); SCM brew_ligature_primitive_proc; diff --git a/lily/include/lily-guile-macros.hh b/lily/include/lily-guile-macros.hh index ba2c955248..94849fb4f7 100644 --- a/lily/include/lily-guile-macros.hh +++ b/lily/include/lily-guile-macros.hh @@ -51,7 +51,8 @@ inline SCM scm_or_str2symbol (char const *c) { return scm_from_locale_symbol (c); } inline SCM -scm_or_str2symbol (SCM s) { +scm_or_str2symbol (SCM s) +{ assert (scm_is_symbol (s)); return s; } @@ -61,19 +62,19 @@ scm_or_str2symbol (SCM s) { variable per ly_symbol2scm() use, and one boolean evaluation for every call. */ -#define ly_symbol2scm(x) \ - ({ \ - static SCM cached; \ - /* We store this one locally, since G++ -O2 fucks up else */ \ - SCM value = cached; \ - if (__builtin_constant_p ((x))) \ - { \ - if (!cached) \ - value = cached = scm_gc_protect_object (scm_or_str2symbol (x)); \ - } \ - else \ - value = scm_or_str2symbol (x); \ - value; \ +#define ly_symbol2scm(x) \ + ({ \ + static SCM cached; \ + /* We store this one locally, since G++ -O2 fucks up else */ \ + SCM value = cached; \ + if (__builtin_constant_p ((x))) \ + { \ + if (!cached) \ + value = cached = scm_gc_protect_object (scm_or_str2symbol (x)); \ + } \ + else \ + value = scm_or_str2symbol (x); \ + value; \ }) #else inline SCM ly_symbol2scm (char const *x) { return scm_from_locale_symbol ((x)); } @@ -86,45 +87,45 @@ inline SCM ly_symbol2scm (char const *x) { return scm_from_locale_symbol ((x)); exports list of the module. */ -#define ly_lily_module_constant(x) \ - ({ \ - static SCM cached; \ - /* We store this one locally, since G++ -O2 fucks up else */ \ - SCM value = cached; \ - if (__builtin_constant_p ((x))) \ - { \ - if (!cached) \ - value = cached = scm_eval (scm_from_locale_symbol (x), \ - global_lily_module); \ - } \ - else \ - value = scm_eval (scm_from_locale_symbol (x), global_lily_module); \ - value; \ +#define ly_lily_module_constant(x) \ + ({ \ + static SCM cached; \ + /* We store this one locally, since G++ -O2 fucks up else */ \ + SCM value = cached; \ + if (__builtin_constant_p ((x))) \ + { \ + if (!cached) \ + value = cached = scm_eval (scm_from_locale_symbol (x), \ + global_lily_module); \ + } \ + else \ + value = scm_eval (scm_from_locale_symbol (x), global_lily_module); \ + value; \ }) /* Adds the NAME as a Scheme function, and a variable to store the SCM version of the function in the static variable NAME_proc */ -#define DECLARE_SCHEME_CALLBACK(NAME, ARGS) \ - static SCM NAME ARGS; \ +#define DECLARE_SCHEME_CALLBACK(NAME, ARGS) \ + static SCM NAME ARGS; \ static SCM NAME ## _proc #define ADD_TYPE_PREDICATE(func, type_name) \ void \ - func ## _type_adder () \ + func ## _type_adder () \ {\ - ly_add_type_predicate ((Type_predicate_ptr)func, type_name); \ + ly_add_type_predicate ((Type_predicate_ptr)func, type_name); \ }\ ADD_SCM_INIT_FUNC(func ## _type_adder_ctor, \ - func ## _type_adder); + func ## _type_adder); #define ADD_TYPE_PREDICATE(func, type_name) \ void \ - func ## _type_adder () \ + func ## _type_adder () \ {\ - ly_add_type_predicate ((Type_predicate_ptr)func, type_name); \ + ly_add_type_predicate ((Type_predicate_ptr)func, type_name); \ }\ ADD_SCM_INIT_FUNC(func ## _type_adder_ctor, \ - func ## _type_adder); + func ## _type_adder); string mangle_cxx_identifier (string); @@ -135,72 +136,72 @@ string predicate_to_typename (void *ptr); Make TYPE::FUNC available as a Scheme function. */ #define MAKE_SCHEME_CALLBACK_WITH_OPTARGS(TYPE, FUNC, ARGCOUNT, OPTIONAL_COUNT, DOC) \ - SCM TYPE ::FUNC ## _proc; \ - void \ - TYPE ## _ ## FUNC ## _init_functions () \ - { \ + SCM TYPE ::FUNC ## _proc; \ + void \ + TYPE ## _ ## FUNC ## _init_functions () \ + { \ string cxx = string (#TYPE) + "::" + string (#FUNC); \ string id = mangle_cxx_identifier (cxx); \ - TYPE ::FUNC ## _proc = scm_c_define_gsubr (id.c_str(), \ - (ARGCOUNT-OPTIONAL_COUNT), OPTIONAL_COUNT, 0, \ - (scm_t_subr) TYPE::FUNC); \ + TYPE ::FUNC ## _proc = scm_c_define_gsubr (id.c_str(), \ + (ARGCOUNT-OPTIONAL_COUNT), OPTIONAL_COUNT, 0, \ + (scm_t_subr) TYPE::FUNC); \ ly_add_function_documentation (TYPE :: FUNC ## _proc, id.c_str(), "", \ - DOC); \ - scm_c_export (id.c_str (), NULL); \ - } \ - \ - ADD_SCM_INIT_FUNC (TYPE ## _ ## FUNC ## _callback, \ - TYPE ## _ ## FUNC ## _init_functions); - -#define MAKE_DOCUMENTED_SCHEME_CALLBACK(TYPE, FUNC, ARGCOUNT, DOC) \ + DOC); \ + scm_c_export (id.c_str (), NULL); \ + } \ + \ + ADD_SCM_INIT_FUNC (TYPE ## _ ## FUNC ## _callback, \ + TYPE ## _ ## FUNC ## _init_functions); + +#define MAKE_DOCUMENTED_SCHEME_CALLBACK(TYPE, FUNC, ARGCOUNT, DOC) \ MAKE_SCHEME_CALLBACK_WITH_OPTARGS(TYPE, FUNC, ARGCOUNT, 0, DOC); -#define MAKE_SCHEME_CALLBACK(TYPE, FUNC, ARGCOUNT) \ +#define MAKE_SCHEME_CALLBACK(TYPE, FUNC, ARGCOUNT) \ MAKE_SCHEME_CALLBACK_WITH_OPTARGS(TYPE,FUNC,ARGCOUNT, 0, ""); void ly_add_function_documentation (SCM proc, string fname, string varlist, string doc); void ly_check_name (string cxx, string fname); -#define ADD_SCM_INIT_FUNC(name, func) \ - class name ## _scm_initter \ - { \ - public: \ - name ## _scm_initter () \ - { \ - add_scm_init_func (func); \ - } \ - } \ +#define ADD_SCM_INIT_FUNC(name, func) \ + class name ## _scm_initter \ + { \ + public: \ + name ## _scm_initter () \ + { \ + add_scm_init_func (func); \ + } \ + } \ _ ## name ## _scm_initter; /* end define */ #define LY_DEFINE_WITHOUT_DECL(INITPREFIX, FNAME, PRIMNAME, REQ, OPT, VAR, \ - ARGLIST, DOCSTRING) \ - SCM FNAME ## _proc; \ - void \ - INITPREFIX ## init () \ - { \ - FNAME ## _proc = scm_c_define_gsubr (PRIMNAME, REQ, OPT, VAR, \ - (scm_t_subr) FNAME); \ + ARGLIST, DOCSTRING) \ + SCM FNAME ## _proc; \ + void \ + INITPREFIX ## init () \ + { \ + FNAME ## _proc = scm_c_define_gsubr (PRIMNAME, REQ, OPT, VAR, \ + (scm_t_subr) FNAME); \ ly_check_name (#FNAME, PRIMNAME);\ - ly_add_function_documentation (FNAME ## _proc, PRIMNAME, #ARGLIST, \ - DOCSTRING); \ - scm_c_export (PRIMNAME, NULL); \ - } \ + ly_add_function_documentation (FNAME ## _proc, PRIMNAME, #ARGLIST, \ + DOCSTRING); \ + scm_c_export (PRIMNAME, NULL); \ + } \ ADD_SCM_INIT_FUNC (INITPREFIX ## init_unique_prefix, INITPREFIX ## init); \ - SCM \ + SCM \ FNAME ARGLIST -#define LY_DEFINE(FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, DOCSTRING) \ - SCM FNAME ARGLIST; \ +#define LY_DEFINE(FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, DOCSTRING) \ + SCM FNAME ARGLIST; \ LY_DEFINE_WITHOUT_DECL (FNAME, FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, \ - DOCSTRING) + DOCSTRING) #define LY_DEFINE_MEMBER_FUNCTION(CLASS, FNAME, PRIMNAME, REQ, OPT, VAR, \ - ARGLIST, DOCSTRING) \ - SCM FNAME ARGLIST; \ + ARGLIST, DOCSTRING) \ + SCM FNAME ARGLIST; \ LY_DEFINE_WITHOUT_DECL (CLASS ## FNAME, CLASS::FNAME, PRIMNAME, REQ, OPT, \ - VAR, ARGLIST, DOCSTRING) + VAR, ARGLIST, DOCSTRING) #define get_property(x) internal_get_property (ly_symbol2scm (x)) #define get_pure_property(x,y,z) \ @@ -222,20 +223,16 @@ void ly_check_name (string cxx, string fname); #define set_property(x, y) internal_set_property (ly_symbol2scm (x), y) #endif - - -#define LY_ASSERT_TYPE(pred, var, number) \ - { \ +#define LY_ASSERT_TYPE(pred, var, number) \ + { \ if (!pred (var)) \ - { \ - scm_wrong_type_arg_msg(mangle_cxx_identifier (__FUNCTION__).c_str(), \ - number, var, \ - predicate_to_typename ((void*) &pred).c_str()); \ - } \ + { \ + scm_wrong_type_arg_msg(mangle_cxx_identifier (__FUNCTION__).c_str(), \ + number, var, \ + predicate_to_typename ((void*) &pred).c_str()); \ + } \ } #define LY_ASSERT_SMOB(klass, var, number) LY_ASSERT_TYPE(klass::unsmob, var, number) - - #endif /* LILY_GUILE_MACROS_HH */ diff --git a/lily/include/lily-guile.hh b/lily/include/lily-guile.hh index 3fefd5dc3c..5b76625103 100644 --- a/lily/include/lily-guile.hh +++ b/lily/include/lily-guile.hh @@ -31,7 +31,7 @@ Hack for various MacOS incarnations. */ #ifndef GUILE_ELLIPSIS -#define GUILE_ELLIPSIS +#define GUILE_ELLIPSIS #endif #include "guile-compatibility.hh" @@ -78,7 +78,6 @@ Offset robust_scm2offset (SCM, Offset); string robust_scm2string (SCM, string); Rational robust_scm2rational (SCM, Rational); - SCM ly_quote_scm (SCM s); bool type_check_assignment (SCM val, SCM sym, SCM type_symbol); string print_scm_val (SCM val); @@ -93,8 +92,8 @@ SCM ly_hash2alist (SCM tab); SCM ly_hash_table_keys (SCM tab); SCM ly_assoc_prepend_x (SCM alist, SCM key, SCM val); -inline bool ly_is_fraction (SCM x) { return SCM_FRACTIONP(x) || scm_is_integer (x); } - +inline bool ly_is_fraction (SCM x) { return SCM_FRACTIONP (x) || scm_is_integer (x); } + inline bool ly_is_list (SCM x) { return SCM_NFALSEP (scm_list_p (x)); } inline bool ly_cheap_is_list (SCM x) { return scm_is_pair (x) || x == SCM_EOL; } inline bool ly_is_procedure (SCM x) { return SCM_NFALSEP (scm_procedure_p (x)); } @@ -166,7 +165,7 @@ SCM ly_output_formats (); /* snarfing. */ -void add_scm_init_func (void (*) ()); +void add_scm_init_func (void ( *) ()); extern "C" { typedef SCM (*Scheme_function_unknown) (GUILE_ELLIPSIS); @@ -184,7 +183,6 @@ typedef SCM (*Scheme_function_2) (GUILE_ELLIPSIS); typedef SCM (*Scheme_function_3) (GUILE_ELLIPSIS); #endif - /* Inline these for performance reasons. */ @@ -199,22 +197,19 @@ inline SCM ly_car (SCM x) { return SCM_CAR (x); } inline SCM ly_cdr (SCM x) { return SCM_CDR (x); } inline bool ly_is_pair (SCM x) { return SCM_I_CONSP (x); } - - -#include "std-vector.hh" +#include "std-vector.hh" template<class T> SCM -ly_cxx_vector_to_list (vector<T> const &src) +ly_cxx_vector_to_list (vector<T> const &src) { SCM l = SCM_EOL; - for (vsize i = src.size (); i --; ) + for (vsize i = src.size (); i--;) l = scm_cons (src[i]->self_scm (), l); return l; } - SCM ly_offsets2scm (vector<Offset> os); vector<Offset> ly_scm2offsets (SCM s); diff --git a/lily/include/lily-lexer.hh b/lily/include/lily-lexer.hh index 4f5f92d4e1..72391a0877 100644 --- a/lily/include/lily-lexer.hh +++ b/lily/include/lily-lexer.hh @@ -66,7 +66,7 @@ public: void *lexval_; Input *lexloc_; bool is_main_input_; - + Sources *sources_; /* Scheme hash tables with (oct name acc) values, and symbol keys. */ @@ -81,7 +81,7 @@ public: Lily_lexer (Sources *, Lily_parser *); Lily_lexer (Lily_lexer const &, Lily_parser *); int yylex (); - + void add_lexed_char (int); void prepare_for_next_token (); diff --git a/lily/include/lily-parser.hh b/lily/include/lily-parser.hh index fe58940460..0387e2efd7 100644 --- a/lily/include/lily-parser.hh +++ b/lily/include/lily-parser.hh @@ -39,8 +39,8 @@ class Lily_parser char const *here_str0 () const; Simultaneous_music *get_chord (Pitch tonic, - vector<Pitch> *adds, vector<Pitch> *subs, - Pitch *inversion, Pitch *bass, Duration d); + vector<Pitch> *adds, vector<Pitch> *subs, + Pitch *inversion, Pitch *bass, Duration d); void set_chord_tremolo (int type); void set_last_duration (Duration const *); void set_last_pitch (Pitch const *); @@ -70,7 +70,7 @@ public: void parser_error (Input const &, string); void set_yydebug (bool); - SCM make_scope () const; + SCM make_scope () const; }; DECLARE_UNSMOB (Lily_parser, lily_parser); diff --git a/lily/include/lily-proto.hh b/lily/include/lily-proto.hh index 5cde918e3f..86b76c5c58 100644 --- a/lily/include/lily-proto.hh +++ b/lily/include/lily-proto.hh @@ -199,7 +199,7 @@ class Transposed_music; class yyFlexLexer; typedef void (*Engraver_void_function_engraver_grob_info) (Engraver *, - Grob_info); + Grob_info); typedef void (*Translator_void_method_ptr) (Translator *); #endif /* LILY_PROTO_HH */ diff --git a/lily/include/line-interface.hh b/lily/include/line-interface.hh index 1888062132..f375c12335 100644 --- a/lily/include/line-interface.hh +++ b/lily/include/line-interface.hh @@ -26,20 +26,20 @@ struct Line_interface { static Stencil line (Grob *me, Offset from, Offset to); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); static Stencil make_zigzag_line (Grob *me, - Offset from, - Offset to); + Offset from, + Offset to); static Stencil make_trill_line (Grob *me, - Offset from, - Offset to); + Offset from, + Offset to); static Stencil make_dashed_line (Real th, Offset from, Offset to, Real, Real); static Stencil make_line (Real th, Offset from, Offset to); static Stencil make_arrow (Offset beg, Offset end, Real thick, - Real length, Real width); + Real length, Real width); static Stencil arrows (Grob *me, Offset from, Offset to, - bool from_arrow, - bool to_arrow); + bool from_arrow, + bool to_arrow); }; #endif /* LINE_INTERFACE_HH */ diff --git a/lily/include/listener.hh b/lily/include/listener.hh index ed7aced9c9..0bc937f2b3 100644 --- a/lily/include/listener.hh +++ b/lily/include/listener.hh @@ -27,7 +27,7 @@ register a method as an event handler in a dispatcher, then you must: - - declare the method using the DECLARE_LISTENER macro. + - declare the method using the DECLARE_LISTENER macro. class Foo { DECLARE_LISTENER (method); @@ -53,7 +53,7 @@ Stream_distributor *d = (...); Listener l = GET_LISTENER (foo->method); d->register_listener (l, "EventClass"); - + Whenever d hears a stream-event ev of class "EventClass", the implemented procedure is called. @@ -63,12 +63,14 @@ #include "smobs.hh" -typedef struct { +typedef struct +{ void (*listen_callback) (void *, SCM); void (*mark_callback) (void *); } Listener_function_table; -class Listener { +class Listener +{ void *target_; Listener_function_table *type_; public: @@ -85,34 +87,34 @@ public: }; DECLARE_UNSMOB (Listener, listener); -#define IMPLEMENT_LISTENER(cl, method) \ -void \ -cl :: method ## _callback (void *self, SCM ev) \ -{ \ - cl *s = (cl *)self; \ - s->method (ev); \ -} \ -void \ -cl :: method ## _mark (void *self) \ -{ \ - cl *s = (cl *)self; \ - scm_gc_mark (s->self_scm ()); \ -} \ -Listener \ -cl :: method ## _listener () const \ -{ \ - static Listener_function_table callbacks; \ - callbacks.listen_callback = &cl::method ## _callback; \ - callbacks.mark_callback = &cl::method ## _mark; \ - return Listener (this, &callbacks); \ +#define IMPLEMENT_LISTENER(cl, method) \ +void \ +cl :: method ## _callback (void *self, SCM ev) \ +{ \ + cl *s = (cl *)self; \ + s->method (ev); \ +} \ +void \ +cl :: method ## _mark (void *self) \ +{ \ + cl *s = (cl *)self; \ + scm_gc_mark (s->self_scm ()); \ +} \ +Listener \ +cl :: method ## _listener () const \ +{ \ + static Listener_function_table callbacks; \ + callbacks.listen_callback = &cl::method ## _callback; \ + callbacks.mark_callback = &cl::method ## _mark; \ + return Listener (this, &callbacks); \ } #define GET_LISTENER(proc) proc ## _listener () -#define DECLARE_LISTENER(name) \ - inline void name (SCM); \ - static void name ## _callback (void *self, SCM ev); \ - static void name ## _mark (void *self); \ +#define DECLARE_LISTENER(name) \ + inline void name (SCM); \ + static void name ## _callback (void *self, SCM ev); \ + static void name ## _mark (void *self); \ Listener name ## _listener () const #endif /* LISTENER_HH */ diff --git a/lily/include/lookup.hh b/lily/include/lookup.hh index d7157cf3c7..cb1f461dfa 100644 --- a/lily/include/lookup.hh +++ b/lily/include/lookup.hh @@ -31,7 +31,7 @@ struct Lookup static Stencil rotated_box (Real slope, Real width, Real thick, Real blot); static Stencil round_filled_polygon (vector<Offset> const &points, Real blotdiameter); static Stencil frame (Box b, Real thick, Real blot); - static Stencil slur (Bezier controls, Real cthick, Real thick, + static Stencil slur (Bezier controls, Real cthick, Real thick, SCM dash_definition); static Stencil bezier_sandwich (Bezier top_curve, Bezier bottom_curve, Real thickness); diff --git a/lily/include/ly-module.hh b/lily/include/ly-module.hh index f4483ed2d9..50a31d9269 100644 --- a/lily/include/ly-module.hh +++ b/lily/include/ly-module.hh @@ -39,6 +39,5 @@ typedef SCM (*scm_t_hash_fold_fn) (GUILE_ELLIPSIS); typedef SCM (*scm_t_hash_handle_fn) (GUILE_ELLIPSIS); #endif - #endif /* LY_MODULE_HH */ diff --git a/lily/include/ly-smobs.icc b/lily/include/ly-smobs.icc index 1cb9e32590..695fc465ec 100644 --- a/lily/include/ly-smobs.icc +++ b/lily/include/ly-smobs.icc @@ -23,116 +23,116 @@ #include "lily-guile-macros.hh" #include "smobs.hh" -#define IMPLEMENT_TYPE_P(CL, FUNCNAME) \ - SCM CL ## _type_p_proc; \ - void init_type_ ## CL () \ - { \ - SCM subr = scm_c_define_gsubr (FUNCNAME, 1, 0, 0, \ - (scm_t_subr) CL::smob_p); \ - CL ## _type_p_proc = subr; \ - ly_add_function_documentation (subr, FUNCNAME, "(SCM x)", \ - "Is @var{x} a @code{" #CL "} object?"); \ - scm_c_export (FUNCNAME, NULL); \ - } \ +#define IMPLEMENT_TYPE_P(CL, FUNCNAME) \ + SCM CL ## _type_p_proc; \ + void init_type_ ## CL () \ + { \ + SCM subr = scm_c_define_gsubr (FUNCNAME, 1, 0, 0, \ + (scm_t_subr) CL::smob_p); \ + CL ## _type_p_proc = subr; \ + ly_add_function_documentation (subr, FUNCNAME, "(SCM x)", \ + "Is @var{x} a @code{" #CL "} object?"); \ + scm_c_export (FUNCNAME, NULL); \ + } \ ADD_SCM_INIT_FUNC (init_type_ ## CL, init_type_ ## CL) -#define IMPLEMENT_BASE_SMOBS(CL) \ +#define IMPLEMENT_BASE_SMOBS(CL) \ void \ - CL ## _type_adder () \ + CL ## _type_adder () \ {\ - ly_add_type_predicate ((void*) &CL::unsmob, #CL); \ + ly_add_type_predicate ((void*) &CL::unsmob, #CL); \ }\ ADD_SCM_INIT_FUNC(CL ## _type_adder_ctor, \ - CL ## _type_adder);\ - const char *CL::smob_name_ = #CL; \ - scm_t_bits CL::smob_tag_; \ - SCM \ - CL::smob_p (SCM s) \ - { \ - if (SCM_NIMP (s) && SCM_CELL_TYPE (s) == smob_tag_) \ - return SCM_BOOL_T; \ - else \ - return SCM_BOOL_F; \ - \ - } \ - \ - void \ - CL::init_smobs () \ - { \ - smob_tag_ = scm_make_smob_type (#CL, 0); \ - scm_set_smob_mark (smob_tag_, CL::mark_smob); \ - scm_set_smob_free (smob_tag_, CL::free_smob); \ - scm_set_smob_print (smob_tag_, CL::print_smob); \ - scm_set_smob_equalp (smob_tag_, CL::equal_p); \ - } \ - \ - size_t \ - CL::free_smob (SCM ses) \ - { \ - CL *s = (CL *) SCM_CELL_WORD_1 (ses); \ - delete s; \ + CL ## _type_adder);\ + const char *CL::smob_name_ = #CL; \ + scm_t_bits CL::smob_tag_; \ + SCM \ + CL::smob_p (SCM s) \ + { \ + if (SCM_NIMP (s) && SCM_CELL_TYPE (s) == smob_tag_) \ + return SCM_BOOL_T; \ + else \ + return SCM_BOOL_F; \ + \ + } \ + \ + void \ + CL::init_smobs () \ + { \ + smob_tag_ = scm_make_smob_type (#CL, 0); \ + scm_set_smob_mark (smob_tag_, CL::mark_smob); \ + scm_set_smob_free (smob_tag_, CL::free_smob); \ + scm_set_smob_print (smob_tag_, CL::print_smob); \ + scm_set_smob_equalp (smob_tag_, CL::equal_p); \ + } \ + \ + size_t \ + CL::free_smob (SCM ses) \ + { \ + CL *s = (CL *) SCM_CELL_WORD_1 (ses); \ + delete s; \ /* scm_gc_unregister_collectable_memory (s, sizeof (CL), #CL " smob"); */ \ - return SMOB_FREE_RETURN_VAL (CL); \ - } \ - \ + return SMOB_FREE_RETURN_VAL (CL); \ + } \ + \ ADD_SCM_INIT_FUNC (CL, CL::init_smobs) -#define IMPLEMENT_SIMPLE_SMOBS(CL) \ - IMPLEMENT_BASE_SMOBS (CL); \ - SCM CL::smobbed_copy () const \ - { \ - CL *ptr = new CL (*this); \ - SCM s; \ - s = scm_cons (SCM_PACK (CL::smob_tag_), SCM_PACK (ptr)); \ +#define IMPLEMENT_SIMPLE_SMOBS(CL) \ + IMPLEMENT_BASE_SMOBS (CL); \ + SCM CL::smobbed_copy () const \ + { \ + CL *ptr = new CL (*this); \ + SCM s; \ + s = scm_cons (SCM_PACK (CL::smob_tag_), SCM_PACK (ptr)); \ scm_gc_register_collectable_memory ((CL *)this, sizeof (CL), #CL " smob"); \ - \ - return s; \ + \ + return s; \ } -#define IMPLEMENT_SMOBS(CL) \ - IMPLEMENT_BASE_SMOBS (CL) \ - void \ - CL::smobify_self () \ - { \ - protection_cons_ = SCM_EOL; \ - self_scm_ = unprotected_smobify_self (); \ - protect (); \ - } \ - void \ - CL::protect () \ - { \ - protect_smob (self_scm_, &protection_cons_); \ - } \ - SCM \ - CL::unprotect () \ - { \ - unprotect_smob (self_scm_, &protection_cons_); \ - return self_scm_; \ - } \ - SCM \ - CL::unprotected_smobify_self () \ - { \ - /* \ - This is local. We don't assign to self_scm_ directly, to assure \ - that S isn't GC-ed from under us. \ - \ +#define IMPLEMENT_SMOBS(CL) \ + IMPLEMENT_BASE_SMOBS (CL) \ + void \ + CL::smobify_self () \ + { \ + protection_cons_ = SCM_EOL; \ + self_scm_ = unprotected_smobify_self (); \ + protect (); \ + } \ + void \ + CL::protect () \ + { \ + protect_smob (self_scm_, &protection_cons_); \ + } \ + SCM \ + CL::unprotect () \ + { \ + unprotect_smob (self_scm_, &protection_cons_); \ + return self_scm_; \ + } \ + SCM \ + CL::unprotected_smobify_self () \ + { \ + /* \ + This is local. We don't assign to self_scm_ directly, to assure \ + that S isn't GC-ed from under us. \ + \ We don't use smobbed_self () to ensure that mark_smob () doesn't \ have to deal half-initialized objects: scm_done_malloc ( ) might \ trigger GC.the warning in smobs.hh is just to be doubleplus \ goodly sure \ - */ \ - SCM s; \ - SCM_NEWSMOB (s, CL::smob_tag_, this); \ - self_scm_ = s; \ + */ \ + SCM s; \ + SCM_NEWSMOB (s, CL::smob_tag_, this); \ + self_scm_ = s; \ scm_gc_register_collectable_memory (this, sizeof (CL), #CL " smob"); \ - return s; \ + return s; \ } -#define IMPLEMENT_DEFAULT_EQUAL_P(CL) \ - SCM \ - CL::equal_p (SCM a, SCM b) \ - { \ - return a == b ? SCM_BOOL_T : SCM_BOOL_F; \ +#define IMPLEMENT_DEFAULT_EQUAL_P(CL) \ + SCM \ + CL::equal_p (SCM a, SCM b) \ + { \ + return a == b ? SCM_BOOL_T : SCM_BOOL_F; \ } #endif /* LY_SMOBS_ICC */ diff --git a/lily/include/lyric-extender.hh b/lily/include/lyric-extender.hh index 94709ae72c..f3bfd6483f 100644 --- a/lily/include/lyric-extender.hh +++ b/lily/include/lyric-extender.hh @@ -27,7 +27,7 @@ class Lyric_extender { public: - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); DECLARE_SCHEME_CALLBACK (print, (SCM)); }; diff --git a/lily/include/lyric-hyphen.hh b/lily/include/lyric-hyphen.hh index 4617832282..6b4799b431 100644 --- a/lily/include/lyric-hyphen.hh +++ b/lily/include/lyric-hyphen.hh @@ -27,7 +27,7 @@ struct Lyric_hyphen { public: DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM)); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); DECLARE_SCHEME_CALLBACK (print, (SCM)); }; diff --git a/lily/include/main.hh b/lily/include/main.hh index 7fa0905c83..8644a3ee17 100644 --- a/lily/include/main.hh +++ b/lily/include/main.hh @@ -62,7 +62,6 @@ extern int exit_status_global; extern File_path global_path; extern const char *LILYPOND_DATADIR; - /* Debugging options: switch on diff --git a/lily/include/measure-grouping-spanner.hh b/lily/include/measure-grouping-spanner.hh index 0748770e6f..4b66c94803 100644 --- a/lily/include/measure-grouping-spanner.hh +++ b/lily/include/measure-grouping-spanner.hh @@ -23,13 +23,12 @@ #include "grob-interface.hh" #include "lily-proto.hh" - class Measure_grouping { public: DECLARE_SCHEME_CALLBACK (print, (SCM)); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); }; #endif /* MEASURE_GROUPING_SPANNER_HH */ diff --git a/lily/include/melody-spanner.hh b/lily/include/melody-spanner.hh index bcfab163e5..3dbf141bf8 100644 --- a/lily/include/melody-spanner.hh +++ b/lily/include/melody-spanner.hh @@ -26,9 +26,9 @@ class Melody_spanner { public: - DECLARE_GROB_INTERFACE(); - static void add_stem (Grob*, Grob*); - DECLARE_SCHEME_CALLBACK(calc_neutral_stem_direction, (SCM)); + DECLARE_GROB_INTERFACE (); + static void add_stem (Grob *, Grob *); + DECLARE_SCHEME_CALLBACK (calc_neutral_stem_direction, (SCM)); }; #endif /* MELODY_SPANNER_HH */ diff --git a/lily/include/mensural-ligature.hh b/lily/include/mensural-ligature.hh index cb676e5916..350ea66958 100644 --- a/lily/include/mensural-ligature.hh +++ b/lily/include/mensural-ligature.hh @@ -24,7 +24,6 @@ #include "lily-proto.hh" #include "grob-interface.hh" - /* * These are all possible mensural ligature primitives. */ @@ -46,7 +45,7 @@ struct Mensural_ligature { DECLARE_SCHEME_CALLBACK (brew_ligature_primitive, (SCM)); DECLARE_SCHEME_CALLBACK (print, (SCM)); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); }; #endif /* MENSURAL_LIGATURE_HH */ diff --git a/lily/include/midi-chunk.hh b/lily/include/midi-chunk.hh index c567e904f1..77ea97a78d 100644 --- a/lily/include/midi-chunk.hh +++ b/lily/include/midi-chunk.hh @@ -24,7 +24,6 @@ #include "virtual-methods.hh" #include "std-vector.hh" - /** timed MIDI event */ @@ -38,9 +37,6 @@ public: string to_string () const; }; - - - /** variable sized MIDI data */ @@ -73,7 +69,7 @@ public: int port_; DECLARE_CLASSNAME (Midi_track); - vector<Midi_event*> events_; + vector<Midi_event *> events_; Midi_track (int number, bool port); ~Midi_track (); diff --git a/lily/include/midi-item.hh b/lily/include/midi-item.hh index cc59ed0abe..1930e65437 100644 --- a/lily/include/midi-item.hh +++ b/lily/include/midi-item.hh @@ -24,7 +24,7 @@ #include "std-vector.hh" string int2midi_varint_string (int i); - + /** Any piece of midi information. @@ -40,7 +40,6 @@ public: static Midi_item *get_midi (Audio_item *a); - virtual string to_string () const = 0; }; @@ -61,7 +60,6 @@ public: Real seconds_; }; - /** Change instrument event */ @@ -111,7 +109,6 @@ public: Audio_note *audio_; - static int const c0_pitch_ = 60; Byte dynamic_byte_; }; @@ -132,10 +129,10 @@ class Midi_text : public Midi_item { public: enum Type - { - TEXT = 1, COPYRIGHT, TRACK_NAME, INSTRUMENT_NAME, LYRIC, - MARKER, CUE_POINT - }; + { + TEXT = 1, COPYRIGHT, TRACK_NAME, INSTRUMENT_NAME, LYRIC, + MARKER, CUE_POINT + }; DECLARE_CLASSNAME (Midi_text); Midi_text (Audio_text *); diff --git a/lily/include/midi-walker.hh b/lily/include/midi-walker.hh index 3d99b34021..40fde21f95 100644 --- a/lily/include/midi-walker.hh +++ b/lily/include/midi-walker.hh @@ -43,7 +43,7 @@ public: ~Midi_walker (); void process (); - void operator ++ (int); + void operator ++(int); bool ok () const; void finalize (); @@ -51,16 +51,16 @@ private: void do_start_note (Midi_note *note); void do_stop_notes (int); void output_event (int, Midi_item *l); - Midi_item *get_midi (Audio_item*); + Midi_item *get_midi (Audio_item *); Midi_track *track_; bool percussion_; bool merge_unisons_; vsize index_; - vector<Audio_item*> items_; + vector<Audio_item *> items_; PQueue<Midi_note_event> stop_note_queue; int last_tick_; - vector<Midi_item*> midi_events_; + vector<Midi_item *> midi_events_; }; #endif // MIDI_WALKER_HH diff --git a/lily/include/misc.hh b/lily/include/misc.hh index f36e7cecc6..0491b5b4a9 100644 --- a/lily/include/misc.hh +++ b/lily/include/misc.hh @@ -42,7 +42,7 @@ sign (int i) inline int shift_left (int value, int shiftamount) { - if (shiftamount < 0) return (value >> -shiftamount); + if (shiftamount < 0) return (value >> -shiftamount); else return (value << shiftamount); } @@ -50,12 +50,12 @@ inline Real linear_interpolate (Real x, Real x1, Real x2, Real y1, Real y2) { return (x2 - x) / (x2 - x1) * y1 - + (x - x1) / (x2 - x1) * y2; + + (x - x1) / (x2 - x1) * y2; } Real directed_round (Real f, Direction d); -Real peak_around (Real epsilon, Real threshold, Real x); +Real peak_around (Real epsilon, Real threshold, Real x); Real convex_amplifier (Real standard_x, Real increase_factor, Real x); string camel_case_to_lisp_identifier (string in); vsize utf8_char_len (char); diff --git a/lily/include/moment.hh b/lily/include/moment.hh index 6a3922066e..5671d6b234 100644 --- a/lily/include/moment.hh +++ b/lily/include/moment.hh @@ -64,9 +64,9 @@ public: IMPLEMENT_ARITHMETIC_OPERATOR (Moment, +); IMPLEMENT_ARITHMETIC_OPERATOR (Moment, -); -IMPLEMENT_ARITHMETIC_OPERATOR (Moment, /); +IMPLEMENT_ARITHMETIC_OPERATOR (Moment, / ); IMPLEMENT_ARITHMETIC_OPERATOR (Moment, *); -IMPLEMENT_ARITHMETIC_OPERATOR (Moment, %); +IMPLEMENT_ARITHMETIC_OPERATOR (Moment, % ); DECLARE_UNSMOB (Moment, moment); int compare (Moment const &, Moment const &); diff --git a/lily/include/multi-measure-rest.hh b/lily/include/multi-measure-rest.hh index 7c07b3c8dc..399e1490d6 100644 --- a/lily/include/multi-measure-rest.hh +++ b/lily/include/multi-measure-rest.hh @@ -26,7 +26,7 @@ class Multi_measure_rest { public: - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); DECLARE_SCHEME_CALLBACK (print, (SCM)); DECLARE_SCHEME_CALLBACK (percent, (SCM)); static void add_column (Grob *, Item *); @@ -34,7 +34,6 @@ public: DECLARE_SCHEME_CALLBACK (set_text_rods, (SCM)); DECLARE_SCHEME_CALLBACK (centered_stencil, (SCM)); - static void calculate_spacing_rods (Grob *me, Real length); static Stencil big_rest (Grob *, Real); static Stencil symbol_stencil (Grob *, Real); diff --git a/lily/include/music-iterator.hh b/lily/include/music-iterator.hh index 863f87f31b..cc821a1394 100644 --- a/lily/include/music-iterator.hh +++ b/lily/include/music-iterator.hh @@ -64,7 +64,7 @@ protected: Moment music_length_; Moment start_mom_; - DECLARE_CLASSNAME(Music_iterator); + DECLARE_CLASSNAME (Music_iterator); DECLARE_SMOBS (Music_iterator); Music_iterator (Music_iterator const &); @@ -102,15 +102,15 @@ private: bool is_child_context (Context *me, Context *child); -#define IMPLEMENT_CTOR_CALLBACK(Class) \ +#define IMPLEMENT_CTOR_CALLBACK(Class) \ LY_DEFINE_MEMBER_FUNCTION (Class, constructor, \ - mangle_cxx_identifier (string (#Class) + "::constructor").c_str(), \ - 0, 0, 0, \ - (), \ - "") \ - { \ - Class *c = (new Class); \ - return c->unprotect (); \ + mangle_cxx_identifier (string (#Class) + "::constructor").c_str(), \ + 0, 0, 0, \ + (), \ + "") \ + { \ + Class *c = (new Class); \ + return c->unprotect (); \ } DECLARE_UNSMOB (Music_iterator, iterator); diff --git a/lily/include/music-output.hh b/lily/include/music-output.hh index 27c6c423a8..1a09bb6fbf 100644 --- a/lily/include/music-output.hh +++ b/lily/include/music-output.hh @@ -29,7 +29,7 @@ class Music_output { DECLARE_SMOBS (Music_output); - DECLARE_CLASSNAME(Music_output); + DECLARE_CLASSNAME (Music_output); protected: Music_output (); diff --git a/lily/include/music-wrapper-iterator.hh b/lily/include/music-wrapper-iterator.hh index 82a069574e..8cfd9be7a9 100644 --- a/lily/include/music-wrapper-iterator.hh +++ b/lily/include/music-wrapper-iterator.hh @@ -32,7 +32,7 @@ class Music_wrapper_iterator : public Music_iterator public: DECLARE_SCHEME_CALLBACK (constructor, ()); Music_wrapper_iterator (); - DECLARE_CLASSNAME(Music_wrapper_iterator); + DECLARE_CLASSNAME (Music_wrapper_iterator); virtual void derived_substitute (Context *f, Context *t); virtual void derived_mark () const; diff --git a/lily/include/music.hh b/lily/include/music.hh index e3fdb3f83d..fb9e11fe5a 100644 --- a/lily/include/music.hh +++ b/lily/include/music.hh @@ -53,12 +53,12 @@ public: /// Scale the music in time by #factor#. void compress (Moment factor); - + // Broadcast the event in a context's event-source. void send_to_context (Context *c); DECLARE_SCHEME_CALLBACK (duration_length_callback, (SCM)); - + protected: virtual SCM copy_mutable_properties () const; virtual void type_check_assignment (SCM, SCM) const; diff --git a/lily/include/note-collision.hh b/lily/include/note-collision.hh index b2464067c8..58006a7c6e 100644 --- a/lily/include/note-collision.hh +++ b/lily/include/note-collision.hh @@ -24,7 +24,6 @@ #include "grob-interface.hh" #include "lily-proto.hh" - /** Resolve conflicts between various Note_columns (chords). @@ -38,12 +37,12 @@ class Note_collision_interface { public: - static SCM automatic_shift (Grob *, Drul_array<vector<Grob*> >); + static SCM automatic_shift (Grob *, Drul_array<vector<Grob *> >); static SCM forced_shift (Grob *); - static Drul_array<vector<Grob*> > get_clash_groups (Grob *me); + static Drul_array<vector<Grob *> > get_clash_groups (Grob *me); DECLARE_SCHEME_CALLBACK (calc_positioning_done, (SCM smob)); static void add_column (Grob *me, Grob *ncol); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); }; #endif // COLLISION_HH diff --git a/lily/include/note-column.hh b/lily/include/note-column.hh index d2138e9fcd..de440b31d3 100644 --- a/lily/include/note-column.hh +++ b/lily/include/note-column.hh @@ -23,7 +23,6 @@ #include "grob-interface.hh" #include "lily-proto.hh" - /** a struct for treating a group of noteheads (noteheads, stem (chord) and scripts) as a single entity. @@ -44,7 +43,7 @@ public: static bool has_rests (Grob *me); static Grob *dot_column (Grob *me); static Interval cross_staff_extent (Grob *me, Grob *refp); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); static Item *get_stem (Grob *); }; diff --git a/lily/include/note-head.hh b/lily/include/note-head.hh index a7faff9305..4fa1eca589 100644 --- a/lily/include/note-head.hh +++ b/lily/include/note-head.hh @@ -23,7 +23,6 @@ #include "stencil.hh" #include "grob-interface.hh" - class Note_head { public: @@ -32,7 +31,7 @@ public: DECLARE_SCHEME_CALLBACK (stem_x_shift, (SCM)); DECLARE_SCHEME_CALLBACK (calc_stem_attachment, (SCM)); DECLARE_SCHEME_CALLBACK (include_ledger_line_height, (SCM)); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); static Real stem_attachment_coordinate (Grob *, Axis a); static int get_balltype (Grob *); diff --git a/lily/include/note-spacing.hh b/lily/include/note-spacing.hh index d5465b639f..29f9eaad5d 100644 --- a/lily/include/note-spacing.hh +++ b/lily/include/note-spacing.hh @@ -27,11 +27,11 @@ class Note_spacing { public: - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); static Spring get_spacing (Grob *me, Item *, Real, Real); static void stem_dir_correction (Grob *me, Item *next_col, Real incr, - Real *, Real *); + Real *, Real *); }; #endif /* NOTE_SPACING_HH */ diff --git a/lily/include/open-type-font.hh b/lily/include/open-type-font.hh index 486606fd95..785add735a 100644 --- a/lily/include/open-type-font.hh +++ b/lily/include/open-type-font.hh @@ -20,12 +20,11 @@ #ifndef OPEN_TYPE_FONT_HH #define OPEN_TYPE_FONT_HH - #include "font-metric.hh" Index_to_charcode_map make_index_to_charcode_map (FT_Face face); -void get_unicode_name (char*s, FT_ULong code); -void get_glyph_index_name (char*s, FT_ULong code); +void get_unicode_name (char *s, FT_ULong code); +void get_glyph_index_name (char *s, FT_ULong code); class Open_type_font : public Font_metric { @@ -40,13 +39,13 @@ class Open_type_font : public Font_metric Index_to_charcode_map index_to_charcode_map_; Open_type_font (FT_Face); - DECLARE_CLASSNAME(Open_type_font); + DECLARE_CLASSNAME (Open_type_font); public: SCM get_subfonts () const; SCM get_global_table () const; SCM get_char_table () const; SCM glyph_list () const; - + string get_otf_table (string tag) const; static SCM make_otf (string); string font_name () const; @@ -65,5 +64,4 @@ public: string get_otf_table (FT_Face face, string tag); FT_Face open_ft_face (string str, FT_Long idx); - #endif /* OPEN_TYPE_FONT_HH */ diff --git a/lily/include/page-breaking.hh b/lily/include/page-breaking.hh index acf6bac51c..7d50db2524 100644 --- a/lily/include/page-breaking.hh +++ b/lily/include/page-breaking.hh @@ -53,23 +53,23 @@ struct Break_position { /* index into system_specs_, if this is VPOS, the Break_position represents the - start of the book. + start of the book. */ vsize system_spec_index_; /* if system_spec_index_ indexes a score, then we start at the score_brk_'th possible page-break in the score */ - vsize score_break_; + vsize score_break_; /* if system_spec_index_ indexes a score, this points to the broken column */ - Grob *col_; + Grob *col_; bool score_ender_; /* if non-zero, this is the (fixed, uncompressed) number of lines between this Break_position and the previous. */ int forced_line_count_; - Break_position (vsize s=VPOS, vsize brk=VPOS, Grob *g=NULL, bool end=false) + Break_position (vsize s = VPOS, vsize brk = VPOS, Grob *g = NULL, bool end = false) { system_spec_index_ = s; score_break_ = brk; @@ -81,18 +81,18 @@ struct Break_position /* lexicographic in (system_spec_index_, score_break_) */ - bool operator< (const Break_position &other) + bool operator < (const Break_position &other) { return (system_spec_index_ == VPOS && other.system_spec_index_ != VPOS) - || (system_spec_index_ < other.system_spec_index_) - || (system_spec_index_ == other.system_spec_index_ && score_break_ < other.score_break_); + || (system_spec_index_ < other.system_spec_index_) + || (system_spec_index_ == other.system_spec_index_ && score_break_ < other.score_break_); } - bool operator<= (const Break_position &other) + bool operator <= (const Break_position &other) { return (system_spec_index_ == VPOS) - || (system_spec_index_ < other.system_spec_index_ && other.system_spec_index_ != VPOS) - || (system_spec_index_ == other.system_spec_index_ && score_break_ <= other.score_break_); + || (system_spec_index_ < other.system_spec_index_ && other.system_spec_index_ != VPOS) + || (system_spec_index_ == other.system_spec_index_ && score_break_ <= other.score_break_); } }; @@ -102,7 +102,7 @@ public: typedef bool (*Break_predicate) (Grob *); typedef bool (*Prob_break_predicate) (Prob *); typedef vector<vsize> Line_division; - + /* TODO: naming. @@ -132,8 +132,8 @@ public: int line_count_status (int line_count) const; bool too_many_lines (int line_count) const; bool too_few_lines (int line_count) const; - Real min_whitespace_at_top_of_page (Line_details const&) const; - Real min_whitespace_at_bottom_of_page (Line_details const&) const; + Real min_whitespace_at_top_of_page (Line_details const &) const; + Real min_whitespace_at_bottom_of_page (Line_details const &) const; int orphan_penalty () const; protected: @@ -146,31 +146,30 @@ protected: vsize min_system_count (vsize start, vsize end); vsize max_system_count (vsize start, vsize end); - void break_into_pieces (vsize start, vsize end, Line_division const &div); SCM systems (); SCM footnotes (); void set_current_breakpoints (vsize start, - vsize end, - vsize system_count, - Line_division lower_bound = Line_division (), - Line_division upper_bound = Line_division ()); + vsize end, + vsize system_count, + Line_division lower_bound = Line_division (), + Line_division upper_bound = Line_division ()); void set_to_ideal_line_configuration (vsize start, vsize end); vsize current_configuration_count () const; Line_division current_configuration (vsize configuration_index) const; Page_spacing_result space_systems_on_n_pages (vsize configuration_index, - vsize n, vsize first_page_num); + vsize n, vsize first_page_num); Page_spacing_result space_systems_on_n_or_one_more_pages (vsize configuration_index, vsize n, - vsize first_page_num, - Real penalty_for_fewer_pages); + vsize first_page_num, + Real penalty_for_fewer_pages); Page_spacing_result space_systems_on_best_pages (vsize configuration_index, - vsize first_page_num); + vsize first_page_num); Page_spacing_result space_systems_with_fixed_number_per_page (vsize configuration_index, - vsize first_page_num); + vsize first_page_num); Page_spacing_result pack_systems_on_least_pages (vsize configuration_index, - vsize first_page_num); + vsize first_page_num); vsize min_page_count (vsize configuration_index, vsize first_page_num); bool all_lines_stretched (vsize configuration_index); Real blank_page_penalty () const; @@ -214,15 +213,15 @@ private: vector<Break_position> chunk_list (vsize start, vsize end); Line_division system_count_bounds (vector<Break_position> const &chunks, bool min); void line_breaker_args (vsize i, - Break_position const &start, - Break_position const &end, - vsize *line_breaker_start, - vsize *line_breaker_end); + Break_position const &start, + Break_position const &end, + vsize *line_breaker_start, + vsize *line_breaker_end); void line_divisions_rec (vsize system_count, - Line_division const &min, - Line_division const &max, - Line_division *cur); + Line_division const &min, + Line_division const &max, + Line_division *cur); vector<Line_details> line_details (vsize start, vsize end, Line_division const &div); Page_spacing_result space_systems_on_1_page (vector<Line_details> const &lines, Real page_height, bool ragged); diff --git a/lily/include/page-layout-problem.hh b/lily/include/page-layout-problem.hh index 629528bb53..6c952e3eed 100644 --- a/lily/include/page-layout-problem.hh +++ b/lily/include/page-layout-problem.hh @@ -26,43 +26,44 @@ class Page_layout_problem { public: - Page_layout_problem (Paper_book*, SCM page, SCM systems, int footnote_count); + Page_layout_problem (Paper_book *, SCM page, SCM systems, int footnote_count); SCM solution (bool ragged); void set_header_height (Real); void set_footer_height (Real); - static bool read_spacing_spec (SCM spec, Real* dest, SCM sym); + static bool read_spacing_spec (SCM spec, Real *dest, SCM sym); static bool is_spaceable (Grob *g); static SCM get_details (Grob *g); static vsize get_footnote_count (SCM lines); static SCM get_footnotes_from_lines (SCM lines, int counter, Paper_book *pb); - static Stencil* get_footnote_separator_stencil (Output_def *paper); + static Stencil *get_footnote_separator_stencil (Output_def *paper); static SCM get_spacing_spec (Grob *before, Grob *after, bool pure, int start, int end); static Real get_fixed_spacing (Grob *before, Grob *after, int spaceable_index, bool pure, int start, int end); static void add_footnotes_to_footer (SCM footnotes, Stencil *foot, Paper_book *pb); protected: - void append_system (System*, Spring const&, Real indent, Real padding); - void append_prob (Prob*, Spring const&, Real padding); + void append_system (System *, Spring const &, Real indent, Real padding); + void append_prob (Prob *, Spring const &, Real padding); void solve_rod_spring_problem (bool ragged); SCM find_system_offsets (); - void distribute_loose_lines (vector<Grob*> const&, vector<Real> const&, Real, Real); + void distribute_loose_lines (vector<Grob *> const &, vector<Real> const &, Real, Real); - static void build_system_skyline (vector<Grob*> const&, vector<Real> const&, Skyline* up, Skyline* down); - static vector<Grob*> filter_dead_elements (vector<Grob*> const&); + static void build_system_skyline (vector<Grob *> const &, vector<Real> const &, Skyline *up, Skyline *down); + static vector<Grob *> filter_dead_elements (vector<Grob *> const &); // This is a union (in spirit). // Either staves must be empty or prob must be null. - typedef struct Element { + typedef struct Element + { Prob *prob; - vector<Grob*> staves; + vector<Grob *> staves; vector<Real> min_offsets; // Store the appropriate '*-*-spacing 'padding, // for spacing any adjacent loose line Real padding; - Element (vector<Grob*> const& a, vector<Real> const& o, Real p) + Element (vector<Grob *> const &a, vector<Real> const &o, Real p) { staves = a; min_offsets = o; @@ -77,13 +78,13 @@ protected: } } Element; - static Interval first_staff_extent (Element const&); - static Interval last_staff_extent (Element const&); - static Interval prob_extent (Prob*); - static SCM get_details (Element const&); - static SCM details_get_property (SCM details, const char*); - static void alter_spring_from_spacing_spec (SCM spec, Spring* spring); - static void mark_as_spaceable (Grob*); + static Interval first_staff_extent (Element const &); + static Interval last_staff_extent (Element const &); + static Interval prob_extent (Prob *); + static SCM get_details (Element const &); + static SCM details_get_property (SCM details, const char *); + static void alter_spring_from_spacing_spec (SCM spec, Spring *spring); + static void mark_as_spaceable (Grob *); vector<Spring> springs_; vector<Element> elements_; diff --git a/lily/include/page-spacing-result.hh b/lily/include/page-spacing-result.hh index 6d32bc6c2b..8f1f836af6 100644 --- a/lily/include/page-spacing-result.hh +++ b/lily/include/page-spacing-result.hh @@ -27,13 +27,15 @@ // to represent the system count of several pages simultaneously, // it could be that one page has too many systems while another // has too few. -typedef enum { +typedef enum +{ SYSTEM_COUNT_OK = 0, SYSTEM_COUNT_TOO_MANY = 1, SYSTEM_COUNT_TOO_FEW = 2 } System_count_status; -struct Page_spacing_result { +struct Page_spacing_result +{ vector<vsize> systems_per_page_; vector<Real> force_; Real penalty_; @@ -42,7 +44,7 @@ struct Page_spacing_result { Real average_force () const; vsize page_count () const; - void print () const; + void print () const; Page_spacing_result (); }; diff --git a/lily/include/page-spacing.hh b/lily/include/page-spacing.hh index 206bcbf426..111c154e27 100644 --- a/lily/include/page-spacing.hh +++ b/lily/include/page-spacing.hh @@ -43,7 +43,6 @@ const Real BAD_SPACING_PENALTY = 1e6; const Real TERRIBLE_SPACING_PENALTY = 1e8; - /* for page_count > 2, we use a dynamic algorithm similar to constrained-breaking -- we have a class that stores the intermediate calculations so they can be reused for querying different page counts. @@ -51,7 +50,7 @@ const Real TERRIBLE_SPACING_PENALTY = 1e8; class Page_spacer { public: - Page_spacer (vector<Line_details> const &lines, vsize first_page_num, Page_breaking const*); + Page_spacer (vector<Line_details> const &lines, vsize first_page_num, Page_breaking const *); Page_spacing_result solve (vsize page_count); Page_spacing_result solve (); diff --git a/lily/include/page-turn-page-breaking.hh b/lily/include/page-turn-page-breaking.hh index 6717e5ba4a..b090c0a15b 100644 --- a/lily/include/page-turn-page-breaking.hh +++ b/lily/include/page-turn-page-breaking.hh @@ -63,9 +63,9 @@ protected: vsize total_page_count (Break_node const &b); Break_node put_systems_on_pages (vsize start, - vsize end, - vsize configuration, - vsize page_number); + vsize end, + vsize configuration, + vsize page_number); SCM make_lines (vector<Break_node> *breaks); SCM make_pages (vector<Break_node> const &breaks, SCM systems); diff --git a/lily/include/pango-font.hh b/lily/include/pango-font.hh index 3d435af9ca..b92eb60c42 100644 --- a/lily/include/pango-font.hh +++ b/lily/include/pango-font.hh @@ -42,11 +42,11 @@ class Pango_font : public Font_metric public: SCM physical_font_tab () const; Pango_font (PangoFT2FontMap *, - PangoFontDescription const *, - Real); + PangoFontDescription const *, + Real); ~Pango_font (); - string description_string () const; + string description_string () const; SCM font_file_name () const; void register_font_file (string, string, int); @@ -59,10 +59,10 @@ public: PangoFontDescription * symbols_to_pango_font_description (SCM family, - SCM style, - SCM variant, - SCM weight, - SCM stretch); + SCM style, + SCM variant, + SCM weight, + SCM stretch); Font_metric * select_pango_font (Output_def *layout, SCM chain); diff --git a/lily/include/paper-book.hh b/lily/include/paper-book.hh index dd05ee41d2..fad47fe1ad 100644 --- a/lily/include/paper-book.hh +++ b/lily/include/paper-book.hh @@ -37,7 +37,7 @@ class Paper_book void add_score_title (SCM); SCM get_score_title (SCM); - + public: SCM header_; SCM header_0_; @@ -59,20 +59,19 @@ public: SCM pages (); SCM get_system_specs (); - Stencil book_title (); Stencil score_title (SCM); - + void classic_output (SCM output_channel); void output (SCM output_channel); protected: void classic_output_aux (SCM output, - int *first_performance_number); + int *first_performance_number); int output_aux (SCM output_channel, - bool is_last, - int *first_page_number, - int *first_performance_number); + bool is_last, + int *first_page_number, + int *first_performance_number); }; DECLARE_UNSMOB (Paper_book, paper_book) diff --git a/lily/include/paper-column-engraver.hh b/lily/include/paper-column-engraver.hh index 449b26d9a4..edb6ad8d59 100644 --- a/lily/include/paper-column-engraver.hh +++ b/lily/include/paper-column-engraver.hh @@ -49,12 +49,12 @@ protected: DECLARE_ACKNOWLEDGER (staff_spacing); System *system_; - vector<Stream_event*> break_events_; - vector<Stream_event*> label_events_; - int breaks_; // used for stat printing + vector<Stream_event *> break_events_; + vector<Stream_event *> label_events_; + int breaks_; // used for stat printing Paper_column *command_column_; Paper_column *musical_column_; - vector<Item*> items_; + vector<Item *> items_; bool first_; bool made_columns_; Moment last_moment_; diff --git a/lily/include/paper-column.hh b/lily/include/paper-column.hh index bc2eec12c2..acfd84668a 100644 --- a/lily/include/paper-column.hh +++ b/lily/include/paper-column.hh @@ -39,10 +39,10 @@ public: virtual System *get_system () const; void set_system (System *); - static int compare (Grob * const &a, - Grob * const &b); + static int compare (Grob *const &a, + Grob *const &b); static bool less_than (Grob *const &a, - Grob *const &b); + Grob *const &b); int get_rank () const { return rank_; } void set_rank (int); @@ -50,7 +50,7 @@ public: DECLARE_SCHEME_CALLBACK (print, (SCM)); DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM)); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); static int get_rank (Grob const *); static bool is_musical (Grob *); static Moment when_mom (Grob *); diff --git a/lily/include/paper-score.hh b/lily/include/paper-score.hh index aec2846232..fcce96ac91 100644 --- a/lily/include/paper-score.hh +++ b/lily/include/paper-score.hh @@ -31,13 +31,13 @@ class Paper_score : public Music_output SCM systems_; SCM paper_systems_; - mutable vector<Grob*> cols_; + mutable vector<Grob *> cols_; mutable vector<vsize> break_indices_; mutable vector<vsize> break_ranks_; public: Paper_score (Output_def *); - - DECLARE_CLASSNAME(Paper_score); + + DECLARE_CLASSNAME (Paper_score); Output_def *layout () const; System *root_system () const; @@ -46,7 +46,7 @@ public: vector<Column_x_positions> calc_breaking (); vector<vsize> get_break_indices () const; vector<vsize> get_break_ranks () const; - vector<Grob*> get_columns () const; + vector<Grob *> get_columns () const; SCM get_paper_systems (); protected: void find_break_indices () const; diff --git a/lily/include/parse-scm.hh b/lily/include/parse-scm.hh index 0322502e16..ad086061f8 100644 --- a/lily/include/parse-scm.hh +++ b/lily/include/parse-scm.hh @@ -34,12 +34,13 @@ struct Parse_start bool safe_; Lily_parser *parser_; - Parse_start() { + Parse_start () + { str = 0; nchars = 0; safe_ = false; parser_ = 0; - } + } }; SCM catch_protected_parse_body (void *); diff --git a/lily/include/percent-repeat-item.hh b/lily/include/percent-repeat-item.hh index a9e59e35f5..999d0bbeb5 100644 --- a/lily/include/percent-repeat-item.hh +++ b/lily/include/percent-repeat-item.hh @@ -26,7 +26,7 @@ class Percent_repeat_item_interface { public: - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); DECLARE_SCHEME_CALLBACK (beat_slash, (SCM)); DECLARE_SCHEME_CALLBACK (double_percent, (SCM)); static Stencil x_percent (Grob *, int); diff --git a/lily/include/performance.hh b/lily/include/performance.hh index 9612fb8aed..31d65d9b33 100644 --- a/lily/include/performance.hh +++ b/lily/include/performance.hh @@ -27,9 +27,9 @@ class Performance : public Music_output { public: - Performance (bool ports=false); + Performance (bool ports = false); ~Performance (); - DECLARE_CLASSNAME(Performance); + DECLARE_CLASSNAME (Performance); void add_element (Audio_element *p); virtual void process (); @@ -40,8 +40,8 @@ public: void print () const; void write_output (string filename) const; - vector<Audio_staff*> audio_staffs_; - vector<Audio_element*> audio_elements_; + vector<Audio_staff *> audio_staffs_; + vector<Audio_element *> audio_elements_; Output_def *midi_; bool ports_; }; diff --git a/lily/include/pitch.hh b/lily/include/pitch.hh index df829b2a0d..e0a6b45b87 100644 --- a/lily/include/pitch.hh +++ b/lily/include/pitch.hh @@ -24,7 +24,6 @@ #include "smobs.hh" #include "rational.hh" - /* A "tonal" pitch. This is a pitch used in diatonal western music (24 quartertones in an octave), as opposed to a frequency in Hz or a @@ -75,8 +74,8 @@ public: DECLARE_SIMPLE_SMOBS (Pitch); }; - -enum { +enum +{ DOUBLE_FLAT = -4, THREE_Q_FLAT, FLAT, diff --git a/lily/include/pointer-group-interface.hh b/lily/include/pointer-group-interface.hh index 4d1a96aede..b84ecc4571 100644 --- a/lily/include/pointer-group-interface.hh +++ b/lily/include/pointer-group-interface.hh @@ -32,12 +32,12 @@ public: static void add_grob (Grob *, SCM nm, SCM x); static void add_unordered_grob (Grob *, SCM nm, Grob *); static void set_ordered (Grob *, SCM, bool); - static Grob_array *get_grob_array (Grob*, SCM); - static Grob *find_grob (Grob*, SCM, bool (*pred) (Grob*)); + static Grob_array *get_grob_array (Grob *, SCM); + static Grob *find_grob (Grob *, SCM, bool (*pred) (Grob *)); }; -vector<Grob*> const &internal_extract_grob_array (Grob const *elt, SCM symbol); -vector<Item*> internal_extract_item_array (Grob const *elt, SCM symbol); +vector<Grob *> const &internal_extract_grob_array (Grob const *elt, SCM symbol); +vector<Item *> internal_extract_item_array (Grob const *elt, SCM symbol); #define extract_grob_array(x, prop) internal_extract_grob_array (x, ly_symbol2scm (prop)) #define extract_item_array(x, prop) internal_extract_item_array (x, ly_symbol2scm (prop)) @@ -46,9 +46,9 @@ vector<Item*> internal_extract_item_array (Grob const *elt, SCM symbol); This is dubious coding style, but lets not risk that we change the representation of grob sets again. */ -#define extract_grob_set(grob, prop, set) \ +#define extract_grob_set(grob, prop, set) \ vector<Grob*> const &set (internal_extract_grob_array (grob, ly_symbol2scm (prop))) -#define extract_item_set(grob, prop, set) \ +#define extract_item_set(grob, prop, set) \ vector<Item*> set (internal_extract_item_array (grob, ly_symbol2scm (prop))) #endif /* POINTER_GROUP_INTERFACE_HH */ diff --git a/lily/include/prob.hh b/lily/include/prob.hh index 5d4a50029f..dff74f49d5 100644 --- a/lily/include/prob.hh +++ b/lily/include/prob.hh @@ -23,7 +23,6 @@ #include "stencil.hh" #include "virtual-methods.hh" - /* A formatted "system" (A block of titling also is a Property_object) @@ -35,18 +34,18 @@ class Prob { DECLARE_SMOBS (Prob); - DECLARE_CLASSNAME(Prob); + DECLARE_CLASSNAME (Prob); void init_vars (); protected: SCM mutable_property_alist_; SCM immutable_property_alist_; SCM type_; - + virtual void derived_mark () const; virtual SCM copy_mutable_properties () const; - virtual void type_check_assignment (SCM,SCM) const; - + virtual void type_check_assignment (SCM, SCM) const; + public: Prob (SCM, SCM); Prob (Prob const &); @@ -54,15 +53,15 @@ public: SCM type () const { return type_; } SCM get_property_alist (bool _mutable) const; SCM internal_get_property (SCM sym) const; - void instrumented_set_property (SCM, SCM, const char*, int, const char*); + void instrumented_set_property (SCM, SCM, const char *, int, const char *); void internal_set_property (SCM sym, SCM val); }; -DECLARE_UNSMOB(Prob,prob); +DECLARE_UNSMOB (Prob, prob); SCM ly_prob_set_property_x (SCM system, SCM sym, SCM value); SCM ly_prob_property (SCM prob, SCM sym, SCM val); SCM ly_prob_type_p (SCM obj, SCM sym); - + #endif /* PROPERTY_OBJECT_HH */ diff --git a/lily/include/property-iterator.hh b/lily/include/property-iterator.hh index c53a4d9648..2e6548b2ac 100644 --- a/lily/include/property-iterator.hh +++ b/lily/include/property-iterator.hh @@ -30,7 +30,7 @@ class Property_iterator : public Simple_music_iterator public: DECLARE_SCHEME_CALLBACK (constructor, ()); DECLARE_SCHEME_CALLBACK (once_finalization, (SCM, SCM, SCM)); - DECLARE_CLASSNAME(Property_iterator); + DECLARE_CLASSNAME (Property_iterator); protected: virtual void do_quit (); @@ -44,7 +44,7 @@ class Property_unset_iterator : public Simple_music_iterator { public: DECLARE_SCHEME_CALLBACK (constructor, ()); - DECLARE_CLASSNAME(Property_unset_iterator); + DECLARE_CLASSNAME (Property_unset_iterator); protected: virtual void process (Moment); }; @@ -54,7 +54,7 @@ class Push_property_iterator : public Simple_music_iterator public: DECLARE_SCHEME_CALLBACK (constructor, ()); DECLARE_SCHEME_CALLBACK (once_finalization, (SCM, SCM)); - DECLARE_CLASSNAME(Push_property_iterator); + DECLARE_CLASSNAME (Push_property_iterator); protected: virtual void process (Moment); virtual void do_quit (); @@ -64,7 +64,7 @@ class Pop_property_iterator : public Simple_music_iterator { public: DECLARE_SCHEME_CALLBACK (constructor, ()); - DECLARE_CLASSNAME(Pop_property_iterator); + DECLARE_CLASSNAME (Pop_property_iterator); protected: virtual void process (Moment); }; diff --git a/lily/include/rest-collision.hh b/lily/include/rest-collision.hh index a954b6f24b..b35c6e2e41 100644 --- a/lily/include/rest-collision.hh +++ b/lily/include/rest-collision.hh @@ -28,7 +28,7 @@ class Rest_collision public: static void add_column (Grob *me, Grob *); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); DECLARE_SCHEME_CALLBACK (calc_positioning_done, (SCM element)); DECLARE_SCHEME_CALLBACK (force_shift_callback_rest, (SCM element, SCM off)); static SCM do_shift (Grob *); diff --git a/lily/include/rest.hh b/lily/include/rest.hh index 053e3960c0..ba1ab3e90a 100644 --- a/lily/include/rest.hh +++ b/lily/include/rest.hh @@ -29,10 +29,10 @@ class Rest public: DECLARE_SCHEME_CALLBACK (y_offset_callback, (SCM)); DECLARE_SCHEME_CALLBACK (calc_cross_staff, (SCM)); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); static string glyph_name (Grob *, int, string, bool); - static SCM brew_internal_stencil (Grob*, bool); - static SCM generic_extent_callback (Grob*, Axis); + static SCM brew_internal_stencil (Grob *, bool); + static SCM generic_extent_callback (Grob *, Axis); static void translate (Grob *me, int dy); DECLARE_SCHEME_CALLBACK (polyphonic_offset_callback, (SCM)); DECLARE_SCHEME_CALLBACK (print, (SCM)); diff --git a/lily/include/rhythmic-head.hh b/lily/include/rhythmic-head.hh index 7dbe9fa2e7..8cad135232 100644 --- a/lily/include/rhythmic-head.hh +++ b/lily/include/rhythmic-head.hh @@ -32,7 +32,7 @@ public: static Item *get_dots (Grob *); static int dot_count (Grob *); DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM)); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); }; #endif // RHYTHMIC_HEAD_HH diff --git a/lily/include/scale.hh b/lily/include/scale.hh index 7f6a881762..4562d372a7 100644 --- a/lily/include/scale.hh +++ b/lily/include/scale.hh @@ -27,8 +27,8 @@ struct Scale { public: - Scale (vector<Rational> const&); - Scale (Scale const&); + Scale (vector<Rational> const &); + Scale (Scale const &); Rational tones_at_step (int step, int octave) const; Rational step_size (int step) const; @@ -45,4 +45,3 @@ extern Scale *default_global_scale; #endif /* SCALE_HH */ - diff --git a/lily/include/scheme-engraver.hh b/lily/include/scheme-engraver.hh index 9ae0591bb4..e3d0839db6 100644 --- a/lily/include/scheme-engraver.hh +++ b/lily/include/scheme-engraver.hh @@ -1,8 +1,8 @@ -/* +/* scheme-engraver.hh -- declare Scheme_engraver - + source file of the GNU LilyPond music typesetter - + Copyright (c) 2009--2011 Han-Wen Nienhuys <hanwen@lilypond.org> LilyPond is free software: you can redistribute it and/or modify @@ -16,8 +16,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with LilyPond. If not, see <http://www.gnu.org/licenses/>. - + along with LilyPond. If not, see <http://www.gnu.org/licenses/>. */ #ifndef SCHEME_ENGRAVER_HH @@ -25,16 +24,17 @@ #include "engraver.hh" -class Scheme_engraver : public Engraver { +class Scheme_engraver : public Engraver +{ public: void init_from_scheme (SCM definition); TRANSLATOR_DECLARATIONS_NO_LISTENER (Scheme_engraver); - + static Listener get_listener (void *generic_arg, SCM event); - + protected: ~Scheme_engraver (); - + void stop_translation_timestep (); void start_translation_timestep (); void process_music (); @@ -54,7 +54,7 @@ private: DECLARE_END_ACKNOWLEDGER (grob); bool must_be_last_; - + SCM acknowledge_grob_function_; SCM stop_translation_timestep_function_; SCM start_translation_timestep_function_; diff --git a/lily/include/score-engraver.hh b/lily/include/score-engraver.hh index 3be8eb42f1..7bf177576b 100644 --- a/lily/include/score-engraver.hh +++ b/lily/include/score-engraver.hh @@ -26,7 +26,7 @@ class Score_engraver : public Engraver_group { System *system_; - vector<Grob*> elems_; + vector<Grob *> elems_; Paper_score *pscore_; void typeset_all (); diff --git a/lily/include/script-column.hh b/lily/include/script-column.hh index ea76373e55..85a57d3027 100644 --- a/lily/include/script-column.hh +++ b/lily/include/script-column.hh @@ -30,8 +30,8 @@ public: static void add_side_positioned (Grob *, Grob *); DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM)); DECLARE_SCHEME_CALLBACK (row_before_line_breaking, (SCM)); - DECLARE_GROB_INTERFACE(); - static void order_grobs (vector<Grob*> grobs); + DECLARE_GROB_INTERFACE (); + static void order_grobs (vector<Grob *> grobs); }; diff --git a/lily/include/script-interface.hh b/lily/include/script-interface.hh index 4ec00d01df..3063594e71 100644 --- a/lily/include/script-interface.hh +++ b/lily/include/script-interface.hh @@ -34,15 +34,15 @@ public: static Stencil get_stencil (Grob *, Direction d); static Direction get_direction (Grob *); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); DECLARE_SCHEME_CALLBACK (print, (SCM)); DECLARE_SCHEME_CALLBACK (calc_direction, (SCM)); DECLARE_SCHEME_CALLBACK (calc_positioning_done, (SCM)); DECLARE_SCHEME_CALLBACK (calc_cross_staff, (SCM)); }; -void make_script_from_event (Grob *p, Context *tg, - SCM type, int index); +void make_script_from_event (Grob *p, Context *tg, + SCM type, int index); #endif /* SCRIPT_INTERFACE_HH */ diff --git a/lily/include/self-alignment-interface.hh b/lily/include/self-alignment-interface.hh index be51ee061a..8ecde08a3e 100644 --- a/lily/include/self-alignment-interface.hh +++ b/lily/include/self-alignment-interface.hh @@ -25,14 +25,14 @@ struct Self_alignment_interface { - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); static SCM aligned_on_self (Grob *me, Axis a, bool pure, int start, int end); static SCM centered_on_object (Grob *me, Axis a); static SCM aligned_on_parent (Grob *me, Axis a); static void set_center_parent (Grob *me, Axis a); static void set_align_self (Grob *me, Axis a); - + DECLARE_SCHEME_CALLBACK (x_aligned_on_self, (SCM element)); DECLARE_SCHEME_CALLBACK (y_aligned_on_self, (SCM element)); diff --git a/lily/include/semi-tie-column.hh b/lily/include/semi-tie-column.hh index 58511cb170..836fc96888 100644 --- a/lily/include/semi-tie-column.hh +++ b/lily/include/semi-tie-column.hh @@ -26,12 +26,11 @@ struct Semi_tie_column { - DECLARE_GROB_INTERFACE(); - + DECLARE_GROB_INTERFACE (); + DECLARE_SCHEME_CALLBACK (calc_positioning_done, (SCM)); DECLARE_SCHEME_CALLBACK (calc_head_direction, (SCM)); }; - #endif /* SEMI_TIE_COLUMN_HH */ diff --git a/lily/include/semi-tie.hh b/lily/include/semi-tie.hh index 8cbb3601d7..34ff039e6f 100644 --- a/lily/include/semi-tie.hh +++ b/lily/include/semi-tie.hh @@ -20,18 +20,17 @@ #ifndef SEMI_TIE_HH #define SEMI_TIE_HH - #include "grob-interface.hh" #include "lily-proto.hh" struct Semi_tie { - DECLARE_GROB_INTERFACE(); - + DECLARE_GROB_INTERFACE (); + DECLARE_SCHEME_CALLBACK (calc_direction, (SCM)); DECLARE_SCHEME_CALLBACK (calc_control_points, (SCM)); static bool less (Grob *const &s1, - Grob *const &s2); + Grob *const &s2); static int get_position (Grob *); }; diff --git a/lily/include/sequential-iterator.hh b/lily/include/sequential-iterator.hh index 60bdac96bf..afe9169b10 100644 --- a/lily/include/sequential-iterator.hh +++ b/lily/include/sequential-iterator.hh @@ -30,7 +30,7 @@ class Sequential_iterator : public Music_iterator { public: DECLARE_SCHEME_CALLBACK (constructor, ()); - DECLARE_CLASSNAME(Sequential_iterator); + DECLARE_CLASSNAME (Sequential_iterator); Sequential_iterator (); Sequential_iterator (Sequential_iterator const &); virtual void derived_substitute (Context *f, Context *t); @@ -45,10 +45,10 @@ public: protected: virtual void process (Moment); virtual bool run_always () const; - + protected: Music_iterator *iter_; - + virtual SCM get_music_list () const; virtual void next_element (bool side_effect); diff --git a/lily/include/side-position-interface.hh b/lily/include/side-position-interface.hh index 624bff4e89..b7d1427ee3 100644 --- a/lily/include/side-position-interface.hh +++ b/lily/include/side-position-interface.hh @@ -40,13 +40,13 @@ public: DECLARE_SCHEME_CALLBACK (calc_cross_staff, (SCM element)); DECLARE_SCHEME_CALLBACK (move_to_extremal_staff, (SCM)); - static SCM aligned_side (Grob*me, Axis a, bool pure, int start, int end, Real *current_off_ptr); + static SCM aligned_side (Grob *me, Axis a, bool pure, int start, int end, Real *current_off_ptr); static SCM general_side_position (Grob *, Axis, bool, bool my_extents, - bool pure, int start, int end, Real *current_off); + bool pure, int start, int end, Real *current_off); static Axis get_axis (Grob *); static void set_axis (Grob *, Axis); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); static void add_support (Grob *, Grob *); static void add_staff_support (Grob *); }; diff --git a/lily/include/simple-music-iterator.hh b/lily/include/simple-music-iterator.hh index f046b84689..df20fb817c 100644 --- a/lily/include/simple-music-iterator.hh +++ b/lily/include/simple-music-iterator.hh @@ -29,7 +29,7 @@ class Simple_music_iterator : public Music_iterator { protected: - DECLARE_CLASSNAME(Simple_music_iterator); + DECLARE_CLASSNAME (Simple_music_iterator); Moment last_processed_mom_; public: diff --git a/lily/include/simple-spacer.hh b/lily/include/simple-spacer.hh index 895fbcf8d8..620921fe9a 100644 --- a/lily/include/simple-spacer.hh +++ b/lily/include/simple-spacer.hh @@ -32,7 +32,7 @@ public: void solve (Real line_len, bool ragged); void add_rod (int l, int r, Real dist); - void add_spring (Spring const&); + void add_spring (Spring const &); Real range_ideal_len (int l, int r) const; Real range_stiffness (int l, int r, bool stretch) const; Real configuration_length (Real) const; @@ -57,15 +57,15 @@ private: }; /* returns a vector of dimensions breaks.size () * breaks.size () */ -vector<Real> get_line_forces (vector<Grob*> const &columns, - Real line_len, - Real indent, - bool ragged); - -Column_x_positions get_line_configuration (vector<Grob*> const &columns, - Real line_len, - Real indent, - bool ragged); +vector<Real> get_line_forces (vector<Grob *> const &columns, + Real line_len, + Real indent, + bool ragged); + +Column_x_positions get_line_configuration (vector<Grob *> const &columns, + Real line_len, + Real indent, + bool ragged); #endif /* SIMPLE_SPACER_HH */ diff --git a/lily/include/simultaneous-music-iterator.hh b/lily/include/simultaneous-music-iterator.hh index ff1100fb6d..30094126f4 100644 --- a/lily/include/simultaneous-music-iterator.hh +++ b/lily/include/simultaneous-music-iterator.hh @@ -30,7 +30,7 @@ public: virtual void derived_substitute (Context *f, Context *t); virtual void derived_mark () const; DECLARE_SCHEME_CALLBACK (constructor, ()); - DECLARE_CLASSNAME(Simultaneous_music_iterator); + DECLARE_CLASSNAME (Simultaneous_music_iterator); /// make a new context for every child. bool create_separate_contexts_; diff --git a/lily/include/skyline-pair.hh b/lily/include/skyline-pair.hh index b32bd13815..f4b5ced9e3 100644 --- a/lily/include/skyline-pair.hh +++ b/lily/include/skyline-pair.hh @@ -27,7 +27,7 @@ class Skyline_pair private: Drul_array<Skyline> skylines_; - DECLARE_SIMPLE_SMOBS(Skyline_pair); + DECLARE_SIMPLE_SMOBS (Skyline_pair); public: Skyline_pair (); Skyline_pair (vector<Box> const &boxes, Real horizon_padding, Axis a); diff --git a/lily/include/skyline.hh b/lily/include/skyline.hh index bb637a21bb..2eccdb2ef4 100644 --- a/lily/include/skyline.hh +++ b/lily/include/skyline.hh @@ -55,10 +55,10 @@ private: Direction sky_; void internal_merge_skyline (list<Building>*, list<Building>*, - list<Building> *const result); + list<Building> *const result); list<Building> internal_build_skyline (list<Box>*, Real, Axis, Direction); - DECLARE_SIMPLE_SMOBS(Skyline); + DECLARE_SIMPLE_SMOBS (Skyline); public: Skyline (); diff --git a/lily/include/slur-configuration.hh b/lily/include/slur-configuration.hh index a4d78f99c9..acf2b1fdc6 100644 --- a/lily/include/slur-configuration.hh +++ b/lily/include/slur-configuration.hh @@ -46,15 +46,15 @@ public: }; int next_scorer_todo; - + Slur_configuration (); Real score () const { return score_; } - string card () const { return score_card_; } + string card () const { return score_card_; } void add_score (Real, string); - + void generate_curve (Slur_score_state const &state, Real r0, Real h_inf, - vector<Offset> const &); + vector<Offset> const &); void run_next_scorer (Slur_score_state const &); bool done () const; static Slur_configuration *new_config (Drul_array<Offset> const &offs, int idx); @@ -72,7 +72,7 @@ protected: class Slur_configuration_less { public: - bool operator () (Slur_configuration* const& l, Slur_configuration* const& r) + bool operator () (Slur_configuration *const &l, Slur_configuration *const &r) { // Invert return l->score_ > r->score_; diff --git a/lily/include/slur-scoring.hh b/lily/include/slur-scoring.hh index 866b216942..82784c4971 100644 --- a/lily/include/slur-scoring.hh +++ b/lily/include/slur-scoring.hh @@ -32,7 +32,7 @@ struct Extra_collision_info Real penalty_; Grob *grob_; SCM type_; - + Extra_collision_info (Grob *g, Real idx, Interval x, Interval y, Real p); Extra_collision_info (); }; @@ -89,7 +89,7 @@ struct Slur_score_state bool has_same_beam_; Real musical_dy_; - vector<Grob*> columns_; + vector<Grob *> columns_; vector<Encompass_info> encompass_infos_; vector<Extra_collision_info> extra_encompass_infos_; @@ -97,7 +97,7 @@ struct Slur_score_state Slur_score_parameters parameters_; Drul_array<Bound_info> extremes_; Drul_array<Offset> base_attachments_; - vector<Slur_configuration*> configurations_; + vector<Slur_configuration *> configurations_; Real staff_space_; Real thickness_; @@ -108,18 +108,18 @@ struct Slur_score_state Slur_configuration *get_best_curve () const; void fill (Grob *); Direction slur_direction () const; - + vector<Offset> generate_avoid_offsets () const; Drul_array<Bound_info> get_bound_info () const; void generate_curves () const; - vector<Slur_configuration*> enumerate_attachments (Drul_array<Real> end_ys) const; + vector<Slur_configuration *> enumerate_attachments (Drul_array<Real> end_ys) const; Drul_array<Offset> get_base_attachments () const; Drul_array<Real> get_y_attachment_range () const; Encompass_info get_encompass_info (Grob *col) const; vector<Extra_collision_info> get_extra_encompass_infos () const; Real move_away_from_staffline (Real y, Grob *on_staff) const; - Grob *breakable_bound_item (Direction) const; + Grob *breakable_bound_item (Direction) const; }; void set_slur_control_points (Grob *me); diff --git a/lily/include/slur.hh b/lily/include/slur.hh index 7abc764559..78659c9317 100644 --- a/lily/include/slur.hh +++ b/lily/include/slur.hh @@ -30,7 +30,7 @@ public: static void add_column (Grob *me, Grob *col); static void add_extra_encompass (Grob *me, Grob *col); static void replace_breakable_encompass_objects (Grob *me); - static void auxiliary_acknowledge_extra_object (Grob_info const &, vector<Grob*>&, vector<Grob*>&); + static void auxiliary_acknowledge_extra_object (Grob_info const &, vector<Grob *>&, vector<Grob *>&); DECLARE_SCHEME_CALLBACK (print, (SCM)); DECLARE_SCHEME_CALLBACK (calc_control_points, (SCM)); DECLARE_SCHEME_CALLBACK (calc_direction, (SCM)); @@ -40,7 +40,7 @@ public: DECLARE_SCHEME_CALLBACK (pure_outside_slur_callback, (SCM, SCM, SCM, SCM)); DECLARE_SCHEME_CALLBACK (outside_slur_cross_staff, (SCM, SCM)); DECLARE_SCHEME_CALLBACK (calc_cross_staff, (SCM)); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); static Bezier get_curve (Grob *me); }; diff --git a/lily/include/smobs.hh b/lily/include/smobs.hh index cf6ffcc9a3..f0cea02301 100644 --- a/lily/include/smobs.hh +++ b/lily/include/smobs.hh @@ -99,52 +99,52 @@ from file "ly-smobs.icc" */ -#define DECLARE_SIMPLE_SMOBS(CL) \ - public: \ - SCM smobbed_copy () const; \ +#define DECLARE_SIMPLE_SMOBS(CL) \ + public: \ + SCM smobbed_copy () const; \ DECLARE_BASE_SMOBS (CL) -#define DECLARE_BASE_SMOBS(CL) \ - friend class Non_existent_class; \ - private: \ +#define DECLARE_BASE_SMOBS(CL) \ + friend class Non_existent_class; \ + private: \ static const char* smob_name_; \ - static scm_t_bits smob_tag_; \ - static SCM mark_smob (SCM); \ - static size_t free_smob (SCM s); \ - static int print_smob (SCM s, SCM p, scm_print_state*); \ - public: \ - static SCM equal_p (SCM a, SCM b); \ - static CL *unsmob (SCM s) __attribute__((pure)) \ - { \ - if (SCM_NIMP (s) && SCM_CELL_TYPE (s) == smob_tag_) \ - return (CL *) SCM_CELL_WORD_1 (s); \ - else \ - return 0; \ - } \ - static SCM smob_p (SCM); \ - static void init_smobs (); \ + static scm_t_bits smob_tag_; \ + static SCM mark_smob (SCM); \ + static size_t free_smob (SCM s); \ + static int print_smob (SCM s, SCM p, scm_print_state*); \ + public: \ + static SCM equal_p (SCM a, SCM b); \ + static CL *unsmob (SCM s) __attribute__((pure)) \ + { \ + if (SCM_NIMP (s) && SCM_CELL_TYPE (s) == smob_tag_) \ + return (CL *) SCM_CELL_WORD_1 (s); \ + else \ + return 0; \ + } \ + static SCM smob_p (SCM); \ + static void init_smobs (); \ private: -#define DECLARE_SMOBS(CL) \ - DECLARE_BASE_SMOBS (CL) \ - protected: \ - virtual ~CL (); \ - SCM unprotected_smobify_self (); \ - private: \ - void smobify_self (); \ - SCM self_scm_; \ - SCM protection_cons_; \ - public: \ - SCM unprotect (); \ - void protect (); \ - SCM self_scm () const { return self_scm_; } \ +#define DECLARE_SMOBS(CL) \ + DECLARE_BASE_SMOBS (CL) \ + protected: \ + virtual ~CL (); \ + SCM unprotected_smobify_self (); \ + private: \ + void smobify_self (); \ + SCM self_scm_; \ + SCM protection_cons_; \ + public: \ + SCM unprotect (); \ + void protect (); \ + SCM self_scm () const { return self_scm_; } \ private: -#define DECLARE_UNSMOB(CL, name) \ - inline CL * \ - unsmob_ ## name (SCM s) \ - { \ - return CL::unsmob (s); \ +#define DECLARE_UNSMOB(CL, name) \ + inline CL * \ + unsmob_ ## name (SCM s) \ + { \ + return CL::unsmob (s); \ } #define DECLARE_TYPE_P(CL) extern SCM CL ## _type_p_proc diff --git a/lily/include/source-file.hh b/lily/include/source-file.hh index 9dedceb48b..0210418c65 100644 --- a/lily/include/source-file.hh +++ b/lily/include/source-file.hh @@ -37,7 +37,7 @@ using namespace std; class Source_file { - vector<char const*> newline_locations_; + vector<char const *> newline_locations_; istream *istream_; vector<char> characters_; SCM str_port_; @@ -45,7 +45,7 @@ class Source_file void load_stdin (); void init_port (); void init (); - + DECLARE_SMOBS (Source_file); public: Source_file (string fn); @@ -65,7 +65,7 @@ public: Slice line_slice (char const *pos_str0) const; string line_string (char const *pos_str0) const; void get_counts (char const *pos_str0, int *, int *, int *, int *) const; - + SCM get_port () const; string name_; diff --git a/lily/include/sources.hh b/lily/include/sources.hh index b873ac8bc0..d9deec1baa 100644 --- a/lily/include/sources.hh +++ b/lily/include/sources.hh @@ -26,13 +26,13 @@ class Sources { Sources (Sources const &); - vector<Source_file*> sourcefiles_; + vector<Source_file *> sourcefiles_; public: Sources (); ~Sources (); - Source_file *get_file (string file_name, string const& currentpath); + Source_file *get_file (string file_name, string const ¤tpath); void add (Source_file *sourcefile); void set_path (File_path *); diff --git a/lily/include/spaceable-grob.hh b/lily/include/spaceable-grob.hh index 5788fecb47..16594c0fd5 100644 --- a/lily/include/spaceable-grob.hh +++ b/lily/include/spaceable-grob.hh @@ -31,7 +31,7 @@ struct Spaceable_grob static void add_spring (Grob *me, Grob *to, Spring sp); static Spring get_spring (Grob *me, Grob *other); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); static SCM get_minimum_distances (Grob *); static SCM get_ideal_distances (Grob *); }; diff --git a/lily/include/spacing-interface.hh b/lily/include/spacing-interface.hh index 5b23672c30..b567f2dd1c 100644 --- a/lily/include/spacing-interface.hh +++ b/lily/include/spacing-interface.hh @@ -25,14 +25,14 @@ struct Spacing_interface { static Real minimum_distance (Grob *me, Grob *right_col); - static vector<Item*> right_note_columns (Grob *me); - static vector<Item*> left_note_columns (Grob *me); - static Item* right_column (Grob *me); - static Item* left_column (Grob *me); + static vector<Item *> right_note_columns (Grob *me); + static vector<Item *> left_note_columns (Grob *me); + static Item *right_column (Grob *me); + static Item *left_column (Grob *me); static Drul_array<Skyline> skylines (Grob *me, Grob *right_col); - static Grob* extremal_break_aligned_grob (Grob *me, Direction, Direction, Interval*); + static Grob *extremal_break_aligned_grob (Grob *me, Direction, Direction, Interval *); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); }; #endif /* SPACING_INTERFACE_HH */ diff --git a/lily/include/spacing-options.hh b/lily/include/spacing-options.hh index c96f1d0cfb..0e465c8cff 100644 --- a/lily/include/spacing-options.hh +++ b/lily/include/spacing-options.hh @@ -38,8 +38,8 @@ struct Spacing_options Rational global_shortest_; Real increment_; Real shortest_duration_space_; - - Spacing_options(); + + Spacing_options (); void init_from_grob (Grob *me); Real get_duration_space (Rational d) const; }; diff --git a/lily/include/spacing-spanner.hh b/lily/include/spacing-spanner.hh index d469c3f463..c7316fecb2 100644 --- a/lily/include/spacing-spanner.hh +++ b/lily/include/spacing-spanner.hh @@ -31,26 +31,26 @@ class Spacing_spanner private: static void set_distances_for_loose_col (Grob *me, Grob *c, Drul_array<Item *> next_door, Spacing_options const *); static void generate_pair_spacing (Grob *me, - Paper_column *l, Paper_column *r, - Paper_column *nextr, - Spacing_options const *options); + Paper_column *l, Paper_column *r, + Paper_column *nextr, + Spacing_options const *options); static Real default_bar_spacing (Grob *, Grob *, Grob *, Moment); - static Rational effective_shortest_duration (Grob *me, vector<Grob*> const &all); + static Rational effective_shortest_duration (Grob *me, vector<Grob *> const &all); static void breakable_column_spacing (Grob *, Item *l, Item *r, Spacing_options const *); - static void prune_loose_columns (Grob *, vector<Grob*> *cols, Spacing_options *); - static void set_explicit_neighbor_columns (vector<Grob*> const &cols); - static void set_implicit_neighbor_columns (vector<Grob*> const &cols); - static void generate_springs (Grob *me, vector<Grob*> const &cols, Spacing_options const *); + static void prune_loose_columns (Grob *, vector<Grob *> *cols, Spacing_options *); + static void set_explicit_neighbor_columns (vector<Grob *> const &cols); + static void set_implicit_neighbor_columns (vector<Grob *> const &cols); + static void generate_springs (Grob *me, vector<Grob *> const &cols, Spacing_options const *); static void musical_column_spacing (Grob *, Item *, Item *, Spacing_options const *); static bool fills_measure (Grob *, Item *, Item *); public: - static vector<Grob*> get_columns (Grob *me); + static vector<Grob *> get_columns (Grob *me); static Real note_spacing (Grob *, Grob *, Grob *, Spacing_options const *); static Spring standard_breakable_column_spacing (Grob *me, Item *l, Item *r, Spacing_options const *); - + DECLARE_SCHEME_CALLBACK (set_springs, (SCM)); DECLARE_SCHEME_CALLBACK (calc_common_shortest_duration, (SCM)); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); }; #endif /* SPACING_SPANNER_HH */ diff --git a/lily/include/span-bar.hh b/lily/include/span-bar.hh index 7ebedb4d46..1f017321c5 100644 --- a/lily/include/span-bar.hh +++ b/lily/include/span-bar.hh @@ -32,7 +32,7 @@ class Span_bar { public: - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); static Interval get_spanned_interval (Grob *); static void add_bar (Grob *, Grob *); static void evaluate_glyph (Grob *); diff --git a/lily/include/spanner.hh b/lily/include/spanner.hh index 7bda060c86..b67dde0843 100644 --- a/lily/include/spanner.hh +++ b/lily/include/spanner.hh @@ -44,7 +44,7 @@ class Spanner : public Grob Drul_array<Item *> spanned_drul_; vsize break_index_; - DECLARE_CLASSNAME(Spanner); + DECLARE_CLASSNAME (Spanner); public: DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM)); @@ -52,11 +52,11 @@ public: DECLARE_SCHEME_CALLBACK (bounds_width, (SCM)); DECLARE_SCHEME_CALLBACK (kill_zero_spanned_time, (SCM)); - vector<Spanner*> broken_intos_; + vector<Spanner *> broken_intos_; vsize get_break_index () const; Spanner *broken_neighbor (Direction d) const; - + // todo: move to somewhere else. Real get_broken_left_end_align () const; void substitute_one_mutable_property (SCM sym, SCM val); @@ -76,7 +76,7 @@ public: static bool less (Spanner *const &, Spanner *const &); virtual Grob *find_broken_piece (System *) const; virtual void derived_mark () const; - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); virtual System *get_system () const; SCM get_cached_pure_property (SCM sym, int start, int end); diff --git a/lily/include/spring.hh b/lily/include/spring.hh index 7172809499..2afb0a5152 100644 --- a/lily/include/spring.hh +++ b/lily/include/spring.hh @@ -45,7 +45,7 @@ public: Real inverse_stretch_strength () const {return inverse_stretch_strength_;} Real inverse_compress_strength () const {return inverse_compress_strength_;} Real blocking_force () const {return blocking_force_;} - + Real length (Real f) const; void set_distance (Real); @@ -58,8 +58,8 @@ public: void set_default_compress_strength (); void set_default_stretch_strength (); - void operator*= (Real); - bool operator> (Spring const&) const; + void operator *= (Real); + bool operator > (Spring const &) const; }; DECLARE_UNSMOB (Spring, spring); diff --git a/lily/include/staff-spacing.hh b/lily/include/staff-spacing.hh index fb572dc157..935bcf5b83 100644 --- a/lily/include/staff-spacing.hh +++ b/lily/include/staff-spacing.hh @@ -30,7 +30,7 @@ class Staff_spacing static Real next_notes_correction (Grob *, Grob *); public: - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); static Spring get_spacing (Grob *, Grob *right_col); static Interval bar_y_positions (Grob *); }; diff --git a/lily/include/staff-symbol-referencer.hh b/lily/include/staff-symbol-referencer.hh index ed6156c62c..249fd8ed6c 100644 --- a/lily/include/staff-symbol-referencer.hh +++ b/lily/include/staff-symbol-referencer.hh @@ -30,7 +30,7 @@ class Staff_symbol_referencer { public: - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); static bool ugly_hack (Grob *); static void set_position (Grob *, Real); DECLARE_SCHEME_CALLBACK (callback, (SCM element)); @@ -48,7 +48,7 @@ public: static Real get_position (Grob *); static Real staff_radius (Grob *); static int get_rounded_position (Grob *); - static Interval extent_in_staff (Grob *); + static Interval extent_in_staff (Grob *); }; int compare_position (Grob *const &, Grob *const &); diff --git a/lily/include/staff-symbol.hh b/lily/include/staff-symbol.hh index 1c091c6388..9aee969f49 100644 --- a/lily/include/staff-symbol.hh +++ b/lily/include/staff-symbol.hh @@ -32,13 +32,13 @@ public: static Real staff_space (Grob *); static Real get_line_thickness (Grob *); static Real get_ledger_line_thickness (Grob *); - + static int get_steps (Grob *); static int line_count (Grob *); static bool on_line (Grob *me, int pos); static Interval line_span (Grob *); DECLARE_SCHEME_CALLBACK (print, (SCM)); - DECLARE_SCHEME_CALLBACK (height, (SCM)); - DECLARE_GROB_INTERFACE(); + DECLARE_SCHEME_CALLBACK (height, (SCM)); + DECLARE_GROB_INTERFACE (); }; #endif // STAFF_SYMBOL_HH diff --git a/lily/include/stem-tremolo.hh b/lily/include/stem-tremolo.hh index adc2c0c0b4..a7e026a570 100644 --- a/lily/include/stem-tremolo.hh +++ b/lily/include/stem-tremolo.hh @@ -27,7 +27,7 @@ class Stem_tremolo { public: - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); DECLARE_SCHEME_CALLBACK (calc_slope, (SCM)); DECLARE_SCHEME_CALLBACK (calc_width, (SCM)); DECLARE_SCHEME_CALLBACK (print, (SCM)); @@ -35,8 +35,8 @@ public: DECLARE_SCHEME_CALLBACK (calc_style, (SCM)); DECLARE_SCHEME_CALLBACK (pure_height, (SCM, SCM, SCM)); static Stencil raw_stencil (Grob *, Real slope, Direction stemdir); - static Stencil translated_stencil (Grob*, Real slope); - static Stencil untranslated_stencil (Grob*, Real slope); + static Stencil translated_stencil (Grob *, Real slope); + static Stencil untranslated_stencil (Grob *, Real slope); static Real get_beam_translation (Grob *me); static Real vertical_length (Grob *me); }; diff --git a/lily/include/stem.hh b/lily/include/stem.hh index 3388e34b59..b18b39e53a 100644 --- a/lily/include/stem.hh +++ b/lily/include/stem.hh @@ -42,7 +42,7 @@ public: static Real chord_start_y (Grob *); static void set_stemend (Grob *, Real); static Slice beam_multiplicity (Grob *); - static Direction get_default_dir (Grob*); + static Direction get_default_dir (Grob *); static Real thickness (Grob *); static int head_count (Grob *); static bool is_invisible (Grob *); @@ -51,10 +51,10 @@ public: static Interval head_positions (Grob *); static Real stem_end_position (Grob *); static Stencil flag (Grob *); - static Stencil get_translated_flag (Grob*); - DECLARE_GROB_INTERFACE(); + static Stencil get_translated_flag (Grob *); + DECLARE_GROB_INTERFACE (); static void set_spacing_hints (Grob *); - + DECLARE_SCHEME_CALLBACK (print, (SCM)); DECLARE_SCHEME_CALLBACK (calc_default_direction, (SCM)); DECLARE_SCHEME_CALLBACK (offset_callback, (SCM element)); diff --git a/lily/include/stencil.hh b/lily/include/stencil.hh index 2e38cdfdfc..09a0ef0148 100644 --- a/lily/include/stencil.hh +++ b/lily/include/stencil.hh @@ -19,7 +19,7 @@ #ifndef STENCIL_HH #define STENCIL_HH -#include <cstdlib> // size_t +#include <cstdlib> // size_t using namespace std; #include "lily-proto.hh" @@ -90,14 +90,13 @@ public: DECLARE_UNSMOB (Stencil, stencil); void interpret_stencil_expression (SCM expr, - void (*func) (void *, SCM), - void *func_arg, - Offset o); + void (*func) (void *, SCM), + void *func_arg, + Offset o); SCM find_expression_fonts (SCM expr); void register_stencil_head (SCM symbol); bool is_stencil_head (SCM symbol); SCM all_stencil_heads (); - #endif /* STENCIL_HH */ diff --git a/lily/include/stream-event.hh b/lily/include/stream-event.hh index 18b162a17c..1a9fdd017d 100644 --- a/lily/include/stream-event.hh +++ b/lily/include/stream-event.hh @@ -30,7 +30,7 @@ public: Stream_event (); VIRTUAL_COPY_CONSTRUCTOR (Stream_event, Stream_event); - Stream_event (SCM event_class, SCM mutable_props=SCM_EOL); + Stream_event (SCM event_class, SCM mutable_props = SCM_EOL); Stream_event (SCM class_name, Input *); Input *origin () const; diff --git a/lily/include/stream.hh b/lily/include/stream.hh index 2547900e9e..06bd345da9 100644 --- a/lily/include/stream.hh +++ b/lily/include/stream.hh @@ -28,7 +28,7 @@ using namespace std; #if __GNUC__ > 2 ostream *open_file_stream (string file_name, - ios_base::openmode mode = ios::out); + ios_base::openmode mode = ios::out); #else ostream *open_file_stream (string file_name, int mode = ios::out); #endif diff --git a/lily/include/system-start-delimiter.hh b/lily/include/system-start-delimiter.hh index 5131eeb469..86ce97e4bd 100644 --- a/lily/include/system-start-delimiter.hh +++ b/lily/include/system-start-delimiter.hh @@ -31,14 +31,14 @@ class System_start_delimiter public: DECLARE_SCHEME_CALLBACK (print, (SCM)); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); static void try_collapse (Grob *); static Stencil staff_bracket (Grob *, Real); static Stencil old_staff_bracket (Grob *, Real); static Stencil staff_brace (Grob *, Real); static Stencil simple_bar (Grob *, Real); static Stencil line_bracket (Grob *, Real); - + }; #endif /* SYSTEM_START_DELIMITER_HH */ diff --git a/lily/include/system.hh b/lily/include/system.hh index 4b56238f36..ee44d2afe6 100644 --- a/lily/include/system.hh +++ b/lily/include/system.hh @@ -34,15 +34,15 @@ class System : public Spanner int rank_; Grob_array *all_elements_; void init_elements (); - friend class Paper_score; // ugh. - Paper_score *pscore_; // ugh. + friend class Paper_score; // ugh. + Paper_score *pscore_; // ugh. bool checked_footnotes_; vector<Grob *> footnote_grobs_; // TODO: make this a grob array public: Paper_score *paper_score () const; Grob *get_vertical_alignment (); - Grob *get_extremal_staff (Direction dir, Interval const&); + Grob *get_extremal_staff (Direction dir, Interval const &); Grob *get_pure_bound (Direction dir, int start, int end); Grob *get_maybe_pure_bound (Direction dir, bool pure, int start, int end); int get_rank () const; @@ -69,10 +69,10 @@ public: int spanner_count () const; void break_into_pieces (vector<Column_x_positions> const &); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); - vector<Item*> broken_col_range (Item const *, Item const *) const; - vector<Grob*> used_columns () const; + vector<Item *> broken_col_range (Item const *, Item const *) const; + vector<Grob *> used_columns () const; Paper_column *column (vsize i) const; void add_column (Paper_column *); diff --git a/lily/include/text-interface.hh b/lily/include/text-interface.hh index e01bd4aeab..19c6e7c243 100644 --- a/lily/include/text-interface.hh +++ b/lily/include/text-interface.hh @@ -24,14 +24,13 @@ #include "stencil.hh" #include "grob-interface.hh" - class Text_interface { public: DECLARE_SCHEME_CALLBACK (print, (SCM)); DECLARE_SCHEME_CALLBACK (interpret_markup, (SCM, SCM, SCM)); DECLARE_SCHEME_CALLBACK (interpret_string, (SCM, SCM, SCM)); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); static bool is_markup (SCM); static bool is_markup_list (SCM); }; diff --git a/lily/include/tie-column-format.hh b/lily/include/tie-column-format.hh index 0a5ca6cacf..885ce6245e 100644 --- a/lily/include/tie-column-format.hh +++ b/lily/include/tie-column-format.hh @@ -24,26 +24,25 @@ #include "tie-configuration.hh" void set_chord_outline (Skyline *skyline, - vector<Item*> bounds, - Grob *common, - Direction d); + vector<Item *> bounds, + Grob *common, + Direction d); void set_tie_config_directions (Ties_configuration *tie_configs_ptr); void shift_small_ties (Ties_configuration *tie_configs, - Grob *staff_referencer, - Tie_details const &details); + Grob *staff_referencer, + Tie_details const &details); void final_shape_adjustment (Tie_configuration &conf, - Tie_formatting_problem const&, - Grob *staff_referencer); + Tie_formatting_problem const &, + Grob *staff_referencer); void set_chord_outlines (Drul_array<Skyline> *skyline_drul, - vector<Grob*> ties, - Grob *common); + vector<Grob *> ties, + Grob *common); void set_manual_tie_configuration (Ties_configuration *tie_configs, - bool *manual_override, - SCM manual_configs - ); - + bool *manual_override, + SCM manual_configs + ); #endif /* TIE_COLUMN_FORMAT_HH */ diff --git a/lily/include/tie-column.hh b/lily/include/tie-column.hh index 3821f3b80a..3a30de8b7c 100644 --- a/lily/include/tie-column.hh +++ b/lily/include/tie-column.hh @@ -26,7 +26,7 @@ class Tie_column { public: - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); static void add_tie (Grob *me, Grob *); DECLARE_SCHEME_CALLBACK (calc_positioning_done, (SCM)); DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM)); diff --git a/lily/include/tie-configuration.hh b/lily/include/tie-configuration.hh index 715928fd9b..ff8a9a2c9e 100644 --- a/lily/include/tie-configuration.hh +++ b/lily/include/tie-configuration.hh @@ -42,7 +42,7 @@ public: Direction dir_; Real delta_y_; Drul_array<int> column_ranks_; - + /* computed. */ Interval attachment_x_; @@ -51,13 +51,13 @@ public: void center_tie_vertically (Tie_details const &); Bezier get_transformed_bezier (Tie_details const &) const; Bezier get_untransformed_bezier (Tie_details const &) const; - Real height (Tie_details const&) const; + Real height (Tie_details const &) const; int column_span_length () const; - + static int compare (Tie_configuration const &a, - Tie_configuration const &b); + Tie_configuration const &b); static Real distance (Tie_configuration const &a, - Tie_configuration const &b); + Tie_configuration const &b); }; INSTANTIATE_COMPARE (Tie_configuration, Tie_configuration::compare); @@ -76,13 +76,11 @@ public: void add_tie_score (Real amount, int i, string description); Real score () const; void reset_score (); - string card () const; + string card () const; string tie_card (int i) const { return tie_score_cards_[i]; } string complete_tie_card (vsize i) const; - string complete_score_card () const; + string complete_score_card () const; }; #endif /* TIE_CONFIGURATION_HH */ - - diff --git a/lily/include/tie-details.hh b/lily/include/tie-details.hh index e43fc7e13a..cc9e8c9029 100644 --- a/lily/include/tie-details.hh +++ b/lily/include/tie-details.hh @@ -28,7 +28,7 @@ struct Tie_details Real ratio_; Real staff_space_; Real x_gap_; - Real stem_gap_; + Real stem_gap_; Real between_length_limit_; Real wrong_direction_offset_penalty_; Real same_dir_as_stem_penalty_; @@ -54,11 +54,10 @@ struct Tie_details int single_tie_region_size_; int multi_tie_region_size_; Direction neutral_direction_; - + Tie_details (); void from_grob (Grob *); }; #endif /* TIE_DETAILS_HH */ - diff --git a/lily/include/tie-formatting-problem.hh b/lily/include/tie-formatting-problem.hh index 9799839cb3..6378b68242 100644 --- a/lily/include/tie-formatting-problem.hh +++ b/lily/include/tie-formatting-problem.hh @@ -30,12 +30,12 @@ #include <map> #include <set> -typedef map< Tuple<int,4>, Tie_configuration *> Tie_configuration_map; +typedef map< Tuple<int, 4>, Tie_configuration *> Tie_configuration_map; struct Tie_configuration_variation { vector<pair<int, Tie_configuration *> > index_suggestion_pairs_; - void add_suggestion(int index, Tie_configuration* suggestion) + void add_suggestion (int index, Tie_configuration *suggestion) { index_suggestion_pairs_.push_back (make_pair (index, suggestion)); } @@ -51,45 +51,44 @@ class Tie_formatting_problem Column_extent_map stem_extents_; Column_extent_map head_extents_; Position_extent_map head_positions_; - + set<int> dot_positions_; Interval dot_x_; vector<Tie_specification> specifications_; bool use_horizontal_spacing_; - + Tie_configuration_map possibilities_; Grob *x_refpoint_; Grob *y_refpoint_; - Tie_configuration *get_configuration (int position, Direction dir, Drul_array<int> cols, bool tune_y) const; Tie_configuration *generate_configuration (int position, Direction dir, Drul_array<int> cols, bool tune_y) const; vector<Tie_configuration_variation> generate_collision_variations (Ties_configuration const &ties) const; vector<Tie_configuration_variation> generate_extremal_tie_variations (Ties_configuration const &ties) const; vector<Tie_configuration_variation> generate_single_tie_variations (Ties_configuration const &ties) const; - + void score_configuration (Tie_configuration *) const; Real score_aptitude (Tie_configuration *, Tie_specification const &, - Ties_configuration *, int) const; + Ties_configuration *, int) const; void score_ties_aptitude (Ties_configuration *ties) const; void score_ties_configuration (Ties_configuration *ties) const; void set_ties_config_standard_directions (Ties_configuration *tie_configs_ptr); void score_ties (Ties_configuration *) const; - + Slice head_positions_slice (int) const; Ties_configuration generate_base_chord_configuration (); Ties_configuration find_best_variation (Ties_configuration const &base, - vector<Tie_configuration_variation> const &vars); + vector<Tie_configuration_variation> const &vars); public: Tie_details details_; void print_ties_configuration (Ties_configuration const *); - Interval get_stem_extent (int, Direction, Axis) const; - Interval get_head_extent (int, Direction, Axis) const; - + Interval get_stem_extent (int, Direction, Axis) const; + Interval get_head_extent (int, Direction, Axis) const; + public: Tie_formatting_problem (); ~Tie_formatting_problem (); @@ -98,11 +97,11 @@ public: Ties_configuration generate_optimal_configuration (); Ties_configuration generate_ties_configuration (Ties_configuration const &); - void from_ties (vector<Grob*> const &ties); + void from_ties (vector<Grob *> const &ties); void from_tie (Grob *tie); - void from_semi_ties (vector<Grob*> const &, Direction head_dir); - void set_chord_outline (vector<Item*>, Direction); - void set_column_chord_outline (vector<Item*>, Direction, int rank); + void from_semi_ties (vector<Grob *> const &, Direction head_dir); + void set_chord_outline (vector<Item *>, Direction); + void set_column_chord_outline (vector<Item *>, Direction, int rank); void set_manual_tie_configuration (SCM); Interval get_attachment (Real, Drul_array<int>) const; Grob *common_x_refpoint () const; diff --git a/lily/include/tie-specification.hh b/lily/include/tie-specification.hh index a41aa3626b..7434a499e8 100644 --- a/lily/include/tie-specification.hh +++ b/lily/include/tie-specification.hh @@ -26,18 +26,18 @@ struct Tie_specification { int position_; - Drul_array<Grob*> note_head_drul_; + Drul_array<Grob *> note_head_drul_; Drul_array<int> column_ranks_; Grob *tie_grob_; - + bool has_manual_position_; bool has_manual_dir_; bool has_manual_delta_y_; bool has_accidental_; - + Real manual_position_; Direction manual_dir_; - + Tie_specification (); int column_span () const; void from_grob (Grob *); diff --git a/lily/include/tie.hh b/lily/include/tie.hh index 9da006c8ef..60664e1074 100644 --- a/lily/include/tie.hh +++ b/lily/include/tie.hh @@ -24,29 +24,25 @@ #include "skyline.hh" #include "grob-interface.hh" - - - class Tie { public: static void set_head (Grob *, Direction, Grob *head); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); static Grob *head (Grob *, Direction); static int get_column_rank (Grob *, Direction); static int get_position (Grob *); - static Direction get_default_dir (Grob *); + static Direction get_default_dir (Grob *); static SCM get_control_points (Grob *, Grob *, - Tie_configuration const&, - Tie_details const&); + Tie_configuration const &, + Tie_details const &); static SCM get_default_control_points (Grob *); DECLARE_SCHEME_CALLBACK (print, (SCM)); DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM)); DECLARE_SCHEME_CALLBACK (calc_direction, (SCM)); DECLARE_SCHEME_CALLBACK (calc_control_points, (SCM)); static bool less (Grob *const &s1, - Grob *const &s2); + Grob *const &s2); }; - #endif // TIE_HH diff --git a/lily/include/time-scaled-music-iterator.hh b/lily/include/time-scaled-music-iterator.hh index b3a4ce480d..2b3d39f7d4 100644 --- a/lily/include/time-scaled-music-iterator.hh +++ b/lily/include/time-scaled-music-iterator.hh @@ -28,7 +28,7 @@ class Time_scaled_music_iterator : public Sequential_iterator public: DECLARE_SCHEME_CALLBACK (constructor, ()); /* construction */ - DECLARE_CLASSNAME(Time_scaled_music_iterator); + DECLARE_CLASSNAME (Time_scaled_music_iterator); Time_scaled_music_iterator (); protected: virtual SCM get_music_list () const; diff --git a/lily/include/time-signature.hh b/lily/include/time-signature.hh index 95190025bc..72d02c1f85 100644 --- a/lily/include/time-signature.hh +++ b/lily/include/time-signature.hh @@ -32,7 +32,7 @@ */ struct Time_signature { - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); static Stencil special_time_signature (Grob *, SCM, int, int); static Stencil numbered_time_signature (Grob *, int, int); DECLARE_SCHEME_CALLBACK (print, (SCM)); diff --git a/lily/include/translator-dispatch-list.hh b/lily/include/translator-dispatch-list.hh index 1504ebcecc..1e848afabc 100644 --- a/lily/include/translator-dispatch-list.hh +++ b/lily/include/translator-dispatch-list.hh @@ -36,7 +36,7 @@ class Engraver_dispatch_list public: void apply (Grob_info); SCM static create (SCM trans_list, - SCM iface_list, Direction); + SCM iface_list, Direction); DECLARE_SIMPLE_SMOBS (Engraver_dispatch_list); }; diff --git a/lily/include/translator-group.hh b/lily/include/translator-group.hh index 3eaf8a85b7..de0faf80f8 100644 --- a/lily/include/translator-group.hh +++ b/lily/include/translator-group.hh @@ -95,7 +95,7 @@ protected: SCM names_to_translators (SCM namelist, Context *tg); void recurse_over_translators (Context *c, Translator_method ptr, - Translator_group_method ptr2, Direction); + Translator_group_method ptr2, Direction); void precomputed_recurse_over_translators (Context *c, Translator_precompute_index idx, Direction dir); Translator_group *get_translator_group (SCM sym); diff --git a/lily/include/translator.hh b/lily/include/translator.hh index d2723929ee..0b35812015 100644 --- a/lily/include/translator.hh +++ b/lily/include/translator.hh @@ -23,7 +23,7 @@ #include "global-ctor.hh" #include "lily-proto.hh" #include "virtual-methods.hh" -#include "input.hh" // for error reporting +#include "input.hh" // for error reporting #include "smobs.hh" #include "std-vector.hh" #include "protected-scm.hh" @@ -33,85 +33,86 @@ struct Acknowledge_information SCM symbol_; Engraver_void_function_engraver_grob_info function_; - Acknowledge_information () { + Acknowledge_information () + { symbol_ = SCM_EOL; function_ = 0; } }; - /* Each translator class has a static list of listener records. Each record makes one explains how to register one of the class's stream event listeners to a context. */ -typedef struct translator_listener_record { +typedef struct translator_listener_record +{ Listener (*get_listener_) (void *, SCM event_class); SCM event_class_; struct translator_listener_record *next_; - translator_listener_record () { + translator_listener_record () + { next_ = 0; event_class_ = SCM_EOL; get_listener_ = 0; } - -} translator_listener_record; +} translator_listener_record; #define TRANSLATOR_DECLARATIONS_NO_LISTENER(NAME) \ -private: \ - public: \ - NAME (); \ - VIRTUAL_COPY_CONSTRUCTOR (Translator, NAME); \ - static SCM static_description_; \ +private: \ + public: \ + NAME (); \ + VIRTUAL_COPY_CONSTRUCTOR (Translator, NAME); \ + static SCM static_description_; \ static Drul_array<vector<Acknowledge_information> > acknowledge_static_array_drul_; \ virtual void fetch_precomputable_methods (Translator_void_method_ptr methods[]); \ - virtual SCM static_translator_description () const; \ - virtual SCM translator_description () const; \ + virtual SCM static_translator_description () const; \ + virtual SCM translator_description () const; \ static Engraver_void_function_engraver_grob_info static_get_acknowledger (SCM sym); \ static Engraver_void_function_engraver_grob_info static_get_end_acknowledger(SCM); \ virtual Engraver_void_function_engraver_grob_info get_acknowledger (SCM sym) \ - { \ - return static_get_acknowledger (sym); \ - } \ + { \ + return static_get_acknowledger (sym); \ + } \ virtual Engraver_void_function_engraver_grob_info get_end_acknowledger (SCM sym) \ - { \ - return static_get_end_acknowledger (sym); \ + { \ + return static_get_end_acknowledger (sym); \ } \ /* end #define */ -#define TRANSLATOR_DECLARATIONS(NAME) \ - TRANSLATOR_DECLARATIONS_NO_LISTENER(NAME) \ -private: \ - static translator_listener_record *listener_list_; \ -public: \ - virtual translator_listener_record *get_listener_list () const \ - { \ - return listener_list_; \ - } \ +#define TRANSLATOR_DECLARATIONS(NAME) \ + TRANSLATOR_DECLARATIONS_NO_LISTENER(NAME) \ +private: \ + static translator_listener_record *listener_list_; \ +public: \ + virtual translator_listener_record *get_listener_list () const \ + { \ + return listener_list_; \ + } \ /* end #define */ -#define DECLARE_TRANSLATOR_LISTENER(m) \ -public: \ -inline void listen_ ## m (Stream_event *); \ -/* Should be private */ \ -static void _internal_declare_ ## m (); \ -private: \ - static Listener _get_ ## m ## _listener (void *, SCM); \ +#define DECLARE_TRANSLATOR_LISTENER(m) \ +public: \ +inline void listen_ ## m (Stream_event *); \ +/* Should be private */ \ +static void _internal_declare_ ## m (); \ +private: \ + static Listener _get_ ## m ## _listener (void *, SCM); \ DECLARE_LISTENER (_listen_scm_ ## m); #define DECLARE_ACKNOWLEDGER(x) public : void acknowledge_ ## x (Grob_info); protected: #define DECLARE_END_ACKNOWLEDGER(x) public : void acknowledge_end_ ## x (Grob_info); protected: enum Translator_precompute_index - { - START_TRANSLATION_TIMESTEP, - STOP_TRANSLATION_TIMESTEP, - PROCESS_MUSIC, - PROCESS_ACKNOWLEDGED, - TRANSLATOR_METHOD_PRECOMPUTE_COUNT, - }; +{ + START_TRANSLATION_TIMESTEP, + STOP_TRANSLATION_TIMESTEP, + PROCESS_MUSIC, + PROCESS_ACKNOWLEDGED, + TRANSLATOR_METHOD_PRECOMPUTE_COUNT, +}; /* Translate music into grobs. @@ -150,19 +151,19 @@ public: TRANSLATOR_DECLARATIONS (Translator); DECLARE_SMOBS (Translator); -protected: // should be private. +protected: // should be private. Context *daddy_context_; void protect_event (SCM ev); virtual void derived_mark () const; static void add_translator_listener (translator_listener_record **listener_list, - translator_listener_record *r, - Listener (*get_listener) (void *, SCM), - const char *ev_class); - SCM static_translator_description (const char *grobs, - const char *desc, - translator_listener_record *listener_list, - const char *read, - const char *write) const; + translator_listener_record *r, + Listener (*get_listener) (void *, SCM), + const char *ev_class); + SCM static_translator_description (const char *grobs, + const char *desc, + translator_listener_record *listener_list, + const char *read, + const char *write) const; friend class Translator_group; }; @@ -174,13 +175,10 @@ Moment get_event_length (Stream_event *s, Moment now); Moment get_event_length (Stream_event *s); DECLARE_UNSMOB (Translator, translator); - /* This helper is only meaningful inside listen_* methods. */ extern bool internal_event_assignment (Stream_event **old_ev, Stream_event *new_ev, const char *function); #define ASSIGN_EVENT_ONCE(o,n) internal_event_assignment (&o, n, __FUNCTION__) - - #endif // TRANSLATOR_HH diff --git a/lily/include/translator.icc b/lily/include/translator.icc index a7bb910608..e384d4c7fb 100644 --- a/lily/include/translator.icc +++ b/lily/include/translator.icc @@ -31,131 +31,131 @@ /** A macro to automate administration of translators. */ -#define ADD_THIS_TRANSLATOR(T) \ - SCM T::static_description_ = SCM_EOL; \ - static void _ ## T ## _adder () \ - { \ - T *t = new T; \ - T::static_description_ = t->static_translator_description (); \ - scm_permanent_object (T::static_description_); \ - add_translator (t); \ - } \ - SCM T::translator_description () const \ - { \ - return static_description_; \ - } \ +#define ADD_THIS_TRANSLATOR(T) \ + SCM T::static_description_ = SCM_EOL; \ + static void _ ## T ## _adder () \ + { \ + T *t = new T; \ + T::static_description_ = t->static_translator_description (); \ + scm_permanent_object (T::static_description_); \ + add_translator (t); \ + } \ + SCM T::translator_description () const \ + { \ + return static_description_; \ + } \ ADD_GLOBAL_CTOR (_ ## T ## _adder); \ /* end define */ #define DEFINE_TRANSLATOR_LISTENER_LIST(T) \ - translator_listener_record *T::listener_list_; \ + translator_listener_record *T::listener_list_; \ /* end define */ #define DEFINE_ACKNOWLEDGERS(classname) \ - Drul_array< vector<Acknowledge_information> > classname::acknowledge_static_array_drul_; \ - Engraver_void_function_engraver_grob_info \ - classname::static_get_acknowledger (SCM sym) \ - { \ - return generic_get_acknowledger (sym, &acknowledge_static_array_drul_[START]); \ - } \ - Engraver_void_function_engraver_grob_info \ - classname::static_get_end_acknowledger (SCM sym) \ - { \ - return generic_get_acknowledger (sym, &acknowledge_static_array_drul_[STOP]); \ - } \ + Drul_array< vector<Acknowledge_information> > classname::acknowledge_static_array_drul_; \ + Engraver_void_function_engraver_grob_info \ + classname::static_get_acknowledger (SCM sym) \ + { \ + return generic_get_acknowledger (sym, &acknowledge_static_array_drul_[START]); \ + } \ + Engraver_void_function_engraver_grob_info \ + classname::static_get_end_acknowledger (SCM sym) \ + { \ + return generic_get_acknowledger (sym, &acknowledge_static_array_drul_[STOP]); \ + } \ /* end define */ -#define DEFINE_TRANSLATOR_DOC(classname, desc, grobs, read, write) \ - SCM \ - classname::static_translator_description () const \ - { \ +#define DEFINE_TRANSLATOR_DOC(classname, desc, grobs, read, write) \ + SCM \ + classname::static_translator_description () const \ + { \ return Translator::static_translator_description (grobs, desc, listener_list_, read, write); \ } -#define ADD_TRANSLATOR(classname, desc, grobs, read, write) \ - IMPLEMENT_FETCH_PRECOMPUTABLE_METHODS (classname); \ - ADD_THIS_TRANSLATOR (classname); \ - DEFINE_TRANSLATOR_DOC(classname, desc, grobs, read, write) \ +#define ADD_TRANSLATOR(classname, desc, grobs, read, write) \ + IMPLEMENT_FETCH_PRECOMPUTABLE_METHODS (classname); \ + ADD_THIS_TRANSLATOR (classname); \ + DEFINE_TRANSLATOR_DOC(classname, desc, grobs, read, write) \ DEFINE_ACKNOWLEDGERS(classname) \ DEFINE_TRANSLATOR_LISTENER_LIST(classname) \ - -#define IMPLEMENT_FETCH_PRECOMPUTABLE_METHODS(T) \ - void \ - T::fetch_precomputable_methods (Translator_void_method_ptr ptrs[]) \ - { \ - ptrs[START_TRANSLATION_TIMESTEP] = \ - ((Translator_void_method_ptr) & T::start_translation_timestep == \ + +#define IMPLEMENT_FETCH_PRECOMPUTABLE_METHODS(T) \ + void \ + T::fetch_precomputable_methods (Translator_void_method_ptr ptrs[]) \ + { \ + ptrs[START_TRANSLATION_TIMESTEP] = \ + ((Translator_void_method_ptr) & T::start_translation_timestep == \ (Translator_void_method_ptr) & Translator::start_translation_timestep) \ - ? 0 \ - : (Translator_void_method_ptr) & T::start_translation_timestep; \ - \ - ptrs[STOP_TRANSLATION_TIMESTEP] = \ + ? 0 \ + : (Translator_void_method_ptr) & T::start_translation_timestep; \ + \ + ptrs[STOP_TRANSLATION_TIMESTEP] = \ ((Translator_void_method_ptr) & T::stop_translation_timestep == (Translator_void_method_ptr) & Translator::stop_translation_timestep) \ - ? 0 \ - : (Translator_void_method_ptr) & T::stop_translation_timestep; \ - \ - ptrs[PROCESS_MUSIC] = \ + ? 0 \ + : (Translator_void_method_ptr) & T::stop_translation_timestep; \ + \ + ptrs[PROCESS_MUSIC] = \ ((Translator_void_method_ptr) & T::process_music == (Translator_void_method_ptr) & Translator::process_music) \ - ? 0 \ - : (Translator_void_method_ptr) & T::process_music; \ - \ - ptrs[PROCESS_ACKNOWLEDGED] = \ + ? 0 \ + : (Translator_void_method_ptr) & T::process_music; \ + \ + ptrs[PROCESS_ACKNOWLEDGED] = \ ((Translator_void_method_ptr) & T::process_acknowledged == (Translator_void_method_ptr) & Translator::process_acknowledged) \ - ? 0 \ - : (Translator_void_method_ptr) & T::process_acknowledged; \ + ? 0 \ + : (Translator_void_method_ptr) & T::process_acknowledged; \ } void add_acknowledger (Engraver_void_function_engraver_grob_info ptr, - char const *func_name, - vector<Acknowledge_information> *ack_array); + char const *func_name, + vector<Acknowledge_information> *ack_array); Engraver_void_function_engraver_grob_info generic_get_acknowledger (SCM sym, - vector<Acknowledge_information> const *ack_array); + vector<Acknowledge_information> const *ack_array); -#define ADD_ACKNOWLEDGER(CLASS, NAME) \ - void CLASS ## NAME ## _ack_adder () \ - { \ +#define ADD_ACKNOWLEDGER(CLASS, NAME) \ + void CLASS ## NAME ## _ack_adder () \ + { \ add_acknowledger ((Engraver_void_function_engraver_grob_info) & CLASS::acknowledge_ ## NAME, #NAME, &CLASS::acknowledge_static_array_drul_[START]); \ - } \ + } \ ADD_SCM_INIT_FUNC (CLASS ## NAME ## _ack_adder_initclass, CLASS ## NAME ## _ack_adder); -#define ADD_END_ACKNOWLEDGER(CLASS, NAME) \ - void CLASS ## NAME ## _end_ack_adder () \ - { \ +#define ADD_END_ACKNOWLEDGER(CLASS, NAME) \ + void CLASS ## NAME ## _end_ack_adder () \ + { \ add_acknowledger ((Engraver_void_function_engraver_grob_info) & CLASS::acknowledge_end_ ## NAME, #NAME, &CLASS::acknowledge_static_array_drul_[STOP]); \ - } \ + } \ ADD_SCM_INIT_FUNC (CLASS ## NAME ## _end_ack_adder_initclass, CLASS ## NAME ## _end_ack_adder); /* - Implement the method cl::listen_##m, and make it listen to stream + Implement the method cl::listen_##m, and make it listen to stream events of class m. */ -#define IMPLEMENT_TRANSLATOR_LISTENER(cl, m) \ -void \ -cl :: _internal_declare_ ## m () \ -{ \ - static translator_listener_record r; \ +#define IMPLEMENT_TRANSLATOR_LISTENER(cl, m) \ +void \ +cl :: _internal_declare_ ## m () \ +{ \ + static translator_listener_record r; \ add_translator_listener (&listener_list_, &r, _get_ ## m ## _listener, #m); \ -} \ - \ -ADD_SCM_INIT_FUNC (cl ## _declare_event_ ## m, cl::_internal_declare_ ## m); \ - \ -Listener \ +} \ + \ +ADD_SCM_INIT_FUNC (cl ## _declare_event_ ## m, cl::_internal_declare_ ## m); \ + \ +Listener \ cl :: _get_ ## m ## _listener (void *me, SCM unused) \ -{ \ - cl *obj = (cl *) me; \ +{ \ + cl *obj = (cl *) me; \ (void) unused; \ - return obj->GET_LISTENER (_listen_scm_ ## m); \ -} \ - \ -IMPLEMENT_LISTENER (cl, _listen_scm_ ## m) \ -void \ -cl::_listen_scm_ ## m (SCM sev) \ -{ \ - Stream_event *ev = unsmob_stream_event (sev); \ - protect_event (sev); \ - listen_ ## m (ev); \ + return obj->GET_LISTENER (_listen_scm_ ## m); \ +} \ + \ +IMPLEMENT_LISTENER (cl, _listen_scm_ ## m) \ +void \ +cl::_listen_scm_ ## m (SCM sev) \ +{ \ + Stream_event *ev = unsmob_stream_event (sev); \ + protect_event (sev); \ + listen_ ## m (ev); \ } #endif /* TRANSLATOR_ICC */ diff --git a/lily/include/tuplet-bracket.hh b/lily/include/tuplet-bracket.hh index 17285a0917..ceeb7f3440 100644 --- a/lily/include/tuplet-bracket.hh +++ b/lily/include/tuplet-bracket.hh @@ -33,20 +33,20 @@ public: DECLARE_SCHEME_CALLBACK (print, (SCM)); DECLARE_SCHEME_CALLBACK (calc_connect_to_neighbors, (SCM smob)); DECLARE_SCHEME_CALLBACK (calc_cross_staff, (SCM)); - - DECLARE_GROB_INTERFACE(); - static Grob* get_common_x (Spanner *); + + DECLARE_GROB_INTERFACE (); + static Grob *get_common_x (Spanner *); static void add_tuplet_bracket (Grob *me, Grob *smaller_bracket); static void get_bounds (Grob *, Grob **, Grob **); static void add_column (Grob *me, Item *); static void add_beam (Grob *me, Grob *); - static Grob *parallel_beam (Grob *me, vector<Grob*> const &cols, - bool *equally_long); + static Grob *parallel_beam (Grob *me, vector<Grob *> const &cols, + bool *equally_long); static void calc_position_and_height (Grob *, Real *, Real *dy); static Stencil make_bracket (Grob *me, Axis protrusion_axis, - Offset dz, Drul_array<Real> height, - Interval gap, Drul_array<Real> widen, - Drul_array<Real> shorten); + Offset dz, Drul_array<Real> height, + Interval gap, Drul_array<Real> widen, + Drul_array<Real> shorten); static Direction get_default_dir (Grob *); }; diff --git a/lily/include/vaticana-ligature.hh b/lily/include/vaticana-ligature.hh index 7379510aa8..471119777f 100644 --- a/lily/include/vaticana-ligature.hh +++ b/lily/include/vaticana-ligature.hh @@ -27,7 +27,7 @@ struct Vaticana_ligature { DECLARE_SCHEME_CALLBACK (brew_ligature_primitive, (SCM)); DECLARE_SCHEME_CALLBACK (print, (SCM)); - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); }; /* diff --git a/lily/include/volta-bracket.hh b/lily/include/volta-bracket.hh index 12821ffa0b..539d42f028 100644 --- a/lily/include/volta-bracket.hh +++ b/lily/include/volta-bracket.hh @@ -26,7 +26,7 @@ class Volta_bracket_interface { public: - DECLARE_GROB_INTERFACE(); + DECLARE_GROB_INTERFACE (); DECLARE_SCHEME_CALLBACK (print, (SCM)); static void modify_edge_height (Spanner *); static void add_bar (Grob *me, Item *bar); diff --git a/lily/input-scheme.cc b/lily/input-scheme.cc index 379c2fa9bd..1325c8e151 100644 --- a/lily/input-scheme.cc +++ b/lily/input-scheme.cc @@ -23,21 +23,21 @@ /* We don't use IMPLEMENT_TYPE_P, since the smobification part is implemented separately from the class. */ LY_DEFINE (ly_input_location_p, "ly:input-location?", 1, 0, 0, - (SCM x), - "Is @var{x} an @code{input-location}?") + (SCM x), + "Is @var{x} an @code{input-location}?") { return unsmob_input (x) ? SCM_BOOL_T : SCM_BOOL_F; } LY_DEFINE (ly_input_message, "ly:input-message", 2, 0, 1, (SCM sip, SCM msg, SCM rest), - "Print @var{msg} as a GNU compliant error message, pointing" - " to the location in @var{sip}. @var{msg} is interpreted" - " similar to @code{format}'s argument, using @var{rest}.") + "Print @var{msg} as a GNU compliant error message, pointing" + " to the location in @var{sip}. @var{msg} is interpreted" + " similar to @code{format}'s argument, using @var{rest}.") { Input *ip = unsmob_input (sip); LY_ASSERT_TYPE (unsmob_input, sip, 1); - LY_ASSERT_TYPE (scm_is_string, msg,2); + LY_ASSERT_TYPE (scm_is_string, msg, 2); msg = scm_simple_format (SCM_BOOL_F, msg, rest); @@ -47,12 +47,11 @@ LY_DEFINE (ly_input_message, "ly:input-message", 2, 0, 1, (SCM sip, SCM msg, SCM return SCM_UNSPECIFIED; } - LY_DEFINE (ly_input_file_line_char_column, - "ly:input-file-line-char-column", - 1, 0, 0, (SCM sip), - "Return input location in @var{sip} as" - " @code{(file-name line char column)}.") + "ly:input-file-line-char-column", + 1, 0, 0, (SCM sip), + "Return input location in @var{sip} as" + " @code{(file-name line char column)}.") { LY_ASSERT_TYPE (unsmob_input, sip, 1); Input *ip = unsmob_input (sip); @@ -60,24 +59,24 @@ LY_DEFINE (ly_input_file_line_char_column, int l, ch, col, offset = 0; ip->get_counts (&l, &ch, &col, &offset); return scm_list_4 (ly_string2scm (ip->file_string ()), - scm_from_int (l), - scm_from_int (ch), - scm_from_int (col)); + scm_from_int (l), + scm_from_int (ch), + scm_from_int (col)); } LY_DEFINE (ly_input_both_locations, - "ly:input-both-locations", - 1, 0, 0, (SCM sip), - "Return input location in @var{sip} as" - " @code{(file-name first-line first-column last-line last-column)}.") + "ly:input-both-locations", + 1, 0, 0, (SCM sip), + "Return input location in @var{sip} as" + " @code{(file-name first-line first-column last-line last-column)}.") { - + LY_ASSERT_TYPE (unsmob_input, sip, 1); Input *ip = unsmob_input (sip); - + return scm_list_5 (ly_string2scm (ip->file_string ()), - scm_from_int (ip->line_number ()), - scm_from_int (ip->column_number ()), - scm_from_int (ip->end_line_number ()), - scm_from_int (ip->end_column_number ())); + scm_from_int (ip->line_number ()), + scm_from_int (ip->column_number ()), + scm_from_int (ip->end_line_number ()), + scm_from_int (ip->end_column_number ())); } diff --git a/lily/input-smob.cc b/lily/input-smob.cc index 716c41d713..77a03fd54e 100644 --- a/lily/input-smob.cc +++ b/lily/input-smob.cc @@ -59,9 +59,9 @@ equal_smob (SCM sa, SCM sb) { Input *a = (Input *) SCM_CELL_WORD_1 (sa); Input *b = (Input *) SCM_CELL_WORD_1 (sb); - if (a->get_source_file () == b->get_source_file () && - a->start () == b->start () && - a->end () == b->end ()) + if (a->get_source_file () == b->get_source_file () + && a->start () == b->start () + && a->end () == b->end ()) return SCM_BOOL_T; else return SCM_BOOL_F; diff --git a/lily/input.cc b/lily/input.cc index cbb609941f..6cc8a182a5 100644 --- a/lily/input.cc +++ b/lily/input.cc @@ -83,23 +83,22 @@ Input::message (string s) const { if (source_file_) s = location_string () + ": " + s + "\n" - + source_file_->quote_input (start_) + "\n"; + + source_file_->quote_input (start_) + "\n"; ::message (s); } - void Input::programming_error (string s) const { if (get_program_option ("warning-as-error")) ::error (s); - else { - message (_f ("programming error: %s", s.c_str ())); - message (_ ("continuing, cross fingers") + "\n"); - } + else + { + message (_f ("programming error: %s", s.c_str ())); + message (_ ("continuing, cross fingers") + "\n"); + } } - void Input::warning (string s) const { diff --git a/lily/instrument-name-engraver.cc b/lily/instrument-name-engraver.cc index 56fa84ee26..e3214069b3 100644 --- a/lily/instrument-name-engraver.cc +++ b/lily/instrument-name-engraver.cc @@ -39,7 +39,7 @@ protected: SCM short_text_; vector<Grob *> axis_groups_; - + virtual void finalize (); DECLARE_ACKNOWLEDGER (axis_group); void process_music (); @@ -78,7 +78,7 @@ Instrument_name_engraver::consider_start_spanner () SCM short_text = get_property ("shortInstrumentName"); if (!(Text_interface::is_markup (long_text) - || Text_interface::is_markup (short_text))) + || Text_interface::is_markup (short_text))) { long_text = get_property ("vocalName"); short_text = get_property ("shortVocalName"); @@ -87,11 +87,11 @@ Instrument_name_engraver::consider_start_spanner () if ((Text_interface::is_markup (long_text) || Text_interface::is_markup (short_text)) && (!text_spanner_ - || short_text_ != short_text - || long_text_ != long_text)) + || short_text_ != short_text + || long_text_ != long_text)) { if (text_spanner_) - stop_spanner (); + stop_spanner (); short_text_ = short_text; long_text_ = long_text; @@ -149,36 +149,35 @@ Instrument_name_engraver::stop_spanner () { for (vsize i = 0; i < axis_groups_.size (); i++) Pointer_group_interface::add_grob (text_spanner_, - ly_symbol2scm ("elements"), - axis_groups_[i]); - + ly_symbol2scm ("elements"), + axis_groups_[i]); + text_spanner_->set_bound (RIGHT, - unsmob_grob (get_property ("currentCommandColumn"))); + unsmob_grob (get_property ("currentCommandColumn"))); Pointer_group_interface::set_ordered (text_spanner_, - ly_symbol2scm ("elements"), - false); + ly_symbol2scm ("elements"), + false); text_spanner_ = 0; } - ADD_ACKNOWLEDGER (Instrument_name_engraver, axis_group); ADD_TRANSLATOR (Instrument_name_engraver, - /* doc */ - "Create a system start text for instrument or vocal names.", - - /* create */ - "InstrumentName ", - - /* read */ - "currentCommandColumn " - "instrumentName " - "shortInstrumentName " - "shortVocalName " - "vocalName ", - - /* write */ - "" - ); + /* doc */ + "Create a system start text for instrument or vocal names.", + + /* create */ + "InstrumentName ", + + /* read */ + "currentCommandColumn " + "instrumentName " + "shortInstrumentName " + "shortVocalName " + "vocalName ", + + /* write */ + "" + ); diff --git a/lily/instrument-switch-engraver.cc b/lily/instrument-switch-engraver.cc index 8ae322fae0..852aed0d40 100644 --- a/lily/instrument-switch-engraver.cc +++ b/lily/instrument-switch-engraver.cc @@ -24,7 +24,6 @@ #include "translator.icc" - class Instrument_switch_engraver : public Engraver { @@ -77,15 +76,15 @@ Instrument_switch_engraver::stop_translation_time_step () } ADD_TRANSLATOR (Instrument_switch_engraver, - /* doc */ - "Create a cue text for taking instrument.", - - /* create */ - "InstrumentSwitch ", - - /* read */ - "instrumentCueName ", - - /* write */ - "" - ); + /* doc */ + "Create a cue text for taking instrument.", + + /* create */ + "InstrumentSwitch ", + + /* read */ + "instrumentCueName ", + + /* write */ + "" + ); diff --git a/lily/item-scheme.cc b/lily/item-scheme.cc index 405fe776cd..bd612efdee 100644 --- a/lily/item-scheme.cc +++ b/lily/item-scheme.cc @@ -20,10 +20,9 @@ #include "item.hh" - LY_DEFINE (ly_item_p, "ly:item?", - 1, 0, 0, (SCM g), - "Is @var{g} an @code{Item} object?") + 1, 0, 0, (SCM g), + "Is @var{g} an @code{Item} object?") { Grob *me = unsmob_grob (g); bool b = dynamic_cast<Item *> (me); @@ -31,10 +30,10 @@ LY_DEFINE (ly_item_p, "ly:item?", } LY_DEFINE (ly_item_break_dir, "ly:item-break-dir", - 1, 0, 0, (SCM it), - "The break status direction of item @var{it}. @code{-1} means" - " end of line, @code{0}@tie{}unbroken, and" - " @code{1}@tie{}beginning of line.") + 1, 0, 0, (SCM it), + "The break status direction of item @var{it}. @code{-1} means" + " end of line, @code{0}@tie{}unbroken, and" + " @code{1}@tie{}beginning of line.") { LY_ASSERT_TYPE (unsmob_item, it, 1); Item *me = unsmob_item (it); diff --git a/lily/item.cc b/lily/item.cc index 0a853484e0..4e9818192a 100644 --- a/lily/item.cc +++ b/lily/item.cc @@ -29,7 +29,6 @@ #include "moment.hh" - Grob * Item::clone () const { @@ -124,7 +123,7 @@ Item::find_broken_piece (System *l) const { Grob *s = broken_to_drul_[d]; if (s && s->get_system () == l) - return s; + return s; } while (flip (&d) != LEFT); @@ -169,7 +168,7 @@ Item::handle_prebroken_dependencies () bool Item::break_visible (Grob *g) { - Item *it = dynamic_cast<Item*> (g); + Item *it = dynamic_cast<Item *> (g); SCM vis = g->get_property ("break-visibility"); if (scm_is_vector (vis)) return to_boolean (scm_c_vector_ref (vis, it->break_status_dir () + 1)); @@ -185,9 +184,9 @@ Item::pure_is_visible (int start, int end) const int pos = 1; int pc_rank = Paper_column::get_rank (get_column ()); if (pc_rank == start) - pos = 2; + pos = 2; else if (pc_rank == end) - pos = 0; + pos = 0; return to_boolean (scm_vector_ref (vis, scm_from_int (pos))); } return true; @@ -201,32 +200,30 @@ Item::spanned_rank_interval () const } Interval_t<Moment> -spanned_time_interval (Item *l, Item *r) +spanned_time_interval (Item *l, Item *r) { - Drul_array<Item*> bounds (l, r); + Drul_array<Item *> bounds (l, r); Interval_t<Moment> iv; Direction d = LEFT; do { if (bounds[d] && bounds[d]->get_column ()) - iv[d] = robust_scm2moment (bounds[d]->get_column ()->get_property ("when"), - iv[d]); + iv[d] = robust_scm2moment (bounds[d]->get_column ()->get_property ("when"), + iv[d]); } while (flip (&d) != LEFT); do { if (!bounds[d] || !bounds[d]->get_column ()) - iv[d] = iv[-d]; + iv[d] = iv[-d]; } while (flip (&d) != LEFT); - - + return iv; } - void Item::derived_mark () const { @@ -254,46 +251,46 @@ Item::pure_height (Grob *g, int start, int end) } ADD_INTERFACE (Item, - "Grobs can be distinguished in their role in the horizontal" - " spacing. Many grobs define constraints on the spacing by" - " their sizes, for example, note heads, clefs, stems, and all" - " other symbols with a fixed shape. These grobs form a" - " subtype called @code{Item}.\n" - "\n" - "Some items need special treatment for line breaking. For" - " example, a clef is normally only printed at the start of a" - " line (i.e., after a line break). To model this," - " @q{breakable} items (clef, key signature, bar lines, etc.)" - " are copied twice. Then we have three versions of each" - " breakable item: one version if there is no line break, one" - " version that is printed before the line break (at the end of" - " a system), and one version that is printed after the line" - " break.\n" - "\n" - "Whether these versions are visible and take up space is" - " determined by the outcome of the @code{break-visibility}" - " grob property, which is a function taking a direction" - " (@code{-1}, @code{0} or@tie{}@code{1}) as an argument. It" - " returns a cons of booleans, signifying whether this grob" - " should be transparent and have no extent.\n" - "\n" - "The following variables for @code{break-visibility} are" - " predefined:\n" - "@example\n" - " grob will show: before no after\n" - " break break break\n" - " all-invisible no no no\n" - " begin-of-line-visible no no yes\n" - " end-of-line-visible yes no no\n" - " all-visible yes yes yes\n" - " begin-of-line-invisible yes yes no\n" - " end-of-line-invisible no yes yes\n" - " center-invisible yes no yes\n" - "@end example", - - /* properties */ - "break-visibility " - "extra-spacing-height " - "extra-spacing-width " - "non-musical " - ); + "Grobs can be distinguished in their role in the horizontal" + " spacing. Many grobs define constraints on the spacing by" + " their sizes, for example, note heads, clefs, stems, and all" + " other symbols with a fixed shape. These grobs form a" + " subtype called @code{Item}.\n" + "\n" + "Some items need special treatment for line breaking. For" + " example, a clef is normally only printed at the start of a" + " line (i.e., after a line break). To model this," + " @q{breakable} items (clef, key signature, bar lines, etc.)" + " are copied twice. Then we have three versions of each" + " breakable item: one version if there is no line break, one" + " version that is printed before the line break (at the end of" + " a system), and one version that is printed after the line" + " break.\n" + "\n" + "Whether these versions are visible and take up space is" + " determined by the outcome of the @code{break-visibility}" + " grob property, which is a function taking a direction" + " (@code{-1}, @code{0} or@tie{}@code{1}) as an argument. It" + " returns a cons of booleans, signifying whether this grob" + " should be transparent and have no extent.\n" + "\n" + "The following variables for @code{break-visibility} are" + " predefined:\n" + "@example\n" + " grob will show: before no after\n" + " break break break\n" + " all-invisible no no no\n" + " begin-of-line-visible no no yes\n" + " end-of-line-visible yes no no\n" + " all-visible yes yes yes\n" + " begin-of-line-invisible yes yes no\n" + " end-of-line-invisible no yes yes\n" + " center-invisible yes no yes\n" + "@end example", + + /* properties */ + "break-visibility " + "extra-spacing-height " + "extra-spacing-width " + "non-musical " + ); diff --git a/lily/keep-alive-together-engraver.cc b/lily/keep-alive-together-engraver.cc index 8cda5a0d5f..2bc4754811 100644 --- a/lily/keep-alive-together-engraver.cc +++ b/lily/keep-alive-together-engraver.cc @@ -27,7 +27,7 @@ class Keep_alive_together_engraver: public Engraver { - vector<Grob*> group_spanners_; + vector<Grob *> group_spanners_; public: TRANSLATOR_DECLARATIONS (Keep_alive_together_engraver); @@ -65,21 +65,21 @@ Keep_alive_together_engraver::finalize () ADD_ACKNOWLEDGER (Keep_alive_together_engraver, hara_kiri_group_spanner); ADD_TRANSLATOR (Keep_alive_together_engraver, - /* doc */ - "This engraver collects all @code{Hara_kiri_group_spanner}s " - "that are created in contexts at or below its own. " - "These spanners are then tied together so that one will " - "be removed only if all are removed. For example, " - "if a @code{StaffGroup} uses this engraver, then the staves " - "in the group will all be visible as long as there is a note " - "in at least one of them.", - - /* create */ - "", - - /* read */ - "", - - /* write */ - "" - ); + /* doc */ + "This engraver collects all @code{Hara_kiri_group_spanner}s " + "that are created in contexts at or below its own. " + "These spanners are then tied together so that one will " + "be removed only if all are removed. For example, " + "if a @code{StaffGroup} uses this engraver, then the staves " + "in the group will all be visible as long as there is a note " + "in at least one of them.", + + /* create */ + "", + + /* read */ + "", + + /* write */ + "" + ); diff --git a/lily/key-engraver.cc b/lily/key-engraver.cc index 2264e27876..4dec628213 100644 --- a/lily/key-engraver.cc +++ b/lily/key-engraver.cc @@ -63,55 +63,54 @@ Key_engraver::Key_engraver () cancellation_ = 0; } - void Key_engraver::create_key (bool is_default) { if (!item_) { item_ = make_item ("KeySignature", - key_event_ ? key_event_->self_scm () : SCM_EOL); + key_event_ ? key_event_->self_scm () : SCM_EOL); /* Use middleCClefPosition rather than middleCPosition, because cue - * notes with a different clef will modify middleCPosition. The + * notes with a different clef will modify middleCPosition. The * Key signature, however, should still be printed at the original * position. */ item_->set_property ("c0-position", - get_property ("middleCClefPosition")); + get_property ("middleCClefPosition")); SCM last = get_property ("lastKeySignature"); SCM key = get_property ("keySignature"); if ((to_boolean (get_property ("printKeyCancellation")) - || key == SCM_EOL) - && !scm_is_eq (last, key)) - { - SCM restore = SCM_EOL; - SCM *tail = &restore; - for (SCM s = last; scm_is_pair (s); s = scm_cdr (s)) - { - SCM new_alter_pair = scm_assoc (scm_caar (s), key); - Rational old_alter = robust_scm2rational (scm_cdar (s), 0); - if (new_alter_pair == SCM_BOOL_F - || ((ly_scm2rational (scm_cdr (new_alter_pair)) - old_alter) * old_alter - < Rational (0))) - { - *tail = scm_cons (scm_car (s), *tail); - tail = SCM_CDRLOC (*tail); - } - } - - if (scm_is_pair (restore)) - { - cancellation_ = make_item ("KeyCancellation", - key_event_ - ? key_event_->self_scm () : SCM_EOL); - - cancellation_->set_property ("alteration-alist", scm_reverse (restore)); - cancellation_->set_property ("c0-position", - get_property ("middleCPosition")); - } - } + || key == SCM_EOL) + && !scm_is_eq (last, key)) + { + SCM restore = SCM_EOL; + SCM *tail = &restore; + for (SCM s = last; scm_is_pair (s); s = scm_cdr (s)) + { + SCM new_alter_pair = scm_assoc (scm_caar (s), key); + Rational old_alter = robust_scm2rational (scm_cdar (s), 0); + if (new_alter_pair == SCM_BOOL_F + || ((ly_scm2rational (scm_cdr (new_alter_pair)) - old_alter) * old_alter + < Rational (0))) + { + *tail = scm_cons (scm_car (s), *tail); + tail = SCM_CDRLOC (*tail); + } + } + + if (scm_is_pair (restore)) + { + cancellation_ = make_item ("KeyCancellation", + key_event_ + ? key_event_->self_scm () : SCM_EOL); + + cancellation_->set_property ("alteration-alist", scm_reverse (restore)); + cancellation_->set_property ("c0-position", + get_property ("middleCPosition")); + } + } item_->set_property ("alteration-alist", scm_reverse (key)); } @@ -179,31 +178,31 @@ Key_engraver::read_event (Stream_event const *r) scm_is_pair (s) && scm_is_pair (alist); s = scm_cdr (s)) { SCM head = scm_member (scm_car (s), alist); - + if (scm_is_pair (head)) - { - accs = scm_cons (scm_car (head), accs); - alist = scm_delete_x (scm_car (head), alist); - } + { + accs = scm_cons (scm_car (head), accs); + alist = scm_delete_x (scm_car (head), alist); + } } if (scm_is_pair (alist)) { bool warn = false; for (SCM s = alist; scm_is_pair (s); s = scm_cdr (s)) - if (ly_scm2rational (scm_cdar (s))) - { - warn = true; - accs = scm_cons (scm_car (s), accs); - } + if (ly_scm2rational (scm_cdar (s))) + { + warn = true; + accs = scm_cons (scm_car (s), accs); + } if (warn) - r->origin ()->warning ("Incomplete keyAlterationOrder for key signature"); + r->origin ()->warning ("Incomplete keyAlterationOrder for key signature"); } - + context ()->set_property ("keySignature", scm_reverse (accs)); context ()->set_property ("tonic", - r->get_property ("tonic")); + r->get_property ("tonic")); } void @@ -220,25 +219,25 @@ ADD_ACKNOWLEDGER (Key_engraver, clef); ADD_ACKNOWLEDGER (Key_engraver, bar_line); ADD_TRANSLATOR (Key_engraver, - /* doc */ - "Engrave a key signature.", - - /* create */ - "KeyCancellation " - "KeySignature ", - - /* read */ - "createKeyOnClefChange " - "explicitKeySignatureVisibility " - "extraNatural " - "keyAlterationOrder " - "keySignature " - "lastKeySignature " - "printKeyCancellation " - "middleCClefPosition ", - - /* write */ - "keySignature " - "lastKeySignature " - "tonic " - ); + /* doc */ + "Engrave a key signature.", + + /* create */ + "KeyCancellation " + "KeySignature ", + + /* read */ + "createKeyOnClefChange " + "explicitKeySignatureVisibility " + "extraNatural " + "keyAlterationOrder " + "keySignature " + "lastKeySignature " + "printKeyCancellation " + "middleCClefPosition ", + + /* write */ + "keySignature " + "lastKeySignature " + "tonic " + ); diff --git a/lily/key-performer.cc b/lily/key-performer.cc index 93d932b8d5..dc247440fb 100644 --- a/lily/key-performer.cc +++ b/lily/key-performer.cc @@ -62,26 +62,26 @@ Key_performer::process_music () SCM acc = scm_call_1 (proc, pitchlist); Pitch key_do (0, - scm_to_int (scm_caar (pitchlist)), - ly_scm2rational (scm_cdar (pitchlist))); + scm_to_int (scm_caar (pitchlist)), + ly_scm2rational (scm_cdar (pitchlist))); Pitch c_do (0, 0, 0); SCM c_pitchlist - = ly_transpose_key_alist (pitchlist, - pitch_interval (key_do, c_do).smobbed_copy ()); + = ly_transpose_key_alist (pitchlist, + pitch_interval (key_do, c_do).smobbed_copy ()); /* MIDI keys are too limited for lilypond scales. - We check for minor scale and assume major otherwise. */ + We check for minor scale and assume major otherwise. */ SCM third = scm_assoc (scm_from_int (2), - c_pitchlist); + c_pitchlist); bool minor = (scm_is_pair (third) - && scm_is_number (scm_cdr (third)) - && ly_scm2rational (scm_cdr (third)) == FLAT_ALTERATION); + && scm_is_number (scm_cdr (third)) + && ly_scm2rational (scm_cdr (third)) == FLAT_ALTERATION); audio_ = new Audio_key (scm_to_int (acc), - !minor); + !minor); Audio_element_info info (audio_, key_ev_); announce_element (info); @@ -107,15 +107,15 @@ Key_performer::listen_key_change (Stream_event *ev) } ADD_TRANSLATOR (Key_performer, - /* doc */ - "", + /* doc */ + "", - /* create */ - "", + /* create */ + "", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/key-signature-interface.cc b/lily/key-signature-interface.cc index f05dc7dabe..52fbcffb6f 100644 --- a/lily/key-signature-interface.cc +++ b/lily/key-signature-interface.cc @@ -34,7 +34,6 @@ struct Key_signature_interface DECLARE_GROB_INTERFACE (); }; - /* TODO - space the `natural' signs wider @@ -52,7 +51,7 @@ Key_signature_interface::print (SCM smob) SCM c0s = me->get_property ("c0-position"); bool is_cancellation = me->internal_has_interface - (ly_symbol2scm ("key-cancellation-interface")); + (ly_symbol2scm ("key-cancellation-interface")); /* SCM lists are stacks, so we work from right to left, ending with @@ -62,60 +61,60 @@ Key_signature_interface::print (SCM smob) int last_pos = -1000; SCM last_glyph_name = SCM_BOOL_F; SCM padding_pairs = me->get_property ("padding-pairs"); - + Font_metric *fm = Font_interface::get_default_font (me); SCM alist = me->get_property ("glyph-name-alist"); for (SCM s = me->get_property ("alteration-alist"); scm_is_pair (s); s = scm_cdr (s)) { SCM alt = is_cancellation - ? scm_from_int (0) - : scm_cdar (s); + ? scm_from_int (0) + : scm_cdar (s); SCM glyph_name_scm = ly_assoc_get (alt, alist, SCM_BOOL_F); if (!scm_is_string (glyph_name_scm)) - { - me->warning (_f ("No glyph found for alteration: %s", - ly_scm2rational (alt).to_string ().c_str ())); - continue; - } + { + me->warning (_f ("No glyph found for alteration: %s", + ly_scm2rational (alt).to_string ().c_str ())); + continue; + } string glyph_name = ly_scm2string (glyph_name_scm); Stencil acc (fm->find_by_name (glyph_name)); if (acc.is_empty ()) - me->warning (_ ("alteration not found")); + me->warning (_ ("alteration not found")); else - { - SCM what = scm_caar (s); - - SCM proc = ly_lily_module_constant ("key-signature-interface::alteration-position"); - - int pos = scm_to_int (scm_call_3 (proc, what, scm_cdar (s), c0s)); - acc.translate_axis (pos * inter, Y_AXIS); - - /* - The natural sign (unlike flat & sharp) - has vertical edges on both sides. A little padding is - needed to prevent collisions. - */ - Real padding = robust_scm2double (me->get_property ("padding"), - 0.0); - SCM handle = scm_assoc (scm_cons (glyph_name_scm, last_glyph_name), - padding_pairs); - if (scm_is_pair (handle)) - padding = robust_scm2double (scm_cdr (handle), 0.0); - else if (glyph_name == "accidentals.natural" - && last_pos < pos + 2 - && last_pos > pos - 6) - padding += 0.3; - - mol.add_at_edge (X_AXIS, LEFT, acc, padding); - - last_pos = pos; - last_glyph_name = glyph_name_scm; - } + { + SCM what = scm_caar (s); + + SCM proc = ly_lily_module_constant ("key-signature-interface::alteration-position"); + + int pos = scm_to_int (scm_call_3 (proc, what, scm_cdar (s), c0s)); + acc.translate_axis (pos * inter, Y_AXIS); + + /* + The natural sign (unlike flat & sharp) + has vertical edges on both sides. A little padding is + needed to prevent collisions. + */ + Real padding = robust_scm2double (me->get_property ("padding"), + 0.0); + SCM handle = scm_assoc (scm_cons (glyph_name_scm, last_glyph_name), + padding_pairs); + if (scm_is_pair (handle)) + padding = robust_scm2double (scm_cdr (handle), 0.0); + else if (glyph_name == "accidentals.natural" + && last_pos < pos + 2 + && last_pos > pos - 6) + padding += 0.3; + + mol.add_at_edge (X_AXIS, LEFT, acc, padding); + + last_pos = pos; + last_glyph_name = glyph_name_scm; + } } mol.align_to (X_AXIS, LEFT); @@ -124,12 +123,12 @@ Key_signature_interface::print (SCM smob) } ADD_INTERFACE (Key_signature_interface, - "A group of accidentals, to be printed as signature sign.", - - /* properties */ - "alteration-alist " - "c0-position " - "glyph-name-alist " - "padding " - "padding-pairs " - ); + "A group of accidentals, to be printed as signature sign.", + + /* properties */ + "alteration-alist " + "c0-position " + "glyph-name-alist " + "padding " + "padding-pairs " + ); diff --git a/lily/laissez-vibrer-engraver.cc b/lily/laissez-vibrer-engraver.cc index 49c64ce772..307f5aa7e6 100644 --- a/lily/laissez-vibrer-engraver.cc +++ b/lily/laissez-vibrer-engraver.cc @@ -29,7 +29,7 @@ class Laissez_vibrer_engraver : public Engraver { Stream_event *event_; Grob *lv_column_; - vector<Grob*> lv_ties_; + vector<Grob *> lv_ties_; void stop_translation_timestep (); DECLARE_ACKNOWLEDGER (note_head); @@ -75,7 +75,7 @@ Laissez_vibrer_engraver::acknowledge_note_head (Grob_info inf) lv_tie->set_object ("note-head", inf.grob ()->self_scm ()); Pointer_group_interface::add_grob (lv_column_, ly_symbol2scm ("ties"), - lv_tie); + lv_tie); if (is_direction (unsmob_stream_event (cause)->get_property ("direction"))) { @@ -90,16 +90,16 @@ Laissez_vibrer_engraver::acknowledge_note_head (Grob_info inf) ADD_ACKNOWLEDGER (Laissez_vibrer_engraver, note_head); ADD_TRANSLATOR (Laissez_vibrer_engraver, - /* doc */ - "Create laissez vibrer items.", + /* doc */ + "Create laissez vibrer items.", - /* create */ - "LaissezVibrerTie " - "LaissezVibrerTieColumn ", + /* create */ + "LaissezVibrerTie " + "LaissezVibrerTieColumn ", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/least-squares.cc b/lily/least-squares.cc index 048920b192..66a0999780 100644 --- a/lily/least-squares.cc +++ b/lily/least-squares.cc @@ -23,21 +23,21 @@ void minimise_least_squares (Real *coef, Real *offset, - vector<Offset> const &input) + vector<Offset> const &input) { Real sx = 0.0; Real sy = 0.0; Real sqx = 0.0; Real sxy = 0.0; - for (vsize i = 0; i < input.size ();i++) + for (vsize i = 0; i < input.size (); i++) { Real x = input[i][X_AXIS]; Real y = input[i][Y_AXIS]; sx += x; sy += y; sqx += sqr (x); - sxy += x*y; + sxy += x * y; } int count = input.size (); @@ -49,8 +49,8 @@ minimise_least_squares (Real *coef, Real *offset, if (!count || !den) { programming_error ("minimise_least_squares (): Nothing to minimise\n" - "This means that vertical spacing is triggered\n" - "before line breaking\n"); + "This means that vertical spacing is triggered\n" + "before line breaking\n"); *coef = 0.0; *offset = count ? sy / count : 0.0; } diff --git a/lily/ledger-line-engraver.cc b/lily/ledger-line-engraver.cc index bd0a323e97..e1d2539f09 100644 --- a/lily/ledger-line-engraver.cc +++ b/lily/ledger-line-engraver.cc @@ -25,8 +25,8 @@ class Ledger_line_engraver : public Engraver { Spanner *span_; - vector<Grob*> ledgered_grobs_; - + vector<Grob *> ledgered_grobs_; + public: TRANSLATOR_DECLARATIONS (Ledger_line_engraver); @@ -62,12 +62,12 @@ Ledger_line_engraver::stop_translation_timestep () if (span_) { for (vsize i = 0; i < ledgered_grobs_.size (); i++) - { - if (!to_boolean (ledgered_grobs_[i]->get_property ("no-ledgers"))) - Pointer_group_interface::add_grob (span_, - ly_symbol2scm ("note-heads"), - ledgered_grobs_[i]); - } + { + if (!to_boolean (ledgered_grobs_[i]->get_property ("no-ledgers"))) + Pointer_group_interface::add_grob (span_, + ly_symbol2scm ("note-heads"), + ledgered_grobs_[i]); + } } ledgered_grobs_.clear (); @@ -77,7 +77,7 @@ void Ledger_line_engraver::process_music () { /* - Need to do this, otherwise the first note might miss ledgers. + Need to do this, otherwise the first note might miss ledgers. */ if (!span_) start_spanner (); @@ -124,16 +124,16 @@ Ledger_line_engraver::acknowledge_ledgered (Grob_info s) ADD_ACKNOWLEDGER (Ledger_line_engraver, ledgered); ADD_ACKNOWLEDGER (Ledger_line_engraver, staff_symbol); ADD_TRANSLATOR (Ledger_line_engraver, - /* doc */ - "Create the spanner to draw ledger lines, and notices" - " objects that need ledger lines.", + /* doc */ + "Create the spanner to draw ledger lines, and notices" + " objects that need ledger lines.", - /* create */ - "LedgerLineSpanner ", + /* create */ + "LedgerLineSpanner ", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/ledger-line-spanner.cc b/lily/ledger-line-spanner.cc index a518bc9225..0123822214 100644 --- a/lily/ledger-line-spanner.cc +++ b/lily/ledger-line-spanner.cc @@ -33,55 +33,55 @@ struct Ledger_line_spanner DECLARE_SCHEME_CALLBACK (print, (SCM)); DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM)); static Stencil brew_ledger_lines (Grob *me, - int pos, - Interval, - Real, Real, - Interval x_extent, - Real left_shorten); + int pos, + Interval, + Real, Real, + Interval x_extent, + Real left_shorten); DECLARE_GROB_INTERFACE (); }; Stencil Ledger_line_spanner::brew_ledger_lines (Grob *staff, - int pos, - Interval staff_extent, - Real halfspace, - Real ledgerlinethickness, - Interval x_extent, - Real left_shorten) + int pos, + Interval staff_extent, + Real halfspace, + Real ledgerlinethickness, + Interval x_extent, + Real left_shorten) { int line_count = (staff_extent.contains (pos) - ? 0 - : sign (pos) * int (rint (pos - staff_extent[Direction (sign (pos))])) / 2); + ? 0 + : sign (pos) * int (rint (pos - staff_extent[Direction (sign (pos))])) / 2); Stencil stencil; if (line_count) { Real blotdiameter = ledgerlinethickness; Interval y_extent - = Interval (-0.5 * (ledgerlinethickness), - +0.5 * (ledgerlinethickness)); + = Interval (-0.5 * (ledgerlinethickness), + +0.5 * (ledgerlinethickness)); Stencil proto_ledger_line - = Lookup::round_filled_box (Box (x_extent, y_extent), blotdiameter); + = Lookup::round_filled_box (Box (x_extent, y_extent), blotdiameter); x_extent[LEFT] += left_shorten; Stencil proto_first_line - = Lookup::round_filled_box (Box (x_extent, y_extent), blotdiameter); + = Lookup::round_filled_box (Box (x_extent, y_extent), blotdiameter); Direction dir = (Direction)sign (pos); Real offs = (Staff_symbol_referencer::on_line (staff, pos)) - ? 0.0 - : -dir * halfspace; + ? 0.0 + : -dir * halfspace; offs += pos * halfspace; for (int i = 0; i < line_count; i++) - { - Stencil ledger_line ((i == 0) - ? proto_first_line - : proto_ledger_line); - ledger_line.translate_axis (-dir * halfspace * i * 2 + offs, Y_AXIS); - stencil.add_stencil (ledger_line); - } + { + Stencil ledger_line ((i == 0) + ? proto_first_line + : proto_ledger_line); + ledger_line.translate_axis (-dir * halfspace * i * 2 + offs, Y_AXIS); + stencil.add_stencil (ledger_line); + } } return stencil; @@ -89,33 +89,33 @@ Ledger_line_spanner::brew_ledger_lines (Grob *staff, static void set_rods (Drul_array<Interval> const ¤t_extents, - Drul_array<Interval> const &previous_extents, - Item *current_column, - Item *previous_column, - Real min_length_fraction) + Drul_array<Interval> const &previous_extents, + Item *current_column, + Item *previous_column, + Real min_length_fraction) { Direction d = UP; do { if (!current_extents[d].is_empty () - && !previous_extents[d].is_empty ()) - { - Real total_head_length = previous_extents[d].length () - + current_extents[d].length (); - - Rod rod; - rod.distance_ = total_head_length - * (3 / 2 * min_length_fraction) - /* - we go from right to left. - */ - - previous_extents[d][LEFT] - + current_extents[d][RIGHT]; - - rod.item_drul_[LEFT] = current_column; - rod.item_drul_[RIGHT] = previous_column; - rod.add_to_cols (); - } + && !previous_extents[d].is_empty ()) + { + Real total_head_length = previous_extents[d].length () + + current_extents[d].length (); + + Rod rod; + rod.distance_ = total_head_length + * (3 / 2 * min_length_fraction) + /* + we go from right to left. + */ + - previous_extents[d][LEFT] + + current_extents[d][RIGHT]; + + rod.item_drul_[LEFT] = current_column; + rod.item_drul_[RIGHT] = previous_column; + rod.add_to_cols (); + } } while (flip (&d) != DOWN); } @@ -146,7 +146,7 @@ Ledger_line_spanner::set_spacing_rods (SCM smob) Interval staff_extent = staff->extent (staff, Y_AXIS); staff_extent *= 1 / halfspace; - + /* Run through heads using a loop. Since Ledger_line_spanner can contain a lot of noteheads, superlinear performance is too slow. @@ -158,35 +158,35 @@ Ledger_line_spanner::set_spacing_rods (SCM smob) int pos = Staff_symbol_referencer::get_rounded_position (h); if (staff_extent.contains (pos)) - continue; + continue; Item *column = h->get_column (); if (current_column != column) - { - set_rods (current_extents, previous_extents, - current_column, previous_column, - min_length_fraction); + { + set_rods (current_extents, previous_extents, + current_column, previous_column, + min_length_fraction); - previous_column = current_column; - current_column = column; - previous_extents = current_extents; + previous_column = current_column; + current_column = column; + previous_extents = current_extents; - current_extents[DOWN].set_empty (); - current_extents[UP].set_empty (); - } + current_extents[DOWN].set_empty (); + current_extents[UP].set_empty (); + } Interval head_extent = h->extent (column, X_AXIS); Direction vdir = Direction (sign (pos)); if (!vdir) - continue; + continue; current_extents[vdir].unite (head_extent); } if (previous_column && current_column) set_rods (current_extents, previous_extents, - current_column, previous_column, - min_length_fraction); + current_column, previous_column, + min_length_fraction); return SCM_UNSPECIFIED; } @@ -231,7 +231,7 @@ Ledger_line_spanner::print (SCM smob) Interval staff_extent = staff->extent (staff, Y_AXIS); staff_extent *= 1 / halfspace; - + Real length_fraction = robust_scm2double (me->get_property ("length-fraction"), 0.25); @@ -245,8 +245,8 @@ Ledger_line_spanner::print (SCM smob) Axis a = Axis (i); common[a] = common_refpoint_of_array (heads, me, a); for (vsize i = heads.size (); i--;) - if (Grob *g = unsmob_grob (me->get_object ("accidental-grob"))) - common[a] = common[a]->common_refpoint (g, a); + if (Grob *g = unsmob_grob (me->get_object ("accidental-grob"))) + common[a] = common[a]->common_refpoint (g, a); } Ledger_requests reqs; @@ -256,19 +256,19 @@ Ledger_line_spanner::print (SCM smob) int pos = Staff_symbol_referencer::get_rounded_position (h); if (pos && !staff_extent.contains (pos)) - { - Interval head_extent = h->extent (common[X_AXIS], X_AXIS); - Interval ledger_extent = head_extent; - ledger_extent.widen (length_fraction * head_extent.length ()); - - Direction vdir = Direction (sign (pos)); - int rank = h->get_column ()->get_rank (); - - reqs[rank][vdir].ledger_extent_.unite (ledger_extent); - reqs[rank][vdir].head_extent_.unite (head_extent); - reqs[rank][vdir].position_ - = vdir * max (vdir * reqs[rank][vdir].position_, vdir * pos); - } + { + Interval head_extent = h->extent (common[X_AXIS], X_AXIS); + Interval ledger_extent = head_extent; + ledger_extent.widen (length_fraction * head_extent.length ()); + + Direction vdir = Direction (sign (pos)); + int rank = h->get_column ()->get_rank (); + + reqs[rank][vdir].ledger_extent_.unite (ledger_extent); + reqs[rank][vdir].head_extent_.unite (head_extent); + reqs[rank][vdir].position_ + = vdir * max (vdir * reqs[rank][vdir].position_, vdir * pos); + } } // determine maximum size for non-colliding ledger. @@ -278,37 +278,37 @@ Ledger_line_spanner::print (SCM smob) i != reqs.end (); last = i++) { if (last == reqs.end ()) - continue; + continue; Direction d = DOWN; do - { - if (!staff_extent.contains (last->second[d].position_) - && !staff_extent.contains (i->second[d].position_)) - { - Real center - = (last->second[d].head_extent_[RIGHT] - + i->second[d].head_extent_[LEFT]) / 2; - - Direction which = LEFT; - do - { - Ledger_request &lr = ((which == LEFT) ? * last : *i).second[d]; - - // due tilt of quarter note-heads - /* FIXME */ - bool both - = (!staff_extent.contains (last->second[d].position_ - - sign (last->second[d].position_)) - && !staff_extent.contains (i->second[d].position_ - - sign (i->second[d].position_))); - Real limit = (center + (both ? which * gap / 2 : 0)); - lr.ledger_extent_.at (-which) - = which * max (which * lr.ledger_extent_[-which], which * limit); - } - while (flip (&which) != LEFT); - } - } + { + if (!staff_extent.contains (last->second[d].position_) + && !staff_extent.contains (i->second[d].position_)) + { + Real center + = (last->second[d].head_extent_[RIGHT] + + i->second[d].head_extent_[LEFT]) / 2; + + Direction which = LEFT; + do + { + Ledger_request &lr = ((which == LEFT) ? * last : *i).second[d]; + + // due tilt of quarter note-heads + /* FIXME */ + bool both + = (!staff_extent.contains (last->second[d].position_ + - sign (last->second[d].position_)) + && !staff_extent.contains (i->second[d].position_ + - sign (i->second[d].position_))); + Real limit = (center + (both ? which * gap / 2 : 0)); + lr.ledger_extent_.at (-which) + = which * max (which * lr.ledger_extent_[-which], which * limit); + } + while (flip (&which) != LEFT); + } + } while (flip (&d) != DOWN); } @@ -321,58 +321,58 @@ Ledger_line_spanner::print (SCM smob) int pos = Staff_symbol_referencer::get_rounded_position (h); if (!staff_extent.contains (pos - sign (pos)) && !staff_extent.is_empty ()) - { - Interval head_size = h->extent (common[X_AXIS], X_AXIS); - Interval ledger_size = head_size; - ledger_size.widen (ledger_size.length () * length_fraction); - - Interval max_size = reqs[h->get_column ()->get_rank ()] - [Direction (sign (pos))].ledger_extent_; - - ledger_size.intersect (max_size); - Real left_shorten = 0.0; - if (Grob *g = unsmob_grob (h->get_object ("accidental-grob"))) - { - Interval accidental_size = g->extent (common[X_AXIS], X_AXIS); - Real d - = linear_combination (Drul_array<Real> (accidental_size[RIGHT], - head_size[LEFT]), - 0.0); - - left_shorten = max (-ledger_size[LEFT] + d, 0.0); - - /* - TODO: shorten 2 ledger lines for the case natural + - downstem. - */ - } - - ledgers.add_stencil (brew_ledger_lines (staff, pos, staff_extent, - halfspace, - ledgerlinethickness, - ledger_size, - left_shorten)); - } + { + Interval head_size = h->extent (common[X_AXIS], X_AXIS); + Interval ledger_size = head_size; + ledger_size.widen (ledger_size.length () * length_fraction); + + Interval max_size = reqs[h->get_column ()->get_rank ()] + [Direction (sign (pos))].ledger_extent_; + + ledger_size.intersect (max_size); + Real left_shorten = 0.0; + if (Grob *g = unsmob_grob (h->get_object ("accidental-grob"))) + { + Interval accidental_size = g->extent (common[X_AXIS], X_AXIS); + Real d + = linear_combination (Drul_array<Real> (accidental_size[RIGHT], + head_size[LEFT]), + 0.0); + + left_shorten = max (-ledger_size[LEFT] + d, 0.0); + + /* + TODO: shorten 2 ledger lines for the case natural + + downstem. + */ + } + + ledgers.add_stencil (brew_ledger_lines (staff, pos, staff_extent, + halfspace, + ledgerlinethickness, + ledger_size, + left_shorten)); + } } ledgers.translate_axis (-me->relative_coordinate (common[X_AXIS], X_AXIS), - X_AXIS); + X_AXIS); return ledgers.smobbed_copy (); } ADD_INTERFACE (Ledger_line_spanner, - "This spanner draws the ledger lines of a staff. This is a" - " separate grob because it has to process all potential" - " collisions between all note heads.", - - /* properties */ - "gap " - "length-fraction " - "minimum-length-fraction " - "note-heads " - "thickness " - ); + "This spanner draws the ledger lines of a staff. This is a" + " separate grob because it has to process all potential" + " collisions between all note heads.", + + /* properties */ + "gap " + "length-fraction " + "minimum-length-fraction " + "note-heads " + "thickness " + ); struct Ledgered_interface { @@ -380,9 +380,9 @@ struct Ledgered_interface }; ADD_INTERFACE (Ledgered_interface, - "Objects that need ledger lines, typically note heads. See" - " also @ref{ledger-line-spanner-interface}.", + "Objects that need ledger lines, typically note heads. See" + " also @ref{ledger-line-spanner-interface}.", - /* properties */ - "no-ledgers " - ); + /* properties */ + "no-ledgers " + ); diff --git a/lily/ligature-bracket-engraver.cc b/lily/ligature-bracket-engraver.cc index b467ec998a..47c28c71e6 100644 --- a/lily/ligature-bracket-engraver.cc +++ b/lily/ligature-bracket-engraver.cc @@ -63,15 +63,15 @@ Ligature_bracket_engraver::Ligature_bracket_engraver () } void -Ligature_bracket_engraver::process_music() +Ligature_bracket_engraver::process_music () { if (events_drul_[STOP]) { if (!ligature_) - { - events_drul_[STOP]->origin ()->warning (_ ("cannot find start of ligature")); - return; - } + { + events_drul_[STOP]->origin ()->warning (_ ("cannot find start of ligature")); + return; + } finished_ligature_ = ligature_; ligature_ = 0; @@ -81,10 +81,10 @@ Ligature_bracket_engraver::process_music() if (events_drul_[START]) { if (ligature_) - { - events_drul_[START]->origin ()->warning (_ ("already have a ligature")); - return; - } + { + events_drul_[START]->origin ()->warning (_ ("already have a ligature")); + return; + } previous_start_event_ = events_drul_[START]; ligature_ = make_spanner ("LigatureBracket", events_drul_[START]->self_scm ()); @@ -97,23 +97,22 @@ Ligature_bracket_engraver::acknowledge_note_column (Grob_info info) if (ligature_) { Tuplet_bracket::add_column (ligature_, - info.item ()); - add_bound_item (ligature_, info.item()); + info.item ()); + add_bound_item (ligature_, info.item ()); } } void Ligature_bracket_engraver::acknowledge_rest (Grob_info info) { - acknowledge_note_column(info); + acknowledge_note_column (info); } - void Ligature_bracket_engraver::stop_translation_timestep () { - events_drul_[LEFT] = - events_drul_[RIGHT] = 0; + events_drul_[LEFT] + = events_drul_[RIGHT] = 0; finished_ligature_ = 0; } @@ -121,16 +120,16 @@ ADD_ACKNOWLEDGER (Ligature_bracket_engraver, rest); ADD_ACKNOWLEDGER (Ligature_bracket_engraver, note_column); ADD_TRANSLATOR (Ligature_bracket_engraver, - /* doc */ - "Handle @code{Ligature_events} by engraving @code{Ligature}" - " brackets.", + /* doc */ + "Handle @code{Ligature_events} by engraving @code{Ligature}" + " brackets.", - /* create */ - "LigatureBracket ", + /* create */ + "LigatureBracket ", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/ligature-engraver.cc b/lily/ligature-engraver.cc index 99e86ed20b..ed346a1480 100644 --- a/lily/ligature-engraver.cc +++ b/lily/ligature-engraver.cc @@ -100,15 +100,15 @@ Ligature_engraver::process_music () if (events_drul_[STOP]) { if (!ligature_) - { - events_drul_[STOP]->origin ()->warning (_ ("cannot find start of ligature")); - return; - } + { + events_drul_[STOP]->origin ()->warning (_ ("cannot find start of ligature")); + return; + } if (!last_bound_) - events_drul_[STOP]->origin ()->warning (_ ("no right bound")); + events_drul_[STOP]->origin ()->warning (_ ("no right bound")); else - ligature_->set_bound (RIGHT, last_bound_); + ligature_->set_bound (RIGHT, last_bound_); prev_start_event_ = 0; finished_primitives_ = primitives_; @@ -127,19 +127,19 @@ Ligature_engraver::process_music () if (events_drul_[START]) { if (ligature_) - { - events_drul_[START]->origin ()->warning (_ ("already have a ligature")); - return; - } + { + events_drul_[START]->origin ()->warning (_ ("already have a ligature")); + return; + } prev_start_event_ = events_drul_[START]; ligature_ = create_ligature_spanner (); Grob *bound = unsmob_grob (get_property ("currentMusicalColumn")); if (!bound) - events_drul_[START]->origin ()->warning (_ ("no left bound")); + events_drul_[START]->origin ()->warning (_ ("no left bound")); else - ligature_->set_bound (LEFT, bound); + ligature_->set_bound (LEFT, bound); ligature_start_mom_ = now_mom (); @@ -154,16 +154,15 @@ Ligature_engraver::stop_translation_timestep () if (finished_ligature_) { if (!finished_primitives_.size ()) - { - finished_ligature_->programming_error ( - "Ligature_engraver::stop_translation_timestep ():" - " junking empty ligature"); - } + { + finished_ligature_->programming_error ("Ligature_engraver::stop_translation_timestep ():" + " junking empty ligature"); + } else - { - typeset_ligature (finished_ligature_, finished_primitives_); - finished_primitives_.clear (); - } + { + typeset_ligature (finished_ligature_, finished_primitives_); + finished_primitives_.clear (); + } finished_ligature_ = 0; } diff --git a/lily/lily-guile.cc b/lily/lily-guile.cc index 1763a5cebb..4d6f6a79c6 100644 --- a/lily/lily-guile.cc +++ b/lily/lily-guile.cc @@ -41,7 +41,6 @@ using namespace std; #include "version.hh" #include "warn.hh" - /* symbols/strings. */ @@ -49,9 +48,9 @@ string ly_scm_write_string (SCM s) { SCM port = scm_mkstrport (SCM_INUM0, - scm_make_string (SCM_INUM0, SCM_UNDEFINED), - SCM_OPN | SCM_WRTNG, - "ly_write2string"); + scm_make_string (SCM_INUM0, SCM_UNDEFINED), + SCM_OPN | SCM_WRTNG, + "ly_write2string"); // SCM write = scm_eval_3 (ly_symbol2scm ("write"), s, SCM_EOL); SCM write = scm_primitive_eval (ly_symbol2scm ("write")); @@ -83,13 +82,13 @@ gulp_file_to_string (string fn, bool must_exist, int size) if (s == "") { if (must_exist) - { - string e = _f ("cannot find file: `%s'", fn); - e += " "; - e += _f ("(load path: `%s')", global_path.to_string ()); - error (e); - /* unreachable */ - } + { + string e = _f ("cannot find file: `%s'", fn); + e += " "; + e += _f ("(load path: `%s')", global_path.to_string ()); + error (e); + /* unreachable */ + } return s; } @@ -124,10 +123,11 @@ ly_scm2string (SCM str) assert (scm_is_string (str)); string result; size_t len = scm_c_string_length (str); - if (len) { - result.resize(len); - scm_to_locale_stringbuf(str, &result.at(0), len); - } + if (len) + { + result.resize (len); + scm_to_locale_stringbuf (str, &result.at (0), len); + } return result; } @@ -135,7 +135,7 @@ SCM ly_string2scm (string const &str) { return scm_from_locale_stringn (str.c_str (), - str.length ()); + str.length ()); } char * @@ -147,7 +147,7 @@ ly_scm2str0 (SCM str) /* PAIRS */ -SCM +SCM index_get_cell (SCM s, Direction d) { assert (d); @@ -168,10 +168,9 @@ bool is_number_pair (SCM p) { return scm_is_pair (p) - && scm_is_number (scm_car (p)) && scm_is_number (scm_cdr (p)); + && scm_is_number (scm_car (p)) && scm_is_number (scm_cdr (p)); } - unsigned int ly_scm_hash (SCM s) { @@ -236,7 +235,7 @@ Drul_array<Real> ly_scm2realdrul (SCM p) { return Drul_array<Real> (scm_to_double (scm_car (p)), - scm_to_double (scm_cdr (p))); + scm_to_double (scm_cdr (p))); } SCM @@ -245,7 +244,6 @@ ly_interval2scm (Drul_array<Real> i) return scm_cons (scm_from_double (i[LEFT]), scm_from_double (i[RIGHT])); } - Interval robust_scm2interval (SCM k, Drul_array<Real> v) { @@ -289,7 +287,7 @@ Offset ly_scm2offset (SCM s) { return Offset (scm_to_double (scm_car (s)), - scm_to_double (scm_cdr (s))); + scm_to_double (scm_cdr (s))); } Offset @@ -321,9 +319,6 @@ ly_scm2offsets (SCM s) return os; } - - - /* ALIST */ @@ -339,9 +334,9 @@ alist_equal_p (SCM a, SCM b) SCM l = scm_assoc (key, b); if (l == SCM_BOOL_F - || !ly_is_equal (scm_cdr (l), val)) + || !ly_is_equal (scm_cdr (l), val)) - return false; + return false; } return true; } @@ -371,7 +366,6 @@ robust_list_ref (int i, SCM l) return scm_car (l); } - SCM ly_deep_copy (SCM src) { @@ -381,11 +375,11 @@ ly_deep_copy (SCM src) { int len = scm_c_vector_length (src); SCM nv = scm_c_make_vector (len, SCM_UNDEFINED); - for (int i = 0;i < len; i++) - { - SCM si = scm_from_int (i); - scm_vector_set_x (nv, si, ly_deep_copy (scm_vector_ref (src, si))); - } + for (int i = 0; i < len; i++) + { + SCM si = scm_from_int (i); + scm_vector_set_x (nv, si, ly_deep_copy (scm_vector_ref (src, si))); + } } return src; } @@ -396,8 +390,8 @@ print_scm_val (SCM val) string realval = ly_scm_write_string (val); if (realval.length () > 200) realval = realval.substr (0, 100) - + "\n :\n :\n" - + realval.substr (realval.length () - 100); + + "\n :\n :\n" + + realval.substr (realval.length () - 100); return realval; } @@ -419,15 +413,15 @@ type_check_assignment (SCM sym, SCM val, SCM type_symbol) #if 0 return false; #else - /* - This is used for autoBeamSettings. + /* + This is used for autoBeamSettings. - TODO: deprecate the use of \override and \revert for - autoBeamSettings? + TODO: deprecate the use of \override and \revert for + autoBeamSettings? - or use a symbol autoBeamSettingS? - */ - return true; + or use a symbol autoBeamSettingS? + */ + return true; #endif SCM type = scm_object_property (sym, type_symbol); @@ -435,33 +429,33 @@ type_check_assignment (SCM sym, SCM val, SCM type_symbol) if (type != SCM_EOL && !ly_is_procedure (type)) { warning (_f ("cannot find property type-check for `%s' (%s).", - ly_symbol2string (sym).c_str (), - ly_symbol2string (type_symbol).c_str ()) - + " " + _ ("perhaps a typing error?")); + ly_symbol2string (sym).c_str (), + ly_symbol2string (type_symbol).c_str ()) + + " " + _ ("perhaps a typing error?")); /* Be strict when being anal :) */ if (do_internal_type_checking_global) - scm_throw (ly_symbol2scm ("ly-file-failed"), scm_list_3 (ly_symbol2scm ("typecheck"), - sym, val)); + scm_throw (ly_symbol2scm ("ly-file-failed"), scm_list_3 (ly_symbol2scm ("typecheck"), + sym, val)); warning (_ ("doing assignment anyway")); } else { if (val != SCM_EOL - && ly_is_procedure (type) - && scm_call_1 (type, val) == SCM_BOOL_F) - { - ok = false; - SCM typefunc = ly_lily_module_constant ("type-name"); - SCM type_name = scm_call_1 (typefunc, type); - - warning (_f ("type check for `%s' failed; value `%s' must be of type `%s'", - ly_symbol2string (sym).c_str (), - print_scm_val (val), - ly_scm2string (type_name).c_str ())); - progress_indication ("\n"); - } + && ly_is_procedure (type) + && scm_call_1 (type, val) == SCM_BOOL_F) + { + ok = false; + SCM typefunc = ly_lily_module_constant ("type-name"); + SCM type_name = scm_call_1 (typefunc, type); + + warning (_f ("type check for `%s' failed; value `%s' must be of type `%s'", + ly_symbol2string (sym).c_str (), + print_scm_val (val), + ly_scm2string (type_name).c_str ())); + progress_indication ("\n"); + } } return ok; } @@ -479,13 +473,12 @@ ly_unique (SCM list) for (SCM i = list; scm_is_pair (i); i = scm_cdr (i)) { if (!scm_is_pair (scm_cdr (i)) - || !ly_is_equal (scm_car (i), scm_cadr (i))) - unique = scm_cons (scm_car (i), unique); + || !ly_is_equal (scm_car (i), scm_cadr (i))) + unique = scm_cons (scm_car (i), unique); } return scm_reverse_x (unique, SCM_EOL); } - /* Split list at member s, removing s. Return (BEFORE . AFTER) */ SCM @@ -498,7 +491,7 @@ ly_split_list (SCM s, SCM list) SCM i = scm_car (after); after = scm_cdr (after); if (ly_is_equal (i, s)) - break; + break; before = scm_cons (i, before); } return scm_cons (scm_reverse_x (before, SCM_EOL), after); @@ -549,7 +542,6 @@ robust_scm2double (SCM k, double x) return x; } - string robust_scm2string (SCM k, string s) { @@ -566,20 +558,18 @@ robust_scm2int (SCM k, int o) return o; } - SCM ly_rational2scm (Rational r) { return scm_divide (scm_from_int64 (r.numerator ()), - scm_from_int64 (r.denominator ())); + scm_from_int64 (r.denominator ())); } - Rational ly_scm2rational (SCM r) { return Rational (scm_to_int64 (scm_numerator (r)), - scm_to_int64 (scm_denominator (r))); + scm_to_int64 (scm_denominator (r))); } Rational @@ -614,7 +604,6 @@ ly_hash2alist (SCM tab) return scm_call_1 (func, tab); } - /* C++ interfacing. */ @@ -639,17 +628,14 @@ mangle_cxx_identifier (string cxx_id) replace_all (&cxx_id, "__", "::"); replace_all (&cxx_id, '_', '-'); - return cxx_id; } - - SCM ly_string_array_to_scm (vector<string> a) { SCM s = SCM_EOL; - for (vsize i = a.size (); i ; i--) + for (vsize i = a.size (); i; i--) s = scm_cons (ly_symbol2scm (a[i - 1].c_str ()), s); return s; } diff --git a/lily/lily-lexer-scheme.cc b/lily/lily-lexer-scheme.cc index e2be4fca43..02644096b6 100644 --- a/lily/lily-lexer-scheme.cc +++ b/lily/lily-lexer-scheme.cc @@ -2,7 +2,7 @@ This file is part of LilyPond, the GNU music typesetter. Copyright (C) 2006--2011 Han-Wen Nienhuys <hanwen@lilypond.org> - + LilyPond is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,12 +21,12 @@ #include "lily-lexer.hh" LY_DEFINE (ly_lexer_keywords, "ly:lexer-keywords", - 1, 0, 0, (SCM lexer), - "Return a list of @code{(KEY . CODE)} pairs, signifying the" - " LilyPond reserved words list.") + 1, 0, 0, (SCM lexer), + "Return a list of @code{(KEY . CODE)} pairs, signifying the" + " LilyPond reserved words list.") { LY_ASSERT_SMOB (Lily_lexer, lexer, 1); - Lily_lexer * lex = Lily_lexer::unsmob (lexer); + Lily_lexer *lex = Lily_lexer::unsmob (lexer); return lex->keyword_list (); } diff --git a/lily/lily-lexer.cc b/lily/lily-lexer.cc index 1160fe69f6..5d87c83872 100644 --- a/lily/lily-lexer.cc +++ b/lily/lily-lexer.cc @@ -37,7 +37,8 @@ using namespace std; #include "lily-parser.hh" static Keyword_ent the_key_tab[] -= { += +{ {"accepts", ACCEPTS}, {"addlyrics", ADDLYRICS}, {"alias", ALIAS}, @@ -209,8 +210,8 @@ Lily_lexer::keyword_list () const for (vsize i = 0; i < keytable_->table_.size (); i++) { *tail = scm_acons (scm_from_locale_string (keytable_->table_[i].name_), - scm_from_int (keytable_->table_[i].tokcode_), - SCM_EOL); + scm_from_int (keytable_->table_[i].tokcode_), + SCM_EOL); tail = SCM_CDRLOC (*tail); } @@ -225,7 +226,7 @@ Lily_lexer::lookup_identifier_symbol (SCM sym) { SCM var = ly_module_lookup (scm_car (s), sym); if (var != SCM_BOOL_F) - return scm_variable_ref (var); + return scm_variable_ref (var); } return SCM_UNDEFINED; @@ -246,8 +247,8 @@ Lily_lexer::start_main_input () new_input (main_input_name_, sources_); scm_module_define (scm_car (scopes_), - ly_symbol2scm ("input-file-name"), - ly_string2scm (main_input_name_)); + ly_symbol2scm ("input-file-name"), + ly_string2scm (main_input_name_)); } void @@ -286,19 +287,19 @@ Lily_lexer::set_identifier (SCM path, SCM val) if (scm_is_symbol (sym)) { if (lookup_keyword (ly_symbol2string (sym)) >= 0) - { - string symstr = ly_symbol2string (sym); - warning (_f ("identifier name is a keyword: `%s'", symstr.c_str ())); - } + { + string symstr = ly_symbol2string (sym); + warning (_f ("identifier name is a keyword: `%s'", symstr.c_str ())); + } SCM mod = scm_car (scopes_); if (scm_is_pair (path)) - { - SCM prev = ly_module_lookup (mod, sym); - if (prev != SCM_BOOL_F) - val = nested_property_alist (scm_variable_ref (prev), path, val); - } + { + SCM prev = ly_module_lookup (mod, sym); + if (prev != SCM_BOOL_F) + val = nested_property_alist (scm_variable_ref (prev), path, val); + } scm_module_define (mod, sym, val); } else @@ -356,7 +357,7 @@ Lily_lexer::add_lexed_char (int count) { char const *start = here_str0 (); lexloc_->set (get_source_file (), - start, start + count); + start, start + count); char_count_stack_.back () += count; } @@ -382,7 +383,7 @@ Lily_lexer::mark_smob (SCM s) } int -Lily_lexer::print_smob (SCM s, SCM port, scm_print_state*) +Lily_lexer::print_smob (SCM s, SCM port, scm_print_state *) { Lily_lexer *lexer = Lily_lexer::unsmob (s); diff --git a/lily/lily-parser-scheme.cc b/lily/lily-parser-scheme.cc index 6a5f8d791b..ceefa6b038 100644 --- a/lily/lily-parser-scheme.cc +++ b/lily/lily-parser-scheme.cc @@ -33,9 +33,9 @@ #include "warn.hh" LY_DEFINE (ly_parse_file, "ly:parse-file", - 1, 0, 0, (SCM name), - "Parse a single @code{.ly} file." - " Upon failure, throw @code{ly-file-failed} key.") + 1, 0, 0, (SCM name), + "Parse a single @code{.ly} file." + " Upon failure, throw @code{ly-file-failed} key.") { LY_ASSERT_TYPE (scm_is_string, name, 1); string file = ly_scm2string (name); @@ -51,9 +51,10 @@ LY_DEFINE (ly_parse_file, "ly:parse-file", out_file_name.ext_ = ""; out_file_name.root_ = ""; if (ly_get_option (ly_symbol2scm ("gui")) != SCM_BOOL_T - && ly_get_option (ly_symbol2scm ("strip-output-dir")) == SCM_BOOL_T) { - out_file_name.dir_ = ""; - } + && ly_get_option (ly_symbol2scm ("strip-output-dir")) == SCM_BOOL_T) + { + out_file_name.dir_ = ""; + } /* When running from gui, generate output in .ly source directory. */ string output_name = output_name_global; @@ -62,29 +63,29 @@ LY_DEFINE (ly_parse_file, "ly:parse-file", /* Interpret --output=DIR to mean --output=DIR/BASE. */ string dir; if (is_dir (output_name)) - { - dir = output_name; - output_name = ""; - } + { + dir = output_name; + output_name = ""; + } else - { - File_name out (output_name); - if (is_dir (out.dir_part ())) - { - dir = out.dir_part (); - out_file_name = out.file_part (); - } - } + { + File_name out (output_name); + if (is_dir (out.dir_part ())) + { + dir = out.dir_part (); + out_file_name = out.file_part (); + } + } if (dir != "" && dir != "." && dir != get_working_directory ()) - { - global_path.prepend (get_working_directory ()); - message (_f ("Changing working directory to: `%s'", - dir.c_str ())); - chdir (dir.c_str ()); - } + { + global_path.prepend (get_working_directory ()); + message (_f ("Changing working directory to: `%s'", + dir.c_str ())); + chdir (dir.c_str ()); + } else - out_file_name = File_name (output_name); + out_file_name = File_name (output_name); } string init; @@ -98,11 +99,10 @@ LY_DEFINE (ly_parse_file, "ly:parse-file", { warning (_f ("cannot find init file: `%s'", init)); warning (_f ("(search path: `%s')", - global_path.to_string ().c_str ())); + global_path.to_string ().c_str ())); exit (2); } - bool error = false; if ((file_name != "-") && file_name.empty ()) { @@ -134,23 +134,22 @@ LY_DEFINE (ly_parse_file, "ly:parse-file", if (error) /* TODO: pass renamed input file too. */ scm_throw (ly_symbol2scm ("ly-file-failed"), - scm_list_1 (ly_string2scm (file_name))); + scm_list_1 (ly_string2scm (file_name))); return SCM_UNSPECIFIED; } - LY_DEFINE (ly_parser_lexer, "ly:parser-lexer", - 1, 0, 0, (SCM parser_smob), - "Return the lexer for @var{parser-smob}.") + 1, 0, 0, (SCM parser_smob), + "Return the lexer for @var{parser-smob}.") { Lily_parser *parser = unsmob_lily_parser (parser_smob); return parser->lexer_->self_scm (); } LY_DEFINE (ly_parser_clone, "ly:parser-clone", - 1, 0, 0, (SCM parser_smob), - "Return a clone of @var{parser-smob}.") + 1, 0, 0, (SCM parser_smob), + "Return a clone of @var{parser-smob}.") { LY_ASSERT_SMOB (Lily_parser, parser_smob, 1); Lily_parser *parser = unsmob_lily_parser (parser_smob); @@ -160,8 +159,8 @@ LY_DEFINE (ly_parser_clone, "ly:parser-clone", } LY_DEFINE (ly_parser_define_x, "ly:parser-define!", - 3, 0, 0, (SCM parser_smob, SCM symbol, SCM val), - "Bind @var{symbol} to @var{val} in @var{parser-smob}'s module.") + 3, 0, 0, (SCM parser_smob, SCM symbol, SCM val), + "Bind @var{symbol} to @var{val} in @var{parser-smob}'s module.") { LY_ASSERT_SMOB (Lily_parser, parser_smob, 1); @@ -174,9 +173,9 @@ LY_DEFINE (ly_parser_define_x, "ly:parser-define!", } LY_DEFINE (ly_parser_lookup, "ly:parser-lookup", - 2, 0, 0, (SCM parser_smob, SCM symbol), - "Look up @var{symbol} in @var{parser-smob}'s module." - " Return @code{'()} if not defined.") + 2, 0, 0, (SCM parser_smob, SCM symbol), + "Look up @var{symbol} in @var{parser-smob}'s module." + " Return @code{'()} if not defined.") { LY_ASSERT_SMOB (Lily_parser, parser_smob, 1); @@ -192,9 +191,9 @@ LY_DEFINE (ly_parser_lookup, "ly:parser-lookup", } LY_DEFINE (ly_parser_parse_string, "ly:parser-parse-string", - 2, 0, 0, (SCM parser_smob, SCM ly_code), - "Parse the string @var{ly-code} with @var{parser-smob}." - " Upon failure, throw @code{ly-file-failed} key.") + 2, 0, 0, (SCM parser_smob, SCM ly_code), + "Parse the string @var{ly-code} with @var{parser-smob}." + " Upon failure, throw @code{ly-file-failed} key.") { LY_ASSERT_SMOB (Lily_parser, parser_smob, 1); Lily_parser *parser = unsmob_lily_parser (parser_smob); @@ -202,7 +201,7 @@ LY_DEFINE (ly_parser_parse_string, "ly:parser-parse-string", if (!parser->lexer_->is_clean ()) parser->parser_error (_ ("ly:parser-parse-string is only valid with a new parser." - " Use ly:parser-include-string instead.")); + " Use ly:parser-include-string instead.")); else parser->parse_string (ly_scm2string (ly_code)); @@ -210,9 +209,9 @@ LY_DEFINE (ly_parser_parse_string, "ly:parser-parse-string", } LY_DEFINE (ly_parser_include_string, "ly:parser-include-string", - 2, 0, 0, (SCM parser_smob, SCM ly_code), - "Include the string @var{ly-code} into the input stream" - " for @var{parser-smob}.") + 2, 0, 0, (SCM parser_smob, SCM ly_code), + "Include the string @var{ly-code} into the input stream" + " for @var{parser-smob}.") { LY_ASSERT_SMOB (Lily_parser, parser_smob, 1); Lily_parser *parser = unsmob_lily_parser (parser_smob); @@ -224,10 +223,10 @@ LY_DEFINE (ly_parser_include_string, "ly:parser-include-string", } LY_DEFINE (ly_parser_set_note_names, "ly:parser-set-note-names", - 2, 0, 0, (SCM parser, SCM names), - "Replace current note names in @var{parser}." - " @var{names} is an alist of symbols. This only has effect" - " if the current mode is notes.") + 2, 0, 0, (SCM parser, SCM names), + "Replace current note names in @var{parser}." + " @var{names} is an alist of symbols. This only has effect" + " if the current mode is notes.") { LY_ASSERT_SMOB (Lily_parser, parser, 1); Lily_parser *p = unsmob_lily_parser (parser); @@ -268,8 +267,8 @@ LY_DEFINE (ly_parser_set_repetition_function, "ly:parser-set-repetition-function } LY_DEFINE (ly_parser_output_name, "ly:parser-output-name", - 1, 0, 0, (SCM parser), - "Return the base name of the output file.") + 1, 0, 0, (SCM parser), + "Return the base name of the output file.") { LY_ASSERT_SMOB (Lily_parser, parser, 1); Lily_parser *p = unsmob_lily_parser (parser); @@ -278,8 +277,8 @@ LY_DEFINE (ly_parser_output_name, "ly:parser-output-name", } LY_DEFINE (ly_parser_error, "ly:parser-error", - 2, 1, 0, (SCM parser, SCM msg, SCM input), - "Display an error message and make the parser fail.") + 2, 1, 0, (SCM parser, SCM msg, SCM input), + "Display an error message and make the parser fail.") { LY_ASSERT_SMOB (Lily_parser, parser, 1); Lily_parser *p = unsmob_lily_parser (parser); @@ -297,13 +296,12 @@ LY_DEFINE (ly_parser_error, "ly:parser-error", } LY_DEFINE (ly_parser_clear_error, "ly:parser-clear-error", - 1, 0, 0, (SCM parser), - "Clear the error flag for the parser.") + 1, 0, 0, (SCM parser), + "Clear the error flag for the parser.") { LY_ASSERT_SMOB (Lily_parser, parser, 1); Lily_parser *p = unsmob_lily_parser (parser); - p->error_level_ = 0; p->lexer_->error_level_ = 0; @@ -311,8 +309,8 @@ LY_DEFINE (ly_parser_clear_error, "ly:parser-clear-error", } LY_DEFINE (ly_parser_has_error_p, "ly:parser-has-error?", - 1, 0, 0, (SCM parser), - "Does @var{parser} have an error flag?") + 1, 0, 0, (SCM parser), + "Does @var{parser} have an error flag?") { LY_ASSERT_SMOB (Lily_parser, parser, 1); Lily_parser *p = unsmob_lily_parser (parser); diff --git a/lily/lily-parser.cc b/lily/lily-parser.cc index 2ee77b1e6d..ba3bd0f99b 100644 --- a/lily/lily-parser.cc +++ b/lily/lily-parser.cc @@ -72,7 +72,6 @@ Lily_parser::~Lily_parser () { } - SCM Lily_parser::mark_smob (SCM s) { @@ -81,7 +80,7 @@ Lily_parser::mark_smob (SCM s) } int -Lily_parser::print_smob (SCM s, SCM port, scm_print_state*) +Lily_parser::print_smob (SCM s, SCM port, scm_print_state *) { scm_puts ("#<Lily_parser ", port); Lily_parser *parser = (Lily_parser *) SCM_CELL_WORD_1 (s); @@ -124,7 +123,7 @@ Lily_parser::parse_file (string init, string name, string out_name) Don't mix cyclic pointers with weak tables. */ lexer_->set_identifier (ly_symbol2scm ("parser"), - SCM_EOL); + SCM_EOL); ly_reexport_module (scm_current_module ()); scm_set_current_module (mod); @@ -144,7 +143,7 @@ Lily_parser::parse_string (string ly_code) { // TODO: use $parser lexer_->set_identifier (ly_symbol2scm ("parser"), - self_scm ()); + self_scm ()); lexer_->main_input_name_ = "<string>"; lexer_->is_main_input_ = true; @@ -157,8 +156,8 @@ Lily_parser::parse_string (string ly_code) if (!define_spots_.empty ()) { if (define_spots_.empty () - && !error_level_) - programming_error ("define_spots_ don't match, but error_level_ not set."); + && !error_level_) + programming_error ("define_spots_ don't match, but error_level_ not set."); } error_level_ = error_level_ | lexer_->error_level_; @@ -176,7 +175,7 @@ Lily_parser::clear () if (lexer_) { while (lexer_->has_scope ()) - lexer_->remove_scope (); + lexer_->remove_scope (); } lexer_ = 0; @@ -202,13 +201,10 @@ Lily_parser::parser_error (Input const &i, string s) error_level_ = 1; } - - IMPLEMENT_SMOBS (Lily_parser); IMPLEMENT_TYPE_P (Lily_parser, "ly:lily-parser?"); IMPLEMENT_DEFAULT_EQUAL_P (Lily_parser); - /**************************************************************** OUTPUT-DEF ****************************************************************/ @@ -240,8 +236,8 @@ Output_def * get_paper (Lily_parser *parser) { SCM papers = parser->lexer_->lookup_identifier ("$papers"); - Output_def *layout = ((papers == SCM_UNDEFINED) || scm_is_null (papers)) ? - 0 : unsmob_output_def (scm_car (papers)); + Output_def *layout = ((papers == SCM_UNDEFINED) || scm_is_null (papers)) + ? 0 : unsmob_output_def (scm_car (papers)); SCM default_paper = parser->lexer_->lookup_identifier ("$defaultpaper"); layout = layout ? layout : unsmob_output_def (default_paper); diff --git a/lily/lilypond-version.cc b/lily/lilypond-version.cc index e7b686a208..8db2b47440 100644 --- a/lily/lilypond-version.cc +++ b/lily/lilypond-version.cc @@ -32,10 +32,10 @@ Lilypond_version::Lilypond_version (int major, int minor, int patch) Lilypond_version::Lilypond_version (string str) { - major_ = 0; + major_ = 0; minor_ = 0; patch_ = 0; - + vector<string> version; version = string_split (str, '.'); @@ -43,7 +43,7 @@ Lilypond_version::Lilypond_version (string str) major_ = String_convert::dec2int (version[0]); if (version.size () > 1 && isdigit (version[1][0])) minor_ = String_convert::dec2int (version[1]); - + patch_ = 0; if (version.size () >= 3 && isdigit (version[2][0])) @@ -57,8 +57,8 @@ string Lilypond_version::to_string () const { return ::to_string (major_) - + "." + ::to_string (minor_) - + "." + ::to_string (patch_); + + "." + ::to_string (minor_) + + "." + ::to_string (patch_); } Lilypond_version::operator int () const diff --git a/lily/line-interface.cc b/lily/line-interface.cc index ebbd62ef4f..991225f517 100644 --- a/lily/line-interface.cc +++ b/lily/line-interface.cc @@ -27,8 +27,8 @@ Stencil Line_interface::make_arrow (Offset begin, Offset end, - Real thick, - Real length, Real width) + Real thick, + Real length, Real width) { Real angle = (end - begin).arg (); vector<Offset> points; @@ -45,8 +45,8 @@ Line_interface::make_arrow (Offset begin, Offset end, Stencil Line_interface::make_trill_line (Grob *me, - Offset from, - Offset to) + Offset from, + Offset to) { Offset dz = (to - from); @@ -60,7 +60,7 @@ Line_interface::make_trill_line (Grob *me, programming_error ("can't find scripts.trill_element"); return Stencil (); } - + Stencil line; Real len = 0.0; do @@ -73,19 +73,18 @@ Line_interface::make_trill_line (Grob *me, line.rotate (dz.arg (), Offset (LEFT, CENTER)); line.translate (from); - return line; + return line; } - Stencil Line_interface::make_zigzag_line (Grob *me, - Offset from, - Offset to) + Offset from, + Offset to) { Offset dz = to - from; Real thick = Staff_symbol_referencer::line_thickness (me); - thick *= robust_scm2double (me->get_property ("thickness"), 1.0); // todo: staff sym referencer? + thick *= robust_scm2double (me->get_property ("thickness"), 1.0); // todo: staff sym referencer? Real staff_space = Staff_symbol_referencer::staff_space (me); @@ -119,23 +118,22 @@ Line_interface::make_zigzag_line (Grob *me, return total; } - Stencil Line_interface::make_dashed_line (Real thick, Offset from, Offset to, - Real dash_period, Real dash_fraction) + Real dash_period, Real dash_fraction) { dash_fraction = min (max (dash_fraction, 0.0), 1.0); Real on = dash_fraction * dash_period + thick; Real off = max (0.0, dash_period - on); SCM at = scm_list_n (ly_symbol2scm ("dashed-line"), - scm_from_double (thick), - scm_from_double (on), - scm_from_double (off), - scm_from_double (to[X_AXIS] - from[X_AXIS]), - scm_from_double (to[Y_AXIS] - from[Y_AXIS]), - scm_from_double (0.0), - SCM_UNDEFINED); + scm_from_double (thick), + scm_from_double (on), + scm_from_double (off), + scm_from_double (to[X_AXIS] - from[X_AXIS]), + scm_from_double (to[Y_AXIS] - from[Y_AXIS]), + scm_from_double (0.0), + SCM_UNDEFINED); Box box; box.add_point (Offset (0, 0)); @@ -153,12 +151,12 @@ Stencil Line_interface::make_line (Real th, Offset from, Offset to) { SCM at = scm_list_n (ly_symbol2scm ("draw-line"), - scm_from_double (th), - scm_from_double (from[X_AXIS]), - scm_from_double (from[Y_AXIS]), - scm_from_double (to[X_AXIS]), - scm_from_double (to[Y_AXIS]), - SCM_UNDEFINED); + scm_from_double (th), + scm_from_double (from[X_AXIS]), + scm_from_double (from[Y_AXIS]), + scm_from_double (to[X_AXIS]), + scm_from_double (to[Y_AXIS]), + SCM_UNDEFINED); Box box; box.add_point (from); @@ -172,24 +170,24 @@ Line_interface::make_line (Real th, Offset from, Offset to) Stencil Line_interface::arrows (Grob *me, Offset from, Offset to, - bool from_arrow, - bool to_arrow) + bool from_arrow, + bool to_arrow) { Stencil a; if (from_arrow || to_arrow) { Real thick = Staff_symbol_referencer::line_thickness (me) - * robust_scm2double (me->get_property ("thickness"), 1); + * robust_scm2double (me->get_property ("thickness"), 1); Real ss = Staff_symbol_referencer::staff_space (me); Real len = robust_scm2double (me->get_property ("arrow-length"), 1.3 * ss); Real wid = robust_scm2double (me->get_property ("arrow-width"), 0.5 * ss); if (to_arrow) - a.add_stencil (make_arrow (from, to, thick, len, wid)); + a.add_stencil (make_arrow (from, to, thick, len, wid)); if (from_arrow) - a.add_stencil (make_arrow (to, from, thick, len, wid)); + a.add_stencil (make_arrow (to, from, thick, len, wid)); } return a; @@ -199,7 +197,7 @@ Stencil Line_interface::line (Grob *me, Offset from, Offset to) { Real thick = Staff_symbol_referencer::line_thickness (me) - * robust_scm2double (me->get_property ("thickness"), 1); + * robust_scm2double (me->get_property ("thickness"), 1); SCM type = me->get_property ("style"); if (type == ly_symbol2scm ("zigzag")) @@ -208,36 +206,36 @@ Line_interface::line (Grob *me, Offset from, Offset to) return make_trill_line (me, from, to); else if (type == ly_symbol2scm ("none")) return Stencil (); - + Stencil stencil; if (type == ly_symbol2scm ("dashed-line") || type == ly_symbol2scm ("dotted-line")) { Real fraction - = type == ly_symbol2scm ("dotted-line") - ? 0.0 - : robust_scm2double (me->get_property ("dash-fraction"), 0.4); + = type == ly_symbol2scm ("dotted-line") + ? 0.0 + : robust_scm2double (me->get_property ("dash-fraction"), 0.4); fraction = min (max (fraction, 0.0), 1.0); Real period = Staff_symbol_referencer::staff_space (me) - * robust_scm2double (me->get_property ("dash-period"), 1.0); + * robust_scm2double (me->get_property ("dash-period"), 1.0); if (period <= 0) - return Stencil (); + return Stencil (); Real len = (to - from).length (); - + int n = (int) rint ((len - period * fraction) / period); n = max (0, n); if (n > 0) - { - /* - TODO: figure out something intelligent for really short - sections. - */ - period = ((to - from).length () - period * fraction) / n; - } + { + /* + TODO: figure out something intelligent for really short + sections. + */ + period = ((to - from).length () - period * fraction) / n; + } stencil = make_dashed_line (thick, from, to, period, fraction); } else @@ -247,22 +245,22 @@ Line_interface::line (Grob *me, Offset from, Offset to) } ADD_INTERFACE (Line_interface, - "Generic line objects. Any object using lines supports this." - " The property @code{style} can be @code{line}," - " @code{dashed-line}, @code{trill}, @code{dotted-line}," - " @code{zigzag} or @code{none} (a transparent line).\n" - "\n" - "For @code{dashed-line}, the length of the dashes is tuned" - " with @code{dash-fraction}. If the latter is set to@tie{}0, a" - " dotted line is produced.", - - /* properties */ - "arrow-length " - "arrow-width " - "dash-fraction " - "dash-period " - "style " - "thickness " - "zigzag-length " - "zigzag-width " - ); + "Generic line objects. Any object using lines supports this." + " The property @code{style} can be @code{line}," + " @code{dashed-line}, @code{trill}, @code{dotted-line}," + " @code{zigzag} or @code{none} (a transparent line).\n" + "\n" + "For @code{dashed-line}, the length of the dashes is tuned" + " with @code{dash-fraction}. If the latter is set to@tie{}0, a" + " dotted line is produced.", + + /* properties */ + "arrow-length " + "arrow-width " + "dash-fraction " + "dash-period " + "style " + "thickness " + "zigzag-length " + "zigzag-width " + ); diff --git a/lily/line-spanner.cc b/lily/line-spanner.cc index d55c01ff45..b2877211f1 100644 --- a/lily/line-spanner.cc +++ b/lily/line-spanner.cc @@ -63,17 +63,17 @@ Line_spanner::calc_bound_info (SCM smob, Direction dir) SCM details = SCM_BOOL_F; if (details == SCM_BOOL_F) details = ly_assoc_get ((dir == LEFT) - ? ly_symbol2scm ("left") - : ly_symbol2scm ("right"), bound_details, SCM_BOOL_F); + ? ly_symbol2scm ("left") + : ly_symbol2scm ("right"), bound_details, SCM_BOOL_F); if (me->get_bound (dir)->break_status_dir ()) { SCM extra = ly_assoc_get ((dir == LEFT) - ? ly_symbol2scm ("left-broken") - : ly_symbol2scm ("right-broken"), bound_details, SCM_EOL); + ? ly_symbol2scm ("left-broken") + : ly_symbol2scm ("right-broken"), bound_details, SCM_EOL); for (SCM s = scm_reverse (extra); scm_is_pair (s); s = scm_cdr (s)) - details = scm_cons (scm_car (s), details); + details = scm_cons (scm_car (s), details); } if (details == SCM_BOOL_F) @@ -85,107 +85,106 @@ Line_spanner::calc_bound_info (SCM smob, Direction dir) Output_def *layout = me->layout (); SCM properties = Font_interface::text_font_alist_chain (me); details = scm_acons (ly_symbol2scm ("stencil"), - Text_interface::interpret_markup (layout->self_scm (), - properties, text), - details); + Text_interface::interpret_markup (layout->self_scm (), + properties, text), + details); } if (!scm_is_number (ly_assoc_get (ly_symbol2scm ("X"), details, SCM_BOOL_F))) { Direction attach = (Direction) - robust_scm2int (ly_assoc_get (ly_symbol2scm ("attach-dir"), - details, SCM_BOOL_F), - CENTER); + robust_scm2int (ly_assoc_get (ly_symbol2scm ("attach-dir"), + details, SCM_BOOL_F), + CENTER); Item *bound_item = me->get_bound (dir); Grob *bound_grob = bound_item; if (to_boolean (ly_assoc_get (ly_symbol2scm ("end-on-note"), details, SCM_BOOL_F)) - && bound_item->break_status_dir ()) - { - extract_grob_set (me, "note-columns", columns); - if (columns.size ()) - bound_grob = (dir == LEFT) - ? columns[0] : columns.back(); - } + && bound_item->break_status_dir ()) + { + extract_grob_set (me, "note-columns", columns); + if (columns.size ()) + bound_grob = (dir == LEFT) + ? columns[0] : columns.back (); + } details = scm_acons (ly_symbol2scm ("X"), - scm_from_double (robust_relative_extent (bound_grob, commonx, X_AXIS) - .linear_combination (attach)), - details); + scm_from_double (robust_relative_extent (bound_grob, commonx, X_AXIS) + .linear_combination (attach)), + details); } - if (!scm_is_number (ly_assoc_get (ly_symbol2scm ("Y"), details, SCM_BOOL_F))) { Real y = 0.0; Real extra_dy = robust_scm2double (me->get_property ("extra-dy"), - 0.0); + 0.0); Grob *common_y = me->common_refpoint (me->get_bound (dir), Y_AXIS); if (me->get_bound (dir)->break_status_dir ()) - { - if (to_boolean (me->get_property ("simple-Y"))) - { - Spanner *orig = dynamic_cast<Spanner *>(me->original ()); - Spanner *extreme = dir == LEFT ? orig->broken_intos_.front () : orig->broken_intos_.back (); - Grob *e_bound = extreme->get_bound (dir); + { + if (to_boolean (me->get_property ("simple-Y"))) + { + Spanner *orig = dynamic_cast<Spanner *>(me->original ()); + Spanner *extreme = dir == LEFT ? orig->broken_intos_.front () : orig->broken_intos_.back (); + Grob *e_bound = extreme->get_bound (dir); Grob *e_common_y = extreme->common_refpoint (e_bound, Y_AXIS); y = e_bound->extent (e_common_y, Y_AXIS).center (); - } + } else { - Spanner *next_sp = me->broken_neighbor (dir); - Item *next_bound = next_sp->get_bound (dir); - - if (next_bound->break_status_dir ()) - { - programming_error ("no note heads for the line spanner on neighbor line?" - " Confused."); - me->suicide (); - return SCM_EOL; - } - - Spanner *next_bound_parent = parent_spanner (next_bound); - Interval next_ext = next_bound->extent (next_bound_parent, Y_AXIS); - - /* - We want to know what would be the y-position of the next - bound (relative to my y-parent) if it belonged to the - same system as this bound. We rely on the fact that the - y-parent of the next bound is a spanner (probably the - VerticalAxisGroup of a staff) that extends over the break. - */ - Spanner *next_bound_parent_on_this_line = - next_bound_parent->broken_neighbor (other_dir (dir)); - - if (next_bound_parent_on_this_line) - { - Grob *common = me->common_refpoint (next_bound_parent_on_this_line, Y_AXIS); - Real bound_offset = next_bound_parent_on_this_line->relative_coordinate (common, Y_AXIS); - y = next_ext.center () + bound_offset - me->relative_coordinate (common, Y_AXIS); - } - else - { - /* - We fall back to assuming that the distance between - staves doesn't change over line breaks. - */ - programming_error ("next-bound's parent doesn't extend to this line"); - Grob *next_system = next_bound->get_system (); - Grob *this_system = me->get_system (); - y = next_ext.center () + next_bound_parent->relative_coordinate (next_system, Y_AXIS) - - me->relative_coordinate (this_system, Y_AXIS); - } + Spanner *next_sp = me->broken_neighbor (dir); + Item *next_bound = next_sp->get_bound (dir); + + if (next_bound->break_status_dir ()) + { + programming_error ("no note heads for the line spanner on neighbor line?" + " Confused."); + me->suicide (); + return SCM_EOL; + } + + Spanner *next_bound_parent = parent_spanner (next_bound); + Interval next_ext = next_bound->extent (next_bound_parent, Y_AXIS); + + /* + We want to know what would be the y-position of the next + bound (relative to my y-parent) if it belonged to the + same system as this bound. We rely on the fact that the + y-parent of the next bound is a spanner (probably the + VerticalAxisGroup of a staff) that extends over the break. + */ + Spanner *next_bound_parent_on_this_line + = next_bound_parent->broken_neighbor (other_dir (dir)); + + if (next_bound_parent_on_this_line) + { + Grob *common = me->common_refpoint (next_bound_parent_on_this_line, Y_AXIS); + Real bound_offset = next_bound_parent_on_this_line->relative_coordinate (common, Y_AXIS); + y = next_ext.center () + bound_offset - me->relative_coordinate (common, Y_AXIS); + } + else + { + /* + We fall back to assuming that the distance between + staves doesn't change over line breaks. + */ + programming_error ("next-bound's parent doesn't extend to this line"); + Grob *next_system = next_bound->get_system (); + Grob *this_system = me->get_system (); + y = next_ext.center () + next_bound_parent->relative_coordinate (next_system, Y_AXIS) + - me->relative_coordinate (this_system, Y_AXIS); + } } - } + } else - { - y = me->get_bound (dir)->extent (common_y, Y_AXIS).center (); - details = scm_acons (ly_symbol2scm ("common-Y"), common_y->self_scm (), details); - } + { + y = me->get_bound (dir)->extent (common_y, Y_AXIS).center (); + details = scm_acons (ly_symbol2scm ("common-Y"), common_y->self_scm (), details); + } - y += dir * extra_dy / 2; + y += dir * extra_dy / 2; details = scm_acons (ly_symbol2scm ("Y"), scm_from_double (y), details); } @@ -221,9 +220,9 @@ Line_spanner::calc_left_bound_info_and_text (SCM smob) Output_def *layout = me->layout (); SCM properties = Font_interface::text_font_alist_chain (me); alist = scm_acons (ly_symbol2scm ("stencil"), - Text_interface::interpret_markup (layout->self_scm (), - properties, text), - alist); + Text_interface::interpret_markup (layout->self_scm (), + properties, text), + alist); } return alist; @@ -239,20 +238,20 @@ Line_spanner::print (SCM smob) bool simple_y = to_boolean (me->get_property ("simple-Y")) && !to_boolean (me->get_property ("cross-staff")); Drul_array<SCM> bounds (me->get_property ("left-bound-info"), - me->get_property ("right-bound-info")); + me->get_property ("right-bound-info")); Grob *commonx = me->get_bound (LEFT)->common_refpoint (me->get_bound (RIGHT), X_AXIS); commonx = me->common_refpoint (commonx, X_AXIS); Drul_array<Offset> span_points; - Direction d = LEFT; + Direction d = LEFT; do { Offset z (robust_scm2double (ly_assoc_get (ly_symbol2scm ("X"), - bounds[d], SCM_BOOL_F), 0.0), - robust_scm2double (ly_assoc_get (ly_symbol2scm ("Y"), - bounds[d], SCM_BOOL_F), 0.0)); + bounds[d], SCM_BOOL_F), 0.0), + robust_scm2double (ly_assoc_get (ly_symbol2scm ("Y"), + bounds[d], SCM_BOOL_F), 0.0)); span_points[d] = z; } @@ -260,7 +259,7 @@ Line_spanner::print (SCM smob) Drul_array<Real> gaps (0, 0); Drul_array<bool> arrows (0, 0); - Drul_array<Stencil *> stencils (0,0); + Drul_array<Stencil *> stencils (0, 0); Drul_array<Grob *> common_y (0, 0); // For scaling of 'padding and 'stencil-offset @@ -270,15 +269,15 @@ Line_spanner::print (SCM smob) do { gaps[d] = robust_scm2double (ly_assoc_get (ly_symbol2scm ("padding"), - bounds[d], SCM_BOOL_F), 0.0); + bounds[d], SCM_BOOL_F), 0.0); arrows[d] = to_boolean (ly_assoc_get (ly_symbol2scm ("arrow"), - bounds[d], SCM_BOOL_F)); + bounds[d], SCM_BOOL_F)); stencils[d] = unsmob_stencil (ly_assoc_get (ly_symbol2scm ("stencil"), - bounds[d], SCM_BOOL_F)); + bounds[d], SCM_BOOL_F)); common_y[d] = unsmob_grob (ly_assoc_get (ly_symbol2scm ("common-Y"), - bounds[d], SCM_BOOL_F)); + bounds[d], SCM_BOOL_F)); if (!common_y[d]) - common_y[d] = me; + common_y[d] = me; } while (flip (&d) != LEFT); @@ -310,66 +309,65 @@ Line_spanner::print (SCM smob) span_points[d] += -d * gaps[d] * magstep * dz.direction (); if (stencils[d]) - { - Stencil s = stencils[d]->translated (span_points[d]); - SCM align = ly_assoc_get (ly_symbol2scm ("stencil-align-dir-y"), - bounds[d], SCM_BOOL_F); - SCM off = ly_assoc_get (ly_symbol2scm ("stencil-offset"), - bounds[d], SCM_BOOL_F); + { + Stencil s = stencils[d]->translated (span_points[d]); + SCM align = ly_assoc_get (ly_symbol2scm ("stencil-align-dir-y"), + bounds[d], SCM_BOOL_F); + SCM off = ly_assoc_get (ly_symbol2scm ("stencil-offset"), + bounds[d], SCM_BOOL_F); - if (scm_is_number (align)) - s.align_to (Y_AXIS, scm_to_double (align)); + if (scm_is_number (align)) + s.align_to (Y_AXIS, scm_to_double (align)); - if (is_number_pair (off)) - s.translate (ly_scm2offset (off) * magstep); + if (is_number_pair (off)) + s.translate (ly_scm2offset (off) * magstep); - line.add_stencil (s); - } + line.add_stencil (s); + } } while (flip (&d) != LEFT); do { if (stencils[d]) - span_points[d] += dz_dir * - (stencils[d]->extent (X_AXIS)[-d] / dz_dir[X_AXIS]); + span_points[d] += dz_dir * + (stencils[d]->extent (X_AXIS)[-d] / dz_dir[X_AXIS]); } while (flip (&d) != LEFT); - Offset adjust = dz.direction() * Staff_symbol_referencer::staff_space (me); + Offset adjust = dz.direction () * Staff_symbol_referencer::staff_space (me); - Offset line_left = span_points[LEFT] + (arrows[LEFT] ? adjust*1.4 : Offset (0, 0)); - Offset line_right = span_points[RIGHT] - (arrows[RIGHT] ? adjust*0.55 : Offset (0, 0)); + Offset line_left = span_points[LEFT] + (arrows[LEFT] ? adjust * 1.4 : Offset (0, 0)); + Offset line_right = span_points[RIGHT] - (arrows[RIGHT] ? adjust * 0.55 : Offset (0, 0)); if (line_right[X_AXIS] > line_left[X_AXIS]) { line.add_stencil (Line_interface::line (me, line_left, line_right)); line.add_stencil (Line_interface::arrows (me, - span_points[LEFT], - span_points[RIGHT], - arrows[LEFT], - arrows[RIGHT])); + span_points[LEFT], + span_points[RIGHT], + arrows[LEFT], + arrows[RIGHT])); } line.translate (Offset (-me->relative_coordinate (commonx, X_AXIS), - simple_y ? 0.0 : -me->relative_coordinate (my_common_y, Y_AXIS))); - + simple_y ? 0.0 : -me->relative_coordinate (my_common_y, Y_AXIS))); return line.smobbed_copy (); } ADD_INTERFACE (Line_spanner, - "Generic line drawn between two objects, e.g., for use with" - " glissandi.", - - /* properties */ - "bound-details " - "extra-dy " - "gap " - "left-bound-info " - "note-columns " - "right-bound-info " - "simple-Y " - "thickness " - "to-barline " - ); + "Generic line drawn between two objects, e.g., for use with" + " glissandi.", + + /* properties */ + "bound-details " + "extra-dy " + "gap " + "left-bound-info " + "note-columns " + "right-bound-info " + "simple-Y " + "thickness " + "to-barline " + ); diff --git a/lily/listener.cc b/lily/listener.cc index 686ee3ad67..c785ff3d72 100644 --- a/lily/listener.cc +++ b/lily/listener.cc @@ -36,10 +36,11 @@ Listener::Listener (const void *target, Listener_function_table *type) Listener::Listener (Listener const &other) { target_ = other.target_; - type_ = other.type_; + type_ = other.type_; } -void Listener::listen (SCM ev) const { +void Listener::listen (SCM ev) const +{ (type_->listen_callback) (target_, ev); } @@ -53,7 +54,7 @@ Listener::mark_smob (SCM sm) } int -Listener::print_smob (SCM, SCM p, scm_print_state*) +Listener::print_smob (SCM, SCM p, scm_print_state *) { scm_puts ("#<Listener>", p); return 1; diff --git a/lily/lookup.cc b/lily/lookup.cc index aec43fe8fb..1bdc738214 100644 --- a/lily/lookup.cc +++ b/lily/lookup.cc @@ -37,10 +37,10 @@ Stencil Lookup::dot (Offset p, Real radius) { SCM at = (scm_list_n (ly_symbol2scm ("dot"), - scm_from_double (p[X_AXIS]), - scm_from_double (p[Y_AXIS]), - scm_from_double (radius), - SCM_UNDEFINED)); + scm_from_double (p[X_AXIS]), + scm_from_double (p[Y_AXIS]), + scm_from_double (radius), + SCM_UNDEFINED)); Box box; box.add_point (p - Offset (radius, radius)); box.add_point (p + Offset (radius, radius)); @@ -61,38 +61,38 @@ Lookup::beam (Real slope, Real width, Real thick, Real blot) SCM points = SCM_EOL; points = scm_cons (scm_from_double (p[X_AXIS]), - scm_cons (scm_from_double (p[Y_AXIS]), - points)); + scm_cons (scm_from_double (p[Y_AXIS]), + points)); p = Offset (0, -thick / 2); b.add_point (p); p += Offset (1, 1) * (blot / 2); points = scm_cons (scm_from_double (p[X_AXIS]), - scm_cons (scm_from_double (p[Y_AXIS]), - points)); + scm_cons (scm_from_double (p[Y_AXIS]), + points)); p = Offset (width, width * slope - thick / 2); b.add_point (p); p += Offset (-1, 1) * (blot / 2); points = scm_cons (scm_from_double (p[X_AXIS]), - scm_cons (scm_from_double (p[Y_AXIS]), - points)); + scm_cons (scm_from_double (p[Y_AXIS]), + points)); p = Offset (width, width * slope + thick / 2); b.add_point (p); p += Offset (-1, -1) * (blot / 2); points = scm_cons (scm_from_double (p[X_AXIS]), - scm_cons (scm_from_double (p[Y_AXIS]), - points)); + scm_cons (scm_from_double (p[Y_AXIS]), + points)); SCM expr = scm_list_n (ly_symbol2scm ("polygon"), - ly_quote_scm (points), - scm_from_double (blot), - SCM_BOOL_T, - SCM_UNDEFINED); + ly_quote_scm (points), + scm_from_double (blot), + SCM_BOOL_T, + SCM_UNDEFINED); return Stencil (b, expr); } @@ -103,9 +103,9 @@ Lookup::rotated_box (Real slope, Real width, Real thick, Real blot) vector<Offset> pts; Offset rot (1, slope); - thick -= 2*blot; - width -= 2*blot; - rot /= sqrt (1 + slope*slope); + thick -= 2 * blot; + width -= 2 * blot; + rot /= sqrt (1 + slope * slope); pts.push_back (Offset (0, -thick / 2) * rot); pts.push_back (Offset (width, -thick / 2) * rot); pts.push_back (Offset (width, thick / 2) * rot); @@ -117,12 +117,12 @@ Stencil Lookup::horizontal_line (Interval w, Real th) { SCM at = scm_list_n (ly_symbol2scm ("draw-line"), - scm_from_double (th), - scm_from_double (w[LEFT]), - scm_from_double (0), - scm_from_double (w[RIGHT]), - scm_from_double (0), - SCM_UNDEFINED); + scm_from_double (th), + scm_from_double (w[LEFT]), + scm_from_double (0), + scm_from_double (w[RIGHT]), + scm_from_double (0), + SCM_UNDEFINED); Box box; box[X_AXIS] = w; @@ -179,12 +179,12 @@ Lookup::round_filled_box (Box b, Real blotdiameter) blotdiameter = b.y ().length (); SCM at = (scm_list_n (ly_symbol2scm ("round-filled-box"), - scm_from_double (-b[X_AXIS][LEFT]), - scm_from_double (b[X_AXIS][RIGHT]), - scm_from_double (-b[Y_AXIS][DOWN]), - scm_from_double (b[Y_AXIS][UP]), - scm_from_double (blotdiameter), - SCM_UNDEFINED)); + scm_from_double (-b[X_AXIS][LEFT]), + scm_from_double (b[X_AXIS][RIGHT]), + scm_from_double (-b[Y_AXIS][DOWN]), + scm_from_double (b[Y_AXIS][UP]), + scm_from_double (blotdiameter), + SCM_UNDEFINED)); return Stencil (b, at); } @@ -231,7 +231,7 @@ Lookup::round_filled_box (Box b, Real blotdiameter) */ Stencil Lookup::round_filled_polygon (vector<Offset> const &points, - Real blotdiameter) + Real blotdiameter) { /* TODO: Maybe print a warning if one of the above limitations applies to the given polygon. However, this is quite complicated @@ -246,7 +246,7 @@ Lookup::round_filled_polygon (vector<Offset> const &points, int next = (i + 1) % points.size (); Real d = (points[i] - points[next]).length (); if (d < epsilon) - programming_error ("Polygon should not have duplicate points"); + programming_error ("Polygon should not have duplicate points"); } #endif @@ -273,17 +273,18 @@ Lookup::round_filled_polygon (vector<Offset> const &points, Offset p10 = p0 - p1; Offset p12 = p2 - p1; if (p10.length () != 0.0) - { // recompute ccw - Real phi = p10.arg (); - // rotate (p2 - p0) by (-phi) - Offset q = complex_multiply (p2 - p0, complex_exp (Offset (1.0, -phi))); - - if (q[Y_AXIS] > 0) - ccw = 1; - else if (q[Y_AXIS] < 0) - ccw = 0; - else {} // keep ccw unchanged - } + { + // recompute ccw + Real phi = p10.arg (); + // rotate (p2 - p0) by (-phi) + Offset q = complex_multiply (p2 - p0, complex_exp (Offset (1.0, -phi))); + + if (q[Y_AXIS] > 0) + ccw = 1; + else if (q[Y_AXIS] < 0) + ccw = 0; + else {} // keep ccw unchanged + } else {} // keep ccw unchanged Offset p10n = (1.0 / p10.length ()) * p10; // normalize length to 1.0 Offset p12n = (1.0 / p12.length ()) * p12; @@ -292,15 +293,15 @@ Lookup::round_filled_polygon (vector<Offset> const &points, Offset p13; Real d = p13n.length () * p14n.length (); // distance p3n to line (p1..p0) if (d < epsilon) - // special case: p0, p1, p2 are on a single line => build - // vector orthogonal to (p2-p0) of length 0.5 blotdiameter - { - p13[X_AXIS] = p10[Y_AXIS]; - p13[Y_AXIS] = -p10[X_AXIS]; - p13 = (0.5 * blotdiameter / p13.length ()) * p13; - } + // special case: p0, p1, p2 are on a single line => build + // vector orthogonal to (p2-p0) of length 0.5 blotdiameter + { + p13[X_AXIS] = p10[Y_AXIS]; + p13[Y_AXIS] = -p10[X_AXIS]; + p13 = (0.5 * blotdiameter / p13.length ()) * p13; + } else - p13 = (0.5 * blotdiameter / d) * p13n; + p13 = (0.5 * blotdiameter / d) * p13n; shrunk_points[i1] = p1 + ((ccw) ? p13 : -p13); } @@ -315,10 +316,10 @@ Lookup::round_filled_polygon (vector<Offset> const &points, box.add_point (points[i]); } SCM polygon_scm = scm_list_n (ly_symbol2scm ("polygon"), - ly_quote_scm (shrunk_points_scm), - scm_from_double (blotdiameter), - SCM_BOOL_T, - SCM_UNDEFINED); + ly_quote_scm (shrunk_points_scm), + scm_from_double (blotdiameter), + SCM_BOOL_T, + SCM_UNDEFINED); Stencil polygon = Stencil (box, polygon_scm); shrunk_points.clear (); @@ -335,16 +336,16 @@ Lookup::frame (Box b, Real thick, Real blot) Direction d = LEFT; for (Axis a = X_AXIS; a < NO_AXES; a = Axis (a + 1)) { - Axis o = Axis ((a + 1)%NO_AXES); + Axis o = Axis ((a + 1) % NO_AXES); do - { - Box edges; - edges[a] = b[a][d] + 0.5 * thick * Interval (-1, 1); - edges[o][DOWN] = b[o][DOWN] - thick / 2; - edges[o][UP] = b[o][UP] + thick / 2; - - m.add_stencil (round_filled_box (edges, blot)); - } + { + Box edges; + edges[a] = b[a][d] + 0.5 * thick * Interval (-1, 1); + edges[o][DOWN] = b[o][DOWN] - thick / 2; + edges[o][UP] = b[o][UP] + thick / 2; + + m.add_stencil (round_filled_box (edges, blot)); + } while (flip (&d) != LEFT); } return m; @@ -359,7 +360,7 @@ Lookup::slur (Bezier curve, Real curvethick, Real linethick, { Stencil return_value; - /* + /* calculate the offset for the two beziers that make the sandwich for the slur */ @@ -371,36 +372,36 @@ Lookup::slur (Bezier curve, Real curvethick, Real linethick, curve.control_[1] -= perp; curve.control_[2] -= perp; - + if (!scm_is_pair (dash_details)) - { + { /* solid slur */ return_value = bezier_sandwich (back, curve, linethick); } else - { + { /* dashed or combination slur */ int num_segments = scm_to_int (scm_length (dash_details)); - for (int i=0; i<num_segments; i++) + for (int i = 0; i < num_segments; i++) { SCM dash_pattern = scm_list_ref (dash_details, scm_from_int (i)); Real t_min = robust_scm2double (scm_car (dash_pattern), 0); Real t_max = robust_scm2double (scm_cadr (dash_pattern), 1.0); - Real dash_fraction = - robust_scm2double (scm_caddr (dash_pattern), 1.0); - Real dash_period = - robust_scm2double (scm_cadddr (dash_pattern), 0.75); + Real dash_fraction + = robust_scm2double (scm_caddr (dash_pattern), 1.0); + Real dash_period + = robust_scm2double (scm_cadddr (dash_pattern), 0.75); Bezier back_segment = back.extract (t_min, t_max); Bezier curve_segment = curve.extract (t_min, t_max); - if (dash_fraction == 1.0) - return_value.add_stencil (bezier_sandwich (back_segment, - curve_segment, - linethick)); + if (dash_fraction == 1.0) + return_value.add_stencil (bezier_sandwich (back_segment, + curve_segment, + linethick)); else { Bezier back_dash, curve_dash; - Real seg_length = (back_segment.control_[3] - - back_segment.control_[0]).length (); + Real seg_length = (back_segment.control_[3] + - back_segment.control_[0]).length (); int pattern_count = (int) (seg_length / dash_period); Real pattern_length = 1.0 / (pattern_count + dash_fraction); Real start_t, end_t; @@ -408,10 +409,10 @@ Lookup::slur (Bezier curve, Real curvethick, Real linethick, { start_t = p * pattern_length; end_t = (p + dash_fraction) * pattern_length; - back_dash = - back_segment.extract (start_t, end_t); - curve_dash = - curve_segment.extract (start_t, end_t); + back_dash + = back_segment.extract (start_t, end_t); + curve_dash + = curve_segment.extract (start_t, end_t); return_value.add_stencil (bezier_sandwich (back_dash, curve_dash, linethick)); @@ -422,7 +423,6 @@ Lookup::slur (Bezier curve, Real curvethick, Real linethick, return return_value; } - /* * Bezier Sandwich: * @@ -463,9 +463,9 @@ Lookup::bezier_sandwich (Bezier top_curve, Bezier bottom_curve, Real thickness) list = scm_cons (ly_offset2scm (top_curve.control_[1]), list); SCM horizontal_bend = scm_list_n (ly_symbol2scm ("bezier-sandwich"), - ly_quote_scm (list), - scm_from_double (thickness), - SCM_UNDEFINED); + ly_quote_scm (list), + scm_from_double (thickness), + SCM_UNDEFINED); Interval x_extent = top_curve.extent (X_AXIS); x_extent.unite (bottom_curve.extent (X_AXIS)); @@ -494,10 +494,10 @@ Lookup::repeat_slash (Real w, Real s, Real t) SCM sl = scm_from_double (s); SCM thick = scm_from_double (t); SCM slashnodot = scm_list_n (ly_symbol2scm ("repeat-slash"), - wid, sl, thick, SCM_UNDEFINED); + wid, sl, thick, SCM_UNDEFINED); Box b (Interval (0, w + sqrt (sqr (t / s) + sqr (t))), - Interval (0, w * s)); + Interval (0, w * s)); return Stencil (b, slashnodot); // http://slashnodot.org } @@ -506,7 +506,7 @@ Stencil Lookup::bracket (Axis a, Interval iv, Real thick, Real protrude, Real blot) { Box b; - Axis other = Axis ((a + 1)%2); + Axis other = Axis ((a + 1) % 2); b[a] = iv; b[other] = Interval (-1, 1) * thick * 0.5; @@ -540,20 +540,18 @@ Lookup::triangle (Interval iv, Real thick, Real protrude) } - - Stencil Lookup::points_to_line_stencil (Real thick, vector<Offset> const &points) { Stencil ret; for (vsize i = 1; i < points.size (); i++) { - if (points[i-1].is_sane () && points[i].is_sane ()) - { - Stencil line - = Line_interface::make_line (thick, points[i-1], points[i]); - ret.add_stencil (line); - } + if (points[i - 1].is_sane () && points[i].is_sane ()) + { + Stencil line + = Line_interface::make_line (thick, points[i - 1], points[i]); + ret.add_stencil (line); + } } return ret; } diff --git a/lily/ly-module.cc b/lily/ly-module.cc index 210c74293a..b964a56ade 100644 --- a/lily/ly-module.cc +++ b/lily/ly-module.cc @@ -23,8 +23,6 @@ #include "std-string.hh" #include "protected-scm.hh" - - SCM ly_make_module (bool safe) { @@ -36,17 +34,17 @@ ly_make_module (bool safe) SCM maker = ly_lily_module_constant ("make-module"); mod = scm_call_0 (maker); /* - Look up and call Guile module-export-all! or, when using - Guile V1.8, the compatible shim defined in lily.scm. + Look up and call Guile module-export-all! or, when using + Guile V1.8, the compatible shim defined in lily.scm. */ SCM module_export_all_x = ly_lily_module_constant ("module-export-all!"); scm_call_1 (module_export_all_x, mod); /* - Evaluate Guile module "the-root-module", - and ensure we inherit definitions from it and the "lily" module - N.B. this used to be "the-scm-module" and is deprecated in - Guile V1.9/2.0 + Evaluate Guile module "the-root-module", + and ensure we inherit definitions from it and the "lily" module + N.B. this used to be "the-scm-module" and is deprecated in + Guile V1.9/2.0 */ SCM scm_module = ly_lily_module_constant ("the-root-module"); ly_use_module (mod, scm_module); @@ -87,7 +85,6 @@ ly_use_module (SCM mod, SCM used) #define FUNC_NAME __FUNCTION__ - SCM ly_module_symbols (SCM mod) { @@ -99,9 +96,9 @@ ly_module_symbols (SCM mod) static SCM entry_to_alist (void * /* closure */, - SCM key, - SCM val, - SCM result) + SCM key, + SCM val, + SCM result) { if (scm_variable_bound_p (val) == SCM_BOOL_T) return scm_cons (scm_cons (key, scm_variable_ref (val)), result); @@ -110,14 +107,14 @@ entry_to_alist (void * /* closure */, } LY_DEFINE (ly_module_2_alist, "ly:module->alist", - 1, 0, 0, (SCM mod), - "Dump the contents of module @var{mod} as an alist.") + 1, 0, 0, (SCM mod), + "Dump the contents of module @var{mod} as an alist.") { SCM_VALIDATE_MODULE (1, mod); SCM obarr = SCM_MODULE_OBARRAY (mod); return scm_internal_hash_fold ((scm_t_hash_fold_fn) &entry_to_alist, - NULL, SCM_EOL, obarr); + NULL, SCM_EOL, obarr); } void diff --git a/lily/lyric-combine-music-iterator.cc b/lily/lyric-combine-music-iterator.cc index 0168da1500..a6de96f5d3 100644 --- a/lily/lyric-combine-music-iterator.cc +++ b/lily/lyric-combine-music-iterator.cc @@ -70,7 +70,7 @@ private: Moment busy_moment_; Moment pending_grace_moment_; - + Music_iterator *lyric_iter_; }; @@ -85,11 +85,10 @@ Lyric_combine_music_iterator::Lyric_combine_music_iterator () busy_moment_.set_infinite (-1); } - /* It's dubious whether we can ever make this fully work. Due to - associatedVoice switching, this routine may be triggered for - the wrong music_context_ + associatedVoice switching, this routine may be triggered for + the wrong music_context_ */ IMPLEMENT_LISTENER (Lyric_combine_music_iterator, set_busy) void @@ -99,10 +98,10 @@ Lyric_combine_music_iterator::set_busy (SCM se) if ((e->in_event_class ("note-event") || e->in_event_class ("cluster-note-event")) && music_context_) - + busy_moment_ = max (music_context_->now_mom (), - busy_moment_); - + busy_moment_); + } void @@ -111,14 +110,14 @@ Lyric_combine_music_iterator::set_music_context (Context *to) if (music_context_) { music_context_->event_source ()-> - remove_listener (GET_LISTENER (set_busy), ly_symbol2scm ("music-event")); + remove_listener (GET_LISTENER (set_busy), ly_symbol2scm ("music-event")); } music_context_ = to; if (to) { to->event_source ()->add_listener (GET_LISTENER (set_busy), - ly_symbol2scm ("music-event")); + ly_symbol2scm ("music-event")); } } @@ -135,7 +134,7 @@ Lyric_combine_music_iterator::start_new_syllable () const { bool m = melisma_busy (music_context_); if (m) - return false; + return false; } return true; @@ -193,13 +192,13 @@ Lyric_combine_music_iterator::construct_children () if (!lyric_iter_) return; lyrics_context_ = find_context_below (lyric_iter_->get_outlet (), - ly_symbol2scm ("Lyrics"), ""); + ly_symbol2scm ("Lyrics"), ""); if (!lyrics_context_) { m->origin ()->warning ("argument of \\lyricsto should contain Lyrics context"); } - + lyricsto_voice_name_ = get_music ()->get_property ("associated-context"); Context *voice = find_voice (); @@ -207,7 +206,7 @@ Lyric_combine_music_iterator::construct_children () set_music_context (voice); /* - Wait for a Create_context event. If this isn't done, lyrics can be + Wait for a Create_context event. If this isn't done, lyrics can be delayed when voices are created implicitly. */ Global_context *g = get_outlet ()->get_global_context (); @@ -225,8 +224,8 @@ void Lyric_combine_music_iterator::check_new_context (SCM sev) { if (!ok ()) - return ; - + return; + // Search for a possible candidate voice to attach the lyrics to. If none // is found, we'll try next time again. Context *voice = find_voice (); @@ -248,8 +247,8 @@ Lyric_combine_music_iterator::find_voice () { SCM voice_name = lyricsto_voice_name_; SCM running = lyrics_context_ - ? lyrics_context_->get_property ("associatedVoice") - : SCM_EOL; + ? lyrics_context_->get_property ("associatedVoice") + : SCM_EOL; if (scm_is_string (running)) voice_name = running; @@ -259,7 +258,7 @@ Lyric_combine_music_iterator::find_voice () { Context *t = get_outlet (); while (t && t->get_parent_context ()) - t = t->get_parent_context (); + t = t->get_parent_context (); string name = ly_scm2string (voice_name); return find_context_below (t, ly_symbol2scm ("Voice"), name); @@ -283,35 +282,35 @@ Lyric_combine_music_iterator::process (Moment /* when */) if (!music_context_->get_parent_context ()) { /* - The melody has died. - We die too. + The melody has died. + We die too. */ if (lyrics_context_) - lyrics_context_->unset_property (ly_symbol2scm ("associatedVoiceContext")); + lyrics_context_->unset_property (ly_symbol2scm ("associatedVoiceContext")); lyric_iter_ = 0; set_music_context (0); } if (music_context_ - && (start_new_syllable () || - (busy_moment_ >= pending_grace_moment_)) + && (start_new_syllable () + || (busy_moment_ >= pending_grace_moment_)) && lyric_iter_->ok ()) { Moment now = music_context_->now_mom (); if (now.grace_part_ && !to_boolean (lyrics_context_->get_property ("includeGraceNotes"))) - { - pending_grace_moment_ = now; - pending_grace_moment_.grace_part_ = Rational (0); - return; - } + { + pending_grace_moment_ = now; + pending_grace_moment_.grace_part_ = Rational (0); + return; + } else - { - pending_grace_moment_.set_infinite (1); - } + { + pending_grace_moment_.set_infinite (1); + } Moment m = lyric_iter_->pending_moment (); lyrics_context_->set_property (ly_symbol2scm ("associatedVoiceContext"), - music_context_->self_scm ()); + music_context_->self_scm ()); lyric_iter_->process (m); music_found_ = true; diff --git a/lily/lyric-engraver.cc b/lily/lyric-engraver.cc index c52cba8356..e67fa97b48 100644 --- a/lily/lyric-engraver.cc +++ b/lily/lyric-engraver.cc @@ -71,22 +71,22 @@ Lyric_engraver::process_music () SCM text = event_->get_property ("text"); if (ly_is_equal (text, scm_from_locale_string (" "))) - { - if (last_text_) - last_text_->set_property ("self-alignment-X", - get_property ("lyricMelismaAlignment")); - } + { + if (last_text_) + last_text_->set_property ("self-alignment-X", + get_property ("lyricMelismaAlignment")); + } else - text_ = make_item ("LyricText", event_->self_scm ()); + text_ = make_item ("LyricText", event_->self_scm ()); } - Context *voice = get_voice_to_lyrics (context ()); - if (last_text_ - && voice - && to_boolean (voice->get_property ("melismaBusy")) - && !to_boolean (context ()->get_property ("ignoreMelismata"))) - last_text_->set_property ("self-alignment-X", - get_property ("lyricMelismaAlignment")); + Context *voice = get_voice_to_lyrics (context ()); + if (last_text_ + && voice + && to_boolean (voice->get_property ("melismaBusy")) + && !to_boolean (context ()->get_property ("ignoreMelismata"))) + last_text_->set_property ("self-alignment-X", + get_property ("lyricMelismaAlignment")); } Context * @@ -109,7 +109,7 @@ get_voice_to_lyrics (Context *lyrics) { ssize idx = nm.rfind ('-'); if (idx != NPOS) - nm = nm.substr (0, idx); + nm = nm.substr (0, idx); } Context *parent = lyrics; @@ -144,17 +144,17 @@ get_current_note_head (Context *voice, bool include_grace_notes) Grob *g = unsmob_grob (scm_cdar (s));; Moment *end_mom = unsmob_moment (scm_caar (s)); if (!end_mom || !g) - { - programming_error ("busyGrobs invalid"); - continue; - } + { + programming_error ("busyGrobs invalid"); + continue; + } - if (((end_mom->main_part_ > now.main_part_) || - (include_grace_notes && end_mom->grace_part_ > now.grace_part_)) + if (((end_mom->main_part_ > now.main_part_) + || (include_grace_notes && end_mom->grace_part_ > now.grace_part_)) && dynamic_cast<Item *> (g) && Note_head::has_interface (g)) { - return g; + return g; } } @@ -169,24 +169,24 @@ Lyric_engraver::stop_translation_timestep () Context *voice = get_voice_to_lyrics (context ()); if (voice) - { - bool include_grace_notes = to_boolean (get_property ("includeGraceNotes")); - Grob *head = get_current_note_head (voice, include_grace_notes); - - if (head) - { - text_->set_parent (head, X_AXIS); - if (melisma_busy (voice) - && !to_boolean (get_property ("ignoreMelismata"))) - text_->set_property ("self-alignment-X", - get_property ("lyricMelismaAlignment")); - } - else - { - text_->warning (_ ("Lyric syllable does not have note. Use \\lyricsto or associatedVoice.")); - text_->set_property ("X-offset", scm_from_int (0)); - } - } + { + bool include_grace_notes = to_boolean (get_property ("includeGraceNotes")); + Grob *head = get_current_note_head (voice, include_grace_notes); + + if (head) + { + text_->set_parent (head, X_AXIS); + if (melisma_busy (voice) + && !to_boolean (get_property ("ignoreMelismata"))) + text_->set_property ("self-alignment-X", + get_property ("lyricMelismaAlignment")); + } + else + { + text_->warning (_ ("Lyric syllable does not have note. Use \\lyricsto or associatedVoice.")); + text_->set_property ("X-offset", scm_from_int (0)); + } + } last_text_ = text_; text_ = 0; @@ -195,18 +195,18 @@ Lyric_engraver::stop_translation_timestep () } ADD_TRANSLATOR (Lyric_engraver, - /* doc */ - "Engrave text for lyrics.", + /* doc */ + "Engrave text for lyrics.", - /* create */ - "LyricText ", + /* create */ + "LyricText ", - /* read */ - "ignoreMelismata " - "includeGraceNotes " - "lyricMelismaAlignment " - "searchForVoice", + /* read */ + "ignoreMelismata " + "includeGraceNotes " + "lyricMelismaAlignment " + "searchForVoice", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/lyric-extender.cc b/lily/lyric-extender.cc index 088881fc1d..b167e923ab 100644 --- a/lily/lyric-extender.cc +++ b/lily/lyric-extender.cc @@ -43,7 +43,7 @@ Lyric_extender::print (SCM smob) common = common->common_refpoint (me->get_bound (RIGHT), X_AXIS); common = common->common_refpoint (me->get_system (), X_AXIS); - + Real sl = me->layout ()->get_dimension (ly_symbol2scm ("line-thickness")); extract_grob_set (me, "heads", heads); @@ -71,13 +71,13 @@ Lyric_extender::print (SCM smob) = left_point + (robust_scm2double (minlen, 0)); right_point = min (right_point, me->get_system ()->get_bound (RIGHT)->relative_coordinate (common, X_AXIS)); - + if (heads.size ()) right_point = max (right_point, heads.back ()->extent (common, X_AXIS)[RIGHT]); Real h = sl * robust_scm2double (me->get_property ("thickness"), 0); Drul_array<Real> paddings (robust_scm2double (me->get_property ("left-padding"), h), - robust_scm2double (me->get_property ("right-padding"), h)); + robust_scm2double (me->get_property ("right-padding"), h)); if (right_text) right_point = min (right_point, (robust_relative_extent (right_text, common, X_AXIS)[LEFT] - paddings[RIGHT])); @@ -93,22 +93,22 @@ Lyric_extender::print (SCM smob) return SCM_EOL; Stencil mol (Lookup::round_filled_box (Box (Interval (0, w), - Interval (0, h)), - 0.8 * h)); + Interval (0, h)), + 0.8 * h)); mol.translate_axis (left_point - me->relative_coordinate (common, X_AXIS), - X_AXIS); + X_AXIS); return mol.smobbed_copy (); } ADD_INTERFACE (Lyric_extender, - "The extender is a simple line at the baseline of the lyric" - " that helps show the length of a melisma (a tied or slurred" - " note).", - - /* properties */ - "heads " - "left-padding " - "next " - "right-padding " - "thickness " - ); + "The extender is a simple line at the baseline of the lyric" + " that helps show the length of a melisma (a tied or slurred" + " note).", + + /* properties */ + "heads " + "left-padding " + "next " + "right-padding " + "thickness " + ); diff --git a/lily/lyric-hyphen.cc b/lily/lyric-hyphen.cc index 5fae21fc34..695cc59293 100644 --- a/lily/lyric-hyphen.cc +++ b/lily/lyric-hyphen.cc @@ -19,7 +19,6 @@ #include "lyric-hyphen.hh" - #include "lookup.hh" #include "output-def.hh" #include "paper-column.hh" @@ -37,11 +36,11 @@ Lyric_hyphen::print (SCM smob) { Spanner *me = unsmob_spanner (smob); Drul_array<Item *> bounds (me->get_bound (LEFT), - me->get_bound (RIGHT)); + me->get_bound (RIGHT)); if (bounds[LEFT]->break_status_dir () && (Paper_column::when_mom (bounds[LEFT]) - == Paper_column::when_mom (bounds[RIGHT]->get_column ()))) + == Paper_column::when_mom (bounds[RIGHT]->get_column ()))) return SCM_EOL; Grob *common = bounds[LEFT]->common_refpoint (bounds[RIGHT], X_AXIS); @@ -54,8 +53,8 @@ Lyric_hyphen::print (SCM smob) Interval iv = bounds[d]->extent (common, X_AXIS); span_points[d] = iv.is_empty () - ? bounds[d]->relative_coordinate (common, X_AXIS) - : iv[-d]; + ? bounds[d]->relative_coordinate (common, X_AXIS) + : iv[-d]; } while (flip (&d) != LEFT); @@ -63,7 +62,7 @@ Lyric_hyphen::print (SCM smob) Real th = robust_scm2double (me->get_property ("thickness"), 1) * lt; Real font_size_step = robust_scm2double (me->get_property ("font-size"), 0.0); Real h = robust_scm2double (me->get_property ("height"), 0.5) - * pow (2.0, font_size_step / 6.0); + * pow (2.0, font_size_step / 6.0); // interval? @@ -129,7 +128,7 @@ Lyric_hyphen::set_spacing_rods (SCM smob) { r.item_drul_[d] = sp->get_bound (d); if (r.item_drul_[d]) - r.distance_ += -d * r.item_drul_[d]->extent (r.item_drul_[d], X_AXIS)[-d]; + r.distance_ += -d * r.item_drul_[d]->extent (r.item_drul_[d], X_AXIS)[-d]; } while (flip (&d) != LEFT); @@ -141,16 +140,16 @@ Lyric_hyphen::set_spacing_rods (SCM smob) } ADD_INTERFACE (Lyric_hyphen, - "A centered hyphen is simply a line between lyrics used to" - " divide syllables.", - - /* properties */ - "dash-period " - "height " - "length " - "minimum-distance " - "minimum-length " - "padding " - "thickness " - ); + "A centered hyphen is simply a line between lyrics used to" + " divide syllables.", + + /* properties */ + "dash-period " + "height " + "length " + "minimum-distance " + "minimum-length " + "padding " + "thickness " + ); diff --git a/lily/lyric-performer.cc b/lily/lyric-performer.cc index decb4c9c6c..2b117fe4fd 100644 --- a/lily/lyric-performer.cc +++ b/lily/lyric-performer.cc @@ -50,7 +50,7 @@ Lyric_performer::process_music () && ly_scm2string (events_[0]->get_property ("text")).length ()) { audio_ = new Audio_text (Audio_text::LYRIC, - ly_scm2string (events_[0]->get_property ("text"))); + ly_scm2string (events_[0]->get_property ("text"))); Audio_element_info info (audio_, events_[0]); announce_element (info); } @@ -75,15 +75,15 @@ Lyric_performer::listen_lyric (Stream_event *event) } ADD_TRANSLATOR (Lyric_performer, - /* doc */ - "", + /* doc */ + "", - /* create */ - "", + /* create */ + "", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/main.cc b/lily/main.cc index 9e33ec13dc..d0d21601ec 100644 --- a/lily/main.cc +++ b/lily/main.cc @@ -65,7 +65,6 @@ vector<string> dump_header_fieldnames_global; /* Name of initialisation file. */ string init_name_global; - /* Output formats to generate. */ string output_format_global = ""; @@ -88,7 +87,6 @@ string init_scheme_variables_global; bool relocate_binary = true; - /* * Miscellaneous global stuff. */ @@ -99,33 +97,33 @@ File_path global_path; */ static char const *AUTHORS -= " Han-Wen Nienhuys <hanwen@xs4all.nl>\n" - " Jan Nieuwenhuizen <janneke@gnu.org>\n"; + = " Han-Wen Nienhuys <hanwen@xs4all.nl>\n" + " Jan Nieuwenhuizen <janneke@gnu.org>\n"; static char const *PROGRAM_NAME = "lilypond"; static char const *PROGRAM_URL = "http://lilypond.org"; static char const *NOTICE -= _i ("This program is free software. It is covered by the GNU General Public\n" - "License and you are welcome to change it and/or distribute copies of it\n" - "under certain conditions. Invoke as `%s --warranty' for more\n" - "information.\n"); + = _i ("This program is free software. It is covered by the GNU General Public\n" + "License and you are welcome to change it and/or distribute copies of it\n" + "under certain conditions. Invoke as `%s --warranty' for more\n" + "information.\n"); static char const *WARRANTY -= _i (" This program is free software; you can redistribute it and/or\n" - "modify it under the terms of the GNU General Public License as \n" - "published by the Free Software Foundation, either version 3 of\n" - "the License, or (at your option) any later version.\n" - "\n" - " This program is distributed in the hope that it will be useful,\n" - "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" - "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n" - "General Public License for more details.\n" - "\n" - " You should have received a copy of the\n" - "GNU General Public License along with this program; if not, write to\n" - "the Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n" - "Boston, MA 02111-1307, USA.\n"); + = _i (" This program is free software; you can redistribute it and/or\n" + "modify it under the terms of the GNU General Public License as \n" + "published by the Free Software Foundation, either version 3 of\n" + "the License, or (at your option) any later version.\n" + "\n" + " This program is distributed in the hope that it will be useful,\n" + "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n" + "General Public License for more details.\n" + "\n" + " You should have received a copy of the\n" + "GNU General Public License along with this program; if not, write to\n" + "the Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n" + "Boston, MA 02111-1307, USA.\n"); /* Where the init files live. Typically: LILYPOND_DATADIR = /usr/share/lilypond @@ -143,10 +141,13 @@ static Getopt_long *option_parser = 0; * call gettext () explicitly for actual "translation" */ static Long_option_init options_static[] -= { - {_i ("SYM[=VAL]"), "define-default", 'd', - _i ("set Scheme option SYM to VAL (default: #t).\n" - "Use -dhelp for help.")}, += +{ + { + _i ("SYM[=VAL]"), "define-default", 'd', + _i ("set Scheme option SYM to VAL (default: #t).\n" + "Use -dhelp for help.") + }, {_i ("EXPR"), "evaluate", 'e', _i ("evaluate scheme code")}, /* Bug in option parser: --output =foe is taken as an abbreviation @@ -155,33 +156,36 @@ static Long_option_init options_static[] {0, "pdf", 0, _i ("generate PDF (default)")}, {0, "png", 0, _i ("generate PNG")}, {0, "ps", 0, _i ("generate PostScript")}, - {0, "help", 'h', _i ("show this help and exit")}, - {_i ("FIELD"), "header", 'H', _i ("dump header field FIELD to file\n" - "named BASENAME.FIELD")}, - {_i ("DIR"), "include", 'I', _i ("add DIR to search path")}, - {_i ("FILE"), "init", 'i', _i ("use FILE as init file")}, + {0, "help", 'h', _i ("show this help and exit")}, + { + _i ("FIELD"), "header", 'H', _i ("dump header field FIELD to file\n" + "named BASENAME.FIELD") + }, + {_i ("DIR"), "include", 'I', _i ("add DIR to search path")}, + {_i ("FILE"), "init", 'i', _i ("use FILE as init file")}, #if HAVE_CHROOT - {_i ("USER, GROUP, JAIL, DIR"), "jail", 'j', _i ("chroot to JAIL, become USER:GROUP\n" - "and cd into DIR")}, + { + _i ("USER, GROUP, JAIL, DIR"), "jail", 'j', _i ("chroot to JAIL, become USER:GROUP\n" + "and cd into DIR") + }, #endif - {_i ("FILE"), "output", 'o', _i ("write output to FILE (suffix will be added)")}, + {_i ("FILE"), "output", 'o', _i ("write output to FILE (suffix will be added)")}, {0, "relocate", 0, _i ("relocate using directory of lilypond program")}, - {0, "version", 'v', _i ("show version number and exit")}, + {0, "version", 'v', _i ("show version number and exit")}, {0, "verbose", 'V', _i ("be verbose")}, - {0, "warranty", 'w', _i ("show warranty and copyright")}, + {0, "warranty", 'w', _i ("show warranty and copyright")}, {0, 0, 0, 0} }; char const *LILYPOND_DATADIR = PACKAGE_DATADIR "/" TOPLEVEL_VERSION; - /* x86 defaults to using 80-bit extended precision arithmetic. This can cause problems because the truncation from 80 bits to 64 bits can occur in unpredictable places. To get around this, we tell the x87 FPU to use only double precision. Note that this is not needed for x86_64 because that uses the SSE unit by default instead of the x87 FPU. */ -#if ((defined(__x86__) || defined(__i386__)) \ - && defined(HAVE_FPU_CONTROL_H) && (HAVE_FPU_CONTROL_H == 1)) +#if ((defined (__x86__) || defined (__i386__)) \ + && defined (HAVE_FPU_CONTROL_H) && (HAVE_FPU_CONTROL_H == 1)) #include <fpu_control.h> static void @@ -200,7 +204,6 @@ configure_fpu () #endif /* defined(__x86__) || defined(__i386__) */ - static void env_var_info (FILE *out, char const *key) { @@ -259,8 +262,8 @@ notice () } LY_DEFINE (ly_usage, "ly:usage", - 0, 0, 0, (), - "Print usage message.") + 0, 0, 0, (), + "Print usage message.") { /* No version number or newline here. It confuses help2man. */ printf ("%s", (_f ("Usage: %s [OPTION]... FILE...", PROGRAM_NAME).c_str ())); @@ -280,8 +283,8 @@ LY_DEFINE (ly_usage, "ly:usage", or if there is a LilyPond users list or forum in your language "Report bugs in English via %s or in YOUR_LANG via URI" */ printf ("%s", (_f ("Report bugs via %s", - "http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs" - ).c_str ())); + "http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs" + ).c_str ())); printf ("\n"); printf ("\n"); return SCM_UNSPECIFIED; @@ -318,15 +321,15 @@ do_chroot_jail () actual actions. */ enum Jail - { - USER_NAME, GROUP_NAME, JAIL, DIR, JAIL_MAX - }; + { + USER_NAME, GROUP_NAME, JAIL, DIR, JAIL_MAX + }; vector<string> components = string_split (jail_spec, ','); if (components.size () != JAIL_MAX) { error (_f ("expected %d arguments with jail, found: %u", JAIL_MAX, - (unsigned) components.size ())); + (unsigned) components.size ())); exit (2); } @@ -334,16 +337,16 @@ do_chroot_jail () errno = 0; int uid; - if (passwd * passwd = getpwnam (components[USER_NAME].c_str ())) + if (passwd *passwd = getpwnam (components[USER_NAME].c_str ())) uid = passwd->pw_uid; else { if (errno == 0) - error (_f ("no such user: %s", components[USER_NAME])); + error (_f ("no such user: %s", components[USER_NAME])); else - error (_f ("cannot get user id from user name: %s: %s", - components[USER_NAME], - strerror (errno))); + error (_f ("cannot get user id from user name: %s: %s", + components[USER_NAME], + strerror (errno))); exit (3); } @@ -351,23 +354,23 @@ do_chroot_jail () errno = 0; int gid; - if (group * group = getgrnam (components[GROUP_NAME].c_str ())) + if (group *group = getgrnam (components[GROUP_NAME].c_str ())) gid = group->gr_gid; else { if (errno == 0) - error (_f ("no such group: %s", components[GROUP_NAME])); + error (_f ("no such group: %s", components[GROUP_NAME])); else - error (_f ("cannot get group id from group name: %s: %s", - components[GROUP_NAME], - strerror (errno))); + error (_f ("cannot get group id from group name: %s: %s", + components[GROUP_NAME], + strerror (errno))); exit (3); } if (chroot (components[JAIL].c_str ())) { error (_f ("cannot chroot to: %s: %s", components[JAIL], - strerror (errno))); + strerror (errno))); exit (3); } @@ -386,7 +389,7 @@ do_chroot_jail () if (chdir (components[DIR].c_str ())) { error (_f ("cannot change working directory to: %s: %s", components[DIR], - strerror (errno))); + strerror (errno))); exit (3); } } @@ -477,90 +480,90 @@ parse_argv (int argc, char **argv) while (Long_option_init const *opt = (*option_parser) ()) { switch (opt->shortname_char_) - { - case 0: - if (string (opt->longname_str0_) == "pdf" - || string (opt->longname_str0_) == "png" - || string (opt->longname_str0_) == "ps") - add_output_format (opt->longname_str0_); - else if (string (opt->longname_str0_) == "relocate") - relocate_binary = true; - break; - - case 'd': - { - string arg (option_parser->optional_argument_str0_); - ssize eq = arg.find ('='); - - string key = arg; - string val = "#t"; - - if (eq != NPOS) - { - key = arg.substr (0, eq); - val = arg.substr (eq + 1, arg.length () - 1); - } - - init_scheme_variables_global - += "(cons \'" + key + " '" + val + ")\n"; - } - break; - - case 'v': - notice (); - exit (0); - break; - case 'o': - { - string s = option_parser->optional_argument_str0_; - File_name file_name (s); - output_name_global = file_name.to_string (); - } - break; - case 'j': - jail_spec = option_parser->optional_argument_str0_; - break; - - case 'e': - init_scheme_code_global - += option_parser->optional_argument_str0_ + string (" "); - break; - case 'w': - warranty (); - exit (0); - break; - - case 'f': - { - vector<string> components - = string_split (option_parser->optional_argument_str0_, ','); - for (vsize i = 0; i < components.size (); i++) - add_output_format (components[i]); - } - break; - - case 'H': - dump_header_fieldnames_global - .push_back (option_parser->optional_argument_str0_); - break; - case 'I': - global_path.append (option_parser->optional_argument_str0_); - break; - case 'i': - init_name_global = option_parser->optional_argument_str0_; - break; - case 'h': - show_help = true; - break; - case 'V': - be_verbose_global = true; - break; - default: - programming_error (to_string ("unhandled short option: %c", - opt->shortname_char_)); - assert (false); - break; - } + { + case 0: + if (string (opt->longname_str0_) == "pdf" + || string (opt->longname_str0_) == "png" + || string (opt->longname_str0_) == "ps") + add_output_format (opt->longname_str0_); + else if (string (opt->longname_str0_) == "relocate") + relocate_binary = true; + break; + + case 'd': + { + string arg (option_parser->optional_argument_str0_); + ssize eq = arg.find ('='); + + string key = arg; + string val = "#t"; + + if (eq != NPOS) + { + key = arg.substr (0, eq); + val = arg.substr (eq + 1, arg.length () - 1); + } + + init_scheme_variables_global + += "(cons \'" + key + " '" + val + ")\n"; + } + break; + + case 'v': + notice (); + exit (0); + break; + case 'o': + { + string s = option_parser->optional_argument_str0_; + File_name file_name (s); + output_name_global = file_name.to_string (); + } + break; + case 'j': + jail_spec = option_parser->optional_argument_str0_; + break; + + case 'e': + init_scheme_code_global + += option_parser->optional_argument_str0_ + string (" "); + break; + case 'w': + warranty (); + exit (0); + break; + + case 'f': + { + vector<string> components + = string_split (option_parser->optional_argument_str0_, ','); + for (vsize i = 0; i < components.size (); i++) + add_output_format (components[i]); + } + break; + + case 'H': + dump_header_fieldnames_global + .push_back (option_parser->optional_argument_str0_); + break; + case 'I': + global_path.append (option_parser->optional_argument_str0_); + break; + case 'i': + init_name_global = option_parser->optional_argument_str0_; + break; + case 'h': + show_help = true; + break; + case 'V': + be_verbose_global = true; + break; + default: + programming_error (to_string ("unhandled short option: %c", + opt->shortname_char_)); + assert (false); + break; + } } if (output_format_global == "") @@ -570,7 +573,7 @@ parse_argv (int argc, char **argv) { ly_usage (); if (be_verbose_global) - dir_info (stdout); + dir_info (stdout); exit (0); } } @@ -590,11 +593,10 @@ setup_guile_env () sane_putenv ("GUILE_MIN_YIELD_2", yield, overwrite); sane_putenv ("GUILE_MIN_YIELD_MALLOC", yield, overwrite); - sane_putenv ("GUILE_INIT_SEGMENT_SIZE_1", - "10485760", overwrite); + "10485760", overwrite); sane_putenv ("GUILE_MAX_SEGMENT_SIZE", - "104857600", overwrite); + "104857600", overwrite); } vector<string> start_environment_global; @@ -602,10 +604,10 @@ vector<string> start_environment_global; int main (int argc, char **argv, char **envp) { - configure_fpu(); + configure_fpu (); for (char **p = envp; *p; p++) - start_environment_global.push_back(*p); + start_environment_global.push_back (*p); if (getenv ("LILYPOND_VERBOSE")) be_verbose_global = true; diff --git a/lily/mark-engraver.cc b/lily/mark-engraver.cc index 67ad884824..2d6501af0a 100644 --- a/lily/mark-engraver.cc +++ b/lily/mark-engraver.cc @@ -85,12 +85,12 @@ void Mark_engraver::stop_translation_timestep () { if (text_) - { - text_->set_object ("side-support-elements", - grob_list_to_grob_array (get_property ("stavesFound"))); - final_text_ = text_; - text_ = 0; - } + { + text_->set_object ("side-support-elements", + grob_list_to_grob_array (get_property ("stavesFound"))); + final_text_ = text_; + text_ = 0; + } mark_ev_ = 0; } @@ -99,7 +99,7 @@ Mark_engraver::finalize () { if (final_text_) final_text_->set_property ("break-visibility", - scm_c_make_vector (3, SCM_BOOL_T)); + scm_c_make_vector (3, SCM_BOOL_T)); final_text_ = 0; } @@ -130,58 +130,58 @@ Mark_engraver::process_music () create_items (mark_ev_); /* - automatic marks. + automatic marks. */ SCM m = mark_ev_->get_property ("label"); SCM proc = get_property ("markFormatter"); if (!Text_interface::is_markup (m) - && ly_is_procedure (proc)) - { - if (!scm_is_number (m)) - m = get_property ("rehearsalMark"); - - if (scm_integer_p (m) == SCM_BOOL_T - && scm_exact_p (m) == SCM_BOOL_T) - { - int mark_count = scm_to_int (m); - mark_count++; - context ()->set_property ("rehearsalMark", - scm_from_int (mark_count)); - } - - if (scm_is_number (m)) - m = scm_call_2 (proc, m, context ()->self_scm ()); - else - /* FIXME: constant error message. */ - warning (_ ("rehearsalMark must have integer value")); - } + && ly_is_procedure (proc)) + { + if (!scm_is_number (m)) + m = get_property ("rehearsalMark"); + + if (scm_integer_p (m) == SCM_BOOL_T + && scm_exact_p (m) == SCM_BOOL_T) + { + int mark_count = scm_to_int (m); + mark_count++; + context ()->set_property ("rehearsalMark", + scm_from_int (mark_count)); + } + + if (scm_is_number (m)) + m = scm_call_2 (proc, m, context ()->self_scm ()); + else + /* FIXME: constant error message. */ + warning (_ ("rehearsalMark must have integer value")); + } if (Text_interface::is_markup (m)) - text_->set_property ("text", m); + text_->set_property ("text", m); else - warning (_ ("mark label must be a markup object")); + warning (_ ("mark label must be a markup object")); } } ADD_ACKNOWLEDGER (Mark_engraver, break_alignment); ADD_TRANSLATOR (Mark_engraver, - /* doc */ - "Create @code{RehearsalMark} objects. It puts them on top of" - " all staves (which is taken from the property" - " @code{stavesFound}). If moving this engraver to a different" - " context, @ref{Staff_collecting_engraver} must move along," - " otherwise all marks end up on the same Y@tie{}location.", - - /* create */ - "RehearsalMark ", - - /* read */ - "markFormatter " - "rehearsalMark " - "stavesFound ", - - /* write */ - "" - ); + /* doc */ + "Create @code{RehearsalMark} objects. It puts them on top of" + " all staves (which is taken from the property" + " @code{stavesFound}). If moving this engraver to a different" + " context, @ref{Staff_collecting_engraver} must move along," + " otherwise all marks end up on the same Y@tie{}location.", + + /* create */ + "RehearsalMark ", + + /* read */ + "markFormatter " + "rehearsalMark " + "stavesFound ", + + /* write */ + "" + ); diff --git a/lily/measure-grouping-engraver.cc b/lily/measure-grouping-engraver.cc index 7a788dc3d2..144d279d7c 100644 --- a/lily/measure-grouping-engraver.cc +++ b/lily/measure-grouping-engraver.cc @@ -64,7 +64,7 @@ Measure_grouping_engraver::process_music () if (grouping_ && now.main_part_ >= stop_grouping_mom_ && !now.grace_part_) { grouping_->set_bound (RIGHT, - unsmob_grob (get_property ("currentMusicalColumn"))); + unsmob_grob (get_property ("currentMusicalColumn"))); grouping_ = 0; } @@ -83,34 +83,34 @@ Measure_grouping_engraver::process_music () Rational where (0); for (SCM s = grouping; scm_is_pair (s); - where += Rational ((int) scm_to_int (scm_car (s))) * base_moment, - s = scm_cdr (s)) - { - int grouplen = scm_to_int (scm_car (s)); - if (where == mp) - { - if (grouping_) - { - programming_error ("last grouping not finished yet"); - continue; - } + where += Rational ((int) scm_to_int (scm_car (s))) * base_moment, + s = scm_cdr (s)) + { + int grouplen = scm_to_int (scm_car (s)); + if (where == mp) + { + if (grouping_) + { + programming_error ("last grouping not finished yet"); + continue; + } if (grouplen > 1) - { - grouping_ = make_spanner ("MeasureGrouping", SCM_EOL); - grouping_->set_bound (LEFT, unsmob_grob (get_property ("currentMusicalColumn"))); - - stop_grouping_mom_ = now.main_part_ + Rational (grouplen - 1) * base_moment; - get_global_context ()->add_moment_to_process (Moment (stop_grouping_mom_)); - - if (grouplen == 3) - grouping_->set_property ("style", ly_symbol2scm ("triangle")); - else - grouping_->set_property ("style", ly_symbol2scm ("bracket")); - - break; - } - } - } + { + grouping_ = make_spanner ("MeasureGrouping", SCM_EOL); + grouping_->set_bound (LEFT, unsmob_grob (get_property ("currentMusicalColumn"))); + + stop_grouping_mom_ = now.main_part_ + Rational (grouplen - 1) * base_moment; + get_global_context ()->add_moment_to_process (Moment (stop_grouping_mom_)); + + if (grouplen == 3) + grouping_->set_property ("style", ly_symbol2scm ("triangle")); + else + grouping_->set_property ("style", ly_symbol2scm ("bracket")); + + break; + } + } + } } } @@ -121,18 +121,18 @@ Measure_grouping_engraver::Measure_grouping_engraver () ADD_ACKNOWLEDGER (Measure_grouping_engraver, note_column); ADD_TRANSLATOR (Measure_grouping_engraver, - /* doc */ - "Create @code{MeasureGrouping} to indicate beat subdivision.", + /* doc */ + "Create @code{MeasureGrouping} to indicate beat subdivision.", - /* create */ - "MeasureGrouping ", + /* create */ + "MeasureGrouping ", - /* read */ + /* read */ "baseMoment " - "beatStructure " - "currentMusicalColumn " - "measurePosition ", + "beatStructure " + "currentMusicalColumn " + "measurePosition ", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/measure-grouping-spanner.cc b/lily/measure-grouping-spanner.cc index db6b4fced2..5d5b9a0758 100644 --- a/lily/measure-grouping-spanner.cc +++ b/lily/measure-grouping-spanner.cc @@ -36,10 +36,10 @@ Measure_grouping::print (SCM grob) Real t = Staff_symbol_referencer::line_thickness (me) * robust_scm2double (me->get_property ("thickness"), 1); Grob *common = me->get_bound (LEFT)->common_refpoint (me->get_bound (RIGHT), - X_AXIS); + X_AXIS); Real right_point = robust_relative_extent (me->get_bound (RIGHT), - common, X_AXIS).linear_combination (CENTER); + common, X_AXIS).linear_combination (CENTER); Real left_point = me->get_bound (LEFT)->relative_coordinate (common, X_AXIS); Interval iv (left_point, right_point); @@ -59,12 +59,12 @@ Measure_grouping::print (SCM grob) } ADD_INTERFACE (Measure_grouping, - "This object indicates groups of beats. Valid choices for" - " @code{style} are @code{bracket} and @code{triangle}.", - - /* properties */ - "thickness " - "style " - "height " - ); + "This object indicates groups of beats. Valid choices for" + " @code{style} are @code{bracket} and @code{triangle}.", + + /* properties */ + "thickness " + "style " + "height " + ); diff --git a/lily/melody-engraver.cc b/lily/melody-engraver.cc index 96873d3293..9e601a1949 100644 --- a/lily/melody-engraver.cc +++ b/lily/melody-engraver.cc @@ -17,7 +17,6 @@ along with LilyPond. If not, see <http://www.gnu.org/licenses/>. */ - #include "engraver.hh" #include "item.hh" @@ -27,9 +26,9 @@ class Melody_engraver : public Engraver { Grob *melody_item_; - Grob *stem_; + Grob *stem_; protected: - + DECLARE_ACKNOWLEDGER (stem); DECLARE_ACKNOWLEDGER (slur); TRANSLATOR_DECLARATIONS (Melody_engraver); @@ -37,7 +36,6 @@ protected: void process_music (); }; - Melody_engraver::Melody_engraver () { stem_ = 0; @@ -50,7 +48,7 @@ Melody_engraver::process_music () if (scm_is_string (get_property ("whichBar"))) melody_item_ = 0; } - + void Melody_engraver::stop_translation_timestep () { @@ -59,51 +57,47 @@ Melody_engraver::stop_translation_timestep () { extract_grob_set (stem_, "rests", rests); if (rests.size ()) - melody_item_ = 0; + melody_item_ = 0; else - { - if (!melody_item_) - melody_item_ = make_item ("MelodyItem", stem_->self_scm ()); + { + if (!melody_item_) + melody_item_ = make_item ("MelodyItem", stem_->self_scm ()); - Melody_spanner::add_stem (melody_item_, stem_); - } + Melody_spanner::add_stem (melody_item_, stem_); + } } stem_ = 0; } - void Melody_engraver::acknowledge_slur (Grob_info /* info */) { melody_item_ = 0; } - void Melody_engraver::acknowledge_stem (Grob_info info) { stem_ = info.grob (); } - - #include "translator.icc" ADD_ACKNOWLEDGER (Melody_engraver, stem); ADD_ACKNOWLEDGER (Melody_engraver, slur); ADD_TRANSLATOR (Melody_engraver, - /* doc */ - "Create information for context dependent typesetting" - " decisions.", + /* doc */ + "Create information for context dependent typesetting" + " decisions.", + + /* create */ + "MelodyItem ", - /* create */ - "MelodyItem ", + /* read */ + "", - /* read */ - "", + /* write */ + "" + ); - /* write */ - "" - ); - diff --git a/lily/melody-spanner.cc b/lily/melody-spanner.cc index 8a96a2feb7..a6bda0e75b 100644 --- a/lily/melody-spanner.cc +++ b/lily/melody-spanner.cc @@ -27,7 +27,6 @@ let's take item for now. */ - /* Interpolate stem directions for neutral stems. */ @@ -36,10 +35,10 @@ SCM Melody_spanner::calc_neutral_stem_direction (SCM smob) { Grob *stem = unsmob_grob (smob); - Grob *me = unsmob_grob (stem->get_object ("melody-spanner")); + Grob *me = unsmob_grob (stem->get_object ("melody-spanner")); if (!me || !me->is_live ()) return scm_from_int (DOWN); - + extract_grob_set (me, "stems", stems); vector<Direction> dirs; @@ -49,47 +48,47 @@ Melody_spanner::calc_neutral_stem_direction (SCM smob) vsize last_nonneutral = VPOS; vsize next_nonneutral = 0; while (next_nonneutral != VPOS && next_nonneutral < dirs.size () - && !dirs[next_nonneutral]) + && !dirs[next_nonneutral]) next_nonneutral++; SCM retval = SCM_EOL; - while (last_nonneutral == VPOS || last_nonneutral + 1 < dirs.size ()) + while (last_nonneutral == VPOS || last_nonneutral + 1 < dirs.size ()) { Direction d1 = CENTER; Direction d2 = CENTER; if (last_nonneutral != VPOS) - d1 = dirs[last_nonneutral]; + d1 = dirs[last_nonneutral]; if (next_nonneutral < dirs.size ()) - d2 = dirs[next_nonneutral]; + d2 = dirs[next_nonneutral]; Direction total = CENTER; if (d1 && d1 == d2) - total = d1; + total = d1; else if (d1 && !d2) - total = d1; + total = d1; else if (d2 && !d1) - total = d2; + total = d2; else - total = to_dir (me->get_property ("neutral-direction")); - - for (vsize i = last_nonneutral + 1; i < next_nonneutral; i++) - { - if (stems[i] == stem) - retval = scm_from_int (total); - else - stems[i]->set_property ("neutral-direction", scm_from_int (total)); - } + total = to_dir (me->get_property ("neutral-direction")); + + for (vsize i = last_nonneutral + 1; i < next_nonneutral; i++) + { + if (stems[i] == stem) + retval = scm_from_int (total); + else + stems[i]->set_property ("neutral-direction", scm_from_int (total)); + } last_nonneutral = next_nonneutral; while (last_nonneutral < dirs.size () - && dirs[last_nonneutral]) - last_nonneutral++; + && dirs[last_nonneutral]) + last_nonneutral++; next_nonneutral = last_nonneutral; last_nonneutral--; while (next_nonneutral < dirs.size () - && !dirs[next_nonneutral]) - next_nonneutral++; + && !dirs[next_nonneutral]) + next_nonneutral++; } return retval; @@ -104,11 +103,10 @@ Melody_spanner::add_stem (Grob *me, Grob *stem) } ADD_INTERFACE (Melody_spanner, - "Context dependent typesetting decisions.", + "Context dependent typesetting decisions.", - /* properties */ - "stems " - "neutral-direction " - ); + /* properties */ + "stems " + "neutral-direction " + ); - diff --git a/lily/mensural-ligature-engraver.cc b/lily/mensural-ligature-engraver.cc index ead5f1f0ad..a51f223e18 100644 --- a/lily/mensural-ligature-engraver.cc +++ b/lily/mensural-ligature-engraver.cc @@ -78,8 +78,8 @@ Mensural_ligature_engraver::listen_ligature (Stream_event *ev) Mensural_ligature_engraver::Mensural_ligature_engraver () { - brew_ligature_primitive_proc = - Mensural_ligature::brew_ligature_primitive_proc; + brew_ligature_primitive_proc + = Mensural_ligature::brew_ligature_primitive_proc; } Spanner * @@ -115,52 +115,52 @@ Mensural_ligature_engraver::transform_heads (vector<Grob_info> primitives) Stream_event *nr = info.event_cause (); /* - ugh. why not simply check for pitch? + ugh. why not simply check for pitch? */ if (!nr->in_event_class ("note-event")) - { - nr->origin ()->warning - (_ ("cannot determine pitch of ligature primitive -> skipping")); - at_beginning = true; - continue; - } + { + nr->origin ()->warning + (_ ("cannot determine pitch of ligature primitive -> skipping")); + at_beginning = true; + continue; + } int pitch = unsmob_pitch (nr->get_property ("pitch"))->steps (); int prim = 0; if (at_beginning) - { - if (i == s - 1) - { - // we can get here after invalid input - nr->origin ()->warning - (_ ("single note ligature - skipping")); - break; - } - prev_semibrevis = prev_brevis_shape = false; - prev_primitive = NULL; - } + { + if (i == s - 1) + { + // we can get here after invalid input + nr->origin ()->warning + (_ ("single note ligature - skipping")); + break; + } + prev_semibrevis = prev_brevis_shape = false; + prev_primitive = NULL; + } else - { - if (pitch == prev_pitch) - { - nr->origin ()->warning - (_ ("prime interval within ligature -> skipping")); - at_beginning = true; + { + if (pitch == prev_pitch) + { + nr->origin ()->warning + (_ ("prime interval within ligature -> skipping")); + at_beginning = true; prim = MLP_NONE; - continue; - } - } + continue; + } + } if (duration_log < -3 // is this possible at all??? - || duration_log > 0) - { - nr->origin ()->warning - (_ ("mensural ligature: duration none of Mx, L, B, S -> skipping")); + || duration_log > 0) + { + nr->origin ()->warning + (_ ("mensural ligature: duration none of Mx, L, B, S -> skipping")); prim = MLP_NONE; - at_beginning = true; - continue; - } + at_beginning = true; + continue; + } bool general_case = true; bool make_flexa = false; @@ -169,82 +169,82 @@ Mensural_ligature_engraver::transform_heads (vector<Grob_info> primitives) // first check special cases // 1. beginning if (at_beginning) - { - // a. semibreves - if (duration_log == 0) - { + { + // a. semibreves + if (duration_log == 0) + { prim = MLP_UP | MLP_BREVIS; - general_case = false; - } - // b. descendens longa or brevis - else if (i < s - 1 - && (unsmob_pitch (primitives[i + 1].event_cause () - ->get_property ("pitch"))->steps () < pitch) - && duration_log > -3) - { - int left_stem = duration_log == -1 ? MLP_DOWN : 0; + general_case = false; + } + // b. descendens longa or brevis + else if (i < s - 1 + && (unsmob_pitch (primitives[i + 1].event_cause () + ->get_property ("pitch"))->steps () < pitch) + && duration_log > -3) + { + int left_stem = duration_log == -1 ? MLP_DOWN : 0; prim = left_stem | MLP_BREVIS; - general_case = false; - } - } + general_case = false; + } + } // 2. initial semibrevis must be followed by another one else if (prev_semibrevis) - { - prev_semibrevis = false; - if (duration_log == 0) - { - prim = MLP_BREVIS; - general_case = false; - } - else - { - nr->origin ()->warning - (_ ("semibrevis must be followed by another one -> skipping")); + { + prev_semibrevis = false; + if (duration_log == 0) + { + prim = MLP_BREVIS; + general_case = false; + } + else + { + nr->origin ()->warning + (_ ("semibrevis must be followed by another one -> skipping")); prim = MLP_NONE; - at_beginning = true; - continue; - } - } + at_beginning = true; + continue; + } + } // 3. semibreves are otherwise not allowed else if (duration_log == 0) - { - nr->origin ()->warning - (_ ("semibreves can only appear at the beginning of a ligature,\n" - "and there may be only zero or two of them")); + { + nr->origin ()->warning + (_ ("semibreves can only appear at the beginning of a ligature,\n" + "and there may be only zero or two of them")); prim = MLP_NONE; - at_beginning = true; - continue; - } + at_beginning = true; + continue; + } // 4. end, descendens else if (i == s - 1 && pitch < prev_pitch) - { - // brevis; previous note must be turned into flexa - if (duration_log == -1) - { - if (prev_brevis_shape) - { + { + // brevis; previous note must be turned into flexa + if (duration_log == -1) + { + if (prev_brevis_shape) + { make_flexa = true; general_case = false; - } - else - { - nr->origin ()->warning - (_ ("invalid ligatura ending:\n" - "when the last note is a descending brevis,\n" - "the penultimate note must be another one,\n" - "or the ligatura must be LB or SSB")); - prim = MLP_NONE; - break; - } - } - // longa - else if (duration_log == -2) - { - prim = MLP_BREVIS; - general_case = allow_flexa = false; - } - // else maxima; fall through to regular case below - } + } + else + { + nr->origin ()->warning + (_ ("invalid ligatura ending:\n" + "when the last note is a descending brevis,\n" + "the penultimate note must be another one,\n" + "or the ligatura must be LB or SSB")); + prim = MLP_NONE; + break; + } + } + // longa + else if (duration_log == -2) + { + prim = MLP_BREVIS; + general_case = allow_flexa = false; + } + // else maxima; fall through to regular case below + } if (allow_flexa && to_boolean (primitive->get_property ("ligature-flexa"))) @@ -272,22 +272,22 @@ Mensural_ligature_engraver::transform_heads (vector<Grob_info> primitives) breve: check whether descending */ int const next_pitch = unsmob_pitch - (next_info.event_cause ()->get_property ("pitch"))->steps (); + (next_info.event_cause ()->get_property ("pitch"))->steps (); if (next_pitch < pitch) - /* - sorry, forbidden - */ - make_flexa = false; + /* + sorry, forbidden + */ + make_flexa = false; } } } if (general_case) - { + { static int const shape[3] = {MLP_MAXIMA, MLP_LONGA, MLP_BREVIS}; prim = shape[duration_log + 3]; - } + } if (make_flexa) { @@ -295,21 +295,21 @@ Mensural_ligature_engraver::transform_heads (vector<Grob_info> primitives) turn the note with the previous one into a flexa */ prev_primitive->set_property - ("primitive", - scm_from_int - (MLP_FLEXA_BEGIN - | (scm_to_int (prev_primitive->get_property ("primitive")) - & MLP_STEM))); + ("primitive", + scm_from_int + (MLP_FLEXA_BEGIN + | (scm_to_int (prev_primitive->get_property ("primitive")) + & MLP_STEM))); prev_primitive->set_property - ("flexa-interval", scm_from_int (pitch - prev_pitch)); + ("flexa-interval", scm_from_int (pitch - prev_pitch)); prim = MLP_FLEXA_END; primitive->set_property - ("flexa-interval", scm_from_int (pitch - prev_pitch)); + ("flexa-interval", scm_from_int (pitch - prev_pitch)); } // join_primitives replacement if (!(at_beginning || make_flexa)) - prev_primitive->set_property ("add-join", ly_bool2scm (true)); + prev_primitive->set_property ("add-join", ly_bool2scm (true)); at_beginning = false; prev_primitive = primitive; @@ -336,19 +336,19 @@ Mensural_ligature_engraver::transform_heads (vector<Grob_info> primitives) */ void Mensural_ligature_engraver::propagate_properties (Spanner *ligature, - vector<Grob_info> primitives) + vector<Grob_info> primitives) { Real thickness = robust_scm2double (ligature->get_property ("thickness"), 1.4); thickness - *= ligature->layout ()->get_dimension (ly_symbol2scm ("line-thickness")); + *= ligature->layout ()->get_dimension (ly_symbol2scm ("line-thickness")); Real head_width = Font_interface::get_default_font (ligature)-> - find_by_name ("noteheads.sM1mensural").extent (X_AXIS).length (); + find_by_name ("noteheads.sM1mensural").extent (X_AXIS).length (); Real maxima_head_width = Font_interface::get_default_font (ligature)-> - find_by_name ("noteheads.sM3ligmensural").extent (X_AXIS).length (); + find_by_name ("noteheads.sM3ligmensural").extent (X_AXIS).length (); Item *prev_primitive = NULL; for (vsize i = 0; i < primitives.size (); i++) @@ -356,36 +356,37 @@ Mensural_ligature_engraver::propagate_properties (Spanner *ligature, Item *primitive = dynamic_cast<Item *> (primitives[i].grob ()); int output = scm_to_int (primitive->get_property ("primitive")); primitive->set_property ("thickness", - scm_from_double (thickness)); - - switch (output & MLP_ANY) { - case MLP_BREVIS: - case MLP_LONGA: - primitive->set_property ("head-width", scm_from_double (head_width)); - break; - case MLP_MAXIMA: - primitive->set_property ("head-width", - scm_from_double (maxima_head_width)); - break; - case MLP_FLEXA_BEGIN: - /* - the next note (should be MLP_FLEXA_END) will handle this one - */ - break; - case MLP_FLEXA_END: + scm_from_double (thickness)); + + switch (output & MLP_ANY) { - SCM flexa_scm = primitive->get_property ("flexa-width"); - Real const flexa_width = robust_scm2double (flexa_scm, 2.0); - SCM head_width = scm_from_double (0.5 * (flexa_width + thickness)); - primitive->set_property ("head-width", head_width); - prev_primitive->set_property ("head-width", head_width); - prev_primitive->set_property ("flexa-width", flexa_scm); + case MLP_BREVIS: + case MLP_LONGA: + primitive->set_property ("head-width", scm_from_double (head_width)); + break; + case MLP_MAXIMA: + primitive->set_property ("head-width", + scm_from_double (maxima_head_width)); + break; + case MLP_FLEXA_BEGIN: + /* + the next note (should be MLP_FLEXA_END) will handle this one + */ + break; + case MLP_FLEXA_END: + { + SCM flexa_scm = primitive->get_property ("flexa-width"); + Real const flexa_width = robust_scm2double (flexa_scm, 2.0); + SCM head_width = scm_from_double (0.5 * (flexa_width + thickness)); + primitive->set_property ("head-width", head_width); + prev_primitive->set_property ("head-width", head_width); + prev_primitive->set_property ("flexa-width", flexa_scm); + } + break; + default: + programming_error (_ ("unexpected case fall-through")); + break; } - break; - default: - programming_error (_ ("unexpected case fall-through")); - break; - } prev_primitive = primitive; } @@ -403,69 +404,69 @@ Mensural_ligature_engraver::fold_up_primitives (vector<Grob_info> primitives) { Item *current = dynamic_cast<Item *> (primitives[i].grob ()); if (i == 0) - { - first = current; - staff_space = Staff_symbol_referencer::staff_space (first); - thickness = scm_to_double (current->get_property ("thickness")); - } + { + first = current; + staff_space = Staff_symbol_referencer::staff_space (first); + thickness = scm_to_double (current->get_property ("thickness")); + } move_related_items_to_column (current, first->get_column (), - distance); + distance); Real head_width = scm_to_double (current->get_property ("head-width")); distance += head_width - thickness; if (Rhythmic_head::dot_count (current) > 0) - /* - Move dots above/behind the ligature. - dots should also avoid staff lines. - */ - { - Grob *dot_gr = Rhythmic_head::get_dots (current); - - bool const on_line = Staff_symbol_referencer::on_line - (current, - robust_scm2int (current->get_property ("staff-position"), 0)); - Real vert_shift = on_line ? staff_space * 0.5 : 0.0; - bool const flexa_begin = - scm_to_int (current->get_property ("primitive")) - & MLP_FLEXA_BEGIN; - - if (i + 1 < primitives.size ()) - /* - dot in the midst => avoid next note; - what to avoid and where depends on - being on a line or between lines - */ - { - int const delta = - scm_to_int (current->get_property ("delta-position")); - if (flexa_begin) - vert_shift += delta < 0 - ? staff_space : (on_line ? -2.0 : -1.0) * staff_space; - else if (on_line) - { - if (0 < delta && delta < 3) - vert_shift -= staff_space; - } - else if (delta == 1 || delta == -1) - vert_shift -= delta * staff_space; - } - - dot_gr->translate_axis (vert_shift, Y_AXIS); - - /* - move all dots behind head - */ - dot_gr->translate_axis - ((flexa_begin ? staff_space * 0.6 : head_width) - 2.0*thickness, X_AXIS); - } + /* + Move dots above/behind the ligature. + dots should also avoid staff lines. + */ + { + Grob *dot_gr = Rhythmic_head::get_dots (current); + + bool const on_line = Staff_symbol_referencer::on_line + (current, + robust_scm2int (current->get_property ("staff-position"), 0)); + Real vert_shift = on_line ? staff_space * 0.5 : 0.0; + bool const flexa_begin + = scm_to_int (current->get_property ("primitive")) + & MLP_FLEXA_BEGIN; + + if (i + 1 < primitives.size ()) + /* + dot in the midst => avoid next note; + what to avoid and where depends on + being on a line or between lines + */ + { + int const delta + = scm_to_int (current->get_property ("delta-position")); + if (flexa_begin) + vert_shift += delta < 0 + ? staff_space : (on_line ? -2.0 : -1.0) * staff_space; + else if (on_line) + { + if (0 < delta && delta < 3) + vert_shift -= staff_space; + } + else if (delta == 1 || delta == -1) + vert_shift -= delta * staff_space; + } + + dot_gr->translate_axis (vert_shift, Y_AXIS); + + /* + move all dots behind head + */ + dot_gr->translate_axis + ((flexa_begin ? staff_space * 0.6 : head_width) - 2.0 * thickness, X_AXIS); + } } } void Mensural_ligature_engraver::build_ligature (Spanner *ligature, - vector<Grob_info> primitives) + vector<Grob_info> primitives) { transform_heads (primitives); propagate_properties (ligature, primitives); @@ -476,16 +477,16 @@ ADD_ACKNOWLEDGER (Mensural_ligature_engraver, rest); ADD_ACKNOWLEDGER (Mensural_ligature_engraver, ligature_head); ADD_TRANSLATOR (Mensural_ligature_engraver, - /* doc */ - "Handle @code{Mensural_ligature_events} by glueing special" - " ligature heads together.", + /* doc */ + "Handle @code{Mensural_ligature_events} by glueing special" + " ligature heads together.", - /* create */ - "MensuralLigature ", + /* create */ + "MensuralLigature ", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/mensural-ligature.cc b/lily/mensural-ligature.cc index ad2f0918a9..f7de22edcf 100644 --- a/lily/mensural-ligature.cc +++ b/lily/mensural-ligature.cc @@ -40,10 +40,10 @@ */ Stencil brew_flexa (Grob *me, - bool solid, - Real width, - Real thickness, - bool begin) + bool solid, + Real width, + Real thickness, + bool begin) { Real staff_space = Staff_symbol_referencer::staff_space (me); @@ -60,8 +60,8 @@ brew_flexa (Grob *me, Real height = staff_space - horizontal_line_thickness; Stencil stencil; - Real const interval = - robust_scm2double (me->get_property ("flexa-interval"), 0.0); + Real const interval + = robust_scm2double (me->get_property ("flexa-interval"), 0.0); Real slope = (interval / 2.0 * staff_space) / width; // Compensate optical illusion regarding vertical position of left @@ -78,22 +78,22 @@ brew_flexa (Grob *me, { stencil = Lookup::beam (corrected_slope, thickness, height, 0.0); if (!begin) - { - stencil.translate_axis (width*0.5 - thickness, X_AXIS); - stencil.translate_axis (corrected_slope * (width*0.5 - thickness), + { + stencil.translate_axis (width * 0.5 - thickness, X_AXIS); + stencil.translate_axis (corrected_slope * (width * 0.5 - thickness), Y_AXIS); } - Stencil bottom_edge = - Lookup::beam (corrected_slope, width * 0.5, horizontal_line_thickness, - 0.0); - bottom_edge.translate_axis (-0.5*height, Y_AXIS); + Stencil bottom_edge + = Lookup::beam (corrected_slope, width * 0.5, horizontal_line_thickness, + 0.0); + bottom_edge.translate_axis (-0.5 * height, Y_AXIS); stencil.add_stencil (bottom_edge); - Stencil top_edge = - Lookup::beam (corrected_slope, width * 0.5, horizontal_line_thickness, - 0.0); - top_edge.translate_axis (+0.5*height, Y_AXIS); + Stencil top_edge + = Lookup::beam (corrected_slope, width * 0.5, horizontal_line_thickness, + 0.0); + top_edge.translate_axis (+0.5 * height, Y_AXIS); stencil.add_stencil (top_edge); } @@ -116,7 +116,7 @@ internal_brew_primitive (Grob *me) if (primitive_scm == SCM_EOL) { programming_error ("Mensural_ligature:" - " undefined primitive -> ignoring grob"); + " undefined primitive -> ignoring grob"); return Lookup::blank (Box (Interval (0, 0), Interval (0, 0))); } int primitive = scm_to_int (primitive_scm); @@ -127,10 +127,10 @@ internal_brew_primitive (Grob *me) Real flexa_width = 0.0; Real staff_space = Staff_symbol_referencer::staff_space (me); - bool const color = - me->get_property ("style") == ly_symbol2scm ("blackpetrucci"); - bool const semi = - me->get_property ("style") == ly_symbol2scm ("semipetrucci"); + bool const color + = me->get_property ("style") == ly_symbol2scm ("blackpetrucci"); + bool const semi + = me->get_property ("style") == ly_symbol2scm ("semipetrucci"); if (primitive & MLP_ANY) { @@ -139,7 +139,7 @@ internal_brew_primitive (Grob *me) } if (primitive & MLP_FLEXA) flexa_width = robust_scm2double (me->get_property ("flexa-width"), 2.0) - * staff_space; + * staff_space; int const note_shape = primitive & MLP_ANY; @@ -149,27 +149,27 @@ internal_brew_primitive (Grob *me) return Lookup::blank (Box (Interval (0, 0), Interval (0, 0))); case MLP_LONGA: // mensural brevis head with right cauda out = Font_interface::get_default_font (me)->find_by_name - (color ? "noteheads.sM2blackmensural" : - semi ? "noteheads.sM2semimensural" : "noteheads.sM2mensural"); + (color ? "noteheads.sM2blackmensural" + : semi ? "noteheads.sM2semimensural" : "noteheads.sM2mensural"); break; case MLP_BREVIS: // mensural brevis head out = Font_interface::get_default_font (me)->find_by_name - (color ? "noteheads.sM1blackmensural" : - semi ? "noteheads.sM1semimensural" : "noteheads.sM1mensural"); + (color ? "noteheads.sM1blackmensural" + : semi ? "noteheads.sM1semimensural" : "noteheads.sM1mensural"); break; case MLP_MAXIMA: // should be mensural maxima head without stem out = Font_interface::get_default_font (me)->find_by_name - (color ? "noteheads.sM3blackligmensural" : - semi ? "noteheads.sM3semiligmensural" : "noteheads.sM3ligmensural"); + (color ? "noteheads.sM3blackligmensural" + : semi ? "noteheads.sM3semiligmensural" : "noteheads.sM3ligmensural"); break; case MLP_FLEXA_BEGIN: case MLP_FLEXA_END: out = brew_flexa (me, color, flexa_width, thickness, - note_shape == MLP_FLEXA_BEGIN); + note_shape == MLP_FLEXA_BEGIN); break; default: programming_error (_ ("Mensural_ligature:" - " unexpected case fall-through")); + " unexpected case fall-through")); return Lookup::blank (Box (Interval (0, 0), Interval (0, 0))); } @@ -182,10 +182,10 @@ internal_brew_primitive (Grob *me) Real y_bottom = 0.0, y_top = 3.0 * staff_space; if (primitive & MLP_DOWN) - { - y_bottom = -y_top; - y_top = 0.0; - } + { + y_bottom = -y_top; + y_top = 0.0; + } Interval x_extent (0, thickness); Interval y_extent (y_bottom, y_top); @@ -199,38 +199,38 @@ internal_brew_primitive (Grob *me) { int join_right = scm_to_int (me->get_property ("delta-position")); if (join_right) - { - Real y_top = join_right * 0.5 * staff_space; - Real y_bottom = 0.0; - - if (y_top < 0.0) - { - y_bottom = y_top; - y_top = 0.0; - - /* - if the previous note is longa-shaped, - the joining line may hide the stem, so made it longer - to serve as stem as well - */ - if (primitive & MLP_LONGA) - /* - instead of 3.0 the length of a longa stem should be used - Font_interface::get_default_font (???)->find_by_name - ("noteheads.s-2mensural").extent (Y_AXIS).length () * 0.5 - */ - y_bottom -= 3.0 * staff_space; - } - - Interval x_extent (width - thickness, width); - Interval y_extent (y_bottom, y_top); - Box join_box (x_extent, y_extent); - Stencil join = Lookup::round_filled_box (join_box, blotdiameter); - - out.add_stencil (join); - } + { + Real y_top = join_right * 0.5 * staff_space; + Real y_bottom = 0.0; + + if (y_top < 0.0) + { + y_bottom = y_top; + y_top = 0.0; + + /* + if the previous note is longa-shaped, + the joining line may hide the stem, so made it longer + to serve as stem as well + */ + if (primitive & MLP_LONGA) + /* + instead of 3.0 the length of a longa stem should be used + Font_interface::get_default_font (???)->find_by_name + ("noteheads.s-2mensural").extent (Y_AXIS).length () * 0.5 + */ + y_bottom -= 3.0 * staff_space; + } + + Interval x_extent (width - thickness, width); + Interval y_extent (y_bottom, y_top); + Box join_box (x_extent, y_extent); + Stencil join = Lookup::round_filled_box (join_box, blotdiameter); + + out.add_stencil (join); + } else - programming_error (_ ("Mensural_ligature: (join_right == 0)")); + programming_error (_ ("Mensural_ligature: (join_right == 0)")); } #if 0 /* what happend with the ledger lines? */ @@ -261,14 +261,14 @@ Mensural_ligature::print (SCM) } ADD_INTERFACE (Mensural_ligature, - "A mensural ligature.", - - /* properties */ - "delta-position " - "ligature-flexa " - "head-width " - "add-join " - "flexa-interval " - "primitive " - "thickness " - ); + "A mensural ligature.", + + /* properties */ + "delta-position " + "ligature-flexa " + "head-width " + "add-join " + "flexa-interval " + "primitive " + "thickness " + ); diff --git a/lily/metronome-engraver.cc b/lily/metronome-engraver.cc index 09606c261e..b6d721ad24 100644 --- a/lily/metronome-engraver.cc +++ b/lily/metronome-engraver.cc @@ -72,7 +72,7 @@ static bool safe_is_member (SCM scm, SCM lst) { return scm_list_p (lst) == SCM_BOOL_T - && scm_member (scm, lst) != SCM_BOOL_F; + && scm_member (scm, lst) != SCM_BOOL_F; } void @@ -85,10 +85,10 @@ Metronome_mark_engraver::acknowledge_break_aligned (Grob_info info) == ly_symbol2scm ("staff-bar")) bar_ = g; else if (text_ - && !support_ - && safe_is_member (g->get_property ("break-align-symbol"), - text_->get_property ("break-align-symbols")) - && Item::break_visible (g)) + && !support_ + && safe_is_member (g->get_property ("break-align-symbol"), + text_->get_property ("break-align-symbols")) + && Item::break_visible (g)) { support_ = g; text_->set_parent (g, X_AXIS); @@ -115,10 +115,10 @@ Metronome_mark_engraver::acknowledge_grob (Grob_info info) if (text_) for (SCM s = text_->get_property ("non-break-align-symbols"); - scm_is_pair (s); - s = scm_cdr (s)) + scm_is_pair (s); + s = scm_cdr (s)) if (g->internal_has_interface (scm_car (s))) - text_->set_parent (g, X_AXIS); + text_->set_parent (g, X_AXIS); } void @@ -127,25 +127,25 @@ Metronome_mark_engraver::stop_translation_timestep () if (text_) { if (text_->get_parent (X_AXIS) - && text_->get_parent (X_AXIS)->internal_has_interface (ly_symbol2scm ("multi-measure-rest-interface")) - && bar_) - text_->set_parent (bar_, X_AXIS); + && text_->get_parent (X_AXIS)->internal_has_interface (ly_symbol2scm ("multi-measure-rest-interface")) + && bar_) + text_->set_parent (bar_, X_AXIS); else if (!support_) - { - /* - Gardner Read "Music Notation", p.278 - - Align the metronome mark over the time signature (or the - first notational element of the measure if no time - signature is present in that measure). - */ - if (Grob *mc = unsmob_grob (get_property ("currentMusicalColumn"))) - text_->set_parent (mc, X_AXIS); - else if (Grob *cc = unsmob_grob (get_property ("currentCommandColumn"))) - text_->set_parent (cc, X_AXIS); - } + { + /* + Gardner Read "Music Notation", p.278 + + Align the metronome mark over the time signature (or the + first notational element of the measure if no time + signature is present in that measure). + */ + if (Grob *mc = unsmob_grob (get_property ("currentMusicalColumn"))) + text_->set_parent (mc, X_AXIS); + else if (Grob *cc = unsmob_grob (get_property ("currentCommandColumn"))) + text_->set_parent (cc, X_AXIS); + } text_->set_object ("side-support-elements", - grob_list_to_grob_array (get_property ("stavesFound"))); + grob_list_to_grob_array (get_property ("stavesFound"))); text_ = 0; support_ = 0; bar_ = 0; @@ -162,8 +162,8 @@ Metronome_mark_engraver::process_music () SCM proc = get_property ("metronomeMarkFormatter"); SCM result = scm_call_2 (proc, - tempo_ev_->self_scm (), - context ()->self_scm ()); + tempo_ev_->self_scm (), + context ()->self_scm ()); text_->set_property ("text", result); } @@ -174,23 +174,23 @@ ADD_ACKNOWLEDGER (Metronome_mark_engraver, break_alignment); ADD_ACKNOWLEDGER (Metronome_mark_engraver, grob); ADD_TRANSLATOR (Metronome_mark_engraver, - /* doc */ - "Engrave metronome marking. This delegates the formatting" - " work to the function in the @code{metronomeMarkFormatter}" - " property. The mark is put over all staves. The staves are" - " taken from the @code{stavesFound} property, which is" - " maintained by @ref{Staff_collecting_engraver}.", - - /* create */ - "MetronomeMark ", - - /* read */ - "currentCommandColumn " - "currentMusicalColumn " - "metronomeMarkFormatter " - "stavesFound " - "tempoHideNote ", - - /* write */ - "" - ); + /* doc */ + "Engrave metronome marking. This delegates the formatting" + " work to the function in the @code{metronomeMarkFormatter}" + " property. The mark is put over all staves. The staves are" + " taken from the @code{stavesFound} property, which is" + " maintained by @ref{Staff_collecting_engraver}.", + + /* create */ + "MetronomeMark ", + + /* read */ + "currentCommandColumn " + "currentMusicalColumn " + "metronomeMarkFormatter " + "stavesFound " + "tempoHideNote ", + + /* write */ + "" + ); diff --git a/lily/midi-chunk.cc b/lily/midi-chunk.cc index 0aa11eb549..804a6e1a07 100644 --- a/lily/midi-chunk.cc +++ b/lily/midi-chunk.cc @@ -2,7 +2,7 @@ This file is part of LilyPond, the GNU music typesetter. Copyright (C) 2007--2011 Han-Wen Nienhuys <hanwen@lilypond.org> - + LilyPond is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ #include "string-convert.hh" Midi_track::Midi_track (int number, bool port) - : number_ (number) + : number_ (number) { // 4D 54 72 6B MTrk // 00 00 00 3B chunk length (59) @@ -42,14 +42,14 @@ Midi_track::Midi_track (int number, bool port) // mi = 1: minor key char const *data_str0 = "" - // "00" "ff58" "0404" "0218" "08" - // "00" "ff51" "0307" "a120" - // why a key at all, in midi? - // key: C - // "00" "ff59" "02" "00" "00" - // key: F (scsii-menuetto) - // "00" "ff59" "02" "ff" "00" - ; + // "00" "ff58" "0404" "0218" "08" + // "00" "ff51" "0307" "a120" + // why a key at all, in midi? + // key: C + // "00" "ff59" "02" "00" "00" + // key: F (scsii-menuetto) + // "00" "ff59" "02" "ff" "00" + ; string data_string; // only for format 0 (currently using format 1)? @@ -58,7 +58,7 @@ Midi_track::Midi_track (int number, bool port) if (port) { string port = "00" "ff" "21" "01" - + String_convert::int2hex (number_, 2, '0'); + + String_convert::int2hex (number_, 2, '0'); data_string += String_convert::hex2bin (port); } @@ -82,18 +82,17 @@ Midi_track::data_string () const { string str = Midi_chunk::data_string (); - for (vector<Midi_event*>::const_iterator i (events_.begin ()); - i != events_.end (); i ++) + for (vector<Midi_event *>::const_iterator i (events_.begin ()); + i != events_.end (); i++) { str += (*i)->to_string (); } return str; } - Midi_track::~Midi_track () { - junk_pointers (events_); + junk_pointers (events_); } /**************************************************************** @@ -114,7 +113,7 @@ Midi_event::to_string () const } /**************************************************************** header -*/ +*/ Midi_header::Midi_header (int format, int tracks, int clocks_per_4) { @@ -132,13 +131,12 @@ Midi_header::Midi_header (int format, int tracks, int clocks_per_4) set ("MThd", str, ""); } - /**************************************************************** chunk */ Midi_chunk::~Midi_chunk () { - + } void @@ -161,7 +159,7 @@ Midi_chunk::to_string () const string str = header_string_; string dat = data_string (); string length_string = String_convert::int2hex (dat.length () - + footer_string_.length (), 8, '0'); + + footer_string_.length (), 8, '0'); length_string = String_convert::hex2bin (length_string); str += length_string; diff --git a/lily/midi-item.cc b/lily/midi-item.cc index aa96849f26..a52c990ae0 100644 --- a/lily/midi-item.cc +++ b/lily/midi-item.cc @@ -56,8 +56,6 @@ Midi_item::get_midi (Audio_item *a) return 0; } - - Midi_duration::Midi_duration (Real seconds_f) { seconds_ = seconds_f; @@ -70,8 +68,8 @@ Midi_duration::to_string () const } Midi_instrument::Midi_instrument (Audio_instrument *a) - : Midi_channel_item (a) - , audio_ (a) + : Midi_channel_item (a), + audio_ (a) { audio_->str_ = String_convert::to_lower (audio_->str_); } @@ -124,9 +122,9 @@ int2midi_varint_string (int i) { str += ::to_string ((char)buffer); if (buffer & 0x80) - buffer >>= 8; + buffer >>= 8; else - break; + break; } return str; } @@ -149,8 +147,8 @@ Midi_key::to_string () const } Midi_time_signature::Midi_time_signature (Audio_time_signature *a) - : audio_ (a) - , clocks_per_1_ (18) + : audio_ (a), + clocks_per_1_ (18) { } @@ -166,8 +164,6 @@ Midi_time_signature::to_string () const int den = audio_->one_beat_; - - string str = "ff5804"; str += String_convert::int2hex (num, 2, '0'); str += String_convert::int2hex (intlog2 (den), 2, '0'); @@ -177,10 +173,10 @@ Midi_time_signature::to_string () const } Midi_note::Midi_note (Audio_note *a) - : Midi_channel_item (a) - , audio_ (a) - , dynamic_byte_ (a->dynamic_ && a->dynamic_->volume_ >= 0 - ? Byte (a->dynamic_->volume_ * 0x7f) : Byte (0x5a)) + : Midi_channel_item (a), + audio_ (a), + dynamic_byte_ (a->dynamic_ && a->dynamic_->volume_ >= 0 + ? Byte (a->dynamic_->volume_ * 0x7f) : Byte (0x5a)) { } @@ -188,7 +184,7 @@ int Midi_note::get_fine_tuning () const { Rational tune = (audio_->pitch_.tone_pitch () - + audio_->transposing_.tone_pitch ()) * Rational (2); + + audio_->transposing_.tone_pitch ()) * Rational (2); tune -= Rational (get_semitone_pitch ()); tune *= PITCH_WHEEL_SEMITONE; @@ -199,7 +195,7 @@ int Midi_note::get_semitone_pitch () const { double tune = double ((audio_->pitch_.tone_pitch () - + audio_->transposing_.tone_pitch ()) * Rational (2)); + + audio_->transposing_.tone_pitch ()) * Rational (2)); return int (rint (tune)); } @@ -252,7 +248,7 @@ Midi_note_off::to_string () const // Move pitch wheel back to the central position. str += ::to_string ((char) 0x00); str += ::to_string ((char) (0xE0 + channel_)); - str += ::to_string ((char) (PITCH_WHEEL_CENTER &0x7F)); + str += ::to_string ((char) (PITCH_WHEEL_CENTER & 0x7F)); str += ::to_string ((char) (PITCH_WHEEL_CENTER >> 7)); } @@ -260,8 +256,8 @@ Midi_note_off::to_string () const } Midi_dynamic::Midi_dynamic (Audio_dynamic *a) - : Midi_channel_item (a) - , audio_ (a) + : Midi_channel_item (a), + audio_ (a) { } @@ -287,15 +283,15 @@ Midi_dynamic::to_string () const int const volume_default = 100; if (audio_->volume_ < 0 || audio_->silent_) volume = volume_default; - + str += ::to_string ((char)0x07); str += ::to_string ((char)volume); return str; } Midi_piano_pedal::Midi_piano_pedal (Audio_piano_pedal *a) - : Midi_channel_item (a) - , audio_ (a) + : Midi_channel_item (a), + audio_ (a) { } @@ -349,5 +345,5 @@ Midi_text::to_string () const char const * Midi_item::name () const { - return this->class_name (); + return this->class_name (); } diff --git a/lily/midi-walker.cc b/lily/midi-walker.cc index 6fbb780a1b..f287f2a788 100644 --- a/lily/midi-walker.cc +++ b/lily/midi-walker.cc @@ -46,10 +46,10 @@ compare (Midi_note_event const &left, Midi_note_event const &right) } bool -audio_item_less (Audio_item * const a, - Audio_item * const b) +audio_item_less (Audio_item *const a, + Audio_item *const b) { - return a->get_column ()->when_ < b->get_column ()->when_; + return a->get_column ()->when_ < b->get_column ()->when_; } Midi_walker::Midi_walker (Audio_staff *audio_staff, Midi_track *track) @@ -89,39 +89,39 @@ Midi_walker::do_start_note (Midi_note *note) { /* if this pitch already in queue */ if (stop_note_queue[i].val->get_semitone_pitch () - == note->get_semitone_pitch ()) - { - int queued_ticks - = stop_note_queue[i].val->audio_->audio_column_->ticks (); - // If the two notes started at the same time, or option is set, - if (now_ticks == queued_ticks || merge_unisons_) - { - // merge them. - if (stop_note_queue[i].key < stop_ticks) - { - Midi_note_event e; - e.val = stop_note_queue[i].val; - e.key = stop_ticks; - stop_note_queue[i].ignore_ = true; - stop_note_queue.insert (e); - } - note = 0; - break; - } - else - { - // A note was played that interruped a played note. - // Stop the old note, and continue to the greatest moment - // between the two. - if (stop_note_queue[i].key > stop_ticks) - { - stop_ticks = stop_note_queue[i].key; - } - output_event (now_ticks, stop_note_queue[i].val); - stop_note_queue[i].ignore_ = true; - break; - } - } + == note->get_semitone_pitch ()) + { + int queued_ticks + = stop_note_queue[i].val->audio_->audio_column_->ticks (); + // If the two notes started at the same time, or option is set, + if (now_ticks == queued_ticks || merge_unisons_) + { + // merge them. + if (stop_note_queue[i].key < stop_ticks) + { + Midi_note_event e; + e.val = stop_note_queue[i].val; + e.key = stop_ticks; + stop_note_queue[i].ignore_ = true; + stop_note_queue.insert (e); + } + note = 0; + break; + } + else + { + // A note was played that interruped a played note. + // Stop the old note, and continue to the greatest moment + // between the two. + if (stop_note_queue[i].key > stop_ticks) + { + stop_ticks = stop_note_queue[i].key; + } + output_event (now_ticks, stop_note_queue[i].val); + stop_note_queue[i].ignore_ = true; + break; + } + } } if (note) @@ -144,9 +144,9 @@ Midi_walker::do_stop_notes (int max_ticks) { Midi_note_event e = stop_note_queue.get (); if (e.ignore_) - { - continue; - } + { + continue; + } int stop_ticks = e.key; Midi_note *note = e.val; @@ -183,22 +183,22 @@ Midi_walker::process () if (Midi_item *midi = get_midi (audio)) { if (Midi_note *note = dynamic_cast<Midi_note *> (midi)) - { - if (note->audio_->length_mom_.to_bool ()) - do_start_note (note); - } + { + if (note->audio_->length_mom_.to_bool ()) + do_start_note (note); + } else - output_event (audio->audio_column_->ticks (), midi); + output_event (audio->audio_column_->ticks (), midi); } } -Midi_item* +Midi_item * Midi_walker::get_midi (Audio_item *i) { Midi_item *mi = Midi_item::get_midi (i); if (percussion_) - if (Midi_channel_item *mci = dynamic_cast<Midi_channel_item*> (mi)) + if (Midi_channel_item *mci = dynamic_cast<Midi_channel_item *> (mi)) mci->channel_ = 9; midi_events_.push_back (mi); @@ -212,7 +212,7 @@ Midi_walker::ok () const } void -Midi_walker::operator ++ (int) +Midi_walker::operator ++(int) { assert (ok ()); index_++; diff --git a/lily/misc.cc b/lily/misc.cc index 4b7dc472ed..0fa4a90240 100644 --- a/lily/misc.cc +++ b/lily/misc.cc @@ -18,7 +18,6 @@ along with LilyPond. If not, see <http://www.gnu.org/licenses/>. */ - #include "misc.hh" #include "warn.hh" @@ -55,13 +54,11 @@ directed_round (Real f, Direction d) return ceil (f); } - - /* 0 at threshold, 1 at 0, with 1/x falloff. */ Real -peak_around (Real epsilon, Real threshold, Real x) +peak_around (Real epsilon, Real threshold, Real x) { if (x < 0) return 1.0; @@ -69,29 +66,29 @@ peak_around (Real epsilon, Real threshold, Real x) } /* - 0 at 0, 1 at standard_x, and increasing thereafter. + 0 at 0, 1 at standard_x, and increasing thereafter. */ Real convex_amplifier (Real standard_x, Real increase_factor, Real x) { - return (exp (increase_factor * x / standard_x) - 1.0) / (exp (increase_factor) - 1.0); + return (exp (increase_factor * x / standard_x) - 1.0) / (exp (increase_factor) - 1.0); } string camel_case_to_lisp_identifier (string in) { vector<char> out; - + /* don't add '-' before first character */ out.push_back (char (tolower (in[0]))); - + for (size_t inpos = 1; inpos < in.size (); inpos++) { if (isupper (in[inpos])) - out.push_back ('-'); - out.push_back ( char(tolower (in[inpos]))); + out.push_back ('-'); + out.push_back ( char (tolower (in[inpos]))); } - + string result (&out[0], out.size ()); replace_all (&result, '_', '-'); diff --git a/lily/modified-font-metric.cc b/lily/modified-font-metric.cc index eff730176b..1fee1b9842 100644 --- a/lily/modified-font-metric.cc +++ b/lily/modified-font-metric.cc @@ -27,7 +27,7 @@ using namespace std; #include "program-option.hh" Modified_font_metric::Modified_font_metric (Font_metric *fm, - Real magnification) + Real magnification) { magnification_ = magnification; diff --git a/lily/module-scheme.cc b/lily/module-scheme.cc index f2e66459a0..bcea57a6fd 100644 --- a/lily/module-scheme.cc +++ b/lily/module-scheme.cc @@ -23,7 +23,6 @@ #include "main.hh" #include "std-string.hh" - /* If a variable is changed in SRC, then DEST doesn't see the definitions. @@ -31,9 +30,9 @@ static SCM module_define_closure_func (void *closure, - SCM key, - SCM val, - SCM /* result */) + SCM key, + SCM val, + SCM /* result */) { SCM module = (SCM) closure; if (scm_variable_bound_p (val) == SCM_BOOL_T) @@ -42,18 +41,17 @@ module_define_closure_func (void *closure, } LY_DEFINE (ly_module_copy, "ly:module-copy", - 2, 0, 0, (SCM dest, SCM src), - "Copy all bindings from module @var{src} into @var{dest}.") + 2, 0, 0, (SCM dest, SCM src), + "Copy all bindings from module @var{src} into @var{dest}.") { #define FUNC_NAME __FUNCTION__ SCM_VALIDATE_MODULE (1, src); scm_internal_hash_fold ((scm_t_hash_fold_fn) &module_define_closure_func, - (void *) dest, - SCM_EOL, SCM_MODULE_OBARRAY (src)); + (void *) dest, + SCM_EOL, SCM_MODULE_OBARRAY (src)); return SCM_UNSPECIFIED; } - /* Lookup SYM, but don't give error when it is not defined. */ SCM ly_module_lookup (SCM module, SCM sym) @@ -68,18 +66,18 @@ ly_module_lookup (SCM module, SCM sym) /* Lookup SYM in a list of modules, which do not have to be related. Return the first instance. */ LY_DEFINE (ly_modules_lookup, "ly:modules-lookup", - 2, 1, 0, - (SCM modules, SCM sym, SCM def), - "Look up @var{sym} in the list @var{modules}," - " returning the first occurence. If not found, return" - " @var{def} or @code{#f} if @var{def} isn't specified.") + 2, 1, 0, + (SCM modules, SCM sym, SCM def), + "Look up @var{sym} in the list @var{modules}," + " returning the first occurence. If not found, return" + " @var{def} or @code{#f} if @var{def} isn't specified.") { for (SCM s = modules; scm_is_pair (s); s = scm_cdr (s)) { SCM mod = scm_car (s); SCM v = ly_module_lookup (mod, sym); if (SCM_VARIABLEP (v) && SCM_VARIABLE_REF (v) != SCM_UNDEFINED) - return scm_variable_ref (v); + return scm_variable_ref (v); } if (def != SCM_UNDEFINED) diff --git a/lily/moment-scheme.cc b/lily/moment-scheme.cc index 6b10541403..cc43ea40bf 100644 --- a/lily/moment-scheme.cc +++ b/lily/moment-scheme.cc @@ -21,14 +21,14 @@ /* TODO: add optional factor argument. */ LY_DEFINE (ly_make_moment, "ly:make-moment", - 2, 2, 0, (SCM n, SCM d, SCM gn, SCM gd), - "Create the rational number with main timing @var{n}/@var{d}," - " and optional grace timing @var{gn}/@var{gd}.\n" - "\n" - "A @dfn{moment} is a point in musical time. It consists of" - " a pair of rationals (@var{m},@tie{}@var{g}), where @var{m} is" - " the timing for the main notes, and @var{g} the timing for" - " grace notes. In absence of grace notes, @var{g}@tie{}is zero.") + 2, 2, 0, (SCM n, SCM d, SCM gn, SCM gd), + "Create the rational number with main timing @var{n}/@var{d}," + " and optional grace timing @var{gn}/@var{gd}.\n" + "\n" + "A @dfn{moment} is a point in musical time. It consists of" + " a pair of rationals (@var{m},@tie{}@var{g}), where @var{m} is" + " the timing for the main notes, and @var{g} the timing for" + " grace notes. In absence of grace notes, @var{g}@tie{}is zero.") { LY_ASSERT_TYPE (scm_is_integer, n, 1); LY_ASSERT_TYPE (scm_is_integer, d, 2); @@ -48,16 +48,16 @@ LY_DEFINE (ly_make_moment, "ly:make-moment", } return Moment (Rational (scm_to_int (n), scm_to_int (d)), - Rational (grace_num, grace_den)).smobbed_copy (); + Rational (grace_num, grace_den)).smobbed_copy (); } LY_DEFINE (ly_moment_sub, "ly:moment-sub", - 2, 0, 0, (SCM a, SCM b), - "Subtract two moments.") + 2, 0, 0, (SCM a, SCM b), + "Subtract two moments.") { - LY_ASSERT_SMOB (Moment, a, 1); + LY_ASSERT_SMOB (Moment, a, 1); LY_ASSERT_SMOB (Moment, b, 2); - + Moment *ma = unsmob_moment (a); Moment *mb = unsmob_moment (b); @@ -65,11 +65,11 @@ LY_DEFINE (ly_moment_sub, "ly:moment-sub", } LY_DEFINE (ly_moment_add, "ly:moment-add", - 2, 0, 0, (SCM a, SCM b), - "Add two moments.") + 2, 0, 0, (SCM a, SCM b), + "Add two moments.") { - LY_ASSERT_SMOB (Moment, a, 1); - LY_ASSERT_SMOB (Moment, b, 2); + LY_ASSERT_SMOB (Moment, a, 1); + LY_ASSERT_SMOB (Moment, b, 2); Moment *ma = unsmob_moment (a); Moment *mb = unsmob_moment (b); @@ -78,11 +78,11 @@ LY_DEFINE (ly_moment_add, "ly:moment-add", } LY_DEFINE (ly_moment_mul, "ly:moment-mul", - 2, 0, 0, (SCM a, SCM b), - "Multiply two moments.") + 2, 0, 0, (SCM a, SCM b), + "Multiply two moments.") { - LY_ASSERT_SMOB (Moment, a, 1); - LY_ASSERT_SMOB (Moment, b, 2); + LY_ASSERT_SMOB (Moment, a, 1); + LY_ASSERT_SMOB (Moment, b, 2); Moment *ma = unsmob_moment (a); Moment *mb = unsmob_moment (b); @@ -90,33 +90,33 @@ LY_DEFINE (ly_moment_mul, "ly:moment-mul", } LY_DEFINE (ly_moment_div, "ly:moment-div", - 2, 0, 0, (SCM a, SCM b), - "Divide two moments.") + 2, 0, 0, (SCM a, SCM b), + "Divide two moments.") { - LY_ASSERT_SMOB (Moment, a, 1); - LY_ASSERT_SMOB (Moment, b, 2); + LY_ASSERT_SMOB (Moment, a, 1); + LY_ASSERT_SMOB (Moment, b, 2); Moment *ma = unsmob_moment (a); Moment *mb = unsmob_moment (b); - + return (*ma / * mb).smobbed_copy (); } LY_DEFINE (ly_moment_mod, "ly:moment-mod", - 2, 0, 0, (SCM a, SCM b), - "Modulo of two moments.") + 2, 0, 0, (SCM a, SCM b), + "Modulo of two moments.") { - LY_ASSERT_SMOB (Moment, a, 1); - LY_ASSERT_SMOB (Moment, b, 2); - + LY_ASSERT_SMOB (Moment, a, 1); + LY_ASSERT_SMOB (Moment, b, 2); + Moment *ma = unsmob_moment (a); Moment *mb = unsmob_moment (b); return (*ma % * mb).smobbed_copy (); } LY_DEFINE (ly_moment_grace_numerator, "ly:moment-grace-numerator", - 1, 0, 0, (SCM mom), - "Extract numerator from grace timing.") + 1, 0, 0, (SCM mom), + "Extract numerator from grace timing.") { LY_ASSERT_SMOB (Moment, mom, 1); @@ -126,8 +126,8 @@ LY_DEFINE (ly_moment_grace_numerator, "ly:moment-grace-numerator", } LY_DEFINE (ly_moment_grace_denominator, "ly:moment-grace-denominator", - 1, 0, 0, (SCM mom), - "Extract denominator from grace timing.") + 1, 0, 0, (SCM mom), + "Extract denominator from grace timing.") { LY_ASSERT_SMOB (Moment, mom, 1); Moment *ma = unsmob_moment (mom); @@ -135,8 +135,8 @@ LY_DEFINE (ly_moment_grace_denominator, "ly:moment-grace-denominator", return scm_from_int64 (ma->grace_part_.denominator ()); } LY_DEFINE (ly_moment_main_numerator, "ly:moment-main-numerator", - 1, 0, 0, (SCM mom), - "Extract numerator from main timing.") + 1, 0, 0, (SCM mom), + "Extract numerator from main timing.") { LY_ASSERT_SMOB (Moment, mom, 1); Moment *ma = unsmob_moment (mom); @@ -145,8 +145,8 @@ LY_DEFINE (ly_moment_main_numerator, "ly:moment-main-numerator", } LY_DEFINE (ly_moment_main_denominator, "ly:moment-main-denominator", - 1, 0, 0, (SCM mom), - "Extract denominator from main timing.") + 1, 0, 0, (SCM mom), + "Extract denominator from main timing.") { LY_ASSERT_SMOB (Moment, mom, 1); Moment *ma = unsmob_moment (mom); @@ -155,12 +155,12 @@ LY_DEFINE (ly_moment_main_denominator, "ly:moment-main-denominator", } LY_DEFINE (ly_moment_less_p, "ly:moment<?", - 2, 0, 0, (SCM a, SCM b), - "Compare two moments.") + 2, 0, 0, (SCM a, SCM b), + "Compare two moments.") { - LY_ASSERT_SMOB (Moment, a, 1); - LY_ASSERT_SMOB (Moment, b, 2); - + LY_ASSERT_SMOB (Moment, a, 1); + LY_ASSERT_SMOB (Moment, b, 2); + Moment *ma = unsmob_moment (a); Moment *mb = unsmob_moment (b); diff --git a/lily/moment.cc b/lily/moment.cc index ae6ea63dd2..94d67a7b10 100644 --- a/lily/moment.cc +++ b/lily/moment.cc @@ -71,10 +71,10 @@ SCM Moment::as_scheme () const { return scm_list_5 (ly_symbol2scm ("ly:make-moment"), - scm_from_int64 (main_part_.num ()), - scm_from_int64 (main_part_.den ()), - scm_from_int64 (grace_part_.num ()), - scm_from_int64 (grace_part_.den ())); + scm_from_int64 (main_part_.num ()), + scm_from_int64 (main_part_.den ()), + scm_from_int64 (grace_part_.num ()), + scm_from_int64 (grace_part_.den ())); } SCM diff --git a/lily/multi-measure-rest-engraver.cc b/lily/multi-measure-rest-engraver.cc index 786ab143c1..590260a66e 100644 --- a/lily/multi-measure-rest-engraver.cc +++ b/lily/multi-measure-rest-engraver.cc @@ -47,7 +47,7 @@ protected: private: Stream_event *rest_ev_; - vector<Stream_event*> text_events_; + vector<Stream_event *> text_events_; int start_measure_; Rational last_main_moment_; Moment stop_moment_; @@ -57,8 +57,8 @@ private: Spanner *last_rest_; Spanner *mmrest_; - vector<Spanner*> numbers_; - vector<Spanner*> last_numbers_; + vector<Spanner *> numbers_; + vector<Spanner *> last_numbers_; }; Multi_measure_rest_engraver::Multi_measure_rest_engraver () @@ -105,53 +105,53 @@ Multi_measure_rest_engraver::process_music () mmrest_ = make_spanner ("MultiMeasureRest", rest_ev_->self_scm ()); Spanner *sp - = make_spanner ("MultiMeasureRestNumber", rest_ev_->self_scm ()); + = make_spanner ("MultiMeasureRestNumber", rest_ev_->self_scm ()); numbers_.push_back (sp); if (text_events_.size ()) - { - for (vsize i = 0; i < text_events_.size (); i++) - { - Stream_event *e = text_events_[i]; - Spanner *sp - = make_spanner ("MultiMeasureRestText", e->self_scm ()); - SCM t = e->get_property ("text"); - SCM dir = e->get_property ("direction"); - sp->set_property ("text", t); - if (is_direction (dir)) - sp->set_property ("direction", dir); - - numbers_.push_back (sp); - } - - /* - Stack different scripts. - */ - Direction d = DOWN; - do - { - Grob *last = 0; - for (vsize i = 0; i < numbers_.size (); i++) - { - if (scm_from_int (d) == numbers_[i]->get_property ("direction")) - { - if (last) - Side_position_interface::add_support (numbers_[i], last); - last = numbers_[i]; - } - } - } - while (flip (&d) != DOWN); - } + { + for (vsize i = 0; i < text_events_.size (); i++) + { + Stream_event *e = text_events_[i]; + Spanner *sp + = make_spanner ("MultiMeasureRestText", e->self_scm ()); + SCM t = e->get_property ("text"); + SCM dir = e->get_property ("direction"); + sp->set_property ("text", t); + if (is_direction (dir)) + sp->set_property ("direction", dir); + + numbers_.push_back (sp); + } + + /* + Stack different scripts. + */ + Direction d = DOWN; + do + { + Grob *last = 0; + for (vsize i = 0; i < numbers_.size (); i++) + { + if (scm_from_int (d) == numbers_[i]->get_property ("direction")) + { + if (last) + Side_position_interface::add_support (numbers_[i], last); + last = numbers_[i]; + } + } + } + while (flip (&d) != DOWN); + } for (vsize i = 0; i < numbers_.size (); i++) - { - Side_position_interface::add_support (numbers_[i], mmrest_); - numbers_[i]->set_parent (mmrest_, Y_AXIS); - } + { + Side_position_interface::add_support (numbers_[i], mmrest_); + numbers_[i]->set_parent (mmrest_, Y_AXIS); + } start_measure_ - = scm_to_int (get_property ("internalBarNumber")); + = scm_to_int (get_property ("internalBarNumber")); } bar_seen_ = bar_seen_ || scm_is_string (get_property ("whichBar")); @@ -176,20 +176,20 @@ Multi_measure_rest_engraver::stop_translation_timestep () if (last_command_item_ && (mmrest_ || last_rest_)) { if (last_rest_) - { - add_bound_item (last_rest_, last_command_item_); - for (vsize i = 0; i < last_numbers_.size (); i++) - add_bound_item (last_numbers_[i], last_command_item_); - } + { + add_bound_item (last_rest_, last_command_item_); + for (vsize i = 0; i < last_numbers_.size (); i++) + add_bound_item (last_numbers_[i], last_command_item_); + } if (mmrest_) - { - add_bound_item (mmrest_, last_command_item_); - for (vsize i = 0; i < numbers_.size (); i++) - add_bound_item (numbers_[i], last_command_item_); + { + add_bound_item (mmrest_, last_command_item_); + for (vsize i = 0; i < numbers_.size (); i++) + add_bound_item (numbers_[i], last_command_item_); - last_command_item_ = 0; - } + last_command_item_ = 0; + } } Moment mp (robust_scm2moment (get_property ("measurePosition"), Moment (0))); @@ -223,8 +223,8 @@ Multi_measure_rest_engraver::start_translation_timestep () int num = cur - start_measure_; /* - We can't plug a markup directly into the grob, since the - measure-count determines the formatting of the mmrest. + We can't plug a markup directly into the grob, since the + measure-count determines the formatting of the mmrest. */ last_rest_->set_property ("measure-count", scm_from_int (num)); @@ -233,21 +233,21 @@ Multi_measure_rest_engraver::start_translation_timestep () Grob *last = last_numbers_.size () ? last_numbers_[0] : 0; if (last && last->get_property ("text") == SCM_EOL) - { - SCM thres = get_property ("restNumberThreshold"); - int t = 1; - if (scm_is_number (thres)) - t = scm_to_int (thres); - - if (num <= t) - last->suicide (); - else - { - SCM text - = scm_number_to_string (scm_from_int (num), scm_from_int (10)); - last->set_property ("text", text); - } - } + { + SCM thres = get_property ("restNumberThreshold"); + int t = 1; + if (scm_is_number (thres)) + t = scm_to_int (thres); + + if (num <= t) + last->suicide (); + else + { + SCM text + = scm_number_to_string (scm_from_int (num), scm_from_int (10)); + last->set_property ("text", text); + } + } } last_main_moment_ = now.main_part_; @@ -259,23 +259,23 @@ Multi_measure_rest_engraver::finalize () } ADD_TRANSLATOR (Multi_measure_rest_engraver, - /* doc */ - "Engrave multi-measure rests that are produced with" - " @samp{R}. It reads @code{measurePosition} and" - " @code{internalBarNumber} to determine what number to print" - " over the @ref{MultiMeasureRest}.", - - /* create */ - "MultiMeasureRest " - "MultiMeasureRestNumber " - "MultiMeasureRestText ", - - /* read */ - "internalBarNumber " - "restNumberThreshold " - "currentCommandColumn " - "measurePosition ", - - /* write */ - "" - ); + /* doc */ + "Engrave multi-measure rests that are produced with" + " @samp{R}. It reads @code{measurePosition} and" + " @code{internalBarNumber} to determine what number to print" + " over the @ref{MultiMeasureRest}.", + + /* create */ + "MultiMeasureRest " + "MultiMeasureRestNumber " + "MultiMeasureRestText ", + + /* read */ + "internalBarNumber " + "restNumberThreshold " + "currentCommandColumn " + "measurePosition ", + + /* write */ + "" + ); diff --git a/lily/multi-measure-rest.cc b/lily/multi-measure-rest.cc index 1a9f5e11a7..09f92b58a3 100644 --- a/lily/multi-measure-rest.cc +++ b/lily/multi-measure-rest.cc @@ -44,9 +44,9 @@ Multi_measure_rest::bar_width (Spanner *me) { Item *col = me->get_bound (d)->get_column (); SCM align_sym - = (scm_is_pair (spacing_pair) - ? index_get_cell (spacing_pair, d) - : ly_symbol2scm ("staff-bar")); + = (scm_is_pair (spacing_pair) + ? index_get_cell (spacing_pair, d) + : ly_symbol2scm ("staff-bar")); Interval coldim = Paper_column::break_align_width (col, align_sym); iv[d] = coldim[-d]; @@ -69,7 +69,7 @@ Multi_measure_rest::percent (SCM smob) // ugh copy & paste. Grob *common_x = sp->get_bound (LEFT)->common_refpoint (sp->get_bound (RIGHT), - X_AXIS); + X_AXIS); Interval sp_iv = bar_width (sp); Real x_off = 0.0; @@ -123,7 +123,7 @@ int measure_duration_log (Grob *me) { SCM sml = dynamic_cast<Spanner *> (me)->get_bound (LEFT) - ->get_property ("measure-length"); + ->get_property ("measure-length"); bool round = to_boolean (me->get_property ("round-to-longer-rest")); Rational ml = (unsmob_moment (sml)) ? unsmob_moment (sml)->main_part_ : Rational (1); @@ -136,13 +136,13 @@ measure_duration_log (Grob *me) int closest_list_elt = -15; // -15 is out of range. for (int i = 0; i < scm_to_int (scm_length (duration_logs_list)); i++) - { - int list_elt = scm_to_int (scm_list_ref (duration_logs_list, scm_from_int (i))); - int shortest_distance = abs (measure_duration_log - closest_list_elt); - int distance = abs (measure_duration_log - list_elt); - if (distance < shortest_distance) - closest_list_elt = list_elt; - } + { + int list_elt = scm_to_int (scm_list_ref (duration_logs_list, scm_from_int (i))); + int shortest_distance = abs (measure_duration_log - closest_list_elt); + int distance = abs (measure_duration_log - list_elt); + if (distance < shortest_distance) + closest_list_elt = list_elt; + } return closest_list_elt; } @@ -217,7 +217,7 @@ Multi_measure_rest::big_rest (Grob *me, Real width) */ Stencil Multi_measure_rest::church_rest (Grob *me, Font_metric *musfont, int measures, - Real space) + Real space) { SCM mols = SCM_EOL; @@ -227,52 +227,52 @@ Multi_measure_rest::church_rest (Grob *me, Font_metric *musfont, int measures, SCM duration_logs_list = me->get_property ("usable-duration-logs"); int longest_church_rest = 10; // 10 is out of range. for (int i = 0; i < scm_to_int (scm_length (duration_logs_list)); i++) - { - longest_church_rest = min (longest_church_rest, - scm_to_int (scm_list_ref (duration_logs_list, - scm_from_int (i)))); - } - - while (l) - { - int k; - int i = longest_church_rest - 1; - int length; - int mdl = measure_duration_log (me); - - do { - i++; - length = int (pow (2.0, -i)); + longest_church_rest = min (longest_church_rest, + scm_to_int (scm_list_ref (duration_logs_list, + scm_from_int (i)))); } - while (i <= 0 && - !(l >= length && mdl >= longest_church_rest - i)); - - l -= length; - k = mdl + i; - Stencil r (musfont->find_by_name ("rests." + to_string (k))); - if (k == 0) + while (l) { - Real staff_space = Staff_symbol_referencer::staff_space (me); - r.translate_axis (staff_space, Y_AXIS); + int k; + int i = longest_church_rest - 1; + int length; + int mdl = measure_duration_log (me); + + do + { + i++; + length = int (pow (2.0, -i)); + } + while (i <= 0 + && !(l >= length && mdl >= longest_church_rest - i)); + + l -= length; + k = mdl + i; + + Stencil r (musfont->find_by_name ("rests." + to_string (k))); + if (k == 0) + { + Real staff_space = Staff_symbol_referencer::staff_space (me); + r.translate_axis (staff_space, Y_AXIS); + } + symbols_width += r.extent (X_AXIS).length (); + mols = scm_cons (r.smobbed_copy (), mols); + count++; } - symbols_width += r.extent (X_AXIS).length (); - mols = scm_cons (r.smobbed_copy (), mols); - count++; - } /* Make outer padding this much bigger. */ Real outer_padding_factor = 1.5; Real inner_padding = (space - symbols_width) - / (2 * outer_padding_factor + (count - 1)); + / (2 * outer_padding_factor + (count - 1)); if (inner_padding < 0) inner_padding = 1.0; Stencil mol; for (SCM s = mols; scm_is_pair (s); s = scm_cdr (s)) mol.add_at_edge (X_AXIS, LEFT, *unsmob_stencil (scm_car (s)), - inner_padding); + inner_padding); mol.align_to (X_AXIS, LEFT); mol.translate_axis (outer_padding_factor * inner_padding, X_AXIS); @@ -301,9 +301,10 @@ Multi_measure_rest::calculate_spacing_rods (Grob *me, Real length) Item *rb = ri->find_prebroken_piece (LEFT); Item *combinations[4][2] = {{li, ri}, - {lb, ri}, - {li, rb}, - {lb, rb}}; + {lb, ri}, + {li, rb}, + {lb, rb} + }; for (int i = 0; i < 4; i++) { @@ -311,15 +312,15 @@ Multi_measure_rest::calculate_spacing_rods (Grob *me, Real length) Item *ri = combinations[i][1]; if (!li || !ri) - continue; + continue; Rod rod; rod.item_drul_[LEFT] = li; rod.item_drul_[RIGHT] = ri; rod.distance_ = Paper_column::minimum_distance (li, ri) - + length - + 2 * robust_scm2double (me->get_property ("bound-padding"), 1.0); + + length + + 2 * robust_scm2double (me->get_property ("bound-padding"), 1.0); Real minlen = robust_scm2double (me->get_property ("minimum-length"), 0); rod.distance_ = max (rod.distance_, minlen); @@ -347,24 +348,24 @@ Multi_measure_rest::set_text_rods (SCM smob) /* FIXME uncached */ Real len = (stil && !stil->extent (X_AXIS).is_empty ()) - ? stil->extent (X_AXIS).length () - : 0.0; + ? stil->extent (X_AXIS).length () + : 0.0; calculate_spacing_rods (me, len); return SCM_UNSPECIFIED; } ADD_INTERFACE (Multi_measure_rest, - "A rest that spans a whole number of measures.", - - /* properties */ - "bound-padding " - "expand-limit " - "hair-thickness " - "measure-count " - "minimum-length " - "round-to-longer-rest " - "spacing-pair " - "thick-thickness " + "A rest that spans a whole number of measures.", + + /* properties */ + "bound-padding " + "expand-limit " + "hair-thickness " + "measure-count " + "minimum-length " + "round-to-longer-rest " + "spacing-pair " + "thick-thickness " "usable-duration-logs " - ); + ); diff --git a/lily/music-function-scheme.cc b/lily/music-function-scheme.cc index b6473b19d1..f78a387336 100644 --- a/lily/music-function-scheme.cc +++ b/lily/music-function-scheme.cc @@ -1,30 +1,30 @@ #include "music-function.hh" LY_DEFINE (ly_music_function_p, "ly:music-function?", 1, 0, 0, - (SCM x), - "Is @var{x} a @code{music-function}?") + (SCM x), + "Is @var{x} a @code{music-function}?") { return is_music_function (x) ? SCM_BOOL_T : SCM_BOOL_F; } - + LY_DEFINE (ly_music_function_extract, "ly:music-function-extract", 1, 0, 0, - (SCM x), - "Return the Scheme function inside@tie{}@var{x}.") + (SCM x), + "Return the Scheme function inside@tie{}@var{x}.") { LY_ASSERT_TYPE (is_music_function, x, 1); - - return SCM_CELL_OBJECT_1(x); + + return SCM_CELL_OBJECT_1 (x); } LY_DEFINE (ly_make_music_function, "ly:make-music-function", 2, 0, 0, - (SCM signature, SCM func), - "Make a function to process music, to be used for the" - " parser. @var{func} is the function, and @var{signature}" - " describes its arguments. @var{signature} is a list" - " containing either @code{ly:music?} predicates or other type" - " predicates.") + (SCM signature, SCM func), + "Make a function to process music, to be used for the" + " parser. @var{func} is the function, and @var{signature}" + " describes its arguments. @var{signature} is a list" + " containing either @code{ly:music?} predicates or other type" + " predicates.") { LY_ASSERT_TYPE (ly_is_procedure, func, 1); - return make_music_function (signature, func); + return make_music_function (signature, func); } diff --git a/lily/music-function.cc b/lily/music-function.cc index 85eecb7c33..5d8964e7d5 100644 --- a/lily/music-function.cc +++ b/lily/music-function.cc @@ -64,7 +64,7 @@ SCM make_music_function (SCM signature, SCM func) { scm_set_object_property_x (func, ly_symbol2scm ("music-function-signature"), - signature); + signature); SCM_RETURN_NEWSMOB (music_function_tag, func); } diff --git a/lily/music-iterator.cc b/lily/music-iterator.cc index 46d9fb035d..c1603c8709 100644 --- a/lily/music-iterator.cc +++ b/lily/music-iterator.cc @@ -17,7 +17,6 @@ along with LilyPond. If not, see <http://www.gnu.org/licenses/>. */ - #include <cstdio> using namespace std; @@ -97,11 +96,11 @@ Music_iterator::get_static_get_iterator (Music *m) else { if (dynamic_cast<Music_wrapper *> (m)) - p = new Music_wrapper_iterator; + p = new Music_wrapper_iterator; else if (m->is_mus_type ("event")) p = new Event_iterator; else - p = new Simple_music_iterator; + p = new Simple_music_iterator; iter = p->self_scm (); p->unprotect (); @@ -170,13 +169,13 @@ Music_iterator::descend_to_bottom_context () set_context (get_outlet ()->get_default_interpreter ()); } -void +void Music_iterator::report_event (Music *m) { descend_to_bottom_context (); /* - FIXME: then don't do it. + FIXME: then don't do it. */ if (!m->is_mus_type ("event")) m->origin ()->programming_error (_ ("Sending non-event to context")); @@ -217,7 +216,7 @@ Music_iterator::mark_smob (SCM smob) } int -Music_iterator::print_smob (SCM sm, SCM port, scm_print_state*) +Music_iterator::print_smob (SCM sm, SCM port, scm_print_state *) { char s[1000]; diff --git a/lily/music-output.cc b/lily/music-output.cc index 9b8a99c724..400e53eb3f 100644 --- a/lily/music-output.cc +++ b/lily/music-output.cc @@ -54,7 +54,7 @@ Music_output::mark_smob (SCM s) } int -Music_output::print_smob (SCM s, SCM p, scm_print_state*) +Music_output::print_smob (SCM s, SCM p, scm_print_state *) { Music_output *sc = (Music_output *) SCM_CELL_WORD_1 (s); scm_puts ("#<", p); diff --git a/lily/music-scheme.cc b/lily/music-scheme.cc index c0e4eb3167..f8eca4a6fe 100644 --- a/lily/music-scheme.cc +++ b/lily/music-scheme.cc @@ -23,9 +23,9 @@ #include "warn.hh" LY_DEFINE (ly_music_length, "ly:music-length", - 1, 0, 0, (SCM mus), - "Get the length of music expression @var{mus} and return" - " it as a @code{Moment} object.") + 1, 0, 0, (SCM mus), + "Get the length of music expression @var{mus} and return" + " it as a @code{Moment} object.") { LY_ASSERT_TYPE (unsmob_music, mus, 1); Music *sc = unsmob_music (mus); @@ -33,53 +33,52 @@ LY_DEFINE (ly_music_length, "ly:music-length", } LY_DEFINE (ly_music_property, "ly:music-property", - 2, 1, 0, (SCM mus, SCM sym, SCM val), - "Return the value for property @var{sym} of music expression" - " @var{mus}. If no value is found, return @var{val} or" - " @code{'()} if @var{val} is not specified.") + 2, 1, 0, (SCM mus, SCM sym, SCM val), + "Return the value for property @var{sym} of music expression" + " @var{mus}. If no value is found, return @var{val} or" + " @code{'()} if @var{val} is not specified.") { LY_ASSERT_TYPE (unsmob_music, mus, 1); return ly_prob_property (mus, sym, val); } LY_DEFINE (ly_music_set_property_x, "ly:music-set-property!", - 3, 0, 0, (SCM mus, SCM sym, SCM val), - "Set property @var{sym} in music expression @var{mus} to" - " @var{val}.") + 3, 0, 0, (SCM mus, SCM sym, SCM val), + "Set property @var{sym} in music expression @var{mus} to" + " @var{val}.") { LY_ASSERT_TYPE (unsmob_music, mus, 1); return ly_prob_set_property_x (mus, sym, val); } - /* todo: property args */ LY_DEFINE (ly_make_music, "ly:make-music", - 1, 0, 0, (SCM props), - "Make a C++ @code{Music} object and initialize it with" - " @var{props}.\n" - "\n" - "This function is for internal use and is only called by" - " @code{make-music}, which is the preferred interface" - " for creating music objects.") + 1, 0, 0, (SCM props), + "Make a C++ @code{Music} object and initialize it with" + " @var{props}.\n" + "\n" + "This function is for internal use and is only called by" + " @code{make-music}, which is the preferred interface" + " for creating music objects.") { Music *ms = new Music (props); return ms->unprotect (); } LY_DEFINE (ly_music_p, "ly:music?", - 1, 0, 0, (SCM obj), - "Is @var{obj} a music object?") + 1, 0, 0, (SCM obj), + "Is @var{obj} a music object?") { return scm_from_bool (unsmob_music (obj)); } /* todo: property args */ LY_DEFINE (ly_music_mutable_properties, "ly:music-mutable-properties", - 1, 0, 0, (SCM mus), - "Return an alist containing the mutable properties of @var{mus}." - " The immutable properties are not available, since they are" - " constant and initialized by the @code{make-music} function.") + 1, 0, 0, (SCM mus), + "Return an alist containing the mutable properties of @var{mus}." + " The immutable properties are not available, since they are" + " constant and initialized by the @code{make-music} function.") { LY_ASSERT_TYPE (unsmob_music, mus, 1); Music *m = unsmob_music (mus); @@ -87,23 +86,23 @@ LY_DEFINE (ly_music_mutable_properties, "ly:music-mutable-properties", } LY_DEFINE (ly_music_list_p, "ly:music-list?", - 1, 0, 0, (SCM lst), - "Is @var{lst} a list of music objects?") + 1, 0, 0, (SCM lst), + "Is @var{lst} a list of music objects?") { if (scm_list_p (lst) == SCM_BOOL_T) while (scm_is_pair (lst)) { - if (!unsmob_music (scm_car (lst))) - return SCM_BOOL_F; - lst = scm_cdr (lst); + if (!unsmob_music (scm_car (lst))) + return SCM_BOOL_F; + lst = scm_cdr (lst); } return SCM_BOOL_T; } LY_DEFINE (ly_music_deep_copy, "ly:music-deep-copy", - 1, 0, 0, (SCM m), - "Copy @var{m} and all sub expressions of@tie{}@var{m}.") + 1, 0, 0, (SCM m), + "Copy @var{m} and all sub expressions of@tie{}@var{m}.") { SCM copy = m; if (unsmob_music (m)) @@ -113,14 +112,14 @@ LY_DEFINE (ly_music_deep_copy, "ly:music-deep-copy", } else if (scm_is_pair (m)) copy = scm_cons (ly_music_deep_copy (scm_car (m)), - ly_music_deep_copy (scm_cdr (m))); + ly_music_deep_copy (scm_cdr (m))); return copy; } LY_DEFINE (ly_music_transpose, "ly:music-transpose", - 2, 0, 0, (SCM m, SCM p), - "Transpose @var{m} such that central@tie{}C is mapped" - " to@tie{}@var{p}. Return@tie{}@var{m}.") + 2, 0, 0, (SCM m, SCM p), + "Transpose @var{m} such that central@tie{}C is mapped" + " to@tie{}@var{p}. Return@tie{}@var{m}.") { LY_ASSERT_TYPE (unsmob_music, m, 1); LY_ASSERT_SMOB (Pitch, p, 2); @@ -137,8 +136,8 @@ LY_DEFINE (ly_music_transpose, "ly:music-transpose", TODO: should take moment factor? */ LY_DEFINE (ly_music_compress, "ly:music-compress", - 2, 0, 0, (SCM m, SCM factor), - "Compress music object@tie{}@var{m} by moment @var{factor}.") + 2, 0, 0, (SCM m, SCM factor), + "Compress music object@tie{}@var{m} by moment @var{factor}.") { LY_ASSERT_TYPE (unsmob_music, m, 1); LY_ASSERT_TYPE (unsmob_moment, factor, 2); @@ -149,9 +148,9 @@ LY_DEFINE (ly_music_compress, "ly:music-compress", } LY_DEFINE (ly_music_duration_length, "ly:music-duration-length", 1, 0, 0, - (SCM mus), - "Extract the duration field from @var{mus} and return the" - " length.") + (SCM mus), + "Extract the duration field from @var{mus} and return the" + " length.") { LY_ASSERT_TYPE (unsmob_music, mus, 1); Music *m = unsmob_music (mus); @@ -167,13 +166,13 @@ LY_DEFINE (ly_music_duration_length, "ly:music-duration-length", 1, 0, 0, } LY_DEFINE (ly_music_duration_compress, "ly:music-duration-compress", 2, 0, 0, - (SCM mus, SCM fact), - "Compress @var{mus} by factor @var{fact}, which is a" - " @code{Moment}.") + (SCM mus, SCM fact), + "Compress @var{mus} by factor @var{fact}, which is a" + " @code{Moment}.") { LY_ASSERT_TYPE (unsmob_music, mus, 1); LY_ASSERT_SMOB (Moment, fact, 2); - + Music *m = unsmob_music (mus); Moment *f = unsmob_moment (fact); @@ -191,9 +190,9 @@ LY_DEFINE (ly_music_duration_compress, "ly:music-duration-compress", 2, 0, 0, TODO: this should use ly:pitch. */ LY_DEFINE (ly_transpose_key_alist, "ly:transpose-key-alist", - 2, 0, 0, (SCM l, SCM pit), - "Make a new key alist of@tie{}@var{l} transposed by" - " pitch @var{pit}.") + 2, 0, 0, (SCM l, SCM pit), + "Make a new key alist of@tie{}@var{l} transposed by" + " pitch @var{pit}.") { SCM newlist = SCM_EOL; Pitch *p = unsmob_pitch (pit); @@ -203,28 +202,28 @@ LY_DEFINE (ly_transpose_key_alist, "ly:transpose-key-alist", SCM key = scm_caar (s); SCM alter = scm_cdar (s); if (scm_is_pair (key)) - { - Pitch orig (scm_to_int (scm_car (key)), - scm_to_int (scm_cdr (key)), - ly_scm2rational (alter)); + { + Pitch orig (scm_to_int (scm_car (key)), + scm_to_int (scm_cdr (key)), + ly_scm2rational (alter)); - orig = orig.transposed (*p); + orig = orig.transposed (*p); - SCM key = scm_cons (scm_from_int (orig.get_octave ()), - scm_from_int (orig.get_notename ())); + SCM key = scm_cons (scm_from_int (orig.get_octave ()), + scm_from_int (orig.get_notename ())); - newlist = scm_cons (scm_cons (key, ly_rational2scm (orig.get_alteration ())), - newlist); - } + newlist = scm_cons (scm_cons (key, ly_rational2scm (orig.get_alteration ())), + newlist); + } else if (scm_is_number (key)) - { - Pitch orig (0, scm_to_int (key), ly_scm2rational (alter)); - orig = orig.transposed (*p); - - key = scm_from_int (orig.get_notename ()); - alter = ly_rational2scm (orig.get_alteration ()); - newlist = scm_cons (scm_cons (key, alter), newlist); - } + { + Pitch orig (0, scm_to_int (key), ly_scm2rational (alter)); + orig = orig.transposed (*p); + + key = scm_from_int (orig.get_notename ()); + alter = ly_rational2scm (orig.get_alteration ()); + newlist = scm_cons (scm_cons (key, alter), newlist); + } } return scm_reverse_x (newlist, SCM_EOL); } diff --git a/lily/music-sequence.cc b/lily/music-sequence.cc index 8c9642c860..e8493b8ada 100644 --- a/lily/music-sequence.cc +++ b/lily/music-sequence.cc @@ -41,7 +41,7 @@ Music_sequence::cumulative_length (SCM l) { Moment l = unsmob_music (scm_car (s))->get_length (); if (last_len.grace_part_ && l.main_part_) - last_len.grace_part_ = Rational (0); + last_len.grace_part_ = Rational (0); cumulative += last_len; last_len = l; } @@ -60,12 +60,12 @@ Music_sequence::maximum_length (SCM l) { Music *m = unsmob_music (scm_car (s)); if (!m) - programming_error ("Music sequence should have music elements"); + programming_error ("Music sequence should have music elements"); else - { - Moment l = m->get_length (); - dur = max (dur, l); - } + { + Moment l = m->get_length (); + dur = max (dur, l); + } } return dur; @@ -113,11 +113,11 @@ music_list_to_relative (SCM l, Pitch p, bool ret_first) for (SCM s = l; scm_is_pair (s); s = scm_cdr (s)) { if (Music *m = unsmob_music (scm_car (s))) - { - last = m->to_relative_octave (last); - if (!count++) - first = last; - } + { + last = m->to_relative_octave (last); + if (!count++) + first = last; + } } return (ret_first) ? first : last; @@ -151,7 +151,7 @@ Music_sequence::first_start (SCM l) Moment l = mus->get_length (); Moment s = mus->start_mom (); if (l.to_bool () || s.to_bool ()) - return s; + return s; } return m; } @@ -175,7 +175,7 @@ Music_sequence::simultaneous_relative_callback (SCM music, SCM pitch) Pitch retval_1_8 = music_list_to_relative (copied, p, true); if (retval_1_8 != retval) - lily_1_8_compatibility_used = true; + lily_1_8_compatibility_used = true; retval = retval_1_8; } @@ -190,7 +190,7 @@ Music_sequence::event_chord_relative_callback (SCM music, SCM pitch) Music *me = unsmob_music (music); Pitch p = *unsmob_pitch (pitch); return music_list_to_relative (me->get_property ("elements"), - p, true).smobbed_copy (); + p, true).smobbed_copy (); } MAKE_SCHEME_CALLBACK (Music_sequence, repeated_chord_relative_callback, 2); @@ -212,14 +212,14 @@ Music_sequence::repeated_chord_relative_callback (SCM music, SCM pitch) if (original_chord) { for (SCM s = original_chord->get_property ("elements"); scm_is_pair (s); s = scm_cdr (s)) - { - if (Music *m = unsmob_music (scm_car (s))) - { - p = unsmob_pitch (m->get_property ("pitch")); - if (p) - break; - } - } + { + if (Music *m = unsmob_music (scm_car (s))) + { + p = unsmob_pitch (m->get_property ("pitch")); + if (p) + break; + } + } } /* Use the `pitch' argument if no pitch found in original chord. */ if (! p) @@ -231,17 +231,17 @@ Music_sequence::repeated_chord_relative_callback (SCM music, SCM pitch) for (SCM s = repeated_chord->get_property ("elements"); scm_is_pair (s); s = scm_cdr (s)) { if (Music *m = unsmob_music (scm_car (s))) - { - Pitch *first_pitch = unsmob_pitch (m->get_property ("pitch")); - if (first_pitch) - { - Pitch new_pitch = Pitch (-1, - first_pitch->get_notename (), - first_pitch->get_alteration ()); - m->set_property ("pitch", new_pitch.smobbed_copy ()); - break; - } - } + { + Pitch *first_pitch = unsmob_pitch (m->get_property ("pitch")); + if (first_pitch) + { + Pitch new_pitch = Pitch (-1, + first_pitch->get_notename (), + first_pitch->get_alteration ()); + m->set_property ("pitch", new_pitch.smobbed_copy ()); + break; + } + } } music_list_to_relative (repeated_chord->get_property ("elements"), *p, true).smobbed_copy (); /* Return `pitch' instead of the repeated chord first pitch, diff --git a/lily/music-wrapper-iterator.cc b/lily/music-wrapper-iterator.cc index 4a47357355..ada08b14aa 100644 --- a/lily/music-wrapper-iterator.cc +++ b/lily/music-wrapper-iterator.cc @@ -53,8 +53,8 @@ Music_wrapper_iterator::construct_children () Music *my_music = get_music (); Music *child = unsmob_music (my_music->get_property ("element")); child_iter_ = (child) - ? unsmob_iterator (get_iterator (child)) - : 0; + ? unsmob_iterator (get_iterator (child)) + : 0; } bool @@ -84,5 +84,5 @@ IMPLEMENT_CTOR_CALLBACK (Music_wrapper_iterator); bool Music_wrapper_iterator::run_always () const { - return (child_iter_ && child_iter_->run_always ()); + return (child_iter_ && child_iter_->run_always ()); } diff --git a/lily/music.cc b/lily/music.cc index 401e9efafb..cc6281addc 100644 --- a/lily/music.cc +++ b/lily/music.cc @@ -83,7 +83,7 @@ Music::Music (Music const &m) length_callback_ = m.length_callback_; start_callback_ = m.start_callback_; - /// why? + /// why? set_spot (*m.origin ()); } @@ -130,7 +130,6 @@ print_alist (SCM a, SCM port) } } - Pitch Music::generic_to_relative_octave (Pitch last) { @@ -143,16 +142,16 @@ Music::generic_to_relative_octave (Pitch last) SCM check = get_property ("absolute-octave"); if (scm_is_number (check) - && new_pit.get_octave () != scm_to_int (check)) - { - Pitch expected_pit (scm_to_int (check), - new_pit.get_notename (), - new_pit.get_alteration ()); - origin ()->warning (_f ("octave check failed; expected \"%s\", found: \"%s\"", - expected_pit.to_string (), - new_pit.to_string ())); - new_pit = expected_pit; - } + && new_pit.get_octave () != scm_to_int (check)) + { + Pitch expected_pit (scm_to_int (check), + new_pit.get_notename (), + new_pit.get_alteration ()); + origin ()->warning (_f ("octave check failed; expected \"%s\", found: \"%s\"", + expected_pit.to_string (), + new_pit.to_string ())); + new_pit = expected_pit; + } set_property ("pitch", new_pit.smobbed_copy ()); @@ -173,7 +172,7 @@ Music::to_relative_octave (Pitch last) if (ly_is_procedure (callback)) { Pitch *p = unsmob_pitch (scm_call_2 (callback, self_scm (), - last.smobbed_copy ())); + last.smobbed_copy ())); return *p; } @@ -192,11 +191,11 @@ Music::compress (Moment factor) Duration *d = unsmob_duration (get_property ("duration")); if (d) set_property ("duration", - d->compressed (factor.main_part_).smobbed_copy ()); + d->compressed (factor.main_part_).smobbed_copy ()); } /* - This mutates alist. Hence, make sure that it is not shared + This mutates alist. Hence, make sure that it is not shared */ void transpose_mutable (SCM alist, Pitch delta) @@ -209,38 +208,38 @@ transpose_mutable (SCM alist, Pitch delta) SCM new_val = val; if (Pitch *p = unsmob_pitch (val)) - { - Pitch transposed = p->transposed (delta); - if (transposed.get_alteration ().abs () > Rational (1,1)) - { - string delta_str; - if (delta.get_alteration ().abs () > Rational (1, 1)) - delta_str = (delta.normalized ().to_string () - + " " + _ ("(normalized pitch)")); - else - delta_str = delta.to_string (); - - warning (_f ("Transposing %s by %s makes alteration larger than double", - p->to_string (), - delta_str)); - transposed = transposed.normalized (); - } - - new_val = transposed.smobbed_copy (); - } + { + Pitch transposed = p->transposed (delta); + if (transposed.get_alteration ().abs () > Rational (1, 1)) + { + string delta_str; + if (delta.get_alteration ().abs () > Rational (1, 1)) + delta_str = (delta.normalized ().to_string () + + " " + _ ("(normalized pitch)")); + else + delta_str = delta.to_string (); + + warning (_f ("Transposing %s by %s makes alteration larger than double", + p->to_string (), + delta_str)); + transposed = transposed.normalized (); + } + + new_val = transposed.smobbed_copy (); + } else if (prop == ly_symbol2scm ("element")) - { - if (Music *m = unsmob_music (val)) - m->transpose (delta); - } + { + if (Music *m = unsmob_music (val)) + m->transpose (delta); + } else if (prop == ly_symbol2scm ("elements")) - transpose_music_list (val, delta); - else if (prop == ly_symbol2scm ("pitch-alist") && - scm_is_pair (val)) - new_val = ly_transpose_key_alist (val, delta.smobbed_copy ()); + transpose_music_list (val, delta); + else if (prop == ly_symbol2scm ("pitch-alist") + && scm_is_pair (val)) + new_val = ly_transpose_key_alist (val, delta.smobbed_copy ()); if (val != new_val) - scm_set_cdr_x (entry , new_val); + scm_set_cdr_x (entry, new_val); } } @@ -289,11 +288,11 @@ Music::to_event () const { SCM art_ev = SCM_EOL; for (; scm_is_pair (art_mus); art_mus = scm_cdr (art_mus)) - { - Music *m = unsmob_music (scm_car (art_mus)); - SCM ev = m ? m->to_event ()->unprotect () : scm_car (art_mus); - art_ev = scm_cons (ev, art_ev); - } + { + Music *m = unsmob_music (scm_car (art_mus)); + SCM ev = m ? m->to_event ()->unprotect () : scm_car (art_mus); + art_ev = scm_cons (ev, art_ev); + } e->set_property ("articulations", scm_reverse_x (art_ev, SCM_EOL)); } diff --git a/lily/nested-property.cc b/lily/nested-property.cc index 622a6cc5a5..9c3cc73387 100644 --- a/lily/nested-property.cc +++ b/lily/nested-property.cc @@ -1,7 +1,6 @@ #include "context.hh" #include "grob.hh" - /* Drop symbol from the list alist..alist_end. */ @@ -14,10 +13,10 @@ evict_from_alist (SCM symbol, SCM alist, SCM alist_end) while (alist != alist_end) { if (ly_is_equal (scm_caar (alist), symbol)) - { - alist = scm_cdr (alist); - break; - } + { + alist = scm_cdr (alist); + break; + } *tail = scm_cons (scm_car (alist), SCM_EOL); tail = SCM_CDRLOC (*tail); @@ -61,7 +60,7 @@ nested_property_alist (SCM alist, SCM prop_path, SCM value) SCM nested_property_revert_alist (SCM alist, SCM prop_path) { - assert(scm_is_pair (prop_path)); + assert (scm_is_pair (prop_path)); SCM wanted_sym = scm_car (prop_path); @@ -73,26 +72,26 @@ nested_property_revert_alist (SCM alist, SCM prop_path) SCM old_val = scm_cdar (s); if (sub_sym == wanted_sym) - { - if (scm_is_pair (scm_cdr (prop_path))) - { - SCM new_val = nested_property_revert_alist (old_val, scm_cdr (prop_path)); - - /* nothing changed: drop newly constructed list. */ - if (old_val == new_val) - return alist; - - *tail = scm_acons (sub_sym, new_val, SCM_EOL); - tail = SCM_CDRLOC(*tail); - } - else - { - /* old value is dropped. */ - } - - *tail = scm_cdr (s); - return new_list; - } + { + if (scm_is_pair (scm_cdr (prop_path))) + { + SCM new_val = nested_property_revert_alist (old_val, scm_cdr (prop_path)); + + /* nothing changed: drop newly constructed list. */ + if (old_val == new_val) + return alist; + + *tail = scm_acons (sub_sym, new_val, SCM_EOL); + tail = SCM_CDRLOC (*tail); + } + else + { + /* old value is dropped. */ + } + + *tail = scm_cdr (s); + return new_list; + } *tail = scm_acons (sub_sym, old_val, SCM_EOL); tail = SCM_CDRLOC (*tail); @@ -102,7 +101,6 @@ nested_property_revert_alist (SCM alist, SCM prop_path) return alist; } - void set_nested_property (Grob *me, SCM big_to_small, SCM value) { diff --git a/lily/new-dynamic-engraver.cc b/lily/new-dynamic-engraver.cc index 331d605616..3554b22e9e 100644 --- a/lily/new-dynamic-engraver.cc +++ b/lily/new-dynamic-engraver.cc @@ -45,7 +45,7 @@ protected: private: SCM get_property_setting (Stream_event *evt, char const *evprop, - char const *ctxprop); + char const *ctxprop); string get_spanner_type (Stream_event *ev); Drul_array<Stream_event *> accepted_spanevents_drul_; @@ -103,8 +103,8 @@ New_dynamic_engraver::listen_break_span (Stream_event *event) SCM New_dynamic_engraver::get_property_setting (Stream_event *evt, - char const *evprop, - char const *ctxprop) + char const *evprop, + char const *ctxprop) { SCM spanner_type = evt->get_property (evprop); if (spanner_type == SCM_EOL) @@ -117,15 +117,15 @@ New_dynamic_engraver::process_music () { if (current_spanner_ && (accepted_spanevents_drul_[STOP] - || script_event_ - || accepted_spanevents_drul_[START])) + || script_event_ + || accepted_spanevents_drul_[START])) { Stream_event *ender = accepted_spanevents_drul_[STOP]; if (!ender) - ender = script_event_; + ender = script_event_; if (!ender) - ender = accepted_spanevents_drul_[START]; + ender = accepted_spanevents_drul_[START]; finished_spanner_ = current_spanner_; announce_end_grob (finished_spanner_, ender->self_scm ()); @@ -139,37 +139,37 @@ New_dynamic_engraver::process_music () string start_type = get_spanner_type (current_span_event_); SCM cresc_type = get_property_setting (current_span_event_, "span-type", - (start_type + "Spanner").c_str ()); + (start_type + "Spanner").c_str ()); if (cresc_type == ly_symbol2scm ("text")) - { - current_spanner_ - = make_spanner ("DynamicTextSpanner", - accepted_spanevents_drul_[START]->self_scm ()); - - SCM text = get_property_setting (current_span_event_, "span-text", - (start_type + "Text").c_str ()); - if (Text_interface::is_markup (text)) - current_spanner_->set_property ("text", text); - /* - If the line of a text spanner is hidden, end the alignment spanner - early: this allows dynamics to be spaced individually instead of - being linked together. - */ - if (current_spanner_->get_property ("style") == ly_symbol2scm ("none")) - current_spanner_->set_property ("spanner-broken", SCM_BOOL_T); - } + { + current_spanner_ + = make_spanner ("DynamicTextSpanner", + accepted_spanevents_drul_[START]->self_scm ()); + + SCM text = get_property_setting (current_span_event_, "span-text", + (start_type + "Text").c_str ()); + if (Text_interface::is_markup (text)) + current_spanner_->set_property ("text", text); + /* + If the line of a text spanner is hidden, end the alignment spanner + early: this allows dynamics to be spaced individually instead of + being linked together. + */ + if (current_spanner_->get_property ("style") == ly_symbol2scm ("none")) + current_spanner_->set_property ("spanner-broken", SCM_BOOL_T); + } else - { - if (cresc_type != ly_symbol2scm ("hairpin")) - { - string as_string = ly_scm_write_string (cresc_type); - current_span_event_ - ->origin()->warning (_f ("unknown crescendo style: %s\ndefaulting to hairpin.", as_string.c_str())); - } - current_spanner_ = make_spanner ("Hairpin", - current_span_event_->self_scm ()); - } + { + if (cresc_type != ly_symbol2scm ("hairpin")) + { + string as_string = ly_scm_write_string (cresc_type); + current_span_event_ + ->origin ()->warning (_f ("unknown crescendo style: %s\ndefaulting to hairpin.", as_string.c_str ())); + } + current_spanner_ = make_spanner ("Hairpin", + current_span_event_->self_scm ()); + } // if we have a break-dynamic-span event right after the start dynamic, break the new spanner immediately if (end_new_spanner_) { @@ -177,28 +177,28 @@ New_dynamic_engraver::process_music () end_new_spanner_ = false; } if (finished_spanner_) - { - if (Hairpin::has_interface (finished_spanner_)) - Pointer_group_interface::add_grob (finished_spanner_, - ly_symbol2scm ("adjacent-spanners"), - current_spanner_); - if (Hairpin::has_interface (current_spanner_)) - Pointer_group_interface::add_grob (current_spanner_, - ly_symbol2scm ("adjacent-spanners"), - finished_spanner_); - } + { + if (Hairpin::has_interface (finished_spanner_)) + Pointer_group_interface::add_grob (finished_spanner_, + ly_symbol2scm ("adjacent-spanners"), + current_spanner_); + if (Hairpin::has_interface (current_spanner_)) + Pointer_group_interface::add_grob (current_spanner_, + ly_symbol2scm ("adjacent-spanners"), + finished_spanner_); + } } if (script_event_) { script_ = make_item ("DynamicText", script_event_->self_scm ()); script_->set_property ("text", - script_event_->get_property ("text")); + script_event_->get_property ("text")); if (finished_spanner_) - finished_spanner_->set_bound (RIGHT, script_); + finished_spanner_->set_bound (RIGHT, script_); if (current_spanner_) - current_spanner_->set_bound (LEFT, script_); + current_spanner_->set_bound (LEFT, script_); } } @@ -207,13 +207,13 @@ New_dynamic_engraver::stop_translation_timestep () { if (finished_spanner_ && !finished_spanner_->get_bound (RIGHT)) finished_spanner_ - ->set_bound (RIGHT, - unsmob_grob (get_property ("currentMusicalColumn"))); + ->set_bound (RIGHT, + unsmob_grob (get_property ("currentMusicalColumn"))); if (current_spanner_ && !current_spanner_->get_bound (LEFT)) current_spanner_ - ->set_bound (LEFT, - unsmob_grob (get_property ("currentMusicalColumn"))); + ->set_bound (LEFT, + unsmob_grob (get_property ("currentMusicalColumn"))); script_ = 0; script_event_ = 0; accepted_spanevents_drul_.set (0, 0); @@ -230,9 +230,9 @@ New_dynamic_engraver::finalize () if (current_spanner_) { current_span_event_ - ->origin ()->warning (_f ("unterminated %s", - get_spanner_type (current_span_event_) - .c_str ())); + ->origin ()->warning (_f ("unterminated %s", + get_spanner_type (current_span_event_) + .c_str ())); current_spanner_->suicide (); current_spanner_ = 0; } @@ -261,17 +261,17 @@ New_dynamic_engraver::acknowledge_note_column (Grob_info info) { extract_grob_set (info.grob (), "note-heads", heads); /* - Spacing constraints may require dynamics to be aligned on rests, - so check for a rest if this note column has no note heads. + Spacing constraints may require dynamics to be aligned on rests, + so check for a rest if this note column has no note heads. */ Grob *x_parent = (heads.size () - ? heads[0] - : unsmob_grob (info.grob ()->get_object ("rest"))); + ? heads[0] + : unsmob_grob (info.grob ()->get_object ("rest"))); if (x_parent) - { - script_->set_parent (x_parent, X_AXIS); - Self_alignment_interface::set_center_parent (script_, X_AXIS); - } + { + script_->set_parent (x_parent, X_AXIS); + Self_alignment_interface::set_center_parent (script_, X_AXIS); + } } if (current_spanner_ && !current_spanner_->get_bound (LEFT)) @@ -282,21 +282,21 @@ New_dynamic_engraver::acknowledge_note_column (Grob_info info) ADD_ACKNOWLEDGER (New_dynamic_engraver, note_column); ADD_TRANSLATOR (New_dynamic_engraver, - /* doc */ - "Create hairpins, dynamic texts and dynamic text spanners.", - - /* create */ - "DynamicTextSpanner " - "DynamicText " - "Hairpin ", - - /* read */ - "crescendoSpanner " - "crescendoText " - "currentMusicalColumn " - "decrescendoSpanner " - "decrescendoText ", - - /* write */ - "" - ); + /* doc */ + "Create hairpins, dynamic texts and dynamic text spanners.", + + /* create */ + "DynamicTextSpanner " + "DynamicText " + "Hairpin ", + + /* read */ + "crescendoSpanner " + "crescendoText " + "currentMusicalColumn " + "decrescendoSpanner " + "decrescendoText ", + + /* write */ + "" + ); diff --git a/lily/new-fingering-engraver.cc b/lily/new-fingering-engraver.cc index db99dede95..6444a06bff 100644 --- a/lily/new-fingering-engraver.cc +++ b/lily/new-fingering-engraver.cc @@ -31,7 +31,6 @@ #include "translator.icc" - struct Finger_tuple { Grob *head_; @@ -51,7 +50,7 @@ struct Finger_tuple }; bool -operator< (Finger_tuple const &a, Finger_tuple const &b) +operator < (Finger_tuple const &a, Finger_tuple const &b) { return a.position_ < b.position_; } @@ -74,8 +73,8 @@ protected: DECLARE_ACKNOWLEDGER (rhythmic_head); DECLARE_ACKNOWLEDGER (stem); void add_fingering (Grob *, SCM, - vector<Finger_tuple> *, - Stream_event *, Stream_event *); + vector<Finger_tuple> *, + Stream_event *, Stream_event *); void add_script (Grob *, Stream_event *, Stream_event *); void add_string (Grob *, Stream_event *, Stream_event *); void position_scripts (SCM orientations, vector<Finger_tuple> *); @@ -95,32 +94,32 @@ New_fingering_engraver::acknowledge_rhythmic_head (Grob_info inf) Stream_event *ev = unsmob_stream_event (scm_car (s)); if (!ev) - continue; + continue; if (ev->in_event_class ("fingering-event")) - add_fingering (inf.grob (), - ly_symbol2scm ("Fingering"), - &fingerings_, - ev, note_ev); + add_fingering (inf.grob (), + ly_symbol2scm ("Fingering"), + &fingerings_, + ev, note_ev); else if (ev->in_event_class ("text-script-event")) - ev->origin ()->warning (_ ("cannot add text scripts to individual note heads")); + ev->origin ()->warning (_ ("cannot add text scripts to individual note heads")); else if (ev->in_event_class ("script-event")) - add_script (inf.grob (), ev, note_ev); + add_script (inf.grob (), ev, note_ev); else if (ev->in_event_class ("string-number-event")) - add_fingering (inf.grob (), - ly_symbol2scm ("StringNumber"), &string_numbers_, - ev, note_ev); + add_fingering (inf.grob (), + ly_symbol2scm ("StringNumber"), &string_numbers_, + ev, note_ev); else if (ev->in_event_class ("stroke-finger-event")) - add_fingering (inf.grob (), - ly_symbol2scm ("StrokeFinger"), &stroke_fingerings_, - ev, note_ev); + add_fingering (inf.grob (), + ly_symbol2scm ("StrokeFinger"), &stroke_fingerings_, + ev, note_ev); else if (ev->in_event_class ("harmonic-event")) - { - inf.grob ()->set_property ("style", ly_symbol2scm ("harmonic")); - Grob *d = unsmob_grob (inf.grob ()->get_object ("dot")); - if (d && !to_boolean (get_property ("harmonicDots"))) - d->suicide (); - } + { + inf.grob ()->set_property ("style", ly_symbol2scm ("harmonic")); + Grob *d = unsmob_grob (inf.grob ()->get_object ("dot")); + if (d && !to_boolean (get_property ("harmonicDots"))) + d->suicide (); + } } heads_.push_back (inf.grob ()); @@ -134,14 +133,14 @@ New_fingering_engraver::acknowledge_stem (Grob_info inf) void New_fingering_engraver::add_script (Grob *head, - Stream_event *event, - Stream_event * /* note */) + Stream_event *event, + Stream_event * /* note */) { Finger_tuple ft; Grob *g = make_item ("Script", event->self_scm ()); make_script_from_event (g, context (), - event->get_property ("articulation-type"), 0); + event->get_property ("articulation-type"), 0); ft.script_ = g; ft.script_->set_parent (head, X_AXIS); @@ -154,16 +153,16 @@ New_fingering_engraver::add_script (Grob *head, void New_fingering_engraver::add_fingering (Grob *head, - SCM grob_sym, - vector<Finger_tuple> *tuple_vector, - Stream_event *event, - Stream_event *hevent) + SCM grob_sym, + vector<Finger_tuple> *tuple_vector, + Stream_event *event, + Stream_event *hevent) { Finger_tuple ft; ft.script_ = internal_make_item (grob_sym, event->self_scm (), - ly_symbol2string (grob_sym).c_str (), - __FILE__, __LINE__, __FUNCTION__); + ly_symbol2string (grob_sym).c_str (), + __FILE__, __LINE__, __FUNCTION__); Side_position_interface::add_support (ft.script_, head); @@ -176,7 +175,7 @@ New_fingering_engraver::add_fingering (Grob *head, void New_fingering_engraver::position_scripts (SCM orientations, - vector<Finger_tuple> *scripts) + vector<Finger_tuple> *scripts) { for (vsize i = 0; i < scripts->size (); i++) if (stem_ && to_boolean (scripts->at (i).script_->get_property ("add-stem-support"))) @@ -203,10 +202,10 @@ New_fingering_engraver::position_scripts (SCM orientations, { SCM d = (*scripts)[i].finger_event_->get_property ("direction"); if (to_dir (d)) - { - ((to_dir (d) == UP) ? up : down).push_back ((*scripts)[i]); - scripts->erase (scripts->begin () + i); - } + { + ((to_dir (d) == UP) ? up : down).push_back ((*scripts)[i]); + scripts->erase (scripts->begin () + i); + } } vector_sort (*scripts, less<Finger_tuple> ()); @@ -219,16 +218,16 @@ New_fingering_engraver::position_scripts (SCM orientations, if (left_p || right_p) { if (up_p && !up.size () && scripts->size ()) - { - up.push_back (scripts->back ()); - scripts->pop_back (); - } + { + up.push_back (scripts->back ()); + scripts->pop_back (); + } if (down_p && !down.size () && scripts->size ()) - { - down.push_back ((*scripts)[0]); - scripts->erase (scripts->begin ()); - } + { + down.push_back ((*scripts)[0]); + scripts->erase (scripts->begin ()); + } horiz.insert (horiz.end (), scripts->begin (), scripts->end ()); } @@ -246,10 +245,10 @@ New_fingering_engraver::position_scripts (SCM orientations, else { if (!down_p) - { - warning (_ ("no placement found for fingerings")); - warning (_ ("placing below")); - } + { + warning (_ ("no placement found for fingerings")); + warning (_ ("placing below")); + } down.insert (down.end (), scripts->begin (), scripts->end ()); scripts->clear (); } @@ -262,12 +261,12 @@ New_fingering_engraver::position_scripts (SCM orientations, f->set_parent (ft.head_, Y_AXIS); f->set_property ("avoid-slur", SCM_BOOL_F); if (hordir == LEFT - && unsmob_grob (ft.head_->get_object ("accidental-grob"))) - Side_position_interface::add_support (f, - unsmob_grob (ft.head_->get_object ("accidental-grob"))); + && unsmob_grob (ft.head_->get_object ("accidental-grob"))) + Side_position_interface::add_support (f, + unsmob_grob (ft.head_->get_object ("accidental-grob"))); else if (unsmob_grob (ft.head_->get_object ("dot"))) - Side_position_interface::add_support (f, - unsmob_grob (ft.head_->get_object ("dot"))); + Side_position_interface::add_support (f, + unsmob_grob (ft.head_->get_object ("dot"))); Self_alignment_interface::set_align_self (f, Y_AXIS); Self_alignment_interface::set_center_parent (f, Y_AXIS); @@ -281,20 +280,20 @@ New_fingering_engraver::position_scripts (SCM orientations, do { for (vsize i = 0; i < vertical[d].size (); i++) - { - Finger_tuple ft = vertical[d][i]; - Grob *f = ft.script_; - int finger_prio = robust_scm2int (f->get_property ("script-priority"), 200); - f->set_parent (ft.head_, X_AXIS); - f->set_property ("script-priority", - scm_from_int (finger_prio + d * ft.position_)); - - Self_alignment_interface::set_align_self (f, X_AXIS); - Self_alignment_interface::set_center_parent (f, X_AXIS); - Side_position_interface::set_axis (f, Y_AXIS); - - f->set_property ("direction", scm_from_int (d)); - } + { + Finger_tuple ft = vertical[d][i]; + Grob *f = ft.script_; + int finger_prio = robust_scm2int (f->get_property ("script-priority"), 200); + f->set_parent (ft.head_, X_AXIS); + f->set_property ("script-priority", + scm_from_int (finger_prio + d * ft.position_)); + + Self_alignment_interface::set_align_self (f, X_AXIS); + Self_alignment_interface::set_center_parent (f, X_AXIS); + Side_position_interface::set_axis (f, Y_AXIS); + + f->set_property ("direction", scm_from_int (d)); + } } while (flip (&d) != DOWN); } @@ -313,21 +312,21 @@ New_fingering_engraver::position_all () if (fingerings_.size ()) { position_scripts (get_property ("fingeringOrientations"), - &fingerings_); + &fingerings_); fingerings_.clear (); } if (string_numbers_.size ()) { position_scripts (get_property ("stringNumberOrientations"), - &string_numbers_); + &string_numbers_); string_numbers_.clear (); } if (stroke_fingerings_.size ()) { position_scripts (get_property ("strokeFingerOrientations"), - &stroke_fingerings_); + &stroke_fingerings_); stroke_fingerings_.clear (); } @@ -336,13 +335,13 @@ New_fingering_engraver::position_all () Grob *script = articulations_[i].script_; for (vsize j = heads_.size (); j--;) - Side_position_interface::add_support (script, heads_[j]); + Side_position_interface::add_support (script, heads_[j]); if (stem_ && to_dir (script->get_property ("side-relative-direction"))) - script->set_object ("direction-source", stem_->self_scm ()); + script->set_object ("direction-source", stem_->self_scm ()); if (stem_ && to_boolean (script->get_property ("add-stem-support"))) - Side_position_interface::add_support (script, stem_); + Side_position_interface::add_support (script, stem_); } articulations_.clear (); } @@ -356,23 +355,23 @@ ADD_ACKNOWLEDGER (New_fingering_engraver, rhythmic_head); ADD_ACKNOWLEDGER (New_fingering_engraver, stem); ADD_TRANSLATOR (New_fingering_engraver, - /* doc */ - "Create fingering scripts for notes in a new chord. This" - " engraver is ill-named, since it also takes care of" - " articulations and harmonic note heads.", - - /* create */ - "Fingering " - "StringNumber " - "StrokeFinger " - "Script ", - - /* read */ - "fingeringOrientations " - "harmonicDots " - "strokeFingerOrientations " - "stringNumberOrientations ", - - /* write */ - "" - ); + /* doc */ + "Create fingering scripts for notes in a new chord. This" + " engraver is ill-named, since it also takes care of" + " articulations and harmonic note heads.", + + /* create */ + "Fingering " + "StringNumber " + "StrokeFinger " + "Script ", + + /* read */ + "fingeringOrientations " + "harmonicDots " + "strokeFingerOrientations " + "stringNumberOrientations ", + + /* write */ + "" + ); diff --git a/lily/note-collision.cc b/lily/note-collision.cc index b0049c69ea..ef591c2b6d 100644 --- a/lily/note-collision.cc +++ b/lily/note-collision.cc @@ -33,12 +33,11 @@ #include "stem.hh" #include "warn.hh" - void check_meshing_chords (Grob *me, - Drul_array<vector<Real> > *offsets, - Drul_array<vector<Slice> > const &extents, - Drul_array<vector<Grob*> > const &clash_groups) + Drul_array<vector<Real> > *offsets, + Drul_array<vector<Slice> > const &extents, + Drul_array<vector<Grob *> > const &clash_groups) { if (!extents[UP].size () || !extents[DOWN].size ()) @@ -51,8 +50,8 @@ check_meshing_chords (Grob *me, if (!Note_column::get_stem (clash_up) || !Note_column::get_stem (clash_down)) return; - Drul_array<Grob*> stems (Note_column::get_stem (clash_down), - Note_column::get_stem (clash_up)); + Drul_array<Grob *> stems (Note_column::get_stem (clash_down), + Note_column::get_stem (clash_up)); Grob *head_up = Note_column::first_head (clash_up); Grob *head_down = Note_column::first_head (clash_down); @@ -70,7 +69,7 @@ check_meshing_chords (Grob *me, /* Do not merge notes typeset in different style. */ if (!ly_is_equal (head_up->get_property ("style"), - head_down->get_property ("style"))) + head_down->get_property ("style"))) merge_possible = false; int up_ball_type = Rhythmic_head::duration_log (head_up); @@ -95,9 +94,9 @@ check_meshing_chords (Grob *me, them indistinguishable. */ if (merge_possible && ((Stem::duration_log (stems[UP]) == 1 - && Stem::duration_log (stems[DOWN]) == 2) - || (Stem::duration_log (stems[UP]) == 2 - && Stem::duration_log (stems[DOWN]) == 1))) + && Stem::duration_log (stems[DOWN]) == 2) + || (Stem::duration_log (stems[UP]) == 2 + && Stem::duration_log (stems[DOWN]) == 1))) merge_possible = false; /* @@ -133,36 +132,36 @@ check_meshing_chords (Grob *me, bool distant_half_collide = false; bool full_collide = false; - for (vsize i = 0, j = 0; i < ups.size () && j < dps.size (); ) + for (vsize i = 0, j = 0; i < ups.size () && j < dps.size ();) { if (abs (ups[i] - dps[j]) == 1) - { - merge_possible = false; - if (ups[i] > dps[j]) - close_half_collide = true; - else - distant_half_collide = true; - } + { + merge_possible = false; + if (ups[i] > dps[j]) + close_half_collide = true; + else + distant_half_collide = true; + } else if (ups[i] == dps[j]) - full_collide = true; + full_collide = true; else if (ups[i] > dps[0] && ups[i] < dps.back ()) - merge_possible = false; + merge_possible = false; else if (dps[j] > ups[0] && dps[j] < ups.back ()) - merge_possible = false; + merge_possible = false; if (ups[i] < dps[j]) - i++; + i++; else if (ups[i] > dps[j]) - j++; + j++; else - { - i++; - j++; - } + { + i++; + j++; + } } full_collide = full_collide || (close_half_collide - && distant_half_collide); + && distant_half_collide); Real shift_amount = 1; @@ -171,7 +170,7 @@ check_meshing_chords (Grob *me, the top note of which is the same pitch as the lowest upstem note, they shouldn't count as touching. */ - if (dps.back () == ups[0] && dps.size () > 1 && dps[dps.size() - 2] == ups[0] - 1) + if (dps.back () == ups[0] && dps.size () > 1 && dps[dps.size () - 2] == ups[0] - 1) touch = false; if (touch) @@ -183,9 +182,9 @@ check_meshing_chords (Grob *me, if (full_collide) { if (Rhythmic_head::dot_count (head_up) > Rhythmic_head::dot_count (head_down)) - shift_amount = 1; + shift_amount = 1; else if (Rhythmic_head::dot_count (head_up) < Rhythmic_head::dot_count (head_down)) - stem_to_stem = true; + stem_to_stem = true; } /* The solfa is a triangle, which is inverted depending on stem @@ -209,54 +208,54 @@ check_meshing_chords (Grob *me, shift_amount = 0; /* If possible, don't wipe any heads. Else, wipe shortest head, - or head with smallest amount of dots. Note: when merging - different heads, dots on the smaller one disappear. */ + or head with smallest amount of dots. Note: when merging + different heads, dots on the smaller one disappear. */ Grob *wipe_ball = 0; Grob *dot_wipe_head = head_up; if (up_ball_type == down_ball_type) - { - if (Rhythmic_head::dot_count (head_down) < Rhythmic_head::dot_count (head_up)) - { - wipe_ball = head_down; - dot_wipe_head = head_down; - } - else if (Rhythmic_head::dot_count (head_down) > Rhythmic_head::dot_count (head_up)) - { - dot_wipe_head = head_up; - wipe_ball = head_up; - } - else - dot_wipe_head = head_up; - } + { + if (Rhythmic_head::dot_count (head_down) < Rhythmic_head::dot_count (head_up)) + { + wipe_ball = head_down; + dot_wipe_head = head_down; + } + else if (Rhythmic_head::dot_count (head_down) > Rhythmic_head::dot_count (head_up)) + { + dot_wipe_head = head_up; + wipe_ball = head_up; + } + else + dot_wipe_head = head_up; + } else if (down_ball_type > up_ball_type) - { - wipe_ball = head_down; - dot_wipe_head = head_down; - } + { + wipe_ball = head_down; + dot_wipe_head = head_down; + } else if (down_ball_type < up_ball_type) - { - wipe_ball = head_up; - dot_wipe_head = head_up; - /* - If upper head is eighth note or shorter, and lower head is half note, - shift by the difference between the open and filled note head widths, - otherwise upper stem will be misaligned slightly. - */ - if (Stem::duration_log (stems[DOWN]) == 1 - && Stem::duration_log (stems[UP]) >= 3) - shift_amount = (1 - head_up->extent (head_up, X_AXIS).length () / - head_down->extent (head_down, X_AXIS).length ()) * 0.5; - } + { + wipe_ball = head_up; + dot_wipe_head = head_up; + /* + If upper head is eighth note or shorter, and lower head is half note, + shift by the difference between the open and filled note head widths, + otherwise upper stem will be misaligned slightly. + */ + if (Stem::duration_log (stems[DOWN]) == 1 + && Stem::duration_log (stems[UP]) >= 3) + shift_amount = (1 - head_up->extent (head_up, X_AXIS).length () + / head_down->extent (head_down, X_AXIS).length ()) * 0.5; + } if (dot_wipe_head) - { - if (Grob *d = unsmob_grob (dot_wipe_head->get_object ("dot"))) - d->suicide (); - } + { + if (Grob *d = unsmob_grob (dot_wipe_head->get_object ("dot"))) + d->suicide (); + } if (wipe_ball && wipe_ball->is_live ()) - wipe_ball->set_property ("transparent", SCM_BOOL_T); + wipe_ball->set_property ("transparent", SCM_BOOL_T); } /* TODO: these numbers are magic; should devise a set of grob props to tune this behavior. */ @@ -276,19 +275,18 @@ check_meshing_chords (Grob *me, shift_amount *= 0.17; /* - */ if (full_collide - && down_ball_type * up_ball_type == 0) + && down_ball_type *up_ball_type == 0) { if (up_ball_type == 0 && down_ball_type == 1) - shift_amount *= 1.25; + shift_amount *= 1.25; else if (up_ball_type == 0 && down_ball_type == 2) - shift_amount *= 1.35; + shift_amount *= 1.35; else if (down_ball_type == 0 && up_ball_type == 1) - shift_amount *= 0.7; + shift_amount *= 0.7; else if (down_ball_type == 0 && up_ball_type == 2) - shift_amount *= 0.75; + shift_amount *= 0.75; } /* @@ -305,20 +303,20 @@ check_meshing_chords (Grob *me, { Grob *staff = Staff_symbol_referencer::get_staff_symbol (me); if (!Staff_symbol_referencer::on_line (staff, ups[0])) - { - /* - TODO: consider junking the else body. - */ - if (to_boolean (me->get_property ("prefer-dotted-right"))) - shift_amount = 0.5; - else - { - Grob *d = unsmob_grob (head_up->get_object ("dot")); - Grob *parent = d->get_parent (X_AXIS); - if (Dot_column::has_interface (parent)) - Side_position_interface::add_support (parent, head_down); - } - } + { + /* + TODO: consider junking the else body. + */ + if (to_boolean (me->get_property ("prefer-dotted-right"))) + shift_amount = 0.5; + else + { + Grob *d = unsmob_grob (head_up->get_object ("dot")); + Grob *parent = d->get_parent (X_AXIS); + if (Dot_column::has_interface (parent)) + Side_position_interface::add_support (parent, head_down); + } + } } /* For full or close half collisions, the right hand head may @@ -331,35 +329,34 @@ check_meshing_chords (Grob *me, Grob *parent = d->get_parent (X_AXIS); /* - FIXME: + FIXME: - | - x . o - | + | + x . o + | - the . is put right of o which is erroneous o force-shifted - far to the right. + the . is put right of o which is erroneous o force-shifted + far to the right. */ if (Dot_column::has_interface (parent)) - { - Grob *stem = unsmob_grob (head_up->get_object ("stem")); - extract_grob_set (stem, "note-heads", heads); - for (vsize i = 0; i < heads.size (); i++) - Side_position_interface::add_support (parent, heads[i]); - } + { + Grob *stem = unsmob_grob (head_up->get_object ("stem")); + extract_grob_set (stem, "note-heads", heads); + for (vsize i = 0; i < heads.size (); i++) + Side_position_interface::add_support (parent, heads[i]); + } } Direction d = UP; do { for (vsize i = 0; i < clash_groups[d].size (); i++) - (*offsets)[d][i] += d * shift_amount; + (*offsets)[d][i] += d * shift_amount; } while ((flip (&d)) != UP); } - MAKE_SCHEME_CALLBACK (Note_collision_interface, calc_positioning_done, 1) SCM Note_collision_interface::calc_positioning_done (SCM smob) @@ -367,18 +364,18 @@ Note_collision_interface::calc_positioning_done (SCM smob) Grob *me = unsmob_grob (smob); me->set_property ("positioning-done", SCM_BOOL_T); - Drul_array<vector<Grob*> > clash_groups = get_clash_groups (me); + Drul_array<vector<Grob *> > clash_groups = get_clash_groups (me); Direction d = UP; do { - for (vsize i = clash_groups[d].size (); i--; ) - { - /* - Trigger positioning - */ - clash_groups[d][i]->extent (me, X_AXIS); - } + for (vsize i = clash_groups[d].size (); i--;) + { + /* + Trigger positioning + */ + clash_groups[d][i]->extent (me, X_AXIS); + } } while (flip (&d) != UP); @@ -389,16 +386,16 @@ Note_collision_interface::calc_positioning_done (SCM smob) do { if (clash_groups[d].size ()) - { - Grob *h = clash_groups[d][0]; - Grob *fh = Note_column::first_head (h); - if (fh) - wid = fh->extent (h, X_AXIS).length (); - } + { + Grob *h = clash_groups[d][0]; + Grob *fh = Note_column::first_head (h); + if (fh) + wid = fh->extent (h, X_AXIS).length (); + } } while (flip (&d) != UP); - vector<Grob*> done; + vector<Grob *> done; Real left_most = 1e6; vector<Real> amounts; @@ -410,7 +407,7 @@ Note_collision_interface::calc_positioning_done (SCM smob) done.push_back (s); amounts.push_back (amount); if (amount < left_most) - left_most = amount; + left_most = amount; } for (; scm_is_pair (autos); autos = scm_cdr (autos)) { @@ -419,12 +416,12 @@ Note_collision_interface::calc_positioning_done (SCM smob) vsize x = find (done, s) - done.begin (); if (x == VPOS || x >= done.size ()) - { - done.push_back (s); - amounts.push_back (amount); - if (amount < left_most) - left_most = amount; - } + { + done.push_back (s); + amounts.push_back (amount); + if (amount < left_most) + left_most = amount; + } } for (vsize i = 0; i < amounts.size (); i++) @@ -433,28 +430,28 @@ Note_collision_interface::calc_positioning_done (SCM smob) return SCM_BOOL_T; } -Drul_array < vector<Grob*> > +Drul_array < vector<Grob *> > Note_collision_interface::get_clash_groups (Grob *me) { - Drul_array<vector<Grob*> > clash_groups; + Drul_array<vector<Grob *> > clash_groups; extract_grob_set (me, "elements", elements); for (vsize i = 0; i < elements.size (); i++) { Grob *se = elements[i]; if (Note_column::has_interface (se)) - { - if (!Note_column::dir (se)) - se->programming_error ("note-column has no direction"); - else - clash_groups[Note_column::dir (se)].push_back (se); - } + { + if (!Note_column::dir (se)) + se->programming_error ("note-column has no direction"); + else + clash_groups[Note_column::dir (se)].push_back (se); + } } Direction d = UP; do { - vector<Grob*> &clashes (clash_groups[d]); + vector<Grob *> &clashes (clash_groups[d]); vector_sort (clashes, Note_column::shift_less); } while ((flip (&d)) != UP); @@ -468,7 +465,7 @@ Note_collision_interface::get_clash_groups (Grob *me) */ SCM Note_collision_interface::automatic_shift (Grob *me, - Drul_array<vector<Grob*> > clash_groups) + Drul_array<vector<Grob *> > clash_groups) { Drul_array < vector<int> > shifts; SCM tups = SCM_EOL; @@ -477,27 +474,27 @@ Note_collision_interface::automatic_shift (Grob *me, do { vector<int> &shift (shifts[d]); - vector<Grob*> &clashes (clash_groups[d]); + vector<Grob *> &clashes (clash_groups[d]); for (vsize i = 0; i < clashes.size (); i++) - { - SCM sh - = clashes[i]->get_property ("horizontal-shift"); + { + SCM sh + = clashes[i]->get_property ("horizontal-shift"); - if (scm_is_number (sh)) - shift.push_back (scm_to_int (sh)); - else - shift.push_back (0); - } + if (scm_is_number (sh)) + shift.push_back (scm_to_int (sh)); + else + shift.push_back (0); + } for (vsize i = 1; i < shift.size (); i++) - { - if (shift[i - 1] == shift[i]) - { - clashes[0]->warning (_ ("ignoring too many clashing note columns")); - return tups; - } - } + { + if (shift[i - 1] == shift[i]) + { + clashes[0]->warning (_ ("ignoring too many clashing note columns")); + return tups; + } + } } while ((flip (&d)) != UP); @@ -507,13 +504,13 @@ Note_collision_interface::automatic_shift (Grob *me, do { for (vsize i = 0; i < clash_groups[d].size (); i++) - { - Slice s (Note_column::head_positions_interval (clash_groups[d][i])); - s[LEFT]--; - s[RIGHT]++; - extents[d].push_back (s); - offsets[d].push_back (d * 0.5 * i); - } + { + Slice s (Note_column::head_positions_interval (clash_groups[d][i])); + s[LEFT]--; + s[RIGHT]++; + extents[d].push_back (s); + offsets[d].push_back (d * 0.5 * i); + } } while ((flip (&d)) != UP); @@ -529,18 +526,17 @@ Note_collision_interface::automatic_shift (Grob *me, do { for (vsize i = 1; i < clash_groups[d].size (); i++) - { - Slice prev = extents[d][i - 1]; - prev.intersect (extents[d][i]); - if (prev.length () > 0 - || (extents[-d].size () && d * (extents[d][i][-d] - extents[-d][0][d]) < 0)) - for (vsize j = i; j < clash_groups[d].size (); j++) - offsets[d][j] += d * 0.5; - } + { + Slice prev = extents[d][i - 1]; + prev.intersect (extents[d][i]); + if (prev.length () > 0 + || (extents[-d].size () && d * (extents[d][i][-d] - extents[-d][0][d]) < 0)) + for (vsize j = i; j < clash_groups[d].size (); j++) + offsets[d][j] += d * 0.5; + } } while ((flip (&d)) != UP); - /* see input/regression/dot-up-voice-collision.ly */ @@ -550,11 +546,11 @@ Note_collision_interface::automatic_shift (Grob *me, Grob *dc = Note_column::dot_column (g); if (dc) - for (vsize j = i + 1; j < clash_groups[UP].size (); j++) - { - Grob *stem = Note_column::get_stem (clash_groups[UP][j]); - Side_position_interface::add_support (dc, stem); - } + for (vsize j = i + 1; j < clash_groups[UP].size (); j++) + { + Grob *stem = Note_column::get_stem (clash_groups[UP][j]); + Side_position_interface::add_support (dc, stem); + } } /* @@ -566,9 +562,9 @@ Note_collision_interface::automatic_shift (Grob *me, do { for (vsize i = 0; i < clash_groups[d].size (); i++) - tups = scm_cons (scm_cons (clash_groups[d][i]->self_scm (), - scm_from_double (offsets[d][i])), - tups); + tups = scm_cons (scm_cons (clash_groups[d][i]->self_scm (), + scm_from_double (offsets[d][i])), + tups); } while (flip (&d) != UP); @@ -587,8 +583,8 @@ Note_collision_interface::forced_shift (Grob *me) SCM force = se->get_property ("force-hshift"); if (scm_is_number (force)) - tups = scm_cons (scm_cons (se->self_scm (), force), - tups); + tups = scm_cons (scm_cons (se->self_scm (), force), + tups); } return tups; } @@ -601,15 +597,15 @@ Note_collision_interface::add_column (Grob *me, Grob *ncol) } ADD_INTERFACE (Note_collision_interface, - "An object that handles collisions between notes with" - " different stem directions and horizontal shifts. Most of" - " the interesting properties are to be set in" - " @ref{note-column-interface}: these are @code{force-hshift}" - " and @code{horizontal-shift}.", - - /* properties */ - "merge-differently-dotted " - "merge-differently-headed " - "positioning-done " - "prefer-dotted-right " - ); + "An object that handles collisions between notes with" + " different stem directions and horizontal shifts. Most of" + " the interesting properties are to be set in" + " @ref{note-column-interface}: these are @code{force-hshift}" + " and @code{horizontal-shift}.", + + /* properties */ + "merge-differently-dotted " + "merge-differently-headed " + "positioning-done " + "prefer-dotted-right " + ); diff --git a/lily/note-column-scheme.cc b/lily/note-column-scheme.cc index bf76ce9112..136c9d3062 100644 --- a/lily/note-column-scheme.cc +++ b/lily/note-column-scheme.cc @@ -10,11 +10,11 @@ LilyPond is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with LilyPond. If not, see <http://www.gnu.org/licenses/>. + along with LilyPond. If not, see <http://www.gnu.org/licenses/>. */ #include "note-column.hh" @@ -22,9 +22,9 @@ #include "grob.hh" LY_DEFINE (ly_note_column_accidentals, "ly:note-column-accidentals", - 1, 0, 0, (SCM note_column), - "Return the @code{AccidentalPlacement} grob from @var{note-column}" - " if any, or @code{SCM_EOL} otherwise.") + 1, 0, 0, (SCM note_column), + "Return the @code{AccidentalPlacement} grob from @var{note-column}" + " if any, or @code{SCM_EOL} otherwise.") { Grob *grob = unsmob_grob (note_column); LY_ASSERT_SMOB (Grob, note_column, 1); @@ -35,9 +35,9 @@ LY_DEFINE (ly_note_column_accidentals, "ly:note-column-accidentals", } LY_DEFINE (ly_note_column_dot_column, "ly:note-column-dot-column", - 1, 0, 0, (SCM note_column), - "Return the @code{DotColumn} grob from @var{note-column}" - " if any, or @code{SCM_EOL} otherwise.") + 1, 0, 0, (SCM note_column), + "Return the @code{DotColumn} grob from @var{note-column}" + " if any, or @code{SCM_EOL} otherwise.") { Grob *grob = unsmob_grob (note_column); LY_ASSERT_SMOB (Grob, note_column, 1); diff --git a/lily/note-column.cc b/lily/note-column.cc index 2ba81c66c4..a49c41b134 100644 --- a/lily/note-column.cc +++ b/lily/note-column.cc @@ -19,7 +19,7 @@ #include "note-column.hh" -#include <cmath> // ceil +#include <cmath> // ceil using namespace std; #include "accidental-placement.hh" @@ -92,7 +92,7 @@ Note_column::dir (Grob *me) { extract_grob_set (me, "note-heads", heads); if (heads.size ()) - return (Direction)sign (head_positions_interval (me).center ()); + return (Direction)sign (head_positions_interval (me).center ()); } programming_error ("note column without heads and stem"); @@ -120,14 +120,14 @@ Note_column::add_head (Grob *me, Grob *h) { extract_grob_set (me, "note-heads", heads); if (heads.size ()) - both = true; + both = true; else - me->set_object ("rest", h->self_scm ()); + me->set_object ("rest", h->self_scm ()); } else if (Note_head::has_interface (h)) { if (unsmob_grob (me->get_object ("rest"))) - both = true; + both = true; Pointer_group_interface::add_grob (me, ly_symbol2scm ("note-heads"), h); } @@ -157,7 +157,7 @@ Note_column::accidentals (Grob *me) Grob *h = heads[i]; acc = h ? unsmob_grob (h->get_object ("accidental-grob")) : 0; if (acc) - break; + break; } if (!acc) @@ -178,7 +178,7 @@ Note_column::dot_column (Grob *me) { Grob *dots = unsmob_grob (heads[i]->get_object ("dot")); if (dots) - return dots->get_parent (X_AXIS); + return dots->get_parent (X_AXIS); } return 0; @@ -205,15 +205,15 @@ Note_column::cross_staff_extent (Grob *me, Grob *refp) } ADD_INTERFACE (Note_column, - "Stem and noteheads combined.", - - /* properties */ - "arpeggio " - "force-hshift " - "horizontal-shift " - "ignore-collision " - "note-heads " - "rest " - "rest-collision " - "stem " - ); + "Stem and noteheads combined.", + + /* properties */ + "arpeggio " + "force-hshift " + "horizontal-shift " + "ignore-collision " + "note-heads " + "rest " + "rest-collision " + "stem " + ); diff --git a/lily/note-head-line-engraver.cc b/lily/note-head-line-engraver.cc index 2d41d10758..9298b72db9 100644 --- a/lily/note-head-line-engraver.cc +++ b/lily/note-head-line-engraver.cc @@ -27,7 +27,6 @@ #include "spanner.hh" #include "item.hh" - /** Create line-spanner grobs for lines that connect note heads. @@ -91,7 +90,7 @@ Note_head_line_engraver::process_acknowledged () Should probably store follow_ in line_, and suicide at some later point */ if (follow_) - line_ = make_spanner ("VoiceFollower", head_->self_scm ()); + line_ = make_spanner ("VoiceFollower", head_->self_scm ()); line_->set_bound (LEFT, last_head_); line_->set_bound (RIGHT, head_); @@ -113,18 +112,18 @@ Note_head_line_engraver::stop_translation_timestep () ADD_ACKNOWLEDGER (Note_head_line_engraver, rhythmic_head); ADD_TRANSLATOR (Note_head_line_engraver, - /* doc */ - "Engrave a line between two note heads, for example a" - " glissando. If @code{followVoice} is set, staff switches" - " also generate a line.", + /* doc */ + "Engrave a line between two note heads, for example a" + " glissando. If @code{followVoice} is set, staff switches" + " also generate a line.", - /* create */ - "Glissando " - "VoiceFollower ", + /* create */ + "Glissando " + "VoiceFollower ", - /* read */ - "followVoice ", + /* read */ + "followVoice ", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/note-head-scheme.cc b/lily/note-head-scheme.cc index 6698973339..0277b65b26 100644 --- a/lily/note-head-scheme.cc +++ b/lily/note-head-scheme.cc @@ -21,16 +21,15 @@ #include "note-head.hh" #include "font-metric.hh" - LY_DEFINE (ly_note_head__stem_attachment, "ly:note-head::stem-attachment", - 2, 0, 0, (SCM font_metric, SCM glyph_name), - "Get attachment in @var{font-metric} for attaching a stem to" - " notehead @var{glyph-name}.") + 2, 0, 0, (SCM font_metric, SCM glyph_name), + "Get attachment in @var{font-metric} for attaching a stem to" + " notehead @var{glyph-name}.") { LY_ASSERT_SMOB (Font_metric, font_metric, 1); Font_metric *fm = unsmob_metrics (font_metric); LY_ASSERT_TYPE (scm_is_string, glyph_name, 2); - + return ly_offset2scm (Note_head::get_stem_attachment (fm, ly_scm2string (glyph_name))); } diff --git a/lily/note-head.cc b/lily/note-head.cc index aeb7b4a19b..614ba547ad 100644 --- a/lily/note-head.cc +++ b/lily/note-head.cc @@ -21,7 +21,7 @@ #include <cmath> #include <cctype> -#include <algorithm> // min, max +#include <algorithm> // min, max using namespace std; @@ -45,7 +45,7 @@ internal_print (Grob *me, string *font_char) { SCM gn = me->get_property ("glyph-name"); if (scm_is_string (gn)) - suffix = ly_scm2string (gn); + suffix = ly_scm2string (gn); } Font_metric *fm = Font_interface::get_default_font (me); @@ -61,20 +61,19 @@ internal_print (Grob *me, string *font_char) Grob *stem = unsmob_grob (me->get_object ("stem")); Direction stem_dir = stem ? get_grob_direction (stem) : CENTER; - + if (stem_dir == CENTER) - programming_error ("must have stem dir for note head"); - - idx_directed = idx_either = - prefix + ((stem_dir == UP) ? "u" : "d") + suffix; + programming_error ("must have stem dir for note head"); + + idx_directed = idx_either + = prefix + ((stem_dir == UP) ? "u" : "d") + suffix; out = fm->find_by_name (idx_directed); } - if (out.is_empty ()) { me->warning (_f ("none of note heads `%s' or `%s' found", - idx_symmetric.c_str (), idx_directed.c_str ())); + idx_symmetric.c_str (), idx_directed.c_str ())); out = Stencil (Box (Interval (0, 0), Interval (0, 0)), SCM_EOL); } else @@ -84,7 +83,7 @@ internal_print (Grob *me, string *font_char) } /* - TODO: make stem X-parent of notehead. + TODO: make stem X-parent of notehead. */ MAKE_SCHEME_CALLBACK (Note_head, stem_x_shift, 1); SCM @@ -126,7 +125,7 @@ Note_head::include_ledger_line_height (SCM smob) // the interval between the note and the first ledger line, not // the whole interval between the note and the staff. Interval iv (min (0.0, lines[UP] - my_ext[DOWN] + 1), - max (0.0, lines[DOWN] - my_ext[UP] - 1)); + max (0.0, lines[DOWN] - my_ext[UP] - 1)); return ly_interval2scm (iv); } @@ -137,8 +136,8 @@ Real Note_head::stem_attachment_coordinate (Grob *me, Axis a) { Offset off = robust_scm2offset (me->get_property ("stem-attachment"), - Offset (0,0)); - + Offset (0, 0)); + return off [a]; } @@ -146,22 +145,22 @@ Offset Note_head::get_stem_attachment (Font_metric *fm, string key) { Offset att; - + int k = fm->name_to_index (key); if (k >= 0) { Box b = fm->get_indexed_char_dimensions (k); Offset wxwy = fm->attachment_point (key); - for (int i = X_AXIS ; i < NO_AXES; i++) - { - Axis a = Axis (i); - - Interval v = b[a]; - if (!v.is_empty ()) - { - att[a] = (2 * (wxwy[a] - v.center ()) / v.length ()); - } - } + for (int i = X_AXIS; i < NO_AXES; i++) + { + Axis a = Axis (i); + + Interval v = b[a]; + if (!v.is_empty ()) + { + att[a] = (2 * (wxwy[a] - v.center ()) / v.length ()); + } + } } return att; @@ -171,7 +170,7 @@ MAKE_SCHEME_CALLBACK (Note_head, calc_stem_attachment, 1); SCM Note_head::calc_stem_attachment (SCM smob) { - Grob *me = unsmob_grob (smob); + Grob *me = unsmob_grob (smob); Font_metric *fm = Font_interface::get_default_font (me); string key; internal_print (me, &key); @@ -179,17 +178,16 @@ Note_head::calc_stem_attachment (SCM smob) return ly_offset2scm (get_stem_attachment (fm, key)); } - ADD_INTERFACE (Note_head, - "A note head. There are many possible values for" - " @code{style}. For a complete list, see" - " @ruser{Note head styles}.", - - /* properties */ - "note-names " - "accidental-grob " - "glyph-name " - "stem-attachment " - "style " - ); + "A note head. There are many possible values for" + " @code{style}. For a complete list, see" + " @ruser{Note head styles}.", + + /* properties */ + "note-names " + "accidental-grob " + "glyph-name " + "stem-attachment " + "style " + ); diff --git a/lily/note-heads-engraver.cc b/lily/note-heads-engraver.cc index 4aa97dd4b9..2e584539d6 100644 --- a/lily/note-heads-engraver.cc +++ b/lily/note-heads-engraver.cc @@ -73,45 +73,45 @@ Note_heads_engraver::process_music () #if 0 /* TODO: should have a mechanism to switch off these warnings. */ if (!pit) - ev->origin ()->warning (_ ("NoteEvent without pitch")); + ev->origin ()->warning (_ ("NoteEvent without pitch")); #endif int pos; if (pit == 0) - pos = 0; + pos = 0; else if (ly_is_procedure (layout_proc)) - { - SCM pitch = ev->get_property ("pitch"); - pos = scm_to_int (scm_call_1 (layout_proc, pitch)); - } + { + SCM pitch = ev->get_property ("pitch"); + pos = scm_to_int (scm_call_1 (layout_proc, pitch)); + } else - pos = pit->steps (); + pos = pit->steps (); if (scm_is_number (c0)) - pos += scm_to_int (c0); + pos += scm_to_int (c0); note->set_property ("staff-position", scm_from_int (pos)); /* - Shape note heads change on step of the scale. + Shape note heads change on step of the scale. */ SCM shape_vector = get_property ("shapeNoteStyles"); if (scm_is_vector (shape_vector)) - { - SCM scm_tonic = get_property ("tonic"); - Pitch tonic (0, 0, 0); - if (unsmob_pitch (scm_tonic)) - tonic = *unsmob_pitch (scm_tonic); - - unsigned int delta = (pit->get_notename () - tonic.get_notename () + 7) % 7; - - SCM style = SCM_EOL; - if (scm_c_vector_length (shape_vector) > delta - && scm_is_symbol (scm_vector_ref (shape_vector, scm_from_int (delta)))) - style = scm_vector_ref (shape_vector, scm_from_int (delta)); - if (scm_is_symbol (style)) - note->set_property ("style", style); - } + { + SCM scm_tonic = get_property ("tonic"); + Pitch tonic (0, 0, 0); + if (unsmob_pitch (scm_tonic)) + tonic = *unsmob_pitch (scm_tonic); + + unsigned int delta = (pit->get_notename () - tonic.get_notename () + 7) % 7; + + SCM style = SCM_EOL; + if (scm_c_vector_length (shape_vector) > delta + && scm_is_symbol (scm_vector_ref (shape_vector, scm_from_int (delta)))) + style = scm_vector_ref (shape_vector, scm_from_int (delta)); + if (scm_is_symbol (style)) + note->set_property ("style", style); + } } } @@ -122,16 +122,16 @@ Note_heads_engraver::stop_translation_timestep () } ADD_TRANSLATOR (Note_heads_engraver, - /* doc */ - "Generate note heads.", + /* doc */ + "Generate note heads.", - /* create */ - "NoteHead ", + /* create */ + "NoteHead ", - /* read */ - "middleCPosition " - "staffLineLayoutFunction ", + /* read */ + "middleCPosition " + "staffLineLayoutFunction ", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/note-name-engraver.cc b/lily/note-name-engraver.cc index d2a6b91535..e646d2ad29 100644 --- a/lily/note-name-engraver.cc +++ b/lily/note-name-engraver.cc @@ -49,11 +49,11 @@ Note_name_engraver::process_music () for (vsize i = 0; i < events_.size (); i++) { if (i) - s += " "; + s += " "; Pitch p = *unsmob_pitch (events_[i]->get_property ("pitch")); if (!to_boolean (get_property ("printOctaveNames"))) - p = Pitch (-1, p.get_notename (), p.get_alteration ()); + p = Pitch (-1, p.get_notename (), p.get_alteration ()); s += p.to_string (); } @@ -75,15 +75,15 @@ Note_name_engraver::Note_name_engraver () } ADD_TRANSLATOR (Note_name_engraver, - /* doc */ - "Print pitches as words.", + /* doc */ + "Print pitches as words.", - /* create */ - "NoteName ", + /* create */ + "NoteName ", - /* read */ - "printOctaveNames ", + /* read */ + "printOctaveNames ", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/note-performer.cc b/lily/note-performer.cc index ff3f5b3f81..ce5c822fb4 100644 --- a/lily/note-performer.cc +++ b/lily/note-performer.cc @@ -37,13 +37,12 @@ protected: DECLARE_TRANSLATOR_LISTENER (note); private: - vector<Stream_event*> note_evs_; - vector<Audio_note*> notes_; + vector<Stream_event *> note_evs_; + vector<Audio_note *> notes_; - - vector<Audio_note*> last_notes_; + vector<Audio_note *> last_notes_; Moment last_start_; - + }; void @@ -57,48 +56,48 @@ Note_performer::process_music () if (unsmob_pitch (prop)) transposing = *unsmob_pitch (prop); - for (vsize i = 0; i < note_evs_.size (); i ++) + for (vsize i = 0; i < note_evs_.size (); i++) { Stream_event *n = note_evs_[i]; SCM pit = n->get_property ("pitch"); if (Pitch *pitp = unsmob_pitch (pit)) - { - SCM articulations = n->get_property ("articulations"); - Stream_event *tie_event = 0; - for (SCM s = articulations; - !tie_event && scm_is_pair (s); - s = scm_cdr (s)) - { - Stream_event *ev = unsmob_stream_event (scm_car (s)); - if (!ev) - continue; - - if (ev->in_event_class ("tie-event")) - tie_event = ev; - } - - Moment len = get_event_length (n, now_mom ()); - - Audio_note *p = new Audio_note (*pitp, len, - tie_event, transposing.negated ()); - Audio_element_info info (p, n); - announce_element (info); - notes_.push_back (p); - - /* - shorten previous note. - */ - if (now_mom ().grace_part_) - { - if (last_start_.grace_part_ == Rational (0)) - { - for (vsize i = 0; i < last_notes_.size (); i++) - last_notes_[i]->length_mom_ += Moment (0, - now_mom().grace_part_); - } - } - } + { + SCM articulations = n->get_property ("articulations"); + Stream_event *tie_event = 0; + for (SCM s = articulations; + !tie_event && scm_is_pair (s); + s = scm_cdr (s)) + { + Stream_event *ev = unsmob_stream_event (scm_car (s)); + if (!ev) + continue; + + if (ev->in_event_class ("tie-event")) + tie_event = ev; + } + + Moment len = get_event_length (n, now_mom ()); + + Audio_note *p = new Audio_note (*pitp, len, + tie_event, transposing.negated ()); + Audio_element_info info (p, n); + announce_element (info); + notes_.push_back (p); + + /* + shorten previous note. + */ + if (now_mom ().grace_part_) + { + if (last_start_.grace_part_ == Rational (0)) + { + for (vsize i = 0; i < last_notes_.size (); i++) + last_notes_[i]->length_mom_ += Moment (0, + now_mom ().grace_part_); + } + } + } } } @@ -123,18 +122,18 @@ Note_performer::listen_note (Stream_event *ev) } ADD_TRANSLATOR (Note_performer, - /* doc */ - "", + /* doc */ + "", - /* create */ - "", + /* create */ + "", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); Note_performer::Note_performer () { diff --git a/lily/note-spacing-engraver.cc b/lily/note-spacing-engraver.cc index 761e01aa0b..3608a6b1ed 100644 --- a/lily/note-spacing-engraver.cc +++ b/lily/note-spacing-engraver.cc @@ -30,10 +30,10 @@ class Note_spacing_engraver : public Engraver { - typedef map <Context*, Grob*> Last_spacing_map; + typedef map <Context *, Grob *> Last_spacing_map; Last_spacing_map last_spacings_; Grob *last_spacing_; - + Grob *spacing_; void add_spacing_item (Grob *); @@ -68,21 +68,20 @@ Note_spacing_engraver::add_spacing_item (Grob *g) { spacing_ = make_item ("NoteSpacing", g->self_scm ()); } - + if (spacing_) { Pointer_group_interface::add_grob (spacing_, - ly_symbol2scm ("left-items"), - g); + ly_symbol2scm ("left-items"), + g); if (last_spacing_) - Pointer_group_interface::add_grob (last_spacing_, - ly_symbol2scm ("right-items"), - g); + Pointer_group_interface::add_grob (last_spacing_, + ly_symbol2scm ("right-items"), + g); } } - void Note_spacing_engraver::acknowledge_note_column (Grob_info gi) { @@ -104,11 +103,11 @@ Note_spacing_engraver::finalize () if (last_spacing && !unsmob_grob_array (last_spacing->get_object ("right-items"))) { - Grob *col = unsmob_grob (get_property ("currentCommandColumn")); - + Grob *col = unsmob_grob (get_property ("currentCommandColumn")); + Pointer_group_interface::add_grob (last_spacing, - ly_symbol2scm ("right-items"), - col); + ly_symbol2scm ("right-items"), + col); } } @@ -123,10 +122,10 @@ Note_spacing_engraver::stop_translation_timestep () { Grob *col = unsmob_grob (get_property ("currentCommandColumn")); Pointer_group_interface::add_grob (last_spacing, - ly_symbol2scm ("right-items"), - col); + ly_symbol2scm ("right-items"), + col); } - + if (spacing_) { last_spacings_[parent] = spacing_; @@ -140,16 +139,16 @@ ADD_ACKNOWLEDGER (Note_spacing_engraver, note_column); ADD_ACKNOWLEDGER (Note_spacing_engraver, rhythmic_grob); ADD_TRANSLATOR (Note_spacing_engraver, - /* doc */ - "Generate @code{NoteSpacing}, an object linking horizontal" - " lines for use in spacing.", + /* doc */ + "Generate @code{NoteSpacing}, an object linking horizontal" + " lines for use in spacing.", - /* create */ - "NoteSpacing ", + /* create */ + "NoteSpacing ", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/note-spacing.cc b/lily/note-spacing.cc index 73faa02100..8153af9635 100644 --- a/lily/note-spacing.cc +++ b/lily/note-spacing.cc @@ -41,7 +41,7 @@ Spring Note_spacing::get_spacing (Grob *me, Item *right_col, - Real base_space, Real increment) + Real base_space, Real increment) { vector<Item *> note_columns = Spacing_interface::left_note_columns (me); Real left_head_end = 0; @@ -53,19 +53,19 @@ Note_spacing::get_spacing (Grob *me, Item *right_col, Grob *col = note_columns[i]->get_column (); if (!g) - g = Note_column::first_head (note_columns[i]); + g = Note_column::first_head (note_columns[i]); /* - Ugh. If Stem is switched off, we don't know what the - first note head will be. + Ugh. If Stem is switched off, we don't know what the + first note head will be. */ if (g) - { - if (g->common_refpoint (col, X_AXIS) != col) - programming_error ("Note_spacing::get_spacing (): Common refpoint incorrect"); - else - left_head_end = g->extent (col, X_AXIS)[RIGHT]; - } + { + if (g->common_refpoint (col, X_AXIS) != col) + programming_error ("Note_spacing::get_spacing (): Common refpoint incorrect"); + else + left_head_end = g->extent (col, X_AXIS)[RIGHT]; + } } /* @@ -90,17 +90,17 @@ Note_spacing::get_spacing (Grob *me, Item *right_col, && to_boolean (me->get_property ("space-to-barline"))) { Grob *bar = Pointer_group_interface::find_grob (right_col, - ly_symbol2scm ("elements"), - Bar_line::non_empty_barline); + ly_symbol2scm ("elements"), + Bar_line::non_empty_barline); if (bar) - { - Real shift = bar->extent (right_col, X_AXIS)[LEFT]; - ideal -= shift; - min_desired_space -= max (shift, 0.0); - } + { + Real shift = bar->extent (right_col, X_AXIS)[LEFT]; + ideal -= shift; + min_desired_space -= max (shift, 0.0); + } else - ideal -= right_col->extent (right_col, X_AXIS)[RIGHT]; + ideal -= right_col->extent (right_col, X_AXIS)[RIGHT]; } ideal = max (ideal, min_desired_space); @@ -127,19 +127,19 @@ knee_correction (Grob *note_spacing, Grob *right_stem, Real increment) head_extent = head->extent (rcolumn, X_AXIS); if (!head_extent.is_empty ()) - note_head_width = head_extent[RIGHT]; + note_head_width = head_extent[RIGHT]; note_head_width -= Stem::thickness (right_stem); } return -note_head_width * get_grob_direction (right_stem) - * robust_scm2double (note_spacing->get_property ("knee-spacing-correction"), 0); + * robust_scm2double (note_spacing->get_property ("knee-spacing-correction"), 0); } static Real different_directions_correction (Grob *note_spacing, - Drul_array<Interval> stem_posns, - Direction left_stem_dir) + Drul_array<Interval> stem_posns, + Direction left_stem_dir) { Real ret = 0.0; Interval intersect = stem_posns[LEFT]; @@ -150,11 +150,11 @@ different_directions_correction (Grob *note_spacing, ret = abs (intersect.length ()); /* - Ugh. 7 is hardcoded. + Ugh. 7 is hardcoded. */ ret = min (ret / 7, 1.0) - * left_stem_dir - * robust_scm2double (note_spacing->get_property ("stem-spacing-correction"), 0); + * left_stem_dir + * robust_scm2double (note_spacing->get_property ("stem-spacing-correction"), 0); } return ret; } @@ -204,14 +204,14 @@ same_direction_correction (Grob *note_spacing, Drul_array<Interval> head_posns) */ void Note_spacing::stem_dir_correction (Grob *me, Item *rcolumn, - Real increment, - Real *space, Real *fixed) + Real increment, + Real *space, Real *fixed) { Drul_array<Direction> stem_dirs (CENTER, CENTER); Drul_array<Interval> stem_posns; Drul_array<Interval> head_posns; Drul_array<SCM> props (me->get_object ("left-items"), - me->get_object ("right-items")); + me->get_object ("right-items")); Drul_array<Spanner *> beams_drul (0, 0); Drul_array<Grob *> stems_drul (0, 0); @@ -226,8 +226,8 @@ Note_spacing::stem_dir_correction (Grob *me, Item *rcolumn, bool acc_right = false; Grob *bar = Spacing_interface::extremal_break_aligned_grob (me, RIGHT, - rcolumn->break_status_dir (), - &bar_xextent); + rcolumn->break_status_dir (), + &bar_xextent); if (bar && dynamic_cast<Item *> (bar)->get_column () == rcolumn) bar_yextent = Staff_spacing::bar_y_positions (bar); @@ -235,58 +235,58 @@ Note_spacing::stem_dir_correction (Grob *me, Item *rcolumn, { vector<Grob *> const &items (ly_scm2link_array (props [d])); for (vsize i = 0; i < items.size (); i++) - { - Item *it = dynamic_cast<Item *> (items[i]); - if (!Note_column::has_interface (it)) - continue; - if (d == RIGHT && it->get_column () != rcolumn) - continue; - - /* - Find accidentals which are sticking out of the right side. - */ - if (d == RIGHT) - acc_right = acc_right || Note_column::accidentals (it); - - Grob *stem = Note_column::get_stem (it); - - if (!stem || !stem->is_live () || Stem::is_invisible (stem)) - return; - - stems_drul[d] = stem; - beams_drul[d] = Stem::get_beam (stem); - - Direction stem_dir = get_grob_direction (stem); - if (stem_dirs[d] && stem_dirs[d] != stem_dir) - return; - - stem_dirs[d] = stem_dir; - - /* - Correction doesn't seem appropriate when there is a large flag - hanging from the note. - */ - if (d == LEFT - && Stem::duration_log (stem) > 2 && !Stem::get_beam (stem)) - return; - - Interval hp = Stem::head_positions (stem); - if (!hp.is_empty ()) - { - Real chord_start = hp[stem_dir]; - - /* - can't look at stem-end-position, since that triggers - beam slope computations. - */ - Real stem_end = hp[stem_dir] - + stem_dir * robust_scm2double (stem->get_property ("length"), 7); - - stem_posns[d] = Interval (min (chord_start, stem_end), - max (chord_start, stem_end)); - head_posns[d].unite (hp); - } - } + { + Item *it = dynamic_cast<Item *> (items[i]); + if (!Note_column::has_interface (it)) + continue; + if (d == RIGHT && it->get_column () != rcolumn) + continue; + + /* + Find accidentals which are sticking out of the right side. + */ + if (d == RIGHT) + acc_right = acc_right || Note_column::accidentals (it); + + Grob *stem = Note_column::get_stem (it); + + if (!stem || !stem->is_live () || Stem::is_invisible (stem)) + return; + + stems_drul[d] = stem; + beams_drul[d] = Stem::get_beam (stem); + + Direction stem_dir = get_grob_direction (stem); + if (stem_dirs[d] && stem_dirs[d] != stem_dir) + return; + + stem_dirs[d] = stem_dir; + + /* + Correction doesn't seem appropriate when there is a large flag + hanging from the note. + */ + if (d == LEFT + && Stem::duration_log (stem) > 2 && !Stem::get_beam (stem)) + return; + + Interval hp = Stem::head_positions (stem); + if (!hp.is_empty ()) + { + Real chord_start = hp[stem_dir]; + + /* + can't look at stem-end-position, since that triggers + beam slope computations. + */ + Real stem_end = hp[stem_dir] + + stem_dir * robust_scm2double (stem->get_property ("length"), 7); + + stem_posns[d] = Interval (min (chord_start, stem_end), + max (chord_start, stem_end)); + head_posns[d].unite (hp); + } + } } while (flip (&d) != LEFT); @@ -302,24 +302,24 @@ Note_spacing::stem_dir_correction (Grob *me, Item *rcolumn, if (stem_dirs[LEFT] * stem_dirs[RIGHT] == -1) { if (beams_drul[LEFT] && beams_drul[LEFT] == beams_drul[RIGHT]) - { - correction = knee_correction (me, stems_drul[RIGHT], increment); - *fixed += correction; - } + { + correction = knee_correction (me, stems_drul[RIGHT], increment); + *fixed += correction; + } else - { - correction = different_directions_correction (me, stem_posns, stem_dirs[LEFT]); + { + correction = different_directions_correction (me, stem_posns, stem_dirs[LEFT]); - if (!bar_yextent.is_empty ()) - correction *= 0.5; - } + if (!bar_yextent.is_empty ()) + correction *= 0.5; + } } /* Only apply same direction correction if there are no accidentals sticking out of the right hand side. */ else if (stem_dirs[LEFT] * stem_dirs[RIGHT] == 1 - && !acc_right) + && !acc_right) correction = same_direction_correction (me, head_posns); *space += correction; @@ -330,14 +330,14 @@ Note_spacing::stem_dir_correction (Grob *me, Item *rcolumn, } ADD_INTERFACE (Note_spacing, - "This object calculates spacing wishes for individual voices.", - - /* properties */ - "knee-spacing-correction " - "left-items " - "right-items " - "same-direction-correction " - "stem-spacing-correction " - "space-to-barline " - ); + "This object calculates spacing wishes for individual voices.", + + /* properties */ + "knee-spacing-correction " + "left-items " + "right-items " + "same-direction-correction " + "stem-spacing-correction " + "space-to-barline " + ); diff --git a/lily/open-type-font-scheme.cc b/lily/open-type-font-scheme.cc index fd48290aa0..2afceda119 100644 --- a/lily/open-type-font-scheme.cc +++ b/lily/open-type-font-scheme.cc @@ -21,9 +21,9 @@ #include "open-type-font.hh" LY_DEFINE (ly_font_sub_fonts, "ly:font-sub-fonts", 1, 0, 0, - (SCM font), - "Given the font metric @var{font} of an OpenType font, return the" - " names of the subfonts within @var{font}.") + (SCM font), + "Given the font metric @var{font} of an OpenType font, return the" + " names of the subfonts within @var{font}.") { LY_ASSERT_SMOB (Font_metric, font, 1); @@ -32,15 +32,15 @@ LY_DEFINE (ly_font_sub_fonts, "ly:font-sub-fonts", 1, 0, 0, } LY_DEFINE (ly_otf_font_glyph_info, "ly:otf-font-glyph-info", 2, 0, 0, - (SCM font, SCM glyph), - "Given the font metric @var{font} of an OpenType font, return the" - " information about named glyph @var{glyph} (a string).") + (SCM font, SCM glyph), + "Given the font metric @var{font} of an OpenType font, return the" + " information about named glyph @var{glyph} (a string).") { Modified_font_metric *fm = dynamic_cast<Modified_font_metric *> (unsmob_metrics (font)); Open_type_font *otf = fm - ? dynamic_cast<Open_type_font *> (fm->original_font ()) - : dynamic_cast<Open_type_font *> (unsmob_metrics (font)); + ? dynamic_cast<Open_type_font *> (fm->original_font ()) + : dynamic_cast<Open_type_font *> (unsmob_metrics (font)); SCM_ASSERT_TYPE (otf, font, SCM_ARG1, __FUNCTION__, "OpenType font"); LY_ASSERT_TYPE (scm_is_string, glyph, 2); @@ -50,15 +50,15 @@ LY_DEFINE (ly_otf_font_glyph_info, "ly:otf-font-glyph-info", 2, 0, 0, } LY_DEFINE (ly_otf_font_table_data, "ly:otf-font-table-data", 2, 0, 0, - (SCM font, SCM tag), - "Extract a table @var{tag} from @var{font}. Return empty string" - " for non-existent @var{tag}.") + (SCM font, SCM tag), + "Extract a table @var{tag} from @var{font}. Return empty string" + " for non-existent @var{tag}.") { Modified_font_metric *fm = dynamic_cast<Modified_font_metric *> (unsmob_metrics (font)); Open_type_font *otf = fm - ? dynamic_cast<Open_type_font *> (fm->original_font ()) - : dynamic_cast<Open_type_font *> (unsmob_metrics (font)); + ? dynamic_cast<Open_type_font *> (fm->original_font ()) + : dynamic_cast<Open_type_font *> (unsmob_metrics (font)); SCM_ASSERT_TYPE (otf, font, SCM_ARG1, __FUNCTION__, "OpenType font"); LY_ASSERT_TYPE (scm_is_string, tag, 2); @@ -74,27 +74,27 @@ LY_DEFINE (ly_otf_font_table_data, "ly:otf-font-table-data", 2, 0, 0, } LY_DEFINE (ly_otf_font_p, "ly:otf-font?", 1, 0, 0, - (SCM font), - "Is @var{font} an OpenType font?") + (SCM font), + "Is @var{font} an OpenType font?") { Modified_font_metric *fm = dynamic_cast<Modified_font_metric *> (unsmob_metrics (font)); Open_type_font *otf = fm - ? dynamic_cast<Open_type_font *> (fm->original_font ()) - : dynamic_cast<Open_type_font *> (unsmob_metrics (font)); + ? dynamic_cast<Open_type_font *> (fm->original_font ()) + : dynamic_cast<Open_type_font *> (unsmob_metrics (font)); return scm_from_bool (otf); } LY_DEFINE (ly_otf_glyph_count, "ly:otf-glyph-count", 1, 0, 0, - (SCM font), - "Return the number of glyphs in @var{font}.") + (SCM font), + "Return the number of glyphs in @var{font}.") { Modified_font_metric *fm = dynamic_cast<Modified_font_metric *> (unsmob_metrics (font)); Open_type_font *otf = fm - ? dynamic_cast<Open_type_font *> (fm->original_font ()) - : dynamic_cast<Open_type_font *> (unsmob_metrics (font)); + ? dynamic_cast<Open_type_font *> (fm->original_font ()) + : dynamic_cast<Open_type_font *> (unsmob_metrics (font)); SCM_ASSERT_TYPE (otf, font, SCM_ARG1, __FUNCTION__, "OpenType font"); @@ -102,14 +102,14 @@ LY_DEFINE (ly_otf_glyph_count, "ly:otf-glyph-count", 1, 0, 0, } LY_DEFINE (ly_otf_glyph_list, "ly:otf-glyph-list", 1, 0, 0, - (SCM font), - "Return a list of glyph names for @var{font}.") + (SCM font), + "Return a list of glyph names for @var{font}.") { Modified_font_metric *fm = dynamic_cast<Modified_font_metric *> (unsmob_metrics (font)); Open_type_font *otf = fm - ? dynamic_cast<Open_type_font *> (fm->original_font ()) - : dynamic_cast<Open_type_font *> (unsmob_metrics (font)); + ? dynamic_cast<Open_type_font *> (fm->original_font ()) + : dynamic_cast<Open_type_font *> (unsmob_metrics (font)); SCM_ASSERT_TYPE (otf, font, SCM_ARG1, __FUNCTION__, "OpenType font"); diff --git a/lily/open-type-font.cc b/lily/open-type-font.cc index 50c89a4065..05bb5edb15 100644 --- a/lily/open-type-font.cc +++ b/lily/open-type-font.cc @@ -41,18 +41,18 @@ load_table (char const *tag_str, FT_Face face, FT_ULong *length) { FT_Byte *buffer = (FT_Byte *) malloc (*length); if (buffer == NULL) - error (_f ("cannot allocate %lu bytes", *length)); + error (_f ("cannot allocate %lu bytes", *length)); error_code = FT_Load_Sfnt_Table (face, tag, 0, buffer, length); if (error_code) - error (_f ("cannot load font table: %s", tag_str)); + error (_f ("cannot load font table: %s", tag_str)); return buffer; } else programming_error (_f ("FreeType error: %s", - freetype_error_string (error_code).c_str () - )); + freetype_error_string (error_code).c_str () + )); return 0; } @@ -72,7 +72,7 @@ load_scheme_table (char const *tag_str, FT_Face face) SCM tab = SCM_EOL; if (buffer) { - string contents ((char const*)buffer, length); + string contents ((char const *)buffer, length); contents = "(quote (" + contents + "))"; tab = scm_c_eval_string (contents.c_str ()); @@ -81,7 +81,6 @@ load_scheme_table (char const *tag_str, FT_Face face) return tab; } - Open_type_font::~Open_type_font () { FT_Done_Face (face_); @@ -95,7 +94,7 @@ get_otf_table (FT_Face face, string tag) { FT_ULong len; FT_Byte *tab = load_table (tag.c_str (), face, &len); - string ret ((char const*) tab, len); + string ret ((char const *) tab, len); free (tab); return ret; @@ -110,9 +109,9 @@ open_ft_face (string str, FT_Long idx) if (error_code == FT_Err_Unknown_File_Format) error (_f ("unsupported font format: %s", str.c_str ())); else if (error_code) - error (_f ("error reading font file %s: %s", - str.c_str (), - freetype_error_string (error_code).c_str ())); + error (_f ("error reading font file %s: %s", + str.c_str (), + freetype_error_string (error_code).c_str ())); return face; } @@ -172,10 +171,10 @@ Open_type_font::get_indexed_char_dimensions (size_t signed_idx) const if (SCM_HASHTABLE_P (lily_index_to_bbox_table_)) { SCM box = scm_hashq_ref (lily_index_to_bbox_table_, - scm_from_unsigned_integer (signed_idx), SCM_BOOL_F); + scm_from_unsigned_integer (signed_idx), SCM_BOOL_F); Box *box_ptr = Box::unsmob (box); if (box_ptr) - return *box_ptr; + return *box_ptr; } if (SCM_HASHTABLE_P (lily_character_table_)) @@ -183,35 +182,35 @@ Open_type_font::get_indexed_char_dimensions (size_t signed_idx) const const size_t len = 256; char name[len]; FT_Error code = FT_Get_Glyph_Name (face_, FT_UInt (signed_idx), - name, FT_UInt (len)); + name, FT_UInt (len)); if (code) - warning (_f ("FT_Get_Glyph_Name () Freetype error: %s", - freetype_error_string (code))); + warning (_f ("FT_Get_Glyph_Name () Freetype error: %s", + freetype_error_string (code))); SCM sym = ly_symbol2scm (name); SCM alist = scm_hashq_ref (lily_character_table_, sym, SCM_BOOL_F); if (alist != SCM_BOOL_F) - { - SCM bbox = scm_cdr (scm_assq (ly_symbol2scm ("bbox"), alist)); - - Box b; - b[X_AXIS][LEFT] = scm_to_double (scm_car (bbox)); - bbox = scm_cdr (bbox); - b[Y_AXIS][LEFT] = scm_to_double (scm_car (bbox)); - bbox = scm_cdr (bbox); - b[X_AXIS][RIGHT] = scm_to_double (scm_car (bbox)); - bbox = scm_cdr (bbox); - b[Y_AXIS][RIGHT] = scm_to_double (scm_car (bbox)); - bbox = scm_cdr (bbox); - - b.scale (point_constant); - - scm_hashq_set_x (lily_index_to_bbox_table_, - scm_from_unsigned_integer (signed_idx), - b.smobbed_copy ()); - return b; - } + { + SCM bbox = scm_cdr (scm_assq (ly_symbol2scm ("bbox"), alist)); + + Box b; + b[X_AXIS][LEFT] = scm_to_double (scm_car (bbox)); + bbox = scm_cdr (bbox); + b[Y_AXIS][LEFT] = scm_to_double (scm_car (bbox)); + bbox = scm_cdr (bbox); + b[X_AXIS][RIGHT] = scm_to_double (scm_car (bbox)); + bbox = scm_cdr (bbox); + b[Y_AXIS][RIGHT] = scm_to_double (scm_car (bbox)); + bbox = scm_cdr (bbox); + + b.scale (point_constant); + + scm_hashq_set_x (lily_index_to_bbox_table_, + scm_from_unsigned_integer (signed_idx), + b.smobbed_copy ()); + return b; + } } FT_UInt idx = FT_UInt (signed_idx); @@ -221,7 +220,7 @@ Open_type_font::get_indexed_char_dimensions (size_t signed_idx) const FT_Pos hb = m.horiBearingX; FT_Pos vb = m.horiBearingY; Box b (Interval (Real (-hb), Real (m.width - hb)), - Interval (Real (-vb), Real (m.height - vb))); + Interval (Real (-vb), Real (m.height - vb))); b.scale (design_size () / Real (face_->units_per_EM)); return b; @@ -233,8 +232,8 @@ Open_type_font::name_to_index (string nm) const char *nm_str = (char *) nm.c_str (); if (FT_UInt idx = FT_Get_Name_Index (face_, nm_str)) return (size_t) idx; - - return (size_t) -1; + + return (size_t) - 1; } size_t @@ -262,15 +261,15 @@ Real Open_type_font::design_size () const { SCM entry = scm_hashq_ref (lily_global_table_, - ly_symbol2scm ("design_size"), - - /* - Hmm. Design size is arbitrary for - non-design-size fonts. I vote for 1 - - which will trip errors more - quickly. --hwn. - */ - scm_from_unsigned_integer (1)); + ly_symbol2scm ("design_size"), + + /* + Hmm. Design size is arbitrary for + non-design-size fonts. I vote for 1 - + which will trip errors more + quickly. --hwn. + */ + scm_from_unsigned_integer (1)); return scm_to_double (entry) * Real (point_constant); } @@ -309,19 +308,19 @@ Open_type_font::glyph_list () const { SCM retval = SCM_EOL; SCM *tail = &retval; - + for (int i = 0; i < face_->num_glyphs; i++) { const size_t len = 256; char name[len]; FT_Error code = FT_Get_Glyph_Name (face_, i, name, len); if (code) - warning (_f ("FT_Get_Glyph_Name () error: %s", - freetype_error_string (code).c_str ())); + warning (_f ("FT_Get_Glyph_Name () error: %s", + freetype_error_string (code).c_str ())); *tail = scm_cons (scm_from_locale_string (name), SCM_EOL); tail = SCM_CDRLOC (*tail); } - + return retval; } diff --git a/lily/optimal-page-breaking.cc b/lily/optimal-page-breaking.cc index e404711b4b..275adaeb4e 100644 --- a/lily/optimal-page-breaking.cc +++ b/lily/optimal-page-breaking.cc @@ -55,49 +55,49 @@ Optimal_page_breaking::solve () // Note that system_count () only counts non-title systems. vsize ideal_sys_count = system_count (); - + if (!scm_is_integer (forced_page_count)) { /* find out the ideal number of pages */ message (_ ("Finding the ideal number of pages...")); - + best = space_systems_on_best_pages (0, first_page_num); page_count = best.systems_per_page_.size (); min_sys_count = ideal_sys_count - best.systems_per_page_.back (); - + if (page_count > 1 && best.systems_per_page_[page_count - 2] > 1) - min_sys_count -= best.systems_per_page_[page_count - 2]; + min_sys_count -= best.systems_per_page_[page_count - 2]; min_sys_count = max (min_sys_count, (vsize)1); } else { /* If systems-per-page and page-count are both specified, we know exactly - how many systems should be present. */ + how many systems should be present. */ if (systems_per_page () > 0) - { - ideal_sys_count = systems_per_page () * page_count; - - if (ideal_sys_count > max_system_count (0, end) - || ideal_sys_count < min_system_count (0, end)) - { - warning (_ ("could not satisfy systems-per-page and page-count at the same time, ignoring systems-per-page")); - ideal_sys_count = system_count (); - min_sys_count = page_count; - } - else - { - set_current_breakpoints (0, end, ideal_sys_count); - min_sys_count = max_sys_count = ideal_sys_count; - ideal_line_division = best_division = current_configuration (0); - } - } + { + ideal_sys_count = systems_per_page () * page_count; + + if (ideal_sys_count > max_system_count (0, end) + || ideal_sys_count < min_system_count (0, end)) + { + warning (_ ("could not satisfy systems-per-page and page-count at the same time, ignoring systems-per-page")); + ideal_sys_count = system_count (); + min_sys_count = page_count; + } + else + { + set_current_breakpoints (0, end, ideal_sys_count); + min_sys_count = max_sys_count = ideal_sys_count; + ideal_line_division = best_division = current_configuration (0); + } + } else - min_sys_count = page_count; + min_sys_count = page_count; /* TODO: the following line will spit out programming errors if the - ideal line spacing doesn't fit on PAGE_COUNT pages */ + ideal line spacing doesn't fit on PAGE_COUNT pages */ best = space_systems_on_n_pages (0, page_count, first_page_num); } @@ -106,7 +106,7 @@ Optimal_page_breaking::solve () else if (scm_is_integer (forced_page_count)) message (_f ("Fitting music on %d pages...", (int)page_count)); else - message (_f ("Fitting music on %d or %d pages...", (int)page_count-1, (int)page_count)); + message (_f ("Fitting music on %d or %d pages...", (int)page_count - 1, (int)page_count)); /* try a smaller number of systems than the ideal number for line breaking */ Line_division bound = ideal_line_division; @@ -116,93 +116,93 @@ Optimal_page_breaking::solve () set_current_breakpoints (0, end, sys_count, Line_division (), bound); if (debug_page_breaking_scoring) - message (_f ("trying %d systems", (int)sys_count)); + message (_f ("trying %d systems", (int)sys_count)); for (vsize i = 0; i < current_configuration_count (); i++) - { - Page_spacing_result cur; + { + Page_spacing_result cur; - if (scm_is_integer (forced_page_count)) - cur = space_systems_on_n_pages (i, page_count, first_page_num); - else - cur = space_systems_on_best_pages (i, first_page_num); + if (scm_is_integer (forced_page_count)) + cur = space_systems_on_n_pages (i, page_count, first_page_num); + else + cur = space_systems_on_best_pages (i, first_page_num); - if (cur.demerits_ < best_for_this_sys_count.demerits_) - { - best_for_this_sys_count = cur; - bound = current_configuration (i); - } - } + if (cur.demerits_ < best_for_this_sys_count.demerits_) + { + best_for_this_sys_count = cur; + bound = current_configuration (i); + } + } if (debug_page_breaking_scoring) - message (_f ("best score for this sys-count: %f", best_for_this_sys_count.demerits_)); + message (_f ("best score for this sys-count: %f", best_for_this_sys_count.demerits_)); if (best_for_this_sys_count.demerits_ < best.demerits_) - { - best = best_for_this_sys_count; - best_division = bound; - } + { + best = best_for_this_sys_count; + best_division = bound; + } /* Check to see if we already have too few systems. There are two ways - we check this: if we are trying one less than the ideal number of pages - and the pages are stretched on average then we have too - few systems. If the spacing is worse than BAD_SPACING_PENALTY, then we - have too few systems. In either case, though, we need to continue reducing - the number of systems if max-systems-per-page requires it. */ + we check this: if we are trying one less than the ideal number of pages + and the pages are stretched on average then we have too + few systems. If the spacing is worse than BAD_SPACING_PENALTY, then we + have too few systems. In either case, though, we need to continue reducing + the number of systems if max-systems-per-page requires it. */ if (!(best.system_count_status_ & SYSTEM_COUNT_TOO_MANY)) - { - if (best_for_this_sys_count.page_count () < page_count - && best_for_this_sys_count.average_force () > 0) - break; - - if (best_for_this_sys_count.demerits_ >= BAD_SPACING_PENALTY) - break; - } + { + if (best_for_this_sys_count.page_count () < page_count + && best_for_this_sys_count.average_force () > 0) + break; + + if (best_for_this_sys_count.demerits_ >= BAD_SPACING_PENALTY) + break; + } } /* try a larger number of systems than the ideal line breaking number. This is more or less C&P, but the loop bounds make it difficult to try something like do {...} while (flip(&d) != UP). */ bound = ideal_line_division; - for (vsize sys_count = ideal_sys_count+1; sys_count <= max_sys_count; sys_count++) + for (vsize sys_count = ideal_sys_count + 1; sys_count <= max_sys_count; sys_count++) { Real best_demerits_for_this_sys_count = infinity_f; set_current_breakpoints (0, end, sys_count, bound); if (debug_page_breaking_scoring) - message (_f ("trying %d systems", (int)sys_count)); + message (_f ("trying %d systems", (int)sys_count)); for (vsize i = 0; i < current_configuration_count (); i++) - { - vsize min_p_count = min_page_count (i, first_page_num); - Page_spacing_result cur; - - if (min_p_count > page_count) - continue; - else if (scm_is_integer (forced_page_count)) - cur = space_systems_on_n_pages (i, page_count, first_page_num); - else - cur = space_systems_on_best_pages (i, first_page_num); - - if (cur.demerits_ < best.demerits_) - { - best = cur; - best_division = current_configuration (i); - } - - if (cur.demerits_ < best_demerits_for_this_sys_count) - { - best_demerits_for_this_sys_count = cur.demerits_; - bound = current_configuration (i); - } - } + { + vsize min_p_count = min_page_count (i, first_page_num); + Page_spacing_result cur; + + if (min_p_count > page_count) + continue; + else if (scm_is_integer (forced_page_count)) + cur = space_systems_on_n_pages (i, page_count, first_page_num); + else + cur = space_systems_on_best_pages (i, first_page_num); + + if (cur.demerits_ < best.demerits_) + { + best = cur; + best_division = current_configuration (i); + } + + if (cur.demerits_ < best_demerits_for_this_sys_count) + { + best_demerits_for_this_sys_count = cur.demerits_; + bound = current_configuration (i); + } + } if (debug_page_breaking_scoring) - message (_f ("best score for this sys-count: %f", best_demerits_for_this_sys_count)); + message (_f ("best score for this sys-count: %f", best_demerits_for_this_sys_count)); if (best_demerits_for_this_sys_count >= BAD_SPACING_PENALTY - && !(best.system_count_status_ & SYSTEM_COUNT_TOO_FEW)) - break; + && !(best.system_count_status_ & SYSTEM_COUNT_TOO_FEW)) + break; } message (_ ("Drawing systems...")); diff --git a/lily/ottava-bracket.cc b/lily/ottava-bracket.cc index 1fa77ec799..3aced1d37f 100644 --- a/lily/ottava-bracket.cc +++ b/lily/ottava-bracket.cc @@ -62,17 +62,17 @@ Ottava_bracket::print (SCM smob) broken[d] = (b->break_status_dir () != CENTER); if (Note_column::has_interface (b)) - { - extract_grob_set (b, "note-heads", heads); - common = common_refpoint_of_array (heads, common, X_AXIS); - for (vsize i = 0; i < heads.size (); i++) - { - Grob *h = heads[i]; - Grob *dots = Rhythmic_head::get_dots (h); - if (dots) - common = dots->common_refpoint (common, X_AXIS); - } - } + { + extract_grob_set (b, "note-heads", heads); + common = common_refpoint_of_array (heads, common, X_AXIS); + for (vsize i = 0; i < heads.size (); i++) + { + Grob *h = heads[i]; + Grob *dots = Rhythmic_head::get_dots (h); + if (dots) + common = dots->common_refpoint (common, X_AXIS); + } + } } while (flip (&d) != LEFT); @@ -81,10 +81,10 @@ Ottava_bracket::print (SCM smob) Stencil text; if (Text_interface::is_markup (markup)) text = *unsmob_stencil (Text_interface::interpret_markup (layout->self_scm (), - properties, markup)); + properties, markup)); Drul_array<Real> shorten = robust_scm2interval (me->get_property ("shorten-pair"), - Interval (0, 0)); + Interval (0, 0)); /* TODO: we should check if there are ledgers, and modify length of @@ -96,30 +96,30 @@ Ottava_bracket::print (SCM smob) Interval ext; if (Note_column::has_interface (b)) - { - extract_grob_set (b, "note-heads", heads); - for (vsize i = 0; i < heads.size (); i++) - { - Grob *h = heads[i]; - ext.unite (h->extent (common, X_AXIS)); - Grob *dots = Rhythmic_head::get_dots (h); - - if (dots && d == RIGHT) - ext.unite (dots->extent (common, X_AXIS)); - } - } + { + extract_grob_set (b, "note-heads", heads); + for (vsize i = 0; i < heads.size (); i++) + { + Grob *h = heads[i]; + ext.unite (h->extent (common, X_AXIS)); + Grob *dots = Rhythmic_head::get_dots (h); + + if (dots && d == RIGHT) + ext.unite (dots->extent (common, X_AXIS)); + } + } if (ext.is_empty ()) - ext = robust_relative_extent (b, common, X_AXIS); + ext = robust_relative_extent (b, common, X_AXIS); if (broken[d]) - { - span_points[d] = b->extent (common, X_AXIS)[RIGHT]; - shorten[d] = 0.; - } + { + span_points[d] = b->extent (common, X_AXIS)[RIGHT]; + shorten[d] = 0.; + } else - span_points[d] = ext[d]; + span_points[d] = ext[d]; } while (flip (&d) != LEFT); @@ -127,38 +127,38 @@ Ottava_bracket::print (SCM smob) 0.3 is ~ italic correction. */ Real text_size = text.extent (X_AXIS).is_empty () - ? 0.0 : text.extent (X_AXIS)[RIGHT] + 0.3; + ? 0.0 : text.extent (X_AXIS)[RIGHT] + 0.3; span_points[LEFT] = min (span_points[LEFT], - (span_points[RIGHT] - text_size - - robust_scm2double (me->get_property ("minimum-length"), -1.0))); + (span_points[RIGHT] - text_size + - robust_scm2double (me->get_property ("minimum-length"), -1.0))); Interval bracket_span_points = span_points; bracket_span_points[LEFT] += text_size; Drul_array<Real> edge_height = robust_scm2interval (me->get_property ("edge-height"), - Interval (1.0, 1.0)); + Interval (1.0, 1.0)); Drul_array<Real> flare = robust_scm2interval (me->get_property ("bracket-flare"), - Interval (0, 0)); + Interval (0, 0)); do { edge_height[d] *= -get_grob_direction (me); if (broken[d]) - edge_height[d] = 0.0; + edge_height[d] = 0.0; } - while (flip(&d) != LEFT); + while (flip (&d) != LEFT); Stencil b; Interval empty; if (!bracket_span_points.is_empty () && bracket_span_points.length () > 0.001) b = Tuplet_bracket::make_bracket (me, - Y_AXIS, Offset (bracket_span_points.length (), 0), - edge_height, - empty, - flare, shorten); + Y_AXIS, Offset (bracket_span_points.length (), 0), + edge_height, + empty, + flare, shorten); /* The vertical lines should not take space, for the following scenario: @@ -176,8 +176,8 @@ Ottava_bracket::print (SCM smob) */ b = Stencil (Box (b.extent (X_AXIS), - Interval (0.1, 0.1)), - b.expr ()); + Interval (0.1, 0.1)), + b.expr ()); b.translate_axis (bracket_span_points[LEFT], X_AXIS); text.translate_axis (span_points[LEFT], X_AXIS); @@ -190,12 +190,12 @@ Ottava_bracket::print (SCM smob) } ADD_INTERFACE (Ottava_bracket, - "An ottava bracket.", - - /* properties */ - "edge-height " - "bracket-flare " - "shorten-pair " - "minimum-length " - ); + "An ottava bracket.", + + /* properties */ + "edge-height " + "bracket-flare " + "shorten-pair " + "minimum-length " + ); diff --git a/lily/ottava-engraver.cc b/lily/ottava-engraver.cc index fd59b33b8e..fb72fdf80f 100644 --- a/lily/ottava-engraver.cc +++ b/lily/ottava-engraver.cc @@ -25,7 +25,6 @@ #include "spanner.hh" #include "text-interface.hh" - class Ottava_spanner_engraver : public Engraver { public: @@ -69,14 +68,14 @@ Ottava_spanner_engraver::process_music () finished_ = span_; span_ = 0; if (Text_interface::is_markup (ott)) - { - span_ = make_spanner ("OttavaBracket", SCM_EOL); - span_->set_property ("text", ott); - - SCM offset (get_property ("middleCOffset")); - if (robust_scm2double (offset, 0) > 0) - span_->set_property ("direction", scm_from_int (DOWN)); - } + { + span_ = make_spanner ("OttavaBracket", SCM_EOL); + span_->set_property ("text", ott); + + SCM offset (get_property ("middleCOffset")); + if (robust_scm2double (offset, 0) > 0) + span_->set_property ("direction", scm_from_int (DOWN)); + } } last_ottavation_ = ott; } @@ -90,7 +89,7 @@ Ottava_spanner_engraver::acknowledge_note_column (Grob_info info) Side_position_interface::add_support (span_, it); if (!span_->get_bound (LEFT)) - span_->set_bound (LEFT, it); + span_->set_bound (LEFT, it); span_->set_bound (RIGHT, it); } } @@ -102,13 +101,13 @@ Ottava_spanner_engraver::typeset_all () { Direction d = LEFT; do - { - if (!finished_->get_bound (RIGHT)) - { - Grob *e = unsmob_grob (get_property ("currentMusicalColumn")); - finished_->set_bound (d, e); - } - } + { + if (!finished_->get_bound (RIGHT)) + { + Grob *e = unsmob_grob (get_property ("currentMusicalColumn")); + finished_->set_bound (d, e); + } + } while (flip (&d) != LEFT); finished_ = 0; @@ -142,17 +141,17 @@ Ottava_spanner_engraver::finalize () ADD_ACKNOWLEDGER (Ottava_spanner_engraver, note_column); ADD_TRANSLATOR (Ottava_spanner_engraver, - /* doc */ - "Create a text spanner when the ottavation property changes.", - - /* create */ - "OttavaBracket ", - - /* read */ - "middleCOffset " - "ottavation " - "currentMusicalColumn ", - - /* write */ - "" - ); + /* doc */ + "Create a text spanner when the ottavation property changes.", + + /* create */ + "OttavaBracket ", + + /* read */ + "middleCOffset " + "ottavation " + "currentMusicalColumn ", + + /* write */ + "" + ); diff --git a/lily/page-breaking-scheme.cc b/lily/page-breaking-scheme.cc index 653815dd30..93ac8954de 100644 --- a/lily/page-breaking-scheme.cc +++ b/lily/page-breaking-scheme.cc @@ -23,30 +23,30 @@ #include "minimal-page-breaking.hh" LY_DEFINE (ly_page_turn_breaking, "ly:page-turn-breaking", - 1, 0, 0, (SCM pb), - "Optimally break (pages and lines) the @code{Paper_book} object" - " @var{pb} such that page turns only happen in specified places," - " returning its pages.") + 1, 0, 0, (SCM pb), + "Optimally break (pages and lines) the @code{Paper_book} object" + " @var{pb} such that page turns only happen in specified places," + " returning its pages.") { Page_turn_page_breaking b (unsmob_paper_book (pb)); return b.solve (); } LY_DEFINE (ly_optimal_breaking, "ly:optimal-breaking", - 1, 0, 0, (SCM pb), - "Optimally break (pages and lines) the @code{Paper_book} object" - " @var{pb} to minimize badness in bother vertical and horizontal" - " spacing.") + 1, 0, 0, (SCM pb), + "Optimally break (pages and lines) the @code{Paper_book} object" + " @var{pb} to minimize badness in bother vertical and horizontal" + " spacing.") { Optimal_page_breaking b (unsmob_paper_book (pb)); return b.solve (); } LY_DEFINE (ly_minimal_breaking, "ly:minimal-breaking", - 1, 0, 0, (SCM pb), - "Break (pages and lines) the @code{Paper_book} object @var{pb}" - " without looking for optimal spacing: stack as many lines on" - " a page before moving to the next one.") + 1, 0, 0, (SCM pb), + "Break (pages and lines) the @code{Paper_book} object @var{pb}" + " without looking for optimal spacing: stack as many lines on" + " a page before moving to the next one.") { Minimal_page_breaking b (unsmob_paper_book (pb)); return b.solve (); diff --git a/lily/page-breaking.cc b/lily/page-breaking.cc index 5d55c7a9f4..2e5854885e 100644 --- a/lily/page-breaking.cc +++ b/lily/page-breaking.cc @@ -152,47 +152,47 @@ compress_lines (const vector<Line_details> &orig) for (vsize i = 0; i < orig.size (); i++) { if (ret.size () && !scm_is_symbol (ret.back ().page_permission_)) - { - Line_details const &old = ret.back (); - Line_details compressed = orig[i]; - /* - We must account for the padding between the lines that we are compressing. - The padding values come from "old," which is the upper system here. Note - the meaning of tight-spacing: if a system has tight-spacing, then the padding - _before_ it is ignored. - */ - Real padding = 0; - if (!orig[i].tight_spacing_) - padding = orig[i].title_ ? old.title_padding_ : old.padding_; - - // FIXME: double check these. Doesn't foo.piggyback (bar) mean - // that foo goes on top? - // TODO: break out a Line_details::piggyback from here? - compressed.shape_ = old.shape_.piggyback (orig[i].shape_, padding); - compressed.refpoint_extent_[UP] = old.refpoint_extent_[UP]; - compressed.refpoint_extent_[DOWN] += compressed.shape_.rest_[UP] - old.shape_.rest_[UP]; - compressed.space_ += old.space_; - compressed.inverse_hooke_ += old.inverse_hooke_; - - compressed.compressed_lines_count_ = old.compressed_lines_count_ + 1; - compressed.compressed_nontitle_lines_count_ = - old.compressed_nontitle_lines_count_ + (compressed.title_ ? 0 : 1); - - // compressed.title_ is true if and only if the first of its - // compressed lines was a title. + { + Line_details const &old = ret.back (); + Line_details compressed = orig[i]; + /* + We must account for the padding between the lines that we are compressing. + The padding values come from "old," which is the upper system here. Note + the meaning of tight-spacing: if a system has tight-spacing, then the padding + _before_ it is ignored. + */ + Real padding = 0; + if (!orig[i].tight_spacing_) + padding = orig[i].title_ ? old.title_padding_ : old.padding_; + + // FIXME: double check these. Doesn't foo.piggyback (bar) mean + // that foo goes on top? + // TODO: break out a Line_details::piggyback from here? + compressed.shape_ = old.shape_.piggyback (orig[i].shape_, padding); + compressed.refpoint_extent_[UP] = old.refpoint_extent_[UP]; + compressed.refpoint_extent_[DOWN] += compressed.shape_.rest_[UP] - old.shape_.rest_[UP]; + compressed.space_ += old.space_; + compressed.inverse_hooke_ += old.inverse_hooke_; + + compressed.compressed_lines_count_ = old.compressed_lines_count_ + 1; + compressed.compressed_nontitle_lines_count_ + = old.compressed_nontitle_lines_count_ + (compressed.title_ ? 0 : 1); + + // compressed.title_ is true if and only if the first of its + // compressed lines was a title. compressed.title_ = old.title_; // adds footnotes of one line to the footnotes of another compressed.footnotes_.insert (compressed.footnotes_.begin (), - old.footnotes_.begin (), old.footnotes_.end ()); - - ret.back () = compressed; - } + old.footnotes_.begin (), old.footnotes_.end ()); + + ret.back () = compressed; + } else - { - ret.push_back (orig[i]); - ret.back ().force_ = 0; - } + { + ret.push_back (orig[i]); + ret.back ().force_ = 0; + } } return ret; } @@ -202,7 +202,7 @@ compress_lines (const vector<Line_details> &orig) */ static vector<vsize> uncompress_solution (vector<vsize> const &systems_per_page, - vector<Line_details> const &compressed) + vector<Line_details> const &compressed) { vector<vsize> ret; vsize start_sys = 0; @@ -211,7 +211,7 @@ uncompress_solution (vector<vsize> const &systems_per_page, { int compressed_count = 0; for (vsize j = start_sys; j < start_sys + systems_per_page[i]; j++) - compressed_count += compressed[j].compressed_lines_count_ - 1; + compressed_count += compressed[j].compressed_lines_count_ - 1; ret.push_back (systems_per_page[i] + compressed_count); start_sys += systems_per_page[i]; @@ -268,7 +268,7 @@ Page_breaking::Page_breaking (Paper_book *pb, Break_predicate is_break, Prob_bre footnote_number_raise_ = (to_boolean (pb->paper_->c_variable ("footnote-auto-numbering")) ? robust_scm2double (pb->paper_->c_variable ("footnote-number-raise"), 0.0) : 0.0); - + if (systems_per_page_ && (max_systems_per_page_ || min_systems_per_page_)) { warning (_f ("ignoring min-systems-per-page and max-systems-per-page because systems-per-page was set")); @@ -389,10 +389,10 @@ Page_breaking::line_count_status (int line_count) const /* translate indices into breaks_ into start-end parameters for the line breaker */ void Page_breaking::line_breaker_args (vsize sys, - Break_position const &start, - Break_position const &end, - vsize *line_breaker_start, - vsize *line_breaker_end) + Break_position const &start, + Break_position const &end, + vsize *line_breaker_start, + vsize *line_breaker_end) { assert (system_specs_[sys].pscore_); assert (next_system (start) <= sys && sys <= end.system_spec_index_); @@ -410,7 +410,7 @@ Page_breaking::line_breaker_args (vsize sys, void Page_breaking::break_into_pieces (vsize start_break, vsize end_break, - Line_division const &div) + Line_division const &div) { vector<Break_position> chunks = chunk_list (start_break, end_break); bool ignore_div = false; @@ -424,16 +424,16 @@ Page_breaking::break_into_pieces (vsize start_break, vsize end_break, { vsize sys = next_system (chunks[i]); if (system_specs_[sys].pscore_) - { - vsize start; - vsize end; - line_breaker_args (sys, chunks[i], chunks[i+1], &start, &end); - - vector<Column_x_positions> pos = ignore_div - ? line_breaking_[sys].best_solution (start, end) - : line_breaking_[sys].solve (start, end, div[i]); - system_specs_[sys].pscore_->root_system ()->break_into_pieces (pos); - } + { + vsize start; + vsize end; + line_breaker_args (sys, chunks[i], chunks[i + 1], &start, &end); + + vector<Column_x_positions> pos = ignore_div + ? line_breaking_[sys].best_solution (start, end) + : line_breaking_[sys].solve (start, end, div[i]); + system_specs_[sys].pscore_->root_system ()->break_into_pieces (pos); + } } } @@ -444,18 +444,18 @@ Page_breaking::systems () for (vsize sys = 0; sys < system_specs_.size (); sys++) { if (system_specs_[sys].pscore_) - { - system_specs_[sys].pscore_->root_system () - ->do_break_substitution_and_fixup_refpoints (); - SCM lines = system_specs_[sys].pscore_->root_system () - ->get_broken_system_grobs (); - ret = scm_cons (lines, ret); - } + { + system_specs_[sys].pscore_->root_system () + ->do_break_substitution_and_fixup_refpoints (); + SCM lines = system_specs_[sys].pscore_->root_system () + ->get_broken_system_grobs (); + ret = scm_cons (lines, ret); + } else if (Prob *pb = system_specs_[sys].prob_) - { - ret = scm_cons (scm_list_1 (pb->self_scm ()), ret); - pb->unprotect (); - } + { + ret = scm_cons (scm_list_1 (pb->self_scm ()), ret); + pb->unprotect (); + } } return scm_append (scm_reverse (ret)); } @@ -470,11 +470,11 @@ Page_breaking::make_page (int page_num, bool last) const make_page_scm = scm_variable_ref (make_page_scm); return scm_apply_0 (make_page_scm, - scm_list_n (book_->self_scm (), - ly_symbol2scm ("page-number"), scm_from_int (page_num), - ly_symbol2scm ("is-last-bookpart"), scm_from_bool (last_part), - ly_symbol2scm ("is-bookpart-last-page"), scm_from_bool (last), - SCM_UNDEFINED)); + scm_list_n (book_->self_scm (), + ly_symbol2scm ("page-number"), scm_from_int (page_num), + ly_symbol2scm ("is-last-bookpart"), scm_from_bool (last_part), + ly_symbol2scm ("is-bookpart-last-page"), scm_from_bool (last), + SCM_UNDEFINED)); } // Returns the total height of the paper, including margins and @@ -509,11 +509,11 @@ Page_breaking::page_height (int page_num, bool last) const Real height = scm_to_double (height_scm); if (page_num >= 0) - { - if ((int) cache.size () <= page_num) - cache.resize (page_num + 1, -1); - cache[page_num] = height; - } + { + if ((int) cache.size () <= page_num) + cache.resize (page_num + 1, -1); + cache[page_num] = height; + } return height; } } @@ -547,10 +547,10 @@ Page_breaking::draw_page (SCM systems, SCM configuration, int page_num, int foot { SCM paper_system = scm_car (s); if (Grob *g = unsmob_grob (scm_car (s))) - { - System *sys = dynamic_cast<System*> (g); - paper_system = sys->get_paper_system (); - } + { + System *sys = dynamic_cast<System *> (g); + paper_system = sys->get_paper_system (); + } paper_systems = scm_cons (paper_system, paper_systems); } @@ -572,8 +572,8 @@ Page_breaking::draw_page (SCM systems, SCM configuration, int page_num, int foot : footnote_num); SCM footnotes = Page_layout_problem::get_footnotes_from_lines (systems, - footnote_num, - book_); + footnote_num, + book_); Page_layout_problem::add_footnotes_to_footer (footnotes, foot, book_); @@ -604,7 +604,7 @@ Page_breaking::make_pages (vector<vsize> lines_per_page, SCM systems) // Align_interface::align_to_ideal_distances might be called). SCM systems_configs_fncounts = SCM_EOL; vsize footnote_count = 0; - + for (vsize i = 0; i < lines_per_page.size (); i++) { int page_num = i + first_page_number; @@ -614,7 +614,7 @@ Page_breaking::make_pages (vector<vsize> lines_per_page, SCM systems) SCM lines = scm_list_head (systems, line_count); int fn_lines = Page_layout_problem::get_footnote_count (lines); SCM config = get_page_configuration (lines, page_num, footnote_count, rag, bookpart_last_page); - + systems_configs_fncounts = scm_cons (scm_list_3 (lines, config, scm_from_int ((int)footnote_count)), systems_configs_fncounts); footnote_count += fn_lines; systems = scm_list_tail (systems, line_count); @@ -632,21 +632,21 @@ Page_breaking::make_pages (vector<vsize> lines_per_page, SCM systems) SCM page = draw_page (lines, config, page_num, footnote_num, bookpart_last_page); /* collect labels */ SCM page_num_scm = scm_from_int (page_num); - for (SCM l = lines ; scm_is_pair (l) ; l = scm_cdr (l)) - { - SCM labels = SCM_EOL; - if (Grob * line = unsmob_grob (scm_car (l))) - { - System *system = dynamic_cast<System*> (line); - labels = system->get_property ("labels"); - } - else if (Prob *prob = unsmob_prob (scm_car (l))) - labels = prob->get_property ("labels"); - - for (SCM lbls = labels ; scm_is_pair (lbls) ; lbls = scm_cdr (lbls)) - label_page_table = scm_cons (scm_cons (scm_car (lbls), page_num_scm), - label_page_table); - } + for (SCM l = lines; scm_is_pair (l); l = scm_cdr (l)) + { + SCM labels = SCM_EOL; + if (Grob *line = unsmob_grob (scm_car (l))) + { + System *system = dynamic_cast<System *> (line); + labels = system->get_property ("labels"); + } + else if (Prob *prob = unsmob_prob (scm_car (l))) + labels = prob->get_property ("labels"); + + for (SCM lbls = labels; scm_is_pair (lbls); lbls = scm_cdr (lbls)) + label_page_table = scm_cons (scm_cons (scm_car (lbls), page_num_scm), + label_page_table); + } ret = scm_cons (page, ret); --page_num; @@ -674,10 +674,10 @@ Page_breaking::create_system_list () SCM specs = book_->get_system_specs (); for (SCM s = specs; scm_is_pair (s); s = scm_cdr (s)) { - if (Paper_score *ps = dynamic_cast<Paper_score*> (unsmob_music_output (scm_car (s)))) - { - system_specs_.push_back (System_spec (ps)); - } + if (Paper_score *ps = dynamic_cast<Paper_score *> (unsmob_music_output (scm_car (s)))) + { + system_specs_.push_back (System_spec (ps)); + } else { Prob *pb = unsmob_prob (scm_car (s)); @@ -702,81 +702,81 @@ Page_breaking::find_chunks_and_breaks (Break_predicate is_break, Prob_break_pred for (vsize i = 0; i < system_specs_.size (); i++) { if (system_specs_[i].pscore_) - { - vector<Grob*> cols = system_specs_[i].pscore_->root_system ()->used_columns (); - vector<Grob*> forced_line_break_cols; - - SCM system_count = system_specs_[i].pscore_->layout ()->c_variable ("system-count"); - if (scm_is_number (system_count)) - { - // With system-count given, the line configuration for - // this score is fixed. We need to ensure that chunk - // boundaries only occur at line breaks. - Constrained_breaking breaking (system_specs_[i].pscore_); - vector<Line_details> details = breaking.line_details (0, VPOS, scm_to_int (system_count)); - - for (vsize j = 0; j < details.size (); j++) - forced_line_break_cols.push_back (details[j].last_column_); - } - - int last_forced_line_break_idx = 0; - vsize forced_line_break_idx = 0; - vector<vsize> line_breaker_columns; - line_breaker_columns.push_back (0); - - for (vsize j = 1; j < cols.size (); j++) - { - if (forced_line_break_cols.size ()) - { - if (forced_line_break_idx >= forced_line_break_cols.size () - || forced_line_break_cols[forced_line_break_idx] != cols[j]) - continue; - else - forced_line_break_idx++; - } - - bool last = (j == cols.size () - 1); - bool break_point = is_break && is_break (cols[j]); - bool chunk_end = cols[j]->get_property ("page-break-permission") == force_sym; - Break_position cur_pos = Break_position (i, - line_breaker_columns.size (), - cols[j], - last); - - // NOTE: even in the breaks_ list, forced_line_count_ - // refers to the number of lines between a - // Break_position and the start of that /chunk/. This - // is needed for system_count_bounds to work correctly, - // since it mixes Break_positions from breaks_ and - // chunks_. - if (scm_is_number (system_count)) - cur_pos.forced_line_count_ = forced_line_break_idx - last_forced_line_break_idx; - - if (break_point || (i == system_specs_.size () - 1 && last)) - breaks_.push_back (cur_pos); - if (chunk_end || last) - { - chunks_.push_back (cur_pos); - last_forced_line_break_idx = forced_line_break_idx; - } - - if ((break_point || chunk_end) && !last) - line_breaker_columns.push_back (j); - } - line_breaking_.push_back (Constrained_breaking (system_specs_[i].pscore_, line_breaker_columns)); - } + { + vector<Grob *> cols = system_specs_[i].pscore_->root_system ()->used_columns (); + vector<Grob *> forced_line_break_cols; + + SCM system_count = system_specs_[i].pscore_->layout ()->c_variable ("system-count"); + if (scm_is_number (system_count)) + { + // With system-count given, the line configuration for + // this score is fixed. We need to ensure that chunk + // boundaries only occur at line breaks. + Constrained_breaking breaking (system_specs_[i].pscore_); + vector<Line_details> details = breaking.line_details (0, VPOS, scm_to_int (system_count)); + + for (vsize j = 0; j < details.size (); j++) + forced_line_break_cols.push_back (details[j].last_column_); + } + + int last_forced_line_break_idx = 0; + vsize forced_line_break_idx = 0; + vector<vsize> line_breaker_columns; + line_breaker_columns.push_back (0); + + for (vsize j = 1; j < cols.size (); j++) + { + if (forced_line_break_cols.size ()) + { + if (forced_line_break_idx >= forced_line_break_cols.size () + || forced_line_break_cols[forced_line_break_idx] != cols[j]) + continue; + else + forced_line_break_idx++; + } + + bool last = (j == cols.size () - 1); + bool break_point = is_break && is_break (cols[j]); + bool chunk_end = cols[j]->get_property ("page-break-permission") == force_sym; + Break_position cur_pos = Break_position (i, + line_breaker_columns.size (), + cols[j], + last); + + // NOTE: even in the breaks_ list, forced_line_count_ + // refers to the number of lines between a + // Break_position and the start of that /chunk/. This + // is needed for system_count_bounds to work correctly, + // since it mixes Break_positions from breaks_ and + // chunks_. + if (scm_is_number (system_count)) + cur_pos.forced_line_count_ = forced_line_break_idx - last_forced_line_break_idx; + + if (break_point || (i == system_specs_.size () - 1 && last)) + breaks_.push_back (cur_pos); + if (chunk_end || last) + { + chunks_.push_back (cur_pos); + last_forced_line_break_idx = forced_line_break_idx; + } + + if ((break_point || chunk_end) && !last) + line_breaker_columns.push_back (j); + } + line_breaking_.push_back (Constrained_breaking (system_specs_[i].pscore_, line_breaker_columns)); + } else if (system_specs_[i].prob_) - { - bool break_point = prob_is_break && prob_is_break (system_specs_[i].prob_); - if (break_point || i == system_specs_.size () - 1) - breaks_.push_back (Break_position (i)); + { + bool break_point = prob_is_break && prob_is_break (system_specs_[i].prob_); + if (break_point || i == system_specs_.size () - 1) + breaks_.push_back (Break_position (i)); - chunks_.push_back (Break_position (i)); + chunks_.push_back (Break_position (i)); - /* FIXME: shouldn't we push a Null_breaker or similar dummy - class? --hwn */ - line_breaking_.push_back (Constrained_breaking (NULL)); - } + /* FIXME: shouldn't we push a Null_breaker or similar dummy + class? --hwn */ + line_breaking_.push_back (Constrained_breaking (NULL)); + } } } @@ -829,7 +829,7 @@ Page_breaking::max_system_count (vsize start, vsize end) // per chunk. Page_breaking::Line_division Page_breaking::system_count_bounds (vector<Break_position> const &chunks, - bool min) + bool min) { assert (chunks.size () >= 2); @@ -840,17 +840,17 @@ Page_breaking::system_count_bounds (vector<Break_position> const &chunks, { vsize sys = next_system (chunks[i]); - if (chunks[i+1].forced_line_count_) - ret[i] = chunks[i+1].forced_line_count_; + if (chunks[i + 1].forced_line_count_) + ret[i] = chunks[i + 1].forced_line_count_; else if (system_specs_[sys].pscore_) - { - vsize start; - vsize end; - line_breaker_args (sys, chunks[i], chunks[i+1], &start, &end); - ret[i] = min - ? line_breaking_[sys].min_system_count (start, end) - : line_breaking_[sys].max_system_count (start, end); - } + { + vsize start; + vsize end; + line_breaker_args (sys, chunks[i], chunks[i + 1], &start, &end); + ret[i] = min + ? line_breaking_[sys].min_system_count (start, end) + : line_breaking_[sys].max_system_count (start, end); + } } return ret; @@ -858,10 +858,10 @@ Page_breaking::system_count_bounds (vector<Break_position> const &chunks, void Page_breaking::set_current_breakpoints (vsize start, - vsize end, - vsize system_count, - Line_division lower_bound, - Line_division upper_bound) + vsize end, + vsize system_count, + Line_division lower_bound, + Line_division upper_bound) { system_count_ = system_count; current_chunks_ = chunk_list (start, end); @@ -880,32 +880,32 @@ Page_breaking::set_current_breakpoints (vsize start, Line_division work_in_progress; current_configurations_.clear (); line_divisions_rec (system_count, - lower_bound, - upper_bound, - &work_in_progress); + lower_bound, + upper_bound, + &work_in_progress); /* we only consider a constant number of configurations. Otherwise, this becomes slow when there are many small scores. The constant 5 is somewhat arbitrary. */ if (current_configurations_.size () > 5) { - vector<pair<Real,vsize> > dems_and_indices; + vector<pair<Real, vsize> > dems_and_indices; for (vsize i = 0; i < current_configurations_.size (); i++) - { - cache_line_details (i); - Real dem = 0; - for (vsize j = 0; j < cached_line_details_.size (); j++) - dem += cached_line_details_[j].force_ * cached_line_details_[j].force_ - + cached_line_details_[j].break_penalty_; + { + cache_line_details (i); + Real dem = 0; + for (vsize j = 0; j < cached_line_details_.size (); j++) + dem += cached_line_details_[j].force_ * cached_line_details_[j].force_ + + cached_line_details_[j].break_penalty_; - dems_and_indices.push_back (pair<Real,vsize> (dem, i)); - } - vector_sort (dems_and_indices, less<pair<Real,vsize> > ()); + dems_and_indices.push_back (pair<Real, vsize> (dem, i)); + } + vector_sort (dems_and_indices, less<pair<Real, vsize> > ()); vector<Line_division> best_5_configurations; for (vsize i = 0; i < 5; i++) - best_5_configurations.push_back (current_configurations_[dems_and_indices[i].second]); + best_5_configurations.push_back (current_configurations_[dems_and_indices[i].second]); clear_line_details_cache (); current_configurations_ = best_5_configurations; @@ -922,19 +922,19 @@ Page_breaking::set_to_ideal_line_configuration (vsize start, vsize end) system_count_ = 0; Line_division div; - for (vsize i = 0; i+1 < current_chunks_.size (); i++) + for (vsize i = 0; i + 1 < current_chunks_.size (); i++) { vsize sys = next_system (current_chunks_[i]); - if (current_chunks_[i+1].forced_line_count_) - div.push_back (current_chunks_[i+1].forced_line_count_); + if (current_chunks_[i + 1].forced_line_count_) + div.push_back (current_chunks_[i + 1].forced_line_count_); else if (system_specs_[sys].pscore_) - { - line_breaker_args (sys, current_chunks_[i], current_chunks_[i+1], &start, &end); - div.push_back (line_breaking_[sys].best_solution (start, end).size ()); - } + { + line_breaker_args (sys, current_chunks_[i], current_chunks_[i + 1], &start, &end); + div.push_back (line_breaking_[sys].best_solution (start, end).size ()); + } else - div.push_back (0); + div.push_back (0); system_count_ += div.back (); } @@ -958,25 +958,25 @@ Page_breaking::cache_line_details (vsize configuration_index) Line_division &div = current_configurations_[configuration_index]; uncompressed_line_details_.clear (); for (vsize i = 0; i + 1 < current_chunks_.size (); i++) - { - vsize sys = next_system (current_chunks_[i]); - if (system_specs_[sys].pscore_) - { - vsize start; - vsize end; - line_breaker_args (sys, current_chunks_[i], current_chunks_[i+1], &start, &end); - - vector<Line_details> details = line_breaking_[sys].line_details (start, end, div[i]); - uncompressed_line_details_.insert (uncompressed_line_details_.end (), details.begin (), details.end ()); - } - else - { - assert (div[i] == 0); - uncompressed_line_details_.push_back (system_specs_[sys].prob_ - ? Line_details (system_specs_[sys].prob_, book_->paper_) - : Line_details ()); - } - } + { + vsize sys = next_system (current_chunks_[i]); + if (system_specs_[sys].pscore_) + { + vsize start; + vsize end; + line_breaker_args (sys, current_chunks_[i], current_chunks_[i + 1], &start, &end); + + vector<Line_details> details = line_breaking_[sys].line_details (start, end, div[i]); + uncompressed_line_details_.insert (uncompressed_line_details_.end (), details.begin (), details.end ()); + } + else + { + assert (div[i] == 0); + uncompressed_line_details_.push_back (system_specs_[sys].prob_ + ? Line_details (system_specs_[sys].prob_, book_->paper_) + : Line_details ()); + } + } cached_line_details_ = compress_lines (uncompressed_line_details_); compute_line_heights (); } @@ -992,9 +992,9 @@ Page_breaking::clear_line_details_cache () void Page_breaking::line_divisions_rec (vsize system_count, - Line_division const &min_sys, - Line_division const &max_sys, - Line_division *cur_division) + Line_division const &min_sys, + Line_division const &max_sys, + Line_division *cur_division) { vsize my_index = cur_division->size (); int others_min = 0; @@ -1012,8 +1012,8 @@ Page_breaking::line_divisions_rec (vsize system_count, if (real_min > real_max || real_min < 0) { /* this should never happen within a recursive call. If it happens - at all, it means that we were called with an unsolvable problem - and we should return an empty result */ + at all, it means that we were called with an unsolvable problem + and we should return an empty result */ assert (my_index == 0); return; } @@ -1022,7 +1022,7 @@ Page_breaking::line_divisions_rec (vsize system_count, { cur_division->push_back (i); if (my_index == min_sys.size () - 1) - current_configurations_.push_back (*cur_division); + current_configurations_.push_back (*cur_division); else line_divisions_rec (system_count - i, min_sys, max_sys, cur_division); cur_division->pop_back (); @@ -1042,7 +1042,7 @@ Page_breaking::compute_line_heights () Real prev_refpoint_hanging = 0; for (vsize i = 0; i < cached_line_details_.size (); i++) { - Line_details& cur = cached_line_details_[i]; + Line_details &cur = cached_line_details_[i]; Line_shape shape = cur.shape_; Real a = shape.begin_[UP]; Real b = shape.rest_[UP]; @@ -1050,20 +1050,20 @@ Page_breaking::compute_line_heights () Real refpoint_hanging = max (prev_hanging_begin + a, prev_hanging_rest + b); if (i > 0) - { - Real padding = 0; - Line_details const& prev = cached_line_details_[i-1]; - if (!cur.tight_spacing_) - padding = title - ? prev.title_padding_ - : prev.padding_; - Real min_dist = title - ? prev.title_min_distance_ - : prev.min_distance_; - refpoint_hanging = max (refpoint_hanging + padding, - prev_refpoint_hanging - prev.refpoint_extent_[DOWN] - + cur.refpoint_extent_[UP] + min_dist); - } + { + Real padding = 0; + Line_details const &prev = cached_line_details_[i - 1]; + if (!cur.tight_spacing_) + padding = title + ? prev.title_padding_ + : prev.padding_; + Real min_dist = title + ? prev.title_min_distance_ + : prev.min_distance_; + refpoint_hanging = max (refpoint_hanging + padding, + prev_refpoint_hanging - prev.refpoint_extent_[DOWN] + + cur.refpoint_extent_[UP] + min_dist); + } Real hanging_begin = refpoint_hanging - shape.begin_[DOWN]; Real hanging_rest = refpoint_hanging - shape.rest_[DOWN]; @@ -1094,40 +1094,40 @@ Page_breaking::min_page_count (vsize configuration, vsize first_page_num) for (vsize i = 0; i < cached_line_details_.size (); i++) { Line_details const &cur = cached_line_details_[i]; - Line_details const *const prev = (i > 0) ? &cached_line_details_[i-1] : 0; + Line_details const *const prev = (i > 0) ? &cached_line_details_[i - 1] : 0; Real ext_len; if (cur_rod_height > 0) - ext_len = cur.tallness_; + ext_len = cur.tallness_; else - ext_len = cur.full_height(); + ext_len = cur.full_height (); Real spring_len = (i > 0) ? prev->spring_length (cur) : 0; Real next_rod_height = cur_rod_height + ext_len; Real next_spring_height = cur_spring_height + spring_len; Real next_height = next_rod_height + (ragged () ? next_spring_height : 0) - + min_whitespace_at_bottom_of_page (cur); + + min_whitespace_at_bottom_of_page (cur); int next_line_count = line_count + cur.compressed_nontitle_lines_count_; if ((!too_few_lines (line_count) && (next_height > cur_page_height && cur_rod_height > 0)) - || too_many_lines (next_line_count) - || (prev && prev->page_permission_ == ly_symbol2scm ("force"))) - { - line_count = cur.compressed_nontitle_lines_count_; - cur_rod_height = cur.full_height(); - cur_spring_height = 0; - page_starter = i; - - cur_page_height = page_height (first_page_num + ret, false); - cur_page_height -= min_whitespace_at_top_of_page (cur); - - ret++; - } + || too_many_lines (next_line_count) + || (prev && prev->page_permission_ == ly_symbol2scm ("force"))) + { + line_count = cur.compressed_nontitle_lines_count_; + cur_rod_height = cur.full_height (); + cur_spring_height = 0; + page_starter = i; + + cur_page_height = page_height (first_page_num + ret, false); + cur_page_height -= min_whitespace_at_top_of_page (cur); + + ret++; + } else - { - cur_rod_height = next_rod_height; - cur_spring_height = next_spring_height; - line_count = next_line_count; - } + { + cur_rod_height = next_rod_height; + cur_spring_height = next_spring_height; + line_count = next_line_count; + } } /* there are two potential problems with the last page (because we didn't know @@ -1151,10 +1151,10 @@ Page_breaking::min_page_count (vsize configuration, vsize first_page_num) Real cur_height = cur_rod_height + ((ragged_last () || ragged ()) ? cur_spring_height : 0); if (!too_few_lines (line_count - cached_line_details_.back ().compressed_nontitle_lines_count_) - && cur_height > cur_page_height - /* don't increase the page count if the last page had only one system */ - && cur_rod_height > cached_line_details_.back ().full_height ()) - ret++; + && cur_height > cur_page_height + /* don't increase the page count if the last page had only one system */ + && cur_rod_height > cached_line_details_.back ().full_height ()) + ret++; assert (ret <= cached_line_details_.size ()); } @@ -1178,15 +1178,15 @@ Page_breaking::space_systems_on_n_pages (vsize configuration, vsize n, vsize fir cache_line_details (configuration); bool valid_n = (n >= min_page_count (configuration, first_page_num) - && n <= cached_line_details_.size ()); + && n <= cached_line_details_.size ()); if (!valid_n) programming_error ("number of pages is out of bounds"); if (n == 1 && valid_n) ret = space_systems_on_1_page (cached_line_details_, - page_height (first_page_num, is_last ()), - ragged () || (is_last () && ragged_last ())); + page_height (first_page_num, is_last ()), + ragged () || (is_last () && ragged_last ())); else if (n == 2 && valid_n) ret = space_systems_on_2_pages (configuration, first_page_num); else @@ -1221,7 +1221,7 @@ Page_breaking::blank_page_penalty () const // or N+1 pages; see the comment to space_systems_on_n_pages. Page_spacing_result Page_breaking::space_systems_on_n_or_one_more_pages (vsize configuration, vsize n, vsize first_page_num, - Real penalty_for_fewer_pages) + Real penalty_for_fewer_pages) { Page_spacing_result n_res; Page_spacing_result m_res; @@ -1229,7 +1229,7 @@ Page_breaking::space_systems_on_n_or_one_more_pages (vsize configuration, vsize if (systems_per_page_ > 0) { Page_spacing_result ret = space_systems_with_fixed_number_per_page (configuration, first_page_num); - ret.demerits_ += (ret.force_.size () == n || ret.force_.size () == (n-1)) ? 0 : BAD_SPACING_PENALTY; + ret.demerits_ += (ret.force_.size () == n || ret.force_.size () == (n - 1)) ? 0 : BAD_SPACING_PENALTY; return ret; } @@ -1246,18 +1246,18 @@ Page_breaking::space_systems_on_n_or_one_more_pages (vsize configuration, vsize Real height = page_height (first_page_num, is_last ()); if (1 >= min_p_count) - n_res = space_systems_on_1_page (cached_line_details_, height, rag); + n_res = space_systems_on_1_page (cached_line_details_, height, rag); if (1 < cached_line_details_.size ()) - m_res = space_systems_on_2_pages (configuration, first_page_num); + m_res = space_systems_on_2_pages (configuration, first_page_num); } else { Page_spacer ps (cached_line_details_, first_page_num, this); - + if (n >= min_p_count || !valid_n) - n_res = ps.solve (n); + n_res = ps.solve (n); if (n < cached_line_details_.size () || !valid_n) - m_res = ps.solve (n+1); + m_res = ps.solve (n + 1); } m_res = finalize_spacing_result (configuration, m_res); @@ -1286,7 +1286,7 @@ Page_breaking::space_systems_on_best_pages (vsize configuration, vsize first_pag Page_spacing_result Page_breaking::space_systems_with_fixed_number_per_page (vsize configuration, - vsize first_page_num) + vsize first_page_num) { Page_spacing_result res; Page_spacing space (page_height (first_page_num, false), this); @@ -1303,27 +1303,27 @@ Page_breaking::space_systems_with_fixed_number_per_page (vsize configuration, int system_count_on_this_page = 0; while (system_count_on_this_page < systems_per_page_ - && line < cached_line_details_.size ()) - { - Line_details const &cur_line = cached_line_details_[line]; - space.append_system (cur_line); - system_count_on_this_page += cur_line.compressed_nontitle_lines_count_; - line++; + && line < cached_line_details_.size ()) + { + Line_details const &cur_line = cached_line_details_[line]; + space.append_system (cur_line); + system_count_on_this_page += cur_line.compressed_nontitle_lines_count_; + line++; - if (cur_line.page_permission_ == ly_symbol2scm ("force")) - break; - } + if (cur_line.page_permission_ == ly_symbol2scm ("force")) + break; + } res.systems_per_page_.push_back (line - page_first_line); res.force_.push_back (space.force_); - res.penalty_ += cached_line_details_[line-1].page_penalty_; + res.penalty_ += cached_line_details_[line - 1].page_penalty_; if (system_count_on_this_page != systems_per_page_) - { - res.penalty_ += abs (system_count_on_this_page - systems_per_page_) * TERRIBLE_SPACING_PENALTY; - res.system_count_status_ |= ((system_count_on_this_page < systems_per_page_)) - ? SYSTEM_COUNT_TOO_FEW : SYSTEM_COUNT_TOO_MANY; - } + { + res.penalty_ += abs (system_count_on_this_page - systems_per_page_) * TERRIBLE_SPACING_PENALTY; + res.system_count_status_ |= ((system_count_on_this_page < systems_per_page_)) + ? SYSTEM_COUNT_TOO_FEW : SYSTEM_COUNT_TOO_MANY; + } page_first_line = line; } @@ -1350,47 +1350,47 @@ Page_breaking::pack_systems_on_least_pages (vsize configuration, vsize first_pag Real prev_force = space.force_; space.append_system (cached_line_details_[line]); if ((line > page_first_line) - && (isinf (space.force_) - || ((line > 0) - && (cached_line_details_[line-1].page_permission_ == ly_symbol2scm ("force"))))) - { - res.systems_per_page_.push_back (line - page_first_line); - res.force_.push_back (prev_force); - res.penalty_ += cached_line_details_[line-1].page_penalty_; - page++; - space.resize (page_height (first_page_num + page, false)); - space.clear (); + && (isinf (space.force_) + || ((line > 0) + && (cached_line_details_[line - 1].page_permission_ == ly_symbol2scm ("force"))))) + { + res.systems_per_page_.push_back (line - page_first_line); + res.force_.push_back (prev_force); + res.penalty_ += cached_line_details_[line - 1].page_penalty_; + page++; + space.resize (page_height (first_page_num + page, false)); + space.clear (); space.append_system (cached_line_details_[line]); - page_first_line = line; - } + page_first_line = line; + } if (line == cached_line_details_.size () - 1) - { - /* This is the last line */ - /* When the last page height was computed, we did not know yet that it - * was the last one. If the systems put on it don't fit anymore, the last - * system is moved to a new page */ - space.resize (page_height (first_page_num + page, true)); - if ((line > page_first_line) && (isinf (space.force_))) - { - res.systems_per_page_.push_back (line - page_first_line); - res.force_.push_back (prev_force); - /* the last page containing the last line */ - space.resize (page_height (first_page_num + page + 1, true)); - space.clear (); - space.append_system (cached_line_details_[line]); - res.systems_per_page_.push_back (1); - res.force_.push_back (space.force_); - res.penalty_ += cached_line_details_[line-1].page_penalty_; + { + /* This is the last line */ + /* When the last page height was computed, we did not know yet that it + * was the last one. If the systems put on it don't fit anymore, the last + * system is moved to a new page */ + space.resize (page_height (first_page_num + page, true)); + if ((line > page_first_line) && (isinf (space.force_))) + { + res.systems_per_page_.push_back (line - page_first_line); + res.force_.push_back (prev_force); + /* the last page containing the last line */ + space.resize (page_height (first_page_num + page + 1, true)); + space.clear (); + space.append_system (cached_line_details_[line]); + res.systems_per_page_.push_back (1); + res.force_.push_back (space.force_); + res.penalty_ += cached_line_details_[line - 1].page_penalty_; res.penalty_ += cached_line_details_[line].page_penalty_; - } - else - { - res.systems_per_page_.push_back (line + 1 - page_first_line); - res.force_.push_back (space.force_); + } + else + { + res.systems_per_page_.push_back (line + 1 - page_first_line); + res.force_.push_back (space.force_); res.penalty_ += cached_line_details_[line].page_penalty_; - } - } + } + } } return finalize_spacing_result (configuration, res); } @@ -1421,7 +1421,7 @@ Page_breaking::finalize_spacing_result (vsize configuration, Page_spacing_result { Real f = res.force_[i]; - page_demerits += min(f*f, BAD_SPACING_PENALTY); + page_demerits += min (f * f, BAD_SPACING_PENALTY); } /* for a while we tried averaging page and line forces across pages instead @@ -1476,16 +1476,16 @@ Page_breaking::space_systems_on_2_pages (vsize configuration, vsize first_page_n for (vsize i = 0; i + 1 < cached_line_details_.size (); i++) if (cached_line_details_[i].page_permission_ == ly_symbol2scm ("force")) { - vector<Line_details> lines1 (cached_line_details_.begin (), cached_line_details_.begin () + i + 1); - vector<Line_details> lines2 (cached_line_details_.begin () + i + 1, cached_line_details_.end ()); - Page_spacing_result p1 = space_systems_on_1_page (lines1, page1_height, ragged1); - Page_spacing_result p2 = space_systems_on_1_page (lines2, page2_height, ragged2); - - p1.systems_per_page_.push_back (p2.systems_per_page_[0]); - p1.force_.push_back (p2.force_[0]); - p1.penalty_ += p2.penalty_ - cached_line_details_[i].turn_penalty_; - p1.system_count_status_ |= p2.system_count_status_; - return p1; + vector<Line_details> lines1 (cached_line_details_.begin (), cached_line_details_.begin () + i + 1); + vector<Line_details> lines2 (cached_line_details_.begin () + i + 1, cached_line_details_.end ()); + Page_spacing_result p1 = space_systems_on_1_page (lines1, page1_height, ragged1); + Page_spacing_result p2 = space_systems_on_1_page (lines2, page2_height, ragged2); + + p1.systems_per_page_.push_back (p2.systems_per_page_[0]); + p1.force_.push_back (p2.force_[0]); + p1.penalty_ += p2.penalty_ - cached_line_details_[i].turn_penalty_; + p1.system_count_status_ |= p2.system_count_status_; + return p1; } vector<Real> page1_force; @@ -1526,10 +1526,10 @@ Page_breaking::space_systems_on_2_pages (vsize configuration, vsize first_page_n page1_status[i] = line_count_status (page1_line_count); if (ragged2) - page2_force[page2_force.size () - 1 - i] = - (page2.force_ < 0 && i + 1 < page1_force.size ()) ? infinity_f : 0; + page2_force[page2_force.size () - 1 - i] + = (page2.force_ < 0 && i + 1 < page1_force.size ()) ? infinity_f : 0; else - page2_force[page2_force.size () - 1 - i] = page2.force_; + page2_force[page2_force.size () - 1 - i] = page2.force_; page2_penalty[page2_penalty.size () - 1 - i] = line_count_penalty (page2_line_count); page2_status[page2_penalty.size () - 1 - i] = line_count_status (page2_line_count); } @@ -1545,26 +1545,26 @@ Page_breaking::space_systems_on_2_pages (vsize configuration, vsize first_page_n // constraints. That is, we penalize harshly when they don't happen // but we don't completely reject. Real dem = f - + page1_penalty[i] + page2_penalty[i] - + cached_line_details_[i+1].page_penalty_ - + cached_line_details_.back ().page_penalty_ + cached_line_details_.back ().turn_penalty_; + + page1_penalty[i] + page2_penalty[i] + + cached_line_details_[i + 1].page_penalty_ + + cached_line_details_.back ().page_penalty_ + cached_line_details_.back ().turn_penalty_; if (dem < best_demerits) - { - best_demerits = dem; - best_sys_count = i+1; - } + { + best_demerits = dem; + best_sys_count = i + 1; + } } Page_spacing_result ret; ret.systems_per_page_.push_back (best_sys_count); ret.systems_per_page_.push_back (cached_line_details_.size () - best_sys_count); - ret.force_.push_back (page1_force[best_sys_count-1]); - ret.force_.push_back (page2_force[best_sys_count-1]); - ret.system_count_status_ = page1_status[best_sys_count-1] | page2_status[best_sys_count-1]; - ret.penalty_ = cached_line_details_[best_sys_count-1].page_penalty_ - + cached_line_details_.back ().page_penalty_ - + cached_line_details_.back ().turn_penalty_ - + page1_penalty[best_sys_count-1] + page2_penalty[best_sys_count-1]; + ret.force_.push_back (page1_force[best_sys_count - 1]); + ret.force_.push_back (page2_force[best_sys_count - 1]); + ret.system_count_status_ = page1_status[best_sys_count - 1] | page2_status[best_sys_count - 1]; + ret.penalty_ = cached_line_details_[best_sys_count - 1].page_penalty_ + + cached_line_details_.back ().page_penalty_ + + cached_line_details_.back ().turn_penalty_ + + page1_penalty[best_sys_count - 1] + page2_penalty[best_sys_count - 1]; /* don't do finalize_spacing_result () because we are only an internal function */ return ret; @@ -1602,7 +1602,7 @@ Page_breaking::ends_score () const vsize Page_breaking::last_break_position () const { - return breaks_.size () - 1; + return breaks_.size () - 1; } // This gives the minimum distance between the top of the @@ -1619,11 +1619,11 @@ Page_breaking::min_whitespace_at_top_of_page (Line_details const &line) const Real padding = 0; Page_layout_problem::read_spacing_spec (first_system_spacing, - &min_distance, - ly_symbol2scm ("minimum-distance")); + &min_distance, + ly_symbol2scm ("minimum-distance")); Page_layout_problem::read_spacing_spec (first_system_spacing, - &padding, - ly_symbol2scm ("padding")); + &padding, + ly_symbol2scm ("padding")); // FIXME: take into account the height of the header Real translate = max (line.shape_.begin_[UP], line.shape_.rest_[UP]); @@ -1638,11 +1638,11 @@ Page_breaking::min_whitespace_at_bottom_of_page (Line_details const &line) const Real padding = 0; Page_layout_problem::read_spacing_spec (last_system_spacing, - &min_distance, - ly_symbol2scm ("minimum-distance")); + &min_distance, + ly_symbol2scm ("minimum-distance")); Page_layout_problem::read_spacing_spec (last_system_spacing, - &padding, - ly_symbol2scm ("padding")); + &padding, + ly_symbol2scm ("padding")); // FIXME: take into account the height of the footer Real translate = min (line.shape_.begin_[DOWN], line.shape_.rest_[DOWN]); diff --git a/lily/page-layout-problem.cc b/lily/page-layout-problem.cc index 17c2912e14..c9301ff384 100644 --- a/lily/page-layout-problem.cc +++ b/lily/page-layout-problem.cc @@ -45,9 +45,9 @@ Page_layout_problem::get_footnote_count (SCM lines) for (SCM s = lines; scm_is_pair (s); s = scm_cdr (s)) { if (Grob *g = unsmob_grob (scm_car (s))) - { - System *sys = dynamic_cast<System *> (g); - if (!sys) + { + System *sys = dynamic_cast<System *> (g); + if (!sys) { programming_error ("got a grob for footnotes that wasn't a System"); continue; @@ -112,7 +112,7 @@ Page_layout_problem::get_footnotes_from_lines (SCM lines, int counter, Paper_boo TODO: This recalculates numbering every time this function is called, including once after the balloon prints are called. Although it is not a huge computational drain, it'd be more elegant to turn this calculation off when it is no longer needed. - + In a separate commit, it'd be nice to streamline the way that page layout property is handled so that the process of building `config's in page-breaking does result in duplicated work, either by making this process less complicated or (preferably) @@ -130,7 +130,7 @@ Page_layout_problem::get_footnotes_from_lines (SCM lines, int counter, Paper_boo { programming_error ("Your numbering function needs to return a stencil."); markup = SCM_EOL; - s = new Stencil (Box (Interval (0,0), Interval (0,0)), SCM_EOL); + s = new Stencil (Box (Interval (0, 0), Interval (0, 0)), SCM_EOL); } footnote_number_markups.push_back (markup); footnote_number_stencils.push_back (s); @@ -166,54 +166,54 @@ Page_layout_problem::get_footnotes_from_lines (SCM lines, int counter, Paper_boo { // Take care of musical systems. if (Grob *g = unsmob_grob (scm_car (s))) - { - System *sys = dynamic_cast<System *> (g); - if (!sys) + { + System *sys = dynamic_cast<System *> (g); + if (!sys) { programming_error ("got a grob for footnotes that wasn't a System"); continue; } - Stencil mol; - - for (vsize i = 0; i < sys->footnote_grobs ()->size (); i++) - { - Grob *footnote = sys->footnote_grobs ()->at (i); - SCM footnote_markup = footnote->get_property ("footnote-text"); - if (Spanner *orig = dynamic_cast<Spanner *>(footnote)) - if (orig->is_broken ()) - footnote_markup = orig->broken_intos_[0]->get_property ("footnote-text"); - - if (!Text_interface::is_markup (footnote_markup)) - continue; - - SCM props = scm_call_1 (ly_lily_module_constant ("layout-extract-page-properties"), - paper->self_scm ()); - - SCM footnote_stl = Text_interface::interpret_markup (paper->self_scm (), - props, footnote_markup); - - Stencil *footnote_stencil = unsmob_stencil (footnote_stl); - if (do_numbering) - { - SCM annotation_scm = scm_car (in_text_numbers); - footnote->set_property ("text", annotation_scm); - if (Spanner *orig = dynamic_cast<Spanner *>(footnote)) - { - orig->set_property ("text", annotation_scm); - if (orig->is_broken ()) - for (vsize i = 0; i < orig->broken_intos_.size (); i++) - orig->broken_intos_[i]->set_property ("text", annotation_scm); - } - - Stencil *annotation = unsmob_stencil (scm_car (numbers)); - annotation->translate_axis (footnote_stencil->extent (Y_AXIS)[UP] + number_raise - annotation->extent(Y_AXIS)[UP], Y_AXIS); - footnote_stencil->add_at_edge (X_AXIS, LEFT, *annotation, 0.0); - numbers = scm_cdr (numbers); - in_text_numbers = scm_cdr (in_text_numbers); - } - mol.add_at_edge (Y_AXIS, DOWN, *footnote_stencil, padding); - } - footnotes = scm_cons (mol.smobbed_copy (), footnotes); + Stencil mol; + + for (vsize i = 0; i < sys->footnote_grobs ()->size (); i++) + { + Grob *footnote = sys->footnote_grobs ()->at (i); + SCM footnote_markup = footnote->get_property ("footnote-text"); + if (Spanner *orig = dynamic_cast<Spanner *>(footnote)) + if (orig->is_broken ()) + footnote_markup = orig->broken_intos_[0]->get_property ("footnote-text"); + + if (!Text_interface::is_markup (footnote_markup)) + continue; + + SCM props = scm_call_1 (ly_lily_module_constant ("layout-extract-page-properties"), + paper->self_scm ()); + + SCM footnote_stl = Text_interface::interpret_markup (paper->self_scm (), + props, footnote_markup); + + Stencil *footnote_stencil = unsmob_stencil (footnote_stl); + if (do_numbering) + { + SCM annotation_scm = scm_car (in_text_numbers); + footnote->set_property ("text", annotation_scm); + if (Spanner *orig = dynamic_cast<Spanner *>(footnote)) + { + orig->set_property ("text", annotation_scm); + if (orig->is_broken ()) + for (vsize i = 0; i < orig->broken_intos_.size (); i++) + orig->broken_intos_[i]->set_property ("text", annotation_scm); + } + + Stencil *annotation = unsmob_stencil (scm_car (numbers)); + annotation->translate_axis (footnote_stencil->extent (Y_AXIS)[UP] + number_raise - annotation->extent (Y_AXIS)[UP], Y_AXIS); + footnote_stencil->add_at_edge (X_AXIS, LEFT, *annotation, 0.0); + numbers = scm_cdr (numbers); + in_text_numbers = scm_cdr (in_text_numbers); + } + mol.add_at_edge (Y_AXIS, DOWN, *footnote_stencil, padding); + } + footnotes = scm_cons (mol.smobbed_copy (), footnotes); } // Take care of top-level markups else if (Prob *p = unsmob_prob (scm_car (s))) @@ -236,7 +236,7 @@ Page_layout_problem::get_footnotes_from_lines (SCM lines, int counter, Paper_boo if (!unsmob_stencil (in_text_stencil)) in_text_stencil = SCM_EOL; number_footnote_table = scm_cons (scm_cons (scm_caar (st), in_text_stencil), number_footnote_table); - annotation->translate_axis (mol.extent (Y_AXIS)[UP] + number_raise - annotation->extent(Y_AXIS)[UP], Y_AXIS); + annotation->translate_axis (mol.extent (Y_AXIS)[UP] + number_raise - annotation->extent (Y_AXIS)[UP], Y_AXIS); mol.add_at_edge (X_AXIS, LEFT, *annotation, 0.0); numbers = scm_cdr (numbers); in_text_numbers = scm_cdr (in_text_numbers); @@ -255,7 +255,7 @@ Page_layout_problem::get_footnotes_from_lines (SCM lines, int counter, Paper_boo return scm_reverse (footnotes); } -Stencil* +Stencil * Page_layout_problem::get_footnote_separator_stencil (Output_def *paper) { SCM props = scm_call_1 (ly_lily_module_constant ("layout-extract-page-properties"), @@ -280,7 +280,7 @@ Page_layout_problem::add_footnotes_to_footer (SCM footnotes, Stencil *foot, Pape bool footnotes_found = false; Real footnote_padding = robust_scm2double (pb->paper_->c_variable ("footnote-padding"), 0.0); Real footnote_footer_padding = robust_scm2double (pb->paper_->c_variable ("footnote-footer-padding"), 0.0); - + footnotes = scm_reverse (footnotes); for (SCM s = footnotes; scm_is_pair (s); s = scm_cdr (s)) @@ -363,64 +363,63 @@ Page_layout_problem::Page_layout_problem (Paper_book *pb, SCM page_scm, SCM syst last_bottom_spacing = paper->c_variable ("last-bottom-spacing"); top_system_spacing = paper->c_variable ("top-system-spacing"); if (scm_is_pair (systems) && unsmob_prob (scm_car (systems))) - top_system_spacing = paper->c_variable ("top-markup-spacing"); + top_system_spacing = paper->c_variable ("top-markup-spacing"); // Note: the page height here does _not_ reserve space for headers and // footers. This is because we want to anchor the top-system-spacing // spring at the _top_ of the header. page_height_ -= robust_scm2double (paper->c_variable ("top-margin"), 0) - + robust_scm2double (paper->c_variable ("bottom-margin"), 0); + + robust_scm2double (paper->c_variable ("bottom-margin"), 0); read_spacing_spec (top_system_spacing, &header_padding_, ly_symbol2scm ("padding")); read_spacing_spec (last_bottom_spacing, &footer_padding_, ly_symbol2scm ("padding")); } bool last_system_was_title = false; - for (SCM s = systems; scm_is_pair (s); s = scm_cdr (s)) { bool first = (s == systems); if (Grob *g = unsmob_grob (scm_car (s))) - { - System *sys = dynamic_cast<System*> (g); - if (!sys) - { - programming_error ("got a grob for vertical spacing that wasn't a System"); - continue; - } - - SCM spec = system_system_spacing; - if (first) - spec = top_system_spacing; - else if (last_system_was_title) - spec = markup_system_spacing; - else if (0 == Paper_column::get_rank (sys->get_bound (LEFT))) - spec = score_system_spacing; - - Spring spring (0, 0); - Real padding = 0.0; - Real indent = line_dimensions_int (sys->paper_score ()->layout (), sys->get_rank ())[LEFT]; - alter_spring_from_spacing_spec (spec, &spring); - read_spacing_spec (spec, &padding, ly_symbol2scm ("padding")); - - append_system (sys, spring, indent, padding); - last_system_was_title = false; - } + { + System *sys = dynamic_cast<System *> (g); + if (!sys) + { + programming_error ("got a grob for vertical spacing that wasn't a System"); + continue; + } + + SCM spec = system_system_spacing; + if (first) + spec = top_system_spacing; + else if (last_system_was_title) + spec = markup_system_spacing; + else if (0 == Paper_column::get_rank (sys->get_bound (LEFT))) + spec = score_system_spacing; + + Spring spring (0, 0); + Real padding = 0.0; + Real indent = line_dimensions_int (sys->paper_score ()->layout (), sys->get_rank ())[LEFT]; + alter_spring_from_spacing_spec (spec, &spring); + read_spacing_spec (spec, &padding, ly_symbol2scm ("padding")); + + append_system (sys, spring, indent, padding); + last_system_was_title = false; + } else if (Prob *p = unsmob_prob (scm_car (s))) - { - SCM spec = first ? top_system_spacing - : (last_system_was_title ? markup_markup_spacing : score_markup_spacing); - Spring spring (0, 0); - Real padding = 0.0; - alter_spring_from_spacing_spec (spec, &spring); - read_spacing_spec (spec, &padding, ly_symbol2scm ("padding")); - - append_prob (p, spring, padding); - last_system_was_title = true; - } + { + SCM spec = first ? top_system_spacing + : (last_system_was_title ? markup_markup_spacing : score_markup_spacing); + Spring spring (0, 0); + Real padding = 0.0; + alter_spring_from_spacing_spec (spec, &spring); + read_spacing_spec (spec, &padding, ly_symbol2scm ("padding")); + + append_prob (p, spring, padding); + last_system_was_title = true; + } else - programming_error ("got a system that was neither a Grob nor a Prob"); + programming_error ("got a system that was neither a Grob nor a Prob"); } Spring last_spring (0, 0); @@ -438,15 +437,15 @@ Page_layout_problem::Page_layout_problem (Paper_book *pb, SCM page_scm, SCM syst // bottom-space has the flexibility that one can do it per-system. // NOTE: bottom-space is misnamed since it is not stretchable space. if (Prob *p = elements_.back ().prob) - bottom_padding = robust_scm2double (p->get_property ("bottom-space"), 0); + bottom_padding = robust_scm2double (p->get_property ("bottom-space"), 0); else if (elements_.back ().staves.size ()) - { - SCM details = get_details (elements_.back ()); - bottom_padding = robust_scm2double (ly_assoc_get (ly_symbol2scm ("bottom-space"), - details, - SCM_BOOL_F), - 0.0); - } + { + SCM details = get_details (elements_.back ()); + bottom_padding = robust_scm2double (ly_assoc_get (ly_symbol2scm ("bottom-space"), + details, + SCM_BOOL_F), + 0.0); + } page_height_ -= bottom_padding; } } @@ -464,7 +463,7 @@ Page_layout_problem::set_footer_height (Real height) } void -Page_layout_problem::append_system (System *sys, Spring const& spring, Real indent, Real padding) +Page_layout_problem::append_system (System *sys, Spring const &spring, Real indent, Real padding) { Grob *align = sys->get_vertical_alignment (); if (!align) @@ -473,7 +472,7 @@ Page_layout_problem::append_system (System *sys, Spring const& spring, Real inde align->set_property ("positioning-done", SCM_BOOL_T); extract_grob_set (align, "elements", all_elts); - vector<Grob*> elts = filter_dead_elements (all_elts); + vector<Grob *> elts = filter_dead_elements (all_elts); vector<Real> minimum_offsets = Align_interface::get_minimum_translations_without_min_dist (align, elts, Y_AXIS); vector<Real> minimum_offsets_with_min_dist = Align_interface::get_minimum_translations (align, elts, Y_AXIS); @@ -509,38 +508,38 @@ Page_layout_problem::append_system (System *sys, Spring const& spring, Real inde for (vsize i = 0; i < elts.size (); ++i) { if (is_spaceable (elts[i])) - { - // We don't add a spring for the first staff, since - // we are only adding springs _between_ staves here. - if (!found_spaceable_staff) - { - found_spaceable_staff = true; - last_spaceable_staff = i; - continue; - } - - Spring spring (0.5, 0.0); - SCM spec = elts[last_spaceable_staff]->get_property ("staff-staff-spacing"); - alter_spring_from_spacing_spec (spec, &spring); - - springs_.push_back (spring); - Real min_distance = (found_spaceable_staff ? minimum_offsets_with_min_dist[last_spaceable_staff] : 0) - minimum_offsets_with_min_dist[i]; - springs_.back ().ensure_min_distance (min_distance); - - if (scm_is_pair (manual_dists)) - { - if (scm_is_number (scm_car (manual_dists))) - { - Real dy = scm_to_double (scm_car (manual_dists)); - - springs_.back ().set_distance (dy); - springs_.back ().set_min_distance (dy); - springs_.back ().set_inverse_stretch_strength (0); - } - manual_dists = scm_cdr (manual_dists); - } - last_spaceable_staff = i; - } + { + // We don't add a spring for the first staff, since + // we are only adding springs _between_ staves here. + if (!found_spaceable_staff) + { + found_spaceable_staff = true; + last_spaceable_staff = i; + continue; + } + + Spring spring (0.5, 0.0); + SCM spec = elts[last_spaceable_staff]->get_property ("staff-staff-spacing"); + alter_spring_from_spacing_spec (spec, &spring); + + springs_.push_back (spring); + Real min_distance = (found_spaceable_staff ? minimum_offsets_with_min_dist[last_spaceable_staff] : 0) - minimum_offsets_with_min_dist[i]; + springs_.back ().ensure_min_distance (min_distance); + + if (scm_is_pair (manual_dists)) + { + if (scm_is_number (scm_car (manual_dists))) + { + Real dy = scm_to_double (scm_car (manual_dists)); + + springs_.back ().set_distance (dy); + springs_.back ().set_min_distance (dy); + springs_.back ().set_inverse_stretch_strength (0); + } + manual_dists = scm_cdr (manual_dists); + } + last_spaceable_staff = i; + } } // Corner case: there was only one staff, and it wasn't spaceable. @@ -551,7 +550,7 @@ Page_layout_problem::append_system (System *sys, Spring const& spring, Real inde } void -Page_layout_problem::append_prob (Prob *prob, Spring const& spring, Real padding) +Page_layout_problem::append_prob (Prob *prob, Spring const &spring, Real padding) { Skyline_pair *sky = Skyline_pair::unsmob (prob->get_property ("vertical-skylines")); Real minimum_distance = 0; @@ -599,19 +598,19 @@ Page_layout_problem::solve_rod_spring_problem (bool ragged) if (!spacer.fits ()) { Real overflow = spacer.configuration_length (spacer.force ()) - - page_height_; + - page_height_; if (ragged && overflow < 1e-6) - warning (_ ("cannot fit music on page: ragged-spacing was requested, but page was compressed")); + warning (_ ("cannot fit music on page: ragged-spacing was requested, but page was compressed")); else - { - warning (_f ("cannot fit music on page: overflow is %f", - overflow)); - warning (_ ("compressing music to fit")); - vsize space_count = solution_.size (); - Real spacing_increment = overflow / (space_count - 2); - for (vsize i = 2; i < space_count; i++) - solution_[i] -= (i-1) * spacing_increment; - } + { + warning (_f ("cannot fit music on page: overflow is %f", + overflow)); + warning (_ ("compressing music to fit")); + vsize space_count = solution_.size (); + Real spacing_increment = overflow / (space_count - 2); + for (vsize i = 2; i < space_count; i++) + solution_[i] -= (i - 1) * spacing_increment; + } } } @@ -628,7 +627,7 @@ Page_layout_problem::find_system_offsets () // spring_idx 0 is the top of the page. Interesting values start from 1. vsize spring_idx = 1; - vector<Grob*> loose_lines; + vector<Grob *> loose_lines; vector<Real> loose_line_min_distances; Grob *last_spaceable_line = 0; Real last_spaceable_line_translation = 0; @@ -636,126 +635,127 @@ Page_layout_problem::find_system_offsets () for (vsize i = 0; i < elements_.size (); ++i) { if (elements_[i].prob) - { - *tail = scm_cons (scm_from_double (solution_[spring_idx]), SCM_EOL); - tail = SCM_CDRLOC (*tail); - Interval prob_extent = unsmob_stencil (elements_[i].prob->get_property ("stencil"))->extent (Y_AXIS); - - // Lay out any non-spaceable lines between this line and - // the last one. - if (loose_lines.size ()) - { - Interval loose_extent = loose_lines.back ()->extent (loose_lines.back (), Y_AXIS); - Real min_distance = (-loose_extent[DOWN] + prob_extent[UP] - + elements_[i].padding); - - loose_line_min_distances.push_back (min_distance); - loose_lines.push_back (0); - - distribute_loose_lines (loose_lines, loose_line_min_distances, - last_spaceable_line_translation, -solution_[spring_idx]); - loose_lines.clear (); - loose_line_min_distances.clear (); - } - - last_spaceable_line = 0; - last_spaceable_line_translation = -solution_[spring_idx]; - last_title_extent = prob_extent; - spring_idx++; - } + { + *tail = scm_cons (scm_from_double (solution_[spring_idx]), SCM_EOL); + tail = SCM_CDRLOC (*tail); + Interval prob_extent = unsmob_stencil (elements_[i].prob->get_property ("stencil"))->extent (Y_AXIS); + + // Lay out any non-spaceable lines between this line and + // the last one. + if (loose_lines.size ()) + { + Interval loose_extent = loose_lines.back ()->extent (loose_lines.back (), Y_AXIS); + Real min_distance = (-loose_extent[DOWN] + prob_extent[UP] + + elements_[i].padding); + + loose_line_min_distances.push_back (min_distance); + loose_lines.push_back (0); + + distribute_loose_lines (loose_lines, loose_line_min_distances, + last_spaceable_line_translation, -solution_[spring_idx]); + loose_lines.clear (); + loose_line_min_distances.clear (); + } + + last_spaceable_line = 0; + last_spaceable_line_translation = -solution_[spring_idx]; + last_title_extent = prob_extent; + spring_idx++; + } else - { - // Getting this signs right here is a little tricky. The configuration - // we return has zero at the top of the page and positive numbers further - // down, as does the solution_ vector. Within a staff, however, positive - // numbers are up. - // TODO: perhaps change the way the page 'configuration variable works so - // that it is consistent with the usual up/down sign conventions in - // Lilypond. Then this would be less confusing. - - // These two positions are relative to the page (with positive numbers being - // down). - Real first_staff_position = solution_[spring_idx]; - Real first_staff_min_translation = elements_[i].min_offsets.size () ? elements_[i].min_offsets[0] : 0; - Real system_position = first_staff_position + first_staff_min_translation; - - // Position the staves within this system. - vector<Real> const& min_offsets = elements_[i].min_offsets; - bool found_spaceable_staff = false; - for (vsize staff_idx = 0; staff_idx < elements_[i].staves.size (); ++staff_idx) - { - Grob *staff = elements_[i].staves[staff_idx]; - staff->set_property ("system-Y-offset", scm_from_double (-system_position)); - - if (is_spaceable (staff)) - { - // this is relative to the system: negative numbers are down. - staff->translate_axis (system_position - solution_[spring_idx], Y_AXIS); - - // Lay out any non-spaceable lines between this line and - // the last one. - if (loose_lines.size ()) - { - if (staff_idx) - loose_line_min_distances.push_back (min_offsets[staff_idx-1] - min_offsets[staff_idx]); - else - loose_line_min_distances.push_back (elements_[i].padding - min_offsets[staff_idx]); - loose_lines.push_back (staff); - - distribute_loose_lines (loose_lines, loose_line_min_distances, - last_spaceable_line_translation, -solution_[spring_idx]); - loose_lines.clear (); - loose_line_min_distances.clear (); - } - last_spaceable_line = staff; - last_spaceable_line_translation = -solution_[spring_idx]; - found_spaceable_staff = true; - spring_idx++; - } - else - { - if (loose_lines.empty ()) - loose_lines.push_back (last_spaceable_line); - - if (staff_idx) - // NOTE: the way we do distances between loose lines (and other lines too, actually) - // is not the most accurate way possible: we only insert rods between adjacent - // lines. To be more accurate, we could insert rods between non-adjacent lines - // using a scheme similar to the one in set_column_rods. - loose_line_min_distances.push_back (min_offsets[staff_idx-1] - min_offsets[staff_idx]); - else - { // this is the first line in a system - Real min_dist = 0; - if (loose_lines.back ()) - // distance to the final line in the preceding system, - // including 'system-system-spacing 'padding - min_dist = (Axis_group_interface::minimum_distance (loose_lines.back (), - staff, - Y_AXIS) - + elements_[i].padding); - else if (!last_title_extent.is_empty ()) - // distance to the preceding title, - // including 'markup-system-spacing 'padding - min_dist = (staff->extent (staff, Y_AXIS)[UP] - last_title_extent[DOWN] - + elements_[i].padding); - else // distance to the top margin - min_dist = header_padding_ + header_height_ + staff->extent (staff, Y_AXIS)[UP]; - - loose_line_min_distances.push_back (min_dist); - } - loose_lines.push_back (staff); - } - } - - // Corner case: even if a system has no live staves, it still takes up - // one spring (a system with one live staff also takes up one spring), - // which we need to increment past. - if (!found_spaceable_staff) - spring_idx++; - - *tail = scm_cons (scm_from_double (system_position), SCM_EOL); - tail = SCM_CDRLOC (*tail); - } + { + // Getting this signs right here is a little tricky. The configuration + // we return has zero at the top of the page and positive numbers further + // down, as does the solution_ vector. Within a staff, however, positive + // numbers are up. + // TODO: perhaps change the way the page 'configuration variable works so + // that it is consistent with the usual up/down sign conventions in + // Lilypond. Then this would be less confusing. + + // These two positions are relative to the page (with positive numbers being + // down). + Real first_staff_position = solution_[spring_idx]; + Real first_staff_min_translation = elements_[i].min_offsets.size () ? elements_[i].min_offsets[0] : 0; + Real system_position = first_staff_position + first_staff_min_translation; + + // Position the staves within this system. + vector<Real> const &min_offsets = elements_[i].min_offsets; + bool found_spaceable_staff = false; + for (vsize staff_idx = 0; staff_idx < elements_[i].staves.size (); ++staff_idx) + { + Grob *staff = elements_[i].staves[staff_idx]; + staff->set_property ("system-Y-offset", scm_from_double (-system_position)); + + if (is_spaceable (staff)) + { + // this is relative to the system: negative numbers are down. + staff->translate_axis (system_position - solution_[spring_idx], Y_AXIS); + + // Lay out any non-spaceable lines between this line and + // the last one. + if (loose_lines.size ()) + { + if (staff_idx) + loose_line_min_distances.push_back (min_offsets[staff_idx - 1] - min_offsets[staff_idx]); + else + loose_line_min_distances.push_back (elements_[i].padding - min_offsets[staff_idx]); + loose_lines.push_back (staff); + + distribute_loose_lines (loose_lines, loose_line_min_distances, + last_spaceable_line_translation, -solution_[spring_idx]); + loose_lines.clear (); + loose_line_min_distances.clear (); + } + last_spaceable_line = staff; + last_spaceable_line_translation = -solution_[spring_idx]; + found_spaceable_staff = true; + spring_idx++; + } + else + { + if (loose_lines.empty ()) + loose_lines.push_back (last_spaceable_line); + + if (staff_idx) + // NOTE: the way we do distances between loose lines (and other lines too, actually) + // is not the most accurate way possible: we only insert rods between adjacent + // lines. To be more accurate, we could insert rods between non-adjacent lines + // using a scheme similar to the one in set_column_rods. + loose_line_min_distances.push_back (min_offsets[staff_idx - 1] - min_offsets[staff_idx]); + else + { + // this is the first line in a system + Real min_dist = 0; + if (loose_lines.back ()) + // distance to the final line in the preceding system, + // including 'system-system-spacing 'padding + min_dist = (Axis_group_interface::minimum_distance (loose_lines.back (), + staff, + Y_AXIS) + + elements_[i].padding); + else if (!last_title_extent.is_empty ()) + // distance to the preceding title, + // including 'markup-system-spacing 'padding + min_dist = (staff->extent (staff, Y_AXIS)[UP] - last_title_extent[DOWN] + + elements_[i].padding); + else // distance to the top margin + min_dist = header_padding_ + header_height_ + staff->extent (staff, Y_AXIS)[UP]; + + loose_line_min_distances.push_back (min_dist); + } + loose_lines.push_back (staff); + } + } + + // Corner case: even if a system has no live staves, it still takes up + // one spring (a system with one live staff also takes up one spring), + // which we need to increment past. + if (!found_spaceable_staff) + spring_idx++; + + *tail = scm_cons (scm_from_double (system_position), SCM_EOL); + tail = SCM_CDRLOC (*tail); + } } if (loose_lines.size ()) @@ -766,7 +766,7 @@ Page_layout_problem::find_system_offsets () loose_lines.push_back (0); distribute_loose_lines (loose_lines, loose_line_min_distances, - last_spaceable_line_translation, -page_height_); + last_spaceable_line_translation, -page_height_); } @@ -779,14 +779,14 @@ Page_layout_problem::find_system_offsets () // them. // first_translation and last_translation are relative to the page. void -Page_layout_problem::distribute_loose_lines (vector<Grob*> const &loose_lines, - vector<Real> const &min_distances, - Real first_translation, Real last_translation) +Page_layout_problem::distribute_loose_lines (vector<Grob *> const &loose_lines, + vector<Real> const &min_distances, + Real first_translation, Real last_translation) { Simple_spacer spacer; for (vsize i = 0; i + 1 < loose_lines.size (); ++i) { - SCM spec = get_spacing_spec (loose_lines[i], loose_lines[i+1], false, 0, INT_MAX); + SCM spec = get_spacing_spec (loose_lines[i], loose_lines[i + 1], false, 0, INT_MAX); Spring spring (1.0, 0.0); alter_spring_from_spacing_spec (spec, &spring); spring.ensure_min_distance (min_distances[i]); @@ -821,10 +821,10 @@ Page_layout_problem::solution (bool ragged) // The upper skyline is relative to the top staff; the lower skyline is relative to // the bottom staff. void -Page_layout_problem::build_system_skyline (vector<Grob*> const& staves, - vector<Real> const& minimum_translations, - Skyline *up, - Skyline *down) +Page_layout_problem::build_system_skyline (vector<Grob *> const &staves, + vector<Real> const &minimum_translations, + Skyline *up, + Skyline *down) { if (minimum_translations.empty ()) return; @@ -841,24 +841,24 @@ Page_layout_problem::build_system_skyline (vector<Grob*> const& staves, Grob *g = staves[i]; Skyline_pair *sky = Skyline_pair::unsmob (g->get_property ("vertical-skylines")); if (sky) - { - up->raise (-dy); - up->merge ((*sky)[UP]); - up->raise (dy); - - down->raise (-dy); - down->merge ((*sky)[DOWN]); - down->raise (dy); - } + { + up->raise (-dy); + up->merge ((*sky)[UP]); + up->raise (dy); + + down->raise (-dy); + down->merge ((*sky)[DOWN]); + down->raise (dy); + } if (is_spaceable (staves[i])) - { - if (!found_spaceable_staff) - { - found_spaceable_staff = true; - first_spaceable_dy = dy; - } - last_spaceable_dy = dy; - } + { + if (!found_spaceable_staff) + { + found_spaceable_staff = true; + first_spaceable_dy = dy; + } + last_spaceable_dy = dy; + } } // Leave the up skyline at a position relative @@ -878,7 +878,7 @@ Page_layout_problem::prob_extent (Prob *p) } Interval -Page_layout_problem::first_staff_extent (Element const& e) +Page_layout_problem::first_staff_extent (Element const &e) { if (e.prob) return prob_extent (e.prob); @@ -889,7 +889,7 @@ Page_layout_problem::first_staff_extent (Element const& e) } Interval -Page_layout_problem::last_staff_extent (Element const& e) +Page_layout_problem::last_staff_extent (Element const &e) { if (e.prob) return prob_extent (e.prob); @@ -900,7 +900,7 @@ Page_layout_problem::last_staff_extent (Element const& e) } SCM -Page_layout_problem::get_details (Element const& elt) +Page_layout_problem::get_details (Element const &elt) { if (elt.staves.empty ()) return SCM_EOL; @@ -911,7 +911,7 @@ Page_layout_problem::get_details (Element const& elt) SCM Page_layout_problem::get_details (Grob *g) { - Grob *left_bound = dynamic_cast<Spanner*> (g)->get_bound (LEFT); + Grob *left_bound = dynamic_cast<Spanner *> (g)->get_bound (LEFT); return left_bound->get_property ("line-break-system-details"); } @@ -928,7 +928,7 @@ Page_layout_problem::mark_as_spaceable (Grob *g) } bool -Page_layout_problem::read_spacing_spec (SCM spec, Real* dest, SCM sym) +Page_layout_problem::read_spacing_spec (SCM spec, Real *dest, SCM sym) { SCM pair = scm_sloppy_assq (sym, spec); if (scm_is_pair (pair) && scm_is_number (scm_cdr (pair))) @@ -946,17 +946,17 @@ Page_layout_problem::read_spacing_spec (SCM spec, Real* dest, SCM sym) Real Page_layout_problem::get_fixed_spacing (Grob *before, Grob *after, int spaceable_index, bool pure, int start, int end) { - Spanner *after_sp = dynamic_cast<Spanner*> (after); + Spanner *after_sp = dynamic_cast<Spanner *> (after); SCM cache_symbol = (is_spaceable (before) && is_spaceable (after)) - ? ly_symbol2scm ("spaceable-fixed-spacing") - : ly_symbol2scm ("loose-fixed-spacing"); + ? ly_symbol2scm ("spaceable-fixed-spacing") + : ly_symbol2scm ("loose-fixed-spacing"); if (pure) { // The result of this function doesn't depend on "end," so we can reduce the // size of the cache by ignoring it. SCM cached = after_sp->get_cached_pure_property (cache_symbol, start, 0); if (scm_is_number (cached)) - return robust_scm2double (cached, 0.0); + return robust_scm2double (cached, 0.0); } Real ret = -infinity_f; @@ -971,11 +971,11 @@ Page_layout_problem::get_fixed_spacing (Grob *before, Grob *after, int spaceable SCM details = left_bound->get_property ("line-break-system-details"); SCM manual_dists = ly_assoc_get (ly_symbol2scm ("alignment-distances"), details, SCM_EOL); if (scm_is_pair (manual_dists)) - { - SCM forced = robust_list_ref (spaceable_index - 1, manual_dists); - if (scm_is_number (forced)) - ret = max (ret, scm_to_double (forced)); - } + { + SCM forced = robust_list_ref (spaceable_index - 1, manual_dists); + if (scm_is_number (forced)) + ret = max (ret, scm_to_double (forced)); + } } // Cache the result. As above, we ignore "end." @@ -1016,44 +1016,44 @@ Page_layout_problem::get_spacing_spec (Grob *before, Grob *after, bool pure, int if (is_spaceable (before)) { if (is_spaceable (after)) - return before->get_maybe_pure_property ("staff-staff-spacing", pure, start, end); + return before->get_maybe_pure_property ("staff-staff-spacing", pure, start, end); else - { - Direction affinity = to_dir (after->get_maybe_pure_property ("staff-affinity", pure, start, end)); - return (affinity == DOWN) - ? add_stretchability (after->get_maybe_pure_property ("nonstaff-unrelatedstaff-spacing", pure, start, end), - LARGE_STRETCH) - : after->get_maybe_pure_property ("nonstaff-relatedstaff-spacing", pure, start, end); - } + { + Direction affinity = to_dir (after->get_maybe_pure_property ("staff-affinity", pure, start, end)); + return (affinity == DOWN) + ? add_stretchability (after->get_maybe_pure_property ("nonstaff-unrelatedstaff-spacing", pure, start, end), + LARGE_STRETCH) + : after->get_maybe_pure_property ("nonstaff-relatedstaff-spacing", pure, start, end); + } } else { if (is_spaceable (after)) - { - Direction affinity = to_dir (before->get_maybe_pure_property ("staff-affinity", pure, start, end)); - return (affinity == UP) - ? add_stretchability (before->get_maybe_pure_property ("nonstaff-unrelatedstaff-spacing", pure, start, end), - LARGE_STRETCH) - : before->get_maybe_pure_property ("nonstaff-relatedstaff-spacing", pure, start, end); - } + { + Direction affinity = to_dir (before->get_maybe_pure_property ("staff-affinity", pure, start, end)); + return (affinity == UP) + ? add_stretchability (before->get_maybe_pure_property ("nonstaff-unrelatedstaff-spacing", pure, start, end), + LARGE_STRETCH) + : before->get_maybe_pure_property ("nonstaff-relatedstaff-spacing", pure, start, end); + } else - { - Direction before_affinity = to_dir (before->get_maybe_pure_property ("staff-affinity", pure, start, end)); - Direction after_affinity = to_dir (after->get_maybe_pure_property ("staff-affinity", pure, start, end)); - static bool warned = false; - if (after_affinity > before_affinity - && !warned && !pure) - { - warning (_ ("staff-affinities should only decrease")); - warned = true; - } - if (before_affinity != UP) - return before->get_maybe_pure_property ("nonstaff-nonstaff-spacing", pure, start, end); - else if (after_affinity != DOWN) - return before->get_maybe_pure_property ("nonstaff-nonstaff-spacing", pure, start, end); - return add_stretchability (before->get_maybe_pure_property ("nonstaff-unrelatedstaff-spacing", pure, start, end), - LARGE_STRETCH); - } + { + Direction before_affinity = to_dir (before->get_maybe_pure_property ("staff-affinity", pure, start, end)); + Direction after_affinity = to_dir (after->get_maybe_pure_property ("staff-affinity", pure, start, end)); + static bool warned = false; + if (after_affinity > before_affinity + && !warned && !pure) + { + warning (_ ("staff-affinities should only decrease")); + warned = true; + } + if (before_affinity != UP) + return before->get_maybe_pure_property ("nonstaff-nonstaff-spacing", pure, start, end); + else if (after_affinity != DOWN) + return before->get_maybe_pure_property ("nonstaff-nonstaff-spacing", pure, start, end); + return add_stretchability (before->get_maybe_pure_property ("nonstaff-unrelatedstaff-spacing", pure, start, end), + LARGE_STRETCH); + } } assert (0); @@ -1061,7 +1061,7 @@ Page_layout_problem::get_spacing_spec (Grob *before, Grob *after, bool pure, int } void -Page_layout_problem::alter_spring_from_spacing_spec (SCM spec, Spring* spring) +Page_layout_problem::alter_spring_from_spacing_spec (SCM spec, Spring *spring) { Real space; Real stretch; @@ -1076,17 +1076,17 @@ Page_layout_problem::alter_spring_from_spacing_spec (SCM spec, Spring* spring) spring->set_inverse_stretch_strength (stretch); } -vector<Grob*> -Page_layout_problem::filter_dead_elements (vector<Grob*> const& input) +vector<Grob *> +Page_layout_problem::filter_dead_elements (vector<Grob *> const &input) { - vector<Grob*> output; + vector<Grob *> output; for (vsize i = 0; i < input.size (); ++i) { if (Hara_kiri_group_spanner::has_interface (input[i])) - Hara_kiri_group_spanner::consider_suicide (input[i]); + Hara_kiri_group_spanner::consider_suicide (input[i]); if (input[i]->is_live ()) - output.push_back (input[i]); + output.push_back (input[i]); } return output; diff --git a/lily/page-marker-scheme.cc b/lily/page-marker-scheme.cc index 09bb3abdfe..4a63442147 100644 --- a/lily/page-marker-scheme.cc +++ b/lily/page-marker-scheme.cc @@ -20,9 +20,9 @@ #include "page-marker.hh" LY_DEFINE (ly_make_page_permission_marker, "ly:make-page-permission-marker", - 2, 0, 0, - (SCM symbol, SCM permission), - "Return page marker with page breaking and turning permissions.") + 2, 0, 0, + (SCM symbol, SCM permission), + "Return page marker with page breaking and turning permissions.") { LY_ASSERT_TYPE (ly_is_symbol, symbol, 1); Page_marker *page_marker = new Page_marker (); @@ -31,9 +31,9 @@ LY_DEFINE (ly_make_page_permission_marker, "ly:make-page-permission-marker", } LY_DEFINE (ly_make_page_label_marker, "ly:make-page-label-marker", - 1, 0, 0, - (SCM label), - "Return page marker with label @var{label}.") + 1, 0, 0, + (SCM label), + "Return page marker with label @var{label}.") { LY_ASSERT_TYPE (ly_is_symbol, label, 1); Page_marker *page_marker = new Page_marker (); diff --git a/lily/page-spacing-result.cc b/lily/page-spacing-result.cc index 827dbd4444..6768310eb2 100644 --- a/lily/page-spacing-result.cc +++ b/lily/page-spacing-result.cc @@ -2,7 +2,7 @@ This file is part of LilyPond, the GNU music typesetter. Copyright (C) 2007--2011 Han-Wen Nienhuys <hanwen@lilypond.org> - + LilyPond is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,7 +31,7 @@ Page_spacing_result::Page_spacing_result () vsize Page_spacing_result::page_count () const { - return systems_per_page_.size(); + return systems_per_page_.size (); } Real @@ -48,8 +48,8 @@ Page_spacing_result::average_force () const void Page_spacing_result::print () const { - printf ("penalty %lf, demerits %lf\n" , penalty_, demerits_); + printf ("penalty %lf, demerits %lf\n", penalty_, demerits_); for (vsize i = 0; i < page_count (); i++) printf (" %d: #sys=%d, force=%lf\n", int (i), int (systems_per_page_[i]), - force_[i]); + force_[i]); } diff --git a/lily/page-spacing.cc b/lily/page-spacing.cc index bae7ae6fb7..3255006633 100644 --- a/lily/page-spacing.cc +++ b/lily/page-spacing.cc @@ -28,14 +28,14 @@ void Page_spacing::calc_force () { Real height = page_height_ - - breaker_->min_whitespace_at_top_of_page (first_line_) - - breaker_->min_whitespace_at_bottom_of_page (last_line_); + - breaker_->min_whitespace_at_top_of_page (first_line_) + - breaker_->min_whitespace_at_bottom_of_page (last_line_); if (rod_height_ + last_line_.bottom_padding_ >= height) force_ = -infinity_f; else force_ = (height - rod_height_ - last_line_.bottom_padding_ - spring_len_) - / max (0.1, inverse_spring_k_); + / max (0.1, inverse_spring_k_); } void @@ -87,9 +87,9 @@ Page_spacing::account_for_footnotes (Line_details const &line) } return (footnote_height - - (has_footnotes_ - ? breaker_->footnote_padding () + breaker_->footnote_footer_padding () - : 0.0)); + - (has_footnotes_ + ? breaker_->footnote_padding () + breaker_->footnote_footer_padding () + : 0.0)); } void @@ -102,7 +102,7 @@ Page_spacing::prepend_system (const Line_details &line) rod_height_ -= first_line_.full_height (); rod_height_ += first_line_.tallness_; - rod_height_ += line.full_height(); + rod_height_ += line.full_height (); rod_height_ += account_for_footnotes (line); inverse_spring_k_ += line.inverse_hooke_; @@ -119,7 +119,6 @@ Page_spacing::clear () has_footnotes_ = false; } - Page_spacer::Page_spacer (vector<Line_details> const &lines, vsize first_page_num, Page_breaking const *breaker) : lines_ (lines) { @@ -137,18 +136,18 @@ Page_spacer::solve () { simple_state_.resize (lines_.size ()); for (vsize i = 0; i < lines_.size (); ++i) - calc_subproblem (VPOS, i); + calc_subproblem (VPOS, i); } Page_spacing_result ret; ret.penalty_ = simple_state_.back ().penalty_ - + lines_.back ().page_penalty_ + lines_.back ().turn_penalty_; + + lines_.back ().page_penalty_ + lines_.back ().turn_penalty_; ret.system_count_status_ = simple_state_.back ().system_count_status_; vsize system = lines_.size () - 1; while (system != VPOS) { - Page_spacing_node const& cur = simple_state_[system]; + Page_spacing_node const &cur = simple_state_[system]; vsize system_count = (cur.prev_ == VPOS) ? system + 1 : system - cur.prev_; ret.force_.push_back (cur.force_); @@ -174,45 +173,45 @@ Page_spacer::solve (vsize page_count) vsize extra_systems = 0; vsize extra_pages = 0; - if (isinf (state_.at (system, page_count-1).demerits_)) + if (isinf (state_.at (system, page_count - 1).demerits_)) { programming_error ("tried to space systems on a bad number of pages"); /* Usually, this means that we tried to cram too many systems into - to few pages. To avoid crashing, we look for the largest number of - systems that we can fit properly onto the right number of pages. - All the systems that don't fit get tacked onto the last page. + to few pages. To avoid crashing, we look for the largest number of + systems that we can fit properly onto the right number of pages. + All the systems that don't fit get tacked onto the last page. */ vsize i; - for (i = system; isinf (state_.at (i, page_count-1).demerits_) && i; i--) - ; + for (i = system; isinf (state_.at (i, page_count - 1).demerits_) && i; i--) + ; if (i) - { - extra_systems = system - i; - system = i; - } + { + extra_systems = system - i; + system = i; + } else - { - /* try chopping off pages from the end */ - vsize j; - for (j = page_count; j && isinf (state_.at (system, j-1).demerits_); j--) - ; - - if (j) - { - extra_pages = page_count - j; - page_count = j; - } - else - return Page_spacing_result (); /* couldn't salvage it -- probably going to crash */ - } + { + /* try chopping off pages from the end */ + vsize j; + for (j = page_count; j && isinf (state_.at (system, j - 1).demerits_); j--) + ; + + if (j) + { + extra_pages = page_count - j; + page_count = j; + } + else + return Page_spacing_result (); /* couldn't salvage it -- probably going to crash */ + } } ret.force_.resize (page_count); ret.systems_per_page_.resize (page_count); - ret.system_count_status_ = state_.at (system, page_count-1).system_count_status_; - ret.penalty_ = state_.at (system, page_count-1).penalty_ - + lines_.back ().page_penalty_ + lines_.back ().turn_penalty_; + ret.system_count_status_ = state_.at (system, page_count - 1).system_count_status_; + ret.penalty_ = state_.at (system, page_count - 1).penalty_ + + lines_.back ().page_penalty_ + lines_.back ().turn_penalty_; ret.demerits_ = 0; for (vsize p = page_count; p--;) @@ -223,9 +222,9 @@ Page_spacer::solve (vsize page_count) ret.force_[p] = ps.force_; ret.demerits_ += ps.force_ * ps.force_; if (p == 0) - ret.systems_per_page_[p] = system + 1; + ret.systems_per_page_[p] = system + 1; else - ret.systems_per_page_[p] = system - ps.prev_; + ret.systems_per_page_[p] = system - ps.prev_; system = ps.prev_; } @@ -255,7 +254,7 @@ Page_spacer::resize (vsize page_count) for (vsize page = max_page_count_; page < page_count; page++) for (vsize line = page; line < lines_.size (); line++) if (!calc_subproblem (page, line)) - break; + break; max_page_count_ = page_count; } @@ -287,92 +286,92 @@ Page_spacer::calc_subproblem (vsize page, vsize line) vsize page_num = page == VPOS ? 0 : page; Real paper_height = breaker_->paper_height (); Page_spacing space (breaker_->page_height (page_num + first_page_num_, last), - breaker_); + breaker_); Page_spacing_node &cur = page == VPOS ? simple_state_[line] : state_.at (line, page); bool ragged = ragged_ || (ragged_last_ && last); int line_count = 0; - for (vsize page_start = line+1; page_start > page_num && page_start--;) + for (vsize page_start = line + 1; page_start > page_num && page_start--;) { Page_spacing_node const *prev = 0; if (page == VPOS) - { - if (page_start > 0) - { - prev = &simple_state_[page_start-1]; - space.resize (breaker_->page_height (prev->page_ + 1, last)); - } - else - space.resize (breaker_->page_height (first_page_num_, last)); - } + { + if (page_start > 0) + { + prev = &simple_state_[page_start - 1]; + space.resize (breaker_->page_height (prev->page_ + 1, last)); + } + else + space.resize (breaker_->page_height (first_page_num_, last)); + } else if (page > 0) - prev = &state_.at (page_start-1, page-1); + prev = &state_.at (page_start - 1, page - 1); space.prepend_system (lines_[page_start]); bool overfull = (space.rod_height_ > paper_height - || (ragged - && (space.rod_height_ + space.spring_len_ > paper_height))); + || (ragged + && (space.rod_height_ + space.spring_len_ > paper_height))); // This 'if' statement is a little hard to parse. It won't consider this configuration // if it is overfull unless the current configuration is the first one with this start // point. We also make an exception (and consider this configuration) if the previous // configuration we tried had fewer lines than min-systems-per-page. if (!breaker_->too_few_lines (line_count) - && page_start < line - && overfull) - break; + && page_start < line + && overfull) + break; line_count += lines_[page_start].compressed_nontitle_lines_count_; if (page > 0 || page_start == 0) - { - // If the last page is ragged, set its force to zero. This way, we will leave - // the last page half-empty rather than trying to balance things out - // (which only makes sense in non-ragged situations). - if (line == lines_.size () - 1 && ragged && last && space.force_ > 0) - space.force_ = 0; - - Real demerits = space.force_ * space.force_; - - // Clamp the demerits at BAD_SPACING_PENALTY, even if the page - // is overfull. This ensures that TERRIBLE_SPACING_PENALTY takes - // precedence over overfull pages. - demerits = min (demerits, BAD_SPACING_PENALTY); - demerits += (prev ? prev->demerits_ : 0); - - Real penalty = breaker_->line_count_penalty (line_count); - if (page_start > 0) - penalty += lines_[page_start-1].page_penalty_ - + (page % 2 == 0) ? lines_[page_start-1].turn_penalty_ : 0; - - /* Deal with widow/orphan lines */ - /* Last line of paragraph is first line on the new page */ - if ((page_start > 0) && - (page_start < lines_.size ()) && - (lines_[page_start].last_markup_line_)) - penalty += breaker_->orphan_penalty (); - /* First line of paragraph is last line on the previous page */ - if ((page_start > 0) && - (page_start < lines_.size ()) && - (lines_[page_start-1].first_markup_line_)) - penalty += breaker_->orphan_penalty (); - - demerits += penalty; - if (demerits < cur.demerits_ || page_start == line) - { - cur.demerits_ = demerits; - cur.force_ = space.force_; - cur.penalty_ = penalty + (prev ? prev->penalty_ : 0); - cur.system_count_status_ = breaker_->line_count_status (line_count) - | (prev ? prev->system_count_status_ : 0); - cur.prev_ = page_start - 1; - cur.page_ = prev ? prev->page_ + 1 : first_page_num_; - } - } + { + // If the last page is ragged, set its force to zero. This way, we will leave + // the last page half-empty rather than trying to balance things out + // (which only makes sense in non-ragged situations). + if (line == lines_.size () - 1 && ragged && last && space.force_ > 0) + space.force_ = 0; + + Real demerits = space.force_ * space.force_; + + // Clamp the demerits at BAD_SPACING_PENALTY, even if the page + // is overfull. This ensures that TERRIBLE_SPACING_PENALTY takes + // precedence over overfull pages. + demerits = min (demerits, BAD_SPACING_PENALTY); + demerits += (prev ? prev->demerits_ : 0); + + Real penalty = breaker_->line_count_penalty (line_count); + if (page_start > 0) + penalty += lines_[page_start - 1].page_penalty_ + + (page % 2 == 0) ? lines_[page_start - 1].turn_penalty_ : 0; + + /* Deal with widow/orphan lines */ + /* Last line of paragraph is first line on the new page */ + if ((page_start > 0) + && (page_start < lines_.size ()) + && (lines_[page_start].last_markup_line_)) + penalty += breaker_->orphan_penalty (); + /* First line of paragraph is last line on the previous page */ + if ((page_start > 0) + && (page_start < lines_.size ()) + && (lines_[page_start - 1].first_markup_line_)) + penalty += breaker_->orphan_penalty (); + + demerits += penalty; + if (demerits < cur.demerits_ || page_start == line) + { + cur.demerits_ = demerits; + cur.force_ = space.force_; + cur.penalty_ = penalty + (prev ? prev->penalty_ : 0); + cur.system_count_status_ = breaker_->line_count_status (line_count) + | (prev ? prev->system_count_status_ : 0); + cur.prev_ = page_start - 1; + cur.page_ = prev ? prev->page_ + 1 : first_page_num_; + } + } if (page_start > 0 - && lines_[page_start-1].page_permission_ == ly_symbol2scm ("force")) - break; + && lines_[page_start - 1].page_permission_ == ly_symbol2scm ("force")) + break; } return !isinf (cur.demerits_); } diff --git a/lily/page-turn-engraver.cc b/lily/page-turn-engraver.cc index 5d08a24b91..925a57c218 100644 --- a/lily/page-turn-engraver.cc +++ b/lily/page-turn-engraver.cc @@ -29,7 +29,8 @@ #include "translator.icc" -class Page_turn_event { +class Page_turn_event +{ public: SCM permission_; Real penalty_; @@ -56,8 +57,8 @@ public: if (intersect.is_empty ()) { - ret.push_back (*this); - return ret; + ret.push_back (*this); + return ret; } Real new_pen = max (penalty_, penalty.penalty_); @@ -88,7 +89,7 @@ class Page_turn_engraver : public Engraver /* the next 3 are in sync (ie. same number of elements, etc.) */ vector<Rational> breakable_moments_; - vector<Grob*> breakable_columns_; + vector<Grob *> breakable_columns_; vector<bool> special_barlines_; SCM max_permission (SCM perm1, SCM perm2); @@ -114,7 +115,7 @@ Page_turn_engraver::Page_turn_engraver () note_end_ = 0; } -Grob* +Grob * Page_turn_engraver::breakable_column (Page_turn_event const &brk) { vsize start = lower_bound (breakable_moments_, brk.duration_[LEFT], less<Rational> ()); @@ -147,9 +148,9 @@ Page_turn_engraver::acknowledge_note_head (Grob_info gi) Stream_event *cause = gi.event_cause (); Duration *dur_ptr = cause - ? unsmob_duration (cause->get_property ("duration")) - : 0; - + ? unsmob_duration (cause->get_property ("duration")) + : 0; + if (!dur_ptr) return; @@ -157,9 +158,9 @@ Page_turn_engraver::acknowledge_note_head (Grob_info gi) { Real pen = penalty ((now_mom () - rest_begin_).main_part_); if (!isinf (pen)) - automatic_breaks_.push_back (Page_turn_event (rest_begin_.main_part_, - now_mom ().main_part_, - ly_symbol2scm ("allow"), 0)); + automatic_breaks_.push_back (Page_turn_event (rest_begin_.main_part_, + now_mom ().main_part_, + ly_symbol2scm ("allow"), 0)); } if (rest_begin_ <= repeat_begin_) @@ -229,9 +230,9 @@ Page_turn_engraver::stop_translation_timestep () { SCM command = scm_car (cs); if (command == ly_symbol2scm ("start-repeat")) - start = true; + start = true; else if (command == ly_symbol2scm ("end-repeat")) - end = true; + end = true; } if (end && repeat_begin_.main_part_ >= Moment (0)) @@ -240,12 +241,12 @@ Page_turn_engraver::stop_translation_timestep () Real pen = penalty ((now_mom () - rest_begin_).main_part_ + repeat_begin_rest_length_); Moment *m = unsmob_moment (get_property ("minimumRepeatLengthForPageTurn")); if (m && *m > (now_mom () - repeat_begin_)) - pen = infinity_f; + pen = infinity_f; if (pen == infinity_f) - repeat_penalties_.push_back (Page_turn_event (repeat_begin_.main_part_, now, SCM_EOL, -infinity_f)); + repeat_penalties_.push_back (Page_turn_event (repeat_begin_.main_part_, now, SCM_EOL, -infinity_f)); else - repeat_penalties_.push_back (Page_turn_event (repeat_begin_.main_part_, now, ly_symbol2scm ("allow"), pen)); + repeat_penalties_.push_back (Page_turn_event (repeat_begin_.main_part_, now, ly_symbol2scm ("allow"), pen)); repeat_begin_ = Moment (-1); } @@ -284,30 +285,30 @@ Page_turn_engraver::finalize () /* find the next applicable repeat penalty */ for (; - rep_index < repeat_penalties_.size () - && repeat_penalties_[rep_index].duration_[RIGHT] <= brk.duration_[LEFT]; - rep_index++) - ; + rep_index < repeat_penalties_.size () + && repeat_penalties_[rep_index].duration_[RIGHT] <= brk.duration_[LEFT]; + rep_index++) + ; if (rep_index >= repeat_penalties_.size () - || brk.duration_[RIGHT] <= repeat_penalties_[rep_index].duration_[LEFT]) - auto_breaks.push_back (brk); + || brk.duration_[RIGHT] <= repeat_penalties_[rep_index].duration_[LEFT]) + auto_breaks.push_back (brk); else - { - vector<Page_turn_event> split = brk.penalize (repeat_penalties_[rep_index]); - - /* it's possible that the last of my newly-split events overlaps the next repeat_penalty, - in which case we need to refilter that event */ - if (rep_index + 1 < repeat_penalties_.size () - && split.size () - && split.back ().duration_[RIGHT] > repeat_penalties_[rep_index+1].duration_[LEFT]) - { - automatic_breaks_[i] = split.back (); - split.pop_back (); - i--; - } - auto_breaks.insert (auto_breaks.end (), split.begin (), split.end ()); - } + { + vector<Page_turn_event> split = brk.penalize (repeat_penalties_[rep_index]); + + /* it's possible that the last of my newly-split events overlaps the next repeat_penalty, + in which case we need to refilter that event */ + if (rep_index + 1 < repeat_penalties_.size () + && split.size () + && split.back ().duration_[RIGHT] > repeat_penalties_[rep_index + 1].duration_[LEFT]) + { + automatic_breaks_[i] = split.back (); + split.pop_back (); + i--; + } + auto_breaks.insert (auto_breaks.end (), split.begin (), split.end ()); + } } /* apply the automatic breaks */ @@ -316,12 +317,12 @@ Page_turn_engraver::finalize () Page_turn_event const &brk = auto_breaks[i]; Grob *pc = breakable_column (auto_breaks[i]); if (pc) - { - SCM perm = max_permission (pc->get_property ("page-turn-permission"), brk.permission_); - Real pen = min (robust_scm2double (pc->get_property ("page-turn-penalty"), infinity_f), brk.penalty_); - pc->set_property ("page-turn-permission", perm); - pc->set_property ("page-turn-penalty", scm_from_double (pen)); - } + { + SCM perm = max_permission (pc->get_property ("page-turn-permission"), brk.permission_); + Real pen = min (robust_scm2double (pc->get_property ("page-turn-penalty"), infinity_f), brk.penalty_); + pc->set_property ("page-turn-permission", perm); + pc->set_property ("page-turn-penalty", scm_from_double (pen)); + } } /* unless a manual break overrides it, allow a page turn at the end of the piece */ @@ -333,10 +334,10 @@ Page_turn_engraver::finalize () Page_turn_event const &brk = forced_breaks_[i]; Grob *pc = breakable_column (forced_breaks_[i]); if (pc) - { - pc->set_property ("page-turn-permission", brk.permission_); - pc->set_property ("page-turn-penalty", scm_from_double (brk.penalty_)); - } + { + pc->set_property ("page-turn-permission", brk.permission_); + pc->set_property ("page-turn-penalty", scm_from_double (brk.penalty_)); + } } } @@ -350,9 +351,9 @@ ADD_TRANSLATOR (Page_turn_engraver, "", /* read */ - "minimumPageTurnLength " - "minimumRepeatLengthForPageTurn ", + "minimumPageTurnLength " + "minimumRepeatLengthForPageTurn ", /* write */ "" - ); + ); diff --git a/lily/page-turn-page-breaking.cc b/lily/page-turn-page-breaking.cc index 07b61d92bf..3d9799cd7c 100644 --- a/lily/page-turn-page-breaking.cc +++ b/lily/page-turn-page-breaking.cc @@ -35,9 +35,9 @@ is_break (T *g) { bool turnable = scm_is_symbol (g->get_property ("page-turn-permission")); - if (turnable && - (!scm_is_symbol (g->get_property ("page-break-permission")) - || !scm_is_symbol (g->get_property ("line-break-permission")))) + if (turnable + && (!scm_is_symbol (g->get_property ("page-break-permission")) + || !scm_is_symbol (g->get_property ("line-break-permission")))) { programming_error ("found a page-turnable place which was not breakable"); turnable = false; @@ -57,9 +57,9 @@ Page_turn_page_breaking::~Page_turn_page_breaking () Page_turn_page_breaking::Break_node Page_turn_page_breaking::put_systems_on_pages (vsize start, - vsize end, - vsize configuration, - vsize page_number) + vsize end, + vsize configuration, + vsize page_number) { vsize min_p_count = min_page_count (configuration, page_number); bool auto_first = to_boolean (book_->paper_->c_variable ("auto-first-page-number")); @@ -87,9 +87,9 @@ Page_turn_page_breaking::put_systems_on_pages (vsize start, if (start == 0 && auto_first) { if (min_p_count % 2) - result = space_systems_on_n_or_one_more_pages (configuration, min_p_count, page_number, 0); + result = space_systems_on_n_or_one_more_pages (configuration, min_p_count, page_number, 0); else - result = space_systems_on_n_pages (configuration, min_p_count, page_number); + result = space_systems_on_n_pages (configuration, min_p_count, page_number); } else if (page_number % 2 == min_p_count % 2) result = space_systems_on_n_pages (configuration, min_p_count, page_number); @@ -110,7 +110,7 @@ Page_turn_page_breaking::put_systems_on_pages (vsize start, ret.too_many_lines_ = all_lines_stretched (configuration); ret.demerits_ = result.demerits_; if (start > 0) - ret.demerits_ += state_[start-1].demerits_; + ret.demerits_ += state_[start - 1].demerits_; return ret; } @@ -137,22 +137,22 @@ Page_turn_page_breaking::calc_subproblem (vsize ending_breakpoint) for (vsize start = end; start--;) { - if (start < end-1 - && breakpoint_property (start+1, "page-turn-permission") == ly_symbol2scm ("force")) - break; + if (start < end - 1 + && breakpoint_property (start + 1, "page-turn-permission") == ly_symbol2scm ("force")) + break; - if (start > 0 && best.demerits_ < state_[start-1].demerits_) + if (start > 0 && best.demerits_ < state_[start - 1].demerits_) continue; int p_num = robust_scm2int (book_->paper_->c_variable ("first-page-number"), 1); if (start > 0) { - /* except possibly for the first page, enforce the fact that first_page_number_ - should always be even (left hand page). - TODO: are there different conventions in right-to-left languages? - */ - p_num = state_[start-1].first_page_number_ + state_[start-1].page_count_; - p_num += p_num % 2; + /* except possibly for the first page, enforce the fact that first_page_number_ + should always be even (left hand page). + TODO: are there different conventions in right-to-left languages? + */ + p_num = state_[start - 1].first_page_number_ + state_[start - 1].page_count_; + p_num += p_num % 2; } Line_division min_division; @@ -165,14 +165,14 @@ Page_turn_page_breaking::calc_subproblem (vsize ending_breakpoint) bool ok_page = true; if (debug_page_breaking_scoring) - message (_f ("page-turn-page-breaking: breaking from %d to %d", (int) start, (int) end)); + message (_f ("page-turn-page-breaking: breaking from %d to %d", (int) start, (int) end)); /* heuristic: we've just added a breakpoint, we'll need at least as many systems as before */ min_sys_count = max (min_sys_count, prev_best_system_count); for (vsize sys_count = min_sys_count; sys_count <= max_sys_count && ok_page; sys_count++) { - set_current_breakpoints (start, end, sys_count, min_division, max_division); + set_current_breakpoints (start, end, sys_count, min_division, max_division); bool found = false; for (vsize i = 0; i < current_configuration_count (); i++) @@ -180,9 +180,9 @@ Page_turn_page_breaking::calc_subproblem (vsize ending_breakpoint) cur = put_systems_on_pages (start, end, i, p_num); if (isinf (cur.demerits_) - || (cur.page_count_ + (p_num % 2) > 2 - && (!isinf (this_start_best.demerits_)) - && total_page_count (cur) > total_page_count (this_start_best))) + || (cur.page_count_ + (p_num % 2) > 2 + && (!isinf (this_start_best.demerits_)) + && total_page_count (cur) > total_page_count (this_start_best))) { ok_page = false; break; @@ -190,16 +190,16 @@ Page_turn_page_breaking::calc_subproblem (vsize ending_breakpoint) if (cur.demerits_ < this_start_best.demerits_) { - if (debug_page_breaking_scoring) - print_break_node (cur); + if (debug_page_breaking_scoring) + print_break_node (cur); found = true; this_start_best = cur; prev_best_system_count = sys_count; - /* heuristic: if we increase the number of systems, we can bound the - division from below by our current best division */ - min_division = current_configuration (i); + /* heuristic: if we increase the number of systems, we can bound the + division from below by our current best division */ + min_division = current_configuration (i); } } if (!found && this_start_best.too_many_lines_) @@ -212,13 +212,13 @@ Page_turn_page_breaking::calc_subproblem (vsize ending_breakpoint) } if (start == 0 && end == 1 - && this_start_best.first_page_number_ == 1 - && this_start_best.page_count_ > 1) - warning (_ ("cannot fit the first page turn onto a single page." - " Consider setting first-page-number to an even number.")); + && this_start_best.first_page_number_ == 1 + && this_start_best.page_count_ > 1) + warning (_ ("cannot fit the first page turn onto a single page." + " Consider setting first-page-number to an even number.")); if (this_start_best.demerits_ < best.demerits_) - best = this_start_best; + best = this_start_best; } state_.push_back (best); } @@ -257,7 +257,7 @@ Page_turn_page_breaking::make_lines (vector<Break_node> *psoln) vector<Break_node> &soln = *psoln; for (vsize n = 0; n < soln.size (); n++) { - vsize start = n > 0 ? soln[n-1].break_pos_ : 0; + vsize start = n > 0 ? soln[n - 1].break_pos_ : 0; vsize end = soln[n].break_pos_; break_into_pieces (start, end, soln[n].div_); @@ -276,17 +276,17 @@ Page_turn_page_breaking::make_pages (vector<Break_node> const &soln, SCM systems for (vsize i = 0; i < soln.size (); i++) { for (vsize j = 0; j < soln[i].page_count_; j++) - lines_per_page.push_back (soln[i].system_count_[j]); + lines_per_page.push_back (soln[i].system_count_[j]); if (i + 1 < soln.size () && (soln[i].first_page_number_ + soln[i].page_count_) % 2) - /* add a blank page */ - lines_per_page.push_back (0); + /* add a blank page */ + lines_per_page.push_back (0); } /* this should only actually modify first-page-number if auto-first-page-number was true. */ book_->paper_->set_variable (ly_symbol2scm ("first-page-number"), - scm_from_int (soln[0].first_page_number_)); + scm_from_int (soln[0].first_page_number_)); return Page_breaking::make_pages (lines_per_page, systems); } diff --git a/lily/pango-font-scheme.cc b/lily/pango-font-scheme.cc index f2ae021912..7cde167aca 100644 --- a/lily/pango-font-scheme.cc +++ b/lily/pango-font-scheme.cc @@ -31,18 +31,18 @@ #include "stencil.hh" LY_DEFINE (ly_pango_font_p, "ly:pango-font?", - 1, 0, 0, - (SCM f), - "Is @var{f} a pango font?") + 1, 0, 0, + (SCM f), + "Is @var{f} a pango font?") { return scm_from_bool (dynamic_cast<Pango_font *> (unsmob_metrics (f))); } LY_DEFINE (ly_pango_font_physical_fonts, "ly:pango-font-physical-fonts", - 1, 0, 0, - (SCM f), - "Return alist of @code{(ps-name file-name font-index)} lists" - " for Pango font@tie{}@var{f}.") + 1, 0, 0, + (SCM f), + "Return alist of @code{(ps-name file-name font-index)} lists" + " for Pango font@tie{}@var{f}.") { Pango_font *pf = dynamic_cast<Pango_font *> (unsmob_metrics (f)); diff --git a/lily/pango-font.cc b/lily/pango-font.cc index 26f2e53fb4..1be0656f75 100644 --- a/lily/pango-font.cc +++ b/lily/pango-font.cc @@ -33,7 +33,7 @@ #include "dimensions.hh" #include "file-name.hh" #include "international.hh" -#include "lookup.hh" // debugging +#include "lookup.hh" // debugging #include "main.hh" #include "string-convert.hh" #include "warn.hh" @@ -44,8 +44,8 @@ #include "stencil.hh" Pango_font::Pango_font (PangoFT2FontMap *fontmap, - PangoFontDescription const *description, - Real output_scale) + PangoFontDescription const *description, + Real output_scale) { // This line looks stupid, but if we don't initialize physical_font_tab_ before // we allocate memory in scm_c_make_hash_table, then that could trigger a garbage @@ -65,7 +65,7 @@ Pango_font::Pango_font (PangoFT2FontMap *fontmap, // --hwn output_scale_ = output_scale; scale_ = INCH_TO_BP - / (Real (PANGO_SCALE) * Real (PANGO_RESOLUTION) * output_scale); + / (Real (PANGO_SCALE) * Real (PANGO_RESOLUTION) * output_scale); // ugh. Should make this configurable. pango_context_set_language (context_, pango_language_from_string ("en_US")); @@ -82,13 +82,13 @@ Pango_font::~Pango_font () void Pango_font::register_font_file (string filename, - string ps_name, - int face_index) + string ps_name, + int face_index) { scm_hash_set_x (physical_font_tab_, - ly_string2scm (ps_name), - scm_list_2 (ly_string2scm (filename), - scm_from_int (face_index))); + ly_string2scm (ps_name), + scm_list_2 (ly_string2scm (filename), + scm_from_int (face_index))); } void @@ -99,14 +99,14 @@ Pango_font::derived_mark () const void get_glyph_index_name (char *s, - FT_ULong code) + FT_ULong code) { sprintf (s, "glyphIndex%lX", code); } void get_unicode_name (char *s, - FT_ULong code) + FT_ULong code) { if (code > 0xFFFF) sprintf (s, "u%lX", code); @@ -132,9 +132,9 @@ Pango_font::pango_item_string_stencil (PangoGlyphItem const *glyph_item) const FT_Face ftface = pango_fc_font_lock_face (fcfont); Box b (Interval (PANGO_LBEARING (logical_rect), - PANGO_RBEARING (logical_rect)), - Interval (-PANGO_DESCENT (ink_rect), - PANGO_ASCENT (ink_rect))); + PANGO_RBEARING (logical_rect)), + Interval (-PANGO_DESCENT (ink_rect), + PANGO_ASCENT (ink_rect))); b.scale (scale_); @@ -161,8 +161,7 @@ Pango_font::pango_item_string_stencil (PangoGlyphItem const *glyph_item) const Index_to_charcode_map const *cmap = 0; bool has_glyph_names = ftface->face_flags & FT_FACE_FLAG_GLYPH_NAMES; if (!has_glyph_names) - cmap = all_fonts_global->get_index_to_charcode_map ( - file_name, face_index, ftface); + cmap = all_fonts_global->get_index_to_charcode_map (file_name, face_index, ftface); bool is_ttf = string (FT_Get_X11_Font_Format (ftface)) == "TrueType"; bool cid_keyed = false; @@ -175,63 +174,61 @@ Pango_font::pango_item_string_stencil (PangoGlyphItem const *glyph_item) const PangoGlyphGeometry ggeo = pgi->geometry; /* - Zero-width characters are valid Unicode characters, - but glyph lookups need to be skipped. + Zero-width characters are valid Unicode characters, + but glyph lookups need to be skipped. */ if (!(pg ^ PANGO_GLYPH_EMPTY)) - continue; + continue; glyph_name[0] = '\0'; if (has_glyph_names) - { - FT_Error errorcode = FT_Get_Glyph_Name (ftface, pg, glyph_name, - GLYPH_NAME_LEN); - if (errorcode) - programming_error ( - _f ("FT_Get_Glyph_Name () error: %s", - freetype_error_string (errorcode).c_str ())); - } + { + FT_Error errorcode = FT_Get_Glyph_Name (ftface, pg, glyph_name, + GLYPH_NAME_LEN); + if (errorcode) + programming_error (_f ("FT_Get_Glyph_Name () error: %s", + freetype_error_string (errorcode).c_str ())); + } SCM char_id = SCM_EOL; if (glyph_name[0] == '\0' - && cmap - && is_ttf - && cmap->find (pg) != cmap->end ()) - { - FT_ULong char_code = cmap->find (pg)->second; - get_unicode_name (glyph_name, char_code); - } + && cmap + && is_ttf + && cmap->find (pg) != cmap->end ()) + { + FT_ULong char_code = cmap->find (pg)->second; + get_unicode_name (glyph_name, char_code); + } if (glyph_name[0] == '\0' && has_glyph_names) - { - programming_error ( - _f ("Glyph has no name, but font supports glyph naming.\n" - "Skipping glyph U+%0X, file %s", - pg, file_name.c_str ())); - continue; - } + { + programming_error (_f ("Glyph has no name, but font supports glyph naming.\n" + "Skipping glyph U+%0X, file %s", + pg, file_name.c_str ())); + continue; + } if (glyph_name == string (".notdef") && is_ttf) - glyph_name[0] = '\0'; + glyph_name[0] = '\0'; if (glyph_name[0] == '\0' && is_ttf) - // Access by glyph index directly. - get_glyph_index_name (glyph_name, pg); + // Access by glyph index directly. + get_glyph_index_name (glyph_name, pg); if (glyph_name[0] == '\0') - { - // CID entry - cid_keyed = true; - char_id = scm_from_uint32 (pg); - } + { + // CID entry + cid_keyed = true; + char_id = scm_from_uint32 (pg); + } else - char_id = scm_from_locale_string (glyph_name); + char_id = scm_from_locale_string (glyph_name); *tail = scm_cons (scm_list_4 (scm_from_double (ggeo.width * scale_), - scm_from_double (ggeo.x_offset * scale_), - scm_from_double (- ggeo.y_offset * scale_), - char_id), - SCM_EOL); + scm_from_double (ggeo.x_offset * scale_), + scm_from_double (- ggeo.y_offset * scale_), + char_id), + SCM_EOL); tail = SCM_CDRLOC (*tail); } @@ -239,7 +236,7 @@ Pango_font::pango_item_string_stencil (PangoGlyphItem const *glyph_item) const pgs = 0; PangoFontDescription *descr = pango_font_describe (pa->font); Real size = pango_font_description_get_size (descr) - / (Real (PANGO_SCALE)); + / (Real (PANGO_SCALE)); if (!ps_name_str0) warning (_f ("no PostScript font name for font `%s'", file_name)); @@ -248,23 +245,23 @@ Pango_font::pango_item_string_stencil (PangoGlyphItem const *glyph_item) const if (!ps_name_str0 && file_name != "" && (file_name.find (".otf") != NPOS - || file_name.find (".cff") != NPOS)) + || file_name.find (".cff") != NPOS)) { // UGH: kludge a PS name for OTF/CFF fonts. string name = file_name; ssize idx = file_name.find (".otf"); if (idx == NPOS) - idx = file_name.find (".cff"); + idx = file_name.find (".cff"); name = name.substr (0, idx); ssize slash_idx = name.rfind ('/'); if (slash_idx != NPOS) - { - slash_idx ++; - name = name.substr (slash_idx, - name.length () - slash_idx); - } + { + slash_idx++; + name = name.substr (slash_idx, + name.length () - slash_idx); + } string initial = name.substr (0, 1); initial = String_convert::to_upper (initial); @@ -278,15 +275,15 @@ Pango_font::pango_item_string_stencil (PangoGlyphItem const *glyph_item) const if (ps_name.length ()) { ((Pango_font *) this)->register_font_file (file_name, - ps_name, - face_index); + ps_name, + face_index); pango_fc_font_unlock_face (fcfont); SCM expr = scm_list_5 (ly_symbol2scm ("glyph-string"), - ly_string2scm (ps_name), - scm_from_double (size), - scm_from_bool (cid_keyed), - ly_quote_scm (glyph_exprs)); + ly_string2scm (ps_name), + scm_from_double (size), + scm_from_bool (cid_keyed), + ly_quote_scm (glyph_exprs)); return Stencil (b, expr); } @@ -305,7 +302,7 @@ extern bool music_strings_to_paths; Stencil Pango_font::text_stencil (Output_def * /* state */, - string str, bool music_string) const + string str, bool music_string) const { /* The text assigned to a PangoLayout is automatically divided @@ -325,26 +322,26 @@ Pango_font::text_stencil (Output_def * /* state */, GSList *layout_runs = line->runs; for (GSList *p = layout_runs; p; p = p->next) - { - PangoGlyphItem *item = (PangoGlyphItem *) p->data; - Stencil item_stencil = pango_item_string_stencil (item); + { + PangoGlyphItem *item = (PangoGlyphItem *) p->data; + Stencil item_stencil = pango_item_string_stencil (item); - item_stencil.translate_axis (last_x, X_AXIS); - last_x = item_stencil.extent (X_AXIS)[RIGHT]; + item_stencil.translate_axis (last_x, X_AXIS); + last_x = item_stencil.extent (X_AXIS)[RIGHT]; #if 0 // Check extents. - if (!item_stencil.extent_box ()[X_AXIS].is_empty ()) - { - Stencil frame = Lookup::frame (item_stencil.extent_box (), 0.1, 0.1); - Box empty; - empty.set_empty (); - Stencil dimless_frame (empty, frame.expr ()); - dest.add_stencil (frame); - } + if (!item_stencil.extent_box ()[X_AXIS].is_empty ()) + { + Stencil frame = Lookup::frame (item_stencil.extent_box (), 0.1, 0.1); + Box empty; + empty.set_empty (); + Stencil dimless_frame (empty, frame.expr ()); + dest.add_stencil (frame); + } #endif - dest.add_stencil (item_stencil); - } + dest.add_stencil (item_stencil); + } } string name = get_output_backend_name (); @@ -357,13 +354,13 @@ Pango_font::text_stencil (Output_def * /* state */, { SCM utf8_string = ly_module_lookup (mod, ly_symbol2scm ("utf-8-string")); /* - has_utf8_string should only be true when utf8_string is a - variable that is bound to a *named* procedure, i.e. not a - lambda expression. + has_utf8_string should only be true when utf8_string is a + variable that is bound to a *named* procedure, i.e. not a + lambda expression. */ if (utf8_string != SCM_BOOL_F - && scm_procedure_name (SCM_VARIABLE_REF (utf8_string)) != SCM_BOOL_F) - has_utf8_string = true; + && scm_procedure_name (SCM_VARIABLE_REF (utf8_string)) != SCM_BOOL_F) + has_utf8_string = true; } bool to_paths = music_strings_to_paths; @@ -378,8 +375,8 @@ Pango_font::text_stencil (Output_def * /* state */, { // For Pango based backends, we take a shortcut. SCM exp = scm_list_3 (ly_symbol2scm ("utf-8-string"), - ly_string2scm (description_string ()), - ly_string2scm (str)); + ly_string2scm (description_string ()), + ly_string2scm (str)); Box b (Interval (0, 0), Interval (0, 0)); b.unite (dest.extent_box ()); diff --git a/lily/pango-select-scheme.cc b/lily/pango-select-scheme.cc index 643d407820..e5a33ad67f 100644 --- a/lily/pango-select-scheme.cc +++ b/lily/pango-select-scheme.cc @@ -23,9 +23,9 @@ #include "pango-font.hh" LY_DEFINE (ly_make_pango_description_string, "ly:make-pango-description-string", - 2, 0, 0, (SCM chain, SCM size), - "Make a @code{PangoFontDescription} string for the property" - " alist @var{chain} at size @var{size}.") + 2, 0, 0, (SCM chain, SCM size), + "Make a @code{PangoFontDescription} string for the property" + " alist @var{chain} at size @var{size}.") { LY_ASSERT_TYPE (scm_is_number, size, 1); PangoFontDescription *pfd = properties_to_pango_description (chain, scm_to_double (size)); diff --git a/lily/pango-select.cc b/lily/pango-select.cc index a0832d4369..486fdba629 100644 --- a/lily/pango-select.cc +++ b/lily/pango-select.cc @@ -36,22 +36,22 @@ properties_to_pango_description (SCM chain, Real text_size) else { SCM family = ly_chain_assoc_get (ly_symbol2scm ("font-family"), chain, - SCM_BOOL_F); + SCM_BOOL_F); SCM variant = ly_chain_assoc_get (ly_symbol2scm ("font-shape"), chain, - SCM_BOOL_F); + SCM_BOOL_F); SCM style = ly_chain_assoc_get (ly_symbol2scm ("font-shape"), chain, - SCM_BOOL_F); + SCM_BOOL_F); SCM weight = ly_chain_assoc_get (ly_symbol2scm ("font-series"), chain, - SCM_BOOL_F); + SCM_BOOL_F); description - = symbols_to_pango_font_description (family, style, variant, weight, - SCM_BOOL_F); + = symbols_to_pango_font_description (family, style, variant, weight, + SCM_BOOL_F); } Real step = robust_scm2double (ly_chain_assoc_get (ly_symbol2scm ("font-size"), chain, SCM_BOOL_F), - 0.0); + 0.0); Real size = text_size * pow (2.0, step / 6.0); pango_font_description_set_size (description, gint (size * PANGO_SCALE)); @@ -63,14 +63,14 @@ select_pango_font (Output_def *layout, SCM chain) { PangoFontDescription *pfd = properties_to_pango_description (chain, - point_constant - * layout->get_dimension (ly_symbol2scm ("text-font-size"))); + point_constant + * layout->get_dimension (ly_symbol2scm ("text-font-size"))); char *str = pango_font_description_to_string (pfd); SCM scm_str = scm_from_locale_string (str); g_free (str); pango_font_description_free (pfd); - + return find_pango_font (layout, scm_str, 1.0); } @@ -81,7 +81,7 @@ symbol_to_pango_style (SCM style) if (style == ly_symbol2scm ("italic")) pstyle = PANGO_STYLE_ITALIC; else if (style == ly_symbol2scm ("oblique") - || style == ly_symbol2scm ("slanted")) + || style == ly_symbol2scm ("slanted")) pstyle = PANGO_STYLE_OBLIQUE; return pstyle; @@ -137,10 +137,10 @@ symbol_to_pango_stretch (SCM) // stretch) PangoFontDescription * symbols_to_pango_font_description (SCM family, - SCM style, - SCM variant, - SCM weight, - SCM stretch) + SCM style, + SCM variant, + SCM weight, + SCM stretch) { PangoFontDescription *description = pango_font_description_new (); @@ -151,15 +151,15 @@ symbols_to_pango_font_description (SCM family, family_str = ly_scm2string (family); pango_font_description_set_family (description, - family_str.c_str ()); + family_str.c_str ()); pango_font_description_set_style (description, - symbol_to_pango_style (style)); + symbol_to_pango_style (style)); pango_font_description_set_variant (description, - symbol_to_pango_variant (variant)); + symbol_to_pango_variant (variant)); pango_font_description_set_weight (description, - symbol_to_pango_weight (weight)); + symbol_to_pango_weight (weight)); pango_font_description_set_stretch (description, - symbol_to_pango_stretch (stretch)); + symbol_to_pango_stretch (stretch)); return description; } diff --git a/lily/paper-book-scheme.cc b/lily/paper-book-scheme.cc index 9158444530..b28c7a898a 100644 --- a/lily/paper-book-scheme.cc +++ b/lily/paper-book-scheme.cc @@ -22,16 +22,16 @@ #include "output-def.hh" LY_DEFINE (ly_paper_book_pages, "ly:paper-book-pages", - 1, 0, 0, (SCM pb), - "Return pages in @code{Paper_book} object @var{pb}.") + 1, 0, 0, (SCM pb), + "Return pages in @code{Paper_book} object @var{pb}.") { LY_ASSERT_SMOB (Paper_book, pb, 1); return unsmob_paper_book (pb)->pages (); } LY_DEFINE (ly_paper_book_scopes, "ly:paper-book-scopes", - 1, 0, 0, (SCM pb), - "Return scopes in @code{Paper_book} object @var{pb}.") + 1, 0, 0, (SCM pb), + "Return scopes in @code{Paper_book} object @var{pb}.") { LY_ASSERT_SMOB (Paper_book, pb, 1); Paper_book *book = unsmob_paper_book (pb); @@ -48,25 +48,25 @@ LY_DEFINE (ly_paper_book_scopes, "ly:paper-book-scopes", } LY_DEFINE (ly_paper_book_performances, "ly:paper-book-performances", - 1, 0, 0, (SCM pb), - "Return performances in @code{Paper_book} object @var{pb}.") + 1, 0, 0, (SCM pb), + "Return performances in @code{Paper_book} object @var{pb}.") { LY_ASSERT_SMOB (Paper_book, pb, 1); return unsmob_paper_book (pb)->performances (); } LY_DEFINE (ly_paper_book_systems, "ly:paper-book-systems", - 1, 0, 0, (SCM pb), - "Return systems in @code{Paper_book} object @var{pb}.") + 1, 0, 0, (SCM pb), + "Return systems in @code{Paper_book} object @var{pb}.") { LY_ASSERT_SMOB (Paper_book, pb, 1); return unsmob_paper_book (pb)->systems (); } LY_DEFINE (ly_paper_book_paper, "ly:paper-book-paper", - 1, 0, 0, (SCM pb), - "Return the paper output definition (@code{\\paper})" - " in @code{Paper_book} object @var{pb}.") + 1, 0, 0, (SCM pb), + "Return the paper output definition (@code{\\paper})" + " in @code{Paper_book} object @var{pb}.") { LY_ASSERT_SMOB (Paper_book, pb, 1); Paper_book *pbook = unsmob_paper_book (pb); @@ -74,9 +74,9 @@ LY_DEFINE (ly_paper_book_paper, "ly:paper-book-paper", } LY_DEFINE (ly_paper_book_header, "ly:paper-book-header", - 1, 0, 0, (SCM pb), - "Return the header definition (@code{\\header})" - " in @code{Paper_book} object @var{pb}.") + 1, 0, 0, (SCM pb), + "Return the header definition (@code{\\header})" + " in @code{Paper_book} object @var{pb}.") { LY_ASSERT_SMOB (Paper_book, pb, 1); Paper_book *pbook = unsmob_paper_book (pb); diff --git a/lily/paper-book.cc b/lily/paper-book.cc index 7fcea66c62..fc61386328 100644 --- a/lily/paper-book.cc +++ b/lily/paper-book.cc @@ -98,7 +98,7 @@ dump_fields () for (vsize i = dump_header_fieldnames_global.size (); i--;) fields = scm_cons (ly_symbol2scm (dump_header_fieldnames_global[i].c_str ()), - fields); + fields); return fields; } @@ -122,42 +122,42 @@ Paper_book::add_performance (SCM s) int Paper_book::output_aux (SCM output_channel, - bool is_last, - int *first_page_number, - int *first_performance_number) + bool is_last, + int *first_page_number, + int *first_performance_number) { int page_nb = 0; if (scm_is_pair (performances_)) { SCM proc = ly_lily_module_constant ("write-performances-midis"); - + scm_call_3 (proc, - performances (), - output_channel, - scm_from_long (*first_performance_number)); + performances (), + output_channel, + scm_from_long (*first_performance_number)); *first_performance_number += scm_ilength (performances_); } if (scm_is_pair (bookparts_)) { for (SCM p = bookparts_; scm_is_pair (p); p = scm_cdr (p)) - if (Paper_book *pbookpart = unsmob_paper_book (scm_car (p))) - { - bool is_last_part = (is_last && !scm_is_pair (scm_cdr (p))); - page_nb += pbookpart->output_aux (output_channel, - is_last_part, - first_page_number, - first_performance_number); - } + if (Paper_book *pbookpart = unsmob_paper_book (scm_car (p))) + { + bool is_last_part = (is_last && !scm_is_pair (scm_cdr (p))); + page_nb += pbookpart->output_aux (output_channel, + is_last_part, + first_page_number, + first_performance_number); + } } else { if (scores_ == SCM_EOL) - return 0; + return 0; paper_->set_variable (ly_symbol2scm ("first-page-number"), - scm_from_long (*first_page_number)); + scm_from_long (*first_page_number)); paper_->set_variable (ly_symbol2scm ("is-last-bookpart"), - ly_bool2scm (is_last)); + ly_bool2scm (is_last)); /* Generate all stencils to trigger font loads. */ page_nb = scm_ilength (pages ()); *first_page_number += page_nb; @@ -180,12 +180,12 @@ Paper_book::output (SCM output_channel) if (paper_->c_variable ("line-width") == SCM_UNDEFINED) paper_->set_variable (ly_symbol2scm ("line-width"), - paper_->c_variable ("paper-width")); - + paper_->c_variable ("paper-width")); + if (!output_aux (output_channel, - true, - &first_page_number, - &first_performance_number)) + true, + &first_page_number, + &first_performance_number)) return; SCM scopes = SCM_EOL; @@ -199,56 +199,56 @@ Paper_book::output (SCM output_channel) if (get_program_option ("print-pages")) { SCM framework = ly_module_lookup (mod, - ly_symbol2scm ("output-framework")); + ly_symbol2scm ("output-framework")); if (framework != SCM_BOOL_F) - { - SCM func = scm_variable_ref (framework); - scm_apply_0 (func, scm_list_n (output_channel, - self_scm (), - scopes, - dump_fields (), - SCM_UNDEFINED)); - } + { + SCM func = scm_variable_ref (framework); + scm_apply_0 (func, scm_list_n (output_channel, + self_scm (), + scopes, + dump_fields (), + SCM_UNDEFINED)); + } else - warning (_f ("program option -dprint-pages not supported by backend `%s'", - get_output_backend_name ())); + warning (_f ("program option -dprint-pages not supported by backend `%s'", + get_output_backend_name ())); } if (get_program_option ("preview")) { SCM framework - = ly_module_lookup (mod, ly_symbol2scm ("output-preview-framework")); + = ly_module_lookup (mod, ly_symbol2scm ("output-preview-framework")); if (framework != SCM_BOOL_F) - { - SCM func = scm_variable_ref (framework); - scm_apply_0 (func, scm_list_n (output_channel, - self_scm (), - scopes, - dump_fields (), - SCM_UNDEFINED)); - } + { + SCM func = scm_variable_ref (framework); + scm_apply_0 (func, scm_list_n (output_channel, + self_scm (), + scopes, + dump_fields (), + SCM_UNDEFINED)); + } else - warning (_f ("program option -dpreview not supported by backend `%s'", - get_output_backend_name ())); + warning (_f ("program option -dpreview not supported by backend `%s'", + get_output_backend_name ())); } } void Paper_book::classic_output_aux (SCM output, - int *first_performance_number) + int *first_performance_number) { if (scm_is_pair (performances_)) { SCM proc = ly_lily_module_constant ("write-performances-midis"); scm_call_3 (proc, - performances (), - output, - scm_from_long (*first_performance_number)); + performances (), + output, + scm_from_long (*first_performance_number)); *first_performance_number += scm_ilength (performances_); } - + /* Generate all stencils to trigger font loads. */ systems (); } @@ -274,10 +274,10 @@ Paper_book::classic_output (SCM output) func = scm_variable_ref (func); scm_apply_0 (func, scm_list_n (output, - self_scm (), - scopes, - dump_fields (), - SCM_UNDEFINED)); + self_scm (), + scopes, + dump_fields (), + SCM_UNDEFINED)); progress_indication ("\n"); } @@ -296,8 +296,8 @@ Paper_book::book_title () SCM tit = SCM_EOL; if (ly_is_procedure (title_func)) tit = scm_call_2 (title_func, - paper_->self_scm (), - scopes); + paper_->self_scm (), + scopes); if (unsmob_stencil (tit)) title = *unsmob_stencil (tit); @@ -325,8 +325,8 @@ Paper_book::score_title (SCM header) SCM tit = SCM_EOL; if (ly_is_procedure (title_func)) tit = scm_call_2 (title_func, - paper_->self_scm (), - scopes); + paper_->self_scm (), + scopes); if (unsmob_stencil (tit)) title = *unsmob_stencil (tit); @@ -344,11 +344,11 @@ set_page_permission (SCM sys, SCM symbol, SCM permission) { vector<Grob *> cols = ps->get_columns (); if (cols.size ()) - { - Paper_column *col = dynamic_cast<Paper_column *> (cols.back ()); - col->set_property (symbol, permission); - col->find_prebroken_piece (LEFT)->set_property (symbol, permission); - } + { + Paper_column *col = dynamic_cast<Paper_column *> (cols.back ()); + col->set_property (symbol, permission); + col->find_prebroken_piece (LEFT)->set_property (symbol, permission); + } } else if (Prob *pb = unsmob_prob (sys)) pb->set_property (symbol, permission); @@ -365,19 +365,19 @@ set_system_penalty (SCM sys, SCM header) { SCM force = ly_module_lookup (header, ly_symbol2scm ("breakbefore")); if (SCM_VARIABLEP (force) - && scm_is_bool (SCM_VARIABLE_REF (force))) - { - if (to_boolean (SCM_VARIABLE_REF (force))) - { - set_page_permission (sys, ly_symbol2scm ("page-break-permission"), - ly_symbol2scm ("force")); - set_page_permission (sys, ly_symbol2scm ("line-break-permission"), - ly_symbol2scm ("force")); - } - else - set_page_permission (sys, ly_symbol2scm ("page-break-permission"), - SCM_EOL); - } + && scm_is_bool (SCM_VARIABLE_REF (force))) + { + if (to_boolean (SCM_VARIABLE_REF (force))) + { + set_page_permission (sys, ly_symbol2scm ("page-break-permission"), + ly_symbol2scm ("force")); + set_page_permission (sys, ly_symbol2scm ("line-break-permission"), + ly_symbol2scm ("force")); + } + else + set_page_permission (sys, ly_symbol2scm ("page-break-permission"), + SCM_EOL); + } } } @@ -386,24 +386,24 @@ set_labels (SCM sys, SCM labels) { if (Paper_score *ps = dynamic_cast<Paper_score *> (unsmob_music_output (sys))) { - vector<Grob*> cols = ps->get_columns (); + vector<Grob *> cols = ps->get_columns (); if (cols.size ()) - { - Paper_column *col = dynamic_cast<Paper_column *> (cols[0]); - col->set_property ("labels", - scm_append_x (scm_list_2 (col->get_property ("labels"), - labels))); - Paper_column *col_right - = dynamic_cast<Paper_column *> (col->find_prebroken_piece (RIGHT)); - col_right->set_property ("labels", - scm_append_x (scm_list_2 (col_right->get_property ("labels"), - labels))); - } + { + Paper_column *col = dynamic_cast<Paper_column *> (cols[0]); + col->set_property ("labels", + scm_append_x (scm_list_2 (col->get_property ("labels"), + labels))); + Paper_column *col_right + = dynamic_cast<Paper_column *> (col->find_prebroken_piece (RIGHT)); + col_right->set_property ("labels", + scm_append_x (scm_list_2 (col_right->get_property ("labels"), + labels))); + } } else if (Prob *pb = unsmob_prob (sys)) - pb->set_property ("labels", - scm_append_x (scm_list_2 (pb->get_property ("labels"), - labels))); + pb->set_property ("labels", + scm_append_x (scm_list_2 (pb->get_property ("labels"), + labels))); } SCM @@ -415,11 +415,11 @@ Paper_book::get_score_title (SCM header) if (!title.is_empty ()) { /* - TODO: this should come from the \layout {} block, which should - override settings from \paper {} + TODO: this should come from the \layout {} block, which should + override settings from \paper {} */ SCM props - = paper_->lookup_variable (ly_symbol2scm ("score-title-properties")); + = paper_->lookup_variable (ly_symbol2scm ("score-title-properties")); Prob *ps = make_paper_system (props); paper_system_set_stencil (ps, title); @@ -429,7 +429,6 @@ Paper_book::get_score_title (SCM header) return SCM_BOOL_F; } - SCM Paper_book::get_system_specs () { @@ -439,7 +438,7 @@ Paper_book::get_system_specs () if (!title.is_empty ()) { SCM props - = paper_->lookup_variable (ly_symbol2scm ("book-title-properties")); + = paper_->lookup_variable (ly_symbol2scm ("book-title-properties")); Prob *ps = make_paper_system (props); paper_system_set_stencil (ps, title); @@ -449,7 +448,7 @@ Paper_book::get_system_specs () SCM page_properties = scm_call_1 (ly_lily_module_constant ("layout-extract-page-properties"), - paper_->self_scm ()); + paper_->self_scm ()); SCM interpret_markup_list = ly_lily_module_constant ("interpret-markup-list"); SCM header = SCM_EOL; @@ -457,115 +456,115 @@ Paper_book::get_system_specs () for (SCM s = scm_reverse (scores_); scm_is_pair (s); s = scm_cdr (s)) { if (ly_is_module (scm_car (s))) - { - header = scm_car (s); - if (header_0_ == SCM_EOL) - header_0_ = header; - } + { + header = scm_car (s); + if (header_0_ == SCM_EOL) + header_0_ = header; + } else if (Page_marker *page_marker = unsmob_page_marker (scm_car (s))) - { - /* page markers are used to set page breaking/turning permission, - or to place bookmarking labels */ - if (scm_is_symbol (page_marker->permission_symbol ())) - { - /* set previous element page break or turn permission */ - if (scm_is_pair (system_specs)) - set_page_permission (scm_car (system_specs), - page_marker->permission_symbol (), - page_marker->permission_value ()); - } - if (scm_is_symbol (page_marker->label ())) - { - /* The next element label is to be set */ - labels = scm_cons (page_marker->label (), labels); - } - } + { + /* page markers are used to set page breaking/turning permission, + or to place bookmarking labels */ + if (scm_is_symbol (page_marker->permission_symbol ())) + { + /* set previous element page break or turn permission */ + if (scm_is_pair (system_specs)) + set_page_permission (scm_car (system_specs), + page_marker->permission_symbol (), + page_marker->permission_value ()); + } + if (scm_is_symbol (page_marker->label ())) + { + /* The next element label is to be set */ + labels = scm_cons (page_marker->label (), labels); + } + } else if (Music_output *mop = unsmob_music_output (scm_car (s))) - { - if (Paper_score *pscore = dynamic_cast<Paper_score *> (mop)) - { - SCM title = get_score_title (header); - - if (scm_is_pair (system_specs)) - set_system_penalty (scm_car (system_specs), header); - - if (unsmob_prob (title)) - { - system_specs = scm_cons (title, system_specs); - unsmob_prob (title)->unprotect (); - } - - header = SCM_EOL; - system_specs = scm_cons (pscore->self_scm (), system_specs); - if (scm_is_pair (labels)) - { - set_labels (scm_car (system_specs), labels); - labels = SCM_EOL; - } - } - else - { - /* - Ignore MIDI - */ - } - } + { + if (Paper_score *pscore = dynamic_cast<Paper_score *> (mop)) + { + SCM title = get_score_title (header); + + if (scm_is_pair (system_specs)) + set_system_penalty (scm_car (system_specs), header); + + if (unsmob_prob (title)) + { + system_specs = scm_cons (title, system_specs); + unsmob_prob (title)->unprotect (); + } + + header = SCM_EOL; + system_specs = scm_cons (pscore->self_scm (), system_specs); + if (scm_is_pair (labels)) + { + set_labels (scm_car (system_specs), labels); + labels = SCM_EOL; + } + } + else + { + /* + Ignore MIDI + */ + } + } else if (Text_interface::is_markup_list (scm_car (s))) - { - SCM texts = scm_call_3 (interpret_markup_list, - paper_->self_scm (), - page_properties, - scm_car (s)); - Prob *first = 0; - Prob *last = 0; - for (SCM list = texts; scm_is_pair (list); list = scm_cdr (list)) - { - SCM t = scm_car (list); - // TODO: init props - Prob *ps = make_paper_system (SCM_EOL); - ps->set_property ("page-break-permission", - ly_symbol2scm ("allow")); - ps->set_property ("page-turn-permission", - ly_symbol2scm ("allow")); - ps->set_property ("last-markup-line", SCM_BOOL_F); - ps->set_property ("first-markup-line", SCM_BOOL_F); - - paper_system_set_stencil (ps, *unsmob_stencil (t)); - - SCM footnotes = get_footnotes (unsmob_stencil (t)->expr ()); - ps->set_property ("footnotes", footnotes); - ps->set_property ("is-title", SCM_BOOL_T); - if (list == texts) - first = ps; - else - { - // last line so far, in a multi-line paragraph - last = ps; - //Place closely to previous line, no stretching. - ps->set_property ("tight-spacing", SCM_BOOL_T); - } - system_specs = scm_cons (ps->self_scm (), system_specs); - ps->unprotect (); - - if (scm_is_pair (labels)) - { - set_labels (scm_car (system_specs), labels); - labels = SCM_EOL; - } - // FIXME: figure out penalty. - //set_system_penalty (ps, scores_[i].header_); - } - /* Set properties to avoid widowed/orphaned lines. - Single-line markup_lists are excluded, but in future - we may want to add the case of a very short, single line. */ - if (first && last) - { - last->set_property ("last-markup-line", SCM_BOOL_T); - first->set_property ("first-markup-line", SCM_BOOL_T); - } - } + { + SCM texts = scm_call_3 (interpret_markup_list, + paper_->self_scm (), + page_properties, + scm_car (s)); + Prob *first = 0; + Prob *last = 0; + for (SCM list = texts; scm_is_pair (list); list = scm_cdr (list)) + { + SCM t = scm_car (list); + // TODO: init props + Prob *ps = make_paper_system (SCM_EOL); + ps->set_property ("page-break-permission", + ly_symbol2scm ("allow")); + ps->set_property ("page-turn-permission", + ly_symbol2scm ("allow")); + ps->set_property ("last-markup-line", SCM_BOOL_F); + ps->set_property ("first-markup-line", SCM_BOOL_F); + + paper_system_set_stencil (ps, *unsmob_stencil (t)); + + SCM footnotes = get_footnotes (unsmob_stencil (t)->expr ()); + ps->set_property ("footnotes", footnotes); + ps->set_property ("is-title", SCM_BOOL_T); + if (list == texts) + first = ps; + else + { + // last line so far, in a multi-line paragraph + last = ps; + //Place closely to previous line, no stretching. + ps->set_property ("tight-spacing", SCM_BOOL_T); + } + system_specs = scm_cons (ps->self_scm (), system_specs); + ps->unprotect (); + + if (scm_is_pair (labels)) + { + set_labels (scm_car (system_specs), labels); + labels = SCM_EOL; + } + // FIXME: figure out penalty. + //set_system_penalty (ps, scores_[i].header_); + } + /* Set properties to avoid widowed/orphaned lines. + Single-line markup_lists are excluded, but in future + we may want to add the case of a very short, single line. */ + if (first && last) + { + last->set_property ("last-markup-line", SCM_BOOL_T); + first->set_property ("first-markup-line", SCM_BOOL_T); + } + } else - assert (0); + assert (0); } system_specs = scm_reverse_x (system_specs, SCM_EOL); @@ -582,55 +581,55 @@ Paper_book::systems () if (scm_is_pair (bookparts_)) { for (SCM p = bookparts_; scm_is_pair (p); p = scm_cdr (p)) - if (Paper_book *pbookpart = unsmob_paper_book (scm_car (p))) - systems_ = scm_append_x (scm_list_2 (systems_, - pbookpart->systems ())); + if (Paper_book *pbookpart = unsmob_paper_book (scm_car (p))) + systems_ = scm_append_x (scm_list_2 (systems_, + pbookpart->systems ())); } else { SCM specs = get_system_specs (); for (SCM s = specs; scm_is_pair (s); s = scm_cdr (s)) - { - if (Paper_score *pscore - = dynamic_cast<Paper_score *> (unsmob_music_output (scm_car (s)))) - { - SCM system_list - = scm_vector_to_list (pscore->get_paper_systems ()); - - system_list = scm_reverse (system_list); - systems_ = scm_append (scm_list_2 (system_list, systems_)); - } - else - { - systems_ = scm_cons (scm_car (s), systems_); - } - } + { + if (Paper_score * pscore + = dynamic_cast<Paper_score *> (unsmob_music_output (scm_car (s)))) + { + SCM system_list + = scm_vector_to_list (pscore->get_paper_systems ()); + + system_list = scm_reverse (system_list); + systems_ = scm_append (scm_list_2 (system_list, systems_)); + } + else + { + systems_ = scm_cons (scm_car (s), systems_); + } + } systems_ = scm_reverse (systems_); /* backwards compatibility for the old page breaker */ int i = 0; Prob *last = 0; for (SCM s = systems_; scm_is_pair (s); s = scm_cdr (s)) - { - Prob *ps = unsmob_prob (scm_car (s)); - ps->set_property ("number", scm_from_int (++i)); - - if (last - && to_boolean (last->get_property ("is-title")) - && !scm_is_number (ps->get_property ("penalty"))) - ps->set_property ("penalty", scm_from_int (10000)); - last = ps; - - if (scm_is_pair (scm_cdr (s))) - { - SCM perm = ps->get_property ("page-break-permission"); - Prob *next = unsmob_prob (scm_cadr (s)); - if (perm == SCM_EOL) - next->set_property ("penalty", scm_from_int (10001)); - else if (perm == ly_symbol2scm ("force")) - next->set_property ("penalty", scm_from_int (-10001)); - } - } + { + Prob *ps = unsmob_prob (scm_car (s)); + ps->set_property ("number", scm_from_int (++i)); + + if (last + && to_boolean (last->get_property ("is-title")) + && !scm_is_number (ps->get_property ("penalty"))) + ps->set_property ("penalty", scm_from_int (10000)); + last = ps; + + if (scm_is_pair (scm_cdr (s))) + { + SCM perm = ps->get_property ("page-break-permission"); + Prob *next = unsmob_prob (scm_cadr (s)); + if (perm == SCM_EOL) + next->set_property ("penalty", scm_from_int (10001)); + else if (perm == ly_symbol2scm ("force")) + next->set_property ("penalty", scm_from_int (-10001)); + } + } } return systems_; @@ -646,8 +645,8 @@ Paper_book::pages () if (scm_is_pair (bookparts_)) { for (SCM p = bookparts_; scm_is_pair (p); p = scm_cdr (p)) - if (Paper_book *pbookpart = unsmob_paper_book (scm_car (p))) - pages_ = scm_append_x (scm_list_2 (pages_, pbookpart->pages ())); + if (Paper_book *pbookpart = unsmob_paper_book (scm_car (p))) + pages_ = scm_append_x (scm_list_2 (pages_, pbookpart->pages ())); } else if (scm_is_pair (scores_)) { @@ -655,19 +654,19 @@ Paper_book::pages () pages_ = scm_apply_0 (page_breaking, scm_list_1 (self_scm ())); SCM post_process = paper_->c_variable ("page-post-process"); if (ly_is_procedure (post_process)) - scm_apply_2 (post_process, paper_->self_scm (), pages_, SCM_EOL); + scm_apply_2 (post_process, paper_->self_scm (), pages_, SCM_EOL); /* set systems_ from the pages */ if (systems_ == SCM_BOOL_F) - { - systems_ = SCM_EOL; - for (SCM p = pages_; scm_is_pair (p); p = scm_cdr (p)) - { - Prob *page = unsmob_prob (scm_car (p)); - SCM systems = page->get_property ("lines"); - systems_ = scm_append (scm_list_2 (systems_, systems)); - } - } + { + systems_ = SCM_EOL; + for (SCM p = pages_; scm_is_pair (p); p = scm_cdr (p)) + { + Prob *page = unsmob_prob (scm_car (p)); + SCM systems = page->get_property ("lines"); + systems_ = scm_append (scm_list_2 (systems_, systems)); + } + } } return pages_; } diff --git a/lily/paper-column-engraver.cc b/lily/paper-column-engraver.cc index 8b2b550f2f..31b8023bef 100644 --- a/lily/paper-column-engraver.cc +++ b/lily/paper-column-engraver.cc @@ -36,7 +36,7 @@ Paper_column_engraver::Paper_column_engraver () { - last_moment_.main_part_ = Rational (-1,1); + last_moment_.main_part_ = Rational (-1, 1); command_column_ = 0; musical_column_ = 0; breaks_ = 0; @@ -62,7 +62,7 @@ Paper_column_engraver::finalize () if (command_column_) { if (!scm_is_symbol (command_column_->get_property ("line-break-permission"))) - command_column_->set_property ("line-break-permission", ly_symbol2scm ("allow")); + command_column_->set_property ("line-break-permission", ly_symbol2scm ("allow")); system_->set_bound (RIGHT, command_column_); } } @@ -75,7 +75,7 @@ Paper_column_engraver::make_columns () */ Paper_column *p1 = make_paper_column ("NonMusicalPaperColumn"); Paper_column *p2 = make_paper_column ("PaperColumn"); - /* + /* The columns are timestamped with now_mom () in stop_translation_timestep. Cannot happen now, because the first column is sometimes created before now_mom is initialised. @@ -104,21 +104,21 @@ void Paper_column_engraver::acknowledge_staff_spacing (Grob_info gi) { Pointer_group_interface::add_grob (command_column_, - ly_symbol2scm ("spacing-wishes"), - gi.grob ()); + ly_symbol2scm ("spacing-wishes"), + gi.grob ()); } void Paper_column_engraver::acknowledge_note_spacing (Grob_info gi) { Pointer_group_interface::add_grob (musical_column_, - ly_symbol2scm ("spacing-wishes"), - gi.grob ()); + ly_symbol2scm ("spacing-wishes"), + gi.grob ()); } void Paper_column_engraver::set_columns (Paper_column *new_command, - Paper_column *new_musical) + Paper_column *new_musical) { command_column_ = new_command; musical_column_ = new_musical; @@ -156,12 +156,12 @@ Paper_column_engraver::process_music () string name = ly_scm2string (scm_symbol_to_string (name_sym)); size_t end = name.rfind ("-event"); if (end) - prefix = name.substr (0, end); + prefix = name.substr (0, end); else - { - programming_error ("Paper_column_engraver doesn't know about this break-event"); - return; - } + { + programming_error ("Paper_column_engraver doesn't know about this break-event"); + return; + } string perm_str = prefix + "-permission"; string pen_str = prefix + "-penalty"; @@ -171,16 +171,16 @@ Paper_column_engraver::process_music () SCM perm = break_events_[i]->get_property ("break-permission"); if (scm_is_number (pen)) - { - Real new_pen = robust_scm2double (cur_pen, 0.0) + scm_to_double (pen); - command_column_->set_property (pen_str.c_str (), scm_from_double (new_pen)); - command_column_->set_property (perm_str.c_str (), ly_symbol2scm ("allow")); - } + { + Real new_pen = robust_scm2double (cur_pen, 0.0) + scm_to_double (pen); + command_column_->set_property (pen_str.c_str (), scm_from_double (new_pen)); + command_column_->set_property (perm_str.c_str (), ly_symbol2scm ("allow")); + } else - command_column_->set_property (perm_str.c_str (), perm); + command_column_->set_property (perm_str.c_str (), perm); } - for (vsize i = 0 ; i < label_events_.size () ; i ++) + for (vsize i = 0; i < label_events_.size (); i++) { SCM label = label_events_[i]->get_property ("page-label"); SCM labels = command_column_->get_property ("labels"); @@ -188,7 +188,7 @@ Paper_column_engraver::process_music () } bool start_of_measure = (last_moment_.main_part_ != now_mom ().main_part_ - && !measure_position (context ()).main_part_); + && !measure_position (context ()).main_part_); /* We can't do this in start_translation_timestep (), since time sig @@ -199,9 +199,9 @@ Paper_column_engraver::process_music () Moment mlen = Moment (measure_length (context ())); Grob *column = unsmob_grob (get_property ("currentCommandColumn")); if (column) - column->set_property ("measure-length", mlen.smobbed_copy ()); + column->set_property ("measure-length", mlen.smobbed_copy ()); else - programming_error ("No command column?"); + programming_error ("No command column?"); } } @@ -221,37 +221,37 @@ Paper_column_engraver::stop_translation_timestep () Grob *col = Item::is_non_musical (elem) ? command_column_ : musical_column_; if (!elem->get_parent (X_AXIS)) - elem->set_parent (col, X_AXIS); + elem->set_parent (col, X_AXIS); if (!unsmob_grob (elem->get_object ("axis-group-parent-X"))) - elem->set_object ("axis-group-parent-X", col->self_scm ()); + elem->set_object ("axis-group-parent-X", col->self_scm ()); if (Accidental_placement::has_interface (elem)) - Separation_item::add_conditional_item (col, elem); + Separation_item::add_conditional_item (col, elem); else if (!Accidental_interface::has_interface (elem)) - Separation_item::add_item (col, elem); + Separation_item::add_item (col, elem); } items_.clear (); if (to_boolean (get_property ("forbidBreak")) - && breaks_) /* don't honour forbidBreak if it occurs on the first moment of a score */ + && breaks_) /* don't honour forbidBreak if it occurs on the first moment of a score */ { command_column_->set_property ("page-turn-permission", SCM_EOL); command_column_->set_property ("page-break-permission", SCM_EOL); command_column_->set_property ("line-break-permission", SCM_EOL); for (vsize i = 0; i < break_events_.size (); i++) - { - SCM perm = break_events_[i]->get_property ("break-permission"); - if (perm == ly_symbol2scm ("force") || perm == ly_symbol2scm ("allow")) - warning (_ ("forced break was overridden by some other event, " - "should you be using bar checks?")); - } + { + SCM perm = break_events_[i]->get_property ("break-permission"); + if (perm == ly_symbol2scm ("force") || perm == ly_symbol2scm ("allow")) + warning (_ ("forced break was overridden by some other event, " + "should you be using bar checks?")); + } } else if (Paper_column::is_breakable (command_column_)) { breaks_++; - if (! (breaks_%8)) - progress_indication ("[" + to_string (breaks_) + "]"); + if (! (breaks_ % 8)) + progress_indication ("[" + to_string (breaks_) + "]"); } context ()->get_score_context ()->unset_property (ly_symbol2scm ("forbidBreak")); @@ -266,7 +266,7 @@ Paper_column_engraver::stop_translation_timestep () && scm_is_integer (barnum)) { SCM where = scm_cons (barnum, - mpos); + mpos); command_column_->set_property ("rhythmic-location", where); musical_column_->set_property ("rhythmic-location", where); @@ -288,27 +288,27 @@ ADD_ACKNOWLEDGER (Paper_column_engraver, note_spacing); ADD_ACKNOWLEDGER (Paper_column_engraver, staff_spacing); ADD_TRANSLATOR (Paper_column_engraver, - /* doc */ - "Take care of generating columns.\n" - "\n" - "This engraver decides whether a column is breakable. The" - " default is that a column is always breakable. However," - " every @code{Bar_engraver} that does not have a barline at a" - " certain point will set @code{forbidBreaks} in the score" - " context to stop line breaks. In practice, this means that" - " you can make a break point by creating a bar line (assuming" - " that there are no beams or notes that prevent a break" - " point).", - - /* create */ - "PaperColumn " - "NonMusicalPaperColumn ", - - /* read */ + /* doc */ + "Take care of generating columns.\n" + "\n" + "This engraver decides whether a column is breakable. The" + " default is that a column is always breakable. However," + " every @code{Bar_engraver} that does not have a barline at a" + " certain point will set @code{forbidBreaks} in the score" + " context to stop line breaks. In practice, this means that" + " you can make a break point by creating a bar line (assuming" + " that there are no beams or notes that prevent a break" + " point).", + + /* create */ + "PaperColumn " + "NonMusicalPaperColumn ", + + /* read */ "forbidBreak ", - /* write */ + /* write */ "forbidBreak " - "currentCommandColumn " - "currentMusicalColumn " - ); + "currentCommandColumn " + "currentMusicalColumn " + ); diff --git a/lily/paper-column.cc b/lily/paper-column.cc index f81818ea68..271a752a26 100644 --- a/lily/paper-column.cc +++ b/lily/paper-column.cc @@ -98,15 +98,15 @@ Paper_column::Paper_column (Paper_column const &src) int Paper_column::compare (Grob *const &a, - Grob *const &b) + Grob *const &b) { return sign (dynamic_cast<Paper_column *> (a)->rank_ - - dynamic_cast<Paper_column *> (b)->rank_); + - dynamic_cast<Paper_column *> (b)->rank_); } bool Paper_column::less_than (Grob *const &a, - Grob *const &b) + Grob *const &b) { Paper_column *pa = dynamic_cast<Paper_column *> (a); Paper_column *pb = dynamic_cast<Paper_column *> (b); @@ -173,7 +173,7 @@ Paper_column::minimum_distance (Grob *left, Grob *right) { Skyline_pair *sp = Skyline_pair::unsmob (cols[d]->get_property ("horizontal-skylines")); if (sp) - skys[d] = (*sp)[-d]; + skys[d] = (*sp)[-d]; } while (flip (&d) != LEFT); @@ -198,20 +198,20 @@ Paper_column::break_align_width (Grob *me, SCM align_sym) || align_sym == ly_symbol2scm ("break-alignment")) align = Pointer_group_interface::find_grob (me, ly_symbol2scm ("elements"), - (align_sym == ly_symbol2scm ("staff-bar") - ? Bar_line::non_empty_barline - : Break_alignment_interface::has_interface)); + (align_sym == ly_symbol2scm ("staff-bar") + ? Bar_line::non_empty_barline + : Break_alignment_interface::has_interface)); else { extract_grob_set (me, "elements", elts); for (vsize i = 0; i < elts.size (); i++) - { - if (elts[i]->get_property ("break-align-symbol") == align_sym) - { - align = elts[i]; - break; - } - } + { + if (elts[i]->get_property ("break-align-symbol") == align_sym) + { + align = elts[i]; + break; + } + } } if (!align) @@ -238,22 +238,22 @@ Paper_column::print (SCM p) SCM properties = Font_interface::text_font_alist_chain (me); SCM scm_mol = Text_interface::interpret_markup (me->layout ()->self_scm (), - properties, - ly_string2scm (r)); + properties, + ly_string2scm (r)); SCM when_mol = Text_interface::interpret_markup (me->layout ()->self_scm (), - properties, - ly_string2scm (when)); + properties, + ly_string2scm (when)); Stencil t = *unsmob_stencil (scm_mol); t.add_at_edge (Y_AXIS, DOWN, *unsmob_stencil (when_mol), 0.1); t.align_to (X_AXIS, CENTER); t.align_to (Y_AXIS, DOWN); Stencil l = Lookup::filled_box (Box (Interval (-0.01, 0.01), - Interval (-2, -1))); + Interval (-2, -1))); SCM small_letters = scm_cons (scm_acons (ly_symbol2scm ("font-size"), - scm_from_int (-6), SCM_EOL), - properties); + scm_from_int (-6), SCM_EOL), + properties); int j = 0; for (SCM s = me->get_object ("ideal-distances"); @@ -261,11 +261,11 @@ Paper_column::print (SCM p) { Spring *sp = unsmob_spring (scm_caar (s)); if (!unsmob_grob (scm_cdar (s)) - || !unsmob_grob (scm_cdar (s))->get_system ()) - continue; + || !unsmob_grob (scm_cdar (s))->get_system ()) + continue; j++; - Real y = -j * 1 -3; + Real y = -j * 1 - 3; vector<Offset> pts; pts.push_back (Offset (0, y)); @@ -276,12 +276,12 @@ Paper_column::print (SCM p) Stencil head (musfont->find_by_name ("arrowheads.open.01")); SCM distance_stc = Text_interface::interpret_markup (me->layout ()->self_scm (), - small_letters, - ly_string2scm (String_convert::form_string ("%5.2lf", sp->distance ()))); + small_letters, + ly_string2scm (String_convert::form_string ("%5.2lf", sp->distance ()))); id_stencil.add_stencil (unsmob_stencil (distance_stc)->translated (Offset (sp->distance () / 3, y + 1))); id_stencil.add_stencil (head.translated (p2)); - id_stencil = id_stencil.in_color (0,0,1); + id_stencil = id_stencil.in_color (0, 0, 1); l.add_stencil (id_stencil); } @@ -291,11 +291,11 @@ Paper_column::print (SCM p) Real dist = scm_to_double (scm_cdar (s)); Grob *other = unsmob_grob (scm_caar (s)); if (!other || other->get_system () != me->get_system ()) - continue; + continue; j++; - Real y = -j * 1.0 -3.5; + Real y = -j * 1.0 - 3.5; vector<Offset> pts; pts.push_back (Offset (0, y)); @@ -308,13 +308,13 @@ Paper_column::print (SCM p) id_stencil.add_stencil (head); SCM distance_stc = Text_interface::interpret_markup (me->layout ()->self_scm (), - small_letters, - ly_string2scm (String_convert::form_string ("%5.2lf", - dist))); + small_letters, + ly_string2scm (String_convert::form_string ("%5.2lf", + dist))); id_stencil.add_stencil (unsmob_stencil (distance_stc)->translated (Offset (dist / 3, y - 1))); - id_stencil = id_stencil.in_color (1,0,0); + id_stencil = id_stencil.in_color (1, 0, 0); l.add_stencil (id_stencil); } t.add_stencil (l); @@ -347,8 +347,8 @@ Paper_column::before_line_breaking (SCM grob) Grob *g = array[i]; if (!g || !g->is_live ()) - /* UGH . potentially quadratic. */ - array.erase (array.begin () + i); + /* UGH . potentially quadratic. */ + array.erase (array.begin () + i); } return SCM_UNSPECIFIED; @@ -372,47 +372,47 @@ Paper_column::is_extraneous_column_from_ligature (Grob *me) for (vsize i = 0; i < elts.size (); i++) { if (Rhythmic_head::has_interface (elts[i])) - { - has_notehead = true; - if (dynamic_cast<Item *> (elts[i])->get_column () == me) - return false; - } + { + has_notehead = true; + if (dynamic_cast<Item *> (elts[i])->get_column () == me) + return false; + } } return has_notehead; } ADD_INTERFACE (Paper_column, - "@code{Paper_column} objects form the top-most X@tie{}parents" - " for items. There are two types of columns: musical and" - " non-musical, to which musical and non-musical objects are" - " attached respectively. The spacing engine determines the" - " X@tie{}positions of these objects.\n" - "\n" - "They are numbered, the first (leftmost) is column@tie{}0." - " Numbering happens before line breaking, and columns are not" - " renumbered after line breaking. Since many columns go" - " unused, you should only use the rank field to get ordering" - " information. Two adjacent columns may have non-adjacent" - " numbers.", - - /* properties */ - "between-cols " - "bounded-by-me " - "full-measure-extra-space " - "grace-spacing " - "labels " - "line-break-system-details " - "line-break-penalty " - "line-break-permission " - "maybe-loose " - "page-break-penalty " - "page-break-permission " - "page-turn-penalty " - "page-turn-permission " - "rhythmic-location " - "shortest-playing-duration " - "shortest-starter-duration " - "spacing " - "used " - "when "); + "@code{Paper_column} objects form the top-most X@tie{}parents" + " for items. There are two types of columns: musical and" + " non-musical, to which musical and non-musical objects are" + " attached respectively. The spacing engine determines the" + " X@tie{}positions of these objects.\n" + "\n" + "They are numbered, the first (leftmost) is column@tie{}0." + " Numbering happens before line breaking, and columns are not" + " renumbered after line breaking. Since many columns go" + " unused, you should only use the rank field to get ordering" + " information. Two adjacent columns may have non-adjacent" + " numbers.", + + /* properties */ + "between-cols " + "bounded-by-me " + "full-measure-extra-space " + "grace-spacing " + "labels " + "line-break-system-details " + "line-break-penalty " + "line-break-permission " + "maybe-loose " + "page-break-penalty " + "page-break-permission " + "page-turn-penalty " + "page-turn-permission " + "rhythmic-location " + "shortest-playing-duration " + "shortest-starter-duration " + "spacing " + "used " + "when "); diff --git a/lily/paper-def.cc b/lily/paper-def.cc index 14f1546d60..f45939ad46 100644 --- a/lily/paper-def.cc +++ b/lily/paper-def.cc @@ -93,15 +93,14 @@ find_pango_font (Output_def *layout, SCM descr, Real factor) = pango_font_description_from_string (scm_i_string_chars (descr)); pango_font_description_set_size (description, - gint (factor * - pango_font_description_get_size (description))); + gint (factor * + pango_font_description_get_size (description))); - Font_metric *fm = all_fonts_global->find_pango_font (description, - output_scale (layout)); + output_scale (layout)); pango_font_description_free (description); - + sizes = scm_acons (size_key, fm->self_scm (), sizes); scm_hash_set_x (table, descr, sizes); diff --git a/lily/paper-outputter-scheme.cc b/lily/paper-outputter-scheme.cc index be3d315cf1..652b8a6033 100644 --- a/lily/paper-outputter-scheme.cc +++ b/lily/paper-outputter-scheme.cc @@ -24,9 +24,9 @@ #include "warn.hh" LY_DEFINE (ly_make_paper_outputter, "ly:make-paper-outputter", - 2, 0, 0, (SCM port, SCM format), - "Create an outputter that evaluates within" - " @code{output-}@var{format}, writing to @var{port}.") + 2, 0, 0, (SCM port, SCM format), + "Create an outputter that evaluates within" + " @code{output-}@var{format}, writing to @var{port}.") { LY_ASSERT_TYPE (ly_is_port, port, 1); LY_ASSERT_TYPE (ly_is_symbol, format, 2); @@ -39,7 +39,7 @@ LY_DEFINE (ly_make_paper_outputter, "ly:make-paper-outputter", output_name = ly_scm2string (port_name); message (_f ("Layout output to `%s'...", - output_name.c_str ())); + output_name.c_str ())); progress_indication ("\n"); Paper_outputter *po = new Paper_outputter (port, f); @@ -50,10 +50,10 @@ LY_DEFINE (ly_make_paper_outputter, "ly:make-paper-outputter", /* FIXME: why is output_* wrapper called dump? */ LY_DEFINE (ly_outputter_dump_stencil, "ly:outputter-dump-stencil", - 2, 0, 0, (SCM outputter, SCM stencil), - "Dump stencil @var{expr} onto @var{outputter}.") + 2, 0, 0, (SCM outputter, SCM stencil), + "Dump stencil @var{expr} onto @var{outputter}.") { - + LY_ASSERT_SMOB (Paper_outputter, outputter, 1); LY_ASSERT_SMOB (Stencil, stencil, 2); @@ -65,8 +65,8 @@ LY_DEFINE (ly_outputter_dump_stencil, "ly:outputter-dump-stencil", } LY_DEFINE (ly_outputter_dump_string, "ly:outputter-dump-string", - 2, 0, 0, (SCM outputter, SCM str), - "Dump @var{str} onto @var{outputter}.") + 2, 0, 0, (SCM outputter, SCM str), + "Dump @var{str} onto @var{outputter}.") { LY_ASSERT_SMOB (Paper_outputter, outputter, 1); LY_ASSERT_TYPE (scm_is_string, str, 2); @@ -77,8 +77,8 @@ LY_DEFINE (ly_outputter_dump_string, "ly:outputter-dump-string", } LY_DEFINE (ly_outputter_port, "ly:outputter-port", - 1, 0, 0, (SCM outputter), - "Return output port for @var{outputter}.") + 1, 0, 0, (SCM outputter), + "Return output port for @var{outputter}.") { LY_ASSERT_SMOB (Paper_outputter, outputter, 1); Paper_outputter *po = unsmob_outputter (outputter); @@ -87,8 +87,8 @@ LY_DEFINE (ly_outputter_port, "ly:outputter-port", } LY_DEFINE (ly_outputter_close, "ly:outputter-close", - 1, 0, 0, (SCM outputter), - "Close port of @var{outputter}.") + 1, 0, 0, (SCM outputter), + "Close port of @var{outputter}.") { LY_ASSERT_SMOB (Paper_outputter, outputter, 1); Paper_outputter *po = unsmob_outputter (outputter); @@ -98,8 +98,8 @@ LY_DEFINE (ly_outputter_close, "ly:outputter-close", } LY_DEFINE (ly_outputter_output_scheme, "ly:outputter-output-scheme", - 2, 0, 0, (SCM outputter, SCM expr), - "Eval @var{expr} in module of @var{outputter}.") + 2, 0, 0, (SCM outputter, SCM expr), + "Eval @var{expr} in module of @var{outputter}.") { LY_ASSERT_SMOB (Paper_outputter, outputter, 1); Paper_outputter *po = unsmob_outputter (outputter); @@ -110,8 +110,8 @@ LY_DEFINE (ly_outputter_output_scheme, "ly:outputter-output-scheme", } LY_DEFINE (ly_outputter_module, "ly:outputter-module", - 1, 0, 0, (SCM outputter), - "Return output module of @var{outputter}.") + 1, 0, 0, (SCM outputter), + "Return output module of @var{outputter}.") { LY_ASSERT_SMOB (Paper_outputter, outputter, 1); diff --git a/lily/paper-outputter.cc b/lily/paper-outputter.cc index e08cbd6590..33657d60cb 100644 --- a/lily/paper-outputter.cc +++ b/lily/paper-outputter.cc @@ -74,8 +74,8 @@ Paper_outputter::mark_smob (SCM x) int Paper_outputter::print_smob (SCM /* x */, - SCM p, - scm_print_state *) + SCM p, + scm_print_state *) { scm_puts ("#<Paper_outputter>", p); return 1; @@ -122,7 +122,7 @@ void Paper_outputter::output_stencil (Stencil stil) { interpret_stencil_expression (stil.expr (), paper_outputter_dump, - (void *) this, Offset (0, 0)); + (void *) this, Offset (0, 0)); } void @@ -132,9 +132,9 @@ Paper_outputter::close () { scm_close_port (file_); /* - Remove the "warning" definitions for missing stencil - expressions so that we start fresh with the next \book - block. --pmccarty + Remove the "warning" definitions for missing stencil + expressions so that we start fresh with the next \book + block. --pmccarty */ SCM proc = ly_lily_module_constant ("remove-stencil-warnings"); scm_call_1 (proc, output_module_); diff --git a/lily/paper-score-scheme.cc b/lily/paper-score-scheme.cc index 033f1b6477..713393cca7 100644 --- a/lily/paper-score-scheme.cc +++ b/lily/paper-score-scheme.cc @@ -20,10 +20,10 @@ #include "paper-score.hh" LY_DEFINE (ly_paper_score_paper_systems, "ly:paper-score-paper-systems", - 1, 0, 0, - (SCM paper_score), - "Return vector of @code{paper_system} objects from" - " @var{paper-score}.") + 1, 0, 0, + (SCM paper_score), + "Return vector of @code{paper_system} objects from" + " @var{paper-score}.") { LY_ASSERT_TYPE (unsmob_paper_score, paper_score, 1); diff --git a/lily/paper-score.cc b/lily/paper-score.cc index 9b5e8aa7df..c9c3160260 100644 --- a/lily/paper-score.cc +++ b/lily/paper-score.cc @@ -78,14 +78,14 @@ Paper_score::find_break_indices () const for (vsize i = 0; i < cols_.size (); i++) { - Item *it = dynamic_cast<Item*> (cols_[i]); + Item *it = dynamic_cast<Item *> (cols_[i]); if (Paper_column::is_breakable (cols_[i]) - && (i == 0 || it->find_prebroken_piece (LEFT)) - && (i == cols_.size () - 1 || it->find_prebroken_piece (RIGHT))) - { - break_indices_.push_back (i); - break_ranks_.push_back (it->get_column ()->get_rank ()); - } + && (i == 0 || it->find_prebroken_piece (LEFT)) + && (i == cols_.size () - 1 || it->find_prebroken_piece (RIGHT))) + { + break_indices_.push_back (i); + break_ranks_.push_back (it->get_column ()->get_rank ()); + } } } @@ -97,7 +97,7 @@ Paper_score::get_break_indices () const return break_indices_; } -vector<Grob*> +vector<Grob *> Paper_score::get_columns () const { if (cols_.empty ()) @@ -133,8 +133,8 @@ Paper_score::process () { if (be_verbose_global) message (_f ("Element count %d (spanners %d) ", - system_->element_count (), - system_->spanner_count ())); + system_->element_count (), + system_->spanner_count ())); message (_ ("Preprocessing graphical objects...")); @@ -167,9 +167,8 @@ Paper_score::get_paper_systems () return paper_systems_; } - Paper_score * unsmob_paper_score (SCM x) { - return dynamic_cast<Paper_score*> (unsmob_music_output (x)); + return dynamic_cast<Paper_score *> (unsmob_music_output (x)); } diff --git a/lily/paper-system-scheme.cc b/lily/paper-system-scheme.cc index 4187cfa3db..7c4dc88d09 100644 --- a/lily/paper-system-scheme.cc +++ b/lily/paper-system-scheme.cc @@ -2,7 +2,7 @@ This file is part of LilyPond, the GNU music typesetter. Copyright (C) 2008--2011 Han-Wen Nienhuys <hanwen@lilypond.org> - + LilyPond is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,20 +21,20 @@ #include "prob.hh" #include "skyline-pair.hh" - + LY_DEFINE (ly_paper_system_p, "ly:paper-system?", - 1, 0, 0, (SCM obj), - "Is @var{obj} a C++ @code{Prob} object of type" - " @code{paper-system}?") + 1, 0, 0, (SCM obj), + "Is @var{obj} a C++ @code{Prob} object of type" + " @code{paper-system}?") { return ly_prob_type_p (obj, ly_symbol2scm ("paper-system")); } LY_DEFINE (ly_paper_system_minimum_distance, "ly:paper-system-minimum-distance", - 2, 0, 0, (SCM sys1, SCM sys2), - "Measure the minimum distance between these two paper-systems," - " using their stored skylines if possible and falling back to" - " their extents otherwise.") + 2, 0, 0, (SCM sys1, SCM sys2), + "Measure the minimum distance between these two paper-systems," + " using their stored skylines if possible and falling back to" + " their extents otherwise.") { Real ret = 0; Prob *p1 = unsmob_prob (sys1); diff --git a/lily/paper-system.cc b/lily/paper-system.cc index 437a0eb450..ba2583a009 100644 --- a/lily/paper-system.cc +++ b/lily/paper-system.cc @@ -31,9 +31,9 @@ make_paper_system (SCM immutable_init) /* TODO it might be interesting to split off the footnotes as well, ie. - - get_footnotes(SCM expr, SCM* footnotes, SCM* cleaned) - + + get_footnotes(SCM expr, SCM* footnotes, SCM* cleaned) + by doing it this way and overwriting the old expr in the caller, you can make sure nobody tries to handle footnotes differently downstream. @@ -51,7 +51,7 @@ get_footnotes (SCM expr) // we likely need to do something here...just don't know what... return SCM_EOL; } - + if (head == ly_symbol2scm ("combine-stencil")) { SCM out = SCM_EOL; @@ -77,7 +77,6 @@ get_footnotes (SCM expr) return SCM_EOL; } - void paper_system_set_stencil (Prob *prob, Stencil s) { diff --git a/lily/parenthesis-engraver.cc b/lily/parenthesis-engraver.cc index 1fe8005e4d..7c17c7504b 100644 --- a/lily/parenthesis-engraver.cc +++ b/lily/parenthesis-engraver.cc @@ -46,45 +46,45 @@ Parenthesis_engraver::acknowledge_grob (Grob_info info) if (Stream_event *ev = info.event_cause ()) { if (to_boolean (ev->get_property ("parenthesize"))) - { - if (Item *victim = dynamic_cast<Item*> (info.grob ())) - { - Engraver *eng = dynamic_cast<Engraver*> (info.origin_translator ()); - Item *paren = eng->make_item ("ParenthesesItem", victim->self_scm ()); - Pointer_group_interface::add_grob (paren, ly_symbol2scm ("elements"), victim); - - paren->set_parent (victim, Y_AXIS); - - Real size = robust_scm2double (paren->get_property ("font-size"), 0.0) - + robust_scm2double (victim->get_property ("font-size"), 0.0); - paren->set_property ("font-size", scm_from_double (size)); - - /* - TODO? - - enlarge victim to allow for parentheses space? - */ - } - else - { - programming_error ("Don't know how to parenthesize spanners."); - } - } + { + if (Item *victim = dynamic_cast<Item *> (info.grob ())) + { + Engraver *eng = dynamic_cast<Engraver *> (info.origin_translator ()); + Item *paren = eng->make_item ("ParenthesesItem", victim->self_scm ()); + Pointer_group_interface::add_grob (paren, ly_symbol2scm ("elements"), victim); + + paren->set_parent (victim, Y_AXIS); + + Real size = robust_scm2double (paren->get_property ("font-size"), 0.0) + + robust_scm2double (victim->get_property ("font-size"), 0.0); + paren->set_property ("font-size", scm_from_double (size)); + + /* + TODO? + + enlarge victim to allow for parentheses space? + */ + } + else + { + programming_error ("Don't know how to parenthesize spanners."); + } + } } } ADD_ACKNOWLEDGER (Parenthesis_engraver, grob); ADD_TRANSLATOR (Parenthesis_engraver, - /* doc */ - "Parenthesize objects whose music cause has the" - " @code{parenthesize} property.", - - /* create */ - "ParenthesesItem ", - - /* read */ - "", - - /* write */ - "" - ); + /* doc */ + "Parenthesize objects whose music cause has the" + " @code{parenthesize} property.", + + /* create */ + "ParenthesesItem ", + + /* read */ + "", + + /* write */ + "" + ); diff --git a/lily/parse-scm.cc b/lily/parse-scm.cc index b51dcb296a..f5092675b3 100644 --- a/lily/parse-scm.cc +++ b/lily/parse-scm.cc @@ -43,37 +43,36 @@ internal_ly_parse_scm (Parse_start *ps) scm_seek (port, scm_from_long (off), scm_from_long (SEEK_SET)); SCM from = scm_ftell (port); - scm_set_port_line_x (port, scm_from_int (ps->start_location_.line_number () -1)); - scm_set_port_column_x (port, scm_from_int (ps->start_location_.column_number () -1)); - + scm_set_port_line_x (port, scm_from_int (ps->start_location_.line_number () - 1)); + scm_set_port_column_x (port, scm_from_int (ps->start_location_.column_number () - 1)); + SCM answer = SCM_UNSPECIFIED; SCM form = scm_read (port); SCM to = scm_ftell (port); ps->nchars = scm_to_int (to) - scm_to_int (from); - /* Read expression from port. */ if (!SCM_EOF_OBJECT_P (form)) { if (ps->safe_) - { - static SCM module = SCM_BOOL_F; - if (module == SCM_BOOL_F) - { - SCM function = ly_lily_module_constant ("make-safe-lilypond-module"); - module = scm_call_0 (function); - } - - // We define the parser so trusted Scheme functions can - // access the real namespace underlying the parser. - if (ps->parser_) - scm_module_define (module, ly_symbol2scm ("parser"), - ps->parser_->self_scm()); - answer = scm_eval (form, module); - } + { + static SCM module = SCM_BOOL_F; + if (module == SCM_BOOL_F) + { + SCM function = ly_lily_module_constant ("make-safe-lilypond-module"); + module = scm_call_0 (function); + } + + // We define the parser so trusted Scheme functions can + // access the real namespace underlying the parser. + if (ps->parser_) + scm_module_define (module, ly_symbol2scm ("parser"), + ps->parser_->self_scm ()); + answer = scm_eval (form, module); + } else - answer = scm_primitive_eval (form); + answer = scm_primitive_eval (form); } /* Don't close the port here; if we re-enter this function via a @@ -115,10 +114,10 @@ protected_ly_parse_scm (Parse_start *ps) /* Catch #t : catch all Scheme level errors. */ - return scm_internal_catch (SCM_BOOL_T, - &catch_protected_parse_body, - (void *) ps, - &parse_handler, (void *) ps); + return scm_internal_catch (SCM_BOOL_T, + &catch_protected_parse_body, + (void *) ps, + &parse_handler, (void *) ps); } bool parse_protect_global = true; @@ -136,7 +135,7 @@ ly_parse_scm (char const *s, int *n, Input i, bool safe, Lily_parser *parser) ps.parser_ = parser; SCM ans = parse_protect_global ? protected_ly_parse_scm (&ps) - : internal_ly_parse_scm (&ps); + : internal_ly_parse_scm (&ps); *n = ps.nchars; return ans; diff --git a/lily/part-combine-engraver.cc b/lily/part-combine-engraver.cc index f12cfbad95..c6a3176f47 100644 --- a/lily/part-combine-engraver.cc +++ b/lily/part-combine-engraver.cc @@ -117,8 +117,8 @@ Part_combine_engraver::acknowledge_note_head (Grob_info i) Grob *t = text_; Side_position_interface::add_support (t, i.grob ()); if (Side_position_interface::get_axis (t) == X_AXIS - && !t->get_parent (Y_AXIS)) - t->set_parent (i.grob (), Y_AXIS); + && !t->get_parent (Y_AXIS)) + t->set_parent (i.grob (), Y_AXIS); } } @@ -140,20 +140,20 @@ Part_combine_engraver::stop_translation_timestep () ADD_ACKNOWLEDGER (Part_combine_engraver, note_head); ADD_ACKNOWLEDGER (Part_combine_engraver, stem); ADD_TRANSLATOR (Part_combine_engraver, - /* doc */ - "Part combine engraver for orchestral scores: Print markings" - " @q{a2}, @q{Solo}, @q{Solo II}, and @q{unisono}.", - - /* create */ - "CombineTextScript ", - - /* read */ - "printPartCombineTexts " - "partCombineTextsOnNote " - "soloText " - "soloIIText " - "aDueText ", - - /* write */ - "" - ); + /* doc */ + "Part combine engraver for orchestral scores: Print markings" + " @q{a2}, @q{Solo}, @q{Solo II}, and @q{unisono}.", + + /* create */ + "CombineTextScript ", + + /* read */ + "printPartCombineTexts " + "partCombineTextsOnNote " + "soloText " + "soloIIText " + "aDueText ", + + /* write */ + "" + ); diff --git a/lily/part-combine-iterator.cc b/lily/part-combine-iterator.cc index adbc2beb32..5bd85b05b3 100644 --- a/lily/part-combine-iterator.cc +++ b/lily/part-combine-iterator.cc @@ -26,14 +26,14 @@ #include "warn.hh" enum Outlet_type - { - CONTEXT_ONE, CONTEXT_TWO, - CONTEXT_SHARED, CONTEXT_SOLO, - CONTEXT_NULL, NUM_OUTLETS - }; +{ + CONTEXT_ONE, CONTEXT_TWO, + CONTEXT_SHARED, CONTEXT_SOLO, + CONTEXT_NULL, NUM_OUTLETS +}; -static const char *outlet_names_[NUM_OUTLETS] = - {"one", "two", "shared", "solo", "null"}; +static const char *outlet_names_[NUM_OUTLETS] + = {"one", "two", "shared", "solo", "null"}; class Part_combine_iterator : public Music_iterator { @@ -72,14 +72,14 @@ private: Stream_event *mmrest_event_; enum Status - { - APART, - TOGETHER, - SOLO1, - SOLO2, - UNISONO, - UNISILENCE, - }; + { + APART, + TOGETHER, + SOLO1, + SOLO2, + UNISONO, + UNISILENCE, + }; Status state_; Status playing_state_; @@ -94,7 +94,7 @@ private: Context_handle handles_[NUM_OUTLETS]; void substitute_both (Outlet_type to1, - Outlet_type to2); + Outlet_type to2); /* parameter is really Outlet_type */ void kill_mmrest (int in); @@ -118,7 +118,7 @@ Part_combine_iterator::do_quit () { Context *c = handles_[i].get_outlet (); if (c->is_alias (ly_symbol2scm ("Voice"))) - c->event_source ()->remove_listener (GET_LISTENER (set_busy), ly_symbol2scm ("music-event")); + c->event_source ()->remove_listener (GET_LISTENER (set_busy), ly_symbol2scm ("music-event")); handles_[i].set_context (0); } } @@ -128,7 +128,7 @@ Part_combine_iterator::Part_combine_iterator () mmrest_event_ = 0; unisono_event_ = 0; solo_two_event_ = 0; - solo_one_event_= 0; + solo_one_event_ = 0; first_iter_ = 0; second_iter_ = 0; @@ -148,7 +148,8 @@ Part_combine_iterator::derived_mark () const if (second_iter_) scm_gc_mark (second_iter_->self_scm ()); - Stream_event *ptrs[] = { + Stream_event *ptrs[] = + { unisono_event_, mmrest_event_, solo_two_event_, @@ -162,7 +163,7 @@ Part_combine_iterator::derived_mark () const void Part_combine_iterator::derived_substitute (Context *f, - Context *t) + Context *t) { if (first_iter_) first_iter_->substitute_outlet (f, t); @@ -189,7 +190,7 @@ Part_combine_iterator::ok () const void Part_combine_iterator::substitute_both (Outlet_type to1, - Outlet_type to2) + Outlet_type to2) { Outlet_type tos[] = {to1, to2}; @@ -198,14 +199,14 @@ Part_combine_iterator::substitute_both (Outlet_type to1, for (int i = 0; i < 2; i++) { for (int j = 0; j < NUM_OUTLETS; j++) - if (j != tos[i]) - mis[i]->substitute_outlet (handles_[j].get_outlet (), handles_[tos[i]].get_outlet ()); + if (j != tos[i]) + mis[i]->substitute_outlet (handles_[j].get_outlet (), handles_[tos[i]].get_outlet ()); } for (int j = 0; j < NUM_OUTLETS; j++) { if (j != to1 && j != to2) - kill_mmrest (j); + kill_mmrest (j); } } @@ -233,32 +234,31 @@ Part_combine_iterator::unisono (bool silent) else { /* - If we're coming from SOLO2 state, we might have kill mmrests - in the 1st voice, so in that case, we use the second voice - as a basis for events. + If we're coming from SOLO2 state, we might have kill mmrests + in the 1st voice, so in that case, we use the second voice + as a basis for events. */ Outlet_type c1 = (last_playing_ == SOLO2) ? CONTEXT_NULL : CONTEXT_SHARED; Outlet_type c2 = (last_playing_ == SOLO2) ? CONTEXT_SHARED : CONTEXT_NULL; substitute_both (c1, c2); kill_mmrest ((last_playing_ == SOLO2) - ? CONTEXT_ONE : CONTEXT_TWO); + ? CONTEXT_ONE : CONTEXT_TWO); kill_mmrest (CONTEXT_SHARED); if (playing_state_ != UNISONO - && newstate == UNISONO) - { - if (!unisono_event_) - { - unisono_event_ = new Stream_event (ly_symbol2scm ("unisono-event")); - unisono_event_->unprotect (); - } - - - Context *out = (last_playing_ == SOLO2 ? second_iter_ : first_iter_) - ->get_outlet (); - out->event_source ()->broadcast (unisono_event_); - playing_state_ = UNISONO; - } + && newstate == UNISONO) + { + if (!unisono_event_) + { + unisono_event_ = new Stream_event (ly_symbol2scm ("unisono-event")); + unisono_event_->unprotect (); + } + + Context *out = (last_playing_ == SOLO2 ? second_iter_ : first_iter_) + ->get_outlet (); + out->event_source ()->broadcast (unisono_event_); + playing_state_ = UNISONO; + } state_ = newstate; } } @@ -277,15 +277,15 @@ Part_combine_iterator::solo1 () kill_mmrest (CONTEXT_SHARED); if (playing_state_ != SOLO1) - { - if (!solo_one_event_) - { - solo_one_event_ = new Stream_event (ly_symbol2scm ("solo-one-event")); - solo_one_event_->unprotect (); - } - - first_iter_->get_outlet ()->event_source ()->broadcast (solo_one_event_); - } + { + if (!solo_one_event_) + { + solo_one_event_ = new Stream_event (ly_symbol2scm ("solo-one-event")); + solo_one_event_->unprotect (); + } + + first_iter_->get_outlet ()->event_source ()->broadcast (solo_one_event_); + } playing_state_ = SOLO1; } } @@ -302,16 +302,16 @@ Part_combine_iterator::solo2 () substitute_both (CONTEXT_NULL, CONTEXT_SOLO); if (playing_state_ != SOLO2) - { - if (!solo_two_event_) - { - solo_two_event_ = new Stream_event (ly_symbol2scm ("solo-two-event")); - solo_two_event_->unprotect (); - } - - second_iter_->get_outlet ()->event_source ()->broadcast (solo_two_event_); - playing_state_ = SOLO2; - } + { + if (!solo_two_event_) + { + solo_two_event_ = new Stream_event (ly_symbol2scm ("solo-two-event")); + solo_two_event_->unprotect (); + } + + second_iter_->get_outlet ()->event_source ()->broadcast (solo_two_event_); + playing_state_ = SOLO2; + } } } @@ -359,7 +359,7 @@ Part_combine_iterator::construct_children () c = c->find_create_context (type, outlet_names_[i], SCM_EOL); handles_[i].set_context (c); if (c->is_alias (ly_symbol2scm ("Voice"))) - c->event_source ()->add_listener (GET_LISTENER (set_busy), ly_symbol2scm ("music-event")); + c->event_source ()->add_listener (GET_LISTENER (set_busy), ly_symbol2scm ("music-event")); } SCM lst = get_music ()->get_property ("elements"); @@ -370,12 +370,12 @@ Part_combine_iterator::construct_children () set_context (two); second_iter_ = unsmob_iterator (get_iterator (unsmob_music (scm_cadr (lst)))); - /* Mimic all settings of voiceOne/voiceTwo for the two separate voices...*/ /* FIXME: Is there any way to use the definition of \voiceOne/\voiceTwo directly??? */ char const *syms[] - = { + = + { "Stem", "DynamicLineSpanner", "Tie", @@ -391,21 +391,21 @@ Part_combine_iterator::construct_children () { SCM sym = ly_symbol2scm (*p); execute_pushpop_property (one, sym, - ly_symbol2scm ("direction"), scm_from_int (1)); + ly_symbol2scm ("direction"), scm_from_int (1)); execute_pushpop_property (two, sym, - ly_symbol2scm ("direction"), scm_from_int (-1)); + ly_symbol2scm ("direction"), scm_from_int (-1)); } - /* Handle horizontal shifts for crossing notes */ + /* Handle horizontal shifts for crossing notes */ execute_pushpop_property (one, ly_symbol2scm ("NoteColumn"), - ly_symbol2scm ("horizontal-shift"), scm_from_int (0)); + ly_symbol2scm ("horizontal-shift"), scm_from_int (0)); execute_pushpop_property (two, ly_symbol2scm ("NoteColumn"), - ly_symbol2scm ("horizontal-shift"), scm_from_int (1)); - /* Also handle MultiMeasureRest positions for voice 1/2 */ + ly_symbol2scm ("horizontal-shift"), scm_from_int (1)); + /* Also handle MultiMeasureRest positions for voice 1/2 */ execute_pushpop_property (one, ly_symbol2scm ("MultiMeasureRest"), - ly_symbol2scm ("staff-position"), scm_from_int (4)); + ly_symbol2scm ("staff-position"), scm_from_int (4)); execute_pushpop_property (two, ly_symbol2scm ("MultiMeasureRest"), - ly_symbol2scm ("staff-position"), scm_from_int (-4)); + ly_symbol2scm ("staff-position"), scm_from_int (-4)); } @@ -453,30 +453,30 @@ Part_combine_iterator::process (Moment m) { splitm = unsmob_moment (scm_caar (split_list_)); if (splitm && *splitm + start_moment_ > now) - break; + break; SCM tag = scm_cdar (split_list_); if (tag == ly_symbol2scm ("chords")) - chords_together (); + chords_together (); else if (tag == ly_symbol2scm ("apart") - || tag == ly_symbol2scm ("apart-silence") - || tag == ly_symbol2scm ("apart-spanner")) - apart (tag == ly_symbol2scm ("apart-silence")); + || tag == ly_symbol2scm ("apart-silence") + || tag == ly_symbol2scm ("apart-spanner")) + apart (tag == ly_symbol2scm ("apart-silence")); else if (tag == ly_symbol2scm ("unisono")) - unisono (false); + unisono (false); else if (tag == ly_symbol2scm ("unisilence")) - unisono (true); + unisono (true); else if (tag == ly_symbol2scm ("solo1")) - solo1 (); + solo1 (); else if (tag == ly_symbol2scm ("solo2")) - solo2 (); + solo2 (); else if (scm_is_symbol (tag)) - { - string s = "Unknown split directive: " - + (scm_is_symbol (tag) ? ly_symbol2string (tag) : string ("not a symbol")); - programming_error (s); - } + { + string s = "Unknown split directive: " + + (scm_is_symbol (tag) ? ly_symbol2string (tag) : string ("not a symbol")); + programming_error (s); + } } if (first_iter_->ok ()) @@ -488,7 +488,7 @@ Part_combine_iterator::process (Moment m) if (second_iter_->ok ()) { if (try_process (second_iter_, m)) - last_playing_ = SOLO2; + last_playing_ = SOLO2; } } diff --git a/lily/partial-iterator.cc b/lily/partial-iterator.cc index d38a951465..bec4a358c2 100644 --- a/lily/partial-iterator.cc +++ b/lily/partial-iterator.cc @@ -28,21 +28,21 @@ class Partial_iterator : public Simple_music_iterator { public: DECLARE_SCHEME_CALLBACK (constructor, ()); - protected: +protected: virtual void process (Moment); }; void Partial_iterator::process (Moment m) { - if (Duration *dur + if (Duration * dur = unsmob_duration (get_music ()->get_property ("partial-duration"))) { Context *ctx = get_outlet (); Moment now = ctx->now_mom (); if (now.main_part_ > Rational (0)) - get_music ()->origin ()-> - warning (_ ("trying to use \\partial after the start of a piece")); + get_music ()->origin ()-> + warning (_ ("trying to use \\partial after the start of a piece")); Moment length = Moment (dur->get_length ()); now = Moment (0, now.grace_part_); ctx->set_property ("measurePosition", (now - length).smobbed_copy ()); diff --git a/lily/pdf-scheme.cc b/lily/pdf-scheme.cc index e813e08ec3..ecfe5c4f01 100644 --- a/lily/pdf-scheme.cc +++ b/lily/pdf-scheme.cc @@ -24,17 +24,16 @@ using namespace std; #include "warn.hh" #include "lily-guile.hh" - LY_DEFINE (ly_encode_string_for_pdf, "ly:encode-string-for-pdf", - 1, 0, 0, (SCM str), - "Encode the given string to either Latin1 (which is a subset of" - " the PDFDocEncoding) or if that's not possible to full UTF-16BE" - " with Byte-Order-Mark (BOM).") + 1, 0, 0, (SCM str), + "Encode the given string to either Latin1 (which is a subset of" + " the PDFDocEncoding) or if that's not possible to full UTF-16BE" + " with Byte-Order-Mark (BOM).") { LY_ASSERT_TYPE (scm_is_string, str, 1); char *p = ly_scm2str0 (str); char *g = NULL; - char const *charset="UTF-8"; // Input is ALWAYS UTF-8! + char const *charset = "UTF-8"; // Input is ALWAYS UTF-8! gsize bytes_written = 0; /* First, try to convert to ISO-8859-1 (no encodings required). This will @@ -42,27 +41,27 @@ LY_DEFINE (ly_encode_string_for_pdf, "ly:encode-string-for-pdf", * for errors. */ g = g_convert (p, -1, "ISO-8859-1", charset, 0, &bytes_written, 0); /* If that fails, we have to resolve to full UTF-16BE */ - if (!g) + if (!g) { GError *e = NULL; - char *g_without_BOM = g_convert (p, -1, "UTF-16BE", charset, 0, &bytes_written, &e); - if (e != NULL) + char *g_without_BOM = g_convert (p, -1, "UTF-16BE", charset, 0, &bytes_written, &e); + if (e != NULL) { - warning (_f("Conversion of string `%s' to UTF-16be failed: %s", p, e->message)); + warning (_f ("Conversion of string `%s' to UTF-16be failed: %s", p, e->message)); g_error_free (e); } - /* UTF-16BE allows/recommends a byte-order-mark (BOM) of two bytes - * \xFE\xFF at the begin of the string. The pdfmark specification + /* UTF-16BE allows/recommends a byte-order-mark (BOM) of two bytes + * \xFE\xFF at the begin of the string. The pdfmark specification * requires it and depends on it to distinguish PdfDocEncoding from - * UTF-16BE. As g_convert does not automatically prepend this BOM - * for UTF-16BE (only for UTF-16, which uses lower endian by default, + * UTF-16BE. As g_convert does not automatically prepend this BOM + * for UTF-16BE (only for UTF-16, which uses lower endian by default, * though), we have to prepend it manually. */ if (g_without_BOM) // conversion to UTF-16be might have failed (shouldn't!) - { - g = new char[bytes_written+3]; + { + g = new char[bytes_written + 3]; char const *BOM = "\xFE\xFF"; strcpy (g, BOM); - memcpy (&g[2], g_without_BOM, bytes_written+1); // Copy string + \0 + memcpy (&g[2], g_without_BOM, bytes_written + 1); // Copy string + \0 free (g_without_BOM); bytes_written += 2; } @@ -71,12 +70,12 @@ LY_DEFINE (ly_encode_string_for_pdf, "ly:encode-string-for-pdf", /* Convert back to SCM object and return it */ /* FIXME guile-2.0: With guile 2.0 the internal representation of a string - * has changed (char vector rather than binary bytes in + * has changed (char vector rather than binary bytes in * UTF-8). However, with guile 2.0, ly:encode-string-for-pdf - * is no longer needed and can be replaced by the new + * is no longer needed and can be replaced by the new * (string->utf16 str 'big) */ - if (g) + if (g) return scm_take_str (g, bytes_written); // scm_take_str eventually frees g! else return str; diff --git a/lily/percent-repeat-engraver.cc b/lily/percent-repeat-engraver.cc index 1b437b2822..1e69064051 100644 --- a/lily/percent-repeat-engraver.cc +++ b/lily/percent-repeat-engraver.cc @@ -17,7 +17,6 @@ along with LilyPond. If not, see <http://www.gnu.org/licenses/>. */ - #include "engraver.hh" #include "global-context.hh" #include "international.hh" @@ -35,7 +34,7 @@ class Percent_repeat_engraver : public Engraver public: TRANSLATOR_DECLARATIONS (Percent_repeat_engraver); - + protected: Stream_event *percent_event_; @@ -74,14 +73,14 @@ Percent_repeat_engraver::start_translation_timestep () if (now_mom ().main_part_ != command_moment_.main_part_) { first_command_column_ - = unsmob_grob (get_property ("currentCommandColumn")); + = unsmob_grob (get_property ("currentCommandColumn")); command_moment_ = now_mom (); } if (stop_mom_.main_part_ == now_mom ().main_part_) { if (percent_) - typeset_perc (); + typeset_perc (); percent_event_ = 0; } } @@ -101,8 +100,8 @@ Percent_repeat_engraver::listen_percent (Stream_event *ev) else { /* - print a warning: no assignment happens because - percent_event_ != 0 + print a warning: no assignment happens because + percent_event_ != 0 */ ASSIGN_EVENT_ONCE (percent_event_, ev); } @@ -115,7 +114,7 @@ Percent_repeat_engraver::process_music () && now_mom ().main_part_ == start_mom_.main_part_) { if (percent_) - typeset_perc (); + typeset_perc (); percent_ = make_spanner ("PercentRepeat", percent_event_->self_scm ()); @@ -124,19 +123,19 @@ Percent_repeat_engraver::process_music () SCM count = percent_event_->get_property ("repeat-count"); if (count != SCM_EOL && to_boolean (get_property ("countPercentRepeats")) - && check_repeat_count_visibility (context (), count)) - { - percent_counter_ = make_spanner ("PercentRepeatCounter", - percent_event_->self_scm ()); - - SCM text = scm_number_to_string (count, scm_from_int (10)); - percent_counter_->set_property ("text", text); - percent_counter_->set_bound (LEFT, col); - Side_position_interface::add_support (percent_counter_, percent_); - percent_counter_->set_parent (percent_, Y_AXIS); - } + && check_repeat_count_visibility (context (), count)) + { + percent_counter_ = make_spanner ("PercentRepeatCounter", + percent_event_->self_scm ()); + + SCM text = scm_number_to_string (count, scm_from_int (10)); + percent_counter_->set_property ("text", text); + percent_counter_->set_bound (LEFT, col); + Side_position_interface::add_support (percent_counter_, percent_); + percent_counter_->set_parent (percent_, Y_AXIS); + } else - percent_counter_ = 0; + percent_counter_ = 0; } } @@ -170,18 +169,18 @@ Percent_repeat_engraver::stop_translation_timestep () } ADD_TRANSLATOR (Percent_repeat_engraver, - /* doc */ - "Make whole measure repeats.", - - /* create */ - "PercentRepeat " - "PercentRepeatCounter ", - - /* read */ - "countPercentRepeats " - "currentCommandColumn " - "repeatCountVisibility ", - - /* write */ - "" - ); + /* doc */ + "Make whole measure repeats.", + + /* create */ + "PercentRepeat " + "PercentRepeatCounter ", + + /* read */ + "countPercentRepeats " + "currentCommandColumn " + "repeatCountVisibility ", + + /* write */ + "" + ); diff --git a/lily/percent-repeat-item.cc b/lily/percent-repeat-item.cc index 1e97753fee..09c06fe7e9 100644 --- a/lily/percent-repeat-item.cc +++ b/lily/percent-repeat-item.cc @@ -37,8 +37,8 @@ Percent_repeat_item_interface::brew_slash (Grob *me, int count) Stencil slash = Lookup::repeat_slash (wid, slope, thick); Stencil m = slash; - Real slash_neg_kern = - robust_scm2double (me->get_property ("slash-negative-kern"), 1.6); + Real slash_neg_kern + = robust_scm2double (me->get_property ("slash-negative-kern"), 1.6); for (int i = count - 1; i--;) m.add_at_edge (X_AXIS, RIGHT, slash, -slash_neg_kern); @@ -51,8 +51,8 @@ Percent_repeat_item_interface::x_percent (Grob *me, int count) { Stencil m = brew_slash (me, count); - Real dot_neg_kern = - robust_scm2double (me->get_property ("dot-negative-kern"), 0.75); + Real dot_neg_kern + = robust_scm2double (me->get_property ("dot-negative-kern"), 0.75); Stencil d1 = Font_interface::get_default_font (me)->find_by_name ("dots.dot"); Stencil d2 = d1; @@ -93,11 +93,11 @@ Percent_repeat_item_interface::beat_slash (SCM grob) } ADD_INTERFACE (Percent_repeat_item_interface, - "Repeats that look like percent signs.", - - /* properties */ - "dot-negative-kern " - "slash-negative-kern " - "slope " - "thickness " - ); + "Repeats that look like percent signs.", + + /* properties */ + "dot-negative-kern " + "slash-negative-kern " + "slope " + "thickness " + ); diff --git a/lily/percent-repeat-iterator.cc b/lily/percent-repeat-iterator.cc index d829553557..5bf7bf2197 100644 --- a/lily/percent-repeat-iterator.cc +++ b/lily/percent-repeat-iterator.cc @@ -59,26 +59,26 @@ Percent_repeat_iterator::get_music_list () const else { slash_count - = scm_call_1 (ly_lily_module_constant ("calc-repeat-slash-count"), - child->self_scm ()); + = scm_call_1 (ly_lily_module_constant ("calc-repeat-slash-count"), + child->self_scm ()); event_type = "RepeatSlashEvent"; } int repeats = scm_to_int (mus->get_property ("repeat-count")); for (int i = repeats; i > 1; i--) - { - Music *percent = make_music_by_name (ly_symbol2scm (event_type.c_str ())); - percent->set_spot (*mus->origin ()); - percent->set_property ("length", length); - if (repeats > 1) - { - percent->set_property ("repeat-count", scm_from_int (i)); - if (event_type == "RepeatSlashEvent") - percent->set_property ("slash-count", slash_count); - } + { + Music *percent = make_music_by_name (ly_symbol2scm (event_type.c_str ())); + percent->set_spot (*mus->origin ()); + percent->set_property ("length", length); + if (repeats > 1) + { + percent->set_property ("repeat-count", scm_from_int (i)); + if (event_type == "RepeatSlashEvent") + percent->set_property ("slash-count", slash_count); + } - child_list = scm_cons (percent->unprotect (), child_list); - } + child_list = scm_cons (percent->unprotect (), child_list); + } child_list = scm_cons (child->self_scm (), child_list); diff --git a/lily/performance-scheme.cc b/lily/performance-scheme.cc index 10a1de6659..be1dc15647 100644 --- a/lily/performance-scheme.cc +++ b/lily/performance-scheme.cc @@ -20,8 +20,8 @@ #include "performance.hh" LY_DEFINE (ly_performance_write, "ly:performance-write", - 2, 0, 0, (SCM performance, SCM filename), - "Write @var{performance} to @var{filename}.") + 2, 0, 0, (SCM performance, SCM filename), + "Write @var{performance} to @var{filename}.") { LY_ASSERT_TYPE (unsmob_performance, performance, 1); LY_ASSERT_TYPE (scm_is_string, filename, 2); diff --git a/lily/performance.cc b/lily/performance.cc index bcd8b42c50..1bc547a5a8 100644 --- a/lily/performance.cc +++ b/lily/performance.cc @@ -35,8 +35,8 @@ using namespace std; #include "warn.hh" Performance::Performance (bool ports) - : midi_ (0) - , ports_ (ports) + : midi_ (0), + ports_ (ports) { } @@ -53,15 +53,15 @@ Performance::output (Midi_stream &midi_stream) const midi_stream.write (Midi_header (1, tracks_, 384)); if (be_verbose_global) progress_indication (_ ("Track...") + " "); - + for (vsize i = 0; i < audio_staffs_.size (); i++) { Audio_staff *s = audio_staffs_[i]; if (be_verbose_global) - progress_indication ("[" + to_string (i)); + progress_indication ("[" + to_string (i)); s->output (midi_stream, i, ports_); if (be_verbose_global) - progress_indication ("]"); + progress_indication ("]"); } } @@ -88,7 +88,6 @@ Performance::write_output (string out) const progress_indication ("\n"); } - void Performance::process () { @@ -97,5 +96,5 @@ Performance::process () Performance * unsmob_performance (SCM x) { - return dynamic_cast<Performance*> (unsmob_music_output (x)); + return dynamic_cast<Performance *> (unsmob_music_output (x)); } diff --git a/lily/performer-group.cc b/lily/performer-group.cc index 70a3f84484..1fe99758b5 100644 --- a/lily/performer-group.cc +++ b/lily/performer-group.cc @@ -25,18 +25,18 @@ #include "warn.hh" ADD_TRANSLATOR_GROUP (Performer_group, - /* doc */ - "", + /* doc */ + "", - /* create */ - "", + /* create */ + "", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); void Performer_group::announce_element (Audio_element_info info) @@ -57,12 +57,12 @@ Performer_group::acknowledge_audio_elements () Audio_element_info info = announce_infos_[j]; for (SCM p = get_simple_trans_list (); scm_is_pair (p); p = scm_cdr (p)) - { - Translator *t = unsmob_translator (scm_car (p)); - Performer *eng = dynamic_cast<Performer *> (t); - if (eng && eng != info.origin_trans_) - eng->acknowledge_audio_element (info); - } + { + Translator *t = unsmob_translator (scm_car (p)); + Performer *eng = dynamic_cast<Performer *> (t); + if (eng && eng != info.origin_trans_) + eng->acknowledge_audio_element (info); + } } } @@ -73,7 +73,7 @@ performer_each (SCM list, Performer_method method) { Performer *e = dynamic_cast<Performer *> (unsmob_translator (scm_car (p))); if (e) - (e->*method) (); + (e->*method) (); } } @@ -85,18 +85,18 @@ Performer_group::do_announces () { Context *c = unsmob_context (scm_car (s)); Performer_group *group - = dynamic_cast<Performer_group *> (c->implementation ()); + = dynamic_cast<Performer_group *> (c->implementation ()); if (group) - group->do_announces (); + group->do_announces (); } while (1) { performer_each (get_simple_trans_list (), - &Performer::create_audio_elements); + &Performer::create_audio_elements); if (!announce_infos_.size ()) - break; + break; acknowledge_audio_elements (); announce_infos_.clear (); diff --git a/lily/performer.cc b/lily/performer.cc index 871367af15..58a88cd297 100644 --- a/lily/performer.cc +++ b/lily/performer.cc @@ -23,7 +23,6 @@ #include "performer-group.hh" #include "warn.hh" - Performer_group * Performer::get_daddy_performer () const { diff --git a/lily/pfb-scheme.cc b/lily/pfb-scheme.cc index 89666192a3..34d159cf04 100644 --- a/lily/pfb-scheme.cc +++ b/lily/pfb-scheme.cc @@ -7,9 +7,9 @@ #include "warn.hh" LY_DEFINE (ly_pfb_2_pfa, "ly:pfb->pfa", - 1, 0, 0, (SCM pfb_file_name), - "Convert the contents of a Type@tie{}1 font in PFB format" - " to PFA format.") + 1, 0, 0, (SCM pfb_file_name), + "Convert the contents of a Type@tie{}1 font in PFB format" + " to PFA format.") { LY_ASSERT_TYPE (scm_is_string, pfb_file_name, 1); @@ -17,10 +17,10 @@ LY_DEFINE (ly_pfb_2_pfa, "ly:pfb->pfa", if (be_verbose_global) progress_indication ("\n[" + file_name); - + vector<char> pfb_string = gulp_file (file_name, 0); char *pfa = pfb2pfa ((Byte *) &pfb_string[0], pfb_string.size ()); - + SCM pfa_scm = scm_from_locale_string (pfa); free (pfa); @@ -31,9 +31,9 @@ LY_DEFINE (ly_pfb_2_pfa, "ly:pfb->pfa", } LY_DEFINE (ly_otf_2_cff, "ly:otf->cff", - 1, 0, 0, (SCM otf_file_name), - "Convert the contents of an OTF file to a CFF file," - " returning it as a string.") + 1, 0, 0, (SCM otf_file_name), + "Convert the contents of an OTF file to a CFF file," + " returning it as a string.") { LY_ASSERT_TYPE (scm_is_string, otf_file_name, 1); @@ -45,7 +45,7 @@ LY_DEFINE (ly_otf_2_cff, "ly:otf->cff", string table = get_otf_table (face, "CFF "); SCM asscm = scm_from_locale_stringn ((char *) table.data (), - table.length ()); + table.length ()); if (be_verbose_global) progress_indication ("]"); diff --git a/lily/pfb.cc b/lily/pfb.cc index ba31e17513..54e72b1ab3 100644 --- a/lily/pfb.cc +++ b/lily/pfb.cc @@ -32,49 +32,49 @@ using namespace std; char * pfb2pfa (Byte const *pfb, int length) { - char *out = (char*) malloc(sizeof(char)); + char *out = (char *) malloc (sizeof (char)); int olen = 0; Byte const *p = pfb; while (p < pfb + length) { if (*p++ != 128) - break; + break; Byte type = *p++; if (type == 3) - break; + break; unsigned seglen - = p[0] | (p[1] << 8) - | (p[2] << 16) | (p[3] << 24); + = p[0] | (p[1] << 8) + | (p[2] << 16) | (p[3] << 24); p += 4; if (type == 1) - { - out = (char *)realloc (out, olen + seglen + 1); - char *outp = out + olen; - memcpy (outp, p, seglen); - olen += seglen; - p += seglen; - } + { + out = (char *)realloc (out, olen + seglen + 1); + char *outp = out + olen; + memcpy (outp, p, seglen); + olen += seglen; + p += seglen; + } else if (type == 2) - { - unsigned outlength = (seglen * 2) + (seglen / 32) + 2; - - out = (char *)realloc (out, olen + outlength + 1); - - char *outp = out + olen; - for (int i = seglen; i--;) - { - sprintf (outp, "%02x", *p++); - outp += 2; - if (! (i % 32)) - *outp++ = '\n'; - } - - olen = outp - out; - } + { + unsigned outlength = (seglen * 2) + (seglen / 32) + 2; + + out = (char *)realloc (out, olen + outlength + 1); + + char *outp = out + olen; + for (int i = seglen; i--;) + { + sprintf (outp, "%02x", *p++); + outp += 2; + if (! (i % 32)) + *outp++ = '\n'; + } + + olen = outp - out; + } } out[olen] = 0; diff --git a/lily/phrasing-slur-engraver.cc b/lily/phrasing-slur-engraver.cc index 839554f7e9..4805960042 100644 --- a/lily/phrasing-slur-engraver.cc +++ b/lily/phrasing-slur-engraver.cc @@ -30,29 +30,27 @@ #include "translator.icc" - /* NOTE NOTE NOTE This is largely similar to Slur_engraver. Check if fixes - apply there too. + apply there too. (on principle, engravers don't use inheritance for code sharing) - + */ /* It is possible that a slur starts and ends on the same note. At least, it is for phrasing slurs: a note can be both beginning and ending of a phrase. - */ class Phrasing_slur_engraver : public Engraver { vector<Stream_event *> start_events_; vector<Stream_event *> stop_events_; - vector<Grob*> slurs_; - vector<Grob*> end_slurs_; + vector<Grob *> slurs_; + vector<Grob *> end_slurs_; protected: DECLARE_TRANSLATOR_LISTENER (phrasing_slur); @@ -71,7 +69,6 @@ protected: virtual void finalize (); - public: TRANSLATOR_DECLARATIONS (Phrasing_slur_engraver); }; @@ -86,11 +83,11 @@ Phrasing_slur_engraver::listen_phrasing_slur (Stream_event *ev) { Direction d = to_dir (ev->get_property ("span-direction")); if (d == START) - start_events_.push_back(ev); + start_events_.push_back (ev); else if (d == STOP) - stop_events_.push_back(ev); + stop_events_.push_back (ev); else ev->origin ()->warning (_f ("direction of %s invalid: %d", - "phrasing-slur-event", int (d))); + "phrasing-slur-event", int (d))); } void @@ -193,11 +190,11 @@ Phrasing_slur_engraver::process_music () // Check if we already have a slur with the same spanner-id. // In that case, don't create a new slur, but print a warning for (vsize i = 0; i < slurs_.size (); i++) - have_slur = have_slur || (id == robust_scm2string (slurs_[i]->get_property ("spanner-id"), "")); - + have_slur = have_slur || (id == robust_scm2string (slurs_[i]->get_property ("spanner-id"), "")); + if (have_slur) - ev->origin ()->warning(_ ("already have phrasing slur")); - else + ev->origin ()->warning (_ ("already have phrasing slur")); + else { Grob *slur = make_spanner ("PhrasingSlur", ev->self_scm ()); Direction updown = to_dir (ev->get_property ("direction")); @@ -227,15 +224,15 @@ ADD_ACKNOWLEDGER (Phrasing_slur_engraver, tie); ADD_ACKNOWLEDGER (Phrasing_slur_engraver, tuplet_number); ADD_TRANSLATOR (Phrasing_slur_engraver, - /* doc */ - "Print phrasing slurs. Similar to @ref{Slur_engraver}.", + /* doc */ + "Print phrasing slurs. Similar to @ref{Slur_engraver}.", - /* create */ - "PhrasingSlur ", + /* create */ + "PhrasingSlur ", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/piano-pedal-align-engraver.cc b/lily/piano-pedal-align-engraver.cc index f5aa652a4a..3080393e48 100644 --- a/lily/piano-pedal-align-engraver.cc +++ b/lily/piano-pedal-align-engraver.cc @@ -2,7 +2,7 @@ This file is part of LilyPond, the GNU music typesetter. Copyright (C) 2006--2011 Han-Wen Nienhuys <hanwen@lilypond.org> - + LilyPond is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,7 +18,6 @@ along with LilyPond. If not, see <http://www.gnu.org/licenses/>. */ - #include "engraver.hh" #include "spanner.hh" @@ -28,18 +27,15 @@ #include "warn.hh" #include "axis-group-interface.hh" - /* TODO: * Detach from pedal specifics, - + * Also use this engraver for dynamics. - */ - struct Pedal_align_info { Spanner *line_spanner_; @@ -77,7 +73,7 @@ public: protected: virtual void finalize (); - + DECLARE_ACKNOWLEDGER (piano_pedal_script); DECLARE_ACKNOWLEDGER (piano_pedal_bracket); DECLARE_ACKNOWLEDGER (note_column); @@ -86,9 +82,10 @@ protected: void stop_translation_timestep (); void start_translation_timestep (); - + private: - enum Pedal_type { + enum Pedal_type + { SOSTENUTO, SUSTAIN, UNA_CORDA, @@ -114,46 +111,45 @@ Piano_pedal_align_engraver::start_translation_timestep () void Piano_pedal_align_engraver::stop_translation_timestep () { - for (int i = 0; i < NUM_PEDAL_TYPES; i ++) + for (int i = 0; i < NUM_PEDAL_TYPES; i++) { if (pedal_info_[i].line_spanner_) - { - - if (pedal_info_[i].carrying_item_) - { - if (!pedal_info_[i].line_spanner_->get_bound (LEFT)) - pedal_info_[i].line_spanner_->set_bound (LEFT, - pedal_info_[i].carrying_item_); - - pedal_info_[i].line_spanner_->set_bound (RIGHT, - pedal_info_[i].carrying_item_); - } - else if (pedal_info_[i].carrying_spanner_ - || pedal_info_[i].finished_carrying_spanner_ - ) - { - if (!pedal_info_[i].line_spanner_->get_bound (LEFT) - && pedal_info_[i].carrying_spanner_->get_bound (LEFT)) - pedal_info_[i].line_spanner_->set_bound (LEFT, - pedal_info_[i].carrying_spanner_->get_bound (LEFT)); - - - if (pedal_info_[i].finished_carrying_spanner_) - pedal_info_[i].line_spanner_->set_bound (RIGHT, - pedal_info_[i].finished_carrying_spanner_->get_bound (RIGHT)); - } - - for (vsize j = 0; j < supports_.size (); j++) - { - Side_position_interface::add_support (pedal_info_[i].line_spanner_, supports_[j]); - } - - if (pedal_info_[i].is_finished ()) - { - announce_end_grob (pedal_info_[i].line_spanner_, SCM_EOL); - pedal_info_[i].clear (); - } - } + { + + if (pedal_info_[i].carrying_item_) + { + if (!pedal_info_[i].line_spanner_->get_bound (LEFT)) + pedal_info_[i].line_spanner_->set_bound (LEFT, + pedal_info_[i].carrying_item_); + + pedal_info_[i].line_spanner_->set_bound (RIGHT, + pedal_info_[i].carrying_item_); + } + else if (pedal_info_[i].carrying_spanner_ + || pedal_info_[i].finished_carrying_spanner_ + ) + { + if (!pedal_info_[i].line_spanner_->get_bound (LEFT) + && pedal_info_[i].carrying_spanner_->get_bound (LEFT)) + pedal_info_[i].line_spanner_->set_bound (LEFT, + pedal_info_[i].carrying_spanner_->get_bound (LEFT)); + + if (pedal_info_[i].finished_carrying_spanner_) + pedal_info_[i].line_spanner_->set_bound (RIGHT, + pedal_info_[i].finished_carrying_spanner_->get_bound (RIGHT)); + } + + for (vsize j = 0; j < supports_.size (); j++) + { + Side_position_interface::add_support (pedal_info_[i].line_spanner_, supports_[j]); + } + + if (pedal_info_[i].is_finished ()) + { + announce_end_grob (pedal_info_[i].line_spanner_, SCM_EOL); + pedal_info_[i].clear (); + } + } pedal_info_[i].carrying_item_ = 0; } @@ -173,7 +169,6 @@ Piano_pedal_align_engraver::get_grob_pedal_type (Grob_info g) return SUSTAIN; } - Spanner * Piano_pedal_align_engraver::make_line_spanner (Pedal_type t, SCM cause) { @@ -181,24 +176,24 @@ Piano_pedal_align_engraver::make_line_spanner (Pedal_type t, SCM cause) if (!sp) { switch (t) - { - case (SOSTENUTO): - sp = make_spanner ("SostenutoPedalLineSpanner", cause); - break; - case (SUSTAIN): - sp = make_spanner ("SustainPedalLineSpanner", cause); - break; - case (UNA_CORDA): - sp = make_spanner ("UnaCordaPedalLineSpanner", cause); - break; - default: - programming_error ("No pedal type fonud!") ; - return sp; - } - + { + case (SOSTENUTO): + sp = make_spanner ("SostenutoPedalLineSpanner", cause); + break; + case (SUSTAIN): + sp = make_spanner ("SustainPedalLineSpanner", cause); + break; + case (UNA_CORDA): + sp = make_spanner ("UnaCordaPedalLineSpanner", cause); + break; + default: + programming_error ("No pedal type fonud!"); + return sp; + } + pedal_info_[t].line_spanner_ = sp; } - + return sp; } @@ -229,26 +224,25 @@ void Piano_pedal_align_engraver::acknowledge_piano_pedal_script (Grob_info gi) { Pedal_type type = get_grob_pedal_type (gi); - + Grob *sp = make_line_spanner (type, gi.grob ()->self_scm ()); Axis_group_interface::add_element (sp, gi.grob ()); pedal_info_[type].carrying_item_ = gi.grob (); } - void Piano_pedal_align_engraver::finalize () { - for (int i = 0; i < NUM_PEDAL_TYPES; i ++) + for (int i = 0; i < NUM_PEDAL_TYPES; i++) { if (pedal_info_[i].line_spanner_) - { - SCM cc = get_property ("currentCommandColumn"); - Item *c = unsmob_item (cc); - pedal_info_[i].line_spanner_->set_bound (RIGHT, c); + { + SCM cc = get_property ("currentCommandColumn"); + Item *c = unsmob_item (cc); + pedal_info_[i].line_spanner_->set_bound (RIGHT, c); - pedal_info_[i].clear (); - } + pedal_info_[i].clear (); + } } } @@ -260,19 +254,18 @@ ADD_ACKNOWLEDGER (Piano_pedal_align_engraver, piano_pedal_script); ADD_END_ACKNOWLEDGER (Piano_pedal_align_engraver, piano_pedal_bracket); - ADD_TRANSLATOR (Piano_pedal_align_engraver, - /* doc */ - "Align piano pedal symbols and brackets.", + /* doc */ + "Align piano pedal symbols and brackets.", - /* create */ - "SostenutoPedalLineSpanner " - "SustainPedalLineSpanner " - "UnaCordaPedalLineSpanner ", + /* create */ + "SostenutoPedalLineSpanner " + "SustainPedalLineSpanner " + "UnaCordaPedalLineSpanner ", - /* read */ - "currentCommandColumn ", + /* read */ + "currentCommandColumn ", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/piano-pedal-bracket.cc b/lily/piano-pedal-bracket.cc index 40ebbaef7d..fee4c4b762 100644 --- a/lily/piano-pedal-bracket.cc +++ b/lily/piano-pedal-bracket.cc @@ -37,14 +37,14 @@ Piano_pedal_bracket::print (SCM smob) Drul_array<bool> broken (false, false); Drul_array<Real> height = robust_scm2drul - (me->get_property ("edge-height"), Interval (0, 0)); + (me->get_property ("edge-height"), Interval (0, 0)); Drul_array<Real> shorten = robust_scm2drul - (me->get_property ("shorten-pair"), Interval (0, 0)); + (me->get_property ("shorten-pair"), Interval (0, 0)); Drul_array<Real> flare = robust_scm2drul - (me->get_property ("bracket-flare"), Interval (0, 0)); + (me->get_property ("bracket-flare"), Interval (0, 0)); Grob *common = me->get_bound (LEFT) - ->common_refpoint (me->get_bound (RIGHT), X_AXIS); + ->common_refpoint (me->get_bound (RIGHT), X_AXIS); Grob *textbit = unsmob_grob (me->get_object ("pedal-text")); if (textbit) @@ -57,15 +57,15 @@ Piano_pedal_bracket::print (SCM smob) Item *b = me->get_bound (d); broken[d] = b->break_status_dir () != CENTER; if (broken[d]) - { - if (orig - && ((d == RIGHT - && me->get_break_index () != orig->broken_intos_.size () - 1) - || (d == LEFT && me->get_break_index ()))) - height[d] = 0.0; - else - flare[d] = 0.0; - } + { + if (orig + && ((d == RIGHT + && me->get_break_index () != orig->broken_intos_.size () - 1) + || (d == LEFT && me->get_break_index ()))) + height[d] = 0.0; + else + flare[d] = 0.0; + } Interval ext = robust_relative_extent (b, common, X_AXIS); span_points[d] = ext [broken[d] ? RIGHT : LEFT]; @@ -82,7 +82,7 @@ Piano_pedal_bracket::print (SCM smob) Real padding = robust_scm2double (me->get_property ("bound-padding"), 0); span_points[LEFT] = padding - + robust_relative_extent (textbit, common, X_AXIS)[RIGHT]; + + robust_relative_extent (textbit, common, X_AXIS)[RIGHT]; } Stencil m; @@ -90,24 +90,24 @@ Piano_pedal_bracket::print (SCM smob) && span_points.length () > 0.001) { m = Tuplet_bracket::make_bracket (me, Y_AXIS, - Offset (span_points.length (), 0), - height, - Interval (), - flare, shorten); + Offset (span_points.length (), 0), + height, + Interval (), + flare, shorten); } m.translate_axis (span_points[LEFT] - - me->relative_coordinate (common, X_AXIS), X_AXIS); + - me->relative_coordinate (common, X_AXIS), X_AXIS); return m.smobbed_copy (); } ADD_INTERFACE (Piano_pedal_bracket, - "The bracket of the piano pedal. It can be tuned through" - " the regular bracket properties.", - - /* properties */ - "bound-padding " - "edge-height " - "shorten-pair " - "bracket-flare " - "pedal-text " - ); + "The bracket of the piano pedal. It can be tuned through" + " the regular bracket properties.", + + /* properties */ + "bound-padding " + "edge-height " + "shorten-pair " + "bracket-flare " + "pedal-text " + ); diff --git a/lily/piano-pedal-engraver.cc b/lily/piano-pedal-engraver.cc index 43666efbdd..4cbc7adbd3 100644 --- a/lily/piano-pedal-engraver.cc +++ b/lily/piano-pedal-engraver.cc @@ -48,11 +48,11 @@ Softcode using (list (sustain-event SustainPedal PianoPedalBracket) ... ) * Try to use same engraver for dynamics. - */ /* Ugh: This declaration is duplicated in piano-pedal-performer */ -enum Pedal_type { +enum Pedal_type +{ SOSTENUTO, SUSTAIN, UNA_CORDA, @@ -69,7 +69,7 @@ struct Pedal_type_info SCM event_class_sym_; SCM style_sym_; SCM strings_sym_; - + const char *pedal_c_str_; Pedal_type_info () @@ -138,7 +138,6 @@ private: void typeset_all (Pedal_info *p); }; - static void init_pedal_types () { @@ -154,29 +153,29 @@ init_pedal_types () string base_name = name; /* foo-bar */ string base_ident = ""; - int prev_pos=0; + int prev_pos = 0; int cur_pos; for (cur_pos = 1; name[cur_pos]; cur_pos++) - if (isupper (name[cur_pos])) - { - base_ident = base_ident + String_convert::to_lower (string (name, prev_pos, cur_pos - prev_pos)) + "-"; - prev_pos = cur_pos; - } + if (isupper (name[cur_pos])) + { + base_ident = base_ident + String_convert::to_lower (string (name, prev_pos, cur_pos - prev_pos)) + "-"; + prev_pos = cur_pos; + } base_ident += String_convert::to_lower (string (name, prev_pos, cur_pos - prev_pos)); /* - be careful, as we don't want to loose references to the _sym_ members. + be careful, as we don't want to loose references to the _sym_ members. */ Pedal_type_info info; info.event_class_sym_ = scm_from_locale_symbol ((base_ident + "-event").c_str ()); info.style_sym_ = scm_from_locale_symbol (("pedal" + base_name + "Style").c_str ()); info.strings_sym_ = scm_from_locale_symbol (("pedal" + base_name + "Strings").c_str ()); - + info.base_name_ = name; info.pedal_c_str_ = strdup ((base_name + "Pedal").c_str ()); info.protect (); - + pedal_types_[i] = info; } } @@ -207,7 +206,6 @@ Piano_pedal_engraver::initialize () info_list_[NUM_PEDAL_TYPES].type_ = 0; } - /* Urg: Code dup I'm a script @@ -218,9 +216,9 @@ Piano_pedal_engraver::acknowledge_note_column (Grob_info info) for (Pedal_info *p = info_list_; p->type_; p++) { if (p->bracket_) - add_bound_item (p->bracket_, info.grob ()); + add_bound_item (p->bracket_, info.grob ()); if (p->finished_bracket_) - add_bound_item (p->finished_bracket_, info.grob ()); + add_bound_item (p->finished_bracket_, info.grob ()); } } @@ -254,33 +252,33 @@ Piano_pedal_engraver::process_music () for (Pedal_info *p = info_list_; p->type_; p++) { if (p->event_drul_[STOP] || p->event_drul_[START]) - { - /* Choose the appropriate grobs to add to the line spanner - These can be text items or text-spanners - */ - - /* - ugh, code dup, should read grob to create from other - property. - - bracket: |_________/\____| - text: Ped. *Ped. * - mixed: Ped. _____/\____| - */ - - SCM style = internal_get_property (p->type_->style_sym_); - - bool mixed = style == ly_symbol2scm ("mixed"); - bool bracket = (mixed - || style == ly_symbol2scm ("bracket")); - bool text = (style == ly_symbol2scm ("text") - || mixed); - - if (text && !p->item_) - create_text_grobs (p, mixed); - if (bracket) - create_bracket_grobs (p, mixed); - } + { + /* Choose the appropriate grobs to add to the line spanner + These can be text items or text-spanners + */ + + /* + ugh, code dup, should read grob to create from other + property. + + bracket: |_________/\____| + text: Ped. *Ped. * + mixed: Ped. _____/\____| + */ + + SCM style = internal_get_property (p->type_->style_sym_); + + bool mixed = style == ly_symbol2scm ("mixed"); + bool bracket = (mixed + || style == ly_symbol2scm ("bracket")); + bool text = (style == ly_symbol2scm ("text") + || mixed); + + if (text && !p->item_) + create_text_grobs (p, mixed); + if (bracket) + create_bracket_grobs (p, mixed); + } } } @@ -296,11 +294,11 @@ Piano_pedal_engraver::create_text_grobs (Pedal_info *p, bool mixed) if (!m) m = p->event_drul_ [STOP]; string msg = _f ("expect 3 strings for piano pedals, found: %ld", - scm_ilength (strings)); + scm_ilength (strings)); if (m) - m->origin ()->warning (msg); + m->origin ()->warning (msg); else - warning (msg); + warning (msg); return; } @@ -308,38 +306,38 @@ Piano_pedal_engraver::create_text_grobs (Pedal_info *p, bool mixed) if (p->event_drul_[STOP] && p->event_drul_[START]) { if (!mixed) - { - if (!p->start_ev_) - p->event_drul_[STOP]->origin ()->warning (_f ("cannot find start of piano pedal: `%s'", p->type_->base_name_.c_str ())); - else - s = scm_cadr (strings); - p->start_ev_ = p->event_drul_[START]; - } + { + if (!p->start_ev_) + p->event_drul_[STOP]->origin ()->warning (_f ("cannot find start of piano pedal: `%s'", p->type_->base_name_.c_str ())); + else + s = scm_cadr (strings); + p->start_ev_ = p->event_drul_[START]; + } } else if (p->event_drul_[STOP]) { if (!mixed) - { - if (!p->start_ev_) - p->event_drul_[STOP]->origin ()->warning (_f ("cannot find start of piano pedal: `%s'", p->type_->base_name_.c_str ())); - else - s = scm_caddr (strings); - p->start_ev_ = 0; - } + { + if (!p->start_ev_) + p->event_drul_[STOP]->origin ()->warning (_f ("cannot find start of piano pedal: `%s'", p->type_->base_name_.c_str ())); + else + s = scm_caddr (strings); + p->start_ev_ = 0; + } } else if (p->event_drul_[START]) { p->start_ev_ = p->event_drul_[START]; s = scm_car (strings); - } + } if (scm_is_string (s)) { const char *propname = p->type_->pedal_c_str_; p->item_ = make_item (propname, (p->event_drul_[START] - ? p->event_drul_[START] - : p->event_drul_[STOP])->self_scm ()); + ? p->event_drul_[START] + : p->event_drul_[STOP])->self_scm ()); p->item_->set_property ("text", s); } @@ -368,26 +366,26 @@ Piano_pedal_engraver::create_bracket_grobs (Pedal_info *p, bool mixed) Grob *cmc = unsmob_grob (get_property ("currentMusicalColumn")); if (!p->bracket_->get_bound (RIGHT)) - p->bracket_->set_bound (RIGHT, cmc); + p->bracket_->set_bound (RIGHT, cmc); /* - Set properties so that the stencil-creating function will - know whether the right edge should be flared ___/ + Set properties so that the stencil-creating function will + know whether the right edge should be flared ___/ */ if (!p->event_drul_[START]) - { - SCM flare = p->bracket_->get_property ("bracket-flare"); - if (scm_is_pair (flare)) - p->bracket_->set_property ("bracket-flare", scm_cons (scm_car (flare), - scm_from_double (0))); - } + { + SCM flare = p->bracket_->get_property ("bracket-flare"); + if (scm_is_pair (flare)) + p->bracket_->set_property ("bracket-flare", scm_cons (scm_car (flare), + scm_from_double (0))); + } p->finished_bracket_ = p->bracket_; p->bracket_ = 0; announce_end_grob (p->finished_bracket_, p->event_drul_[STOP]->self_scm ()); - + p->current_bracket_ev_ = 0; } @@ -399,34 +397,34 @@ Piano_pedal_engraver::create_bracket_grobs (Pedal_info *p, bool mixed) p->bracket_ = make_spanner ("PianoPedalBracket", p->event_drul_[START]->self_scm ()); /* - Set properties so that the stencil-creating function will - know whether the left edge should be flared \___ + Set properties so that the stencil-creating function will + know whether the left edge should be flared \___ */ if (!p->finished_bracket_) - { - SCM flare = p->bracket_->get_property ("bracket-flare"); - p->bracket_->set_property ("bracket-flare", scm_cons (scm_from_double (0), scm_cdr (flare))); - } + { + SCM flare = p->bracket_->get_property ("bracket-flare"); + p->bracket_->set_property ("bracket-flare", scm_cons (scm_from_double (0), scm_cdr (flare))); + } /* Set this property for 'mixed style' pedals, Ped._______/\ , - so the stencil function will shorten the ____ line by the length of the Ped. text. + so the stencil function will shorten the ____ line by the length of the Ped. text. */ if (mixed) - { - /* - Mixed style: Store a pointer to the preceding text for use in - calculating the length of the line + { + /* + Mixed style: Store a pointer to the preceding text for use in + calculating the length of the line - TODO: + TODO: - WTF is pedal-text not the bound of the object? --hwn - */ - if (p->item_) - p->bracket_->set_object ("pedal-text", p->item_->self_scm ()); - } + WTF is pedal-text not the bound of the object? --hwn + */ + if (p->item_) + p->bracket_->set_object ("pedal-text", p->item_->self_scm ()); + } } p->event_drul_[START] = 0; @@ -439,19 +437,19 @@ Piano_pedal_engraver::finalize () for (Pedal_info *p = info_list_; p->type_; p++) { if (p->bracket_ - && !p->bracket_->is_live ()) - p->bracket_ = 0; + && !p->bracket_->is_live ()) + p->bracket_ = 0; if (p->bracket_) - { - SCM cc = get_property ("currentCommandColumn"); - Item *c = unsmob_item (cc); - p->bracket_->set_bound (RIGHT, c); + { + SCM cc = get_property ("currentCommandColumn"); + Item *c = unsmob_item (cc); + p->bracket_->set_bound (RIGHT, c); - p->finished_bracket_ = p->bracket_; - p->bracket_ = 0; - typeset_all (p); - } + p->finished_bracket_ = p->bracket_; + p->bracket_ = 0; + typeset_all (p); + } } } @@ -461,15 +459,15 @@ Piano_pedal_engraver::stop_translation_timestep () { for (Pedal_info *p = info_list_; p->type_; p++) { - + typeset_all (p); if (p->bracket_ && !p->bracket_->get_bound (LEFT)) - { - Grob *cmc = unsmob_grob (get_property ("currentMusicalColumn")); + { + Grob *cmc = unsmob_grob (get_property ("currentMusicalColumn")); - if (!p->bracket_->get_bound (LEFT)) - p->bracket_->set_bound (LEFT, cmc); - } + if (!p->bracket_->get_bound (LEFT)) + p->bracket_->set_bound (LEFT, cmc); + } } for (Pedal_info *p = info_list_; p->type_; p++) @@ -496,7 +494,7 @@ Piano_pedal_engraver::typeset_all (Pedal_info *p) { Grob *r = p->finished_bracket_->get_bound (RIGHT); if (!r) - p->finished_bracket_->set_bound (RIGHT, unsmob_grob (get_property ("currentMusicalColumn"))); + p->finished_bracket_->set_bound (RIGHT, unsmob_grob (get_property ("currentMusicalColumn"))); p->finished_bracket_ = 0; } @@ -505,24 +503,24 @@ Piano_pedal_engraver::typeset_all (Pedal_info *p) ADD_ACKNOWLEDGER (Piano_pedal_engraver, note_column); ADD_TRANSLATOR (Piano_pedal_engraver, - /* doc */ - "Engrave piano pedal symbols and brackets.", - - /* create */ - "PianoPedalBracket " - "SostenutoPedal " - "SustainPedal " - "UnaCordaPedal ", - - /* read */ - "currentCommandColumn " - "pedalSostenutoStrings " - "pedalSostenutoStyle " - "pedalSustainStrings " - "pedalSustainStyle " - "pedalUnaCordaStrings " - "pedalUnaCordaStyle ", - - /* write */ - "" - ); + /* doc */ + "Engrave piano pedal symbols and brackets.", + + /* create */ + "PianoPedalBracket " + "SostenutoPedal " + "SustainPedal " + "UnaCordaPedal ", + + /* read */ + "currentCommandColumn " + "pedalSostenutoStrings " + "pedalSostenutoStyle " + "pedalSustainStrings " + "pedalSustainStyle " + "pedalUnaCordaStrings " + "pedalUnaCordaStyle ", + + /* write */ + "" + ); diff --git a/lily/piano-pedal-performer.cc b/lily/piano-pedal-performer.cc index cd191d3ea0..e317872724 100644 --- a/lily/piano-pedal-performer.cc +++ b/lily/piano-pedal-performer.cc @@ -52,7 +52,7 @@ protected: DECLARE_TRANSLATOR_LISTENER (una_corda); DECLARE_TRANSLATOR_LISTENER (sostenuto); private: - vector<Audio_piano_pedal*> audios_; + vector<Audio_piano_pedal *> audios_; Pedal_info info_alist_[NUM_PEDAL_TYPES]; }; @@ -65,11 +65,11 @@ Piano_pedal_performer::pedal_type_str (int t) { switch (t) { - case SOSTENUTO: + case SOSTENUTO: return "Sostenuto"; case SUSTAIN: return "Sustain"; - case UNA_CORDA: + case UNA_CORDA: return "UnaCorda"; default: programming_error ("Unknown pedal type"); @@ -99,31 +99,31 @@ Piano_pedal_performer::process_music () { string pedal_type = pedal_type_str (i); if (p->event_drul_[STOP]) - { - if (!p->start_event_) - p->event_drul_[STOP]->origin ()->warning (_f ("cannot find start of piano pedal: `%s'", pedal_type)); - else - { - Audio_piano_pedal *a = new Audio_piano_pedal; - a->type_string_ = pedal_type; - a->dir_ = STOP; - audios_.push_back (a); + { + if (!p->start_event_) + p->event_drul_[STOP]->origin ()->warning (_f ("cannot find start of piano pedal: `%s'", pedal_type)); + else + { + Audio_piano_pedal *a = new Audio_piano_pedal; + a->type_string_ = pedal_type; + a->dir_ = STOP; + audios_.push_back (a); Audio_element_info info (a, p->event_drul_[STOP]); announce_element (info); - } - p->start_event_ = 0; - } + } + p->start_event_ = 0; + } if (p->event_drul_[START]) - { - p->start_event_ = p->event_drul_[START]; - Audio_piano_pedal *a = new Audio_piano_pedal; - a->type_string_ = pedal_type; - a->dir_ = START; - audios_.push_back (a); + { + p->start_event_ = p->event_drul_[START]; + Audio_piano_pedal *a = new Audio_piano_pedal; + a->type_string_ = pedal_type; + a->dir_ = START; + audios_.push_back (a); Audio_element_info info (a, p->event_drul_[START]); announce_element (info); - } + } p->event_drul_[START] = 0; p->event_drul_[STOP] = 0; } @@ -171,15 +171,15 @@ Piano_pedal_performer::listen_una_corda (Stream_event *r) } ADD_TRANSLATOR (Piano_pedal_performer, - /* doc */ - "", + /* doc */ + "", - /* create */ - "", + /* create */ + "", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/pitch-interval.cc b/lily/pitch-interval.cc index e92a721ae0..a6be0faeb6 100644 --- a/lily/pitch-interval.cc +++ b/lily/pitch-interval.cc @@ -42,7 +42,7 @@ Pitch_interval::is_empty () const Drul_array<bool> Pitch_interval::add_point (Pitch p) { - Drul_array<bool> expansions(false,false); + Drul_array<bool> expansions (false, false); if (at (LEFT).tone_pitch () > p.tone_pitch ()) { at (LEFT) = p; @@ -56,7 +56,6 @@ Pitch_interval::add_point (Pitch p) return expansions; } - Pitch_lexicographic_interval::Pitch_lexicographic_interval (Pitch p1, Pitch p2) { at (LEFT) = p1; @@ -78,7 +77,7 @@ Pitch_lexicographic_interval::is_empty () const Drul_array<bool> Pitch_lexicographic_interval::add_point (Pitch p) { - Drul_array<bool> expansions(false,false); + Drul_array<bool> expansions (false, false); if (at (LEFT) > p) { at (LEFT) = p; diff --git a/lily/pitch-scheme.cc b/lily/pitch-scheme.cc index bc69b633a7..4461ce4a32 100644 --- a/lily/pitch-scheme.cc +++ b/lily/pitch-scheme.cc @@ -20,9 +20,9 @@ #include "pitch.hh" LY_DEFINE (ly_pitch_transpose, "ly:pitch-transpose", - 2, 0, 0, (SCM p, SCM delta), - "Transpose @var{p} by the amount @var{delta}," - " where @var{delta} is relative to middle@tie{}C.") + 2, 0, 0, (SCM p, SCM delta), + "Transpose @var{p} by the amount @var{delta}," + " where @var{delta} is relative to middle@tie{}C.") { LY_ASSERT_SMOB (Pitch, p, 1); LY_ASSERT_SMOB (Pitch, delta, 2); @@ -34,27 +34,27 @@ LY_DEFINE (ly_pitch_transpose, "ly:pitch-transpose", /* Should add optional args. */ LY_DEFINE (ly_make_pitch, "ly:make-pitch", - 2, 1, 0, (SCM octave, SCM note, SCM alter), - "@var{octave} is specified by an integer, zero for the octave" - " containing middle@tie{}C. @var{note} is a number indexing the" - " global default scale, with 0 corresponding to pitch@tie{}C" - " and 6 usually corresponding to pitch@tie{}B. @var{alter} is" - " a rational number of 200-cent whole tones for alteration.") + 2, 1, 0, (SCM octave, SCM note, SCM alter), + "@var{octave} is specified by an integer, zero for the octave" + " containing middle@tie{}C. @var{note} is a number indexing the" + " global default scale, with 0 corresponding to pitch@tie{}C" + " and 6 usually corresponding to pitch@tie{}B. @var{alter} is" + " a rational number of 200-cent whole tones for alteration.") { LY_ASSERT_TYPE (scm_is_integer, octave, 1); LY_ASSERT_TYPE (scm_is_integer, note, 2); LY_ASSERT_TYPE (scm_is_rational, alter, 3); - + Pitch p (scm_to_int (octave), scm_to_int (note), - ly_scm2rational (alter)); - + ly_scm2rational (alter)); + return p.smobbed_copy (); } LY_DEFINE (ly_pitch_negate, "ly:pitch-negate", 1, 0, 0, - (SCM p), - "Negate @var{p}.") + (SCM p), + "Negate @var{p}.") { LY_ASSERT_SMOB (Pitch, p, 1); Pitch *pp = unsmob_pitch (p); @@ -62,9 +62,9 @@ LY_DEFINE (ly_pitch_negate, "ly:pitch-negate", 1, 0, 0, } LY_DEFINE (ly_pitch_steps, "ly:pitch-steps", 1, 0, 0, - (SCM p), - "Number of steps counted from middle@tie{}C of the" - " pitch@tie{}@var{p}.") + (SCM p), + "Number of steps counted from middle@tie{}C of the" + " pitch@tie{}@var{p}.") { LY_ASSERT_SMOB (Pitch, p, 1); Pitch *pp = unsmob_pitch (p); @@ -72,8 +72,8 @@ LY_DEFINE (ly_pitch_steps, "ly:pitch-steps", 1, 0, 0, } LY_DEFINE (ly_pitch_octave, "ly:pitch-octave", - 1, 0, 0, (SCM pp), - "Extract the octave from pitch@tie{}@var{pp}.") + 1, 0, 0, (SCM pp), + "Extract the octave from pitch@tie{}@var{pp}.") { LY_ASSERT_SMOB (Pitch, pp, 1); Pitch *p = unsmob_pitch (pp); @@ -82,8 +82,8 @@ LY_DEFINE (ly_pitch_octave, "ly:pitch-octave", } LY_DEFINE (ly_pitch_alteration, "ly:pitch-alteration", - 1, 0, 0, (SCM pp), - "Extract the alteration from pitch@tie{}@var{pp}.") + 1, 0, 0, (SCM pp), + "Extract the alteration from pitch@tie{}@var{pp}.") { LY_ASSERT_SMOB (Pitch, pp, 1); Pitch *p = unsmob_pitch (pp); @@ -93,8 +93,8 @@ LY_DEFINE (ly_pitch_alteration, "ly:pitch-alteration", } LY_DEFINE (pitch_notename, "ly:pitch-notename", - 1, 0, 0, (SCM pp), - "Extract the note name from pitch @var{pp}.") + 1, 0, 0, (SCM pp), + "Extract the note name from pitch @var{pp}.") { LY_ASSERT_SMOB (Pitch, pp, 1); Pitch *p = unsmob_pitch (pp); @@ -103,9 +103,9 @@ LY_DEFINE (pitch_notename, "ly:pitch-notename", } LY_DEFINE (ly_pitch_quartertones, "ly:pitch-quartertones", - 1, 0, 0, (SCM pp), - "Calculate the number of quarter tones of@tie{}@var{pp} from" - " middle@tie{}C.") + 1, 0, 0, (SCM pp), + "Calculate the number of quarter tones of@tie{}@var{pp} from" + " middle@tie{}C.") { LY_ASSERT_SMOB (Pitch, pp, 1); Pitch *p = unsmob_pitch (pp); @@ -114,9 +114,9 @@ LY_DEFINE (ly_pitch_quartertones, "ly:pitch-quartertones", } LY_DEFINE (ly_pitch_semitones, "ly:pitch-semitones", - 1, 0, 0, (SCM pp), - "Calculate the number of semitones of@tie{}@var{pp} from" - " middle@tie{}C.") + 1, 0, 0, (SCM pp), + "Calculate the number of semitones of@tie{}@var{pp} from" + " middle@tie{}C.") { LY_ASSERT_SMOB (Pitch, pp, 1); Pitch *p = unsmob_pitch (pp); @@ -125,8 +125,8 @@ LY_DEFINE (ly_pitch_semitones, "ly:pitch-semitones", } LY_DEFINE (ly_pitch_less_p, "ly:pitch<?", - 2, 0, 0, (SCM p1, SCM p2), - "Is @var{p1} lexicographically smaller than @var{p2}?") + 2, 0, 0, (SCM p1, SCM p2), + "Is @var{p1} lexicographically smaller than @var{p2}?") { LY_ASSERT_SMOB (Pitch, p1, 1); LY_ASSERT_SMOB (Pitch, p2, 2); @@ -141,11 +141,11 @@ LY_DEFINE (ly_pitch_less_p, "ly:pitch<?", } LY_DEFINE (ly_pitch_diff, "ly:pitch-diff", - 2, 0, 0, (SCM pitch, SCM root), - "Return pitch @var{delta} such that @var{pitch} transposed by" - " @var{delta} equals @var{root}.") + 2, 0, 0, (SCM pitch, SCM root), + "Return pitch @var{delta} such that @var{pitch} transposed by" + " @var{delta} equals @var{root}.") { - + LY_ASSERT_SMOB (Pitch, pitch, 1); LY_ASSERT_SMOB (Pitch, root, 2); @@ -158,10 +158,10 @@ LY_DEFINE (ly_pitch_diff, "ly:pitch-diff", /* FIXME: probably isn't the right place for this function */ #include "context.hh" LY_DEFINE (ly_set_middle_C_x, "ly:set-middle-C!", - 1, 0, 0, (SCM context), - "Set the @code{middleCPosition} variable in @var{context}" - " based on the variables @code{middleCClefPosition} and" - " middleCOffset.") + 1, 0, 0, (SCM context), + "Set the @code{middleCPosition} variable in @var{context}" + " based on the variables @code{middleCClefPosition} and" + " middleCOffset.") { LY_ASSERT_SMOB (Context, context, 1); diff --git a/lily/pitch-squash-engraver.cc b/lily/pitch-squash-engraver.cc index 1ad824ee07..60f213338c 100644 --- a/lily/pitch-squash-engraver.cc +++ b/lily/pitch-squash-engraver.cc @@ -46,18 +46,18 @@ Pitch_squash_engraver::Pitch_squash_engraver () #include "translator.icc" ADD_ACKNOWLEDGER (Pitch_squash_engraver, note_head); ADD_TRANSLATOR (Pitch_squash_engraver, - /* doc */ - "Set the vertical position of note heads to" - " @code{squashedPosition}, if that property is set. This can" - " be used to make a single-line staff demonstrating the" - " rhythm of a melody.", + /* doc */ + "Set the vertical position of note heads to" + " @code{squashedPosition}, if that property is set. This can" + " be used to make a single-line staff demonstrating the" + " rhythm of a melody.", - /* create */ - "", + /* create */ + "", - /* read */ - "squashedPosition ", + /* read */ + "squashedPosition ", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/pitch.cc b/lily/pitch.cc index fbd785f9cd..97664e6530 100644 --- a/lily/pitch.cc +++ b/lily/pitch.cc @@ -26,7 +26,6 @@ #include "ly-smobs.icc" - Pitch::Pitch (int o, int n, Rational a) { notename_ = n; @@ -138,9 +137,9 @@ pitch_interval (Pitch const &from, Pitch const &to) { Rational sound = to.tone_pitch () - from.tone_pitch (); Pitch pt (to.get_octave () - from.get_octave (), - to.get_notename () - from.get_notename (), + to.get_notename () - from.get_notename (), - to.get_alteration () - from.get_alteration ()); + to.get_alteration () - from.get_alteration ()); return pt.transposed (Pitch (0, 0, sound - pt.tone_pitch ())); } @@ -148,14 +147,15 @@ pitch_interval (Pitch const &from, Pitch const &to) /* FIXME Merge with *pitch->text* funcs in chord-name.scm */ char const *accname[] = {"eses", "eseh", "es", "eh", "", - "ih", "is", "isih", "isis"}; + "ih", "is", "isih", "isis" + }; string Pitch::to_string () const { int n = (notename_ + 2) % scale_->step_count (); string s = ::to_string (char (n + 'a')); - Rational qtones = alteration_ * Rational (4,1); + Rational qtones = alteration_ * Rational (4, 1); int qt = int (rint (Real (qtones))); s += string (accname[qt + 4]); @@ -163,13 +163,13 @@ Pitch::to_string () const { int o = octave_ + 1; while (o--) - s += "'"; + s += "'"; } else if (octave_ < 0) { int o = (-octave_) - 1; while (o--) - s += ::to_string (','); + s += ::to_string (','); } return s; @@ -222,7 +222,7 @@ IMPLEMENT_TYPE_P (Pitch, "ly:pitch?"); SCM Pitch::mark_smob (SCM x) { - Pitch *p = (Pitch*) SCM_CELL_WORD_1 (x); + Pitch *p = (Pitch *) SCM_CELL_WORD_1 (x); return p->scale_->self_scm (); } @@ -244,8 +244,8 @@ Pitch::equal_p (SCM a, SCM b) Pitch *q = (Pitch *) SCM_CELL_WORD_1 (b); bool eq = p->notename_ == q->notename_ - && p->octave_ == q->octave_ - && p->alteration_ == q->alteration_; + && p->octave_ == q->octave_ + && p->alteration_ == q->alteration_; return eq ? SCM_BOOL_T : SCM_BOOL_F; } diff --git a/lily/pitched-trill-engraver.cc b/lily/pitched-trill-engraver.cc index 6960d3e2dd..658354ff6e 100644 --- a/lily/pitched-trill-engraver.cc +++ b/lily/pitched-trill-engraver.cc @@ -46,7 +46,7 @@ private: Item *trill_group_; Item *trill_accidental_; - vector<Grob*> heads_; + vector<Grob *> heads_; void make_trill (Stream_event *); }; @@ -89,24 +89,24 @@ Pitched_trill_engraver::make_trill (Stream_event *ev) SCM keysig = get_property ("localKeySignature"); SCM key = scm_cons (scm_from_int (p->get_octave ()), - scm_from_int (p->get_notename ())); + scm_from_int (p->get_notename ())); - int bn = measure_number (context()); + int bn = measure_number (context ()); SCM handle = scm_assoc (key, keysig); if (handle != SCM_BOOL_F) { bool same_bar = (bn == robust_scm2int (scm_caddr (handle), 0)); bool same_alt - = (p->get_alteration () == robust_scm2rational (scm_cadr (handle), 0)); + = (p->get_alteration () == robust_scm2rational (scm_cadr (handle), 0)); if (!same_bar || (same_bar && !same_alt)) - handle = SCM_BOOL_F; + handle = SCM_BOOL_F; } bool print_acc = (handle == SCM_BOOL_F) || p->get_alteration () == Rational (0) - || (ev->get_property ("force-accidental") == SCM_BOOL_T); + || (ev->get_property ("force-accidental") == SCM_BOOL_T); if (trill_head_) { @@ -120,8 +120,8 @@ Pitched_trill_engraver::make_trill (Stream_event *ev) int c0 = scm_is_number (c0scm) ? scm_to_int (c0scm) : 0; trill_head_->set_property ("staff-position", - scm_from_int (unsmob_pitch (scm_pitch)->steps () - + c0)); + scm_from_int (unsmob_pitch (scm_pitch)->steps () + + c0)); trill_group_ = make_item ("TrillPitchGroup", ev->self_scm ()); trill_group_->set_parent (trill_head_, Y_AXIS); @@ -135,7 +135,7 @@ Pitched_trill_engraver::make_trill (Stream_event *ev) // fixme: naming -> alterations trill_accidental_->set_property ("alteration", ly_rational2scm (p->get_alteration ())); Side_position_interface::add_support (trill_accidental_, trill_head_); - + trill_head_->set_object ("accidental-grob", trill_accidental_->self_scm ()); trill_accidental_->set_parent (trill_head_, Y_AXIS); Axis_group_interface::add_element (trill_group_, trill_accidental_); @@ -155,7 +155,6 @@ Pitched_trill_engraver::stop_translation_timestep () trill_accidental_ = 0; } - #include "translator.icc" ADD_ACKNOWLEDGER (Pitched_trill_engraver, note_head); @@ -163,17 +162,17 @@ ADD_ACKNOWLEDGER (Pitched_trill_engraver, dots); ADD_ACKNOWLEDGER (Pitched_trill_engraver, trill_spanner); ADD_TRANSLATOR (Pitched_trill_engraver, - /* doc */ - "Print the bracketed note head after a note head with trill.", + /* doc */ + "Print the bracketed note head after a note head with trill.", - /* create */ - "TrillPitchHead " - "TrillPitchAccidental " - "TrillPitchGroup ", + /* create */ + "TrillPitchHead " + "TrillPitchAccidental " + "TrillPitchGroup ", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/pointer-group-interface-scheme.cc b/lily/pointer-group-interface-scheme.cc index 53fe7b2097..d9fe6ebe7c 100644 --- a/lily/pointer-group-interface-scheme.cc +++ b/lily/pointer-group-interface-scheme.cc @@ -21,16 +21,16 @@ #include "grob.hh" LY_DEFINE (ly_pointer_group_interface__add_grob, "ly:pointer-group-interface::add-grob", - 3, 0, 0, (SCM grob, SCM sym, SCM grob_element), - "Add @var{grob-element} to @var{grob}'s @var{sym} grob array.") + 3, 0, 0, (SCM grob, SCM sym, SCM grob_element), + "Add @var{grob-element} to @var{grob}'s @var{sym} grob array.") { LY_ASSERT_TYPE (unsmob_grob, grob, 1); LY_ASSERT_TYPE (ly_is_symbol, sym, 2); LY_ASSERT_TYPE (unsmob_grob, grob_element, 3); Pointer_group_interface::add_grob (unsmob_grob (grob), - sym, - unsmob_grob (grob_element)); + sym, + unsmob_grob (grob_element)); return SCM_UNSPECIFIED; } diff --git a/lily/pointer-group-interface.cc b/lily/pointer-group-interface.cc index 78c4166d73..ff7bce3014 100644 --- a/lily/pointer-group-interface.cc +++ b/lily/pointer-group-interface.cc @@ -57,7 +57,7 @@ Pointer_group_interface::get_grob_array (Grob *me, SCM sym) } Grob * -Pointer_group_interface::find_grob (Grob *me, SCM sym, bool (*pred) (Grob*)) +Pointer_group_interface::find_grob (Grob *me, SCM sym, bool (*pred) (Grob *)) { Grob_array *arr = get_grob_array (me, sym); @@ -83,28 +83,28 @@ Pointer_group_interface::add_unordered_grob (Grob *me, SCM sym, Grob *p) arr->set_ordered (false); } -static vector<Grob*> empty_array; +static vector<Grob *> empty_array; -vector<Grob*> const & +vector<Grob *> const & ly_scm2link_array (SCM x) { Grob_array *arr = unsmob_grob_array (x); return arr ? arr->array () : empty_array; } -vector<Grob*> const & +vector<Grob *> const & internal_extract_grob_array (Grob const *elt, SCM symbol) { return elt - ? ly_scm2link_array (elt->internal_get_object (symbol)) - : empty_array; + ? ly_scm2link_array (elt->internal_get_object (symbol)) + : empty_array; } -vector<Item*> +vector<Item *> internal_extract_item_array (Grob const *elt, SCM symbol) { Grob_array *arr = unsmob_grob_array (elt->internal_get_object (symbol)); - vector<Item*> items; + vector<Item *> items; for (vsize i = 0; arr && i < arr->size (); i++) items.push_back (arr->item (i)); diff --git a/lily/prob-scheme.cc b/lily/prob-scheme.cc index 57881112d4..4fafc71fcf 100644 --- a/lily/prob-scheme.cc +++ b/lily/prob-scheme.cc @@ -20,8 +20,8 @@ #include "prob.hh" LY_DEFINE (ly_prob_set_property_x, "ly:prob-set-property!", - 2, 1, 0, (SCM obj, SCM sym, SCM value), - "Set property @var{sym} of @var{obj} to @var{value}.") + 2, 1, 0, (SCM obj, SCM sym, SCM value), + "Set property @var{sym} of @var{obj} to @var{value}.") { LY_ASSERT_SMOB (Prob, obj, 1); Prob *ps = unsmob_prob (obj); @@ -35,17 +35,17 @@ LY_DEFINE (ly_prob_set_property_x, "ly:prob-set-property!", Hmm, this is not orthogonal. */ LY_DEFINE (ly_prob_property_p, "ly:prob-property?", - 2, 1, 0, (SCM obj, SCM sym), - "Is boolean prop @var{sym} of @var{sym} set?") + 2, 1, 0, (SCM obj, SCM sym), + "Is boolean prop @var{sym} of @var{sym} set?") { return scm_equal_p (SCM_BOOL_T, ly_prob_property (obj, sym, SCM_BOOL_F)); } LY_DEFINE (ly_prob_property, "ly:prob-property", - 2, 1, 0, (SCM prob, SCM sym, SCM val), - "Return the value for property @var{sym} of Prob object" - " @var{prob}. If no value is found, return @var{val} or" - " @code{'()} if @var{val} is not specified.") + 2, 1, 0, (SCM prob, SCM sym, SCM val), + "Return the value for property @var{sym} of Prob object" + " @var{prob}. If no value is found, return @var{val} or" + " @code{'()} if @var{val} is not specified.") { LY_ASSERT_SMOB (Prob, prob, 1); Prob *ps = unsmob_prob (prob); @@ -62,18 +62,18 @@ LY_DEFINE (ly_prob_property, "ly:prob-property", } LY_DEFINE (ly_prob_type_p, "ly:prob-type?", - 2, 0, 0, - (SCM obj, SCM type), - "Is @var{obj} the specified prob-type?") + 2, 0, 0, + (SCM obj, SCM type), + "Is @var{obj} the specified prob-type?") { - Prob*prob = unsmob_prob (obj); + Prob *prob = unsmob_prob (obj); return scm_from_bool (prob && prob->type () == type); } LY_DEFINE (ly_make_prob, "ly:make-prob", - 2, 0, 1, - (SCM type, SCM init, SCM rest), - "Create a @code{Prob} object.") + 2, 0, 1, + (SCM type, SCM init, SCM rest), + "Create a @code{Prob} object.") { Prob *pr = new Prob (type, init); @@ -85,15 +85,14 @@ LY_DEFINE (ly_make_prob, "ly:make-prob", pr->set_property (sym, val); } - + return pr->unprotect (); } - LY_DEFINE (ly_prob_mutable_properties, "ly:prob-mutable-properties", - 1, 0, 0, - (SCM prob), - "Retrieve an alist of mutable properties.") + 1, 0, 0, + (SCM prob), + "Retrieve an alist of mutable properties.") { LY_ASSERT_SMOB (Prob, prob, 1); Prob *ps = unsmob_prob (prob); @@ -101,9 +100,9 @@ LY_DEFINE (ly_prob_mutable_properties, "ly:prob-mutable-properties", } LY_DEFINE (ly_prob_immutable_properties, "ly:prob-immutable-properties", - 1, 0, 0, - (SCM prob), - "Retrieve an alist of immutable properties.") + 1, 0, 0, + (SCM prob), + "Retrieve an alist of immutable properties.") { LY_ASSERT_SMOB (Prob, prob, 1); Prob *ps = unsmob_prob (prob); diff --git a/lily/prob.cc b/lily/prob.cc index 233c5b6d5f..7050c12949 100644 --- a/lily/prob.cc +++ b/lily/prob.cc @@ -58,22 +58,21 @@ Prob::equal_p (SCM sa, SCM sb) SCM bprop = props[1][i]; for (; - scm_is_pair (aprop) && scm_is_pair (bprop); - aprop = scm_cdr (aprop), bprop = scm_cdr (bprop)) - { - SCM aval = scm_cdar (aprop); - SCM bval = scm_cdar (bprop); - if (scm_caar (aprop) != scm_caar (bprop) || - ( - !(unsmob_input (aval) && unsmob_input (bval)) - && - !to_boolean (scm_equal_p (aval, bval)))) - return SCM_BOOL_F; - } + scm_is_pair (aprop) && scm_is_pair (bprop); + aprop = scm_cdr (aprop), bprop = scm_cdr (bprop)) + { + SCM aval = scm_cdar (aprop); + SCM bval = scm_cdar (bprop); + if (scm_caar (aprop) != scm_caar (bprop) + || (!(unsmob_input (aval) && unsmob_input (bval)) + && + !to_boolean (scm_equal_p (aval, bval)))) + return SCM_BOOL_F; + } /* is one list shorter? */ if (aprop != SCM_EOL || bprop != SCM_EOL) - return SCM_BOOL_F; + return SCM_BOOL_F; } return SCM_BOOL_T; @@ -88,7 +87,6 @@ Prob::Prob (SCM type, SCM immutable_init) smobify_self (); } - Prob::~Prob () { } @@ -107,7 +105,6 @@ Prob::Prob (Prob const &src) mutable_property_alist_ = src.copy_mutable_properties (); } - SCM Prob::copy_mutable_properties () const { @@ -132,7 +129,7 @@ Prob::mark_smob (SCM smob) } int -Prob::print_smob (SCM smob, SCM port, scm_print_state*) +Prob::print_smob (SCM smob, SCM port, scm_print_state *) { Prob *p = (Prob *) SCM_CELL_WORD_1 (smob); scm_puts ("#<", port); @@ -147,8 +144,6 @@ Prob::print_smob (SCM smob, SCM port, scm_print_state*) return 1; } - - SCM Prob::internal_get_property (SCM sym) const { @@ -170,7 +165,7 @@ Prob::internal_get_property (SCM sym) const /* We don't (yet) instrument probs */ void -Prob::instrumented_set_property (SCM sym, SCM val, const char*, int, const char*) +Prob::instrumented_set_property (SCM sym, SCM val, const char *, int, const char *) { internal_set_property (sym, val); } diff --git a/lily/profile.cc b/lily/profile.cc index 4a1c0b08f9..73dead7391 100644 --- a/lily/profile.cc +++ b/lily/profile.cc @@ -26,24 +26,23 @@ SCM grob_property_lookup_table; SCM prob_property_lookup_table; LY_DEFINE (ly_property_lookup_stats, "ly:property-lookup-stats", - 1, 0, 0, (SCM sym), - "Return hash table with a property access corresponding to" - " @var{sym}. Choices are @code{prob}, @code{grob}, and" - " @code{context}.") + 1, 0, 0, (SCM sym), + "Return hash table with a property access corresponding to" + " @var{sym}. Choices are @code{prob}, @code{grob}, and" + " @code{context}.") { if (sym == ly_symbol2scm ("context")) return context_property_lookup_table ? context_property_lookup_table - : scm_c_make_hash_table (1); + : scm_c_make_hash_table (1); if (sym == ly_symbol2scm ("prob")) return prob_property_lookup_table ? prob_property_lookup_table - : scm_c_make_hash_table (1); + : scm_c_make_hash_table (1); if (sym == ly_symbol2scm ("grob")) return grob_property_lookup_table ? grob_property_lookup_table - : scm_c_make_hash_table (1); + : scm_c_make_hash_table (1); return scm_c_make_hash_table (1); } - void note_property_access (SCM *table, SCM sym) { diff --git a/lily/program-option-scheme.cc b/lily/program-option-scheme.cc index 63266566ac..976d51062c 100644 --- a/lily/program-option-scheme.cc +++ b/lily/program-option-scheme.cc @@ -51,10 +51,9 @@ bool strict_infinity_checking = false; static SCM option_hash; - void internal_set_option (SCM var, - SCM val) + SCM val) { if (0) ; @@ -136,7 +135,6 @@ internal_set_option (SCM var, scm_hashq_set_x (option_hash, var, val); } - ssize const HELP_INDENT = 30; ssize const INDENT = 2; ssize const SEPARATION = 5; @@ -157,25 +155,25 @@ get_help_string () SCM sym = scm_caar (s); SCM val = scm_cdar (s); string opt_spec = String_convert::char_string (' ', INDENT) - + ly_symbol2string (sym) - + " (" - + ly_scm2string (scm_call_1 (converter, val)) - + ")"; + + ly_symbol2string (sym) + + " (" + + ly_scm2string (scm_call_1 (converter, val)) + + ")"; if (opt_spec.length () + SEPARATION > HELP_INDENT) - opt_spec += "\n" + String_convert::char_string (' ', HELP_INDENT); + opt_spec += "\n" + String_convert::char_string (' ', HELP_INDENT); else - opt_spec += String_convert::char_string (' ', HELP_INDENT - - opt_spec.length ()); + opt_spec += String_convert::char_string (' ', HELP_INDENT + - opt_spec.length ()); SCM opt_help_scm - = scm_object_property (sym, - ly_symbol2scm ("program-option-documentation")); + = scm_object_property (sym, + ly_symbol2scm ("program-option-documentation")); string opt_help = ly_scm2string (opt_help_scm); replace_all (&opt_help, - string ("\n"), - string ("\n") - + String_convert::char_string (' ', HELP_INDENT)); + string ("\n"), + string ("\n") + + String_convert::char_string (' ', HELP_INDENT)); opts.push_back (opt_spec + opt_help + "\n"); } @@ -187,21 +185,19 @@ get_help_string () return help; } - LY_DEFINE (ly_option_usage, "ly:option-usage", 0, 0, 0, (), - "Print @code{ly:set-option} usage.") + "Print @code{ly:set-option} usage.") { string help = get_help_string (); - puts (help.c_str()); + puts (help.c_str ()); return SCM_UNSPECIFIED; } - LY_DEFINE (ly_add_option, "ly:add-option", 3, 0, 0, - (SCM sym, SCM val, SCM description), - "Add a program option @var{sym}. @var{val} is the default" - " value and @var{description} is a string description.") + (SCM sym, SCM val, SCM description), + "Add a program option @var{sym}. @var{val} is the default" + " value and @var{description} is a string description.") { if (!option_hash) option_hash = scm_permanent_object (scm_c_make_hash_table (11)); @@ -211,14 +207,13 @@ LY_DEFINE (ly_add_option, "ly:add-option", 3, 0, 0, internal_set_option (sym, val); scm_set_object_property_x (sym, ly_symbol2scm ("program-option-documentation"), - description); + description); return SCM_UNSPECIFIED; } - LY_DEFINE (ly_set_option, "ly:set-option", 1, 1, 0, (SCM var, SCM val), - "Set a program option.") + "Set a program option.") { LY_ASSERT_TYPE (ly_is_symbol, var, 1); @@ -240,38 +235,33 @@ LY_DEFINE (ly_set_option, "ly:set-option", 1, 1, 0, (SCM var, SCM val), return SCM_UNSPECIFIED; } - LY_DEFINE (ly_command_line_options, "ly:command-line-options", 0, 0, 0, (), - "The Scheme options specified on command-line with @option{-d}.") + "The Scheme options specified on command-line with @option{-d}.") { return ly_string2scm (init_scheme_variables_global); } - LY_DEFINE (ly_command_line_code, "ly:command-line-code", 0, 0, 0, (), - "The Scheme code specified on command-line with @option{-e}.") + "The Scheme code specified on command-line with @option{-e}.") { return ly_string2scm (init_scheme_code_global); } - LY_DEFINE (ly_command_line_verbose_p, "ly:command-line-verbose?", 0, 0, 0, (), - "Was @code{be_verbose_global} set?") + "Was @code{be_verbose_global} set?") { return scm_from_bool (be_verbose_global); } - LY_DEFINE (ly_all_options, "ly:all-options", - 0, 0, 0, (), - "Get all option settings in an alist.") + 0, 0, 0, (), + "Get all option settings in an alist.") { return ly_hash2alist (option_hash); } - LY_DEFINE (ly_get_option, "ly:get-option", 1, 0, 0, (SCM var), - "Get a global option setting.") + "Get a global option setting.") { LY_ASSERT_TYPE (ly_is_symbol, var, 1); return scm_hashq_ref (option_hash, var, SCM_BOOL_F); diff --git a/lily/program-option.cc b/lily/program-option.cc index 8155025ee4..06fa3e11dc 100644 --- a/lily/program-option.cc +++ b/lily/program-option.cc @@ -2,7 +2,7 @@ This file is part of LilyPond, the GNU music typesetter. Copyright (C) 2007--2011 Han-Wen Nienhuys <hanwen@lilypond.org> - + LilyPond is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/lily/property-iterator.cc b/lily/property-iterator.cc index 2cb8b48680..5f8b8c408e 100644 --- a/lily/property-iterator.cc +++ b/lily/property-iterator.cc @@ -37,8 +37,8 @@ Property_iterator::process (Moment mom) Music *m = get_music (); SCM previous_value = o->get_property (m->get_property ("symbol")); send_stream_event (o, "SetProperty", m->origin (), - ly_symbol2scm ("symbol"), m->get_property ("symbol"), - ly_symbol2scm ("value"), m->get_property ("value")); + ly_symbol2scm ("symbol"), m->get_property ("symbol"), + ly_symbol2scm ("value"), m->get_property ("value")); /* For \once \set install a finalization hook to reset the property to the * previous value after the timestep */ @@ -46,10 +46,10 @@ Property_iterator::process (Moment mom) { Global_context *tg = get_outlet ()->get_global_context (); tg->add_finalization (scm_list_n (once_finalization_proc, - o->self_scm (), m->self_scm (), - ly_quote_scm (previous_value), SCM_UNDEFINED)); + o->self_scm (), m->self_scm (), + ly_quote_scm (previous_value), SCM_UNDEFINED)); } - + Simple_music_iterator::process (mom); } @@ -58,7 +58,7 @@ Property_unset_iterator::process (Moment m) { SCM sym = get_music ()->get_property ("symbol"); send_stream_event (get_outlet (), "UnsetProperty", get_music ()->origin (), - ly_symbol2scm ("symbol"), sym); + ly_symbol2scm ("symbol"), sym); Simple_music_iterator::process (m); } @@ -73,8 +73,8 @@ Property_iterator::once_finalization (SCM ctx, SCM music, SCM previous_value) // Do not use UnsetProperty, which sets the default, but rather // cache the value before the \once \set command and restore it now send_stream_event (c, "SetProperty", m->origin (), - ly_symbol2scm ("symbol"), m->get_property ("symbol"), - ly_symbol2scm ("value"), previous_value); + ly_symbol2scm ("symbol"), m->get_property ("symbol"), + ly_symbol2scm ("value"), previous_value); return SCM_UNSPECIFIED; } @@ -91,7 +91,7 @@ check_grob (Music *mus, SCM sym) if (!g) mus->origin ()->warning (_f ("not a grob name, `%s'", - ly_symbol2string (sym))); + ly_symbol2string (sym))); return g; } @@ -120,15 +120,15 @@ Push_property_iterator::process (Moment m) SCM val = get_music ()->get_property ("grob-value"); if (to_boolean (get_music ()->get_property ("pop-first")) - && !to_boolean (get_music ()->get_property ("once"))) - send_stream_event (get_outlet (), "Revert", get_music ()->origin (), - ly_symbol2scm ("symbol"), sym, - ly_symbol2scm ("property-path"), grob_property_path); - + && !to_boolean (get_music ()->get_property ("once"))) + send_stream_event (get_outlet (), "Revert", get_music ()->origin (), + ly_symbol2scm ("symbol"), sym, + ly_symbol2scm ("property-path"), grob_property_path); + send_stream_event (get_outlet (), "Override", get_music ()->origin (), - ly_symbol2scm ("symbol"), sym, - ly_symbol2scm ("property-path"), grob_property_path, - ly_symbol2scm ("value"), val); + ly_symbol2scm ("symbol"), sym, + ly_symbol2scm ("property-path"), grob_property_path, + ly_symbol2scm ("value"), val); } Simple_music_iterator::process (m); } @@ -146,8 +146,8 @@ Push_property_iterator::once_finalization (SCM ctx, SCM music) SCM grob_property_path = get_property_path (mus); send_stream_event (c, "Revert", mus->origin (), - ly_symbol2scm ("symbol"), sym, - ly_symbol2scm ("property-path"), grob_property_path); + ly_symbol2scm ("symbol"), sym, + ly_symbol2scm ("property-path"), grob_property_path); } return SCM_UNSPECIFIED; } @@ -162,7 +162,7 @@ Push_property_iterator::do_quit () Global_context *tg = get_outlet ()->get_global_context (); tg->add_finalization (scm_list_n (once_finalization_proc, - trans, music, SCM_UNDEFINED)); + trans, music, SCM_UNDEFINED)); } } @@ -176,8 +176,8 @@ Pop_property_iterator::process (Moment m) SCM grob_property_path = get_property_path (get_music ()); send_stream_event (get_outlet (), "Revert", get_music ()->origin (), - ly_symbol2scm ("symbol"), sym, - ly_symbol2scm ("property-path"), grob_property_path); + ly_symbol2scm ("symbol"), sym, + ly_symbol2scm ("property-path"), grob_property_path); } Simple_music_iterator::process (m); } diff --git a/lily/protected-scm.cc b/lily/protected-scm.cc index 4447371a83..13afb6b296 100644 --- a/lily/protected-scm.cc +++ b/lily/protected-scm.cc @@ -32,7 +32,7 @@ Protected_scm::Protected_scm (SCM s) Protected_scm::Protected_scm (Protected_scm const &s) { object_ = (SCM_NIMP (s.object_) ? scm_gc_protect_object (s.object_) - : s.object_); + : s.object_); } Protected_scm::~Protected_scm () diff --git a/lily/quote-iterator.cc b/lily/quote-iterator.cc index 749bc13407..b13d5e1cd5 100644 --- a/lily/quote-iterator.cc +++ b/lily/quote-iterator.cc @@ -40,7 +40,7 @@ public: SCM event_vector_; int event_idx_; int end_idx_; - + SCM transposed_musics_; DECLARE_SCHEME_CALLBACK (constructor, ()); @@ -77,7 +77,7 @@ Quote_iterator::accept_music_type (Stream_event *ev, bool is_cue) const for (; scm_is_pair (accept); accept = scm_cdr (accept)) { if (ev->internal_in_event_class (scm_car (accept))) - return true; + return true; } return false; } @@ -111,9 +111,9 @@ binsearch_scm_vector (SCM vec, SCM key, bool (*is_less) (SCM a, SCM b)) SCM when = scm_caar (scm_c_vector_ref (vec, cmp)); bool result = (*is_less) (key, when); if (result) - hi = cmp; + hi = cmp; else - lo = cmp; + lo = cmp; } while (hi - lo > 1); @@ -124,7 +124,7 @@ void Quote_iterator::construct_children () { Music_wrapper_iterator::construct_children (); - + SCM name = get_music ()->get_property ("quoted-context-type"); SCM id = get_music ()->get_property ("quoted-context-id"); @@ -132,7 +132,7 @@ Quote_iterator::construct_children () && scm_is_symbol (name)) { Context *cue_context = get_outlet ()->find_create_context (name, - ly_scm2string (id), SCM_EOL); + ly_scm2string (id), SCM_EOL); quote_outlet_.set_context (cue_context); } else @@ -160,13 +160,13 @@ bool Quote_iterator::quote_ok () const { return (event_idx_ >= 0 - && scm_is_vector (event_vector_) - && event_idx_ <= end_idx_ + && scm_is_vector (event_vector_) + && event_idx_ <= end_idx_ - /* - Don't quote the grace notes leading to an unquoted note. - */ - && vector_moment (event_idx_).main_part_ < stop_moment_.main_part_); + /* + Don't quote the grace notes leading to an unquoted note. + */ + && vector_moment (event_idx_).main_part_ < stop_moment_.main_part_); } Moment @@ -208,14 +208,14 @@ Quote_iterator::process (Moment m) if (event_idx_ < 0) { event_idx_ = binsearch_scm_vector (event_vector_, - get_outlet ()->now_mom ().smobbed_copy (), - &moment_less); + get_outlet ()->now_mom ().smobbed_copy (), + &moment_less); start_moment_ = get_outlet ()->now_mom () - music_start_mom (); stop_moment_ = start_moment_ + get_music ()->get_length (); end_idx_ = binsearch_scm_vector (event_vector_, - stop_moment_.smobbed_copy (), - &moment_less); + stop_moment_.smobbed_copy (), + &moment_less); } m += start_moment_; @@ -223,10 +223,10 @@ Quote_iterator::process (Moment m) { Moment em = vector_moment (event_idx_); if (em > m) - return; + return; if (em == m) - break; + break; event_idx_++; } @@ -237,41 +237,41 @@ Quote_iterator::process (Moment m) Pitch *quote_pitch = unsmob_pitch (scm_cdar (entry)); /* - The pitch that sounds like central C + The pitch that sounds like central C */ Pitch *me_pitch = unsmob_pitch (get_music ()->get_property ("quoted-transposition")); if (!me_pitch) - me_pitch = unsmob_pitch (get_outlet ()->get_property ("instrumentTransposition")); + me_pitch = unsmob_pitch (get_outlet ()->get_property ("instrumentTransposition")); SCM cid = get_music ()->get_property ("quoted-context-id"); bool is_cue = scm_is_string (cid) && (ly_scm2string (cid) == "cue"); for (SCM s = scm_cdr (entry); scm_is_pair (s); s = scm_cdr (s)) - { - SCM ev_acc = scm_car (s); - - Stream_event *ev = unsmob_stream_event (scm_car (ev_acc)); - if (!ev) - programming_error ("no music found in quote"); - else if (accept_music_type (ev, is_cue)) - { - /* create a transposed copy if necessary */ - if (quote_pitch || me_pitch) - { - Pitch qp, mp; - if (quote_pitch) - qp = *quote_pitch; - if (me_pitch) - mp = *me_pitch; - - Pitch diff = pitch_interval (qp, mp); - ev = ev->clone (); - - transpose_mutable (ev->get_property_alist (true), diff); - transposed_musics_ = scm_cons (ev->unprotect (), transposed_musics_); - } - quote_outlet_.get_outlet ()->event_source ()->broadcast (ev); - } - } + { + SCM ev_acc = scm_car (s); + + Stream_event *ev = unsmob_stream_event (scm_car (ev_acc)); + if (!ev) + programming_error ("no music found in quote"); + else if (accept_music_type (ev, is_cue)) + { + /* create a transposed copy if necessary */ + if (quote_pitch || me_pitch) + { + Pitch qp, mp; + if (quote_pitch) + qp = *quote_pitch; + if (me_pitch) + mp = *me_pitch; + + Pitch diff = pitch_interval (qp, mp); + ev = ev->clone (); + + transpose_mutable (ev->get_property_alist (true), diff); + transposed_musics_ = scm_cons (ev->unprotect (), transposed_musics_); + } + quote_outlet_.get_outlet ()->event_source ()->broadcast (ev); + } + } event_idx_++; } diff --git a/lily/relative-octave-check.cc b/lily/relative-octave-check.cc index bb597f97cb..9a2a9bebcb 100644 --- a/lily/relative-octave-check.cc +++ b/lily/relative-octave-check.cc @@ -28,7 +28,7 @@ public: }; MAKE_SCHEME_CALLBACK (Relative_octave_check, relative_callback, 2) - SCM +SCM Relative_octave_check::relative_callback (SCM music, SCM last_pitch) { Pitch p = *unsmob_pitch (last_pitch); @@ -39,23 +39,23 @@ Relative_octave_check::relative_callback (SCM music, SCM last_pitch) if (check_p) { Pitch no_octave (-1, - check_p->get_notename (), - check_p->get_alteration ()); + check_p->get_notename (), + check_p->get_alteration ()); Pitch result = no_octave.to_relative_octave (p); if (result != *check_p) - { - string s = _ ("Failed octave check, got: "); - s += result.to_string (); + { + string s = _ ("Failed octave check, got: "); + s += result.to_string (); - m->origin ()->warning (s); + m->origin ()->warning (s); - delta_oct = check_p->get_octave () - result.get_octave (); - } + delta_oct = check_p->get_octave () - result.get_octave (); + } } return Pitch (p.get_octave () + delta_oct, - p.get_notename (), - p.get_alteration ()).smobbed_copy (); + p.get_notename (), + p.get_alteration ()).smobbed_copy (); } diff --git a/lily/relative-octave-music.cc b/lily/relative-octave-music.cc index 6c23ac3ed7..73b340d0fe 100644 --- a/lily/relative-octave-music.cc +++ b/lily/relative-octave-music.cc @@ -29,15 +29,15 @@ public: }; MAKE_SCHEME_CALLBACK (Relative_octave_music, no_relative_callback, 2) - SCM +SCM Relative_octave_music::no_relative_callback (SCM /* music */, - SCM pitch) + SCM pitch) { return pitch; } MAKE_SCHEME_CALLBACK (Relative_octave_music, relative_callback, 2) - SCM +SCM Relative_octave_music::relative_callback (SCM music, SCM pitch) { Music *me = unsmob_music (music); @@ -45,11 +45,11 @@ Relative_octave_music::relative_callback (SCM music, SCM pitch) { lily_1_8_compatibility_used = true; /* last-pitch should be junked some time, when - we ditch 1.8 compat too. + we ditch 1.8 compat too. - When you do, B should start where A left off. + When you do, B should start where A left off. - \relative { A \relative { ...} B } */ + \relative { A \relative { ...} B } */ SCM last_pitch = me->get_property ("last-pitch"); Pitch *ptr = unsmob_pitch (last_pitch); return (ptr) ? last_pitch : pitch; diff --git a/lily/relocate.cc b/lily/relocate.cc index 628187363b..964e02941d 100644 --- a/lily/relocate.cc +++ b/lily/relocate.cc @@ -21,7 +21,6 @@ #include "config.hh" - /* TODO: autoconf support */ #include <sys/types.h> @@ -51,17 +50,17 @@ sane_putenv (char const *key, string value, bool overwrite) char *s = strdup (combine.c_str ()); if (be_verbose_global) - progress_indication (_f ("Setting %s to %s" , key, value.c_str ()) - + "\n"); - - int retval = putenv (s); + progress_indication (_f ("Setting %s to %s", key, value.c_str ()) + + "\n"); + + int retval = putenv (s); /* - unfortunately, we can't portably free S here, - due to various bugs in glibc prior to 2.1.1 - */ + unfortunately, we can't portably free S here, + due to various bugs in glibc prior to 2.1.1 + */ return retval; } - + return -1; } @@ -91,10 +90,10 @@ prepend_env_path (char const *key, string value) if (is_dir (value)) { if (be_verbose_global) - progress_indication (_f ("%s=%s (prepend)\n", key, value.c_str ())); + progress_indication (_f ("%s=%s (prepend)\n", key, value.c_str ())); if (char const *cur = getenv (key)) - value += to_string (PATHSEP) + cur; + value += to_string (PATHSEP) + cur; return sane_putenv (key, value.c_str (), true); } @@ -122,8 +121,8 @@ prefix_relocation (string prefix) lilypond_datadir = package_datadir + "/current"; else warning (_f ("not relocating, no %s/ or current/ found under %s", - TOPLEVEL_VERSION, package_datadir.c_str ())); - + TOPLEVEL_VERSION, package_datadir.c_str ())); + #if HAVE_GETTEXT if (is_dir (localedir)) bindtextdomain ("lilypond", localedir.c_str ()); @@ -133,8 +132,8 @@ prefix_relocation (string prefix) if (be_verbose_global) warning (_f ("Relocation: compile datadir=%s, new datadir=%s", - old_lilypond_datadir.c_str (), - lilypond_datadir.c_str ())); + old_lilypond_datadir.c_str (), + lilypond_datadir.c_str ())); } /* @@ -148,11 +147,11 @@ framework_relocation (string prefix) warning (_f ("Relocation: framework_prefix=%s", prefix)); sane_putenv ("INSTALLER_PREFIX", prefix, true); - + read_relocation_dir (prefix + "/etc/relocate/"); string bindir = prefix + "/bin"; - + prepend_env_path ("PATH", bindir); } @@ -163,77 +162,77 @@ void setup_paths (char const *argv0_ptr) { File_name argv0_filename (argv0_ptr); - + if (relocate_binary) { string prefix_directory; if (getenv ("LILYPOND_RELOCATE_PREFIX")) - { - prefix_directory = getenv ("LILYPOND_RELOCATE_PREFIX"); + { + prefix_directory = getenv ("LILYPOND_RELOCATE_PREFIX"); #ifdef __MINGW32__ - /* Normalize file name. */ - prefix_directory = File_name (prefix_directory).to_string (); + /* Normalize file name. */ + prefix_directory = File_name (prefix_directory).to_string (); #endif /* __MINGW32__ */ - - prefix_relocation (prefix_directory); - string bindir = prefix_directory + "/bin"; - framework_relocation (bindir); - } + + prefix_relocation (prefix_directory); + string bindir = prefix_directory + "/bin"; + framework_relocation (bindir); + } else if (relocate_binary) - { - string argv0_abs; - if (argv0_filename.is_absolute ()) - { - argv0_abs = argv0_filename.to_string (); - if (be_verbose_global) - warning (_f ("Relocation: is absolute: argv0=%s", argv0_ptr)); - } - else if (argv0_filename.dir_.length ()) - { - argv0_abs = get_working_directory () - + "/" + string (argv0_filename.to_string ()); - if (be_verbose_global) - warning (_f ("Relocation: from cwd: argv0=%s", argv0_ptr)); - } - else - { - /* Find absolute ARGV0 name, using PATH. */ - File_path path; - path.parse_path (getenv ("PATH")); + { + string argv0_abs; + if (argv0_filename.is_absolute ()) + { + argv0_abs = argv0_filename.to_string (); + if (be_verbose_global) + warning (_f ("Relocation: is absolute: argv0=%s", argv0_ptr)); + } + else if (argv0_filename.dir_.length ()) + { + argv0_abs = get_working_directory () + + "/" + string (argv0_filename.to_string ()); + if (be_verbose_global) + warning (_f ("Relocation: from cwd: argv0=%s", argv0_ptr)); + } + else + { + /* Find absolute ARGV0 name, using PATH. */ + File_path path; + path.parse_path (getenv ("PATH")); #ifndef __MINGW32__ - argv0_abs = path.find (argv0_filename.to_string ()); + argv0_abs = path.find (argv0_filename.to_string ()); #else /* __MINGW32__ */ - path.prepend (get_working_directory ()); - char const *ext[] = {"exe", "", 0 }; - argv0_abs = path.find (argv0_filename.to_string (), ext); + path.prepend (get_working_directory ()); + char const *ext[] = {"exe", "", 0 }; + argv0_abs = path.find (argv0_filename.to_string (), ext); #endif /* __MINGW32__ */ - if (be_verbose_global) - warning (_f ("Relocation: from PATH=%s\nargv0=%s", - path.to_string ().c_str (), argv0_ptr)); - - if (argv0_abs.empty ()) - programming_error ("cannot find absolute argv0"); - } - - string bindir = dir_name (argv0_abs); - string argv0_prefix = dir_name (bindir); - string compile_prefix = dir_name (dir_name (dir_name (lilypond_datadir))); - if (argv0_prefix != compile_prefix) - { - prefix_relocation (argv0_prefix); - prefix_directory = argv0_prefix; - } - if (argv0_prefix != compile_prefix || string (FRAMEWORKDIR) != "..") - { - framework_relocation (bindir + "/" + FRAMEWORKDIR); - prefix_directory = bindir + "/" + FRAMEWORKDIR; - } - } + if (be_verbose_global) + warning (_f ("Relocation: from PATH=%s\nargv0=%s", + path.to_string ().c_str (), argv0_ptr)); + + if (argv0_abs.empty ()) + programming_error ("cannot find absolute argv0"); + } + + string bindir = dir_name (argv0_abs); + string argv0_prefix = dir_name (bindir); + string compile_prefix = dir_name (dir_name (dir_name (lilypond_datadir))); + if (argv0_prefix != compile_prefix) + { + prefix_relocation (argv0_prefix); + prefix_directory = argv0_prefix; + } + if (argv0_prefix != compile_prefix || string (FRAMEWORKDIR) != "..") + { + framework_relocation (bindir + "/" + FRAMEWORKDIR); + prefix_directory = bindir + "/" + FRAMEWORKDIR; + } + } lilypond_datadir = prefix_directory - + "/share/lilypond/" TOPLEVEL_VERSION; + + "/share/lilypond/" TOPLEVEL_VERSION; } if (getenv ("LILYPONDPREFIX")) @@ -253,26 +252,25 @@ setup_paths (char const *argv0_ptr) && is_dir (build_datadir_current.c_str ())) lilypond_datadir = build_datadir_current; + lilypond_datadir = File_name (lilypond_datadir).canonicalized ().to_string (); - lilypond_datadir = File_name (lilypond_datadir).canonicalized().to_string(); - global_path.append (""); /* Adding mf/out make lilypond unchanged source directory, when setting LILYPONDPREFIX to lilypond-x.y.z */ char const *suffixes[] = {"ly", "ps", "scm", 0 }; - + vector<string> dirs; for (char const **s = suffixes; *s; s++) { string path = lilypond_datadir + to_string ('/') + string (*s); dirs.push_back (path); } - + dirs.push_back (lilypond_datadir + "/fonts/otf/"); dirs.push_back (lilypond_datadir + "/fonts/type1/"); dirs.push_back (lilypond_datadir + "/fonts/svg/"); - + for (vsize i = 0; i < dirs.size (); i++) global_path.prepend (dirs[i]); } @@ -288,57 +286,57 @@ expand_environment_variables (string orig) while (ptr < start_ptr + len) { char const *dollar = strchr (ptr, '$'); - + if (dollar != NULL) - { - char const *start_var = dollar + 1; - char const *end_var = start_var; - char const *start_next = end_var; - - out += string (ptr, dollar - ptr); - ptr = dollar; - - if (*start_var == '{') - { - start_var ++; - - end_var = strchr (start_var, '}'); - - if (end_var == NULL) - { - end_var = start_var + len; - start_next = end_var; - } - else - { - start_next = end_var + 1; - } - } - else - { - /* - Hmm. what to do for $1 , $~ etc.? - */ - do - { - end_var ++; - } - while (isalnum (*end_var) || *end_var == '_'); - start_next = end_var; - } - - if (start_var < end_var) - { - string var_name (start_var, end_var - start_var); - char const *value = getenv (var_name.c_str ()); - if (value != NULL) - out += string (value); - - ptr = start_next; - } - } + { + char const *start_var = dollar + 1; + char const *end_var = start_var; + char const *start_next = end_var; + + out += string (ptr, dollar - ptr); + ptr = dollar; + + if (*start_var == '{') + { + start_var++; + + end_var = strchr (start_var, '}'); + + if (end_var == NULL) + { + end_var = start_var + len; + start_next = end_var; + } + else + { + start_next = end_var + 1; + } + } + else + { + /* + Hmm. what to do for $1 , $~ etc.? + */ + do + { + end_var++; + } + while (isalnum (*end_var) || *end_var == '_'); + start_next = end_var; + } + + if (start_var < end_var) + { + string var_name (start_var, end_var - start_var); + char const *value = getenv (var_name.c_str ()); + if (value != NULL) + out += string (value); + + ptr = start_next; + } + } else - break; + break; } @@ -352,10 +350,10 @@ static string read_line (FILE *f) { string out; - + int c = 0; while ((c = fgetc (f)) != EOF && c != '\n') - out += char(c); + out += char (c); return out; } @@ -365,8 +363,8 @@ read_relocation_file (string filename) { if (be_verbose_global) progress_indication (_f ("Relocation file: %s", filename.c_str ()) - + "\n"); - + + "\n"); + char const *cname = filename.c_str (); FILE *f = fopen (cname, "r"); if (!f) @@ -377,13 +375,13 @@ read_relocation_file (string filename) string line = read_line (f); size_t idx = line.find (' '); if (idx == NPOS) - continue; - + continue; + string command = line.substr (0, idx); line = line.substr (idx + 1); - + if (idx == NPOS) - continue; + continue; idx = line.find ('='); string variable = line.substr (0, idx); @@ -392,15 +390,15 @@ read_relocation_file (string filename) value = expand_environment_variables (value); if (command == "set") - sane_putenv (variable.c_str (), value, true); + sane_putenv (variable.c_str (), value, true); else if (command == "setdir") - set_env_dir (variable.c_str (), value); + set_env_dir (variable.c_str (), value); else if (command == "setfile") - set_env_file (variable.c_str (), value); + set_env_file (variable.c_str (), value); else if (command == "prependdir") - prepend_env_path (variable.c_str (), value); + prepend_env_path (variable.c_str (), value); else - error (_f ("Unknown relocation command %s", command)); + error (_f ("Unknown relocation command %s", command)); } fclose (f); @@ -412,8 +410,8 @@ read_relocation_dir (string dirname) if (DIR *dir = opendir (dirname.c_str ())) while (struct dirent *ent = readdir (dir)) { - File_name name (ent->d_name); - if (name.ext_ == "reloc") - read_relocation_file (dirname + "/" + name.to_string ()); + File_name name (ent->d_name); + if (name.ext_ == "reloc") + read_relocation_file (dirname + "/" + name.to_string ()); } } diff --git a/lily/repeat-acknowledge-engraver.cc b/lily/repeat-acknowledge-engraver.cc index ed2f41fcf0..b4ec8ff09c 100644 --- a/lily/repeat-acknowledge-engraver.cc +++ b/lily/repeat-acknowledge-engraver.cc @@ -85,11 +85,11 @@ Repeat_acknowledge_engraver::process_music () { SCM command = scm_car (cs); if (command == ly_symbol2scm ("start-repeat")) - start = true; + start = true; else if (command == ly_symbol2scm ("end-repeat")) - end = true; + end = true; else if (scm_is_pair (command) && scm_car (command) == ly_symbol2scm ("volta")) - volta_found = true; + volta_found = true; cs = scm_cdr (cs); } @@ -113,24 +113,24 @@ Repeat_acknowledge_engraver::process_music () if (!scm_is_string (wb) || ly_is_equal (db, wb)) { if (s != "" || (volta_found && !scm_is_string (wb))) - context ()->set_property ("whichBar", ly_string2scm (s)); + context ()->set_property ("whichBar", ly_string2scm (s)); } } ADD_TRANSLATOR (Repeat_acknowledge_engraver, - /* doc */ - "Acknowledge repeated music, and convert the contents of" - " @code{repeatCommands} into an appropriate setting for" - " @code{whichBar}.", - - /* create */ - "", - - /* read */ - "doubleRepeatType " - "repeatCommands " - "whichBar ", - - /* write */ - "" - ); + /* doc */ + "Acknowledge repeated music, and convert the contents of" + " @code{repeatCommands} into an appropriate setting for" + " @code{whichBar}.", + + /* create */ + "", + + /* read */ + "doubleRepeatType " + "repeatCommands " + "whichBar ", + + /* write */ + "" + ); diff --git a/lily/repeat-tie-engraver.cc b/lily/repeat-tie-engraver.cc index b2d5d6134e..a1d9c9a803 100644 --- a/lily/repeat-tie-engraver.cc +++ b/lily/repeat-tie-engraver.cc @@ -18,7 +18,6 @@ along with LilyPond. If not, see <http://www.gnu.org/licenses/>. */ - #include "engraver.hh" #include "item.hh" #include "pointer-group-interface.hh" @@ -30,12 +29,12 @@ class Repeat_tie_engraver : public Engraver { Stream_event *event_; Grob *semi_tie_column_; - vector<Grob*> semi_ties_; - - void stop_translation_timestep (); + vector<Grob *> semi_ties_; + + void stop_translation_timestep (); DECLARE_ACKNOWLEDGER (note_head); DECLARE_TRANSLATOR_LISTENER (repeat_tie); - + public: TRANSLATOR_DECLARATIONS (Repeat_tie_engraver); }; @@ -75,33 +74,32 @@ Repeat_tie_engraver::acknowledge_note_head (Grob_info inf) SCM cause = event_->self_scm (); Grob *semi_tie = make_item ("RepeatTie", cause); semi_tie->set_object ("note-head", inf.grob ()->self_scm ()); - + Pointer_group_interface::add_grob (semi_tie_column_, ly_symbol2scm ("ties"), - semi_tie); + semi_tie); semi_tie->set_parent (semi_tie_column_, Y_AXIS); semi_ties_.push_back (semi_tie); - if (is_direction (unsmob_stream_event (cause)->get_property ("direction"))) { Direction d = to_dir (unsmob_stream_event (cause)->get_property ("direction")); - semi_tie->set_property ("direction", scm_from_int (d)); + semi_tie->set_property ("direction", scm_from_int (d)); } } ADD_ACKNOWLEDGER (Repeat_tie_engraver, note_head); -ADD_TRANSLATOR (Repeat_tie_engraver, - /* doc */ - "Create repeat ties.", - - /* create */ - "RepeatTie " - "RepeatTieColumn ", - - /* read */ - "", - - /* write */ - "" - ); +ADD_TRANSLATOR (Repeat_tie_engraver, + /* doc */ + "Create repeat ties.", + + /* create */ + "RepeatTie " + "RepeatTieColumn ", + + /* read */ + "", + + /* write */ + "" + ); diff --git a/lily/repeated-music.cc b/lily/repeated-music.cc index 581b1ac17a..2560391a08 100644 --- a/lily/repeated-music.cc +++ b/lily/repeated-music.cc @@ -45,16 +45,16 @@ Repeated_music::relative_callback (SCM music, SCM pitch) { Music *body = unsmob_music (me->get_property ("element")); if (body) - p = body->to_relative_octave (p); + p = body->to_relative_octave (p); Pitch last = p; SCM alternatives = me->get_property ("elements"); for (SCM s = alternatives; scm_is_pair (s); s = scm_cdr (s)) - { - lily_1_8_compatibility_used = true; - unsmob_music (scm_car (s))->to_relative_octave (p); - } + { + lily_1_8_compatibility_used = true; + unsmob_music (scm_car (s))->to_relative_octave (p); + } return last.smobbed_copy (); } @@ -83,7 +83,7 @@ Repeated_music::alternatives_get_length (Music *me, bool fold) m = m + unsmob_music (scm_car (p))->get_length (); done++; if (count - done < len) - p = scm_cdr (p); + p = scm_cdr (p); } return m; } @@ -167,7 +167,7 @@ Repeated_music::first_start (SCM m) Music *body = unsmob_music (me->get_property ("element")); Moment rv = (body) ? body->start_mom () - : Music_sequence::first_start (me->get_property ("elements")); + : Music_sequence::first_start (me->get_property ("elements")); return rv.smobbed_copy (); } diff --git a/lily/rest-collision-engraver.cc b/lily/rest-collision-engraver.cc index d1f1640cf3..8162341355 100644 --- a/lily/rest-collision-engraver.cc +++ b/lily/rest-collision-engraver.cc @@ -52,7 +52,7 @@ void Rest_collision_engraver::process_acknowledged () { vsize rest_count = 0; - set<Grob*> columns; + set<Grob *> columns; Moment now = now_mom (); for (SCM s = get_property ("busyGrobs"); scm_is_pair (s); s = scm_cdr (s)) @@ -60,32 +60,32 @@ Rest_collision_engraver::process_acknowledged () Grob *g = unsmob_grob (scm_cdar (s)); Moment *m = unsmob_moment (scm_caar (s)); if (!g || !m) - continue; + continue; if (Rhythmic_head::has_interface (g) && (*m) > now) - { - Grob *column = g->get_parent (X_AXIS); - if (!column) - { - g->warning (_ ("rhythmic head is not part of a rhythmic column")); - continue; - } - - // Only include rests that start now. Include notes that started any time. - Paper_column *paper_column = dynamic_cast<Item*> (column)->get_column (); - if (!Rest::has_interface (g) || !paper_column || Paper_column::when_mom (paper_column) == now) - { - columns.insert (column); - rest_count += Note_column::has_rests (column); - } - } + { + Grob *column = g->get_parent (X_AXIS); + if (!column) + { + g->warning (_ ("rhythmic head is not part of a rhythmic column")); + continue; + } + + // Only include rests that start now. Include notes that started any time. + Paper_column *paper_column = dynamic_cast<Item *> (column)->get_column (); + if (!Rest::has_interface (g) || !paper_column || Paper_column::when_mom (paper_column) == now) + { + columns.insert (column); + rest_count += Note_column::has_rests (column); + } + } } if (!rest_collision_ && rest_count && columns.size () > 1) { rest_collision_ = make_item ("RestCollision", SCM_EOL); - for (set<Grob*>::iterator i = columns.begin (); i != columns.end (); ++i) - Rest_collision::add_column (rest_collision_, *i); + for (set<Grob *>::iterator i = columns.begin (); i != columns.end (); ++i) + Rest_collision::add_column (rest_collision_, *i); } } @@ -98,15 +98,15 @@ Rest_collision_engraver::stop_translation_timestep () #include "translator.icc" ADD_TRANSLATOR (Rest_collision_engraver, - /* doc */ - "Handle collisions of rests.", + /* doc */ + "Handle collisions of rests.", - /* create */ - "RestCollision ", + /* create */ + "RestCollision ", - /* read */ - "busyGrobs ", + /* read */ + "busyGrobs ", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/rest-collision.cc b/lily/rest-collision.cc index 8be91e3f23..fc8a4b401d 100644 --- a/lily/rest-collision.cc +++ b/lily/rest-collision.cc @@ -19,7 +19,7 @@ #include "rest-collision.hh" -#include <cmath> // ceil. +#include <cmath> // ceil. using namespace std; #include "directional-element-interface.hh" @@ -49,13 +49,13 @@ Rest_collision::force_shift_callback_rest (SCM rest, SCM offset) */ if (scm_is_number (offset)) rest_grob->translate_axis (scm_to_double (offset), Y_AXIS); - + if (Note_column::has_interface (parent) && Note_column::has_rests (parent)) { Grob *collision = unsmob_grob (parent->get_object ("rest-collision")); if (collision) - (void) collision->get_property ("positioning-done"); + (void) collision->get_property ("positioning-done"); } return scm_from_double (0.0); @@ -72,7 +72,7 @@ Rest_collision::add_column (Grob *me, Grob *p) if (rest) { chain_offset_callback (rest, - Rest_collision::force_shift_callback_rest_proc, Y_AXIS); + Rest_collision::force_shift_callback_rest_proc, Y_AXIS); } } @@ -98,16 +98,16 @@ Rest_collision::calc_positioning_done (SCM smob) extract_grob_set (me, "elements", elts); - vector<Grob*> rests; - vector<Grob*> notes; + vector<Grob *> rests; + vector<Grob *> notes; for (vsize i = 0; i < elts.size (); i++) { Grob *e = elts[i]; if (unsmob_grob (e->get_object ("rest"))) - rests.push_back (e); + rests.push_back (e); else - notes.push_back (e); + notes.push_back (e); } /* @@ -131,160 +131,160 @@ Rest_collision::calc_positioning_done (SCM smob) { /* - This is incomplete: in case of an uneven number of rests, the - center one should be centered on the staff. + This is incomplete: in case of an uneven number of rests, the + center one should be centered on the staff. */ - Drul_array<vector<Grob*> > ordered_rests; + Drul_array<vector<Grob *> > ordered_rests; for (vsize i = 0; i < rests.size (); i++) - { - Grob *r = Note_column::get_rest (rests[i]); + { + Grob *r = Note_column::get_rest (rests[i]); - Direction d = get_grob_direction (r); - if (d) - ordered_rests[d].push_back (r); - else - rests[d]->warning (_ ("cannot resolve rest collision: rest direction not set")); - } + Direction d = get_grob_direction (r); + if (d) + ordered_rests[d].push_back (r); + else + rests[d]->warning (_ ("cannot resolve rest collision: rest direction not set")); + } Direction d = LEFT; do - vector_sort (ordered_rests[d], rest_shift_less); + vector_sort (ordered_rests[d], rest_shift_less); while (flip (&d) != LEFT) - ; + ; do - { - if (ordered_rests[d].size () < 1) - { - if (ordered_rests[-d].size () > 1) - ordered_rests[-d][0]->warning (_ ("too many colliding rests")); - - return SCM_BOOL_T; - } - } + { + if (ordered_rests[d].size () < 1) + { + if (ordered_rests[-d].size () > 1) + ordered_rests[-d][0]->warning (_ ("too many colliding rests")); + + return SCM_BOOL_T; + } + } while (flip (&d) != LEFT); Grob *common = common_refpoint_of_array (ordered_rests[DOWN], me, Y_AXIS); common = common_refpoint_of_array (ordered_rests[UP], common, Y_AXIS); Real diff - = (ordered_rests[DOWN].back ()->extent (common, Y_AXIS)[UP] - - ordered_rests[UP].back ()->extent (common, Y_AXIS)[DOWN]) / staff_space; + = (ordered_rests[DOWN].back ()->extent (common, Y_AXIS)[UP] + - ordered_rests[UP].back ()->extent (common, Y_AXIS)[DOWN]) / staff_space; if (diff > 0) - { - int amount_down = (int) ceil (diff / 2); - diff -= amount_down; - Rest::translate (ordered_rests[DOWN].back (), - -2 * amount_down); - if (diff > 0) - Rest::translate (ordered_rests[UP].back (), - 2 * int (ceil (diff))); - } + { + int amount_down = (int) ceil (diff / 2); + diff -= amount_down; + Rest::translate (ordered_rests[DOWN].back (), + -2 * amount_down); + if (diff > 0) + Rest::translate (ordered_rests[UP].back (), + 2 * int (ceil (diff))); + } do - { - for (vsize i = ordered_rests[d].size () - 1; i-- > 0;) - { - Real last_y = ordered_rests[d][i + 1]->extent (common, Y_AXIS)[d]; - Real y = ordered_rests[d][i]->extent (common, Y_AXIS)[-d]; - - Real diff = d * ((last_y - y) / staff_space); - if (diff > 0) - Rest::translate (ordered_rests[d][i], d * (int) ceil (diff) * 2); - } - } + { + for (vsize i = ordered_rests[d].size () - 1; i-- > 0;) + { + Real last_y = ordered_rests[d][i + 1]->extent (common, Y_AXIS)[d]; + Real y = ordered_rests[d][i]->extent (common, Y_AXIS)[-d]; + + Real diff = d * ((last_y - y) / staff_space); + if (diff > 0) + Rest::translate (ordered_rests[d][i], d * (int) ceil (diff) * 2); + } + } while (flip (&d) != LEFT); } else { /* - Rests and notes. + Rests and notes. */ // Count how many rests we move Drul_array<int> rcount (0, 0); for (vsize i = 0; i < rests.size (); i++) - { - Grob *rcol = rests[i]; - Direction dir = Note_column::dir (rcol); - if (!dir) - continue; - - Grob *rest = Note_column::get_rest (rcol); - // Do not compute a translation for pre-positioned rests, - // nor count them for the "too many colliding rests" warning - if (scm_is_number (rest->get_property ("staff-position"))) - continue; - - Grob *common = common_refpoint_of_array (notes, rcol, Y_AXIS); - Interval restdim = rest->extent (common, Y_AXIS); - if (restdim.is_empty ()) - continue; - - Real staff_space = Staff_symbol_referencer::staff_space (rcol); - Real minimum_dist = robust_scm2double (me->get_property ("minimum-distance"), 1.0) * staff_space; - - Interval notedim; - for (vsize i = 0; i < notes.size (); i++) - { - if (Note_column::dir (notes[i]) == -dir - // If the note has already happened (but it has a long - // duration, so there is a collision), don't look at the stem. - // If we do, the rest gets shifted down a lot and it looks bad. - || dynamic_cast<Item*> (notes[i])->get_column () != dynamic_cast<Item*> (rest)->get_column ()) - { - /* try not to look at the stem, as looking at a beamed - note may trigger beam positioning prematurely. - - This happens with dotted rests, which need Y - positioning to compute X-positioning. - */ - Grob *head = Note_column::first_head (notes[i]); - if (head) - notedim.unite (head->extent (common, Y_AXIS)); - else - programming_error ("Note_column without first_head()"); - } - else - notedim.unite (notes[i]->extent (common, Y_AXIS)); - } - - Real y = dir * max (0.0, - -dir * restdim[-dir] + dir * notedim[dir] + minimum_dist); - - int stafflines = Staff_symbol_referencer::line_count (me); - if (!stafflines) - { - programming_error ("no staff line count"); - stafflines = 5; - } - - // move discretely by half spaces. - int discrete_y = dir * int (ceil (y / (0.5 * dir * staff_space))); - - // move by whole spaces inside the staff. - if (fabs (Staff_symbol_referencer::get_position (rest) - + discrete_y) < stafflines + 1) - { - discrete_y = dir * int (ceil (dir * discrete_y / 2.0) * 2.0); - } - - Rest::translate (rest, discrete_y); - if (rcount[dir]++) - rest->warning (_ ("too many colliding rests")); - } + { + Grob *rcol = rests[i]; + Direction dir = Note_column::dir (rcol); + if (!dir) + continue; + + Grob *rest = Note_column::get_rest (rcol); + // Do not compute a translation for pre-positioned rests, + // nor count them for the "too many colliding rests" warning + if (scm_is_number (rest->get_property ("staff-position"))) + continue; + + Grob *common = common_refpoint_of_array (notes, rcol, Y_AXIS); + Interval restdim = rest->extent (common, Y_AXIS); + if (restdim.is_empty ()) + continue; + + Real staff_space = Staff_symbol_referencer::staff_space (rcol); + Real minimum_dist = robust_scm2double (me->get_property ("minimum-distance"), 1.0) * staff_space; + + Interval notedim; + for (vsize i = 0; i < notes.size (); i++) + { + if (Note_column::dir (notes[i]) == -dir + // If the note has already happened (but it has a long + // duration, so there is a collision), don't look at the stem. + // If we do, the rest gets shifted down a lot and it looks bad. + || dynamic_cast<Item *> (notes[i])->get_column () != dynamic_cast<Item *> (rest)->get_column ()) + { + /* try not to look at the stem, as looking at a beamed + note may trigger beam positioning prematurely. + + This happens with dotted rests, which need Y + positioning to compute X-positioning. + */ + Grob *head = Note_column::first_head (notes[i]); + if (head) + notedim.unite (head->extent (common, Y_AXIS)); + else + programming_error ("Note_column without first_head()"); + } + else + notedim.unite (notes[i]->extent (common, Y_AXIS)); + } + + Real y = dir * max (0.0, + -dir * restdim[-dir] + dir * notedim[dir] + minimum_dist); + + int stafflines = Staff_symbol_referencer::line_count (me); + if (!stafflines) + { + programming_error ("no staff line count"); + stafflines = 5; + } + + // move discretely by half spaces. + int discrete_y = dir * int (ceil (y / (0.5 * dir * staff_space))); + + // move by whole spaces inside the staff. + if (fabs (Staff_symbol_referencer::get_position (rest) + + discrete_y) < stafflines + 1) + { + discrete_y = dir * int (ceil (dir * discrete_y / 2.0) * 2.0); + } + + Rest::translate (rest, discrete_y); + if (rcount[dir]++) + rest->warning (_ ("too many colliding rests")); + } } return SCM_BOOL_T; } ADD_INTERFACE (Rest_collision, - "Move ordinary rests (not multi-measure nor pitched rests)" - " to avoid conflicts.", - - /* properties */ - "minimum-distance " - "positioning-done " - "elements " - ); + "Move ordinary rests (not multi-measure nor pitched rests)" + " to avoid conflicts.", + + /* properties */ + "minimum-distance " + "positioning-done " + "elements " + ); diff --git a/lily/rest-engraver.cc b/lily/rest-engraver.cc index 8a5622ce46..ab4384e859 100644 --- a/lily/rest-engraver.cc +++ b/lily/rest-engraver.cc @@ -69,14 +69,14 @@ Rest_engraver::process_music () Pitch *p = unsmob_pitch (rest_event_->get_property ("pitch")); if (p) - { - int pos = p->steps (); - SCM c0 = get_property ("middleCPosition"); - if (scm_is_number (c0)) - pos += scm_to_int (c0); - - rest_->set_property ("staff-position", scm_from_int (pos)); - } + { + int pos = p->steps (); + SCM c0 = get_property ("middleCPosition"); + if (scm_is_number (c0)) + pos += scm_to_int (c0); + + rest_->set_property ("staff-position", scm_from_int (pos)); + } } } @@ -88,15 +88,15 @@ Rest_engraver::listen_rest (Stream_event *ev) } ADD_TRANSLATOR (Rest_engraver, - /* doc */ - "Engrave rests.", + /* doc */ + "Engrave rests.", - /* create */ - "Rest ", + /* create */ + "Rest ", - /* read */ - "middleCPosition ", + /* read */ + "middleCPosition ", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/rest.cc b/lily/rest.cc index c064e5a980..97deba3f8f 100644 --- a/lily/rest.cc +++ b/lily/rest.cc @@ -41,19 +41,19 @@ Rest::y_offset_callback (SCM smob) bool position_override = scm_is_number (me->get_property ("staff-position")); Real amount = robust_scm2double (me->get_property ("staff-position"), 0) - * 0.5 * ss; - + * 0.5 * ss; + if (line_count % 2) { if (duration_log == 0 && line_count > 1) - amount += ss; + amount += ss; } else amount += ss / 2; if (!position_override) - amount += 2 * ss * get_grob_direction (me);; - + amount += 2 * ss * get_grob_direction (me);; + return scm_from_double (amount); } @@ -86,9 +86,9 @@ Rest::glyph_name (Grob *me, int balltype, string style, bool try_ledgers) Real pos = Staff_symbol_referencer::get_position (me); /* - Figure out when the rest is far enough outside the staff. This - could bemore generic, but hey, we understand this even after - dinner. + Figure out when the rest is far enough outside the staff. This + could bemore generic, but hey, we understand this even after + dinner. */ is_ledgered |= (balltype == -1) && (pos <= -rad - 3 || pos >= +rad + 1); is_ledgered |= (balltype == 0) && (pos >= +rad + 2 || pos < -rad); @@ -101,26 +101,26 @@ Rest::glyph_name (Grob *me, int balltype, string style, bool try_ledgers) { /* - FIXME: Currently, ancient font does not provide ledgered rests; - hence the "o" suffix in the glyph name is bogus. But do we need - ledgered rests at all now that we can draw ledger lines with - variable width, length and blotdiameter? -- jr + FIXME: Currently, ancient font does not provide ledgered rests; + hence the "o" suffix in the glyph name is bogus. But do we need + ledgered rests at all now that we can draw ledger lines with + variable width, length and blotdiameter? -- jr */ is_ledgered = 0; /* - There are no 32th/64th/128th mensural/neomensural rests. In - these cases, revert back to default style. + There are no 32th/64th/128th mensural/neomensural rests. In + these cases, revert back to default style. */ if (balltype > 4) - actual_style = ""; + actual_style = ""; } if ((style == "classical") && (balltype != 2)) { /* - classical style: revert back to default style for any rest other - than quarter rest + classical style: revert back to default style for any rest other + than quarter rest */ actual_style = ""; } @@ -128,14 +128,14 @@ Rest::glyph_name (Grob *me, int balltype, string style, bool try_ledgers) if (style == "default") { /* - Some parts of lily still prefer style "default" over "". - Correct this here. -- jr + Some parts of lily still prefer style "default" over "". + Correct this here. -- jr */ actual_style = ""; } return ("rests." + to_string (balltype) + (is_ledgered ? "o" : "") - + actual_style); + + actual_style); } MAKE_SCHEME_CALLBACK (Rest, print, 1); @@ -221,8 +221,8 @@ Rest::generic_extent_callback (Grob *me, Axis a) MAKE_SCHEME_CALLBACK (Rest, pure_height, 3); SCM Rest::pure_height (SCM smob, - SCM /* start */, - SCM /* end */) + SCM /* start */, + SCM /* end */) { Grob *me = unsmob_grob (smob); SCM m = brew_internal_stencil (me, false); @@ -230,13 +230,13 @@ Rest::pure_height (SCM smob, } ADD_INTERFACE (Rest, - "A rest symbol. The property @code{style} can be" - " @code{default}, @code{mensural}, @code{neomensural} or" - " @code{classical}.", - - /* properties */ - "direction " - "minimum-distance " - "style " - ); + "A rest symbol. The property @code{style} can be" + " @code{default}, @code{mensural}, @code{neomensural} or" + " @code{classical}.", + + /* properties */ + "direction " + "minimum-distance " + "style " + ); diff --git a/lily/rhythmic-column-engraver.cc b/lily/rhythmic-column-engraver.cc index 9768cafcab..d02a985cf2 100644 --- a/lily/rhythmic-column-engraver.cc +++ b/lily/rhythmic-column-engraver.cc @@ -53,7 +53,7 @@ class Rhythmic_column_engraver : public Engraver { - vector<Grob*> rheads_; + vector<Grob *> rheads_; Grob *stem_; Grob *note_column_; Grob *dotcol_; @@ -77,18 +77,17 @@ Rhythmic_column_engraver::Rhythmic_column_engraver () arpeggio_ = 0; } - void Rhythmic_column_engraver::process_acknowledged () { if (rheads_.size ()) { if (!note_column_) - note_column_ = make_item ("NoteColumn", rheads_[0]->self_scm ()); + note_column_ = make_item ("NoteColumn", rheads_[0]->self_scm ()); for (vsize i = 0; i < rheads_.size (); i++) - if (!rheads_[i]->get_parent (X_AXIS)) - Note_column::add_head (note_column_, rheads_[i]); + if (!rheads_[i]->get_parent (X_AXIS)) + Note_column::add_head (note_column_, rheads_[i]); rheads_.resize (0); } @@ -96,14 +95,14 @@ Rhythmic_column_engraver::process_acknowledged () if (note_column_) { if (stem_ - && !stem_->get_parent (X_AXIS)) - { - Note_column::set_stem (note_column_, stem_); - stem_ = 0; - } + && !stem_->get_parent (X_AXIS)) + { + Note_column::set_stem (note_column_, stem_); + stem_ = 0; + } if (arpeggio_) - note_column_->set_object ("arpeggio", arpeggio_->self_scm ()); + note_column_->set_object ("arpeggio", arpeggio_->self_scm ()); } } @@ -138,16 +137,16 @@ ADD_ACKNOWLEDGER (Rhythmic_column_engraver, rhythmic_head); ADD_ACKNOWLEDGER (Rhythmic_column_engraver, arpeggio); ADD_TRANSLATOR (Rhythmic_column_engraver, - /* doc */ - "Generate @code{NoteColumn}, an object that groups stems," - " note heads, and rests.", + /* doc */ + "Generate @code{NoteColumn}, an object that groups stems," + " note heads, and rests.", - /* create */ - "NoteColumn ", + /* create */ + "NoteColumn ", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/rhythmic-head.cc b/lily/rhythmic-head.cc index adeb4a871c..77993275ff 100644 --- a/lily/rhythmic-head.cc +++ b/lily/rhythmic-head.cc @@ -43,7 +43,7 @@ int Rhythmic_head::dot_count (Grob *me) { return get_dots (me) - ? robust_scm2int (get_dots (me)->get_property ("dot-count"), 0) : 0; + ? robust_scm2int (get_dots (me)->get_property ("dot-count"), 0) : 0; } void @@ -60,10 +60,10 @@ Rhythmic_head::duration_log (Grob *me) } ADD_INTERFACE (Rhythmic_head, - "Note head or rest.", + "Note head or rest.", - /* properties */ - "dot " - "duration-log " - "stem " - ); + /* properties */ + "dot " + "duration-log " + "stem " + ); diff --git a/lily/rod.cc b/lily/rod.cc index 1198dee36f..014296a32c 100644 --- a/lily/rod.cc +++ b/lily/rod.cc @@ -54,7 +54,7 @@ Rod::add_to_cols () if (item_drul_[LEFT] != item_drul_[RIGHT] && item_drul_[LEFT] && item_drul_[RIGHT]) Spaceable_grob::add_rod (item_drul_[LEFT], - item_drul_[RIGHT], - distance_); + item_drul_[RIGHT], + distance_); } diff --git a/lily/scale.cc b/lily/scale.cc index 5de25f5c43..eeea8f8a42 100644 --- a/lily/scale.cc +++ b/lily/scale.cc @@ -25,65 +25,62 @@ /* todo: put string <-> pitch here too. - */ LY_DEFINE (ly_make_scale, "ly:make-scale", - 1, 0, 0, (SCM steps), - "Create a scale." - " The argument is a vector of rational numbers, each of which" - " represents the number of 200 cent tones of a pitch above the" - " tonic.") + 1, 0, 0, (SCM steps), + "Create a scale." + " The argument is a vector of rational numbers, each of which" + " represents the number of 200 cent tones of a pitch above the" + " tonic.") { bool type_ok = scm_is_vector (steps); - vector<Rational> tones; + vector<Rational> tones; if (type_ok) { int len = scm_c_vector_length (steps); - for (int i = 0 ; i < len; i++) - { - SCM step = scm_c_vector_ref (steps, i); - type_ok = type_ok && scm_is_rational (step); - if (type_ok) - { - Rational from_c (scm_to_int (scm_numerator (step)), - scm_to_int (scm_denominator (step))); - tones.push_back (from_c); - } - } + for (int i = 0; i < len; i++) + { + SCM step = scm_c_vector_ref (steps, i); + type_ok = type_ok && scm_is_rational (step); + if (type_ok) + { + Rational from_c (scm_to_int (scm_numerator (step)), + scm_to_int (scm_denominator (step))); + tones.push_back (from_c); + } + } } - - + SCM_ASSERT_TYPE (type_ok, steps, SCM_ARG1, __FUNCTION__, "vector of rational"); Scale *s = new Scale (tones); - SCM retval = s->self_scm (); + SCM retval = s->self_scm (); s->unprotect (); - + return retval; } LY_DEFINE (ly_default_scale, "ly:default-scale", - 0, 0, 0, (), - "Get the global default scale.") + 0, 0, 0, (), + "Get the global default scale.") { return default_global_scale - ? default_global_scale->self_scm () - : SCM_BOOL_F; + ? default_global_scale->self_scm () + : SCM_BOOL_F; } - -Scale * default_global_scale = 0; +Scale *default_global_scale = 0; LY_DEFINE (ly_set_default_scale, "ly:set-default-scale", - 1, 0, 0, (SCM scale), - "Set the global default scale. This determines the tuning of" - " pitches with no accidentals or key signatures. The first" - " pitch is C. Alterations are calculated relative to this" - " scale. The number of pitches in this scale determines the" - " number of scale steps that make up an octave. Usually the" - " 7-note major scale.") + 1, 0, 0, (SCM scale), + "Set the global default scale. This determines the tuning of" + " pitches with no accidentals or key signatures. The first" + " pitch is C. Alterations are calculated relative to this" + " scale. The number of pitches in this scale determines the" + " number of scale steps that make up an octave. Usually the" + " 7-note major scale.") { LY_ASSERT_SMOB (Scale, scale, 1); @@ -92,7 +89,7 @@ LY_DEFINE (ly_set_default_scale, "ly:set-default-scale", default_global_scale->unprotect (); default_global_scale = s; s->protect (); - + return SCM_UNSPECIFIED; } @@ -110,7 +107,7 @@ Scale::tones_at_step (int step, int octave) const octave += (step - normalized_step) / step_count (); // There are 6 tones in an octave. - return step_tones_[normalized_step] + Rational (octave*6); + return step_tones_[normalized_step] + Rational (octave * 6); } Rational @@ -122,7 +119,7 @@ Scale::step_size (int step) const // scale (6 is the number of tones of the octave above the // first note). if (normalized_step + 1 == step_count ()) - return Rational(6) - step_tones_[normalized_step]; + return Rational (6) - step_tones_[normalized_step]; return step_tones_[normalized_step + 1] - step_tones_[normalized_step]; } @@ -139,10 +136,10 @@ Scale::normalize_step (int step) const int Scale::print_smob (SCM /* x */, - SCM port, - scm_print_state *) + SCM port, + scm_print_state *) { - scm_puts ("#<Scale>", port); + scm_puts ("#<Scale>", port); return 1; } @@ -165,7 +162,6 @@ Scale::Scale (Scale const &src) smobify_self (); } - Scale::~Scale () { } diff --git a/lily/scheme-engraver.cc b/lily/scheme-engraver.cc index 22774f3952..e59903086a 100644 --- a/lily/scheme-engraver.cc +++ b/lily/scheme-engraver.cc @@ -1,8 +1,8 @@ -/* +/* scheme-engraver.cc -- implement Scheme_engraver - + source file of the GNU LilyPond music typesetter - + Copyright (c) 2009--2011 Han-Wen Nienhuys <hanwen@lilypond.org> LilyPond is free software: you can redistribute it and/or modify @@ -16,7 +16,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with LilyPond. If not, see <http://www.gnu.org/licenses/>. + along with LilyPond. If not, see <http://www.gnu.org/licenses/>. */ #include "scheme-engraver.hh" @@ -71,12 +71,12 @@ void Scheme_engraver::init_from_scheme (SCM definition) { start_translation_timestep_function_ = callable (ly_symbol2scm ("start-translation-timestep"), - definition); + definition); stop_translation_timestep_function_ = callable (ly_symbol2scm ("stop-translation-timestep"), - definition); + definition); process_music_function_ = callable (ly_symbol2scm ("process-music"), definition); process_acknowledged_function_ = callable (ly_symbol2scm ("process-acknowledged"), - definition); + definition); initialize_function_ = callable (ly_symbol2scm ("initialize"), definition); finalize_function_ = callable (ly_symbol2scm ("finalize"), definition); @@ -85,9 +85,9 @@ Scheme_engraver::init_from_scheme (SCM definition) listeners_alist_ = SCM_EOL; must_be_last_ = to_boolean (ly_assoc_get (ly_symbol2scm ("must-be-last"), - definition, - SCM_BOOL_F)); - + definition, + SCM_BOOL_F)); + translator_listener_record **tail = &per_instance_listeners_; for (SCM p = listeners; scm_is_pair (p); p = scm_cdr (p)) { @@ -95,10 +95,10 @@ Scheme_engraver::init_from_scheme (SCM definition) SCM proc = scm_cdar (p); if (!(ly_is_procedure (proc) && ly_is_symbol (event_class))) - continue; + continue; // We should check the arity of the function? - + // Record for later lookup. listeners_alist_ = scm_acons (event_class, proc, listeners_alist_); @@ -109,13 +109,13 @@ Scheme_engraver::init_from_scheme (SCM definition) tail = &rec->next_; } - init_acknowledgers (ly_assoc_get(ly_symbol2scm ("acknowledgers"), - definition, SCM_EOL), - &interface_acknowledger_hash_); - - init_acknowledgers (ly_assoc_get(ly_symbol2scm ("end-acknowledgers"), - definition, SCM_EOL), - &interface_end_acknowledger_hash_); + init_acknowledgers (ly_assoc_get (ly_symbol2scm ("acknowledgers"), + definition, SCM_EOL), + &interface_acknowledger_hash_); + + init_acknowledgers (ly_assoc_get (ly_symbol2scm ("end-acknowledgers"), + definition, SCM_EOL), + &interface_end_acknowledger_hash_); // TODO: hook up description, props read/written, grobs created // etc. to provide automatic documentation. @@ -123,16 +123,16 @@ Scheme_engraver::init_from_scheme (SCM definition) void Scheme_engraver::init_acknowledgers (SCM alist, - SCM *hash) -{ - *hash = scm_c_make_hash_table(7); + SCM *hash) +{ + *hash = scm_c_make_hash_table (7); for (SCM p = alist; scm_is_pair (p); p = scm_cdr (p)) { SCM iface = scm_caar (p); SCM proc = scm_cdar (p); if (!(ly_is_procedure (proc) && ly_is_symbol (iface))) - continue; + continue; scm_hashq_set_x (*hash, iface, proc); } @@ -141,7 +141,7 @@ Scheme_engraver::init_acknowledgers (SCM alist, // This is the easy way to do it, at the cost of too many invocations // of Scheme_engraver::acknowledge_grob. The clever dispatching of // acknowledgers is hardwired to have 1 method per engraver per -// grob-type, which doesn't work for this case. +// grob-type, which doesn't work for this case. void Scheme_engraver::acknowledge_grob (Grob_info info) { @@ -156,18 +156,18 @@ Scheme_engraver::acknowledge_end_grob (Grob_info info) void Scheme_engraver::acknowledge_grob_by_hash (Grob_info info, - SCM iface_function_hash) + SCM iface_function_hash) { SCM meta = info.grob ()->internal_get_property (ly_symbol2scm ("meta")); SCM ifaces = scm_cdr (scm_assoc (ly_symbol2scm ("interfaces"), meta)); for (SCM s = ifaces; scm_is_pair (s); s = scm_cdr (s)) { SCM func = scm_hashq_ref (iface_function_hash, - scm_car (s), SCM_BOOL_F); + scm_car (s), SCM_BOOL_F); if (ly_is_procedure (func)) - scm_call_3 (func, self_scm (), info.grob ()->self_scm (), - info.origin_translator ()->self_scm ()); + scm_call_3 (func, self_scm (), info.grob ()->self_scm (), + info.origin_translator ()->self_scm ()); } } @@ -186,7 +186,8 @@ void mark_listen_closure (void *target) scm_gc_mark ((SCM)target); } -Listener_function_table listen_closure = { +Listener_function_table listen_closure = +{ call_listen_closure, mark_listen_closure }; @@ -194,34 +195,34 @@ Listener_function_table listen_closure = { Listener Scheme_engraver::get_listener (void *arg, SCM name) { - Scheme_engraver *me = (Scheme_engraver*) arg; + Scheme_engraver *me = (Scheme_engraver *) arg; SCM func = ly_assoc_get (name, me->listeners_alist_, SCM_BOOL_F); assert (ly_is_procedure (func)); - SCM closure = scm_cons (func, me->self_scm()); - return Listener((void*)closure, &listen_closure); + SCM closure = scm_cons (func, me->self_scm ()); + return Listener ((void *)closure, &listen_closure); } translator_listener_record * -Scheme_engraver::get_listener_list () const -{ +Scheme_engraver::get_listener_list () const +{ return per_instance_listeners_; } -#define DISPATCH(what) \ - void \ - Scheme_engraver::what () \ - { \ - if (what ## _function_ != SCM_BOOL_F) \ - scm_call_1 (what ## _function_, self_scm ()); \ +#define DISPATCH(what) \ + void \ + Scheme_engraver::what () \ + { \ + if (what ## _function_ != SCM_BOOL_F) \ + scm_call_1 (what ## _function_, self_scm ()); \ } -DISPATCH(start_translation_timestep); -DISPATCH(stop_translation_timestep); -DISPATCH(initialize); -DISPATCH(finalize); -DISPATCH(process_music); -DISPATCH(process_acknowledged); +DISPATCH (start_translation_timestep); +DISPATCH (stop_translation_timestep); +DISPATCH (initialize); +DISPATCH (finalize); +DISPATCH (process_music); +DISPATCH (process_acknowledged); void Scheme_engraver::derived_mark () const @@ -232,25 +233,25 @@ Scheme_engraver::derived_mark () const scm_gc_mark (finalize_function_); scm_gc_mark (process_music_function_); scm_gc_mark (process_acknowledged_function_); - scm_gc_mark (listeners_alist_); - scm_gc_mark (interface_acknowledger_hash_); - scm_gc_mark (interface_end_acknowledger_hash_); -} + scm_gc_mark (listeners_alist_); + scm_gc_mark (interface_acknowledger_hash_); + scm_gc_mark (interface_end_acknowledger_hash_); +} ADD_ACKNOWLEDGER (Scheme_engraver, grob); ADD_END_ACKNOWLEDGER (Scheme_engraver, grob); ADD_TRANSLATOR (Scheme_engraver, - /* doc */ - "Implement engravers in Scheme. Interprets arguments to" - " @code{\\consists} as callbacks.", + /* doc */ + "Implement engravers in Scheme. Interprets arguments to" + " @code{\\consists} as callbacks.", - /* create */ - "", + /* create */ + "", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/scheme-listener-scheme.cc b/lily/scheme-listener-scheme.cc index 436d595ed0..c5a55ecb55 100644 --- a/lily/scheme-listener-scheme.cc +++ b/lily/scheme-listener-scheme.cc @@ -20,11 +20,11 @@ #include "scheme-listener.hh" LY_DEFINE (ly_make_listener, "ly:make-listener", - 1, 0, 0, (SCM callback), - "Create a listener. Any time the listener hears an object," - " it will call @var{callback} with that object.\n" - "\n" - "@var{callback} should take exactly one argument.") + 1, 0, 0, (SCM callback), + "Create a listener. Any time the listener hears an object," + " it will call @var{callback} with that object.\n" + "\n" + "@var{callback} should take exactly one argument.") { LY_ASSERT_TYPE (ly_is_procedure, callback, 1); Scheme_listener *l = new Scheme_listener (callback); diff --git a/lily/scheme-listener.cc b/lily/scheme-listener.cc index 52efdbe541..178c8ad7f5 100644 --- a/lily/scheme-listener.cc +++ b/lily/scheme-listener.cc @@ -34,7 +34,7 @@ Scheme_listener::Scheme_listener (SCM c) callback_ = SCM_EOL; self_scm_ = SCM_EOL; smobify_self (); - callback_ = c; + callback_ = c; } SCM @@ -45,7 +45,7 @@ Scheme_listener::mark_smob (SCM obj) } int -Scheme_listener::print_smob (SCM obj, SCM p, scm_print_state*) +Scheme_listener::print_smob (SCM obj, SCM p, scm_print_state *) { Scheme_listener *me = (Scheme_listener *) SCM_CELL_WORD_1 (obj); scm_puts ("#<Scheme_listener ", p); diff --git a/lily/scm-hash.cc b/lily/scm-hash.cc index 858aff52ed..d6dadd03ca 100644 --- a/lily/scm-hash.cc +++ b/lily/scm-hash.cc @@ -40,7 +40,7 @@ static void copy_scm_hashes (SCM dest, SCM src) { scm_internal_hash_for_each_handle ((scm_t_hash_handle_fn) ©_handle, - dest, src); + dest, src); } Scheme_hash_table::Scheme_hash_table () @@ -63,7 +63,7 @@ Scheme_hash_table::copy (Scheme_hash_table const &src) if (&src == this) return; - hash_tab_ = scm_c_make_hash_table (SCM_HASHTABLE_N_ITEMS(src.hash_tab_)); + hash_tab_ = scm_c_make_hash_table (SCM_HASHTABLE_N_ITEMS (src.hash_tab_)); copy_scm_hashes (hash_tab_, src.hash_tab_); } @@ -80,7 +80,7 @@ Scheme_hash_table::mark_smob (SCM s) } int -Scheme_hash_table::print_smob (SCM s, SCM p, scm_print_state*) +Scheme_hash_table::print_smob (SCM s, SCM p, scm_print_state *) { assert (unsmob (s)); scm_puts ("#<Scheme_hash_table ", p); @@ -91,7 +91,8 @@ Scheme_hash_table::print_smob (SCM s, SCM p, scm_print_state*) } bool -Scheme_hash_table::try_retrieve (SCM k, SCM *v){ +Scheme_hash_table::try_retrieve (SCM k, SCM *v) +{ SCM handle = scm_hashq_get_handle (hash_tab_, k); if (scm_is_pair (handle)) @@ -133,18 +134,18 @@ Scheme_hash_table::remove (SCM k) static SCM collect_handles (void * /* closure */, - SCM key, - SCM value, - SCM result) + SCM key, + SCM value, + SCM result) { - return scm_acons(key, value, result); + return scm_acons (key, value, result); } SCM Scheme_hash_table::to_alist () const { return scm_internal_hash_fold ((scm_t_hash_fold_fn) &collect_handles, - NULL, SCM_EOL, hash_tab_); + NULL, SCM_EOL, hash_tab_); } IMPLEMENT_SMOBS (Scheme_hash_table); diff --git a/lily/score-engraver.cc b/lily/score-engraver.cc index ade345e6d0..227c86c41e 100644 --- a/lily/score-engraver.cc +++ b/lily/score-engraver.cc @@ -60,8 +60,8 @@ void Score_engraver::finish (SCM) { recurse_over_translators (context (), &Translator::finalize, - &Translator_group::finalize, - UP); + &Translator_group::finalize, + UP); } #define MUSIC_FONT "emmentaler-20" @@ -76,12 +76,12 @@ Score_engraver::initialize () if (!fm) { error (_f ("cannot find `%s'", MUSIC_FONT ".otf") - + "\n" - + _ ("Music font has not been installed properly.") - + "\n" - + _f ("Search path `%s'", global_path.to_string ().c_str ()) - + "\n" - + _ ("Aborting")); + + "\n" + + _ ("Music font has not been installed properly.") + + "\n" + + _f ("Search path `%s'", global_path.to_string ().c_str ()) + + "\n" + + _ ("Aborting")); } pscore_ = new Paper_score (dynamic_cast<Output_def *> (context ()->get_output_def ())); @@ -91,7 +91,7 @@ Score_engraver::initialize () SCM props = updated_grob_properties (context (), ly_symbol2scm ("System")); pscore_->typeset_system (new System (props)); - + system_ = pscore_->root_system (); context ()->set_property ("rootSystem", system_->self_scm ()); @@ -102,7 +102,7 @@ void Score_engraver::connect_to_context (Context *c) { Engraver_group::connect_to_context (c); - + Dispatcher *d = c->get_global_context ()->event_source (); d->add_listener (GET_LISTENER (one_time_step), ly_symbol2scm ("OneTimeStep")); d->add_listener (GET_LISTENER (prepare), ly_symbol2scm ("Prepare")); @@ -111,16 +111,16 @@ Score_engraver::connect_to_context (Context *c) /* uncovered: - - check_removal always returns false for Score contexts, it has been that way -since I joined the project. There is a reason for this: The typeset score is -stored in the Score_engraver, which in turn is accessed through the -Global_context returned by ly:run-translator. So the score-translator must be + + check_removal always returns false for Score contexts, it has been that way +since I joined the project. There is a reason for this: The typeset score is +stored in the Score_engraver, which in turn is accessed through the +Global_context returned by ly:run-translator. So the score-translator must be connected to the score-context after run-translator finishes. -I plan to change this: we should junk run-translator, and instead keep track -of both context and translator in the SCM code, and access the typeset score -directly via the created global-translator. Then it would be possible to +I plan to change this: we should junk run-translator, and instead keep track +of both context and translator in the SCM code, and access the typeset score +directly via the created global-translator. Then it would be possible to disconnect score-translators at iteration time. -es */ void @@ -175,33 +175,33 @@ Score_engraver::typeset_all () Grob *elem = elems_[i]; if (!elem->get_parent (Y_AXIS)) - Axis_group_interface::add_element (system_, elem); + Axis_group_interface::add_element (system_, elem); } elems_.clear (); } ADD_TRANSLATOR_GROUP (Score_engraver, - /* doc */ - "The top-level engraver. Takes care of generating" - " columns and the complete system (i.e.," - " @code{System}).\n" - "\n" - "This engraver decides whether a column is breakable." - " The default is that a column is always breakable." - " However, every @code{Bar_engraver} that does not have" - " a bar line at a certain point sets @code{forbidBreaks}" - " to stop line breaks. In practice, this means that you" - " can make a break point by creating a bar line" - " (assuming that there are no beams or notes that" - " prevent a break point).", - - /* create */ - "System ", - - /* read */ - "currentMusicalColumn " - "currentCommandColumn ", - - /* write */ - "" - ); + /* doc */ + "The top-level engraver. Takes care of generating" + " columns and the complete system (i.e.," + " @code{System}).\n" + "\n" + "This engraver decides whether a column is breakable." + " The default is that a column is always breakable." + " However, every @code{Bar_engraver} that does not have" + " a bar line at a certain point sets @code{forbidBreaks}" + " to stop line breaks. In practice, this means that you" + " can make a break point by creating a bar line" + " (assuming that there are no beams or notes that" + " prevent a break point).", + + /* create */ + "System ", + + /* read */ + "currentMusicalColumn " + "currentCommandColumn ", + + /* write */ + "" + ); diff --git a/lily/score-performer.cc b/lily/score-performer.cc index 5257788df6..f47963f5e9 100644 --- a/lily/score-performer.cc +++ b/lily/score-performer.cc @@ -33,18 +33,18 @@ #include "audio-item.hh" ADD_TRANSLATOR_GROUP (Score_performer, - /* doc */ - "", + /* doc */ + "", - /* create */ - "", + /* create */ + "", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); Score_performer::Score_performer () { @@ -61,7 +61,7 @@ void Score_performer::announce_element (Audio_element_info info) { announce_infos_.push_back (info); - if (Audio_staff *s = dynamic_cast<Audio_staff*> (info.elem_)) + if (Audio_staff *s = dynamic_cast<Audio_staff *> (info.elem_)) { performance_->audio_staffs_.push_back (s); } @@ -75,17 +75,16 @@ Score_performer::acknowledge_audio_elements () for (vsize i = 0; i < announce_infos_.size (); i++) { if (Audio_item *ai = dynamic_cast<Audio_item *> (announce_infos_[i].elem_)) - audio_column_->add_audio_item (ai); + audio_column_->add_audio_item (ai); } Performer_group::acknowledge_audio_elements (); } - void Score_performer::connect_to_context (Context *c) { Performer_group::connect_to_context (c); - + Dispatcher *d = c->get_global_context ()->event_source (); d->add_listener (GET_LISTENER (one_time_step), ly_symbol2scm ("OneTimeStep")); d->add_listener (GET_LISTENER (prepare), ly_symbol2scm ("Prepare")); @@ -123,9 +122,9 @@ Score_performer::finish (SCM) bool use_ports = channel_mapping == ly_symbol2scm ("voice"); performance_->ports_ = use_ports; recurse_over_translators (context (), - &Translator::finalize, - &Translator_group::finalize, - UP); + &Translator::finalize, + &Translator_group::finalize, + UP); } IMPLEMENT_LISTENER (Score_performer, one_time_step); @@ -136,17 +135,17 @@ Score_performer::one_time_step (SCM) { if (!skipping_) { - skip_start_mom_ = audio_column_->when (); - skipping_ = true; + skip_start_mom_ = audio_column_->when (); + skipping_ = true; } } else { if (skipping_) { - offset_mom_ -= audio_column_->when () - skip_start_mom_; - skipping_ = false; - } + offset_mom_ -= audio_column_->when () - skip_start_mom_; + skipping_ = false; + } audio_column_->offset_when (offset_mom_); precomputed_recurse_over_translators (context (), PROCESS_MUSIC, UP); @@ -170,11 +169,9 @@ Score_performer::initialize () { performance_ = new Performance; performance_->unprotect (); - context ()->set_property ("output", performance_->self_scm ()); + context ()->set_property ("output", performance_->self_scm ()); performance_->midi_ = context ()->get_output_def (); - Translator_group::initialize (); } - diff --git a/lily/score-scheme.cc b/lily/score-scheme.cc index f3afd1429b..5331e3583e 100644 --- a/lily/score-scheme.cc +++ b/lily/score-scheme.cc @@ -27,9 +27,9 @@ #include "paper-book.hh" LY_DEFINE (ly_make_score, "ly:make-score", - 1, 0, 0, - (SCM music), - "Return score with @var{music} encapsulated in it.") + 1, 0, 0, + (SCM music), + "Return score with @var{music} encapsulated in it.") { LY_ASSERT_SMOB (Music, music, 1); @@ -40,8 +40,8 @@ LY_DEFINE (ly_make_score, "ly:make-score", } LY_DEFINE (ly_score_output_defs, "ly:score-output-defs", - 1, 0, 0, (SCM score), - "All output definitions in a score.") + 1, 0, 0, (SCM score), + "All output definitions in a score.") { LY_ASSERT_SMOB (Score, score, 1); Score *sc = unsmob_score (score); @@ -53,8 +53,8 @@ LY_DEFINE (ly_score_output_defs, "ly:score-output-defs", } LY_DEFINE (ly_score_add_output_def_x, "ly:score-add-output-def!", - 2, 0, 0, (SCM score, SCM def), - "Add an output definition @var{def} to @var{score}.") + 2, 0, 0, (SCM score, SCM def), + "Add an output definition @var{def} to @var{score}.") { LY_ASSERT_SMOB (Score, score, 1); LY_ASSERT_SMOB (Output_def, def, 2); @@ -65,8 +65,8 @@ LY_DEFINE (ly_score_add_output_def_x, "ly:score-add-output-def!", } LY_DEFINE (ly_score_header, "ly:score-header", - 1, 0, 0, (SCM score), - "Return score header.") + 1, 0, 0, (SCM score), + "Return score header.") { LY_ASSERT_SMOB (Score, score, 1); Score *sc = unsmob_score (score); @@ -74,12 +74,12 @@ LY_DEFINE (ly_score_header, "ly:score-header", } LY_DEFINE (ly_score_set_header_x, "ly:score-set-header!", - 2, 0, 0, (SCM score, SCM module), - "Set the score header.") + 2, 0, 0, (SCM score, SCM module), + "Set the score header.") { LY_ASSERT_SMOB (Score, score, 1); SCM_ASSERT_TYPE (ly_is_module (module), module, SCM_ARG2, __FUNCTION__, - "module"); + "module"); Score *sc = unsmob_score (score); sc->set_header (module); @@ -87,8 +87,8 @@ LY_DEFINE (ly_score_set_header_x, "ly:score-set-header!", } LY_DEFINE (ly_score_music, "ly:score-music", - 1, 0, 0, (SCM score), - "Return score music.") + 1, 0, 0, (SCM score), + "Return score music.") { LY_ASSERT_SMOB (Score, score, 1); Score *sc = unsmob_score (score); @@ -96,8 +96,8 @@ LY_DEFINE (ly_score_music, "ly:score-music", } LY_DEFINE (ly_score_error_p, "ly:score-error?", - 1, 0, 0, (SCM score), - "Was there an error in the score?") + 1, 0, 0, (SCM score), + "Was there an error in the score?") { LY_ASSERT_SMOB (Score, score, 1); Score *sc = unsmob_score (score); @@ -105,10 +105,10 @@ LY_DEFINE (ly_score_error_p, "ly:score-error?", } LY_DEFINE (ly_score_embedded_format, "ly:score-embedded-format", - 2, 0, 0, (SCM score, SCM layout), - "Run @var{score} through @var{layout} (an output definition)" - " scaled to correct output-scale already, returning a list of" - " layout-lines.") + 2, 0, 0, (SCM score, SCM layout), + "Run @var{score} through @var{layout} (an output definition)" + " scaled to correct output-scale already, returning a list of" + " layout-lines.") { LY_ASSERT_SMOB (Score, score, 1); LY_ASSERT_SMOB (Output_def, layout, 2); diff --git a/lily/score.cc b/lily/score.cc index c3125df5ad..84f236864d 100644 --- a/lily/score.cc +++ b/lily/score.cc @@ -44,7 +44,6 @@ Score::origin () const return unsmob_input (input_location_); } - Score::Score () { header_ = SCM_EOL; @@ -79,7 +78,7 @@ Score::mark_smob (SCM s) } int -Score::print_smob (SCM, SCM p, scm_print_state*) +Score::print_smob (SCM, SCM p, scm_print_state *) { scm_puts ("#<Score>", p); @@ -116,7 +115,6 @@ Score::Score (Score const &s) ly_module_copy (header_, s.header_); } - /* Format score, return list of Music_output objects. @@ -124,7 +122,7 @@ Score::Score (Score const &s) */ SCM Score::book_rendering (Output_def *layoutbook, - Output_def *default_def) + Output_def *default_def) { if (error_found_) return SCM_EOL; @@ -146,22 +144,22 @@ Score::book_rendering (Output_def *layoutbook, SCM scaled = SCM_EOL; if (def->c_variable ("is-layout") == SCM_BOOL_T) - { - def = scale_output_def (def, scale); - def->parent_ = layoutbook; + { + def = scale_output_def (def, scale); + def->parent_ = layoutbook; - scaled = def->unprotect (); - } + scaled = def->unprotect (); + } /* TODO: fix or junk --no-layout. */ SCM context = ly_run_translator (music_, def->self_scm ()); if (dynamic_cast<Global_context *> (unsmob_context (context))) - { - SCM s = ly_format_output (context); + { + SCM s = ly_format_output (context); - *tail = scm_cons (s, SCM_EOL); - tail = SCM_CDRLOC (*tail); - } + *tail = scm_cons (s, SCM_EOL); + tail = SCM_CDRLOC (*tail); + } scm_remember_upto_here_1 (scaled); } @@ -184,7 +182,7 @@ Score::set_music (SCM music) m->origin ()->error (_ ("errors found, ignoring music expression")); this->error_found_ = this->error_found_ - || to_boolean (m->get_property ("error-found")); + || to_boolean (m->get_property ("error-found")); } if (this->error_found_) diff --git a/lily/script-column-engraver.cc b/lily/script-column-engraver.cc index a5be1ef660..c9f4a302ba 100644 --- a/lily/script-column-engraver.cc +++ b/lily/script-column-engraver.cc @@ -30,7 +30,7 @@ class Script_column_engraver : public Engraver { Grob *script_column_; - vector<Grob*> scripts_; + vector<Grob *> scripts_; public: TRANSLATOR_DECLARATIONS (Script_column_engraver); @@ -51,8 +51,8 @@ Script_column_engraver::stop_translation_timestep () if (script_column_) { for (vsize i = 0; i < scripts_.size (); i++) - if (Side_position_interface::get_axis (scripts_[i]) == Y_AXIS) - Script_column::add_side_positioned (script_column_, scripts_[i]); + if (Side_position_interface::get_axis (scripts_[i]) == Y_AXIS) + Script_column::add_side_positioned (script_column_, scripts_[i]); } script_column_ = 0; @@ -66,7 +66,7 @@ Script_column_engraver::acknowledge_side_position (Grob_info inf) if (thing) { if (!Item::is_non_musical (thing)) - scripts_.push_back (thing); + scripts_.push_back (thing); } } @@ -79,16 +79,16 @@ Script_column_engraver::process_acknowledged () ADD_ACKNOWLEDGER (Script_column_engraver, side_position); ADD_TRANSLATOR (Script_column_engraver, - /* doc */ - "Find potentially colliding scripts and put them into a" - " @code{ScriptColumn} object; that will fix the collisions.", + /* doc */ + "Find potentially colliding scripts and put them into a" + " @code{ScriptColumn} object; that will fix the collisions.", - /* create */ - "ScriptColumn ", + /* create */ + "ScriptColumn ", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/script-column.cc b/lily/script-column.cc index b9c9e178f4..4e2dd3edc4 100644 --- a/lily/script-column.cc +++ b/lily/script-column.cc @@ -29,7 +29,7 @@ #include <map> -typedef map<Grob*, vector <Grob*> > Grob_scripts_map; +typedef map<Grob *, vector <Grob *> > Grob_scripts_map; void Script_column::add_side_positioned (Grob *me, Grob *script) @@ -42,8 +42,8 @@ Script_column::add_side_positioned (Grob *me, Grob *script) } LY_DEFINE (ly_grob_script_priority_less, "ly:grob-script-priority-less", - 2, 0, 0, (SCM a, SCM b), - "Compare two grobs by script priority. For internal use.") + 2, 0, 0, (SCM a, SCM b), + "Compare two grobs by script priority. For internal use.") { Grob *i1 = unsmob_grob (a); Grob *i2 = unsmob_grob (b); @@ -59,7 +59,7 @@ SCM Script_column::row_before_line_breaking (SCM smob) { Grob *me = unsmob_grob (smob); - vector<Grob*> horizontal_grobs; + vector<Grob *> horizontal_grobs; extract_grob_set (me, "scripts", scripts); Grob_scripts_map head_scripts_map; @@ -69,25 +69,25 @@ Script_column::row_before_line_breaking (SCM smob) Grob *sc = scripts[i]; /* - Don't want to consider scripts horizontally next to notes. + Don't want to consider scripts horizontally next to notes. */ if (Accidental_placement::has_interface (sc) - || Arpeggio::has_interface (sc)) - { - affect_all_grobs.push_back (sc); - } - else if (sc->get_property_data ("Y-offset") != - Side_position_interface::y_aligned_side_proc) - { - head_scripts_map[sc->get_parent (Y_AXIS)].push_back (sc); - } + || Arpeggio::has_interface (sc)) + { + affect_all_grobs.push_back (sc); + } + else if (sc->get_property_data ("Y-offset") + != Side_position_interface::y_aligned_side_proc) + { + head_scripts_map[sc->get_parent (Y_AXIS)].push_back (sc); + } } for (Grob_scripts_map::const_iterator i (head_scripts_map.begin ()); i != head_scripts_map.end (); i++) { - vector<Grob*> grobs = (*i).second; + vector<Grob *> grobs = (*i).second; // this isn't right in all cases, but in general a safe assumption. concat (grobs, affect_all_grobs); @@ -97,24 +97,23 @@ Script_column::row_before_line_breaking (SCM smob) return SCM_UNSPECIFIED; } - MAKE_SCHEME_CALLBACK (Script_column, before_line_breaking, 1); SCM Script_column::before_line_breaking (SCM smob) { Grob *me = unsmob_grob (smob); - vector<Grob*> staff_sided; + vector<Grob *> staff_sided; extract_grob_set (me, "scripts", scripts); for (vsize i = 0; i < scripts.size (); i++) { Grob *sc = scripts[i]; /* - Don't want to consider scripts horizontally next to notes. + Don't want to consider scripts horizontally next to notes. */ - if (sc->get_property_data ("X-offset") != - Side_position_interface::x_aligned_side_proc) - staff_sided.push_back (sc); + if (sc->get_property_data ("X-offset") + != Side_position_interface::x_aligned_side_proc) + staff_sided.push_back (sc); } order_grobs (staff_sided); @@ -122,7 +121,7 @@ Script_column::before_line_breaking (SCM smob) } void -Script_column::order_grobs (vector<Grob*> grobs) +Script_column::order_grobs (vector<Grob *> grobs) { Drul_array<SCM> scripts_drul (SCM_EOL, SCM_EOL); for (vsize i = 0; i < grobs.size (); i++) @@ -147,40 +146,39 @@ Script_column::order_grobs (vector<Grob*> grobs) // loop over all grobs in script column (already sorted by script_priority) for (SCM s = ss; scm_is_pair (s); s = scm_cdr (s), last = g, last_initial_outside_staff = initial_outside_staff) - { - g = unsmob_grob (scm_car (s)); + { + g = unsmob_grob (scm_car (s)); initial_outside_staff = g->get_property ("outside-staff-priority"); if (last) //not the first grob in the list { - SCM last_outside_staff = last->get_property ("outside-staff-priority"); + SCM last_outside_staff = last->get_property ("outside-staff-priority"); /* if outside_staff_priority is missing for previous grob, just use it as a support for the current grob */ - if (!scm_is_number (last_outside_staff)) - Side_position_interface::add_support (g, last); + if (!scm_is_number (last_outside_staff)) + Side_position_interface::add_support (g, last); /* if outside_staff_priority is missing or is equal to original outside_staff_priority of previous grob, set new outside_staff_priority to just higher than outside_staff_priority of previous grob in order to preserve ordering. */ - else if ((!scm_is_number (initial_outside_staff)) || - (fabs (scm_to_double (initial_outside_staff) - - robust_scm2double (last_initial_outside_staff, 0)) < 0.001)) + else if ((!scm_is_number (initial_outside_staff)) + || (fabs (scm_to_double (initial_outside_staff) + - robust_scm2double (last_initial_outside_staff, 0)) < 0.001)) g->set_property ("outside-staff-priority", - scm_from_double ( - scm_to_double (last_outside_staff) + 0.1)); - } - } + scm_from_double (scm_to_double (last_outside_staff) + 0.1)); + } + } } while (flip (&d) != DOWN); } ADD_INTERFACE (Script_column, - "An interface that sorts scripts according to their" - " @code{script-priority} and @code{outside-staff-priority}.", + "An interface that sorts scripts according to their" + " @code{script-priority} and @code{outside-staff-priority}.", - /* properties */ - "" - ); + /* properties */ + "" + ); diff --git a/lily/script-engraver.cc b/lily/script-engraver.cc index f10f29da8a..dee15b9cd1 100644 --- a/lily/script-engraver.cc +++ b/lily/script-engraver.cc @@ -76,8 +76,8 @@ Script_engraver::listen_articulation (Stream_event *ev) int script_count = scripts_.size (); for (int i = 0; i < script_count; i++) if (ly_is_equal (scripts_[i].event_ - ->get_property ("articulation-type"), - ev->get_property ("articulation-type"))) + ->get_property ("articulation-type"), + ev->get_property ("articulation-type"))) return; Script_tuple t; @@ -92,7 +92,7 @@ copy_property (Grob *g, SCM sym, SCM alist) { SCM entry = scm_assoc (sym, alist); if (scm_is_pair (entry)) - g->set_property (sym, scm_cdr (entry)); + g->set_property (sym, scm_cdr (entry)); } } @@ -101,8 +101,8 @@ copy_property (Grob *g, SCM sym, SCM alist) ScriptStaccato , ScriptMarcato, etc. ). */ void -make_script_from_event (Grob *p, Context *tg, - SCM art_type, int index) +make_script_from_event (Grob *p, Context *tg, + SCM art_type, int index) { SCM alist = tg->get_property ("scriptDefinitions"); SCM art = scm_assoc (art_type, alist); @@ -126,31 +126,31 @@ make_script_from_event (Grob *p, Context *tg, SCM sym = scm_caar (s); SCM type = scm_object_property (sym, ly_symbol2scm ("backend-type?")); if (!ly_is_procedure (type)) - continue; + continue; SCM val = scm_cdar (s); if (sym == ly_symbol2scm ("script-priority")) - { - priority_found = true; - /* Make sure they're in order of user input by adding index i. - Don't use the direction in this priority. Smaller means closer - to the head. */ - int prio = scm_to_int (val) + index; + { + priority_found = true; + /* Make sure they're in order of user input by adding index i. + Don't use the direction in this priority. Smaller means closer + to the head. */ + int prio = scm_to_int (val) + index; - val = scm_from_int (prio); - } + val = scm_from_int (prio); + } SCM preset = p->get_property_data (sym); if (val == SCM_EOL - || scm_call_1 (type, preset) == SCM_BOOL_F) - p->set_property (sym, val); + || scm_call_1 (type, preset) == SCM_BOOL_F) + p->set_property (sym, val); } if (!priority_found) { p->set_property ("script-priority", - scm_from_int (index)); + scm_from_int (index)); } } @@ -164,14 +164,14 @@ Script_engraver::process_music () Grob *p = make_item ("Script", ev->self_scm ()); make_script_from_event (p, context (), - ev->get_property ("articulation-type"), - i); + ev->get_property ("articulation-type"), + i); scripts_[i].script_ = p; SCM force_dir = ev->get_property ("direction"); if (is_direction (force_dir) && to_dir (force_dir)) - p->set_property ("direction", force_dir); + p->set_property ("direction", force_dir); } } @@ -184,7 +184,7 @@ Script_engraver::acknowledge_stem (Grob_info info) Grob *e = scripts_[i].script_; if (to_dir (e->get_property ("side-relative-direction"))) - e->set_object ("direction-source", info.grob ()->self_scm ()); + e->set_object ("direction-source", info.grob ()->self_scm ()); Side_position_interface::add_support (e, info.grob ()); } @@ -201,23 +201,22 @@ Script_engraver::acknowledge_stem_tremolo (Grob_info info) } } - void Script_engraver::acknowledge_rhythmic_head (Grob_info info) { if (info.event_cause ()) { for (vsize i = 0; i < scripts_.size (); i++) - { - Grob *e = scripts_[i].script_; - - if (Side_position_interface::get_axis (e) == X_AXIS - && !e->get_parent (Y_AXIS)) - { - e->set_parent (info.grob (), Y_AXIS); - } - Side_position_interface::add_support (e, info.grob ()); - } + { + Grob *e = scripts_[i].script_; + + if (Side_position_interface::get_axis (e) == X_AXIS + && !e->get_parent (Y_AXIS)) + { + e->set_parent (info.grob (), Y_AXIS); + } + Side_position_interface::add_support (e, info.grob ()); + } } } @@ -235,8 +234,8 @@ Script_engraver::acknowledge_note_column (Grob_info info) Grob *e = scripts_[i].script_; if (!e->get_parent (X_AXIS) - && Side_position_interface::get_axis (e) == Y_AXIS) - e->set_parent (info.grob (), X_AXIS); + && Side_position_interface::get_axis (e) == Y_AXIS) + e->set_parent (info.grob (), X_AXIS); } } @@ -252,15 +251,15 @@ ADD_ACKNOWLEDGER (Script_engraver, note_column); ADD_ACKNOWLEDGER (Script_engraver, stem_tremolo); ADD_TRANSLATOR (Script_engraver, - /* doc */ - "Handle note scripted articulations.", + /* doc */ + "Handle note scripted articulations.", - /* create */ - "Script ", + /* create */ + "Script ", - /* read */ - "scriptDefinitions ", + /* read */ + "scriptDefinitions ", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/script-interface.cc b/lily/script-interface.cc index a1dfd85dc6..c1603f9539 100644 --- a/lily/script-interface.cc +++ b/lily/script-interface.cc @@ -40,9 +40,9 @@ Script_interface::get_stencil (Grob *me, Direction d) { SCM name_entry = scm_cdr (s); SCM str = ((scm_is_pair (name_entry)) ? index_get_cell (name_entry, d) - : name_entry); + : name_entry); return Font_interface::get_default_font (me) - ->find_by_name ("scripts." + ly_scm2string (str)); + ->find_by_name ("scripts." + ly_scm2string (str)); } else assert (false); @@ -59,7 +59,7 @@ Script_interface::calc_positioning_done (SCM smob) { Grob *stem = Note_column::get_stem (par); if (stem && Stem::first_head (stem)) - me->set_parent (Stem::first_head (stem), X_AXIS); + me->set_parent (Stem::first_head (stem), X_AXIS); } return SCM_BOOL_T; } @@ -111,7 +111,7 @@ Script_interface::calc_cross_staff (SCM smob) SCM avoid_slur = me->get_property ("avoid-slur"); if (slur && to_boolean (slur->get_property ("cross-staff")) && (avoid_slur == ly_symbol2scm ("outside") - || avoid_slur == ly_symbol2scm ("around"))) + || avoid_slur == ly_symbol2scm ("around"))) return SCM_BOOL_T; return SCM_BOOL_F; @@ -135,31 +135,31 @@ struct Text_script }; ADD_INTERFACE (Text_script, - "An object that is put above or below a note.", + "An object that is put above or below a note.", - /* properties */ - "add-stem-support " - "avoid-slur " - "script-priority " - "slur " - ); + /* properties */ + "add-stem-support " + "avoid-slur " + "script-priority " + "slur " + ); /* Hmm. Where should we put add-stem-support ? */ ADD_INTERFACE (Script_interface, - "An object that is put above or below a note.", - - /* properties */ - "add-stem-support " - "avoid-slur " - "direction-source " - "positioning-done " - "script-priority " - "script-stencil " - "side-relative-direction " - "slur " - "slur-padding " - "toward-stem-shift " - ); + "An object that is put above or below a note.", + + /* properties */ + "add-stem-support " + "avoid-slur " + "direction-source " + "positioning-done " + "script-priority " + "script-stencil " + "side-relative-direction " + "slur " + "slur-padding " + "toward-stem-shift " + ); diff --git a/lily/script-row-engraver.cc b/lily/script-row-engraver.cc index 430c2c9dc3..ccbdb7853f 100644 --- a/lily/script-row-engraver.cc +++ b/lily/script-row-engraver.cc @@ -2,7 +2,7 @@ This file is part of LilyPond, the GNU music typesetter. Copyright (C) 2006--2011 Han-Wen Nienhuys <hanwen@lilypond.org> - + LilyPond is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -27,7 +27,6 @@ #include "translator.icc" - /** Find potentially colliding scripts, and put them in a Script_row @@ -35,8 +34,8 @@ class Script_row_engraver : public Engraver { Grob *script_row_; - vector<Grob*> scripts_; - + vector<Grob *> scripts_; + public: TRANSLATOR_DECLARATIONS (Script_row_engraver); protected: @@ -57,9 +56,9 @@ Script_row_engraver::stop_translation_timestep () if (script_row_) { for (vsize i = 0; i < scripts_.size (); i++) - if (Accidental_placement::has_interface (scripts_[i]) - || Side_position_interface::get_axis (scripts_[i]) == X_AXIS) - Script_column::add_side_positioned (script_row_, scripts_[i]); + if (Accidental_placement::has_interface (scripts_[i]) + || Side_position_interface::get_axis (scripts_[i]) == X_AXIS) + Script_column::add_side_positioned (script_row_, scripts_[i]); } scripts_.clear (); @@ -73,18 +72,16 @@ Script_row_engraver::acknowledge_side_position (Grob_info inf) if (thing) { if (!Item::is_non_musical (thing)) - scripts_.push_back (thing); + scripts_.push_back (thing); } } - void Script_row_engraver::acknowledge_accidental_placement (Grob_info inf) { scripts_.push_back (inf.grob ()); } - void Script_row_engraver::process_acknowledged () { @@ -92,19 +89,18 @@ Script_row_engraver::process_acknowledged () script_row_ = make_item ("ScriptRow", SCM_EOL); } - ADD_ACKNOWLEDGER (Script_row_engraver, accidental_placement); ADD_ACKNOWLEDGER (Script_row_engraver, side_position); ADD_TRANSLATOR (Script_row_engraver, - /* doc */ - "Determine order in horizontal side position elements.", + /* doc */ + "Determine order in horizontal side position elements.", - /* create */ - "ScriptRow ", + /* create */ + "ScriptRow ", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/self-alignment-interface.cc b/lily/self-alignment-interface.cc index 637ce67521..0c72152333 100644 --- a/lily/self-alignment-interface.cc +++ b/lily/self-alignment-interface.cc @@ -48,21 +48,20 @@ SCM Self_alignment_interface::aligned_on_self (Grob *me, Axis a, bool pure, int start, int end) { SCM sym = (a == X_AXIS) ? ly_symbol2scm ("self-alignment-X") - : ly_symbol2scm ("self-alignment-Y"); + : ly_symbol2scm ("self-alignment-Y"); SCM align (me->internal_get_property (sym)); if (scm_is_number (align)) { Interval ext (me->maybe_pure_extent (me, a, pure, start, end)); if (ext.is_empty ()) - programming_error ("cannot align on self: empty element"); + programming_error ("cannot align on self: empty element"); else - return scm_from_double (- ext.linear_combination (scm_to_double (align))); + return scm_from_double (- ext.linear_combination (scm_to_double (align))); } return scm_from_double (0.0); } - SCM Self_alignment_interface::centered_on_object (Grob *him, Axis a) { @@ -90,14 +89,14 @@ Self_alignment_interface::x_centered_on_y_parent (SCM smob) return centered_on_object (unsmob_grob (smob)->get_parent (Y_AXIS), X_AXIS); } -MAKE_SCHEME_CALLBACK (Self_alignment_interface, aligned_on_x_parent,1); +MAKE_SCHEME_CALLBACK (Self_alignment_interface, aligned_on_x_parent, 1); SCM Self_alignment_interface::aligned_on_x_parent (SCM smob) { return aligned_on_parent (unsmob_grob (smob), X_AXIS); } -MAKE_SCHEME_CALLBACK (Self_alignment_interface, aligned_on_y_parent,1); +MAKE_SCHEME_CALLBACK (Self_alignment_interface, aligned_on_y_parent, 1); SCM Self_alignment_interface::aligned_on_y_parent (SCM smob) { @@ -114,7 +113,7 @@ Self_alignment_interface::aligned_on_parent (Grob *me, Axis a) Interval he = him->extent (him, a); SCM sym = (a == X_AXIS) ? ly_symbol2scm ("self-alignment-X") - : ly_symbol2scm ("self-alignment-Y"); + : ly_symbol2scm ("self-alignment-Y"); SCM align_prop (me->internal_get_property (sym)); if (!scm_is_number (align_prop)) @@ -139,33 +138,33 @@ void Self_alignment_interface::set_center_parent (Grob *me, Axis a) { add_offset_callback (me, - (a == X_AXIS) ? centered_on_x_parent_proc : centered_on_y_parent_proc, - a); + (a == X_AXIS) ? centered_on_x_parent_proc : centered_on_y_parent_proc, + a); } void Self_alignment_interface::set_align_self (Grob *me, Axis a) { add_offset_callback (me, - (a == X_AXIS) ? x_aligned_on_self_proc : y_aligned_on_self_proc, - a); + (a == X_AXIS) ? x_aligned_on_self_proc : y_aligned_on_self_proc, + a); } ADD_INTERFACE (Self_alignment_interface, - "Position this object on itself and/or on its parent. To this" - " end, the following functions are provided:\n" - "\n" - "@table @code\n" - "@item Self_alignment_interface::[xy]_aligned_on_self\n" - "Align self on reference point, using" - " @code{self-alignment-X} and @code{self-alignment-Y}." - "@item Self_alignment_interface::aligned_on_[xy]_parent\n" - "@item Self_alignment_interface::centered_on_[xy]_parent\n" - "Shift the object so its own reference point is centered on" - " the extent of the parent\n" - "@end table\n", - - /* properties */ - "self-alignment-X " - "self-alignment-Y " - ); + "Position this object on itself and/or on its parent. To this" + " end, the following functions are provided:\n" + "\n" + "@table @code\n" + "@item Self_alignment_interface::[xy]_aligned_on_self\n" + "Align self on reference point, using" + " @code{self-alignment-X} and @code{self-alignment-Y}." + "@item Self_alignment_interface::aligned_on_[xy]_parent\n" + "@item Self_alignment_interface::centered_on_[xy]_parent\n" + "Shift the object so its own reference point is centered on" + " the extent of the parent\n" + "@end table\n", + + /* properties */ + "self-alignment-X " + "self-alignment-Y " + ); diff --git a/lily/semi-tie-column.cc b/lily/semi-tie-column.cc index f31e23050a..c2910d5cd1 100644 --- a/lily/semi-tie-column.cc +++ b/lily/semi-tie-column.cc @@ -30,21 +30,18 @@ #include "tie-formatting-problem.hh" #include "tie-column-format.hh" - ADD_INTERFACE (Semi_tie_column, - "The interface for a column of l.v. (laissez vibrer) ties.", - - /* properties */ - "positioning-done " - "head-direction " - "tie-configuration " - ); - + "The interface for a column of l.v. (laissez vibrer) ties.", + /* properties */ + "positioning-done " + "head-direction " + "tie-configuration " + ); /* Cut & paste from tie-column.cc - */ + */ MAKE_SCHEME_CALLBACK (Semi_tie_column, calc_positioning_done, 1); SCM Semi_tie_column::calc_positioning_done (SCM smob) @@ -52,17 +49,16 @@ Semi_tie_column::calc_positioning_done (SCM smob) Grob *me = unsmob_grob (smob); me->set_property ("positioning-done", SCM_BOOL_T); - + extract_grob_set (me, "ties", lv_ro_ties); - vector<Grob*> lv_ties (lv_ro_ties); + vector<Grob *> lv_ties (lv_ro_ties); vector_sort (lv_ties, Semi_tie::less); Ties_configuration ties_config; - Tie_formatting_problem problem; - + problem.from_semi_ties (lv_ties, to_dir (me->get_property ("head-direction"))); SCM manual_configs = me->get_property ("tie-configuration"); @@ -72,17 +68,17 @@ Semi_tie_column::calc_positioning_done (SCM smob) for (vsize i = 0; i < lv_ties.size (); i++) { SCM cp = Tie::get_control_points (lv_ties[i], problem.common_x_refpoint (), base[i], - problem.details_); + problem.details_); lv_ties[i]->set_property ("control-points", cp); set_grob_direction (lv_ties[i], base[i].dir_); problem.set_debug_scoring (base); } - + return SCM_BOOL_T; } - + MAKE_SCHEME_CALLBACK (Semi_tie_column, calc_head_direction, 1); SCM Semi_tie_column::calc_head_direction (SCM smob) @@ -95,10 +91,10 @@ Semi_tie_column::calc_head_direction (SCM smob) { Direction this_d = to_dir (ties[i]->get_property ("head-direction")); if (i > 0 && d != this_d) - { - programming_error ("all semi-ties in a semi-tie-column should have the same head-direction"); - return scm_from_int (d); - } + { + programming_error ("all semi-ties in a semi-tie-column should have the same head-direction"); + return scm_from_int (d); + } d = this_d; } return scm_from_int (d); diff --git a/lily/semi-tie.cc b/lily/semi-tie.cc index 91d50a44be..10e2d43d53 100644 --- a/lily/semi-tie.cc +++ b/lily/semi-tie.cc @@ -27,16 +27,16 @@ #include "staff-symbol-referencer.hh" ADD_INTERFACE (Semi_tie, - "A tie which is only on one side connected to a note head.", + "A tie which is only on one side connected to a note head.", - /* properties */ - "control-points " - "direction " - "details " - "head-direction " - "note-head " - "thickness " - ); + /* properties */ + "control-points " + "direction " + "details " + "head-direction " + "note-head " + "thickness " + ); MAKE_SCHEME_CALLBACK (Semi_tie, calc_control_points, 1) SCM @@ -44,15 +44,15 @@ Semi_tie::calc_control_points (SCM smob) { Grob *me = unsmob_grob (smob); (void) me->get_property ("direction"); - + if (Semi_tie_column::has_interface (me->get_parent (Y_AXIS))) { me->get_parent (Y_AXIS)->get_property ("positioning-done"); } else { - programming_error ("lv tie without Semi_tie_column. Killing lv tie."); - me->suicide (); + programming_error ("lv tie without Semi_tie_column. Killing lv tie."); + me->suicide (); } return me->get_property_data ("control-points"); @@ -67,8 +67,8 @@ Semi_tie::get_position (Grob *me) bool Semi_tie::less (Grob *const &s1, - Grob *const &s2) + Grob *const &s2) { return get_position (s1) < get_position (s2); } - + diff --git a/lily/separating-line-group-engraver.cc b/lily/separating-line-group-engraver.cc index 86c45fb55a..8b40bd1644 100644 --- a/lily/separating-line-group-engraver.cc +++ b/lily/separating-line-group-engraver.cc @@ -35,7 +35,7 @@ struct Spacings { Item *staff_spacing_; - vector<Item*> note_spacings_; + vector<Item *> note_spacings_; Spacings () { @@ -64,7 +64,7 @@ protected: void stop_translation_timestep (); void start_translation_timestep (); - vector<Grob*> break_aligned_; + vector<Grob *> break_aligned_; public: TRANSLATOR_DECLARATIONS (Separating_line_group_engraver); }; @@ -94,24 +94,24 @@ Separating_line_group_engraver::acknowledge_item (Grob_info i) context ()->set_property ("hasStaffSpacing", SCM_BOOL_T); Pointer_group_interface::add_grob (current_spacings_.staff_spacing_, - ly_symbol2scm ("left-items"), - col); - + ly_symbol2scm ("left-items"), + col); + if (!last_spacings_.note_spacings_.size () - && last_spacings_.staff_spacing_) - { - SCM ri = last_spacings_.staff_spacing_->get_object ("right-items"); - Grob_array *ga = unsmob_grob_array (ri); - if (!ga) - { - SCM ga_scm = Grob_array::make_array (); - last_spacings_.staff_spacing_->set_object ("right-items", ga_scm); - ga = unsmob_grob_array (ga_scm); - } - - ga->clear (); - ga->add (col); - } + && last_spacings_.staff_spacing_) + { + SCM ri = last_spacings_.staff_spacing_->get_object ("right-items"); + Grob_array *ga = unsmob_grob_array (ri); + if (!ga) + { + SCM ga_scm = Grob_array::make_array (); + last_spacings_.staff_spacing_->set_object ("right-items", ga_scm); + ga = unsmob_grob_array (ga_scm); + } + + ga->clear (); + ga->add (col); + } } } @@ -135,11 +135,11 @@ Separating_line_group_engraver::stop_translation_timestep () SCM smob = break_aligned_[i]->self_scm (); if (Item *sp = current_spacings_.staff_spacing_) - Pointer_group_interface::add_grob (sp, ly_symbol2scm ("left-break-aligned"), smob); + Pointer_group_interface::add_grob (sp, ly_symbol2scm ("left-break-aligned"), smob); for (vsize j = 0; j < last_spacings_.note_spacings_.size (); j++) - Pointer_group_interface::add_grob (last_spacings_.note_spacings_[j], - ly_symbol2scm ("right-break-aligned"), smob); + Pointer_group_interface::add_grob (last_spacings_.note_spacings_[j], + ly_symbol2scm ("right-break-aligned"), smob); } if (!current_spacings_.is_empty ()) @@ -157,15 +157,15 @@ ADD_ACKNOWLEDGER (Separating_line_group_engraver, item); ADD_ACKNOWLEDGER (Separating_line_group_engraver, break_aligned); ADD_TRANSLATOR (Separating_line_group_engraver, - /* doc */ - "Generate objects for computing spacing parameters.", + /* doc */ + "Generate objects for computing spacing parameters.", - /* create */ - "StaffSpacing ", + /* create */ + "StaffSpacing ", - /* read */ - "createSpacing ", + /* read */ + "createSpacing ", - /* write */ - "hasStaffSpacing " - ); + /* write */ + "hasStaffSpacing " + ); diff --git a/lily/separation-item.cc b/lily/separation-item.cc index 013e457034..fc22dd50f2 100644 --- a/lily/separation-item.cc +++ b/lily/separation-item.cc @@ -46,17 +46,17 @@ Separation_item::add_conditional_item (Grob *me, Grob *e) Real Separation_item::set_distance (Item *l, Item *r, Real padding) { - Drul_array<Skyline_pair*> lines (Skyline_pair::unsmob (l->get_property ("horizontal-skylines")), - Skyline_pair::unsmob (r->get_property ("horizontal-skylines"))); + Drul_array<Skyline_pair *> lines (Skyline_pair::unsmob (l->get_property ("horizontal-skylines")), + Skyline_pair::unsmob (r->get_property ("horizontal-skylines"))); Skyline right = conditional_skyline (r, l); right.merge ((*lines[RIGHT])[LEFT]); - + Real dist = padding + (*lines[LEFT])[RIGHT].distance (right); if (dist > 0) { Rod rod; - rod.item_drul_ = Drul_array<Item*> (l, r); + rod.item_drul_ = Drul_array<Item *> (l, r); rod.distance_ = dist; rod.add_to_cols (); @@ -84,8 +84,7 @@ Separation_item::conditional_skyline (Grob *me, Grob *left) return Skyline (bs, horizon_padding, Y_AXIS, LEFT); } - -MAKE_SCHEME_CALLBACK (Separation_item, calc_skylines,1); +MAKE_SCHEME_CALLBACK (Separation_item, calc_skylines, 1); SCM Separation_item::calc_skylines (SCM smob) { @@ -109,7 +108,7 @@ Separation_item::boxes (Grob *me, Grob *left) Paper_column *pc = item->get_column (); vector<Box> out; extract_grob_set (me, left ? "conditional-elements" : "elements", read_only_elts); - vector<Grob*> elts; + vector<Grob *> elts; if (left) elts = Accidental_placement::get_relevant_accidentals (read_only_elts, left); @@ -118,39 +117,40 @@ Separation_item::boxes (Grob *me, Grob *left) elts = read_only_elts; /* This is a special-case for NoteColumn: we want to include arpeggio in its - skyline (so spacing takes it into account) but we don't want to include it - in the NoteColumn's extent because some spanners (eg. Hairpin) bound themselves - on the NoteColumn and we don't want them to include arpeggios in their bounds. + skyline (so spacing takes it into account) but we don't want to include it + in the NoteColumn's extent because some spanners (eg. Hairpin) bound themselves + on the NoteColumn and we don't want them to include arpeggios in their bounds. */ - if (Grob *a = Note_column::arpeggio (me)) { - elts.push_back (a); - } + if (Grob *a = Note_column::arpeggio (me)) + { + elts.push_back (a); + } } Grob *ycommon = common_refpoint_of_array (elts, me, Y_AXIS); - + for (vsize i = 0; i < elts.size (); i++) { Item *il = dynamic_cast<Item *> (elts[i]); if (pc != il->get_column ()) - continue; + continue; /* ugh. We want to exclude groups of grobs (so that we insert each grob - individually into the skyline instead of adding a single box that - bounds all of them). However, we can't exclude an axis-group that - adds to its childrens' stencil. Currently, this is just TrillPitchGroup; - hence the check for note-head-interface. */ + individually into the skyline instead of adding a single box that + bounds all of them). However, we can't exclude an axis-group that + adds to its childrens' stencil. Currently, this is just TrillPitchGroup; + hence the check for note-head-interface. */ if (Axis_group_interface::has_interface (il) - && !Note_head::has_interface (il)) - continue; + && !Note_head::has_interface (il)) + continue; Interval y (il->pure_height (ycommon, 0, very_large)); Interval x (il->extent (pc, X_AXIS)); Interval extra_width = robust_scm2interval (elts[i]->get_property ("extra-spacing-width"), - Interval (-0.1, 0.1)); + Interval (-0.1, 0.1)); Interval extra_height = robust_scm2interval (elts[i]->get_property ("extra-spacing-height"), - Interval (0.0, 0.0)); + Interval (0.0, 0.0)); x[LEFT] += extra_width[LEFT]; x[RIGHT] += extra_width[RIGHT]; @@ -158,10 +158,10 @@ Separation_item::boxes (Grob *me, Grob *left) y[UP] += extra_height[UP]; if (!x.is_empty () && !y.is_empty ()) - out.push_back (Box (x, y)); + out.push_back (Box (x, y)); } - return out; + return out; } MAKE_SCHEME_CALLBACK (Separation_item, print, 1) @@ -182,13 +182,13 @@ Separation_item::print (SCM smob) } ADD_INTERFACE (Separation_item, - "Item that computes widths to generate spacing rods.", - - /* properties */ - "X-extent " - "conditional-elements " - "elements " - "padding " - "horizontal-skylines " - "skyline-vertical-padding " - ); + "Item that computes widths to generate spacing rods.", + + /* properties */ + "X-extent " + "conditional-elements " + "elements " + "padding " + "horizontal-skylines " + "skyline-vertical-padding " + ); diff --git a/lily/sequential-iterator.cc b/lily/sequential-iterator.cc index 84d677df00..2f0dd51876 100644 --- a/lily/sequential-iterator.cc +++ b/lily/sequential-iterator.cc @@ -101,26 +101,26 @@ create_grace_fixup_list (SCM cursor) Moment l = mus->get_length () - s; if (s.grace_part_) - { - if (last != Moment (-1)) - { - Grace_fixup *p = new Grace_fixup; - p->start_ = last; - p->length_ = here - last; - p->grace_start_ = s.grace_part_; - p->next_ = 0; - *tail = p; - tail = &(*tail)->next_; - } - - here.grace_part_ = s.grace_part_; - } + { + if (last != Moment (-1)) + { + Grace_fixup *p = new Grace_fixup; + p->start_ = last; + p->length_ = here - last; + p->grace_start_ = s.grace_part_; + p->next_ = 0; + *tail = p; + tail = &(*tail)->next_; + } + + here.grace_part_ = s.grace_part_; + } if (l.to_bool ()) - { - last = here; - here += l; - } + { + last = here; + here += l; + } } return head; @@ -181,10 +181,10 @@ Sequential_iterator::next_element (bool) else { /* - !len.grace_part_ || len.main_part_ + !len.grace_part_ || len.main_part_ - We skip over a big chunk (mainpart != 0). Any starting graces - in that chunk should be in len.grace_part_ + We skip over a big chunk (mainpart != 0). Any starting graces + in that chunk should be in len.grace_part_ */ last_mom_ = here_mom_; @@ -207,28 +207,28 @@ Sequential_iterator::process (Moment until) { Grace_fixup *gf = get_grace_fixup (); if (gf - && gf->start_ + gf->length_ - + Moment (Rational (0), gf->grace_start_) == until) - { - /* - do the stuff/note/rest preceding a grace. - */ - iter_->process (iter_->music_get_length ()); - } + && gf->start_ + gf->length_ + + Moment (Rational (0), gf->grace_start_) == until) + { + /* + do the stuff/note/rest preceding a grace. + */ + iter_->process (iter_->music_get_length ()); + } else - { - Moment w = until - here_mom_ + iter_->music_start_mom (); - iter_->process (w); - } + { + Moment w = until - here_mom_ + iter_->music_start_mom (); + iter_->process (w); + } /* - if the iter is still OK, there must be events left that have + if the iter is still OK, there must be events left that have - TIME > LEFT + TIME > LEFT */ if (iter_->ok ()) - return; + return; descend_to_child (iter_->get_outlet ()); next_element (true); diff --git a/lily/side-position-interface.cc b/lily/side-position-interface.cc index 9e8c71f6e6..5befccfccb 100644 --- a/lily/side-position-interface.cc +++ b/lily/side-position-interface.cc @@ -19,7 +19,7 @@ #include "side-position-interface.hh" -#include <cmath> // ceil. +#include <cmath> // ceil. #include <algorithm> using namespace std; @@ -52,9 +52,9 @@ Side_position_interface::add_support (Grob *me, Grob *e) */ SCM Side_position_interface::general_side_position (Grob *me, Axis a, bool use_extents, - bool include_my_extent, - bool pure, int start, int end, - Real *current_offset) + bool include_my_extent, + bool pure, int start, int end, + Real *current_offset) { Real ss = Staff_symbol_referencer::staff_space (me); @@ -62,11 +62,11 @@ Side_position_interface::general_side_position (Grob *me, Axis a, bool use_exten Grob *common = common_refpoint_of_array (support, me->get_parent (a), a); Grob *staff_symbol = Staff_symbol_referencer::get_staff_symbol (me); - bool include_staff = - staff_symbol - && a == Y_AXIS - && scm_is_number (me->get_property ("staff-padding")) - && !to_boolean (me->get_property ("quantize-position")); + bool include_staff + = staff_symbol + && a == Y_AXIS + && scm_is_number (me->get_property ("staff-padding")) + && !to_boolean (me->get_property ("quantize-position")); Interval dim; Interval staff_extents; @@ -76,7 +76,7 @@ Side_position_interface::general_side_position (Grob *me, Axis a, bool use_exten staff_extents = staff_symbol->maybe_pure_extent (common, Y_AXIS, pure, start, end); if (include_staff) - dim.unite (staff_extents); + dim.unite (staff_extents); } Direction dir = get_grob_direction (me); @@ -89,20 +89,20 @@ Side_position_interface::general_side_position (Grob *me, Axis a, bool use_exten // ignoring the stem solves cyclic dependencies if the stem is // attached to a cross-staff beam. if (a == Y_AXIS - && Stem::has_interface (e) - && dir == - get_grob_direction (e)) - continue; + && Stem::has_interface (e) + && dir == - get_grob_direction (e)) + continue; if (e) - { - if (use_extents) - dim.unite (e->maybe_pure_extent (common, a, pure, start, end)); - else - { - Real x = e->maybe_pure_coordinate (common, a, pure, start, end); - dim.unite (Interval (x, x)); - } - } + { + if (use_extents) + dim.unite (e->maybe_pure_extent (common, a, pure, start, end)); + else + { + Real x = e->maybe_pure_coordinate (common, a, pure, start, end); + dim.unite (Interval (x, x)); + } + } } if (dim.is_empty ()) @@ -123,37 +123,35 @@ Side_position_interface::general_side_position (Grob *me, Axis a, bool use_exten { Interval iv = me->maybe_pure_extent (me, a, pure, start, end); if (!iv.is_empty ()) - { - if (!dir) - { - programming_error ("direction unknown, but aligned-side wanted"); - dir = DOWN; - } - total_off += -iv[-dir]; - } + { + if (!dir) + { + programming_error ("direction unknown, but aligned-side wanted"); + dir = DOWN; + } + total_off += -iv[-dir]; + } } if (current_offset) total_off = dir * max (dir * total_off, - dir * (*current_offset)); - + dir * (*current_offset)); /* FIXME: 1000 should relate to paper size. */ if (fabs (total_off) > 1000) { string msg - = String_convert::form_string ("Improbable offset for grob %s: %f", - me->name ().c_str (), total_off); + = String_convert::form_string ("Improbable offset for grob %s: %f", + me->name ().c_str (), total_off); programming_error (msg); if (strict_infinity_checking) - scm_misc_error (__FUNCTION__, "Improbable offset.", SCM_EOL); + scm_misc_error (__FUNCTION__, "Improbable offset.", SCM_EOL); } return scm_from_double (total_off); } - MAKE_SCHEME_CALLBACK (Side_position_interface, y_aligned_on_support_refpoints, 1); SCM Side_position_interface::y_aligned_on_support_refpoints (SCM smob) @@ -166,10 +164,9 @@ SCM Side_position_interface::pure_y_aligned_on_support_refpoints (SCM smob, SCM start, SCM end) { return general_side_position (unsmob_grob (smob), Y_AXIS, false, false, - true, scm_to_int (start), scm_to_int (end), 0); + true, scm_to_int (start), scm_to_int (end), 0); } - /* Position next to support, taking into account my own dimensions and padding. */ @@ -187,7 +184,6 @@ axis_aligned_side_helper (SCM smob, Axis a, bool pure, int start, int end, SCM c return Side_position_interface::aligned_side (unsmob_grob (smob), a, pure, start, end, current_off_ptr); } - MAKE_SCHEME_CALLBACK_WITH_OPTARGS (Side_position_interface, x_aligned_side, 2, 1, ""); SCM Side_position_interface::x_aligned_side (SCM smob, SCM current_off) @@ -207,9 +203,9 @@ SCM Side_position_interface::pure_y_aligned_side (SCM smob, SCM start, SCM end, SCM cur_off) { return axis_aligned_side_helper (smob, Y_AXIS, true, - scm_to_int (start), - scm_to_int (end), - cur_off); + scm_to_int (start), + scm_to_int (end), + cur_off); } MAKE_SCHEME_CALLBACK (Side_position_interface, calc_cross_staff, 1) @@ -229,7 +225,7 @@ Side_position_interface::calc_cross_staff (SCM smob) SCM Side_position_interface::aligned_side (Grob *me, Axis a, bool pure, int start, int end, - Real *current_off) + Real *current_off) { Direction dir = get_grob_direction (me); @@ -244,33 +240,33 @@ Side_position_interface::aligned_side (Grob *me, Axis a, bool pure, int start, i if (staff && a == Y_AXIS) { if (to_boolean (me->get_property ("quantize-position"))) - { - Grob *common = me->common_refpoint (staff, Y_AXIS); - Real my_off = me->get_parent (Y_AXIS)->maybe_pure_coordinate (common, Y_AXIS, pure, start, end); - Real staff_off = staff->maybe_pure_coordinate (common, Y_AXIS, pure, start, end); - Real ss = Staff_symbol::staff_space (staff); - Real position = 2 * (my_off + o - staff_off) / ss; - Real rounded = directed_round (position, dir); - Grob *head = me->get_parent (X_AXIS); - - if (fabs (position) <= 2 * Staff_symbol_referencer::staff_radius (me) + 1 - /* In case of a ledger lines, quantize even if we're outside the staff. */ - || (Note_head::has_interface (head) - - && abs (Staff_symbol_referencer::get_position (head)) > abs (position))) - { - o += (rounded - position) * 0.5 * ss; - if (Staff_symbol_referencer::on_line (me, int (rounded))) - o += dir * 0.5 * ss; - } - } + { + Grob *common = me->common_refpoint (staff, Y_AXIS); + Real my_off = me->get_parent (Y_AXIS)->maybe_pure_coordinate (common, Y_AXIS, pure, start, end); + Real staff_off = staff->maybe_pure_coordinate (common, Y_AXIS, pure, start, end); + Real ss = Staff_symbol::staff_space (staff); + Real position = 2 * (my_off + o - staff_off) / ss; + Real rounded = directed_round (position, dir); + Grob *head = me->get_parent (X_AXIS); + + if (fabs (position) <= 2 * Staff_symbol_referencer::staff_radius (me) + 1 + /* In case of a ledger lines, quantize even if we're outside the staff. */ + || (Note_head::has_interface (head) + + && abs (Staff_symbol_referencer::get_position (head)) > abs (position))) + { + o += (rounded - position) * 0.5 * ss; + if (Staff_symbol_referencer::on_line (me, int (rounded))) + o += dir * 0.5 * ss; + } + } else if (scm_is_number (me->get_property ("staff-padding")) && dir) - { - Interval iv = me->maybe_pure_extent (me, a, pure, start, end); + { + Interval iv = me->maybe_pure_extent (me, a, pure, start, end); - Real staff_padding - = Staff_symbol_referencer::staff_space (me) - * scm_to_double (me->get_property ("staff-padding")); + Real staff_padding + = Staff_symbol_referencer::staff_space (me) + * scm_to_double (me->get_property ("staff-padding")); Grob *parent = me->get_parent (Y_AXIS); Grob *common = me->common_refpoint (staff, Y_AXIS); @@ -281,7 +277,7 @@ Side_position_interface::aligned_side (Grob *me, Axis a, bool pure, int start, i - dir * (o + iv[-dir]) + dir * (staff_position - parent_position)); o += dir * max (diff, 0.0); - } + } } return scm_from_double (o); } @@ -293,10 +289,10 @@ Side_position_interface::set_axis (Grob *me, Axis a) { me->set_property ("side-axis", scm_from_int (a)); chain_offset_callback (me, - (a==X_AXIS) - ? x_aligned_side_proc - : y_aligned_side_proc, - a); + (a == X_AXIS) + ? x_aligned_side_proc + : y_aligned_side_proc, + a); } } @@ -307,7 +303,7 @@ Side_position_interface::get_axis (Grob *me) return Axis (scm_to_int (me->get_property ("side-axis"))); string msg = String_convert::form_string ("side-axis not set for grob %s.", - me->name ().c_str ()); + me->name ().c_str ()); me->programming_error (msg); return NO_AXES; } @@ -317,7 +313,7 @@ SCM Side_position_interface::move_to_extremal_staff (SCM smob) { Grob *me = unsmob_grob (smob); - System *sys = dynamic_cast<System*> (me->get_system ()); + System *sys = dynamic_cast<System *> (me->get_system ()); Direction dir = get_grob_direction (me); if (dir != DOWN) dir = UP; @@ -344,36 +340,35 @@ Side_position_interface::move_to_extremal_staff (SCM smob) Grob_array *ga = unsmob_grob_array (me->get_object ("side-support-elements")); if (ga) { - vector<Grob*> const& elts = ga->array (); - vector<Grob*> new_elts; + vector<Grob *> const &elts = ga->array (); + vector<Grob *> new_elts; for (vsize i = 0; i < elts.size (); ++i) - { - if (me->common_refpoint (elts[i], Y_AXIS) == top_staff) - new_elts.push_back (elts[i]); - } + { + if (me->common_refpoint (elts[i], Y_AXIS) == top_staff) + new_elts.push_back (elts[i]); + } ga->set_array (new_elts); } return SCM_BOOL_T; } - ADD_INTERFACE (Side_position_interface, - "Position a victim object (this one) next to other objects" - " (the support). The property @code{direction} signifies where" - " to put the victim object relative to the support (left or" - " right, up or down?)\n" - "\n" - "The routine also takes the size of the staff into account if" - " @code{staff-padding} is set. If undefined, the staff symbol" - " is ignored.", - - /* properties */ - "direction " - "minimum-space " - "padding " - "quantize-position " - "side-axis " - "side-support-elements " - "slur-padding " - "staff-padding " - ); + "Position a victim object (this one) next to other objects" + " (the support). The property @code{direction} signifies where" + " to put the victim object relative to the support (left or" + " right, up or down?)\n" + "\n" + "The routine also takes the size of the staff into account if" + " @code{staff-padding} is set. If undefined, the staff symbol" + " is ignored.", + + /* properties */ + "direction " + "minimum-space " + "padding " + "quantize-position " + "side-axis " + "side-support-elements " + "slur-padding " + "staff-padding " + ); diff --git a/lily/simple-closure.cc b/lily/simple-closure.cc index 7c46c0198b..6f82f11f56 100644 --- a/lily/simple-closure.cc +++ b/lily/simple-closure.cc @@ -33,7 +33,7 @@ SCM simple_closure_expression (SCM smob) { assert (is_simple_closure (smob)); - return (SCM) SCM_CELL_WORD_1(smob); + return (SCM) SCM_CELL_WORD_1 (smob); } SCM @@ -44,33 +44,33 @@ evaluate_args (SCM delayed_argument, SCM args, bool pure, int start, int end) for (SCM s = args; scm_is_pair (s); s = scm_cdr (s)) { *tail = scm_cons (evaluate_with_simple_closure (delayed_argument, scm_car (s), - pure, start, end), - SCM_EOL); + pure, start, end), + SCM_EOL); if (scm_car (*tail) == SCM_UNSPECIFIED) - return SCM_UNSPECIFIED; + return SCM_UNSPECIFIED; tail = SCM_CDRLOC (*tail); } - + return new_args; } SCM evaluate_with_simple_closure (SCM delayed_argument, - SCM expr, - bool pure, - int start, - int end) + SCM expr, + bool pure, + int start, + int end) { if (is_simple_closure (expr)) { SCM inside = simple_closure_expression (expr); SCM args = scm_cons (delayed_argument, - evaluate_args (delayed_argument, scm_cdr (inside), - pure, start, end)); + evaluate_args (delayed_argument, scm_cdr (inside), + pure, start, end)); if (scm_cdr (args) == SCM_UNSPECIFIED) - return SCM_UNSPECIFIED; + return SCM_UNSPECIFIED; if (pure) - return call_pure_function (scm_car (inside), args, start, end); + return call_pure_function (scm_car (inside), args, start, end); return scm_apply_0 (scm_car (inside), args); } else if (!scm_is_pair (expr)) @@ -81,32 +81,32 @@ evaluate_with_simple_closure (SCM delayed_argument, { SCM args = evaluate_args (delayed_argument, scm_cdr (expr), pure, start, end); if (args == SCM_UNSPECIFIED) - return SCM_UNSPECIFIED; + return SCM_UNSPECIFIED; if (pure) - return call_pure_function (scm_car (expr), args, start, end); + return call_pure_function (scm_car (expr), args, start, end); return scm_apply_0 (scm_car (expr), args); } else - // ugh. deviation from standard. Should print error? - return evaluate_args (delayed_argument, scm_cdr (expr), pure, start, end); - + // ugh. deviation from standard. Should print error? + return evaluate_args (delayed_argument, scm_cdr (expr), pure, start, end); + assert (false); return SCM_EOL; } LY_DEFINE (ly_simple_closure_p, "ly:simple-closure?", - 1, 0, 0, (SCM clos), - "Is @var{clos} a simple closure?") + 1, 0, 0, (SCM clos), + "Is @var{clos} a simple closure?") { return scm_from_bool (is_simple_closure (clos)); } LY_DEFINE (ly_make_simple_closure, "ly:make-simple-closure", - 1, 0, 0, (SCM expr), - "Make a simple closure. @var{expr} should be form of" - " @code{(@var{func} @var{a1} @var{a2} @dots{})}, and will be" - " invoked as @code{(@var{func} @var{delayed-arg} @var{a1}" - " @var{a2} @dots{})}.") + 1, 0, 0, (SCM expr), + "Make a simple closure. @var{expr} should be form of" + " @code{(@var{func} @var{a1} @var{a2} @dots{})}, and will be" + " invoked as @code{(@var{func} @var{delayed-arg} @var{a1}" + " @var{a2} @dots{})}.") { SCM z; @@ -115,10 +115,10 @@ LY_DEFINE (ly_make_simple_closure, "ly:make-simple-closure", } LY_DEFINE (ly_eval_simple_closure, "ly:eval-simple-closure", - 2, 2, 0, (SCM delayed, SCM closure, SCM scm_start, SCM scm_end), - "Evaluate a simple @var{closure} with the given @var{delayed}" - " argument. If @var{scm-start} and @var{scm-end} are defined," - " evaluate it purely with those start and end points.") + 2, 2, 0, (SCM delayed, SCM closure, SCM scm_start, SCM scm_end), + "Evaluate a simple @var{closure} with the given @var{delayed}" + " argument. If @var{scm-start} and @var{scm-end} are defined," + " evaluate it purely with those start and end points.") { bool pure = (scm_is_number (scm_start) && scm_is_number (scm_end)); int start = robust_scm2int (scm_start, 0); @@ -126,7 +126,7 @@ LY_DEFINE (ly_eval_simple_closure, "ly:eval-simple-closure", SCM expr = simple_closure_expression (closure); return evaluate_with_simple_closure (delayed, expr, pure, start, end); } - + int print_simple_closure (SCM s, SCM port, scm_print_state *) { @@ -136,7 +136,6 @@ print_simple_closure (SCM s, SCM port, scm_print_state *) return 1; } - void init_simple_closure () { simple_closure_tag = scm_make_smob_type ("simple-closure", 0); @@ -144,6 +143,4 @@ void init_simple_closure () scm_set_smob_print (simple_closure_tag, print_simple_closure); }; - - ADD_SCM_INIT_FUNC (simple_closure, init_simple_closure); diff --git a/lily/simple-spacer-scheme.cc b/lily/simple-spacer-scheme.cc index 3df7d2f7dd..2456e96611 100644 --- a/lily/simple-spacer-scheme.cc +++ b/lily/simple-spacer-scheme.cc @@ -25,27 +25,27 @@ #include "simple-spacer.hh" LY_DEFINE (ly_solve_spring_rod_problem, "ly:solve-spring-rod-problem", - 4, 1, 0, (SCM springs, SCM rods, SCM length, SCM ragged), - "Solve a spring and rod problem for @var{count} objects, that" - " are connected by @var{count}-1 @var{springs}, and an arbitrary" - " number of @var{rods}. @var{count} is implicitly given by" - " @var{springs} and @var{rods}. The @var{springs} argument has" - " the format @code{(ideal, inverse_hook)} and @var{rods} is of" - " the form @code{(idx1, idx2, distance)}.\n" - "\n" - "@var{length} is a number, @var{ragged} a boolean.\n" - "\n" - "The function returns a list containing the force (positive for" - " stretching, negative for compressing and @code{#f} for" - " non-satisfied constraints) followed by @var{spring-count}+1" - " positions of the objects.") + 4, 1, 0, (SCM springs, SCM rods, SCM length, SCM ragged), + "Solve a spring and rod problem for @var{count} objects, that" + " are connected by @var{count}-1 @var{springs}, and an arbitrary" + " number of @var{rods}. @var{count} is implicitly given by" + " @var{springs} and @var{rods}. The @var{springs} argument has" + " the format @code{(ideal, inverse_hook)} and @var{rods} is of" + " the form @code{(idx1, idx2, distance)}.\n" + "\n" + "@var{length} is a number, @var{ragged} a boolean.\n" + "\n" + "The function returns a list containing the force (positive for" + " stretching, negative for compressing and @code{#f} for" + " non-satisfied constraints) followed by @var{spring-count}+1" + " positions of the objects.") { int len = scm_ilength (springs); if (len == 0) return scm_list_2 (scm_from_double (0.0), scm_from_double (0.0)); SCM_ASSERT_TYPE (len >= 0, springs, SCM_ARG1, __FUNCTION__, "list of springs"); - SCM_ASSERT_TYPE (scm_ilength (rods) > 0, rods, SCM_ARG1, __FUNCTION__, "list of rods"); + SCM_ASSERT_TYPE (scm_ilength (rods) > 0, rods, SCM_ARG1, __FUNCTION__, "list of rods"); LY_ASSERT_TYPE (scm_is_number, length, 3); bool is_ragged = ragged == SCM_BOOL_T; diff --git a/lily/simple-spacer.cc b/lily/simple-spacer.cc index 4376b0133c..10d49b83d9 100644 --- a/lily/simple-spacer.cc +++ b/lily/simple-spacer.cc @@ -25,7 +25,7 @@ #include "column-x-positions.hh" #include "dimensions.hh" #include "international.hh" -#include "libc-extension.hh" // isinf +#include "libc-extension.hh" // isinf #include "paper-column.hh" #include "simple-spacer.hh" #include "spaceable-grob.hh" @@ -115,13 +115,13 @@ Simple_spacer::add_rod (int l, int r, Real dist) { Real spring_dist = range_ideal_len (l, r); if (spring_dist < dist) - for (int i = l; i < r; i++) - { - if (spring_dist) - springs_[i].set_distance (springs_[i].distance () * dist / spring_dist); - else - springs_[i].set_distance (dist / (r - l)); - } + for (int i = l; i < r; i++) + { + if (spring_dist) + springs_[i].set_distance (springs_[i].distance () * dist / spring_dist); + else + springs_[i].set_distance (dist / (r - l)); + } return; } @@ -145,7 +145,7 @@ Simple_spacer::range_stiffness (int l, int r, bool stretch) const Real den = 0.0; for (int i = l; i < r; i++) den += stretch ? springs_[i].inverse_stretch_strength () - : springs_[i].inverse_compress_strength (); + : springs_[i].inverse_compress_strength (); return 1 / den; } @@ -183,7 +183,7 @@ Simple_spacer::expand_line () double cur_len = configuration_length (force_); fits_ = true; - for (vsize i=0; i < springs_.size (); i++) + for (vsize i = 0; i < springs_.size (); i++) inv_hooke += springs_[i].inverse_stretch_strength (); if (inv_hooke == 0.0) /* avoid division by zero. If springs are infinitely stiff */ @@ -221,31 +221,31 @@ Simple_spacer::compress_line () /* inv_hooke is the total flexibility of currently-active springs */ double inv_hooke = 0; vsize i = sorted_springs.size (); - for ( ; i && sorted_springs[i - 1].blocking_force () < cur_force; i--) + for (; i && sorted_springs[i - 1].blocking_force () < cur_force; i--) inv_hooke += compressed - ? sorted_springs[i - 1].inverse_compress_strength () - : sorted_springs[i - 1].inverse_stretch_strength (); + ? sorted_springs[i - 1].inverse_compress_strength () + : sorted_springs[i - 1].inverse_stretch_strength (); /* i now indexes the first active spring, so */ - for ( ; i < sorted_springs.size (); i++) + for (; i < sorted_springs.size (); i++) { Spring sp = sorted_springs[i]; if (isinf (sp.blocking_force ())) - break; + break; double block_dist = (cur_force - sp.blocking_force ()) * inv_hooke; if (cur_len - block_dist < line_len_) - { - cur_force += (line_len_ - cur_len) / inv_hooke; - cur_len = line_len_; - - /* - Paranoia check. - */ - assert (fabs (configuration_length (cur_force) - cur_len) < 1e-6); - return cur_force; - } - + { + cur_force += (line_len_ - cur_len) / inv_hooke; + cur_len = line_len_; + + /* + Paranoia check. + */ + assert (fabs (configuration_length (cur_force) - cur_len) < 1e-6); + return cur_force; + } + cur_len -= block_dist; inv_hooke -= compressed ? sp.inverse_compress_strength () : sp.inverse_stretch_strength (); cur_force = sp.blocking_force (); @@ -284,7 +284,7 @@ Simple_spacer::force_penalty (bool ragged) const /* Use a convex compression penalty. */ Real f = force_; - return f - (f < 0 ? f*f*f*f*2 : 0); + return f - (f < 0 ? f * f * f * f * 2 : 0); } /****************************************************************/ @@ -294,7 +294,7 @@ struct Rod_description vsize r_; Real dist_; - bool operator< (const Rod_description r) + bool operator < (const Rod_description r) { return r_ < r.r_; } @@ -334,26 +334,26 @@ is_loose (Grob *g) return (scm_is_pair (g->get_object ("between-cols"))); } -static Grob* +static Grob * maybe_find_prebroken_piece (Grob *g, Direction d) { - Grob *ret = dynamic_cast<Item*> (g)->find_prebroken_piece (d); + Grob *ret = dynamic_cast<Item *> (g)->find_prebroken_piece (d); if (ret) return ret; return g; } -static Grob* -next_spaceable_column (vector<Grob*> const &list, vsize starting) +static Grob * +next_spaceable_column (vector<Grob *> const &list, vsize starting) { - for (vsize i = starting+1; i < list.size (); i++) + for (vsize i = starting + 1; i < list.size (); i++) if (!is_loose (list[i])) return list[i]; return 0; } static Column_description -get_column_description (vector<Grob*> const &cols, vsize col_index, bool line_starter) +get_column_description (vector<Grob *> const &cols, vsize col_index, bool line_starter) { Grob *col = cols[col_index]; if (line_starter) @@ -364,7 +364,7 @@ get_column_description (vector<Grob*> const &cols, vsize col_index, bool line_st if (next_col) description.spring_ = Spaceable_grob::get_spring (col, next_col); - Grob *end_col = dynamic_cast<Item*> (cols[col_index+1])->find_prebroken_piece (LEFT); + Grob *end_col = dynamic_cast<Item *> (cols[col_index + 1])->find_prebroken_piece (LEFT); if (end_col) description.end_spring_ = Spaceable_grob::get_spring (col, end_col); @@ -374,14 +374,14 @@ get_column_description (vector<Grob*> const &cols, vsize col_index, bool line_st Grob *other = unsmob_grob (scm_caar (s)); vsize j = binary_search (cols, other, Paper_column::less_than, col_index); if (j != VPOS) - { - if (cols[j] == other) - description.rods_.push_back (Rod_description (j, scm_to_double (scm_cdar (s)))); - else /* it must end at the LEFT prebroken_piece */ - description.end_rods_.push_back (Rod_description (j, scm_to_double (scm_cdar (s)))); - } + { + if (cols[j] == other) + description.rods_.push_back (Rod_description (j, scm_to_double (scm_cdar (s)))); + else /* it must end at the LEFT prebroken_piece */ + description.end_rods_.push_back (Rod_description (j, scm_to_double (scm_cdar (s)))); + } } - + if (!line_starter && to_boolean (col->get_property ("keep-inside-line"))) description.keep_inside_line_ = col->extent (col, X_AXIS); @@ -390,12 +390,12 @@ get_column_description (vector<Grob*> const &cols, vsize col_index, bool line_st } vector<Real> -get_line_forces (vector<Grob*> const &columns, - Real line_len, Real indent, bool ragged) +get_line_forces (vector<Grob *> const &columns, + Real line_len, Real indent, bool ragged) { vector<vsize> breaks; vector<Real> force; - vector<Grob*> non_loose; + vector<Grob *> non_loose; vector<Column_description> cols; SCM force_break = ly_symbol2scm ("force"); @@ -409,7 +409,7 @@ get_line_forces (vector<Grob*> const &columns, for (vsize i = 1; i + 1 < non_loose.size (); i++) { if (Paper_column::is_breakable (non_loose[i])) - breaks.push_back (cols.size ()); + breaks.push_back (cols.size ()); cols.push_back (get_column_description (non_loose, i, false)); } @@ -421,67 +421,66 @@ get_line_forces (vector<Grob*> const &columns, cols[breaks[b]] = get_column_description (non_loose, breaks[b], true); vsize st = breaks[b]; - for (vsize c = b+1; c < breaks.size (); c++) - { - vsize end = breaks[c]; - Simple_spacer spacer; - - for (vsize i = breaks[b]; i < end - 1; i++) - spacer.add_spring (cols[i].spring_); - spacer.add_spring (cols[end-1].end_spring_); - - - for (vsize i = breaks[b]; i < end; i++) - { - for (vsize r = 0; r < cols[i].rods_.size (); r++) - if (cols[i].rods_[r].r_ < end) - spacer.add_rod (i - st, cols[i].rods_[r].r_ - st, cols[i].rods_[r].dist_); - for (vsize r = 0; r < cols[i].end_rods_.size (); r++) - if (cols[i].end_rods_[r].r_ == end) - spacer.add_rod (i - st, end - st, cols[i].end_rods_[r].dist_); - if (!cols[i].keep_inside_line_.is_empty ()) - { - spacer.add_rod (i - st, end - st, cols[i].keep_inside_line_[RIGHT]); - spacer.add_rod (0, i - st, -cols[i].keep_inside_line_[LEFT]); - } - } - spacer.solve ((b == 0) ? line_len - indent : line_len, ragged); - force[b * breaks.size () + c] = spacer.force_penalty (ragged); - - if (!spacer.fits ()) - { - if (c == b + 1) - force[b * breaks.size () + c] = -200000; - else - force[b * breaks.size () + c] = infinity_f; - break; - } - if (end < cols.size () && cols[end].break_permission_ == force_break) - break; - } + for (vsize c = b + 1; c < breaks.size (); c++) + { + vsize end = breaks[c]; + Simple_spacer spacer; + + for (vsize i = breaks[b]; i < end - 1; i++) + spacer.add_spring (cols[i].spring_); + spacer.add_spring (cols[end - 1].end_spring_); + + for (vsize i = breaks[b]; i < end; i++) + { + for (vsize r = 0; r < cols[i].rods_.size (); r++) + if (cols[i].rods_[r].r_ < end) + spacer.add_rod (i - st, cols[i].rods_[r].r_ - st, cols[i].rods_[r].dist_); + for (vsize r = 0; r < cols[i].end_rods_.size (); r++) + if (cols[i].end_rods_[r].r_ == end) + spacer.add_rod (i - st, end - st, cols[i].end_rods_[r].dist_); + if (!cols[i].keep_inside_line_.is_empty ()) + { + spacer.add_rod (i - st, end - st, cols[i].keep_inside_line_[RIGHT]); + spacer.add_rod (0, i - st, -cols[i].keep_inside_line_[LEFT]); + } + } + spacer.solve ((b == 0) ? line_len - indent : line_len, ragged); + force[b * breaks.size () + c] = spacer.force_penalty (ragged); + + if (!spacer.fits ()) + { + if (c == b + 1) + force[b * breaks.size () + c] = -200000; + else + force[b * breaks.size () + c] = infinity_f; + break; + } + if (end < cols.size () && cols[end].break_permission_ == force_break) + break; + } } return force; } Column_x_positions -get_line_configuration (vector<Grob*> const &columns, - Real line_len, - Real indent, - bool ragged) +get_line_configuration (vector<Grob *> const &columns, + Real line_len, + Real indent, + bool ragged) { vector<Column_description> cols; Simple_spacer spacer; Column_x_positions ret; - ret.cols_.push_back (dynamic_cast<Item*> (columns[0])->find_prebroken_piece (RIGHT)); + ret.cols_.push_back (dynamic_cast<Item *> (columns[0])->find_prebroken_piece (RIGHT)); for (vsize i = 1; i + 1 < columns.size (); i++) { if (is_loose (columns[i])) - ret.loose_cols_.push_back (columns[i]); + ret.loose_cols_.push_back (columns[i]); else - ret.cols_.push_back (columns[i]); + ret.cols_.push_back (columns[i]); } - ret.cols_.push_back (dynamic_cast<Item*> (columns.back ())->find_prebroken_piece (LEFT)); + ret.cols_.push_back (dynamic_cast<Item *> (columns.back ())->find_prebroken_piece (LEFT)); /* since we've already put our line-ending column in the column list, we can ignore the end_XXX_ fields of our column_description */ @@ -493,13 +492,13 @@ get_line_configuration (vector<Grob*> const &columns, for (vsize i = 0; i < cols.size (); i++) { for (vsize r = 0; r < cols[i].rods_.size (); r++) - spacer.add_rod (i, cols[i].rods_[r].r_, cols[i].rods_[r].dist_); + spacer.add_rod (i, cols[i].rods_[r].r_, cols[i].rods_[r].dist_); if (!cols[i].keep_inside_line_.is_empty ()) - { - spacer.add_rod (i, cols.size (), cols[i].keep_inside_line_[RIGHT]); - spacer.add_rod (0, i, -cols[i].keep_inside_line_[LEFT]); - } + { + spacer.add_rod (i, cols.size (), cols[i].keep_inside_line_[RIGHT]); + spacer.add_rod (0, i, -cols[i].keep_inside_line_[LEFT]); + } } spacer.solve (line_len, ragged); @@ -518,7 +517,7 @@ get_line_configuration (vector<Grob*> const &columns, { SCM p = ret.cols_[i]->get_property ("line-break-permission"); if (p == ly_symbol2scm ("force")) - ret.satisfies_constraints_ = false; + ret.satisfies_constraints_ = false; } return ret; diff --git a/lily/simultaneous-music-iterator.cc b/lily/simultaneous-music-iterator.cc index 3723c2695f..36e0fb817e 100644 --- a/lily/simultaneous-music-iterator.cc +++ b/lily/simultaneous-music-iterator.cc @@ -59,26 +59,26 @@ Simultaneous_music_iterator::construct_children () Music_iterator *mi = unsmob_iterator (scm_iter); /* if create_separate_contexts_ is set, create a new context with the - number number as name */ + number number as name */ SCM name = ly_symbol2scm (get_outlet ()->context_name ().c_str ()); Context *c = (j && create_separate_contexts_) - ? get_outlet ()->find_create_context (name, to_string (j), SCM_EOL) - : get_outlet (); + ? get_outlet ()->find_create_context (name, to_string (j), SCM_EOL) + : get_outlet (); if (!c) - c = get_outlet (); + c = get_outlet (); mi->init_context (mus, c); mi->construct_children (); if (mi->ok ()) - { - *tail = scm_cons (scm_iter, *tail); - tail = SCM_CDRLOC (*tail); - } + { + *tail = scm_cons (scm_iter, *tail); + tail = SCM_CDRLOC (*tail); + } else - mi->quit (); + mi->quit (); } } @@ -90,15 +90,15 @@ Simultaneous_music_iterator::process (Moment until) { Music_iterator *i = unsmob_iterator (scm_car (*proc)); if (i->run_always () - || i->pending_moment () == until) - i->process (until); + || i->pending_moment () == until) + i->process (until); if (!i->ok ()) - { - i->quit (); - *proc = scm_cdr (*proc); - } + { + i->quit (); + *proc = scm_cdr (*proc); + } else - proc = SCM_CDRLOC (*proc); + proc = SCM_CDRLOC (*proc); } } @@ -125,9 +125,9 @@ Simultaneous_music_iterator::ok () const { Music_iterator *it = unsmob_iterator (scm_car (s)); if (!it->run_always ()) - return true; + return true; else - run_always_ok = run_always_ok || it->ok (); + run_always_ok = run_always_ok || it->ok (); } return run_always_ok; } @@ -139,7 +139,7 @@ Simultaneous_music_iterator::run_always () const { Music_iterator *it = unsmob_iterator (scm_car (s)); if (it->run_always ()) - return true; + return true; } return false; } diff --git a/lily/skyline-pair.cc b/lily/skyline-pair.cc index 2f7ea73575..2a3b26ff9e 100644 --- a/lily/skyline-pair.cc +++ b/lily/skyline-pair.cc @@ -2,7 +2,7 @@ This file is part of LilyPond, the GNU music typesetter. Copyright (C) 2008--2011 Han-Wen Nienhuys <hanwen@lilypond.org> - + LilyPond is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -79,21 +79,20 @@ Skyline_pair::print_points () const skylines_[DOWN].print (); } - bool Skyline_pair::is_empty () const { return skylines_[UP].is_empty () - && skylines_[DOWN].is_empty (); + && skylines_[DOWN].is_empty (); } -Skyline& +Skyline & Skyline_pair::operator [] (Direction d) { return skylines_[d]; } -Skyline const& +Skyline const & Skyline_pair::operator [] (Direction d) const { return skylines_[d]; diff --git a/lily/skyline.cc b/lily/skyline.cc index fe30291f78..b5288e2526 100644 --- a/lily/skyline.cc +++ b/lily/skyline.cc @@ -78,8 +78,8 @@ Skyline::print_points () const vector<Offset> ps (to_points (X_AXIS)); for (vsize i = 0; i < ps.size (); i++) - printf ("(%f,%f)%s" , ps[i][X_AXIS], ps[i][Y_AXIS], - (i%2)==1 ? "\n" : " "); + printf ("(%f,%f)%s", ps[i][X_AXIS], ps[i][Y_AXIS], + (i % 2) == 1 ? "\n" : " "); } Building::Building (Real start, Real start_height, Real end_height, Real end) @@ -122,7 +122,7 @@ Building::precompute (Real start, Real start_height, Real end_height, Real end) Real Building::height (Real x) const { - return isinf (x) ? y_intercept_ : slope_*x + y_intercept_; + return isinf (x) ? y_intercept_ : slope_ * x + y_intercept_; } void @@ -168,15 +168,15 @@ first_intersection (Building const &b, list<Building> *const s, Real start_x) { Building c = s->front (); if (c.conceals (b, start_x)) - return start_x; + return start_x; Real i = b.intersection_x (c); if (i > start_x && i <= b.end_ && i <= c.end_) - return i; + return i; start_x = c.end_; if (b.end_ > c.end_) - s->pop_front (); + s->pop_front (); } return b.end_; } @@ -190,12 +190,12 @@ Building::conceals (Building const &other, Real x) const /* their slopes were not equal, so there is an intersection point */ Real i = intersection_x (other); return (i <= x && slope_ > other.slope_) - || (i > x && slope_ < other.slope_); + || (i > x && slope_ < other.slope_); } void Skyline::internal_merge_skyline (list<Building> *s1, list<Building> *s2, - list<Building> *const result) + list<Building> *const result) { if (s1->empty () || s2->empty ()) { @@ -207,26 +207,26 @@ Skyline::internal_merge_skyline (list<Building> *s1, list<Building> *s2, while (!s1->empty ()) { if (s2->front ().conceals (s1->front (), x)) - swap (s1, s2); + swap (s1, s2); Building b = s1->front (); Real end = first_intersection (b, s2, x); if (s2->empty ()) - { - result->push_front (b); - break; - } + { + result->push_front (b); + break; + } /* only include buildings wider than epsilon */ if (end > x + EPS) - { - b.leading_part (end); - result->push_front (b); - } + { + b.leading_part (end); + result->push_front (b); + } if (end >= s1->front ().end_) - s1->pop_front (); + s1->pop_front (); x = end; } @@ -249,7 +249,7 @@ single_skyline (Building b, Real start, Real horizon_padding, list<Building> *co bool sloped_neighbours = horizon_padding > 0 && !isinf (start) && !isinf (b.end_); if (!isinf (b.end_)) ret->push_front (Building (b.end_ + horizon_padding, -infinity_f, - -infinity_f, infinity_f)); + -infinity_f, infinity_f)); if (sloped_neighbours) ret->push_front (b.sloped_neighbour (start, horizon_padding, RIGHT)); @@ -261,7 +261,7 @@ single_skyline (Building b, Real start, Real horizon_padding, list<Building> *co if (!isinf (start)) ret->push_front (Building (-infinity_f, -infinity_f, - -infinity_f, start - horizon_padding)); + -infinity_f, start - horizon_padding)); } /* remove a non-overlapping set of boxes from BOXES and build a skyline @@ -277,21 +277,21 @@ non_overlapping_skyline (list<Box> *const boxes, Real horizon_padding, Axis hori Interval iv = (*i)[horizon_axis]; if (iv[LEFT] - horizon_padding < last_end) - { - i++; - continue; - } + { + i++; + continue; + } if (iv[LEFT] - horizon_padding > last_end + EPS) - result.push_front (Building (last_end, -infinity_f, -infinity_f, iv[LEFT] - 2*horizon_padding)); + result.push_front (Building (last_end, -infinity_f, -infinity_f, iv[LEFT] - 2 * horizon_padding)); Building b (*i, horizon_padding, horizon_axis, sky); bool sloped_neighbours = horizon_padding > 0 && !isinf (iv.length ()); if (sloped_neighbours) - result.push_front (b.sloped_neighbour (iv[LEFT] - horizon_padding, horizon_padding, LEFT)); + result.push_front (b.sloped_neighbour (iv[LEFT] - horizon_padding, horizon_padding, LEFT)); result.push_front (b); if (sloped_neighbours) - result.push_front (b.sloped_neighbour (iv[LEFT] - horizon_padding, horizon_padding, RIGHT)); + result.push_front (b.sloped_neighbour (iv[LEFT] - horizon_padding, horizon_padding, RIGHT)); list<Box>::iterator j = i++; boxes->erase (j); @@ -313,7 +313,7 @@ public: a_ = a; } - bool operator() (Box const &b1, Box const &b2) + bool operator () (Box const &b1, Box const &b2) { return b1[a_][LEFT] < b2[a_][LEFT]; } @@ -334,8 +334,8 @@ Skyline::internal_build_skyline (list<Box> *boxes, Real horizon_padding, Axis ho { list<Building> result; single_skyline (Building (boxes->front (), horizon_padding, horizon_axis, sky), - boxes->front ()[horizon_axis][LEFT] - horizon_padding, - horizon_padding, &result); + boxes->front ()[horizon_axis][LEFT] - horizon_padding, + horizon_padding, &result); return result; } @@ -352,7 +352,7 @@ Skyline::internal_build_skyline (list<Box> *boxes, Real horizon_padding, Axis ho list<Building> one = partials.front (); partials.pop_front (); if (partials.empty ()) - return one; + return one; list<Building> two = partials.front (); partials.pop_front (); @@ -407,17 +407,16 @@ Skyline::Skyline (Skyline const &src, Real horizon_padding, Axis a) // establish a baseline box boxes.push_back (Box (Interval (-infinity_f, infinity_f), - Interval (0, 0))); + Interval (0, 0))); list<Building>::const_iterator end = src.buildings_.end (); - for (list<Building>::const_iterator i = src.buildings_.begin (); i != end; start=i->end_, i++ ) + for (list<Building>::const_iterator i = src.buildings_.begin (); i != end; start = i->end_, i++) if ((i->slope_ == 0) && !isinf (i->y_intercept_)) boxes.push_back (Box (Interval (start, i->end_), - Interval (-infinity_f , i->y_intercept_))); + Interval (-infinity_f, i->y_intercept_))); buildings_ = internal_build_skyline (&boxes, horizon_padding, X_AXIS, UP); sky_ = src.sky_; } - /* build skyline from a set of boxes. If horizon_padding > 0, expand all the boxes by that amount and add 45-degree sloped boxes to the edges of each box (of @@ -438,7 +437,7 @@ Skyline::Skyline (vector<Box> const &boxes, Real horizon_padding, Axis horizon_a Interval iv = boxes[i][horizon_axis]; iv.widen (horizon_padding); if (iv.length () > EPS && !boxes[i][vert_axis].is_empty ()) - filtered_boxes.push_front (boxes[i]); + filtered_boxes.push_front (boxes[i]); } buildings_ = internal_build_skyline (&filtered_boxes, horizon_padding, horizon_axis, sky); @@ -449,7 +448,7 @@ Skyline::Skyline (Box const &b, Real horizon_padding, Axis horizon_axis, Directi sky_ = sky; Building front (b, horizon_padding, horizon_axis, sky); single_skyline (front, b[horizon_axis][LEFT] - horizon_padding, - horizon_padding, &buildings_); + horizon_padding, &buildings_); } void @@ -484,7 +483,7 @@ Skyline::insert (Box const &b, Real horizon_padding, Axis a) my_bld.splice (my_bld.begin (), buildings_); single_skyline (Building (b, horizon_padding, a, sky_), b[a][LEFT] - horizon_padding, - horizon_padding, &other_bld); + horizon_padding, &other_bld); internal_merge_skyline (&other_bld, &my_bld, &buildings_); } @@ -539,9 +538,9 @@ Skyline::distance (Skyline const &other, Real horizon_padding) const Real end_dist = i->height (end) + j->height (end); dist = max (dist, max (start_dist, end_dist)); if (i->end_ <= j->end_) - i++; + i++; else - j++; + j++; start = end; } return dist; @@ -556,7 +555,7 @@ Skyline::height (Real airplane) const for (i = buildings_.begin (); i != buildings_.end (); i++) { if (i->end_ >= airplane) - return sky_ * i->height (airplane); + return sky_ * i->height (airplane); } assert (0); @@ -579,7 +578,6 @@ Skyline::set_minimum_height (Real h) merge (s); } - vector<Offset> Skyline::to_points (Axis horizon_axis) const { @@ -617,7 +615,6 @@ Skyline::clear () /****************************************************************/ - IMPLEMENT_SIMPLE_SMOBS (Skyline); IMPLEMENT_TYPE_P (Skyline, "ly:skyline?"); IMPLEMENT_DEFAULT_EQUAL_P (Skyline); diff --git a/lily/slash-repeat-engraver.cc b/lily/slash-repeat-engraver.cc index 0db3ceffb3..4f974fe7c6 100644 --- a/lily/slash-repeat-engraver.cc +++ b/lily/slash-repeat-engraver.cc @@ -48,7 +48,7 @@ IMPLEMENT_TRANSLATOR_LISTENER (Slash_repeat_engraver, repeat_slash); void Slash_repeat_engraver::listen_repeat_slash (Stream_event *ev) { - ASSIGN_EVENT_ONCE (slash_, ev); + ASSIGN_EVENT_ONCE (slash_, ev); } void @@ -58,24 +58,24 @@ Slash_repeat_engraver::process_music () { SCM count = slash_->get_property ("slash-count"); if (scm_to_int (count) == 0) - make_item ("DoubleRepeatSlash", slash_->self_scm ()); + make_item ("DoubleRepeatSlash", slash_->self_scm ()); else - make_item ("RepeatSlash", slash_->self_scm ()); + make_item ("RepeatSlash", slash_->self_scm ()); slash_ = 0; } } ADD_TRANSLATOR (Slash_repeat_engraver, - /* doc */ - "Make beat repeats.", + /* doc */ + "Make beat repeats.", - /* create */ - "DoubleRepeatSlash " - "RepeatSlash ", + /* create */ + "DoubleRepeatSlash " + "RepeatSlash ", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/slur-configuration.cc b/lily/slur-configuration.cc index e83856364d..8fdea86edb 100644 --- a/lily/slur-configuration.cc +++ b/lily/slur-configuration.cc @@ -19,7 +19,6 @@ #include "slur-configuration.hh" - #include "item.hh" #include "libc-extension.hh" #include "misc.hh" @@ -33,7 +32,7 @@ Bezier avoid_staff_line (Slur_score_state const &state, - Bezier bez) + Bezier bez) { Offset horiz (1, 0); vector<Real> ts = bez.solve_derivative (horiz); @@ -48,34 +47,34 @@ avoid_staff_line (Slur_score_state const &state, Grob *staff = state.extremes_[LEFT].staff_; Real p = 2 * (y - staff->relative_coordinate (state.common_[Y_AXIS], Y_AXIS)) - / state.staff_space_; + / state.staff_space_; - Real distance = fabs (my_round (p) - p); // in halfspaces + Real distance = fabs (my_round (p) - p); // in halfspaces if (distance < 4 * state.thickness_ - && (int) fabs (my_round (p)) - <= 2 * Staff_symbol_referencer::staff_radius (staff) + 0.1 - && (int (fabs (my_round (p))) % 2 - != Staff_symbol_referencer::line_count (staff) % 2)) - { - Direction resolution_dir - = (distance ? state.dir_ : Direction (sign (p - my_round (p)))); - - // TODO: parameter - Real newp = my_round (p) + resolution_dir - * 5 * state.thickness_; - - Real dy = (newp - p) * state.staff_space_ / 2.0; - - bez.control_[1][Y_AXIS] += dy; - bez.control_[2][Y_AXIS] += dy; - } + && (int) fabs (my_round (p)) + <= 2 * Staff_symbol_referencer::staff_radius (staff) + 0.1 + && (int (fabs (my_round (p))) % 2 + != Staff_symbol_referencer::line_count (staff) % 2)) + { + Direction resolution_dir + = (distance ? state.dir_ : Direction (sign (p - my_round (p)))); + + // TODO: parameter + Real newp = my_round (p) + resolution_dir + * 5 * state.thickness_; + + Real dy = (newp - p) * state.staff_space_ / 2.0; + + bez.control_[1][Y_AXIS] += dy; + bez.control_[2][Y_AXIS] += dy; + } } return bez; } Real fit_factor (Offset dz_unit, Offset dz_perp, - Bezier curve, Direction d, vector<Offset> const &avoid) + Bezier curve, Direction d, vector<Offset> const &avoid) { Real fit_factor = 0.0; Offset x0 = curve.control_[0]; @@ -91,27 +90,27 @@ fit_factor (Offset dz_unit, Offset dz_perp, { Offset z = (avoid[i] - x0); Offset p (dot_product (z, dz_unit), - d * dot_product (z, dz_perp)); + d * dot_product (z, dz_perp)); Real eps = 0.01; - Interval pext = eps * Interval (-1,1) + p[X_AXIS]; + Interval pext = eps * Interval (-1, 1) + p[X_AXIS]; pext.intersect (curve_xext); if (pext.is_empty () || pext.length () <= 1.999 * eps) - continue; + continue; Real y = curve.get_other_coordinate (X_AXIS, p[X_AXIS]); if (y) - fit_factor = max (fit_factor, (p[Y_AXIS] / y)); + fit_factor = max (fit_factor, (p[Y_AXIS] / y)); } return fit_factor; } void Slur_configuration::generate_curve (Slur_score_state const &state, - Real r_0, Real h_inf, - vector<Offset> const &avoid) + Real r_0, Real h_inf, + vector<Offset> const &avoid) { - Offset dz = attachment_[RIGHT]- attachment_[LEFT];; + Offset dz = attachment_[RIGHT] - attachment_[LEFT];; Offset dz_unit = dz; dz_unit *= 1 / dz.length (); Offset dz_perp = dz_unit * Offset (0, 1); @@ -155,9 +154,9 @@ Slur_configuration::generate_curve (Slur_score_state const &state, Bezier curve; curve.control_[0] = attachment_[LEFT]; curve.control_[1] = attachment_[LEFT] + dz_perp * height * state.dir_ - + dz_unit * x1; + + dz_unit * x1; curve.control_[2] = attachment_[RIGHT] + dz_perp * height * state.dir_ - + dz_unit * x2; + + dz_unit * x2; curve.control_[3] = attachment_[RIGHT]; Real ff = fit_factor (dz_unit, dz_perp, curve, state.dir_, avoid); @@ -166,9 +165,9 @@ Slur_configuration::generate_curve (Slur_score_state const &state, curve.control_[0] = attachment_[LEFT]; curve.control_[1] = attachment_[LEFT] + dz_perp * height * state.dir_ - + dz_unit * x1; + + dz_unit * x1; curve.control_[2] = attachment_[RIGHT] + dz_perp * height * state.dir_ - + dz_unit * x2; + + dz_unit * x2; curve.control_[3] = attachment_[RIGHT]; curve_ = avoid_staff_line (state, curve); @@ -189,11 +188,11 @@ Slur_configuration::add_score (Real s, string desc) programming_error ("Negative demerits found for slur. Ignoring"); s = 0.0; } - + if (s) { if (score_card_.length () > 0) - score_card_ += ", "; + score_card_ += ", "; score_card_ += to_string ("%s=%.2f", desc.c_str (), s); score_ += s; } @@ -219,100 +218,100 @@ Slur_configuration::score_encompass (Slur_score_state const &state) bool edge = l_edge || r_edge; if (! (x < attachment_[RIGHT][X_AXIS] - && x > attachment_[LEFT][X_AXIS])) - continue; + && x > attachment_[LEFT][X_AXIS])) + continue; Real y = bez.get_other_coordinate (X_AXIS, x); if (!edge) - { - Real head_dy = (y - state.encompass_infos_[j].head_); - if (state.dir_ * head_dy < 0) - { - demerit += state.parameters_.head_encompass_penalty_; - convex_head_distances.push_back (0.0); - } - else - { - Real hd = (head_dy) - ? (1 / fabs (head_dy) - 1 / state.parameters_.free_head_distance_) - : state.parameters_.head_encompass_penalty_; - hd = min (max (hd, 0.0), state.parameters_.head_encompass_penalty_); - - demerit += hd; - } - - Real line_y = linear_interpolate (x, - attachment_[RIGHT][X_AXIS], - attachment_[LEFT][X_AXIS], - attachment_[RIGHT][Y_AXIS], - attachment_[LEFT][Y_AXIS]); - - if (1) // state.dir_ * state.encompass_infos_[j].get_point (state.dir_) > state.dir_ *line_y ) - { - - Real closest - = state.dir_ * max (state.dir_ * state.encompass_infos_[j].get_point (state.dir_), state.dir_ * line_y); - Real d = fabs (closest - y); - - convex_head_distances.push_back (d); - } - } + { + Real head_dy = (y - state.encompass_infos_[j].head_); + if (state.dir_ * head_dy < 0) + { + demerit += state.parameters_.head_encompass_penalty_; + convex_head_distances.push_back (0.0); + } + else + { + Real hd = (head_dy) + ? (1 / fabs (head_dy) - 1 / state.parameters_.free_head_distance_) + : state.parameters_.head_encompass_penalty_; + hd = min (max (hd, 0.0), state.parameters_.head_encompass_penalty_); + + demerit += hd; + } + + Real line_y = linear_interpolate (x, + attachment_[RIGHT][X_AXIS], + attachment_[LEFT][X_AXIS], + attachment_[RIGHT][Y_AXIS], + attachment_[LEFT][Y_AXIS]); + + if (1) // state.dir_ * state.encompass_infos_[j].get_point (state.dir_) > state.dir_ *line_y ) + { + + Real closest + = state.dir_ * max (state.dir_ * state.encompass_infos_[j].get_point (state.dir_), state.dir_ * line_y); + Real d = fabs (closest - y); + + convex_head_distances.push_back (d); + } + } if (state.dir_ * (y - state.encompass_infos_[j].stem_) < 0) - { - Real stem_dem = state.parameters_.stem_encompass_penalty_; - if ((l_edge && state.dir_ == UP) - || (r_edge && state.dir_ == DOWN)) - stem_dem /= 5; - - demerit += stem_dem; - } + { + Real stem_dem = state.parameters_.stem_encompass_penalty_; + if ((l_edge && state.dir_ == UP) + || (r_edge && state.dir_ == DOWN)) + stem_dem /= 5; + + demerit += stem_dem; + } else if (!edge) - { - Interval ext; - ext.add_point (state.encompass_infos_[j].stem_); - ext.add_point (state.encompass_infos_[j].head_); - - // ? - demerit += -state.parameters_.closeness_factor_ - * min (state.dir_ - * (y - (ext[state.dir_] + state.dir_ * state.parameters_.free_head_distance_)), 0.0) - / state.encompass_infos_.size (); - } + { + Interval ext; + ext.add_point (state.encompass_infos_[j].stem_); + ext.add_point (state.encompass_infos_[j].head_); + + // ? + demerit += -state.parameters_.closeness_factor_ + * min (state.dir_ + * (y - (ext[state.dir_] + state.dir_ * state.parameters_.free_head_distance_)), 0.0) + / state.encompass_infos_.size (); + } } add_score (demerit, "encompass"); - + if (convex_head_distances.size ()) { Real avg_distance = 0.0; Real min_dist = infinity_f; for (vsize j = 0; j < convex_head_distances.size (); j++) - { - min_dist = min (min_dist, convex_head_distances[j]); - avg_distance += convex_head_distances[j]; - } + { + min_dist = min (min_dist, convex_head_distances[j]); + avg_distance += convex_head_distances[j]; + } /* - For slurs over 3 or 4 heads, the average distance is not a - good normalizer. + For slurs over 3 or 4 heads, the average distance is not a + good normalizer. */ Real n = convex_head_distances.size (); if (n <= 2) - { - Real fact = 1.0; - avg_distance += height_ * fact; - n += fact; - } + { + Real fact = 1.0; + avg_distance += height_ * fact; + n += fact; + } /* - TODO: maybe it's better to use (avgdist - mindist)*factor - as penalty. + TODO: maybe it's better to use (avgdist - mindist)*factor + as penalty. */ avg_distance /= n; Real variance_penalty = state.parameters_.head_slur_distance_max_ratio_; if (min_dist > 0.0) - variance_penalty - = min ((avg_distance / (min_dist + state.parameters_.absolute_closeness_measure_) - 1.0), variance_penalty); + variance_penalty + = min ((avg_distance / (min_dist + state.parameters_.absolute_closeness_measure_) - 1.0), variance_penalty); variance_penalty = max (variance_penalty, 0.0); variance_penalty *= state.parameters_.head_slur_distance_factor_; @@ -328,69 +327,69 @@ Slur_configuration::score_extra_encompass (Slur_score_state const &state) { Drul_array<Offset> attachment = attachment_; Extra_collision_info const &info (state.extra_encompass_infos_[j]); - + Interval slur_wid (attachment[LEFT][X_AXIS], attachment[RIGHT][X_AXIS]); /* - to prevent numerical inaccuracies in - Bezier::get_other_coordinate (). + to prevent numerical inaccuracies in + Bezier::get_other_coordinate (). */ Direction d = LEFT; bool found = false; Real y = 0.0; do - { - /* - We need to check for the bound explicitly, since the - slur-ending can be almost vertical, making the Y - coordinate a bad approximation of the object-slur - distance. - */ - Item *as_item = dynamic_cast<Item *> (state.extra_encompass_infos_[j].grob_); - if (!as_item) - continue; - - Interval item_x = as_item->extent (state.common_[X_AXIS], X_AXIS); - item_x.intersect (state.extremes_[d].slur_head_x_extent_); - if (!item_x.is_empty ()) - { - y = attachment[d][Y_AXIS]; - found = true; - } - - } + { + /* + We need to check for the bound explicitly, since the + slur-ending can be almost vertical, making the Y + coordinate a bad approximation of the object-slur + distance. + */ + Item *as_item = dynamic_cast<Item *> (state.extra_encompass_infos_[j].grob_); + if (!as_item) + continue; + + Interval item_x = as_item->extent (state.common_[X_AXIS], X_AXIS); + item_x.intersect (state.extremes_[d].slur_head_x_extent_); + if (!item_x.is_empty ()) + { + y = attachment[d][Y_AXIS]; + found = true; + } + + } while (flip (&d) != LEFT); if (!found) - { - Real x = info.extents_[X_AXIS].linear_combination (info.idx_); + { + Real x = info.extents_[X_AXIS].linear_combination (info.idx_); - if (!slur_wid.contains (x)) - continue; + if (!slur_wid.contains (x)) + continue; - y = curve_.get_other_coordinate (X_AXIS, x); - } + y = curve_.get_other_coordinate (X_AXIS, x); + } Real dist = 0.0; if (info.type_ == ly_symbol2scm ("around")) - dist = info.extents_[Y_AXIS].distance (y); + dist = info.extents_[Y_AXIS].distance (y); /* - Have to score too: the curve enumeration is limited in its - shape, and may produce curves which collide anyway. + Have to score too: the curve enumeration is limited in its + shape, and may produce curves which collide anyway. */ else if (info.type_ == ly_symbol2scm ("inside")) - dist = state.dir_ * (y - info.extents_[Y_AXIS][state.dir_]); + dist = state.dir_ * (y - info.extents_[Y_AXIS][state.dir_]); else - programming_error ("unknown avoidance type"); + programming_error ("unknown avoidance type"); dist = max (dist, 0.0); - + Real penalty = info.penalty_ * peak_around (0.1 * state.parameters_.extra_encompass_free_distance_, - state.parameters_.extra_encompass_free_distance_, - dist); - + state.parameters_.extra_encompass_free_distance_, + dist); + add_score (penalty, "extra"); } } @@ -400,7 +399,7 @@ Slur_configuration::score_edges (Slur_score_state const &state) { Direction d = LEFT; Offset dz = attachment_[RIGHT] - - attachment_[LEFT]; + - attachment_[LEFT]; Real slope = dz[Y_AXIS] / dz[X_AXIS]; do { @@ -410,14 +409,13 @@ Slur_configuration::score_edges (Slur_score_state const &state) Real factor = state.parameters_.edge_attraction_factor_; Real demerit = factor * dy; if (state.extremes_[d].stem_ - && state.extremes_[d].stem_dir_ == state.dir_ + && state.extremes_[d].stem_dir_ == state.dir_ // TODO - Stem::get_beaming() should be precomputed. - && !Stem::get_beaming (state.extremes_[d].stem_, -d)) - demerit /= 5; + && !Stem::get_beaming (state.extremes_[d].stem_, -d)) + demerit /= 5; demerit *= exp (state.dir_ * d * slope - * state.parameters_.edge_slope_exponent_); - + * state.parameters_.edge_slope_exponent_); string dir_str = d == LEFT ? "L" : "R"; add_score (demerit, dir_str + " edge"); @@ -434,8 +432,8 @@ Slur_configuration::score_slopes (Slur_score_state const &state) Real demerit = 0.0; demerit += max ((fabs (slur_dy / slur_dz[X_AXIS]) - - state.parameters_.max_slope_), 0.0) - * state.parameters_.max_slope_factor_; + - state.parameters_.max_slope_), 0.0) + * state.parameters_.max_slope_factor_; /* 0.2: account for staffline offset. */ Real max_dy = (fabs (dy) + 0.2); @@ -444,11 +442,11 @@ Slur_configuration::score_slopes (Slur_score_state const &state) if (!state.is_broken_) demerit += state.parameters_.steeper_slope_factor_ - * (max (fabs (slur_dy) -max_dy, 0.0)); + * (max (fabs (slur_dy) - max_dy, 0.0)); demerit += max ((fabs (slur_dy / slur_dz[X_AXIS]) - - state.parameters_.max_slope_), 0.0) - * state.parameters_.max_slope_factor_; + - state.parameters_.max_slope_), 0.0) + * state.parameters_.max_slope_factor_; if (sign (dy) == 0 && sign (slur_dy) != 0 @@ -460,41 +458,42 @@ Slur_configuration::score_slopes (Slur_score_state const &state) && sign (slur_dy) && sign (slur_dy) != sign (dy)) demerit += state.edge_has_beams_ - ? state.parameters_.same_slope_penalty_ / 10 - : state.parameters_.same_slope_penalty_; + ? state.parameters_.same_slope_penalty_ / 10 + : state.parameters_.same_slope_penalty_; add_score (demerit, "slope"); } - // This is a temporary hack to see how much we can gain by using a // priority queue on the beams to score. static int score_count = 0; LY_DEFINE (ly_slur_score_count, "ly:slur-score-count", 0, 0, 0, - (), - "count number of slur scores.") { + (), + "count number of slur scores.") +{ return scm_from_int (score_count); } void Slur_configuration::run_next_scorer (Slur_score_state const &state) { - switch (next_scorer_todo) { - case EXTRA_ENCOMPASS: - score_extra_encompass (state); - break; - case SLOPE: - score_slopes (state); - break; - case EDGES: - score_edges (state); - break; - case ENCOMPASS: - score_encompass (state); - break; - default: - assert (false); - } + switch (next_scorer_todo) + { + case EXTRA_ENCOMPASS: + score_extra_encompass (state); + break; + case SLOPE: + score_slopes (state); + break; + case EDGES: + score_edges (state); + break; + case ENCOMPASS: + score_encompass (state); + break; + default: + assert (false); + } next_scorer_todo++; score_count++; } diff --git a/lily/slur-engraver.cc b/lily/slur-engraver.cc index 45aa121a71..98f0bbf336 100644 --- a/lily/slur-engraver.cc +++ b/lily/slur-engraver.cc @@ -30,7 +30,6 @@ #include "translator.icc" - /* NOTE NOTE NOTE @@ -38,7 +37,7 @@ apply there too. (on principle, engravers don't use inheritance for code sharing) - + */ /* @@ -50,8 +49,8 @@ class Slur_engraver : public Engraver { vector<Stream_event *> start_events_; vector<Stream_event *> stop_events_; - vector<Grob*> slurs_; - vector<Grob*> end_slurs_; + vector<Grob *> slurs_; + vector<Grob *> end_slurs_; void set_melisma (bool); @@ -71,7 +70,6 @@ protected: virtual void finalize (); - public: TRANSLATOR_DECLARATIONS (Slur_engraver); }; @@ -86,11 +84,11 @@ Slur_engraver::listen_slur (Stream_event *ev) { Direction d = to_dir (ev->get_property ("span-direction")); if (d == START) - start_events_.push_back(ev); + start_events_.push_back (ev); else if (d == STOP) - stop_events_.push_back(ev); + stop_events_.push_back (ev); else ev->origin ()->warning (_f ("direction of %s invalid: %d", - "slur-event", int (d))); + "slur-event", int (d))); } void @@ -193,16 +191,16 @@ Slur_engraver::process_music () // Check if we already have a slur with the same spanner-id. // In that case, don't create a new slur, but print a warning for (vsize j = 0; j < slurs_.size (); j++) - have_slur = have_slur || (id == robust_scm2string (slurs_[j]->get_property ("spanner-id"), "")); - + have_slur = have_slur || (id == robust_scm2string (slurs_[j]->get_property ("spanner-id"), "")); + if (have_slur) { // We already have a slur, so give a warning and completely ignore // the new slur. - ev->origin ()->warning(_ ("already have slur")); + ev->origin ()->warning (_ ("already have slur")); start_events_.erase (start_events_.begin () + i); } - else + else { Grob *slur = make_spanner ("Slur", ev->self_scm ()); Direction updown = to_dir (ev->get_property ("direction")); @@ -230,19 +228,18 @@ Slur_engraver::stop_translation_timestep () if (Grob *g = unsmob_grob (get_property ("currentCommandColumn"))) { for (vsize i = 0; i < end_slurs_.size (); i++) - Slur::add_extra_encompass (end_slurs_[i], g); + Slur::add_extra_encompass (end_slurs_[i], g); if (!start_events_.size ()) - for (vsize i = 0; i < slurs_.size (); i++) - Slur::add_extra_encompass (slurs_[i], g); + for (vsize i = 0; i < slurs_.size (); i++) + Slur::add_extra_encompass (slurs_[i], g); } - - + for (vsize i = 0; i < end_slurs_.size (); i++) { - Spanner * s = dynamic_cast<Spanner*> (end_slurs_[i]); + Spanner *s = dynamic_cast<Spanner *> (end_slurs_[i]); if (!s->get_bound (RIGHT)) - s->set_bound (RIGHT, unsmob_grob (get_property ("currentMusicalColumn"))); + s->set_bound (RIGHT, unsmob_grob (get_property ("currentMusicalColumn"))); announce_end_grob (s, SCM_EOL); } end_slurs_.clear (); @@ -258,16 +255,16 @@ ADD_ACKNOWLEDGER (Slur_engraver, text_script); ADD_ACKNOWLEDGER (Slur_engraver, tie); ADD_ACKNOWLEDGER (Slur_engraver, tuplet_number); ADD_TRANSLATOR (Slur_engraver, - /* doc */ - "Build slur grobs from slur events.", + /* doc */ + "Build slur grobs from slur events.", - /* create */ - "Slur ", + /* create */ + "Slur ", - /* read */ - "slurMelismaBusy " - "doubleSlurs ", + /* read */ + "slurMelismaBusy " + "doubleSlurs ", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/slur-performer.cc b/lily/slur-performer.cc index bd466fe8c2..bcf537bc45 100644 --- a/lily/slur-performer.cc +++ b/lily/slur-performer.cc @@ -39,7 +39,7 @@ protected: void start_translation_timestep (); void process_music (); void set_melisma (bool); - + DECLARE_TRANSLATOR_LISTENER (slur); private: Stream_event *start_ev_; @@ -96,15 +96,15 @@ Slur_performer::listen_slur (Stream_event *ev) } ADD_TRANSLATOR (Slur_performer, - /* doc */ - "", + /* doc */ + "", - /* create */ - "", + /* create */ + "", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/slur-score-parameters.cc b/lily/slur-score-parameters.cc index 1683aeea2f..00f2d60312 100644 --- a/lily/slur-score-parameters.cc +++ b/lily/slur-score-parameters.cc @@ -18,19 +18,17 @@ along with LilyPond. If not, see <http://www.gnu.org/licenses/>. */ - #include "slur-score-parameters.hh" #include "grob.hh" - Real get_detail (SCM alist, SCM sym) { SCM entry = scm_assq (sym, alist); return robust_scm2double (scm_is_pair (entry) - ? scm_cdr (entry) - : SCM_EOL, - 0.0); + ? scm_cdr (entry) + : SCM_EOL, + 0.0); } void diff --git a/lily/slur-scoring.cc b/lily/slur-scoring.cc index 63160a9917..5413c047c2 100644 --- a/lily/slur-scoring.cc +++ b/lily/slur-scoring.cc @@ -18,7 +18,6 @@ along with LilyPond. If not, see <http://www.gnu.org/licenses/>. */ - #include "slur-scoring.hh" #include <queue> @@ -111,7 +110,7 @@ Slur_score_state::get_encompass_info (Grob *col) const programming_error ("no stem for note column"); ei.x_ = col->relative_coordinate (common_[X_AXIS], X_AXIS); ei.head_ = ei.stem_ = col->extent (common_[Y_AXIS], - Y_AXIS)[dir_]; + Y_AXIS)[dir_]; return ei; } Direction stem_dir = get_grob_direction (stem); @@ -135,12 +134,12 @@ Slur_score_state::get_encompass_info (Grob *col) const { ei.stem_ = stem->extent (common_[Y_AXIS], Y_AXIS)[dir_]; if (Grob *b = Stem::get_beam (stem)) - ei.stem_ += stem_dir * 0.5 * Beam::get_beam_thickness (b); + ei.stem_ += stem_dir * 0.5 * Beam::get_beam_thickness (b); Interval x = stem->extent (common_[X_AXIS], X_AXIS); ei.x_ = x.is_empty () - ? stem->relative_coordinate (common_[X_AXIS], X_AXIS) - : x.center (); + ? stem->relative_coordinate (common_[X_AXIS], X_AXIS) + : x.center (); } else ei.stem_ = ei.head_; @@ -160,45 +159,45 @@ Slur_score_state::get_bound_info () const { extremes[d].bound_ = slur_->get_bound (d); if (Note_column::has_interface (extremes[d].bound_)) - { - extremes[d].note_column_ = extremes[d].bound_; - extremes[d].stem_ = Note_column::get_stem (extremes[d].note_column_); - if (extremes[d].stem_) - { - extremes[d].stem_dir_ = get_grob_direction (extremes[d].stem_); - - for (int a = X_AXIS; a < NO_AXES; a++) - { - Axis ax = Axis (a); - Interval s = extremes[d].stem_->extent (common_[ax], ax); - if (s.is_empty ()) - { - /* - do not issue warning. This happens for rests and - whole notes. - */ - s = Interval (0, 0) - + extremes[d].stem_->relative_coordinate (common_[ax], ax); - } - extremes[d].stem_extent_[ax] = s; - } - - extremes[d].slur_head_ - = Stem::extremal_heads (extremes[d].stem_)[dir]; - if (!extremes[d].slur_head_ - && Note_column::has_rests (extremes[d].bound_)) - extremes[d].slur_head_ = Note_column::get_rest (extremes[d].bound_); - extremes[d].staff_ = Staff_symbol_referencer - ::get_staff_symbol (extremes[d].stem_); - extremes[d].staff_space_ = Staff_symbol_referencer - ::staff_space (extremes[d].stem_); - } - - if (extremes[d].slur_head_) - extremes[d].slur_head_x_extent_ - = extremes[d].slur_head_->extent (common_[X_AXIS], X_AXIS); - - } + { + extremes[d].note_column_ = extremes[d].bound_; + extremes[d].stem_ = Note_column::get_stem (extremes[d].note_column_); + if (extremes[d].stem_) + { + extremes[d].stem_dir_ = get_grob_direction (extremes[d].stem_); + + for (int a = X_AXIS; a < NO_AXES; a++) + { + Axis ax = Axis (a); + Interval s = extremes[d].stem_->extent (common_[ax], ax); + if (s.is_empty ()) + { + /* + do not issue warning. This happens for rests and + whole notes. + */ + s = Interval (0, 0) + + extremes[d].stem_->relative_coordinate (common_[ax], ax); + } + extremes[d].stem_extent_[ax] = s; + } + + extremes[d].slur_head_ + = Stem::extremal_heads (extremes[d].stem_)[dir]; + if (!extremes[d].slur_head_ + && Note_column::has_rests (extremes[d].bound_)) + extremes[d].slur_head_ = Note_column::get_rest (extremes[d].bound_); + extremes[d].staff_ = Staff_symbol_referencer + ::get_staff_symbol (extremes[d].stem_); + extremes[d].staff_space_ = Staff_symbol_referencer + ::staff_space (extremes[d].stem_); + } + + if (extremes[d].slur_head_) + extremes[d].slur_head_x_extent_ + = extremes[d].slur_head_->extent (common_[X_AXIS], X_AXIS); + + } } while (flip (&d) != LEFT); @@ -211,7 +210,7 @@ Slur_score_state::fill (Grob *me) slur_ = dynamic_cast<Spanner *> (me); columns_ = internal_extract_grob_array (me, ly_symbol2scm ("note-columns")); - + if (columns_.empty ()) { me->suicide (); @@ -239,20 +238,20 @@ Slur_score_state::fill (Grob *me) Direction d = LEFT; do - { - /* - If bound is not in note-columns, we don't want to know about - its Y-position - */ - if (a != Y_AXIS) - common_[a] = common_[a]->common_refpoint (sp->get_bound (d), a); - } + { + /* + If bound is not in note-columns, we don't want to know about + its Y-position + */ + if (a != Y_AXIS) + common_[a] = common_[a]->common_refpoint (sp->get_bound (d), a); + } while (flip (&d) != LEFT); } extremes_ = get_bound_info (); is_broken_ = (!extremes_[LEFT].note_column_ - || !extremes_[RIGHT].note_column_); + || !extremes_[RIGHT].note_column_); has_same_beam_ = (extremes_[LEFT].stem_ && extremes_[RIGHT].stem_ @@ -275,21 +274,20 @@ Slur_score_state::fill (Grob *me) do { if (!is_broken_ - && extremes_[d].slur_head_) - musical_dy_ += d - * extremes_[d].slur_head_->relative_coordinate (common_[Y_AXIS], Y_AXIS); + && extremes_[d].slur_head_) + musical_dy_ += d + * extremes_[d].slur_head_->relative_coordinate (common_[Y_AXIS], Y_AXIS); } while (flip (&d) != LEFT); edge_has_beams_ = (extremes_[LEFT].stem_ && Stem::get_beam (extremes_[LEFT].stem_)) - || (extremes_[RIGHT].stem_ && Stem::get_beam (extremes_[RIGHT].stem_)); + || (extremes_[RIGHT].stem_ && Stem::get_beam (extremes_[RIGHT].stem_)); if (is_broken_) musical_dy_ = 0.0; } - MAKE_SCHEME_CALLBACK (Slur, calc_control_points, 1) SCM Slur::calc_control_points (SCM smob) @@ -307,17 +305,17 @@ Slur::calc_control_points (SCM smob) SCM end_ys = me->get_property ("positions"); SCM inspect_quants = me->get_property ("inspect-quants"); bool debug_slurs = to_boolean (me->layout () - ->lookup_variable (ly_symbol2scm ("debug-slur-scoring"))); + ->lookup_variable (ly_symbol2scm ("debug-slur-scoring"))); if (is_number_pair (inspect_quants)) { debug_slurs = true; end_ys = inspect_quants; } - + Slur_configuration *best = NULL; if (is_number_pair (end_ys)) - best = state.get_forced_configuration (ly_scm2interval(end_ys)); + best = state.get_forced_configuration (ly_scm2interval (end_ys)); else best = state.get_best_curve (); @@ -325,24 +323,24 @@ Slur::calc_control_points (SCM smob) if (debug_slurs) { string total = best->card (); - total += to_string (" TOTAL=%.2f idx=%d", best->score (), best->index_); + total += to_string (" TOTAL=%.2f idx=%d", best->score (), best->index_); me->set_property ("annotation", ly_string2scm (total)); } #endif - + SCM controls = SCM_EOL; for (int i = 4; i--;) { Offset o = best->curve_.control_[i] - - Offset (me->relative_coordinate (state.common_[X_AXIS], X_AXIS), - me->relative_coordinate (state.common_[Y_AXIS], Y_AXIS)); + - Offset (me->relative_coordinate (state.common_[X_AXIS], X_AXIS), + me->relative_coordinate (state.common_[Y_AXIS], Y_AXIS)); controls = scm_cons (ly_offset2scm (o), controls); } return controls; } -Slur_configuration* +Slur_configuration * Slur_score_state::get_forced_configuration (Interval ys) const { Slur_configuration *best = NULL; @@ -350,42 +348,42 @@ Slur_score_state::get_forced_configuration (Interval ys) const for (vsize i = 0; i < configurations_.size (); i++) { Real d = fabs (configurations_[i]->attachment_[LEFT][Y_AXIS] - ys[LEFT]) - + fabs (configurations_[i]->attachment_[RIGHT][Y_AXIS] - ys[RIGHT]); + + fabs (configurations_[i]->attachment_[RIGHT][Y_AXIS] - ys[RIGHT]); if (d < mindist) - { - best = configurations_[i]; - mindist = d; - } + { + best = configurations_[i]; + mindist = d; + } } while (!best->done ()) best->run_next_scorer (*this); - + if (mindist > 1e5) programming_error ("cannot find quant"); return best; } - Slur_configuration * Slur_score_state::get_best_curve () const { - std::priority_queue<Slur_configuration*, std::vector<Slur_configuration*>, - Slur_configuration_less> queue; + std::priority_queue < Slur_configuration *, std::vector<Slur_configuration *>, + Slur_configuration_less > queue; for (vsize i = 0; i < configurations_.size (); i++) queue.push (configurations_[i]); Slur_configuration *best = NULL; - while (true) { - best = queue.top (); - if (best->done ()) - break; - - queue.pop (); - best->run_next_scorer (*this); - queue.push (best); - } + while (true) + { + best = queue.top (); + if (best->done ()) + break; + + queue.pop (); + best->run_next_scorer (*this); + queue.push (best); + } return best; } @@ -399,9 +397,9 @@ Slur_score_state::breakable_bound_item (Direction d) const for (vsize i = 0; i < extra_encompasses.size (); i++) { - Item *item = dynamic_cast<Item*> (extra_encompasses[i]); + Item *item = dynamic_cast<Item *> (extra_encompasses[i]); if (item && col == item->get_column ()) - return item; + return item; } return 0; @@ -420,15 +418,15 @@ Slur_score_state::get_y_attachment_range () const do { if (extremes_[d].note_column_) - { - end_ys[d] = dir_ - * max (max (dir_ * (base_attachments_[d][Y_AXIS] - + parameters_.region_size_ * dir_), - dir_ * (dir_ + extremes_[d].note_column_->extent (common_[Y_AXIS], Y_AXIS)[dir_])), - dir_ * base_attachments_[-d][Y_AXIS]); - } + { + end_ys[d] = dir_ + * max (max (dir_ * (base_attachments_[d][Y_AXIS] + + parameters_.region_size_ * dir_), + dir_ * (dir_ + extremes_[d].note_column_->extent (common_[Y_AXIS], Y_AXIS)[dir_])), + dir_ * base_attachments_[-d][Y_AXIS]); + } else - end_ys[d] = base_attachments_[d][Y_AXIS] + parameters_.region_size_ * dir_; + end_ys[d] = base_attachments_[d][Y_AXIS] + parameters_.region_size_ * dir_; } while (flip (&d) != LEFT); @@ -448,7 +446,7 @@ spanner_less (Spanner *s1, Spanner *s2) while (flip (&d) != LEFT); return b2[LEFT] <= b1[LEFT] && b2[RIGHT] >= b1[RIGHT] - && (b2[LEFT] != b1[LEFT] || b2[RIGHT] != b1[RIGHT]); + && (b2[LEFT] != b1[LEFT] || b2[RIGHT] != b1[RIGHT]); } Drul_array<Offset> @@ -464,31 +462,31 @@ Slur_score_state::get_base_attachments () const Real x = 0.0; Real y = 0.0; if (extremes_[d].note_column_) - { - - /* - fixme: X coord should also be set in this case. - */ - if (stem - && !Stem::is_invisible (stem) - && extremes_[d].stem_dir_ == dir_ - && Stem::get_beaming (stem, -d) - && Stem::get_beam (stem) - && (!spanner_less (slur_, Stem::get_beam (stem)) - || has_same_beam_)) - y = extremes_[d].stem_extent_[Y_AXIS][dir_]; - else if (head) - y = head->extent (common_[Y_AXIS], Y_AXIS)[dir_]; - y += dir_ * 0.5 * staff_space_; - - y = move_away_from_staffline (y, head); - - Grob *fh = Note_column::first_head (extremes_[d].note_column_); - x - = (fh ? fh->extent (common_[X_AXIS], X_AXIS) - : extremes_[d].bound_->extent (common_[X_AXIS], X_AXIS)) - .linear_combination (CENTER); - } + { + + /* + fixme: X coord should also be set in this case. + */ + if (stem + && !Stem::is_invisible (stem) + && extremes_[d].stem_dir_ == dir_ + && Stem::get_beaming (stem, -d) + && Stem::get_beam (stem) + && (!spanner_less (slur_, Stem::get_beam (stem)) + || has_same_beam_)) + y = extremes_[d].stem_extent_[Y_AXIS][dir_]; + else if (head) + y = head->extent (common_[Y_AXIS], Y_AXIS)[dir_]; + y += dir_ * 0.5 * staff_space_; + + y = move_away_from_staffline (y, head); + + Grob *fh = Note_column::first_head (extremes_[d].note_column_); + x + = (fh ? fh->extent (common_[X_AXIS], X_AXIS) + : extremes_[d].bound_->extent (common_[X_AXIS], X_AXIS)) + .linear_combination (CENTER); + } base_attachment[d] = Offset (x, y); } while (flip (&d) != LEFT); @@ -496,53 +494,53 @@ Slur_score_state::get_base_attachments () const do { if (!extremes_[d].note_column_) - { - Real x = 0; - Real y = 0; - - if (Grob *g = breakable_bound_item (d)) - { - x = robust_relative_extent (g, common_[X_AXIS], X_AXIS)[RIGHT]; - } - else if (d == RIGHT) - x = robust_relative_extent (extremes_[d].bound_, common_[X_AXIS], X_AXIS)[d]; - else - x = slur_->get_broken_left_end_align (); - - Grob *col = (d == LEFT) ? columns_[0] : columns_.back (); - - if (extremes_[-d].bound_ != col) - { - y = robust_relative_extent (col, common_[Y_AXIS], Y_AXIS)[dir_]; - y += dir_ * 0.5 * staff_space_; - - if (get_grob_direction (col) == dir_ - && Note_column::get_stem (col) - && !Stem::is_invisible (Note_column::get_stem (col))) - y -= dir_ * 1.5 * staff_space_; - } - else - y = base_attachment[-d][Y_AXIS]; - - y = move_away_from_staffline (y, col); - - base_attachment[d] = Offset (x, y); - } + { + Real x = 0; + Real y = 0; + + if (Grob *g = breakable_bound_item (d)) + { + x = robust_relative_extent (g, common_[X_AXIS], X_AXIS)[RIGHT]; + } + else if (d == RIGHT) + x = robust_relative_extent (extremes_[d].bound_, common_[X_AXIS], X_AXIS)[d]; + else + x = slur_->get_broken_left_end_align (); + + Grob *col = (d == LEFT) ? columns_[0] : columns_.back (); + + if (extremes_[-d].bound_ != col) + { + y = robust_relative_extent (col, common_[Y_AXIS], Y_AXIS)[dir_]; + y += dir_ * 0.5 * staff_space_; + + if (get_grob_direction (col) == dir_ + && Note_column::get_stem (col) + && !Stem::is_invisible (Note_column::get_stem (col))) + y -= dir_ * 1.5 * staff_space_; + } + else + y = base_attachment[-d][Y_AXIS]; + + y = move_away_from_staffline (y, col); + + base_attachment[d] = Offset (x, y); + } } while (flip (&d) != LEFT); do { for (int a = X_AXIS; a < NO_AXES; a++) - { - Real &b = base_attachment[d][Axis (a)]; - - if (isinf (b) || isnan (b)) - { - programming_error ("slur attachment is inf/nan"); - b = 0.0; - } - } + { + Real &b = base_attachment[d][Axis (a)]; + + if (isinf (b) || isnan (b)) + { + programming_error ("slur attachment is inf/nan"); + b = 0.0; + } + } } while (flip (&d) != LEFT); @@ -551,19 +549,19 @@ Slur_score_state::get_base_attachments () const Real Slur_score_state::move_away_from_staffline (Real y, - Grob *on_staff) const + Grob *on_staff) const { if (!on_staff) return y; - + Grob *staff_symbol = Staff_symbol_referencer::get_staff_symbol (on_staff); if (!staff_symbol) return y; Real pos = (y - staff_symbol->relative_coordinate (common_[Y_AXIS], - Y_AXIS)) - * 2.0 / staff_space_; + Y_AXIS)) + * 2.0 / staff_space_; if (fabs (pos - my_round (pos)) < 0.2 && Staff_symbol_referencer::on_line (on_staff, (int) rint (pos)) @@ -577,13 +575,13 @@ vector<Offset> Slur_score_state::generate_avoid_offsets () const { vector<Offset> avoid; - vector<Grob*> encompasses = columns_; + vector<Grob *> encompasses = columns_; for (vsize i = 0; i < encompasses.size (); i++) { if (extremes_[LEFT].note_column_ == encompasses[i] - || extremes_[RIGHT].note_column_ == encompasses[i]) - continue; + || extremes_[RIGHT].note_column_ == encompasses[i]) + continue; Encompass_info inf (get_encompass_info (encompasses[i])); Real y = dir_ * (max (dir_ * inf.head_, dir_ * inf.stem_)); @@ -595,28 +593,28 @@ Slur_score_state::generate_avoid_offsets () const for (vsize i = 0; i < extra_encompasses.size (); i++) { if (Slur::has_interface (extra_encompasses[i])) - { - Grob *small_slur = extra_encompasses[i]; - Bezier b = Slur::get_curve (small_slur); + { + Grob *small_slur = extra_encompasses[i]; + Bezier b = Slur::get_curve (small_slur); - Offset z = b.curve_point (0.5); - z += Offset (small_slur->relative_coordinate (common_[X_AXIS], X_AXIS), - small_slur->relative_coordinate (common_[Y_AXIS], Y_AXIS)); + Offset z = b.curve_point (0.5); + z += Offset (small_slur->relative_coordinate (common_[X_AXIS], X_AXIS), + small_slur->relative_coordinate (common_[Y_AXIS], Y_AXIS)); - z[Y_AXIS] += dir_ * parameters_.free_slur_distance_; - avoid.push_back (z); - } + z[Y_AXIS] += dir_ * parameters_.free_slur_distance_; + avoid.push_back (z); + } else if (extra_encompasses[i]->get_property ("avoid-slur") == ly_symbol2scm ("inside")) - { - Grob *g = extra_encompasses [i]; - Interval xe = g->extent (common_[X_AXIS], X_AXIS); - Interval ye = g->extent (common_[Y_AXIS], Y_AXIS); - - if (!xe.is_empty () - && !ye.is_empty ()) - avoid.push_back (Offset (xe.center (), ye[dir_])); - } - } + { + Grob *g = extra_encompasses [i]; + Interval xe = g->extent (common_[X_AXIS], X_AXIS); + Interval ye = g->extent (common_[Y_AXIS], Y_AXIS); + + if (!xe.is_empty () + && !ye.is_empty ()) + avoid.push_back (Offset (xe.center (), ye[dir_])); + } + } return avoid; } @@ -631,85 +629,85 @@ Slur_score_state::generate_curves () const configurations_[i]->generate_curve (*this, r_0, h_inf, avoid); } -vector<Slur_configuration*> +vector<Slur_configuration *> Slur_score_state::enumerate_attachments (Drul_array<Real> end_ys) const { - vector<Slur_configuration*> scores; + vector<Slur_configuration *> scores; Drul_array<Offset> os; os[LEFT] = base_attachments_[LEFT]; Real minimum_length = staff_space_ - * robust_scm2double (slur_->get_property ("minimum-length"), 2.0); + * robust_scm2double (slur_->get_property ("minimum-length"), 2.0); for (int i = 0; dir_ * os[LEFT][Y_AXIS] <= dir_ * end_ys[LEFT]; i++) { os[RIGHT] = base_attachments_[RIGHT]; for (int j = 0; dir_ * os[RIGHT][Y_AXIS] <= dir_ * end_ys[RIGHT]; j++) - { - Direction d = LEFT; - Drul_array<bool> attach_to_stem (false, false); - do - { - os[d][X_AXIS] = base_attachments_[d][X_AXIS]; - if (extremes_[d].stem_ - && !Stem::is_invisible (extremes_[d].stem_) - && extremes_[d].stem_dir_ == dir_) - { - Interval stem_y = extremes_[d].stem_extent_[Y_AXIS]; - stem_y.widen (0.25 * staff_space_); - if (stem_y.contains (os[d][Y_AXIS])) - { - os[d][X_AXIS] = extremes_[d].stem_extent_[X_AXIS][-d] - - d * 0.3; - attach_to_stem[d] = true; - } - else if (dir_ * extremes_[d].stem_extent_[Y_AXIS][dir_] - < dir_ * os[d][Y_AXIS] - && !extremes_[d].stem_extent_[X_AXIS].is_empty ()) - - os[d][X_AXIS] = extremes_[d].stem_extent_[X_AXIS].center (); - } - } - while (flip (&d) != LEFT); - - Offset dz; - dz = os[RIGHT] - os[LEFT]; - if (dz[X_AXIS] < minimum_length - || fabs (dz[Y_AXIS] / dz[X_AXIS]) > parameters_.max_slope_) - { - do - { - if (extremes_[d].slur_head_ - && !extremes_[d].slur_head_x_extent_.is_empty ()) - { - os[d][X_AXIS] = extremes_[d].slur_head_x_extent_.center (); - attach_to_stem[d] = false; - } - } - while (flip (&d) != LEFT); - } - - dz = os[RIGHT] - os[LEFT]; - do - { - if (extremes_[d].slur_head_ - && !attach_to_stem[d]) - { - /* Horizontally move tilted slurs a little. Move - more for bigger tilts. - - TODO: parameter */ - os[d][X_AXIS] - -= dir_ * extremes_[d].slur_head_x_extent_.length () - * sin (dz.arg ()) / 3; - } - } - while (flip (&d) != LEFT); - - scores.push_back (Slur_configuration::new_config (os, scores.size ())); - - os[RIGHT][Y_AXIS] += dir_ * staff_space_ / 2; - } + { + Direction d = LEFT; + Drul_array<bool> attach_to_stem (false, false); + do + { + os[d][X_AXIS] = base_attachments_[d][X_AXIS]; + if (extremes_[d].stem_ + && !Stem::is_invisible (extremes_[d].stem_) + && extremes_[d].stem_dir_ == dir_) + { + Interval stem_y = extremes_[d].stem_extent_[Y_AXIS]; + stem_y.widen (0.25 * staff_space_); + if (stem_y.contains (os[d][Y_AXIS])) + { + os[d][X_AXIS] = extremes_[d].stem_extent_[X_AXIS][-d] + - d * 0.3; + attach_to_stem[d] = true; + } + else if (dir_ * extremes_[d].stem_extent_[Y_AXIS][dir_] + < dir_ * os[d][Y_AXIS] + && !extremes_[d].stem_extent_[X_AXIS].is_empty ()) + + os[d][X_AXIS] = extremes_[d].stem_extent_[X_AXIS].center (); + } + } + while (flip (&d) != LEFT); + + Offset dz; + dz = os[RIGHT] - os[LEFT]; + if (dz[X_AXIS] < minimum_length + || fabs (dz[Y_AXIS] / dz[X_AXIS]) > parameters_.max_slope_) + { + do + { + if (extremes_[d].slur_head_ + && !extremes_[d].slur_head_x_extent_.is_empty ()) + { + os[d][X_AXIS] = extremes_[d].slur_head_x_extent_.center (); + attach_to_stem[d] = false; + } + } + while (flip (&d) != LEFT); + } + + dz = os[RIGHT] - os[LEFT]; + do + { + if (extremes_[d].slur_head_ + && !attach_to_stem[d]) + { + /* Horizontally move tilted slurs a little. Move + more for bigger tilts. + + TODO: parameter */ + os[d][X_AXIS] + -= dir_ * extremes_[d].slur_head_x_extent_.length () + * sin (dz.arg ()) / 3; + } + } + while (flip (&d) != LEFT); + + scores.push_back (Slur_configuration::new_config (os, scores.size ())); + + os[RIGHT][Y_AXIS] += dir_ * staff_space_ / 2; + } os[LEFT][Y_AXIS] += dir_ * staff_space_ / 2; } @@ -726,80 +724,80 @@ Slur_score_state::get_extra_encompass_infos () const for (vsize i = encompasses.size (); i--;) { if (Slur::has_interface (encompasses[i])) - { - Spanner *small_slur = dynamic_cast<Spanner *> (encompasses[i]); - Bezier b = Slur::get_curve (small_slur); - - Offset relative (small_slur->relative_coordinate (common_[X_AXIS], X_AXIS), - small_slur->relative_coordinate (common_[Y_AXIS], Y_AXIS)); - - for (int k = 0; k < 3; k++) - { - Direction hdir = Direction (k - 1); - - /* - Only take bound into account if small slur starts - together with big slur. - */ - if (hdir && small_slur->get_bound (hdir) != slur_->get_bound (hdir)) - continue; - - Offset z = b.curve_point (k / 2.0); - z += relative; - - Interval yext; - yext.set_full (); - yext[dir_] = z[Y_AXIS] + dir_ * thickness_ * 1.0; - - Interval xext (-1, 1); - xext = xext * (thickness_ * 2) + z[X_AXIS]; - Extra_collision_info info (small_slur, - hdir, - xext, - yext, - parameters_.extra_object_collision_penalty_); - collision_infos.push_back (info); - } - } + { + Spanner *small_slur = dynamic_cast<Spanner *> (encompasses[i]); + Bezier b = Slur::get_curve (small_slur); + + Offset relative (small_slur->relative_coordinate (common_[X_AXIS], X_AXIS), + small_slur->relative_coordinate (common_[Y_AXIS], Y_AXIS)); + + for (int k = 0; k < 3; k++) + { + Direction hdir = Direction (k - 1); + + /* + Only take bound into account if small slur starts + together with big slur. + */ + if (hdir && small_slur->get_bound (hdir) != slur_->get_bound (hdir)) + continue; + + Offset z = b.curve_point (k / 2.0); + z += relative; + + Interval yext; + yext.set_full (); + yext[dir_] = z[Y_AXIS] + dir_ * thickness_ * 1.0; + + Interval xext (-1, 1); + xext = xext * (thickness_ * 2) + z[X_AXIS]; + Extra_collision_info info (small_slur, + hdir, + xext, + yext, + parameters_.extra_object_collision_penalty_); + collision_infos.push_back (info); + } + } else - { - Grob *g = encompasses [i]; - Interval xe = g->extent (common_[X_AXIS], X_AXIS); - Interval ye = g->extent (common_[Y_AXIS], Y_AXIS); - - Real xp = 0.0; - Real penalty = parameters_.extra_object_collision_penalty_; - if (Accidental_interface::has_interface (g)) - { - penalty = parameters_.accidental_collision_; - - Rational alt = ly_scm2rational (g->get_property ("alteration")); - SCM scm_style = g->get_property ("style"); - if (!scm_is_symbol (scm_style) - && !to_boolean (g->get_property ("parenthesized")) - && !to_boolean (g->get_property ("restore-first"))) - { - /* End copy accidental.cc */ - if (alt == FLAT_ALTERATION - || alt == DOUBLE_FLAT_ALTERATION) - xp = LEFT; - else if (alt == SHARP_ALTERATION) - xp = 0.5 * dir_; - else if (alt == NATURAL_ALTERATION) - xp = -dir_; - } - } - - ye.widen (thickness_ * 0.5); - xe.widen (thickness_ * 1.0); - Extra_collision_info info (g, xp, xe, ye, penalty); - collision_infos.push_back (info); - } + { + Grob *g = encompasses [i]; + Interval xe = g->extent (common_[X_AXIS], X_AXIS); + Interval ye = g->extent (common_[Y_AXIS], Y_AXIS); + + Real xp = 0.0; + Real penalty = parameters_.extra_object_collision_penalty_; + if (Accidental_interface::has_interface (g)) + { + penalty = parameters_.accidental_collision_; + + Rational alt = ly_scm2rational (g->get_property ("alteration")); + SCM scm_style = g->get_property ("style"); + if (!scm_is_symbol (scm_style) + && !to_boolean (g->get_property ("parenthesized")) + && !to_boolean (g->get_property ("restore-first"))) + { + /* End copy accidental.cc */ + if (alt == FLAT_ALTERATION + || alt == DOUBLE_FLAT_ALTERATION) + xp = LEFT; + else if (alt == SHARP_ALTERATION) + xp = 0.5 * dir_; + else if (alt == NATURAL_ALTERATION) + xp = -dir_; + } + } + + ye.widen (thickness_ * 0.5); + xe.widen (thickness_ * 1.0); + Extra_collision_info info (g, xp, xe, ye, penalty); + collision_infos.push_back (info); + } } return collision_infos; } - + Extra_collision_info::Extra_collision_info (Grob *g, Real idx, Interval x, Interval y, Real p) { idx_ = idx; @@ -815,5 +813,5 @@ Extra_collision_info::Extra_collision_info () idx_ = 0.0; penalty_ = 0.; grob_ = 0; - type_ = SCM_EOL; + type_ = SCM_EOL; } diff --git a/lily/slur.cc b/lily/slur.cc index 433406c92a..32149e8412 100644 --- a/lily/slur.cc +++ b/lily/slur.cc @@ -28,7 +28,7 @@ #include "item.hh" #include "pointer-group-interface.hh" #include "lookup.hh" -#include "main.hh" // DEBUG_SLUR_SCORING +#include "main.hh" // DEBUG_SLUR_SCORING #include "note-column.hh" #include "output-def.hh" #include "spanner.hh" @@ -41,8 +41,6 @@ #include "separation-item.hh" #include "international.hh" - - MAKE_SCHEME_CALLBACK (Slur, calc_direction, 1) SCM Slur::calc_direction (SCM smob) @@ -60,10 +58,10 @@ Slur::calc_direction (SCM smob) for (vsize i = 0; i < encompasses.size (); i++) { if (Note_column::dir (encompasses[i]) < 0) - { - d = UP; - break; - } + { + d = UP; + break; + } } return scm_from_int (d); } @@ -90,7 +88,7 @@ Slur::pure_height (SCM smob, SCM start_scm, SCM end_scm) { Interval d = encompasses[i]->pure_height (parent, start, end); if (!d.is_empty ()) - ret.unite (d); + ret.unite (d); } // The +0.5 comes from the fact that we try to place a slur @@ -109,7 +107,7 @@ Slur::height (SCM smob) // FIXME uncached Stencil *m = me->get_stencil (); return m ? ly_interval2scm (m->extent (Y_AXIS)) - : ly_interval2scm (Interval ()); + : ly_interval2scm (Interval ()); } MAKE_SCHEME_CALLBACK (Slur, print, 1); @@ -126,9 +124,9 @@ Slur::print (SCM smob) Real staff_thick = Staff_symbol_referencer::line_thickness (me); Real base_thick = staff_thick - * robust_scm2double (me->get_property ("thickness"), 1); + * robust_scm2double (me->get_property ("thickness"), 1); Real line_thick = staff_thick - * robust_scm2double (me->get_property ("line-thickness"), 1); + * robust_scm2double (me->get_property ("line-thickness"), 1); Bezier one = get_curve (me); Stencil a; @@ -136,7 +134,7 @@ Slur::print (SCM smob) SCM dash_definition = me->get_property ("dash-definition"); a = Lookup::slur (one, get_grob_direction (me) * base_thick, - line_thick, + line_thick, dash_definition); #if DEBUG_SLUR_SCORING @@ -147,12 +145,12 @@ Slur::print (SCM smob) SCM properties = Font_interface::text_font_alist_chain (me); if (!scm_is_number (me->get_property ("font-size"))) - properties = scm_cons (scm_acons (ly_symbol2scm ("font-size"), scm_from_int (-6), SCM_EOL), - properties); - + properties = scm_cons (scm_acons (ly_symbol2scm ("font-size"), scm_from_int (-6), SCM_EOL), + properties); + Stencil tm = *unsmob_stencil (Text_interface::interpret_markup - (me->layout ()->self_scm (), properties, - annotation)); + (me->layout ()->self_scm (), properties, + annotation)); a.add_at_edge (Y_AXIS, get_grob_direction (me), tm, 1.0); } #endif @@ -160,7 +158,6 @@ Slur::print (SCM smob) return a.smobbed_copy (); } - /* it would be better to do this at engraver level, but that is fragile, as the breakable items are generated on staff level, at @@ -175,26 +172,26 @@ Slur::replace_breakable_encompass_objects (Grob *me) for (vsize i = 0; i < extra_objects.size (); i++) { Grob *g = extra_objects[i]; - + if (Separation_item::has_interface (g)) - { - extract_grob_set (g, "elements", breakables); - for (vsize j = 0; j < breakables.size (); j++) - /* if we encompass a separation-item that spans multiple staves, - we filter out the grobs that don't belong to our staff */ - if (me->common_refpoint (breakables[j], Y_AXIS) == me->get_parent (Y_AXIS) - && breakables[j]->get_property ("avoid-slur") == ly_symbol2scm ("inside")) - new_encompasses.push_back (breakables[j]); - } + { + extract_grob_set (g, "elements", breakables); + for (vsize j = 0; j < breakables.size (); j++) + /* if we encompass a separation-item that spans multiple staves, + we filter out the grobs that don't belong to our staff */ + if (me->common_refpoint (breakables[j], Y_AXIS) == me->get_parent (Y_AXIS) + && breakables[j]->get_property ("avoid-slur") == ly_symbol2scm ("inside")) + new_encompasses.push_back (breakables[j]); + } else - new_encompasses.push_back (g); + new_encompasses.push_back (g); } SCM encompass_scm = me->get_object ("encompass-objects"); if (Grob_array::unsmob (encompass_scm)) { - vector<Grob *> &arr = - unsmob_grob_array (encompass_scm)->array_reference (); + vector<Grob *> &arr + = unsmob_grob_array (encompass_scm)->array_reference (); arr = new_encompasses; } } @@ -249,7 +246,7 @@ SCM Slur::outside_slur_callback (SCM grob, SCM offset_scm) { Grob *script = unsmob_grob (grob); - Grob *slur = unsmob_grob (script->get_object ("slur")); + Grob *slur = unsmob_grob (script->get_object ("slur")); if (!slur) return offset_scm; @@ -258,7 +255,7 @@ Slur::outside_slur_callback (SCM grob, SCM offset_scm) if (avoid != ly_symbol2scm ("outside") && avoid != ly_symbol2scm ("around")) return offset_scm; - + Direction dir = get_grob_direction (script); if (dir == CENTER) return offset_scm; @@ -269,17 +266,17 @@ Slur::outside_slur_callback (SCM grob, SCM offset_scm) Bezier curve = Slur::get_curve (slur); curve.translate (Offset (slur->relative_coordinate (cx, X_AXIS), - slur->relative_coordinate (cy, Y_AXIS))); + slur->relative_coordinate (cy, Y_AXIS))); Interval yext = robust_relative_extent (script, cy, Y_AXIS); Interval xext = robust_relative_extent (script, cx, X_AXIS); Real offset = robust_scm2double (offset_scm, 0); yext.translate (offset); - + /* FIXME: slur property, script property? */ Real slur_padding = robust_scm2double (script->get_property ("slur-padding"), - 0.0); + 0.0); yext.widen (slur_padding); const Real EPS = 1e-3; @@ -287,36 +284,36 @@ Slur::outside_slur_callback (SCM grob, SCM offset_scm) bool consider[] = {false, false, false}; Real ys[] = {0, 0, 0}; bool do_shift = false; - + for (int d = LEFT, k = 0; d <= RIGHT; d++, k++) { Real x = xext.linear_combination ((Direction) d); consider[k] = bezext.contains (x); if (consider[k]) - { - ys[k] - = (fabs (bezext[LEFT] - x) < EPS) - ? curve.control_[0][Y_AXIS] - : ((fabs (bezext[RIGHT] - x) < EPS) - ? curve.control_[3][Y_AXIS] - : curve.get_other_coordinate (X_AXIS, x)); - - /* Request shift if slur is contained script's Y, or if - script is inside slur and avoid == outside. */ - if (yext.contains (ys[k]) - || (dir * ys[k] > dir * yext[-dir] && avoid == ly_symbol2scm ("outside"))) - do_shift = true; - } + { + ys[k] + = (fabs (bezext[LEFT] - x) < EPS) + ? curve.control_[0][Y_AXIS] + : ((fabs (bezext[RIGHT] - x) < EPS) + ? curve.control_[3][Y_AXIS] + : curve.get_other_coordinate (X_AXIS, x)); + + /* Request shift if slur is contained script's Y, or if + script is inside slur and avoid == outside. */ + if (yext.contains (ys[k]) + || (dir * ys[k] > dir * yext[-dir] && avoid == ly_symbol2scm ("outside"))) + do_shift = true; + } } Real avoidance_offset = 0.0; if (do_shift) { for (int d = LEFT, k = 0; d <= RIGHT; d++, k++) - if (consider[k]) - avoidance_offset = dir * (max (dir * avoidance_offset, - dir * (ys[k] - yext[-dir] + dir * slur_padding))); + if (consider[k]) + avoidance_offset = dir * (max (dir * avoidance_offset, + dir * (ys[k] - yext[-dir] + dir * slur_padding))); } return scm_from_double (offset + avoidance_offset); } @@ -326,41 +323,41 @@ Slur::outside_slur_callback (SCM grob, SCM offset_scm) */ void Slur::auxiliary_acknowledge_extra_object (Grob_info const &info, - vector<Grob*> &slurs, - vector<Grob*> &end_slurs) + vector<Grob *> &slurs, + vector<Grob *> &end_slurs) { if (slurs.empty () && end_slurs.empty ()) return; - + Grob *e = info.grob (); SCM avoid = e->get_property ("avoid-slur"); if (Tie::has_interface (e) || avoid == ly_symbol2scm ("inside")) { for (vsize i = slurs.size (); i--;) - add_extra_encompass (slurs[i], e); + add_extra_encompass (slurs[i], e); for (vsize i = end_slurs.size (); i--;) - add_extra_encompass (end_slurs[i], e); + add_extra_encompass (end_slurs[i], e); } else if (avoid == ly_symbol2scm ("outside") - || avoid == ly_symbol2scm ("around")) + || avoid == ly_symbol2scm ("around")) { Grob *slur; if (end_slurs.size () && !slurs.size ()) - slur = end_slurs[0]; + slur = end_slurs[0]; else - slur = slurs[0]; + slur = slurs[0]; if (slur) - { - chain_offset_callback (e, outside_slur_callback_proc, Y_AXIS); - chain_callback (e, outside_slur_cross_staff_proc, ly_symbol2scm("cross-staff")); - e->set_object ("slur", slur->self_scm ()); - } + { + chain_offset_callback (e, outside_slur_callback_proc, Y_AXIS); + chain_callback (e, outside_slur_cross_staff_proc, ly_symbol2scm ("cross-staff")); + e->set_object ("slur", slur->self_scm ()); + } } else if (avoid != ly_symbol2scm ("ignore")) e->warning (_f ("Ignoring grob for slur: %s. avoid-slur not set?", - e->name().c_str ())); + e->name ().c_str ())); } /* @@ -396,13 +393,13 @@ Slur::calc_cross_staff (SCM smob) for (vsize i = 0; i < cols.size (); i++) { if (Grob *s = Note_column::get_stem (cols[i])) - if (to_boolean (s->get_property ("cross-staff"))) - return SCM_BOOL_T; + if (to_boolean (s->get_property ("cross-staff"))) + return SCM_BOOL_T; } /* the separation items are dealt with in replace_breakable_encompass_objects so we can ignore them here */ - vector<Grob*> non_sep_extras; + vector<Grob *> non_sep_extras; for (vsize i = 0; i < extras.size (); i++) if (!Separation_item::has_interface (extras[i])) non_sep_extras.push_back (extras[i]); @@ -414,90 +411,90 @@ Slur::calc_cross_staff (SCM smob) } ADD_INTERFACE (Slur, - "A slur." - "\n" - "The following properties may be set in the @code{details}" - " list.\n" - "\n" - "@table @code\n" - "@item region-size\n" - "Size of region (in staff spaces) for determining" - " potential endpoints in the Y direction.\n" - "@item head-encompass-penalty\n" - "Demerit to apply when note heads collide with a slur.\n" - "@item stem-encompass-penalty\n" - "Demerit to apply when stems collide with a slur.\n" - "@item closeness-factor\n" - "Additional demerit used when scoring encompasses.\n" - "@item edge-attraction-factor\n" - "Factor used to calculate the demerit for distances" - " between slur endpoints and their corresponding base" - " attachments.\n" - "@item same-slope-penalty\n" - "Demerit for slurs with attachment points that are" - " horizontally aligned.\n" - "@item steeper-slope-factor\n" - "Factor used to calculate demerit only if this slur is" - " not broken.\n" - "@item non-horizontal-penalty\n" - "Demerit for slurs with attachment points that are not" - " horizontally aligned.\n" - "@item max-slope\n" - "The maximum slope allowed for this slur.\n" - "@item max-slope-factor\n" - "Factor that calculates demerit based on the max slope.\n" - "@item free-head-distance\n" - "The amount of vertical free space that must exist" - " between a slur and note heads.\n" - "@item absolute-closeness-measure\n" - "Factor to calculate demerit for variance between a note" - " head and slur.\n" - "@item extra-object-collision-penalty\n" - "Factor to calculate demerit for extra objects that the" - " slur encompasses, including accidentals, fingerings, and" - " tuplet numbers.\n" - "@item accidental-collision\n" - "Factor to calculate demerit for @code{Accidental} objects" - " that the slur encompasses. This property value replaces" - " the value of @code{extra-object-collision-penalty}.\n" - "@item extra-encompass-free-distance\n" - "The amount of vertical free space that must exist" - " between a slur and various objects it encompasses," - " including accidentals, fingerings, and tuplet numbers.\n" - "@item extra-encompass-collision-distance\n" - "This detail is currently unused.\n" - "@item head-slur-distance-factor\n" - "Factor to calculate demerit for variance between a note" - " head and slur.\n" - "@item head-slur-distance-max-ratio\n" - "The maximum value for the ratio of distance between a" - " note head and slur.\n" - "@item free-slur-distance\n" - "The amount of vertical free space that must exist" - " between adjacent slurs. This subproperty only works" - " for @code{PhrasingSlur}.\n" - "@item edge-slope-exponent\n" - "Factor used to calculate the demerit for the slope of" - " a slur near its endpoints; a larger value yields a" - " larger demerit.\n" - "@end table\n", - - /* properties */ - "annotation " - "avoid-slur " /* UGH. */ - "control-points " + "A slur." + "\n" + "The following properties may be set in the @code{details}" + " list.\n" + "\n" + "@table @code\n" + "@item region-size\n" + "Size of region (in staff spaces) for determining" + " potential endpoints in the Y direction.\n" + "@item head-encompass-penalty\n" + "Demerit to apply when note heads collide with a slur.\n" + "@item stem-encompass-penalty\n" + "Demerit to apply when stems collide with a slur.\n" + "@item closeness-factor\n" + "Additional demerit used when scoring encompasses.\n" + "@item edge-attraction-factor\n" + "Factor used to calculate the demerit for distances" + " between slur endpoints and their corresponding base" + " attachments.\n" + "@item same-slope-penalty\n" + "Demerit for slurs with attachment points that are" + " horizontally aligned.\n" + "@item steeper-slope-factor\n" + "Factor used to calculate demerit only if this slur is" + " not broken.\n" + "@item non-horizontal-penalty\n" + "Demerit for slurs with attachment points that are not" + " horizontally aligned.\n" + "@item max-slope\n" + "The maximum slope allowed for this slur.\n" + "@item max-slope-factor\n" + "Factor that calculates demerit based on the max slope.\n" + "@item free-head-distance\n" + "The amount of vertical free space that must exist" + " between a slur and note heads.\n" + "@item absolute-closeness-measure\n" + "Factor to calculate demerit for variance between a note" + " head and slur.\n" + "@item extra-object-collision-penalty\n" + "Factor to calculate demerit for extra objects that the" + " slur encompasses, including accidentals, fingerings, and" + " tuplet numbers.\n" + "@item accidental-collision\n" + "Factor to calculate demerit for @code{Accidental} objects" + " that the slur encompasses. This property value replaces" + " the value of @code{extra-object-collision-penalty}.\n" + "@item extra-encompass-free-distance\n" + "The amount of vertical free space that must exist" + " between a slur and various objects it encompasses," + " including accidentals, fingerings, and tuplet numbers.\n" + "@item extra-encompass-collision-distance\n" + "This detail is currently unused.\n" + "@item head-slur-distance-factor\n" + "Factor to calculate demerit for variance between a note" + " head and slur.\n" + "@item head-slur-distance-max-ratio\n" + "The maximum value for the ratio of distance between a" + " note head and slur.\n" + "@item free-slur-distance\n" + "The amount of vertical free space that must exist" + " between adjacent slurs. This subproperty only works" + " for @code{PhrasingSlur}.\n" + "@item edge-slope-exponent\n" + "Factor used to calculate the demerit for the slope of" + " a slur near its endpoints; a larger value yields a" + " larger demerit.\n" + "@end table\n", + + /* properties */ + "annotation " + "avoid-slur " /* UGH. */ + "control-points " "dash-definition " - "details " - "direction " - "eccentricity " - "encompass-objects " - "height-limit " - "inspect-quants " - "inspect-index " - "line-thickness " - "note-columns " - "positions " - "ratio " - "thickness " - ); + "details " + "direction " + "eccentricity " + "encompass-objects " + "height-limit " + "inspect-quants " + "inspect-index " + "line-thickness " + "note-columns " + "positions " + "ratio " + "thickness " + ); diff --git a/lily/smobs.cc b/lily/smobs.cc index 5544d95d7b..e09fd6035d 100644 --- a/lily/smobs.cc +++ b/lily/smobs.cc @@ -33,12 +33,12 @@ init_smob_protection () ADD_SCM_INIT_FUNC (init_smob_protection, init_smob_protection); LY_DEFINE (ly_smob_protects, "ly:smob-protects", - 0, 0, 0, (), - "Return LilyPond's internal smob protection list.") + 0, 0, 0, (), + "Return LilyPond's internal smob protection list.") { return scm_is_pair (smob_protection_list) - ? scm_cdr (smob_protection_list) - : SCM_EOL; + ? scm_cdr (smob_protection_list) + : SCM_EOL; } void @@ -52,10 +52,10 @@ protect_smob (SCM smob, SCM *prot_cons) } SCM prot = scm_cons (smob, s); scm_set_cdr_x (smob_protection_list, - prot); + prot); *prot_cons = prot; #else - (void) prot_cons; + (void) prot_cons; scm_gc_protect_object (smob); #endif } @@ -64,7 +64,7 @@ void unprotect_smob (SCM smob, SCM *prot_cons) { #if 1 - (void) prot_cons; + (void) prot_cons; scm_gc_unprotect_object (smob); #else SCM next = scm_cdr (*prot_cons); @@ -75,9 +75,9 @@ unprotect_smob (SCM smob, SCM *prot_cons) { scm_set_car_x (*prot_cons, SCM_BOOL_F); while (scm_is_pair (next) - && scm_car (next) == SCM_BOOL_F) + && scm_car (next) == SCM_BOOL_F) - next = scm_cdr (next); + next = scm_cdr (next); scm_set_cdr_x (*prot_cons, next); } diff --git a/lily/source-file.cc b/lily/source-file.cc index b016763558..b42fb7a5b3 100644 --- a/lily/source-file.cc +++ b/lily/source-file.cc @@ -52,7 +52,7 @@ Source_file::load_stdin () } /* - return contents of FILENAME. *Not 0-terminated!* + return contents of FILENAME. *Not 0-terminated!* */ vector<char> gulp_file (string filename, int desired_size) @@ -74,7 +74,7 @@ gulp_file (string filename, int desired_size) if (desired_size > 0) read_count = min (read_count, desired_size); - + rewind (f); char *str = new char[read_count + 1]; @@ -83,7 +83,7 @@ gulp_file (string filename, int desired_size) int bytes_read = fread (str, sizeof (char), read_count, f); if (bytes_read != read_count) warning (_f ("expected to read %d characters, got %d", bytes_read, - read_count)); + read_count)); fclose (f); int filesize = bytes_read; @@ -91,7 +91,7 @@ gulp_file (string filename, int desired_size) cxx_arr.resize (filesize); copy (str, str + filesize, cxx_arr.begin ()); - + delete[] str; return cxx_arr; } @@ -109,14 +109,14 @@ Source_file::init () Source_file::Source_file (string filename, string data) { init (); - + name_ = filename; characters_.resize (data.length ()); copy (data.begin (), data.end (), characters_.begin ()); characters_.push_back (0); - + init_port (); for (vsize i = 0; i < characters_.size (); i++) @@ -127,7 +127,7 @@ Source_file::Source_file (string filename, string data) Source_file::Source_file (string filename_string) { init (); - + name_ = filename_string; if (filename_string == "-") @@ -154,20 +154,19 @@ Source_file::init_port () scm_set_port_filename_x (str_port_, ly_string2scm (name_)); } - istream * Source_file::get_istream () { if (!istream_) { if (length ()) // can-t this be done without such a hack? - istream_ = new istringstream (c_str ()); + istream_ = new istringstream (c_str ()); else - { - istream_ = new istringstream (""); - istream_->setstate (ios::eofbit); - // istream_->set (ios::eofbit); - } + { + istream_ = new istringstream (""); + istream_->setstate (ios::eofbit); + // istream_->set (ios::eofbit); + } } return istream_; } @@ -183,7 +182,7 @@ Source_file::file_line_column_string (char const *context_str0) const get_counts (context_str0, &l, &ch, &col, &offset); return name_string () + ":" + to_string (l) - + ":" + to_string (col); + + ":" + to_string (col); } } @@ -197,9 +196,9 @@ Source_file::quote_input (char const *pos_str0) const get_counts (pos_str0, &l, &ch, &col, &offset); string line = line_string (pos_str0); string context = line.substr (0, offset) - + to_string ('\n') - + to_string (' ', col) - + line.substr (offset, line.length () - offset); + + to_string ('\n') + + to_string (' ', col) + + line.substr (offset, line.length () - offset); return context; } @@ -229,16 +228,16 @@ Source_file::line_slice (char const *pos_str0) const while (begin_str0 > data_str0) if (*--begin_str0 == '\n') { - begin_str0++; - break; + begin_str0++; + break; } char const *end_str0 = pos_str0; while (end_str0 < eof_C_) if (*end_str0++ == '\n') { - end_str0--; - break; + end_str0--; + break; } return Slice (begin_str0 - data_str0, end_str0 - data_str0); @@ -257,13 +256,13 @@ Source_file::line_string (char const *pos_str0) const void Source_file::get_counts (char const *pos_str0, - int *line_number, - int *line_char, - int *column, - int *byte_offset) const + int *line_number, + int *line_char, + int *column, + int *byte_offset) const { *line_number = 0; - + if (!contains (pos_str0)) return; @@ -286,16 +285,16 @@ Source_file::get_counts (char const *pos_str0, size_t thislen = utf8_char_len (*line_chars); if (thislen == 1 && line_chars[0] == '\t') - (*column) = (*column / 8 + 1) * 8; + (*column) = (*column / 8 + 1) * 8; else - (*column)++; + (*column)++; (*line_char)++; /* - To have decent output in UTF-8 aware terminals, - we must keep track of the number of bytes from - the left edge of the terminal. + To have decent output in UTF-8 aware terminals, + we must keep track of the number of bytes from + the left edge of the terminal. */ *byte_offset += thislen; @@ -322,8 +321,8 @@ Source_file::get_line (char const *pos_str0) const /* this will find the '\n' character at the end of our line */ vsize lo = lower_bound (newline_locations_, - pos_str0, - less<char const*> ()); + pos_str0, + less<char const *> ()); /* the return value will be indexed from 1 */ return lo + 1 + line_offset_; @@ -372,7 +371,6 @@ Source_file::mark_smob (SCM smob) return sc->str_port_; } - int Source_file::print_smob (SCM smob, SCM port, scm_print_state *) { diff --git a/lily/sources.cc b/lily/sources.cc index 0b33c92f9e..0379e66d83 100644 --- a/lily/sources.cc +++ b/lily/sources.cc @@ -29,13 +29,11 @@ Sources::Sources () path_ = 0; } - Sources::Sources (Sources const &) { assert (false); } - void Sources::set_path (File_path *f) { @@ -51,27 +49,27 @@ Sources::set_path (File_path *f) working directory. */ Source_file * -Sources::get_file (string file_string, string const& current_dir) -{ +Sources::get_file (string file_string, string const ¤t_dir) +{ if (file_string != "-") { // First, check for a path relative to the directory of the // file currently being parsed. if (current_dir.length () - && file_string.length () - && !File_name (file_string).is_absolute () - && is_file (current_dir + DIRSEP + file_string)) - file_string = current_dir + DIRSEP + file_string; + && file_string.length () + && !File_name (file_string).is_absolute () + && is_file (current_dir + DIRSEP + file_string)) + file_string = current_dir + DIRSEP + file_string; // Otherwise, check the rest of the path. else if (path_) - { - string file_string_o = path_->find (file_string); - if ((file_string_o == "") && (file_string != "")) - return 0; + { + string file_string_o = path_->find (file_string); + if ((file_string_o == "") && (file_string != "")) + return 0; - file_string = file_string_o; - } + file_string = file_string_o; + } } Source_file *f = new Source_file (file_string); diff --git a/lily/spaceable-grob.cc b/lily/spaceable-grob.cc index 268259b088..2bf5ff9fe6 100644 --- a/lily/spaceable-grob.cc +++ b/lily/spaceable-grob.cc @@ -52,11 +52,11 @@ Spaceable_grob::add_rod (Grob *me, Grob *p, Real d) { SCM dist = scm_car (s); if (scm_car (dist) == p->self_scm ()) - { - scm_set_cdr_x (dist, scm_max (scm_cdr (dist), - newdist)); - return; - } + { + scm_set_cdr_x (dist, scm_max (scm_cdr (dist), + newdist)); + return; + } } if (Paper_column::get_rank (p) < Paper_column::get_rank (me)) @@ -85,31 +85,29 @@ Spaceable_grob::get_spring (Grob *this_col, Grob *next_col) s = scm_cdr (s)) { if (scm_is_pair (scm_car (s)) - && unsmob_grob (scm_cdar (s)) == next_col - && unsmob_spring (scm_caar (s))) - spring = unsmob_spring (scm_caar (s)); + && unsmob_grob (scm_cdar (s)) == next_col + && unsmob_spring (scm_caar (s))) + spring = unsmob_spring (scm_caar (s)); } if (!spring) programming_error (_f ("No spring between column %d and next one", - Paper_column::get_rank (this_col))); + Paper_column::get_rank (this_col))); return spring ? *spring : Spring (); } - - ADD_INTERFACE (Spaceable_grob, - "A layout object that takes part in the spacing problem.", - - /* properties */ - "allow-loose-spacing " - "ideal-distances " - "keep-inside-line " - "left-neighbor " - "measure-length " - "minimum-distances " - "right-neighbor " - "spacing-wishes " - ); + "A layout object that takes part in the spacing problem.", + + /* properties */ + "allow-loose-spacing " + "ideal-distances " + "keep-inside-line " + "left-neighbor " + "measure-length " + "minimum-distances " + "right-neighbor " + "spacing-wishes " + ); diff --git a/lily/spacing-basic.cc b/lily/spacing-basic.cc index 6b7773f8de..d85cae6679 100644 --- a/lily/spacing-basic.cc +++ b/lily/spacing-basic.cc @@ -47,17 +47,17 @@ Spacing_spanner::standard_breakable_column_spacing (Grob *me, Item *l, Item *r, Moment *dt = unsmob_moment (l->get_property ("measure-length")); Moment mlen (1); if (dt) - mlen = *dt; + mlen = *dt; Real incr = robust_scm2double (me->get_property ("spacing-increment"), 1); Real space = incr * double (mlen.main_part_ / options->global_shortest_) * 0.8; Spring spring = Spring (min_dist + space, min_dist); /* - By default, the spring will have an inverse_stretch_strength of space+min_dist. - However, we don't want stretchability to scale with min_dist or else an - empty first measure on a line (which has a large min_dist because of the clef) - will stretch much more than an empty measure later in the line. + By default, the spring will have an inverse_stretch_strength of space+min_dist. + However, we don't want stretchability to scale with min_dist or else an + empty first measure on a line (which has a large min_dist because of the clef) + will stretch much more than an empty measure later in the line. */ spring.set_inverse_stretch_strength (space); return spring; @@ -69,8 +69,8 @@ Spacing_spanner::standard_breakable_column_spacing (Grob *me, Item *l, Item *r, if (dt == Moment (0, 0)) { /* - In this case, Staff_spacing should handle the job, - using dt when it is 0 is silly. + In this case, Staff_spacing should handle the job, + using dt when it is 0 is silly. */ ideal = min_dist + 0.5; } @@ -83,29 +83,29 @@ Spacing_spanner::standard_breakable_column_spacing (Grob *me, Item *l, Item *r, Moment * get_measure_length (Grob *column) { - Grob * sys = column->get_parent (X_AXIS); + Grob *sys = column->get_parent (X_AXIS); extract_grob_set (sys, "columns", cols); vsize col_idx = Paper_column::get_rank (column); - + do { if (Moment *len = unsmob_moment (cols[col_idx]->get_property ("measure-length"))) - { - return len; - } + { + return len; + } } while (col_idx-- != 0); - + return 0; } Real Spacing_spanner::note_spacing (Grob * /* me */, - Grob *lc, - Grob *rc, - Spacing_options const *options) + Grob *lc, + Grob *rc, + Spacing_options const *options) { Moment shortest_playing_len = 0; SCM s = lc->get_property ("shortest-playing-duration"); @@ -138,8 +138,8 @@ Spacing_spanner::note_spacing (Grob * /* me */, delta_t = min (delta_t, *measure_len); /* - The following is an extra safety measure, such that - the length of a mmrest event doesn't cause havoc. + The following is an extra safety measure, such that + the length of a mmrest event doesn't cause havoc. */ shortest_playing_len = min (shortest_playing_len, *measure_len); } @@ -153,19 +153,19 @@ Spacing_spanner::note_spacing (Grob * /* me */, else if (delta_t.grace_part_) { /* - Crude hack for spacing graces: we take the shortest space - available (namely the space for the global shortest note), and - multiply that by grace-space-factor + Crude hack for spacing graces: we take the shortest space + available (namely the space for the global shortest note), and + multiply that by grace-space-factor */ dist = options->get_duration_space (options->global_shortest_) / 2.0; Grob *grace_spacing = unsmob_grob (lc->get_object ("grace-spacing")); if (grace_spacing) - { - Spacing_options grace_opts; - grace_opts.init_from_grob (grace_spacing); - dist = grace_opts.get_duration_space (delta_t.grace_part_); - } - + { + Spacing_options grace_opts; + grace_opts.init_from_grob (grace_spacing); + dist = grace_opts.get_duration_space (delta_t.grace_part_); + } + } return dist; diff --git a/lily/spacing-determine-loose-columns.cc b/lily/spacing-determine-loose-columns.cc index 5a2411b322..79551ecac3 100644 --- a/lily/spacing-determine-loose-columns.cc +++ b/lily/spacing-determine-loose-columns.cc @@ -47,7 +47,6 @@ is_loose_column (Grob *l, Grob *col, Grob *r, Spacing_options const *options) { if (!to_boolean (col->get_property ("allow-loose-spacing"))) return false; - if ((options->float_nonmusical_columns_ || options->float_grace_columns_) @@ -56,7 +55,6 @@ is_loose_column (Grob *l, Grob *col, Grob *r, Spacing_options const *options) return true; } - if (Paper_column::is_musical (col)) return false; @@ -92,7 +90,7 @@ is_loose_column (Grob *l, Grob *col, Grob *r, Spacing_options const *options) its neighbor (ie. no funny polyphonic stuff), don't make it loose. */ if (l == l_neighbor && r == r_neighbor && col->extent (col, X_AXIS).length () > 0) - return false; + return false; /* Only declare loose if the bounds make a little sense. This means @@ -100,7 +98,7 @@ is_loose_column (Grob *l, Grob *col, Grob *r, Spacing_options const *options) nicely folded, but hey, then don't do that. */ if (! ((Paper_column::is_musical (l_neighbor) || Paper_column::is_breakable (l_neighbor)) - && (Paper_column::is_musical (r_neighbor) || Paper_column::is_breakable (r_neighbor)))) + && (Paper_column::is_musical (r_neighbor) || Paper_column::is_breakable (r_neighbor)))) return false; /* @@ -111,21 +109,21 @@ is_loose_column (Grob *l, Grob *col, Grob *r, Spacing_options const *options) { Grob *g = elts[i]; if (g && Break_alignment_interface::has_interface (g)) - { - extract_grob_set (g, "elements", gelts); - for (vsize j = gelts.size (); j--;) - { - Grob *h = gelts[j]; - - if (h && h->get_property ("break-align-symbol") == ly_symbol2scm ("staff-bar")) - { - extract_grob_set (h, "elements", helts); - for (vsize k = helts.size (); k--;) - if ("" != robust_scm2string (helts[k]->get_property ("glyph-name"), "")) - return false; - } - } - } + { + extract_grob_set (g, "elements", gelts); + for (vsize j = gelts.size (); j--;) + { + Grob *h = gelts[j]; + + if (h && h->get_property ("break-align-symbol") == ly_symbol2scm ("staff-bar")) + { + extract_grob_set (h, "elements", helts); + for (vsize k = helts.size (); k--;) + if ("" != robust_scm2string (helts[k]->get_property ("glyph-name"), "")) + return false; + } + } + } } return true; @@ -133,8 +131,8 @@ is_loose_column (Grob *l, Grob *col, Grob *r, Spacing_options const *options) void Spacing_spanner::set_distances_for_loose_col (Grob *me, Grob *c, - Drul_array<Item *> next_door, - Spacing_options const *options) + Drul_array<Item *> next_door, + Spacing_options const *options) { Direction d = LEFT; Drul_array<Real> dists (0, 0); @@ -146,42 +144,41 @@ Spacing_spanner::set_distances_for_loose_col (Grob *me, Grob *c, extract_grob_set (lc, "spacing-wishes", wishes); for (vsize k = wishes.size (); k--;) - { - Grob *sp = wishes[k]; - if (Spacing_interface::left_column (sp) != lc - || Spacing_interface::right_column (sp) != rc) - continue; - - if (Note_spacing::has_interface (sp)) - { - /* - The note spacing should be taken from the musical - columns. - */ - Real base = note_spacing (me, lc, rc, options); - Spring spring = Note_spacing::get_spacing (sp, rc, base, options->increment_); - - dists[d] = max (dists[d], spring.min_distance ()); - } - else if (Staff_spacing::has_interface (sp)) - { - Spring spring = Staff_spacing::get_spacing (sp, rc); - - dists[d] = max (dists[d], spring.min_distance ()); - } - else - programming_error ("Subversive spacing wish"); - } + { + Grob *sp = wishes[k]; + if (Spacing_interface::left_column (sp) != lc + || Spacing_interface::right_column (sp) != rc) + continue; + + if (Note_spacing::has_interface (sp)) + { + /* + The note spacing should be taken from the musical + columns. + */ + Real base = note_spacing (me, lc, rc, options); + Spring spring = Note_spacing::get_spacing (sp, rc, base, options->increment_); + + dists[d] = max (dists[d], spring.min_distance ()); + } + else if (Staff_spacing::has_interface (sp)) + { + Spring spring = Staff_spacing::get_spacing (sp, rc); + + dists[d] = max (dists[d], spring.min_distance ()); + } + else + programming_error ("Subversive spacing wish"); + } } while (flip (&d) != LEFT); Rod r; r.distance_ = dists[LEFT] + dists[RIGHT]; r.item_drul_ = next_door; - - r.add_to_cols (); -} + r.add_to_cols (); +} /* Remove columns that are not tightly fitting from COLS. In the @@ -190,72 +187,71 @@ Spacing_spanner::set_distances_for_loose_col (Grob *me, Grob *c, */ void Spacing_spanner::prune_loose_columns (Grob *me, - vector<Grob*> *cols, - Spacing_options *options) + vector<Grob *> *cols, + Spacing_options *options) { - vector<Grob*> newcols; + vector<Grob *> newcols; for (vsize i = 0; i < cols->size (); i++) { Grob *c = cols->at (i); bool loose = (i > 0 && i + 1 < cols->size ()) - && is_loose_column (cols->at (i - 1), c, cols->at (i + 1), options); + && is_loose_column (cols->at (i - 1), c, cols->at (i + 1), options); /* Breakable columns never get pruned; even if they are loose, their broken pieces are not. However, we mark them so that the spacing can take their mid-line looseness into account. */ if (loose && Paper_column::is_breakable (c)) - { - loose = false; - c->set_property ("maybe-loose", SCM_BOOL_T); - } + { + loose = false; + c->set_property ("maybe-loose", SCM_BOOL_T); + } /* - Unbreakable columns which only contain page-labels also - never get pruned, otherwise the labels are lost before they can - be collected by the System: so we mark these columns too. + Unbreakable columns which only contain page-labels also + never get pruned, otherwise the labels are lost before they can + be collected by the System: so we mark these columns too. */ if (!loose && !Paper_column::is_breakable (c) - && scm_is_pair (c->get_property ("labels"))) - { - extract_grob_set (c, "elements", elts); - if (elts.empty ()) - c->set_property ("maybe-loose", SCM_BOOL_T); - } + && scm_is_pair (c->get_property ("labels"))) + { + extract_grob_set (c, "elements", elts); + if (elts.empty ()) + c->set_property ("maybe-loose", SCM_BOOL_T); + } if (loose) - { - Grob *right_neighbor = unsmob_grob (c->get_object ("right-neighbor")); - Grob *left_neighbor = unsmob_grob (c->get_object ("left-neighbor")); - - /* - Either object can be non existent, if the score ends - prematurely. - */ - if (!right_neighbor || !left_neighbor) - { - c->programming_error ("Cannot determine neighbors for floating column. "); - c->set_object ("between-cols", scm_cons (cols->at (i-1)->self_scm (), - cols->at (i+1)->self_scm ())); - } - else - { - c->set_object ("between-cols", scm_cons (left_neighbor->self_scm (), - right_neighbor->self_scm ())); - - - /* - Set distance constraints for loose columns - */ - Drul_array<Item *> next_door (dynamic_cast<Item*> (cols->at (i - 1)), - dynamic_cast<Item*> (cols->at (i + 1))); - - set_distances_for_loose_col (me, c, next_door, options); - } - } + { + Grob *right_neighbor = unsmob_grob (c->get_object ("right-neighbor")); + Grob *left_neighbor = unsmob_grob (c->get_object ("left-neighbor")); + + /* + Either object can be non existent, if the score ends + prematurely. + */ + if (!right_neighbor || !left_neighbor) + { + c->programming_error ("Cannot determine neighbors for floating column. "); + c->set_object ("between-cols", scm_cons (cols->at (i - 1)->self_scm (), + cols->at (i + 1)->self_scm ())); + } + else + { + c->set_object ("between-cols", scm_cons (left_neighbor->self_scm (), + right_neighbor->self_scm ())); + + /* + Set distance constraints for loose columns + */ + Drul_array<Item *> next_door (dynamic_cast<Item *> (cols->at (i - 1)), + dynamic_cast<Item *> (cols->at (i + 1))); + + set_distances_for_loose_col (me, c, next_door, options); + } + } if (!loose) - newcols.push_back (c); + newcols.push_back (c); } *cols = newcols; @@ -265,35 +261,35 @@ Spacing_spanner::prune_loose_columns (Grob *me, Set neighboring columns determined by the spacing-wishes grob property. */ void -Spacing_spanner::set_explicit_neighbor_columns (vector<Grob*> const &cols) +Spacing_spanner::set_explicit_neighbor_columns (vector<Grob *> const &cols) { for (vsize i = 0; i < cols.size (); i++) { extract_grob_set (cols[i], "spacing-wishes", wishes); for (vsize j = wishes.size (); j--;) - { - Item *wish = dynamic_cast<Item*> (wishes[j]); - Item *left_col = wish->get_column (); - int left_rank = Paper_column::get_rank (left_col); - int min_right_rank = INT_MAX; - - extract_grob_set (wish, "right-items", right_items); - for (vsize k = right_items.size (); k--;) - { - Item *right_col = dynamic_cast<Item*> (right_items[k])->get_column (); - int right_rank = Paper_column::get_rank (right_col); - - if (right_rank < min_right_rank) - { - left_col->set_object ("right-neighbor", right_col->self_scm ()); - min_right_rank = right_rank; - } - - Grob *old_left_neighbor = unsmob_grob (right_col->get_object ("left-neighbor")); - if (!old_left_neighbor || left_rank > Paper_column::get_rank (old_left_neighbor)) - right_col->set_object ("left-neighbor", left_col->self_scm ()); - } - } + { + Item *wish = dynamic_cast<Item *> (wishes[j]); + Item *left_col = wish->get_column (); + int left_rank = Paper_column::get_rank (left_col); + int min_right_rank = INT_MAX; + + extract_grob_set (wish, "right-items", right_items); + for (vsize k = right_items.size (); k--;) + { + Item *right_col = dynamic_cast<Item *> (right_items[k])->get_column (); + int right_rank = Paper_column::get_rank (right_col); + + if (right_rank < min_right_rank) + { + left_col->set_object ("right-neighbor", right_col->self_scm ()); + min_right_rank = right_rank; + } + + Grob *old_left_neighbor = unsmob_grob (right_col->get_object ("left-neighbor")); + if (!old_left_neighbor || left_rank > Paper_column::get_rank (old_left_neighbor)) + right_col->set_object ("left-neighbor", left_col->self_scm ()); + } + } } } @@ -303,17 +299,17 @@ Spacing_spanner::set_explicit_neighbor_columns (vector<Grob*> const &cols) Why only these? --jneem */ void -Spacing_spanner::set_implicit_neighbor_columns (vector<Grob*> const &cols) +Spacing_spanner::set_implicit_neighbor_columns (vector<Grob *> const &cols) { for (vsize i = 0; i < cols.size (); i++) { Item *it = dynamic_cast<Item *> (cols[i]); if (!Paper_column::is_breakable (it) && !Paper_column::is_musical (it)) - continue; + continue; if (i && !unsmob_grob (cols[i]->get_object ("left-neighbor"))) - cols[i]->set_object ("left-neighbor", cols[i-1]->self_scm ()); + cols[i]->set_object ("left-neighbor", cols[i - 1]->self_scm ()); if (i + 1 < cols.size () && !unsmob_grob (cols[i]->get_object ("right-neighbor"))) - cols[i]->set_object ("right-neighbor", cols[i+1]->self_scm ()); + cols[i]->set_object ("right-neighbor", cols[i + 1]->self_scm ()); } } diff --git a/lily/spacing-engraver.cc b/lily/spacing-engraver.cc index 65cea5cbec..c9049f3398 100644 --- a/lily/spacing-engraver.cc +++ b/lily/spacing-engraver.cc @@ -53,7 +53,7 @@ compare (Rhythmic_tuple const &a, Rhythmic_tuple const &b) int Rhythmic_tuple::time_compare (Rhythmic_tuple const &h1, - Rhythmic_tuple const &h2) + Rhythmic_tuple const &h2) { return (h1.end_ - h2.end_).main_part_.sign (); } @@ -72,7 +72,7 @@ class Spacing_engraver : public Engraver Moment now_; Spanner *spacing_; Stream_event *start_section_; - + TRANSLATOR_DECLARATIONS (Spacing_engraver); protected: @@ -111,7 +111,7 @@ Spacing_engraver::process_music () { if (start_section_ && spacing_) stop_spanner (); - + if (!spacing_) start_spanner (); } @@ -121,10 +121,9 @@ Spacing_engraver::start_spanner () { assert (!spacing_); - spacing_ = make_spanner ("SpacingSpanner", SCM_EOL); spacing_->set_bound (LEFT, - unsmob_grob (get_property ("currentCommandColumn"))); + unsmob_grob (get_property ("currentCommandColumn"))); } void @@ -160,7 +159,7 @@ Spacing_engraver::acknowledge_staff_spacing (Grob_info i) void Spacing_engraver::acknowledge_rhythmic_grob (Grob_info i) { - add_starter_duration (i); + add_starter_duration (i); } void @@ -169,7 +168,6 @@ Spacing_engraver::acknowledge_rhythmic_head (Grob_info i) add_starter_duration (i); } - void Spacing_engraver::add_starter_duration (Grob_info i) { @@ -184,11 +182,11 @@ Spacing_engraver::add_starter_duration (Grob_info i) { Stream_event *r = i.event_cause (); if (r && r->in_event_class ("rhythmic-event")) - { - Moment len = get_event_length (r, now_); - Rhythmic_tuple t (i, now_mom () + len); - now_durations_.push_back (t); - } + { + Moment len = get_event_length (r, now_); + Rhythmic_tuple t (i, now_mom () + len); + now_durations_.push_back (t); + } } } @@ -198,14 +196,13 @@ Spacing_engraver::stop_translation_timestep () Paper_column *musical_column = dynamic_cast<Paper_column *> (unsmob_grob (get_property ("currentMusicalColumn"))); - if (!spacing_) start_spanner (); musical_column->set_object ("spacing", spacing_->self_scm ()); unsmob_grob (get_property ("currentCommandColumn")) - ->set_object ("spacing", spacing_->self_scm ()); - + ->set_object ("spacing", spacing_->self_scm ()); + SCM proportional = get_property ("proportionalNotationDuration"); if (unsmob_moment (proportional)) { @@ -221,11 +218,11 @@ Spacing_engraver::stop_translation_timestep () { Stream_event *ev = playing_durations_[i].info_.event_cause (); if (ev) - { - Moment now = now_mom (); - Moment m = get_event_length (ev); - shortest_playing = min (shortest_playing, m); - } + { + Moment now = now_mom (); + Moment m = get_event_length (ev); + shortest_playing = min (shortest_playing, m); + } } Moment starter; starter.set_infinite (1); @@ -234,10 +231,10 @@ Spacing_engraver::stop_translation_timestep () { Moment m = get_event_length (now_durations_[i].info_.event_cause ()); if (m.to_bool ()) - { - starter = min (starter, m); - playing_durations_.insert (now_durations_[i]); - } + { + starter = min (starter, m); + playing_durations_.insert (now_durations_[i]); + } } now_durations_.clear (); @@ -251,8 +248,6 @@ Spacing_engraver::stop_translation_timestep () musical_column->set_property ("shortest-starter-duration", st); } - - void Spacing_engraver::start_translation_timestep () { @@ -260,7 +255,7 @@ Spacing_engraver::start_translation_timestep () now_ = now_mom (); stopped_durations_.clear (); - + while (playing_durations_.size () && playing_durations_.front ().end_ < now_) playing_durations_.delmin (); while (playing_durations_.size () && playing_durations_.front ().end_ == now_) @@ -273,18 +268,18 @@ ADD_ACKNOWLEDGER (Spacing_engraver, rhythmic_head); ADD_ACKNOWLEDGER (Spacing_engraver, rhythmic_grob); ADD_TRANSLATOR (Spacing_engraver, - /* doc */ - "Make a @code{SpacingSpanner} and do bookkeeping of shortest" - " starting and playing notes.", - - /* create */ - "SpacingSpanner ", - - /* read */ - "currentMusicalColumn " - "currentCommandColumn " - "proportionalNotationDuration ", - - /* write */ - "" - ); + /* doc */ + "Make a @code{SpacingSpanner} and do bookkeeping of shortest" + " starting and playing notes.", + + /* create */ + "SpacingSpanner ", + + /* read */ + "currentMusicalColumn " + "currentCommandColumn " + "proportionalNotationDuration ", + + /* write */ + "" + ); diff --git a/lily/spacing-interface.cc b/lily/spacing-interface.cc index f9d3287cb0..944618bf5b 100644 --- a/lily/spacing-interface.cc +++ b/lily/spacing-interface.cc @@ -44,49 +44,49 @@ Spacing_interface::skylines (Grob *me, Grob *right_col) */ Grob *orig = me->original () ? me->original () : me; - Drul_array<Direction> break_dirs (dynamic_cast<Item*> (me)->break_status_dir (), - dynamic_cast<Item*> (right_col)->break_status_dir ()); + Drul_array<Direction> break_dirs (dynamic_cast<Item *> (me)->break_status_dir (), + dynamic_cast<Item *> (right_col)->break_status_dir ()); Drul_array<Skyline> skylines = Drul_array<Skyline> (Skyline (RIGHT), Skyline (LEFT)); - Drul_array<vector<Grob*> > items (ly_scm2link_array (orig->get_object ("left-items")), - ly_scm2link_array (orig->get_object ("right-items"))); + Drul_array<vector<Grob *> > items (ly_scm2link_array (orig->get_object ("left-items")), + ly_scm2link_array (orig->get_object ("right-items"))); Grob *system = me->get_system (); - Grob *left_col = dynamic_cast<Item*> (me)->get_column (); + Grob *left_col = dynamic_cast<Item *> (me)->get_column (); - Drul_array<Grob*> columns (left_col, right_col); + Drul_array<Grob *> columns (left_col, right_col); Direction d = LEFT; do { for (vsize i = 0; i < items[d].size (); i++) - { - Item *g = dynamic_cast<Item*> (items[d][i]); - if (g) - if (Item *piece = g->find_prebroken_piece (break_dirs[d])) - g = piece; - - if (g && Separation_item::has_interface (g) && g->get_column () == columns[d]) - { - SCM sky_scm = g->get_property ("horizontal-skylines"); - Skyline_pair *sky = Skyline_pair::unsmob (sky_scm); - - extract_grob_set (g, "elements", elts); - Grob *ycommon = common_refpoint_of_array (elts, g, Y_AXIS); - Real shift = ycommon->pure_relative_y_coordinate (system, 0, INT_MAX); - - skylines[d].shift (-shift); - - if (sky) - skylines[d].merge ((*sky)[-d]); - else - programming_error ("separation item has no skyline"); - - if (d == RIGHT && items[LEFT].size ()) - skylines[d].merge (Separation_item::conditional_skyline (items[d][i], items[LEFT][0])); - - skylines[d].shift (shift); - } - } + { + Item *g = dynamic_cast<Item *> (items[d][i]); + if (g) + if (Item *piece = g->find_prebroken_piece (break_dirs[d])) + g = piece; + + if (g && Separation_item::has_interface (g) && g->get_column () == columns[d]) + { + SCM sky_scm = g->get_property ("horizontal-skylines"); + Skyline_pair *sky = Skyline_pair::unsmob (sky_scm); + + extract_grob_set (g, "elements", elts); + Grob *ycommon = common_refpoint_of_array (elts, g, Y_AXIS); + Real shift = ycommon->pure_relative_y_coordinate (system, 0, INT_MAX); + + skylines[d].shift (-shift); + + if (sky) + skylines[d].merge ((*sky)[-d]); + else + programming_error ("separation item has no skyline"); + + if (d == RIGHT && items[LEFT].size ()) + skylines[d].merge (Separation_item::conditional_skyline (items[d][i], items[LEFT][0])); + + skylines[d].shift (shift); + } + } } while (flip (&d) != LEFT); @@ -121,10 +121,10 @@ Spacing_interface::right_column (Grob *me) int rank = Paper_column::get_rank (col); if (rank < min_rank) - { - min_rank = rank; - mincol = col; - } + { + min_rank = rank; + mincol = col; + } } return mincol; @@ -139,35 +139,35 @@ Spacing_interface::left_column (Grob *me) return dynamic_cast<Item *> (me)->get_column (); } -static vector<Item*> -get_note_columns (vector<Grob*> const &elts) +static vector<Item *> +get_note_columns (vector<Grob *> const &elts) { - vector<Item*> ret; + vector<Item *> ret; for (vsize i = 0; i < elts.size (); i++) { if (Note_column::has_interface (elts[i])) - ret.push_back (dynamic_cast<Item*> (elts[i])); + ret.push_back (dynamic_cast<Item *> (elts[i])); else if (Separation_item::has_interface (elts[i])) - { - extract_grob_set (elts[i], "elements", more_elts); - vector<Item*> ncs = get_note_columns (more_elts); + { + extract_grob_set (elts[i], "elements", more_elts); + vector<Item *> ncs = get_note_columns (more_elts); - ret.insert (ret.end (), ncs.begin (), ncs.end ()); - } + ret.insert (ret.end (), ncs.begin (), ncs.end ()); + } } return ret; } -vector<Item*> +vector<Item *> Spacing_interface::right_note_columns (Grob *me) { extract_grob_set (me, "right-items", elts); return get_note_columns (elts); } -vector<Item*> +vector<Item *> Spacing_interface::left_note_columns (Grob *me) { extract_grob_set (me, "left-items", elts); @@ -180,9 +180,9 @@ Spacing_interface::left_note_columns (Grob *me) */ Grob * Spacing_interface::extremal_break_aligned_grob (Grob *me, - Direction d, - Direction break_dir, - Interval *last_ext) + Direction d, + Direction break_dir, + Interval *last_ext) { Grob *col = 0; last_ext->set_empty (); @@ -192,39 +192,38 @@ Spacing_interface::extremal_break_aligned_grob (Grob *me, for (vsize i = elts.size (); i--;) { - Item *break_item = dynamic_cast<Item*> (elts[i]); + Item *break_item = dynamic_cast<Item *> (elts[i]); if (break_item->break_status_dir () != break_dir) - break_item = break_item->find_prebroken_piece (break_dir); + break_item = break_item->find_prebroken_piece (break_dir); if (!break_item || !scm_is_pair (break_item->get_property ("space-alist"))) - continue; + continue; if (!col) - col = dynamic_cast<Item*> (elts[0])->get_column ()->find_prebroken_piece (break_dir); + col = dynamic_cast<Item *> (elts[0])->get_column ()->find_prebroken_piece (break_dir); Interval ext = break_item->extent (col, X_AXIS); if (ext.is_empty ()) - continue; + continue; if (!last_grob - || (last_grob && d * (ext[-d]- (*last_ext)[-d]) < 0)) - { - *last_ext = ext; - last_grob = break_item; - } + || (last_grob && d * (ext[-d] - (*last_ext)[-d]) < 0)) + { + *last_ext = ext; + last_grob = break_item; + } } return last_grob; } - ADD_INTERFACE (Spacing_interface, - "This object calculates the desired and minimum distances" - " between two columns.", + "This object calculates the desired and minimum distances" + " between two columns.", - /* properties */ - "left-items " - "right-items " - ); + /* properties */ + "left-items " + "right-items " + ); diff --git a/lily/spacing-loose-columns.cc b/lily/spacing-loose-columns.cc index 03cac8431c..fb5e326369 100644 --- a/lily/spacing-loose-columns.cc +++ b/lily/spacing-loose-columns.cc @@ -48,135 +48,134 @@ set_loose_columns (System *which, Column_x_positions const *posns) Item *left = 0; Item *right = 0; - vector<Item*> clique; + vector<Item *> clique; while (1) - { - SCM between = loose->get_object ("between-cols"); - if (!scm_is_pair (between)) - break; + { + SCM between = loose->get_object ("between-cols"); + if (!scm_is_pair (between)) + break; - /* If the line was broken at one of the loose columns, split - the clique at that column. */ - if (!loose->get_system ()) - break; + /* If the line was broken at one of the loose columns, split + the clique at that column. */ + if (!loose->get_system ()) + break; - Paper_column *le = dynamic_cast<Paper_column *> (unsmob_grob (scm_car (between))); - Paper_column *re = dynamic_cast<Paper_column *> (unsmob_grob (scm_cdr (between))); + Paper_column *le = dynamic_cast<Paper_column *> (unsmob_grob (scm_car (between))); + Paper_column *re = dynamic_cast<Paper_column *> (unsmob_grob (scm_cdr (between))); - if (! (le && re)) - break; + if (! (le && re)) + break; - if (!left && le) - { - left = le->get_column (); - if (!left->get_system ()) - left = left->find_prebroken_piece (RIGHT); + if (!left && le) + { + left = le->get_column (); + if (!left->get_system ()) + left = left->find_prebroken_piece (RIGHT); - clique.push_back (left); - } + clique.push_back (left); + } - clique.push_back (loose); + clique.push_back (loose); - divide_over++; - loose = right = re->get_column (); - } + divide_over++; + loose = right = re->get_column (); + } if (!right) - { - programming_error ("Can't attach loose column sensibly. Attaching to end of system."); - right = which->get_bound (RIGHT); - } + { + programming_error ("Can't attach loose column sensibly. Attaching to end of system."); + right = which->get_bound (RIGHT); + } if (right->get_system ()) - ; /* do nothing */ + ; /* do nothing */ else if (right->find_prebroken_piece (LEFT) - && right->find_prebroken_piece (LEFT)->get_system () == which) - right = right->find_prebroken_piece (LEFT); + && right->find_prebroken_piece (LEFT)->get_system () == which) + right = right->find_prebroken_piece (LEFT); else if (Paper_column::get_rank (which->get_bound (RIGHT)) < Paper_column::get_rank (right)) - right = which->get_bound (RIGHT); + right = which->get_bound (RIGHT); else - { - clique.back ()->programming_error ("Loose column does not have right side to attach to."); - System *base_system = dynamic_cast<System*> (which->original ()); - int j = Paper_column::get_rank (clique.back ()) + 1; - int end_rank = Paper_column::get_rank (which->get_bound (RIGHT)); - extract_grob_set (base_system, "columns", base_cols); - for (; j < end_rank; j++) - { - if (base_cols[j]->get_system () == which) - right = dynamic_cast<Item*> ((Grob*)base_cols[j]); - } - } - + { + clique.back ()->programming_error ("Loose column does not have right side to attach to."); + System *base_system = dynamic_cast<System *> (which->original ()); + int j = Paper_column::get_rank (clique.back ()) + 1; + int end_rank = Paper_column::get_rank (which->get_bound (RIGHT)); + extract_grob_set (base_system, "columns", base_cols); + for (; j < end_rank; j++) + { + if (base_cols[j]->get_system () == which) + right = dynamic_cast<Item *> ((Grob *)base_cols[j]); + } + } + Grob *common = right->common_refpoint (left, X_AXIS); clique.push_back (right); vector<Real> clique_spacing; clique_spacing.push_back (0.0); - for (vsize j = 1; j + 1 < clique.size (); j ++) - { - Grob *clique_col = clique[j]; - - Paper_column *loose_col = dynamic_cast<Paper_column *> (clique[j]); - Paper_column *next_col = dynamic_cast<Paper_column *> (clique[j + 1]); - - Grob *spacing = unsmob_grob (clique_col->get_object ("spacing")); - if (Grob *grace_spacing = unsmob_grob (clique_col->get_object ("grace-spacing"))) - { - spacing = grace_spacing; - } - - Spacing_options options; - if (spacing) - options.init_from_grob (spacing); - else - programming_error ("Column without spacing object"); - - Real base_note_space = 0.0; - - if (Paper_column::is_musical (next_col) - && Paper_column::is_musical (loose_col)) - base_note_space = Spacing_spanner::note_spacing (spacing, loose_col, next_col, - &options); - else - { - Spring spring = Spacing_spanner::standard_breakable_column_spacing (spacing, - loose_col, next_col, - &options); - - base_note_space = spring.distance (); - } - - base_note_space = max (base_note_space, - robust_relative_extent (loose_col, loose_col, X_AXIS)[RIGHT] - - robust_relative_extent (next_col, next_col, X_AXIS)[LEFT]); - - clique_spacing.push_back (base_note_space); - } + for (vsize j = 1; j + 1 < clique.size (); j++) + { + Grob *clique_col = clique[j]; + + Paper_column *loose_col = dynamic_cast<Paper_column *> (clique[j]); + Paper_column *next_col = dynamic_cast<Paper_column *> (clique[j + 1]); + + Grob *spacing = unsmob_grob (clique_col->get_object ("spacing")); + if (Grob *grace_spacing = unsmob_grob (clique_col->get_object ("grace-spacing"))) + { + spacing = grace_spacing; + } + + Spacing_options options; + if (spacing) + options.init_from_grob (spacing); + else + programming_error ("Column without spacing object"); + + Real base_note_space = 0.0; + + if (Paper_column::is_musical (next_col) + && Paper_column::is_musical (loose_col)) + base_note_space = Spacing_spanner::note_spacing (spacing, loose_col, next_col, + &options); + else + { + Spring spring = Spacing_spanner::standard_breakable_column_spacing (spacing, + loose_col, next_col, + &options); + + base_note_space = spring.distance (); + } + + base_note_space = max (base_note_space, + robust_relative_extent (loose_col, loose_col, X_AXIS)[RIGHT] + - robust_relative_extent (next_col, next_col, X_AXIS)[LEFT]); + + clique_spacing.push_back (base_note_space); + } Real default_padding = 1.0; clique_spacing.push_back (default_padding); Real right_point = robust_relative_extent (clique.back (), common, X_AXIS)[LEFT]; - - + Grob *finished_right_column = clique.back (); - + for (vsize j = clique.size () - 2; j > 0; j--) - { - Paper_column *clique_col = dynamic_cast<Paper_column *> (clique[j]); - - right_point = finished_right_column->relative_coordinate (common, X_AXIS); + { + Paper_column *clique_col = dynamic_cast<Paper_column *> (clique[j]); + + right_point = finished_right_column->relative_coordinate (common, X_AXIS); + + Real distance_to_next = clique_spacing[j]; - Real distance_to_next = clique_spacing[j]; - - Real my_offset = right_point - distance_to_next; + Real my_offset = right_point - distance_to_next; - clique_col->translate_axis (my_offset - clique_col->relative_coordinate (common, X_AXIS), X_AXIS); + clique_col->translate_axis (my_offset - clique_col->relative_coordinate (common, X_AXIS), X_AXIS); - finished_right_column = clique_col; - } + finished_right_column = clique_col; + } } } diff --git a/lily/spacing-options.cc b/lily/spacing-options.cc index 934acb20cc..8719e4cc6b 100644 --- a/lily/spacing-options.cc +++ b/lily/spacing-options.cc @@ -38,9 +38,8 @@ Spacing_options::init_from_grob (Grob *me) = to_boolean (me->get_property ("strict-grace-spacing")); shortest_duration_space_ = robust_scm2double (me->get_property ("shortest-duration-space"), 1); - Moment shortest_dur = robust_scm2moment (me->get_property ("common-shortest-duration"), - Moment (Rational (1,8), Rational (1,16))); + Moment (Rational (1, 8), Rational (1, 16))); if (shortest_dur.main_part_) global_shortest_ = shortest_dur.main_part_; @@ -61,8 +60,6 @@ Spacing_options::Spacing_options () global_shortest_ = Rational (1, 8); } - - /* Get the measure wide ant for arithmetic spacing. */ @@ -74,18 +71,18 @@ Spacing_options::get_duration_space (Rational d) const if (d < global_shortest_) { /* - We don't space really short notes using the log of the - duration, since it would disproportionally stretches the long - notes in a piece. In stead, we use geometric spacing with constant 0.5 - (i.e. linear.) + We don't space really short notes using the log of the + duration, since it would disproportionally stretches the long + notes in a piece. In stead, we use geometric spacing with constant 0.5 + (i.e. linear.) - This should probably be tunable, to use other base numbers. + This should probably be tunable, to use other base numbers. - In Mozart hrn3 by EB., we have 8th note = 3.9 mm (total), 16th note = - 3.6 mm (total). head-width = 2.4, so we 1.2mm for 16th, 1.5 - mm for 8th. (white space), suggesting that we use + In Mozart hrn3 by EB., we have 8th note = 3.9 mm (total), 16th note = + 3.6 mm (total). head-width = 2.4, so we 1.2mm for 16th, 1.5 + mm for 8th. (white space), suggesting that we use - (1.2 / 1.5)^{-log2(duration ratio)} + (1.2 / 1.5)^{-log2(duration ratio)} */ @@ -96,9 +93,9 @@ Spacing_options::get_duration_space (Rational d) const else { /* - John S. Gourlay. ``Spacing a Line of Music, '' Technical - Report OSU-CISRC-10/87-TR35, Department of Computer and - Information Science, The Ohio State University, 1987. + John S. Gourlay. ``Spacing a Line of Music, '' Technical + Report OSU-CISRC-10/87-TR35, Department of Computer and + Information Science, The Ohio State University, 1987. */ Real log = log_2 (global_shortest_); k -= log; diff --git a/lily/spacing-spanner.cc b/lily/spacing-spanner.cc index 0395506bbc..75dc166925 100644 --- a/lily/spacing-spanner.cc +++ b/lily/spacing-spanner.cc @@ -39,18 +39,18 @@ #include "system.hh" #include "warn.hh" -vector<Grob*> +vector<Grob *> Spacing_spanner::get_columns (Grob *me_grob) { - Spanner *me = dynamic_cast<Spanner*> (me_grob); - vector<Grob*> all (get_root_system (me)->used_columns ()); - vsize start = binary_search (all, (Grob*)me->get_bound (LEFT), - &Paper_column::less_than); - vsize end = binary_search (all, (Grob*) me->get_bound (RIGHT), - &Paper_column::less_than); - - all = vector<Grob*> (all.begin () + start, - all.begin () + end + 1); + Spanner *me = dynamic_cast<Spanner *> (me_grob); + vector<Grob *> all (get_root_system (me)->used_columns ()); + vsize start = binary_search (all, (Grob *)me->get_bound (LEFT), + &Paper_column::less_than); + vsize end = binary_search (all, (Grob *) me->get_bound (RIGHT), + &Paper_column::less_than); + + all = vector<Grob *> (all.begin () + start, + all.begin () + end + 1); return all; } @@ -65,7 +65,7 @@ Spacing_spanner::set_springs (SCM smob) */ Spacing_options options; options.init_from_grob (me); - vector<Grob*> cols = Spacing_spanner::get_columns (me); + vector<Grob *> cols = Spacing_spanner::get_columns (me); set_explicit_neighbor_columns (cols); prune_loose_columns (me, &cols, &options); @@ -86,13 +86,13 @@ Spacing_spanner::set_springs (SCM smob) */ MAKE_SCHEME_CALLBACK (Spacing_spanner, calc_common_shortest_duration, 1); -SCM +SCM Spacing_spanner::calc_common_shortest_duration (SCM grob) { Spanner *me = unsmob_spanner (grob); - vector<Grob*> cols (get_columns (me)); - + vector<Grob *> cols (get_columns (me)); + /* ascending in duration */ @@ -105,47 +105,47 @@ Spacing_spanner::calc_common_shortest_duration (SCM grob) for (vsize i = 0; i < cols.size (); i++) { if (Paper_column::is_musical (cols[i])) - { - Moment *when = unsmob_moment (cols[i]->get_property ("when")); - - /* - ignore grace notes for shortest notes. - */ - if (when && when->grace_part_) - continue; - - SCM st = cols[i]->get_property ("shortest-starter-duration"); - Moment this_shortest = *unsmob_moment (st); - assert (this_shortest.to_bool ()); - shortest_in_measure = min (shortest_in_measure, this_shortest.main_part_); - } + { + Moment *when = unsmob_moment (cols[i]->get_property ("when")); + + /* + ignore grace notes for shortest notes. + */ + if (when && when->grace_part_) + continue; + + SCM st = cols[i]->get_property ("shortest-starter-duration"); + Moment this_shortest = *unsmob_moment (st); + assert (this_shortest.to_bool ()); + shortest_in_measure = min (shortest_in_measure, this_shortest.main_part_); + } else if (!shortest_in_measure.is_infinity () - && Paper_column::is_breakable (cols[i])) - { - vsize j = 0; - for (; j < durations.size (); j++) - { - if (durations[j] > shortest_in_measure) - { - counts.insert (counts.begin () + j, 1); - durations.insert (durations.begin () + j, shortest_in_measure); - break; - } - else if (durations[j] == shortest_in_measure) - { - counts[j]++; - break; - } - } - - if (durations.size () == j) - { - durations.push_back (shortest_in_measure); - counts.push_back (1); - } - - shortest_in_measure.set_infinite (1); - } + && Paper_column::is_breakable (cols[i])) + { + vsize j = 0; + for (; j < durations.size (); j++) + { + if (durations[j] > shortest_in_measure) + { + counts.insert (counts.begin () + j, 1); + durations.insert (durations.begin () + j, shortest_in_measure); + break; + } + else if (durations[j] == shortest_in_measure) + { + counts[j]++; + break; + } + } + + if (durations.size () == j) + { + durations.push_back (shortest_in_measure); + counts.push_back (1); + } + + shortest_in_measure.set_infinite (1); + } } vsize max_idx = VPOS; @@ -153,10 +153,10 @@ Spacing_spanner::calc_common_shortest_duration (SCM grob) for (vsize i = durations.size (); i--;) { if (counts[i] >= max_count) - { - max_idx = i; - max_count = counts[i]; - } + { + max_idx = i; + max_count = counts[i]; + } } SCM bsd = me->get_property ("base-shortest-duration"); @@ -172,144 +172,143 @@ Spacing_spanner::calc_common_shortest_duration (SCM grob) void Spacing_spanner::generate_pair_spacing (Grob *me, - Paper_column *left_col, Paper_column *right_col, - Paper_column *after_right_col, - Spacing_options const *options) + Paper_column *left_col, Paper_column *right_col, + Paper_column *after_right_col, + Spacing_options const *options) { if (Paper_column::is_musical (left_col)) { if (!Paper_column::is_musical (right_col) - && (options->float_nonmusical_columns_ || to_boolean (right_col->get_property ("maybe-loose"))) - && after_right_col - && Paper_column::is_musical (after_right_col)) - { - /* - TODO: should generate rods to prevent collisions. - */ - musical_column_spacing (me, left_col, after_right_col, options); - right_col->set_object ("between-cols", scm_cons (left_col->self_scm (), - after_right_col->self_scm ())); - } + && (options->float_nonmusical_columns_ || to_boolean (right_col->get_property ("maybe-loose"))) + && after_right_col + && Paper_column::is_musical (after_right_col)) + { + /* + TODO: should generate rods to prevent collisions. + */ + musical_column_spacing (me, left_col, after_right_col, options); + right_col->set_object ("between-cols", scm_cons (left_col->self_scm (), + after_right_col->self_scm ())); + } else - musical_column_spacing (me, left_col, right_col, options); + musical_column_spacing (me, left_col, right_col, options); if (Item *rb = right_col->find_prebroken_piece (LEFT)) - musical_column_spacing (me, left_col, rb, options); + musical_column_spacing (me, left_col, rb, options); } else { /* - The case that the right part is broken as well is rather - rare, but it is possible, eg. with a single empty measure, - or if one staff finishes a tad earlier than the rest. + The case that the right part is broken as well is rather + rare, but it is possible, eg. with a single empty measure, + or if one staff finishes a tad earlier than the rest. */ Item *lb = left_col->find_prebroken_piece (RIGHT); Item *rb = right_col->find_prebroken_piece (LEFT); if (left_col && right_col) - breakable_column_spacing (me, left_col, right_col, options); + breakable_column_spacing (me, left_col, right_col, options); if (lb && right_col) - breakable_column_spacing (me, lb, right_col, options); + breakable_column_spacing (me, lb, right_col, options); if (left_col && rb) - breakable_column_spacing (me, left_col, rb, options); + breakable_column_spacing (me, left_col, rb, options); if (lb && rb) - breakable_column_spacing (me, lb, rb, options); + breakable_column_spacing (me, lb, rb, options); } } static void -set_column_rods (vector<Grob*> const &cols, Real padding) +set_column_rods (vector<Grob *> const &cols, Real padding) { /* distances[i] will be the minimum distance between column i and column i+1 */ vector<Real> distances; for (vsize i = 1; i < cols.size (); i++) { - assert (distances.size () == i-1); + assert (distances.size () == i - 1); - Item *r = dynamic_cast<Item*> (cols[i]); + Item *r = dynamic_cast<Item *> (cols[i]); Item *rb = r->find_prebroken_piece (LEFT); if (Separation_item::is_empty (r) && (!rb || Separation_item::is_empty (rb))) - { - distances.push_back (0); - continue; - } + { + distances.push_back (0); + continue; + } Skyline_pair *skys = Skyline_pair::unsmob (r->get_property ("horizontal-skylines")); Real right_stickout = skys ? (*skys)[LEFT].max_height () : 0.0; /* min rather than max because right-stickout will be negative if the right-hand column - sticks out a lot to the left */ + sticks out a lot to the left */ right_stickout = min (right_stickout, - Separation_item::conditional_skyline (r, cols[i-1]).max_height ()); + Separation_item::conditional_skyline (r, cols[i - 1]).max_height ()); - Drul_array<Item*> r_cols (r, rb); + Drul_array<Item *> r_cols (r, rb); Drul_array<Real> cur_dist (0.0, 0.0); /* This is an inner loop and hence it is potentially quadratic. However, we only continue - as long as there is a rod to insert. Therefore, this loop will usually only execute - a constant number of times per iteration of the outer loop. */ + as long as there is a rod to insert. Therefore, this loop will usually only execute + a constant number of times per iteration of the outer loop. */ for (vsize j = i; j--;) - { - Item *l = dynamic_cast<Item*> (cols[j]); - Item *lb = l->find_prebroken_piece (RIGHT); - Skyline_pair *skys = Skyline_pair::unsmob (l->get_property ("horizontal-skylines")); - Real left_stickout = skys ? (*skys)[RIGHT].max_height () : 0.0; - bool done = true; - - Direction d = LEFT; - do - { - if (j < i-1) - cur_dist[d] += distances[j]; - - Item *r_col = r_cols[d]; - bool touches = right_stickout - left_stickout + cur_dist[d] < 0.0; - Real dist = 0.0; - - /* we set a distance for the line-starter column even if its non-broken counterpart - doesn't touch the right column. */ - if (lb) - Separation_item::set_distance (lb, r_col, padding); - - if (touches || j == i-1) - dist = Separation_item::set_distance (l, r_col, padding); - - if (j == i-1 && d == LEFT) - distances.push_back (dist); - - if (j == i-1) - cur_dist[d] = distances[j]; - - cur_dist[d] = max (cur_dist[d], dist); - done = done && !touches; - } - while (flip (&d) != LEFT && rb); - - /* we need the empty check for gregorian notation, where there are a lot of - extraneous paper-columns that we need to skip over */ - if (done && !Separation_item::is_empty (l)) - break; - } + { + Item *l = dynamic_cast<Item *> (cols[j]); + Item *lb = l->find_prebroken_piece (RIGHT); + Skyline_pair *skys = Skyline_pair::unsmob (l->get_property ("horizontal-skylines")); + Real left_stickout = skys ? (*skys)[RIGHT].max_height () : 0.0; + bool done = true; + + Direction d = LEFT; + do + { + if (j < i - 1) + cur_dist[d] += distances[j]; + + Item *r_col = r_cols[d]; + bool touches = right_stickout - left_stickout + cur_dist[d] < 0.0; + Real dist = 0.0; + + /* we set a distance for the line-starter column even if its non-broken counterpart + doesn't touch the right column. */ + if (lb) + Separation_item::set_distance (lb, r_col, padding); + + if (touches || j == i - 1) + dist = Separation_item::set_distance (l, r_col, padding); + + if (j == i - 1 && d == LEFT) + distances.push_back (dist); + + if (j == i - 1) + cur_dist[d] = distances[j]; + + cur_dist[d] = max (cur_dist[d], dist); + done = done && !touches; + } + while (flip (&d) != LEFT && rb); + + /* we need the empty check for gregorian notation, where there are a lot of + extraneous paper-columns that we need to skip over */ + if (done && !Separation_item::is_empty (l)) + break; + } } } - void Spacing_spanner::generate_springs (Grob *me, - vector<Grob*> const &cols, - Spacing_options const *options) + vector<Grob *> const &cols, + Spacing_options const *options) { - Paper_column *prev = dynamic_cast<Paper_column*> (cols[0]); + Paper_column *prev = dynamic_cast<Paper_column *> (cols[0]); for (vsize i = 1; i < cols.size (); i++) { Paper_column *col = dynamic_cast<Paper_column *> (cols[i]); - Paper_column *next = (i + 1 < cols.size ()) ? dynamic_cast<Paper_column *> (cols[i+1]) : 0; - + Paper_column *next = (i + 1 < cols.size ()) ? dynamic_cast<Paper_column *> (cols[i + 1]) : 0; + generate_pair_spacing (me, prev, col, next, options); prev = col; @@ -324,9 +323,9 @@ Spacing_spanner::generate_springs (Grob *me, */ void Spacing_spanner::musical_column_spacing (Grob *me, - Item *left_col, - Item *right_col, - Spacing_options const *options) + Item *left_col, + Item *right_col, + Spacing_options const *options) { Real base_note_space = note_spacing (me, left_col, right_col, options); Spring spring; @@ -339,76 +338,76 @@ Spacing_spanner::musical_column_spacing (Grob *me, extract_grob_set (left_col, "spacing-wishes", wishes); for (vsize i = 0; i < wishes.size (); i++) - { - Grob *wish = wishes[i]; - if (Spacing_interface::left_column (wish) != left_col) - { - /* This shouldn't really happen, but the ancient music - stuff really messes up the spacing code, grrr - */ - continue; - } - - extract_grob_set (wish, "right-items", right_items); - bool found_matching_column = false; - for (vsize j = 0; j < right_items.size (); j++) - { - Item *it = dynamic_cast<Item*> (right_items[j]); - if (it && (right_col == it->get_column () - || right_col->original () == it->get_column ())) - found_matching_column = true; - } - - /* - This is probably a waste of time in the case of polyphonic - music. */ - if (found_matching_column && Note_spacing::has_interface (wish)) - { - Real inc = options->increment_; - Grob *gsp = unsmob_grob (left_col->get_object ("grace-spacing")); - if (gsp && Paper_column::when_mom (left_col).grace_part_) - { - Spacing_options grace_opts; - grace_opts.init_from_grob (gsp); - inc = grace_opts.increment_; - } - springs.push_back (Note_spacing::get_spacing (wish, right_col, base_note_space, inc)); - } - } + { + Grob *wish = wishes[i]; + if (Spacing_interface::left_column (wish) != left_col) + { + /* This shouldn't really happen, but the ancient music + stuff really messes up the spacing code, grrr + */ + continue; + } + + extract_grob_set (wish, "right-items", right_items); + bool found_matching_column = false; + for (vsize j = 0; j < right_items.size (); j++) + { + Item *it = dynamic_cast<Item *> (right_items[j]); + if (it && (right_col == it->get_column () + || right_col->original () == it->get_column ())) + found_matching_column = true; + } + + /* + This is probably a waste of time in the case of polyphonic + music. */ + if (found_matching_column && Note_spacing::has_interface (wish)) + { + Real inc = options->increment_; + Grob *gsp = unsmob_grob (left_col->get_object ("grace-spacing")); + if (gsp && Paper_column::when_mom (left_col).grace_part_) + { + Spacing_options grace_opts; + grace_opts.init_from_grob (gsp); + inc = grace_opts.increment_; + } + springs.push_back (Note_spacing::get_spacing (wish, right_col, base_note_space, inc)); + } + } if (springs.empty ()) - { - - if (!Paper_column::is_musical (right_col)) - { - /* - There used to be code that examined left_col->extent - (X_AXIS), but this is resulted in unexpected wide - spacing, because the width of s^"text" output is also - taken into account here. - */ - spring = Spring (max (base_note_space, options->increment_), - options->increment_); - } - else - { - /* - Min distance should be 0.0. If there are no spacing - wishes, we're probably dealing with polyphonic spacing - of hemiolas. - */ - spring = Spring (base_note_space, 0.0); - } - } + { + + if (!Paper_column::is_musical (right_col)) + { + /* + There used to be code that examined left_col->extent + (X_AXIS), but this is resulted in unexpected wide + spacing, because the width of s^"text" output is also + taken into account here. + */ + spring = Spring (max (base_note_space, options->increment_), + options->increment_); + } + else + { + /* + Min distance should be 0.0. If there are no spacing + wishes, we're probably dealing with polyphonic spacing + of hemiolas. + */ + spring = Spring (base_note_space, 0.0); + } + } else - spring = merge_springs (springs); + spring = merge_springs (springs); } if (Paper_column::when_mom (right_col).grace_part_ && !Paper_column::when_mom (left_col).grace_part_) { /* - Ugh. 0.8 is arbitrary. + Ugh. 0.8 is arbitrary. */ spring *= 0.8; } @@ -419,30 +418,30 @@ Spacing_spanner::musical_column_spacing (Grob *me, if (options->packed_) { /* - In packed mode, pack notes as tight as possible. This makes - sense mostly in combination with ragged-right mode: the notes - are then printed at minimum distance. This is mostly useful - for ancient notation, but may also be useful for some flavours - of contemporary music. If not in ragged-right mode, lily will - pack as many bars of music as possible into a line, but the - line will then be stretched to fill the whole linewidth. - - Note that we don't actually pack things as tightly as possible: - we don't allow the next column to begin before this one ends. + In packed mode, pack notes as tight as possible. This makes + sense mostly in combination with ragged-right mode: the notes + are then printed at minimum distance. This is mostly useful + for ancient notation, but may also be useful for some flavours + of contemporary music. If not in ragged-right mode, lily will + pack as many bars of music as possible into a line, but the + line will then be stretched to fill the whole linewidth. + + Note that we don't actually pack things as tightly as possible: + we don't allow the next column to begin before this one ends. */ /* FIXME: the else clause below is the "right" thing to do, - but we can't do it because of all the empty columns that the - ligature-engravers leave lying around. In that case, the extent of - the column is incorrect because it includes note-heads that aren't - there. We get around this by only including the column extent if - the left-hand column is "genuine". This is a dirty hack and it - should be fixed in the ligature-engravers. --jneem + but we can't do it because of all the empty columns that the + ligature-engravers leave lying around. In that case, the extent of + the column is incorrect because it includes note-heads that aren't + there. We get around this by only including the column extent if + the left-hand column is "genuine". This is a dirty hack and it + should be fixed in the ligature-engravers. --jneem */ if (Paper_column::is_extraneous_column_from_ligature (left_col)) - spring.set_distance (spring.min_distance ()); + spring.set_distance (spring.min_distance ()); else - spring.set_distance (max (left_col->extent (left_col, X_AXIS)[RIGHT], - spring.min_distance ())); + spring.set_distance (max (left_col->extent (left_col, X_AXIS)[RIGHT], + spring.min_distance ())); spring.set_inverse_stretch_strength (1.0); } @@ -466,21 +465,21 @@ Spacing_spanner::fills_measure (Grob *me, Item *left, Item *col) || !Paper_column::is_musical (col) || !Paper_column::is_used (next)) return false; - - Moment dt = - Paper_column::when_mom (next) - Paper_column::when_mom (col); - + + Moment dt + = Paper_column::when_mom (next) - Paper_column::when_mom (col); + Moment *len = unsmob_moment (left->get_property ("measure-length")); if (!len) return false; - + /* Don't check for exact measure length, since ending measures are often shortened due to pickups. */ if (dt.main_part_ > len->main_part_ / Rational (2) && (next->is_broken () - || next->break_status_dir ())) + || next->break_status_dir ())) return true; return false; @@ -491,7 +490,7 @@ Spacing_spanner::fills_measure (Grob *me, Item *left, Item *col) */ void Spacing_spanner::breakable_column_spacing (Grob *me, Item *l, Item *r, - Spacing_options const *options) + Spacing_options const *options) { vector<Spring> springs; Spring spring; @@ -503,20 +502,20 @@ Spacing_spanner::breakable_column_spacing (Grob *me, Item *l, Item *r, extract_grob_set (l, "spacing-wishes", wishes); for (vsize i = 0; i < wishes.size (); i++) - { - Item *spacing_grob = dynamic_cast<Item *> (wishes[i]); + { + Item *spacing_grob = dynamic_cast<Item *> (wishes[i]); - if (!spacing_grob || !Staff_spacing::has_interface (spacing_grob)) - continue; + if (!spacing_grob || !Staff_spacing::has_interface (spacing_grob)) + continue; - /* - column for the left one settings should be ok due automatic - pointer munging. - */ - assert (spacing_grob->get_column () == l); + /* + column for the left one settings should be ok due automatic + pointer munging. + */ + assert (spacing_grob->get_column () == l); - springs.push_back (Staff_spacing::get_spacing (spacing_grob, r)); - } + springs.push_back (Staff_spacing::get_spacing (spacing_grob, r)); + } } if (springs.empty ()) @@ -527,9 +526,9 @@ Spacing_spanner::breakable_column_spacing (Grob *me, Item *l, Item *r, if (Paper_column::when_mom (r).grace_part_) { /* - Correct for grace notes. - - Ugh. The 0.8 is arbitrary. + Correct for grace notes. + + Ugh. The 0.8 is arbitrary. */ spring *= 0.8; } @@ -542,7 +541,7 @@ Spacing_spanner::breakable_column_spacing (Grob *me, Item *l, Item *r, spring.set_distance (spring.distance () + full_measure_extra_space); spring.set_default_compress_strength (); } - + if (options->stretch_uniformly_ && l->break_status_dir () != RIGHT) { spring.set_min_distance (0.0); @@ -553,28 +552,28 @@ Spacing_spanner::breakable_column_spacing (Grob *me, Item *l, Item *r, } ADD_INTERFACE (Spacing_spanner, - "The space taken by a note is dependent on its duration." - " Doubling a duration adds @code{spacing-increment} to the" - " space. The most common shortest note gets" - " @code{shortest-duration-space}. Notes that are even shorter" - " are spaced proportonial to their duration.\n" - "\n" - "Typically, the increment is the width of a black note head." - " In a piece with lots of 8th notes, and some 16th notes, the" - " eighth note gets a 2@tie{}note heads width (i.e., the space" - " following a note is a 1@tie{}note head width). A 16th note" - " is followed by 0.5 note head width. The quarter note is" - " followed by 3@tie{}NHW, the half by 4@tie{}NHW, etc.", - - /* properties */ - "average-spacing-wishes " - "base-shortest-duration " - "common-shortest-duration " - "packed-spacing " - "shortest-duration-space " - "spacing-increment " - "strict-grace-spacing " - "strict-note-spacing " - "uniform-stretching " - ); + "The space taken by a note is dependent on its duration." + " Doubling a duration adds @code{spacing-increment} to the" + " space. The most common shortest note gets" + " @code{shortest-duration-space}. Notes that are even shorter" + " are spaced proportonial to their duration.\n" + "\n" + "Typically, the increment is the width of a black note head." + " In a piece with lots of 8th notes, and some 16th notes, the" + " eighth note gets a 2@tie{}note heads width (i.e., the space" + " following a note is a 1@tie{}note head width). A 16th note" + " is followed by 0.5 note head width. The quarter note is" + " followed by 3@tie{}NHW, the half by 4@tie{}NHW, etc.", + + /* properties */ + "average-spacing-wishes " + "base-shortest-duration " + "common-shortest-duration " + "packed-spacing " + "shortest-duration-space " + "spacing-increment " + "strict-grace-spacing " + "strict-note-spacing " + "uniform-stretching " + ); diff --git a/lily/span-arpeggio-engraver.cc b/lily/span-arpeggio-engraver.cc index adb465b382..38df515034 100644 --- a/lily/span-arpeggio-engraver.cc +++ b/lily/span-arpeggio-engraver.cc @@ -42,7 +42,7 @@ protected: private: Item *span_arpeggio_; - vector<Grob*> arpeggios_; + vector<Grob *> arpeggios_; }; Span_arpeggio_engraver::Span_arpeggio_engraver () @@ -53,7 +53,7 @@ Span_arpeggio_engraver::Span_arpeggio_engraver () void Span_arpeggio_engraver::acknowledge_arpeggio (Grob_info info) { - if (info.origin_contexts (this).size ()) // huh? what's this test for? + if (info.origin_contexts (this).size ()) // huh? what's this test for? arpeggios_.push_back (info.grob ()); } @@ -81,28 +81,27 @@ Span_arpeggio_engraver::stop_translation_timestep () if (span_arpeggio_) { /* - we do this very late, to make sure we also catch `extra' - side-pos support like accidentals. + we do this very late, to make sure we also catch `extra' + side-pos support like accidentals. */ for (vsize j = 0; j < arpeggios_.size (); j++) - { - extract_grob_set (arpeggios_[j], "stems", stems); - for (vsize i = 0; i < stems.size (); i++) - Pointer_group_interface::add_grob (span_arpeggio_, ly_symbol2scm ("stems"), - stems[i]); - - extract_grob_set (arpeggios_[j], "side-support-elements", sses); - for (vsize i = 0; i < sses.size (); i++) - Pointer_group_interface::add_grob (span_arpeggio_, ly_symbol2scm ("side-support-elements"), - sses[i]); - - /* - we can't kill the children, since we don't want to the - previous note to bump into the span arpeggio; so we make - it transparent. */ - arpeggios_[j]->set_property ("transparent", SCM_BOOL_T); - } - + { + extract_grob_set (arpeggios_[j], "stems", stems); + for (vsize i = 0; i < stems.size (); i++) + Pointer_group_interface::add_grob (span_arpeggio_, ly_symbol2scm ("stems"), + stems[i]); + + extract_grob_set (arpeggios_[j], "side-support-elements", sses); + for (vsize i = 0; i < sses.size (); i++) + Pointer_group_interface::add_grob (span_arpeggio_, ly_symbol2scm ("side-support-elements"), + sses[i]); + + /* + we can't kill the children, since we don't want to the + previous note to bump into the span arpeggio; so we make + it transparent. */ + arpeggios_[j]->set_property ("transparent", SCM_BOOL_T); + } span_arpeggio_->set_parent (arpeggios_[0]->get_parent (Y_AXIS), Y_AXIS); span_arpeggio_ = 0; @@ -114,15 +113,15 @@ Span_arpeggio_engraver::stop_translation_timestep () ADD_ACKNOWLEDGER (Span_arpeggio_engraver, arpeggio); ADD_TRANSLATOR (Span_arpeggio_engraver, - /* doc */ - "Make arpeggios that span multiple staves.", + /* doc */ + "Make arpeggios that span multiple staves.", - /* create */ - "Arpeggio ", + /* create */ + "Arpeggio ", - /* read */ - "connectArpeggios ", + /* read */ + "connectArpeggios ", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/span-bar-engraver.cc b/lily/span-bar-engraver.cc index 5378eab765..6d145898f3 100644 --- a/lily/span-bar-engraver.cc +++ b/lily/span-bar-engraver.cc @@ -33,7 +33,7 @@ dependencies to the spanbars. class Span_bar_engraver : public Engraver { Item *spanbar_; - vector<Item*> bars_; + vector<Item *> bars_; public: TRANSLATOR_DECLARATIONS (Span_bar_engraver); @@ -57,11 +57,11 @@ Span_bar_engraver::acknowledge_bar_line (Grob_info i) bars_.push_back (it); if (bars_.size () >= 2 && !spanbar_) - { - spanbar_ = make_item ("SpanBar", SCM_EOL); + { + spanbar_ = make_item ("SpanBar", SCM_EOL); - spanbar_->set_parent (bars_[0], X_AXIS); - } + spanbar_->set_parent (bars_[0], X_AXIS); + } } } @@ -71,12 +71,12 @@ Span_bar_engraver::stop_translation_timestep () if (spanbar_) { for (vsize i = 0; i < bars_.size (); i++) - Span_bar::add_bar (spanbar_, bars_[i]); + Span_bar::add_bar (spanbar_, bars_[i]); SCM vissym = ly_symbol2scm ("break-visibility"); SCM vis = bars_[0]->internal_get_property (vissym); if (ly_is_equal (spanbar_->internal_get_property (vissym), vis)) - spanbar_->set_property (vissym, vis); + spanbar_->set_property (vissym, vis); spanbar_ = 0; } @@ -87,16 +87,16 @@ Span_bar_engraver::stop_translation_timestep () ADD_ACKNOWLEDGER (Span_bar_engraver, bar_line); ADD_TRANSLATOR (Span_bar_engraver, - /* doc */ - "Make cross-staff bar lines: It catches all normal bar lines" - " and draws a single span bar across them.", + /* doc */ + "Make cross-staff bar lines: It catches all normal bar lines" + " and draws a single span bar across them.", - /* create */ - "SpanBar ", + /* create */ + "SpanBar ", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/span-bar.cc b/lily/span-bar.cc index 00e22fb085..4cc9971d5d 100644 --- a/lily/span-bar.cc +++ b/lily/span-bar.cc @@ -30,7 +30,6 @@ #include "pointer-group-interface.hh" #include "staff-symbol-referencer.hh" - void Span_bar::add_bar (Grob *me, Grob *b) { @@ -77,9 +76,9 @@ Span_bar::print (SCM smobbed_me) Grob *bar = elements[i]; Interval ext = Bar_line::bar_y_extent (bar, refp); if (Grob *staff = Staff_symbol_referencer::get_staff_symbol (bar)) - ext.unite (staff->extent (refp, Y_AXIS)); + ext.unite (staff->extent (refp, Y_AXIS)); if (ext.is_empty ()) - continue; + continue; extents.push_back (ext); make_span_bar.push_back (to_boolean (bar->get_property ("allow-span-bar"))); @@ -97,28 +96,28 @@ Span_bar::print (SCM smobbed_me) Interval prev_extent = extents[i - 1]; Interval ext = extents[i]; if (!prev_extent.is_empty ()) - { - Interval l (prev_extent [UP], - ext[DOWN]); - - if (l.is_empty () || !make_span_bar[i]) - { - /* There is overlap between the bar lines. Do nothing. */ - } - else - { - Stencil interbar = Bar_line::compound_barline (model_bar, - glyph_string, - l, - false); - span_bar.add_stencil (interbar); - } - } + { + Interval l (prev_extent [UP], + ext[DOWN]); + + if (l.is_empty () || !make_span_bar[i]) + { + /* There is overlap between the bar lines. Do nothing. */ + } + else + { + Stencil interbar = Bar_line::compound_barline (model_bar, + glyph_string, + l, + false); + span_bar.add_stencil (interbar); + } + } prev_extent = ext; } span_bar.translate_axis (- me->relative_coordinate (refp, Y_AXIS), - Y_AXIS); + Y_AXIS); return span_bar.smobbed_copy (); } @@ -137,8 +136,8 @@ Span_bar::width (SCM smob) /* urg. */ - Stencil m = - Bar_line::compound_barline (me, gl, Interval (-20 PT, 20 PT), false); + Stencil m + = Bar_line::compound_barline (me, gl, Interval (-20 PT, 20 PT), false); return ly_interval2scm (m.extent (X_AXIS)); } @@ -175,9 +174,7 @@ Span_bar::center_on_spanned_callback (SCM smob) return scm_from_double (i.center ()); } - - -MAKE_SCHEME_CALLBACK(Span_bar, calc_glyph_name, 1); +MAKE_SCHEME_CALLBACK (Span_bar, calc_glyph_name, 1); SCM Span_bar::calc_glyph_name (SCM smob) { @@ -211,7 +208,7 @@ Span_bar::calc_glyph_name (SCM smob) type = ".|"; else if (type == ":|S" || type == ":|S.") type = "|."; - else if (type == ":|S|:" || type == ":|S.|:") + else if (type == ":|S|:" || type == ":|S.|:") type = "|._.|"; else if (type == "'") type = ""; @@ -226,16 +223,16 @@ Span_bar::get_spanned_interval (Grob *me) } ADD_INTERFACE (Span_bar, - "A bar line that is spanned between other barlines. This" - " interface is used for bar lines that connect different" - " staves.", - - /* properties */ - "glyph-name " - "elements " - "pure-Y-common " - "pure-relevant-grobs " - "pure-relevant-items " - "pure-relevant-spanners " - ); + "A bar line that is spanned between other barlines. This" + " interface is used for bar lines that connect different" + " staves.", + + /* properties */ + "glyph-name " + "elements " + "pure-Y-common " + "pure-relevant-grobs " + "pure-relevant-items " + "pure-relevant-spanners " + ); diff --git a/lily/spanner-break-forbid-engraver.cc b/lily/spanner-break-forbid-engraver.cc index a37056ba8d..319361bd58 100644 --- a/lily/spanner-break-forbid-engraver.cc +++ b/lily/spanner-break-forbid-engraver.cc @@ -17,8 +17,6 @@ along with LilyPond. If not, see <http://www.gnu.org/licenses/>. */ - - #include "engraver.hh" #include "international.hh" #include "spanner.hh" @@ -31,7 +29,7 @@ class Spanner_break_forbid_engraver : public Engraver { TRANSLATOR_DECLARATIONS (Spanner_break_forbid_engraver); - vector<Spanner*> running_spanners_; + vector<Spanner *> running_spanners_; protected: DECLARE_ACKNOWLEDGER (unbreakable_spanner); DECLARE_END_ACKNOWLEDGER (unbreakable_spanner); @@ -39,7 +37,6 @@ protected: void process_music (); }; - void Spanner_break_forbid_engraver::process_music () { @@ -52,8 +49,8 @@ Spanner_break_forbid_engraver::process_music () void Spanner_break_forbid_engraver::acknowledge_end_unbreakable_spanner (Grob_info gi) { - vector<Spanner*>::iterator i = find (running_spanners_.begin (), running_spanners_.end (), - gi.spanner ()); + vector<Spanner *>::iterator i = find (running_spanners_.begin (), running_spanners_.end (), + gi.spanner ()); if (i != running_spanners_.end ()) running_spanners_.erase (i); } @@ -69,19 +66,18 @@ Spanner_break_forbid_engraver::Spanner_break_forbid_engraver () { } - ADD_END_ACKNOWLEDGER (Spanner_break_forbid_engraver, unbreakable_spanner); ADD_ACKNOWLEDGER (Spanner_break_forbid_engraver, unbreakable_spanner); ADD_TRANSLATOR (Spanner_break_forbid_engraver, - /* doc */ - "Forbid breaks in certain spanners.", + /* doc */ + "Forbid breaks in certain spanners.", - /* create */ - "", + /* create */ + "", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/spanner-scheme.cc b/lily/spanner-scheme.cc index f2a9f0f939..65c1c261cd 100644 --- a/lily/spanner-scheme.cc +++ b/lily/spanner-scheme.cc @@ -2,7 +2,7 @@ This file is part of LilyPond, the GNU music typesetter. Copyright (C) 2007--2011 Han-Wen Nienhuys <hanwen@lilypond.org> - + LilyPond is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,9 +22,9 @@ #include "item.hh" LY_DEFINE (ly_spanner_bound, "ly:spanner-bound", - 2, 0, 0, (SCM spanner, SCM dir), - "Get one of the bounds of @var{spanner}. @var{dir} is @code{-1}" - " for left, and @code{1} for right.") + 2, 0, 0, (SCM spanner, SCM dir), + "Get one of the bounds of @var{spanner}. @var{dir} is @code{-1}" + " for left, and @code{1} for right.") { LY_ASSERT_TYPE (unsmob_spanner, spanner, 1); LY_ASSERT_TYPE (is_direction, dir, 2); @@ -33,9 +33,9 @@ LY_DEFINE (ly_spanner_bound, "ly:spanner-bound", } LY_DEFINE (ly_spanner_set_bound_x, "ly:spanner-set-bound!", - 3, 0, 0, (SCM spanner, SCM dir, SCM item), - "Set grob @var{item} as bound in direction @var{dir} for" - " @var{spanner}.") + 3, 0, 0, (SCM spanner, SCM dir, SCM item), + "Set grob @var{item} as bound in direction @var{dir} for" + " @var{spanner}.") { LY_ASSERT_TYPE (unsmob_spanner, spanner, 1); LY_ASSERT_TYPE (is_direction, dir, 2); @@ -48,8 +48,8 @@ LY_DEFINE (ly_spanner_set_bound_x, "ly:spanner-set-bound!", /* TODO: maybe we should return a vector -- random access is more logical for this list? */ LY_DEFINE (ly_spanner_broken_into, "ly:spanner-broken-into", - 1, 0, 0, (SCM spanner), - "Return broken-into list for @var{spanner}.") + 1, 0, 0, (SCM spanner), + "Return broken-into list for @var{spanner}.") { LY_ASSERT_TYPE (unsmob_spanner, spanner, 1); Spanner *me = dynamic_cast<Spanner *> (unsmob_grob (spanner)); @@ -61,8 +61,8 @@ LY_DEFINE (ly_spanner_broken_into, "ly:spanner-broken-into", } LY_DEFINE (ly_spanner_p, "ly:spanner?", - 1, 0, 0, (SCM g), - "Is @var{g} a spanner object?") + 1, 0, 0, (SCM g), + "Is @var{g} a spanner object?") { Grob *me = unsmob_grob (g); bool b = dynamic_cast<Spanner *> (me); diff --git a/lily/spanner.cc b/lily/spanner.cc index 18a7e645f5..822a7203aa 100644 --- a/lily/spanner.cc +++ b/lily/spanner.cc @@ -42,38 +42,37 @@ Spanner::do_break_processing () if (!left || !right) return; - if (get_system () || is_broken ()) return; if (left == right) { /* - If we have a spanner spanning one column, we must break it - anyway because it might provide a parent for another item. */ + If we have a spanner spanning one column, we must break it + anyway because it might provide a parent for another item. */ Direction d = LEFT; do - { - Item *bound = left->find_prebroken_piece (d); - if (!bound) - programming_error ("no broken bound"); - else if (bound->get_system ()) - { - Spanner *span = dynamic_cast<Spanner *> (clone ()); - span->set_bound (LEFT, bound); - span->set_bound (RIGHT, bound); - - assert (span->get_system ()); - span->get_system ()->typeset_grob (span); - broken_intos_.push_back (span); - } - } + { + Item *bound = left->find_prebroken_piece (d); + if (!bound) + programming_error ("no broken bound"); + else if (bound->get_system ()) + { + Spanner *span = dynamic_cast<Spanner *> (clone ()); + span->set_bound (LEFT, bound); + span->set_bound (RIGHT, bound); + + assert (span->get_system ()); + span->get_system ()->typeset_grob (span); + broken_intos_.push_back (span); + } + } while ((flip (&d)) != LEFT); } else { - System *root = get_root_system (this); - vector<Item*> break_points = root->broken_col_range (left, right); + System *root = get_root_system (this); + vector<Item *> break_points = root->broken_col_range (left, right); break_points.insert (break_points.begin () + 0, left); break_points.push_back (right); @@ -82,62 +81,61 @@ Spanner::do_break_processing () parent_rank_slice.set_full (); /* - Check if our parent in X-direction spans equally wide - or wider than we do. + Check if our parent in X-direction spans equally wide + or wider than we do. */ for (int a = X_AXIS; a < NO_AXES; a++) - { - if (Spanner *parent = dynamic_cast<Spanner *> (get_parent ((Axis)a))) - parent_rank_slice.intersect (parent->spanned_rank_interval ()); - } + { + if (Spanner *parent = dynamic_cast<Spanner *> (get_parent ((Axis)a))) + parent_rank_slice.intersect (parent->spanned_rank_interval ()); + } for (vsize i = 1; i < break_points.size (); i++) - { - Drul_array<Item *> bounds; - bounds[LEFT] = break_points[i - 1]; - bounds[RIGHT] = break_points[i]; - Direction d = LEFT; - do - { - if (!bounds[d]->get_system ()) - bounds[d] = bounds[d]->find_prebroken_piece (- d); - } - while ((flip (&d)) != LEFT); - - if (!bounds[LEFT] || ! bounds[RIGHT]) - { - programming_error ("bounds of this piece aren't breakable. "); - continue; - } - - bool ok = parent_rank_slice.contains (bounds[LEFT]->get_column ()->get_rank ()); - ok = ok && parent_rank_slice.contains (bounds[RIGHT]->get_column ()->get_rank ()); - - if (!ok) - { - programming_error (to_string ("Spanner `%s' is not fully contained in parent spanner. Ignoring orphaned part", - name ().c_str ())); - continue; - } - - - Spanner *span = dynamic_cast<Spanner *> (clone ()); - span->set_bound (LEFT, bounds[LEFT]); - span->set_bound (RIGHT, bounds[RIGHT]); - - if (!bounds[LEFT]->get_system () - || !bounds[RIGHT]->get_system () - || bounds[LEFT]->get_system () != bounds[RIGHT]->get_system ()) - { - programming_error ("bounds of spanner are invalid"); - span->suicide (); - } - else - { - bounds[LEFT]->get_system ()->typeset_grob (span); - broken_intos_.push_back (span); - } - } + { + Drul_array<Item *> bounds; + bounds[LEFT] = break_points[i - 1]; + bounds[RIGHT] = break_points[i]; + Direction d = LEFT; + do + { + if (!bounds[d]->get_system ()) + bounds[d] = bounds[d]->find_prebroken_piece (- d); + } + while ((flip (&d)) != LEFT); + + if (!bounds[LEFT] || ! bounds[RIGHT]) + { + programming_error ("bounds of this piece aren't breakable. "); + continue; + } + + bool ok = parent_rank_slice.contains (bounds[LEFT]->get_column ()->get_rank ()); + ok = ok && parent_rank_slice.contains (bounds[RIGHT]->get_column ()->get_rank ()); + + if (!ok) + { + programming_error (to_string ("Spanner `%s' is not fully contained in parent spanner. Ignoring orphaned part", + name ().c_str ())); + continue; + } + + Spanner *span = dynamic_cast<Spanner *> (clone ()); + span->set_bound (LEFT, bounds[LEFT]); + span->set_bound (RIGHT, bounds[RIGHT]); + + if (!bounds[LEFT]->get_system () + || !bounds[RIGHT]->get_system () + || bounds[LEFT]->get_system () != bounds[RIGHT]->get_system ()) + { + programming_error ("bounds of spanner are invalid"); + span->suicide (); + } + else + { + bounds[LEFT]->get_system ()->typeset_grob (span); + broken_intos_.push_back (span); + } + } } vector_sort (broken_intos_, Spanner::less); for (vsize i = broken_intos_.size (); i--;) @@ -157,7 +155,7 @@ Spanner::set_my_columns () do { if (!spanned_drul_[i]->get_system ()) - set_bound (i, spanned_drul_[i]->find_prebroken_piece ((Direction) -i)); + set_bound (i, spanned_drul_[i]->find_prebroken_piece ((Direction) - i)); } while (flip (&i) != LEFT); } @@ -178,10 +176,9 @@ Interval_t<Moment> Spanner::spanned_time () const { return spanned_time_interval (spanned_drul_[LEFT], - spanned_drul_[RIGHT]); + spanned_drul_[RIGHT]); } - Item * Spanner::get_bound (Direction d) const { @@ -198,7 +195,7 @@ Spanner::set_bound (Direction d, Grob *s) Item *i = dynamic_cast<Item *> (s); if (!i) { - programming_error ("must have Item for spanner bound of " + name()); + programming_error ("must have Item for spanner bound of " + name ()); return; } @@ -244,7 +241,7 @@ Spanner::spanner_length () const Drul_array<SCM> bounds (get_property ("left-bound-info"), get_property ("right-bound-info")); - Direction d = LEFT; + Direction d = LEFT; do lr[d] = robust_scm2double (ly_assoc_get (ly_symbol2scm ("X"), bounds[d], SCM_BOOL_F), -d); @@ -289,7 +286,7 @@ Spanner::broken_neighbor (Direction d) const return 0; vsize k = get_break_index (); - Spanner *orig = dynamic_cast<Spanner*> (original_); + Spanner *orig = dynamic_cast<Spanner *> (original_); int j = int (k) + d; if (j < 0 || vsize (j) >= orig->broken_intos_.size ()) return 0; @@ -331,9 +328,9 @@ Spanner::get_broken_left_end_align () const && sc->break_status_dir () == RIGHT) { /* - We used to do a full search for the Break_align_item. - But that doesn't make a difference, since the Paper_column - is likely to contain only a Break_align_item. + We used to do a full search for the Break_align_item. + But that doesn't make a difference, since the Paper_column + is likely to contain only a Break_align_item. */ return sc->extent (sc, X_AXIS)[RIGHT]; } @@ -383,26 +380,26 @@ Spanner::set_spacing_rods (SCM smob) Rod r; Spanner *sp = dynamic_cast<Spanner *> (me); System *root = get_root_system (me); - Drul_array<Item*> bounds (sp->get_bound (LEFT), - sp->get_bound (RIGHT)); + Drul_array<Item *> bounds (sp->get_bound (LEFT), + sp->get_bound (RIGHT)); if (!bounds[LEFT] || !bounds[RIGHT]) - return SCM_UNSPECIFIED; + return SCM_UNSPECIFIED; - vector<Item*> cols (root->broken_col_range (bounds[LEFT]->get_column (), - bounds[RIGHT]->get_column ())); + vector<Item *> cols (root->broken_col_range (bounds[LEFT]->get_column (), + bounds[RIGHT]->get_column ())); if (cols.size ()) - { - Rod r ; - r.item_drul_[LEFT] = sp->get_bound (LEFT); - r.item_drul_[RIGHT] = cols[0]->find_prebroken_piece (LEFT); - r.distance_ = robust_scm2double (num_length, 0); - r.add_to_cols (); - - r.item_drul_[LEFT] = cols.back ()->find_prebroken_piece (RIGHT); - r.item_drul_[RIGHT] = sp->get_bound (RIGHT); - r.add_to_cols (); - } + { + Rod r; + r.item_drul_[LEFT] = sp->get_bound (LEFT); + r.item_drul_[RIGHT] = cols[0]->find_prebroken_piece (LEFT); + r.distance_ = robust_scm2double (num_length, 0); + r.add_to_cols (); + + r.item_drul_[LEFT] = cols.back ()->find_prebroken_piece (RIGHT); + r.item_drul_[RIGHT] = sp->get_bound (RIGHT); + r.add_to_cols (); + } r.distance_ = robust_scm2double (num_length, 0); r.item_drul_[LEFT] = sp->get_bound (LEFT); @@ -475,7 +472,7 @@ Spanner::bounds_width (SCM grob) Grob *common = me->get_bound (LEFT)->common_refpoint (me->get_bound (RIGHT), X_AXIS); Interval w (me->get_bound (LEFT)->relative_coordinate (common, X_AXIS), - me->get_bound (RIGHT)->relative_coordinate (common, X_AXIS)); + me->get_bound (RIGHT)->relative_coordinate (common, X_AXIS)); w -= me->relative_coordinate (common, X_AXIS); @@ -537,17 +534,17 @@ Spanner::cache_pure_property (SCM sym, int start, int end, SCM val) } ADD_INTERFACE (Spanner, - "Some objects are horizontally spanned between objects. For" - " example, slurs, beams, ties, etc. These grobs form a subtype" - " called @code{Spanner}. All spanners have two span points" - " (these must be @code{Item} objects), one on the left and one" - " on the right. The left bound is also the X@tie{}reference" - " point of the spanner.", - - /* properties */ - "normalized-endpoints " - "minimum-length " + "Some objects are horizontally spanned between objects. For" + " example, slurs, beams, ties, etc. These grobs form a subtype" + " called @code{Spanner}. All spanners have two span points" + " (these must be @code{Item} objects), one on the left and one" + " on the right. The left bound is also the X@tie{}reference" + " point of the spanner.", + + /* properties */ + "normalized-endpoints " + "minimum-length " "spanner-broken " "spanner-id " - "to-barline " - ); + "to-barline " + ); diff --git a/lily/spring-smob.cc b/lily/spring-smob.cc index a679eeae5f..8e263d0694 100644 --- a/lily/spring-smob.cc +++ b/lily/spring-smob.cc @@ -39,6 +39,6 @@ Spring::print_smob (SCM, SCM p, scm_print_state *) SCM Spring::equal_p (SCM a, SCM b) { - return a == b? SCM_BOOL_T : SCM_BOOL_F; + return a == b ? SCM_BOOL_T : SCM_BOOL_F; } diff --git a/lily/spring.cc b/lily/spring.cc index c576da3743..fc5b18f781 100644 --- a/lily/spring.cc +++ b/lily/spring.cc @@ -57,16 +57,15 @@ Spring::update_blocking_force () // Conceptually, this should be +inf, but 0.0 meets the requirements // of Simple_spacer and creates fewer cases of 0.0*inf to handle. blocking_force_ = 0.0; + else if (inverse_compress_strength_ > 0.0) + blocking_force_ = (min_distance_ - distance_) / inverse_compress_strength_; else - if (inverse_compress_strength_ > 0.0) - blocking_force_ = (min_distance_ - distance_) / inverse_compress_strength_; - else - blocking_force_ = 0.0; + blocking_force_ = 0.0; } /* scale a spring, but in a way that doesn't violate min_distance */ void -Spring::operator*= (Real r) +Spring::operator *= (Real r) { distance_ = max (min_distance_, distance_ * r); inverse_compress_strength_ = max (0.0, distance_ - min_distance_); @@ -75,7 +74,7 @@ Spring::operator*= (Real r) } bool -Spring::operator> (Spring const &other) const +Spring::operator > (Spring const &other) const { return blocking_force_ > other.blocking_force_; } @@ -203,7 +202,7 @@ Spring::length (Real f) const Real force = max (f, blocking_force_); Real inv_k = force < 0.0 ? inverse_compress_strength_ : inverse_stretch_strength_; - if (isinf(force)) + if (isinf (force)) { programming_error ("cruelty to springs"); force = 0.0; diff --git a/lily/staff-collecting-engraver.cc b/lily/staff-collecting-engraver.cc index 29ddd8d70b..b8ab0f593f 100644 --- a/lily/staff-collecting-engraver.cc +++ b/lily/staff-collecting-engraver.cc @@ -58,15 +58,15 @@ ADD_ACKNOWLEDGER (Staff_collecting_engraver, staff_symbol); ADD_END_ACKNOWLEDGER (Staff_collecting_engraver, staff_symbol); ADD_TRANSLATOR (Staff_collecting_engraver, - /* doc */ - "Maintain the @code{stavesFound} variable.", + /* doc */ + "Maintain the @code{stavesFound} variable.", - /* create */ - "", + /* create */ + "", - /* read */ - "stavesFound ", + /* read */ + "stavesFound ", - /* write */ - "stavesFound " - ); + /* write */ + "stavesFound " + ); diff --git a/lily/staff-grouper-interface.cc b/lily/staff-grouper-interface.cc index 803e1ee82d..4099ebfbd2 100644 --- a/lily/staff-grouper-interface.cc +++ b/lily/staff-grouper-interface.cc @@ -32,15 +32,15 @@ Staff_grouper_interface::maybe_pure_within_group (Grob *me, Grob *child, bool pu { extract_grob_set (me, "elements", elts); - vector<Grob*>::const_iterator i = find (elts, child); + vector<Grob *>::const_iterator i = find (elts, child); if (i == elts.end ()) return false; for (++i; i != elts.end (); ++i) if (Page_layout_problem::is_spaceable (*i) - && ((pure && !Hara_kiri_group_spanner::request_suicide (*i, start, end)) - || (!pure && (*i)->is_live ()))) + && ((pure && !Hara_kiri_group_spanner::request_suicide (*i, start, end)) + || (!pure && (*i)->is_live ()))) return me == unsmob_grob ((*i)->get_object ("staff-grouper")); // If there was no spaceable, living child after me, I don't @@ -49,10 +49,10 @@ Staff_grouper_interface::maybe_pure_within_group (Grob *me, Grob *child, bool pu } ADD_INTERFACE (Staff_grouper_interface, - "A grob that collects staves together.", + "A grob that collects staves together.", - /* properties */ - "staff-staff-spacing " - "staffgroup-staff-spacing " - ); + /* properties */ + "staff-staff-spacing " + "staffgroup-staff-spacing " + ); diff --git a/lily/staff-performer.cc b/lily/staff-performer.cc index 6d621a79a3..6d0595f54b 100644 --- a/lily/staff-performer.cc +++ b/lily/staff-performer.cc @@ -48,9 +48,9 @@ private: void set_instrument_name (string voice); void set_instrument (int channel, string voice); int get_channel (string instrument); - Audio_staff* get_audio_staff (string voice); - Audio_staff* new_audio_staff (string voice); - Audio_dynamic* get_dynamic (string voice); + Audio_staff *get_audio_staff (string voice); + Audio_staff *new_audio_staff (string voice); + Audio_dynamic *get_dynamic (string voice); string instrument_string_; int channel_; @@ -58,9 +58,9 @@ private: Audio_text *instrument_name_; Audio_text *name_; Audio_tempo *tempo_; - map<string, Audio_staff*> staff_map_; + map<string, Audio_staff *> staff_map_; map<string, int> channel_map_; - map<string, Audio_dynamic*> dynamic_map_; + map<string, Audio_dynamic *> dynamic_map_; // Would prefer to have the following two items be // members of the containing class Performance, // so they can be reset for each new midi file output. @@ -77,24 +77,24 @@ int Staff_performer::staff_performer_count_ = 0; #include "translator.icc" ADD_TRANSLATOR (Staff_performer, - /* doc */ - "", + /* doc */ + "", - /* create */ - "", + /* create */ + "", - /* read */ - "", + /* read */ + "", - /* write */ - ""); + /* write */ + ""); Staff_performer::Staff_performer () - : channel_ (-1) - , instrument_ (0) - , instrument_name_ (0) - , name_ (0) - , tempo_ (0) + : channel_ (-1), + instrument_ (0), + instrument_name_ (0), + name_ (0), + tempo_ (0) { } @@ -105,20 +105,20 @@ Staff_performer::~Staff_performer () void Staff_performer::initialize () { - ++staff_performer_count_; + ++staff_performer_count_; } -Audio_staff* +Audio_staff * Staff_performer::new_audio_staff (string voice) { - Audio_staff* audio_staff = new Audio_staff; + Audio_staff *audio_staff = new Audio_staff; audio_staff->merge_unisons_ = to_boolean (get_property ("midiMergeUnisons")); string track_name = context ()->id_string () + ":" + voice; if (track_name != ":") { name_ = new Audio_text (Audio_text::TRACK_NAME, context ()->id_string () - + ":" + voice); + + ":" + voice); audio_staff->add_audio_item (name_); announce_element (Audio_element_info (name_, 0)); } @@ -129,7 +129,7 @@ Staff_performer::new_audio_staff (string voice) return audio_staff; } -Audio_staff* +Audio_staff * Staff_performer::get_audio_staff (string voice) { SCM channel_mapping = get_property ("midiChannelMapping"); @@ -137,10 +137,10 @@ Staff_performer::get_audio_staff (string voice) && staff_map_.size ()) return staff_map_.begin ()->second; - map<string, Audio_staff*>::const_iterator i = staff_map_.find (voice); + map<string, Audio_staff *>::const_iterator i = staff_map_.find (voice); if (i != staff_map_.end ()) return i->second; - map<string, Audio_staff*>::const_iterator e = staff_map_.find (""); + map<string, Audio_staff *>::const_iterator e = staff_map_.find (""); if (staff_map_.size () == 1 && e != staff_map_.end ()) { staff_map_[voice] = e->second; @@ -149,10 +149,10 @@ Staff_performer::get_audio_staff (string voice) return new_audio_staff (voice); } -Audio_dynamic* +Audio_dynamic * Staff_performer::get_dynamic (string voice) { - map<string, Audio_dynamic*>::const_iterator i = dynamic_map_.find (voice); + map<string, Audio_dynamic *>::const_iterator i = dynamic_map_.find (voice); if (i != dynamic_map_.end ()) return i->second; return 0; @@ -169,7 +169,7 @@ Staff_performer::set_instrument (int channel, string voice) instrument_ = new Audio_instrument (instrument_string_); instrument_->channel_ = channel; announce_element (Audio_element_info (instrument_, 0)); - Audio_staff* audio_staff = get_audio_staff (voice); + Audio_staff *audio_staff = get_audio_staff (voice); audio_staff->add_audio_item (instrument_); SCM proc = ly_lily_module_constant ("percussion?"); SCM drums = scm_call_1 (proc, ly_symbol2scm (instrument_string_.c_str ())); @@ -180,7 +180,7 @@ void Staff_performer::set_instrument_name (string voice) { instrument_name_ = new Audio_text (Audio_text::INSTRUMENT_NAME, - instrument_string_); + instrument_string_); announce_element (Audio_element_info (instrument_name_, 0)); get_audio_staff (voice)->add_audio_item (instrument_name_); } @@ -229,8 +229,8 @@ Staff_performer::get_channel (string instrument) SCM channel_mapping = get_property ("midiChannelMapping"); map<string, int>& channel_map = (channel_mapping != ly_symbol2scm ("instrument")) - ? channel_map_ - : static_channel_map_; + ? channel_map_ + : static_channel_map_; if (channel_mapping == ly_symbol2scm ("staff") && channel_ >= 0) @@ -239,10 +239,10 @@ Staff_performer::get_channel (string instrument) map<string, int>::const_iterator i = channel_map.find (instrument); if (i != channel_map.end ()) return i->second; - + int channel = (channel_mapping == ly_symbol2scm ("staff")) - ? channel_count_++ - : channel_map.size (); + ? channel_count_++ + : channel_map.size (); /* MIDI players tend to ignore instrument settings on channel 10, the percussion channel. */ @@ -256,7 +256,7 @@ Staff_performer::get_channel (string instrument) { warning (_ ("MIDI channel wrapped around")); warning (_ ("remapping modulo 16")); - channel = channel % 16; + channel = channel % 16; } channel_map[instrument] = channel; @@ -269,38 +269,38 @@ Staff_performer::acknowledge_audio_element (Audio_element_info inf) if (Audio_item *ai = dynamic_cast<Audio_item *> (inf.elem_)) { /* map each context (voice) to its own track */ - Context* c = inf.origin_contexts (this)[0]; + Context *c = inf.origin_contexts (this)[0]; string voice; if (c->is_alias (ly_symbol2scm ("Voice"))) - voice = c->id_string (); + voice = c->id_string (); SCM channel_mapping = get_property ("midiChannelMapping"); string str = new_instrument_string (); if (channel_mapping != ly_symbol2scm ("instrument")) - channel_ = get_channel (voice); + channel_ = get_channel (voice); else if (channel_ < 0 && str.empty ()) - channel_ = get_channel (str); + channel_ = get_channel (str); if (str.length ()) - { - if (channel_mapping != ly_symbol2scm ("voice")) - channel_ = get_channel (str); - set_instrument (channel_, voice); - set_instrument_name (voice); - } + { + if (channel_mapping != ly_symbol2scm ("voice")) + channel_ = get_channel (str); + set_instrument (channel_, voice); + set_instrument_name (voice); + } ai->channel_ = channel_; bool encode_dynamics_as_velocity_ = true; if (encode_dynamics_as_velocity_) - { - if (Audio_dynamic *d = dynamic_cast<Audio_dynamic *> (inf.elem_)) - { - dynamic_map_[voice] = d; - // Output volume as velocity: must disable Midi_dynamic output - d->silent_ = true; - } - if (Audio_dynamic *d = get_dynamic (voice)) - if (Audio_note *n = dynamic_cast<Audio_note *> (inf.elem_)) - n->dynamic_ = d; - } - Audio_staff* audio_staff = get_audio_staff (voice); + { + if (Audio_dynamic *d = dynamic_cast<Audio_dynamic *> (inf.elem_)) + { + dynamic_map_[voice] = d; + // Output volume as velocity: must disable Midi_dynamic output + d->silent_ = true; + } + if (Audio_dynamic *d = get_dynamic (voice)) + if (Audio_note *n = dynamic_cast<Audio_note *> (inf.elem_)) + n->dynamic_ = d; + } + Audio_staff *audio_staff = get_audio_staff (voice); audio_staff->add_audio_item (ai); } } diff --git a/lily/staff-spacing.cc b/lily/staff-spacing.cc index ff064b5c0f..2a216bdc6e 100644 --- a/lily/staff-spacing.cc +++ b/lily/staff-spacing.cc @@ -55,24 +55,24 @@ Staff_spacing::optical_correction (Grob *me, Grob *g, Interval bar_height) { Direction d = get_grob_direction (stem); if (Stem::is_normal_stem (stem) && d == DOWN) - { - - /* - can't look at stem-end-position, since that triggers - beam slope computations. - */ - Real stem_start = Stem::head_positions (stem) [d]; - Real stem_end = stem_start + - d * robust_scm2double (stem->get_property ("length"), 7); - - Interval stem_posns (min (stem_start, stem_end), - max (stem_end, stem_start)); - - stem_posns.intersect (bar_height); - - ret = min (abs (stem_posns.length () / 7.0), 1.0); - ret *= robust_scm2double (me->get_property ("stem-spacing-correction"), 1); - } + { + + /* + can't look at stem-end-position, since that triggers + beam slope computations. + */ + Real stem_start = Stem::head_positions (stem) [d]; + Real stem_end = stem_start + + d * robust_scm2double (stem->get_property ("length"), 7); + + Interval stem_posns (min (stem_start, stem_end), + max (stem_end, stem_start)); + + stem_posns.intersect (bar_height); + + ret = min (abs (stem_posns.length () / 7.0), 1.0); + ret *= robust_scm2double (me->get_property ("stem-spacing-correction"), 1); + } } return ret; } @@ -92,23 +92,23 @@ Staff_spacing::bar_y_positions (Grob *bar_grob) string glyph_string = scm_is_string (glyph) ? ly_scm2string (glyph) : ""; if (glyph_string.substr (0, 1) == "|" - || glyph_string.substr (0, 1) == ".") - { - Grob *common = bar_grob->common_refpoint (staff_sym, Y_AXIS); - bar_size = bar_grob->extent (common, Y_AXIS); - bar_size *= 1.0 / Staff_symbol_referencer::staff_space (bar_grob); - } + || glyph_string.substr (0, 1) == ".") + { + Grob *common = bar_grob->common_refpoint (staff_sym, Y_AXIS); + bar_size = bar_grob->extent (common, Y_AXIS); + bar_size *= 1.0 / Staff_symbol_referencer::staff_space (bar_grob); + } } return bar_size; } Real Staff_spacing::next_notes_correction (Grob *me, - Grob *last_grob) + Grob *last_grob) { Interval bar_size = bar_y_positions (last_grob); Grob *orig = me->original () ? me->original () : me; - vector<Item*> note_columns = Spacing_interface::right_note_columns (orig); + vector<Item *> note_columns = Spacing_interface::right_note_columns (orig); Real max_optical = 0.0; @@ -132,20 +132,20 @@ Staff_spacing::get_spacing (Grob *me, Grob *right_col) Interval last_ext; Direction break_dir = me_item->break_status_dir (); Grob *last_grob = Spacing_interface::extremal_break_aligned_grob (me, LEFT, - break_dir, - &last_ext); + break_dir, + &last_ext); if (!last_grob) { /* - TODO: + TODO: - Should insert a adjustable space here? For excercises, you might want to - use a staff without a clef in the beginning. + Should insert a adjustable space here? For excercises, you might want to + use a staff without a clef in the beginning. */ /* - we used to have a warning here, but it generates a lot of - spurious error messages. + we used to have a warning here, but it generates a lot of + spurious error messages. */ return Spring (); } @@ -159,7 +159,7 @@ Staff_spacing::get_spacing (Grob *me, Grob *right_col) { SCM nndef = scm_sloppy_assq (ly_symbol2scm ("next-note"), alist); if (scm_is_pair (nndef)) - space_def = nndef; + space_def = nndef; } if (!scm_is_pair (space_def)) @@ -195,7 +195,6 @@ Staff_spacing::get_spacing (Grob *me, Grob *right_col) ideal = fixed; } - Real optical_correction = next_notes_correction (me, last_grob); Real min_dist = Paper_column::minimum_distance (left_col, right_col); @@ -212,10 +211,10 @@ Staff_spacing::get_spacing (Grob *me, Grob *right_col) } ADD_INTERFACE (Staff_spacing, - "This object calculates spacing details from a breakable" - " symbol (left) to another object. For example, it takes care" - " of optical spacing from a bar line to a note.", + "This object calculates spacing details from a breakable" + " symbol (left) to another object. For example, it takes care" + " of optical spacing from a bar line to a note.", - /* properties */ - "stem-spacing-correction " - ); + /* properties */ + "stem-spacing-correction " + ); diff --git a/lily/staff-symbol-engraver.cc b/lily/staff-symbol-engraver.cc index 55e118245f..a726f21325 100644 --- a/lily/staff-symbol-engraver.cc +++ b/lily/staff-symbol-engraver.cc @@ -84,7 +84,7 @@ Staff_symbol_engraver::process_music () finished_span_ = span_; span_ = 0; if (first_start_) - first_start_ = false; + first_start_ = false; } if (span_events_[START] @@ -99,7 +99,7 @@ Staff_symbol_engraver::start_spanner () { span_ = make_spanner ("StaffSymbol", SCM_EOL); span_->set_bound (LEFT, - unsmob_grob (get_property ("currentCommandColumn"))); + unsmob_grob (get_property ("currentCommandColumn"))); } } @@ -113,9 +113,9 @@ Staff_symbol_engraver::stop_spanner () finished_span_->set_bound (RIGHT, unsmob_grob (get_property ("currentCommandColumn"))); announce_end_grob (finished_span_, - span_events_[STOP] - ? span_events_[STOP]->self_scm () - : SCM_EOL); + span_events_[STOP] + ? span_events_[STOP]->self_scm () + : SCM_EOL); finished_span_ = 0; } @@ -155,15 +155,15 @@ Staff_symbol_engraver::acknowledge_grob (Grob_info s) ADD_ACKNOWLEDGER (Staff_symbol_engraver, grob); ADD_TRANSLATOR (Staff_symbol_engraver, - /* doc */ - "Create the constellation of five (default) staff lines.", + /* doc */ + "Create the constellation of five (default) staff lines.", - /* create */ - "StaffSymbol ", + /* create */ + "StaffSymbol ", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/staff-symbol-referencer-scheme.cc b/lily/staff-symbol-referencer-scheme.cc index e954dd37fe..35cd814f0c 100644 --- a/lily/staff-symbol-referencer-scheme.cc +++ b/lily/staff-symbol-referencer-scheme.cc @@ -30,7 +30,7 @@ LY_DEFINE (ly_grob_staff_position, "ly:grob-staff-position", Grob *g = unsmob_grob (sg); Real pos = Staff_symbol_referencer::get_position (g); - if (fabs (rint (pos) -pos) < 1e-6) // ugh. + if (fabs (rint (pos) - pos) < 1e-6) // ugh. return scm_from_int ((int) my_round (pos)); else return scm_from_double (pos); diff --git a/lily/staff-symbol-referencer.cc b/lily/staff-symbol-referencer.cc index 2939e0c061..f5ac177149 100644 --- a/lily/staff-symbol-referencer.cc +++ b/lily/staff-symbol-referencer.cc @@ -81,7 +81,7 @@ Staff_symbol_referencer::get_position (Grob *me) if (st && c) { Real y = me->relative_coordinate (c, Y_AXIS) - - st->relative_coordinate (c, Y_AXIS); + - st->relative_coordinate (c, Y_AXIS); Real space = Staff_symbol::staff_space (st); p = (space == 0) ? 0 : 2.0 * y / space; return p; @@ -91,7 +91,6 @@ Staff_symbol_referencer::get_position (Grob *me) return robust_scm2double (me->get_property ("staff-position"), p); } - Interval Staff_symbol_referencer::extent_in_staff (Grob *me) { @@ -101,8 +100,8 @@ Staff_symbol_referencer::extent_in_staff (Grob *me) Interval retval; if (st && c) { - retval = me->extent (c, Y_AXIS) - - st->relative_coordinate (c, Y_AXIS); + retval = me->extent (c, Y_AXIS) + - st->relative_coordinate (c, Y_AXIS); } return retval; @@ -154,7 +153,7 @@ Staff_symbol_referencer::set_position (Grob *me, Real p) } Real ss = Staff_symbol_referencer::staff_space (me); - me->translate_axis ((p - oldpos) * ss * 0.5, Y_AXIS); + me->translate_axis ((p - oldpos) * ss * 0.5, Y_AXIS); } /* Half of the height, in staff space, i.e. 2.0 for a normal staff. */ @@ -168,22 +167,22 @@ int compare_position (Grob *const &a, Grob *const &b) { return sign (Staff_symbol_referencer::get_position ((Grob *)a) - - Staff_symbol_referencer::get_position ((Grob *) b)); + - Staff_symbol_referencer::get_position ((Grob *) b)); } bool position_less (Grob *const &a, Grob *const &b) { return Staff_symbol_referencer::get_position (a) - < Staff_symbol_referencer::get_position (b); + < Staff_symbol_referencer::get_position (b); } ADD_INTERFACE (Staff_symbol_referencer, - "An object whose Y@tie{}position is meant relative to a staff" - " symbol. These usually" - " have @code{Staff_symbol_referencer::callback} in their" - " @code{Y-offset-callbacks}.", - - /* properties */ - "staff-position " - ); + "An object whose Y@tie{}position is meant relative to a staff" + " symbol. These usually" + " have @code{Staff_symbol_referencer::callback} in their" + " @code{Y-offset-callbacks}.", + + /* properties */ + "staff-position " + ); diff --git a/lily/staff-symbol.cc b/lily/staff-symbol.cc index d1629dfb24..f80a5c5774 100644 --- a/lily/staff-symbol.cc +++ b/lily/staff-symbol.cc @@ -54,25 +54,25 @@ Staff_symbol::print (SCM smob) { SCM width_scm = me->get_property ("width"); if (d == RIGHT && scm_is_number (width_scm)) - { - /* - don't multiply by Staff_symbol_referencer::staff_space (me), - since that would make aligning staff symbols of different sizes to - one right margin hell. - */ - span_points[RIGHT] = scm_to_double (width_scm); - } + { + /* + don't multiply by Staff_symbol_referencer::staff_space (me), + since that would make aligning staff symbols of different sizes to + one right margin hell. + */ + span_points[RIGHT] = scm_to_double (width_scm); + } else - { - Item *x = sp->get_bound (d); + { + Item *x = sp->get_bound (d); - span_points[d] = x->relative_coordinate (common, X_AXIS); - if (!x->break_status_dir () - && !x->extent (x, X_AXIS).is_empty ()) - span_points[d] += x->extent (x, X_AXIS)[d]; - } + span_points[d] = x->relative_coordinate (common, X_AXIS); + if (!x->break_status_dir () + && !x->extent (x, X_AXIS).is_empty ()) + span_points[d] += x->extent (x, X_AXIS)[d]; + } - span_points[d] -= d* t / 2; + span_points[d] -= d * t / 2; } while (flip (&d) != LEFT); @@ -81,36 +81,35 @@ Staff_symbol::print (SCM smob) SCM line_positions = me->get_property ("line-positions"); Stencil line = Lookup::horizontal_line (span_points - -me->relative_coordinate (common, X_AXIS), - t); + - me->relative_coordinate (common, X_AXIS), + t); Real space = staff_space (me); if (scm_is_pair (line_positions)) { for (SCM s = line_positions; scm_is_pair (s); - s = scm_cdr (s)) - { - Stencil b (line); - b.translate_axis (scm_to_double (scm_car (s)) - * 0.5 * space, Y_AXIS); - m.add_stencil (b); - } + s = scm_cdr (s)) + { + Stencil b (line); + b.translate_axis (scm_to_double (scm_car (s)) + * 0.5 * space, Y_AXIS); + m.add_stencil (b); + } } else { int l = Staff_symbol::line_count (me); Real height = (l - 1) * staff_space (me) / 2; for (int i = 0; i < l; i++) - { - Stencil b (line); - b.translate_axis (height - i * space, Y_AXIS); - m.add_stencil (b); - } + { + Stencil b (line); + b.translate_axis (height - i * space, Y_AXIS); + m.add_stencil (b); + } } return m.smobbed_copy (); } - int Staff_symbol::get_steps (Grob *me) { @@ -150,14 +149,14 @@ Staff_symbol::get_ledger_line_thickness (Grob *me) return z[X_AXIS] * get_line_thickness (me) + z[Y_AXIS] * staff_space (me); } -MAKE_SCHEME_CALLBACK (Staff_symbol, height,1); +MAKE_SCHEME_CALLBACK (Staff_symbol, height, 1); SCM -Staff_symbol::height (SCM smob) +Staff_symbol::height (SCM smob) { Grob *me = unsmob_grob (smob); Real t = me->layout ()->get_dimension (ly_symbol2scm ("line-thickness")); t *= robust_scm2double (me->get_property ("thickness"), 1.0); - + SCM line_positions = me->get_property ("line-positions"); Interval y_ext; @@ -165,8 +164,8 @@ Staff_symbol::height (SCM smob) if (scm_is_pair (line_positions)) { for (SCM s = line_positions; scm_is_pair (s); - s = scm_cdr (s)) - y_ext.add_point (scm_to_double (scm_car (s)) * 0.5 * space); + s = scm_cdr (s)) + y_ext.add_point (scm_to_double (scm_car (s)) * 0.5 * space); } else { @@ -174,7 +173,7 @@ Staff_symbol::height (SCM smob) Real height = (l - 1) * staff_space (me) / 2; y_ext = Interval (-height, height); } - y_ext.widen (t/2); + y_ext.widen (t / 2); return ly_interval2scm (y_ext); } @@ -187,20 +186,20 @@ Staff_symbol::on_line (Grob *me, int pos) Real min_line = HUGE_VAL; Real max_line = -HUGE_VAL; for (SCM s = line_positions; scm_is_pair (s); s = scm_cdr (s)) - { - Real current_line = scm_to_double (scm_car (s)); - if (pos == current_line) - return true; - if (current_line > max_line) - max_line = current_line; - if (current_line < min_line) - min_line = current_line; - - } + { + Real current_line = scm_to_double (scm_car (s)); + if (pos == current_line) + return true; + if (current_line > max_line) + max_line = current_line; + if (current_line < min_line) + min_line = current_line; + + } if (pos < min_line) - return (( (int) (rint (pos - min_line)) % 2) == 0); + return (( (int) (rint (pos - min_line)) % 2) == 0); if (pos > max_line) - return (( (int) (rint (pos - max_line)) % 2) == 0); + return (( (int) (rint (pos - max_line)) % 2) == 0); return false; } @@ -227,18 +226,18 @@ Staff_symbol::line_span (Grob *me) } ADD_INTERFACE (Staff_symbol, - "This spanner draws the lines of a staff. A staff symbol" - " defines a vertical unit, the @emph{staff space}. Quantities" - " that go by a half staff space are called @emph{positions}." - " The center (i.e., middle line or space) is position@tie{}0." - " The length of the symbol may be set by hand through the" - " @code{width} property.", - - /* properties */ - "ledger-line-thickness " - "line-count " - "line-positions " - "staff-space " - "thickness " - "width " - ); + "This spanner draws the lines of a staff. A staff symbol" + " defines a vertical unit, the @emph{staff space}. Quantities" + " that go by a half staff space are called @emph{positions}." + " The center (i.e., middle line or space) is position@tie{}0." + " The length of the symbol may be set by hand through the" + " @code{width} property.", + + /* properties */ + "ledger-line-thickness " + "line-count " + "line-positions " + "staff-space " + "thickness " + "width " + ); diff --git a/lily/stanza-number-align-engraver.cc b/lily/stanza-number-align-engraver.cc index 1acf51f362..bccd68e437 100644 --- a/lily/stanza-number-align-engraver.cc +++ b/lily/stanza-number-align-engraver.cc @@ -32,8 +32,8 @@ public: TRANSLATOR_DECLARATIONS (Stanza_number_align_engraver); protected: - vector<Grob*> lyrics_; - vector<Grob*> stanza_numbers_; + vector<Grob *> lyrics_; + vector<Grob *> stanza_numbers_; DECLARE_ACKNOWLEDGER (lyric_syllable); DECLARE_ACKNOWLEDGER (stanza_number); @@ -73,16 +73,16 @@ ADD_ACKNOWLEDGER (Stanza_number_align_engraver, lyric_syllable); ADD_ACKNOWLEDGER (Stanza_number_align_engraver, stanza_number); ADD_TRANSLATOR (Stanza_number_align_engraver, - /* doc */ - "This engraver ensures that stanza numbers are neatly" - " aligned.", + /* doc */ + "This engraver ensures that stanza numbers are neatly" + " aligned.", - /* create */ - "", + /* create */ + "", - /* read */ - "", + /* read */ + "", - /* write */ - ""); + /* write */ + ""); diff --git a/lily/stanza-number-engraver.cc b/lily/stanza-number-engraver.cc index 0737e969df..d37268d084 100644 --- a/lily/stanza-number-engraver.cc +++ b/lily/stanza-number-engraver.cc @@ -85,15 +85,15 @@ Stanza_number_engraver::stop_translation_timestep () ADD_ACKNOWLEDGER (Stanza_number_engraver, lyric_syllable); ADD_TRANSLATOR (Stanza_number_engraver, - /* doc */ - "Engrave stanza numbers.", + /* doc */ + "Engrave stanza numbers.", - /* create */ - "StanzaNumber ", + /* create */ + "StanzaNumber ", - /* read */ - "stanza ", + /* read */ + "stanza ", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/stem-engraver.cc b/lily/stem-engraver.cc index fb54591147..6890b5b041 100644 --- a/lily/stem-engraver.cc +++ b/lily/stem-engraver.cc @@ -69,52 +69,51 @@ Stem_engraver::make_stem (Grob_info gi) if (tremolo_ev_) { /* Stem tremolo is never applied to a note by default, - it must be requested. But there is a default for the - tremolo value: + it must be requested. But there is a default for the + tremolo value: - c4:8 c c: + c4:8 c c: - the first and last (quarter) note both get one tremolo flag. */ + the first and last (quarter) note both get one tremolo flag. */ int requested_type - = robust_scm2int (tremolo_ev_->get_property ("tremolo-type"), 0); + = robust_scm2int (tremolo_ev_->get_property ("tremolo-type"), 0); SCM f = get_property ("tremoloFlags"); if (!requested_type) - { - if (scm_is_number (f)) - requested_type = scm_to_int (f); - else - requested_type = 8; - } + { + if (scm_is_number (f)) + requested_type = scm_to_int (f); + else + requested_type = 8; + } else - context ()->set_property ("tremoloFlags", scm_from_int (requested_type)); - + context ()->set_property ("tremoloFlags", scm_from_int (requested_type)); /* - we take the duration log from the Event, since the duration-log - for a note head is always <= 2. + we take the duration log from the Event, since the duration-log + for a note head is always <= 2. */ Stream_event *ev = gi.event_cause (); Duration *dur = unsmob_duration (ev->get_property ("duration")); - + int tremolo_flags = intlog2 (requested_type) - 2 - - (dur->duration_log () > 2 ? dur->duration_log () - 2 : 0); + - (dur->duration_log () > 2 ? dur->duration_log () - 2 : 0); if (tremolo_flags <= 0) - { - tremolo_ev_->origin ()->warning (_ ("tremolo duration is too long")); - tremolo_flags = 0; - } + { + tremolo_ev_->origin ()->warning (_ ("tremolo duration is too long")); + tremolo_flags = 0; + } if (tremolo_flags) - { - tremolo_ = make_item ("StemTremolo", tremolo_ev_->self_scm ()); - - /* The number of tremolo flags is the number of flags of the - tremolo-type minus the number of flags of the note itself. */ - tremolo_->set_property ("flag-count", scm_from_int (tremolo_flags)); - tremolo_->set_parent (stem_, X_AXIS); - stem_->set_object ("tremolo-flag", tremolo_->self_scm ()); - tremolo_->set_object ("stem", stem_->self_scm ()); - } + { + tremolo_ = make_item ("StemTremolo", tremolo_ev_->self_scm ()); + + /* The number of tremolo flags is the number of flags of the + tremolo-type minus the number of flags of the note itself. */ + tremolo_->set_property ("flag-count", scm_from_int (tremolo_flags)); + tremolo_->set_parent (stem_, X_AXIS); + stem_->set_object ("tremolo-flag", tremolo_->self_scm ()); + tremolo_->set_object ("stem", stem_->self_scm ()); + } } } @@ -150,11 +149,11 @@ Stem_engraver::acknowledge_rhythmic_head (Grob_info gi) if (dc == -1) dc = 0; - if (ds != dc) + if (ds != dc) { gi.event_cause ()->origin ()->warning (_f ("adding note head to incompatible stem (type = %d/%d)", - ds < 0 ? 1 << -ds : 1, - ds > 0 ? 1 << ds : 1)); + ds < 0 ? 1 << -ds : 1, + ds > 0 ? 1 << ds : 1)); gi.event_cause ()->origin ()->warning (_ ("maybe input should specify polyphonic voices")); } @@ -170,16 +169,16 @@ Stem_engraver::stop_translation_timestep () /* FIXME: junk these properties. */ SCM prop = get_property ("stemLeftBeamCount"); if (scm_is_number (prop)) - { - Stem::set_beaming (stem_, scm_to_int (prop), LEFT); - context ()->unset_property (ly_symbol2scm ("stemLeftBeamCount")); - } + { + Stem::set_beaming (stem_, scm_to_int (prop), LEFT); + context ()->unset_property (ly_symbol2scm ("stemLeftBeamCount")); + } prop = get_property ("stemRightBeamCount"); if (scm_is_number (prop)) - { - Stem::set_beaming (stem_, scm_to_int (prop), RIGHT); - context ()->unset_property (ly_symbol2scm ("stemRightBeamCount")); - } + { + Stem::set_beaming (stem_, scm_to_int (prop), RIGHT); + context ()->unset_property (ly_symbol2scm ("stemRightBeamCount")); + } stem_ = 0; } tremolo_ev_ = 0; @@ -195,19 +194,19 @@ Stem_engraver::listen_tremolo (Stream_event *ev) ADD_ACKNOWLEDGER (Stem_engraver, rhythmic_head); ADD_TRANSLATOR (Stem_engraver, - /* doc */ - "Create stems and single-stem tremolos. It also works" - " together with the beam engraver for overriding beaming.", - - /* create */ - "Stem " - "StemTremolo ", - - /* read */ - "tremoloFlags " - "stemLeftBeamCount " - "stemRightBeamCount ", - - /* write */ - "" - ); + /* doc */ + "Create stems and single-stem tremolos. It also works" + " together with the beam engraver for overriding beaming.", + + /* create */ + "Stem " + "StemTremolo ", + + /* read */ + "tremoloFlags " + "stemLeftBeamCount " + "stemRightBeamCount ", + + /* write */ + "" + ); diff --git a/lily/stem-tremolo.cc b/lily/stem-tremolo.cc index 5a115835ef..2036d9a890 100644 --- a/lily/stem-tremolo.cc +++ b/lily/stem-tremolo.cc @@ -42,23 +42,22 @@ Stem_tremolo::calc_slope (SCM smob) Real dy = 0; SCM s = beam->get_property ("quantized-positions"); if (is_number_pair (s)) - dy = - scm_to_double (scm_car (s)) + scm_to_double (scm_cdr (s)); + dy = - scm_to_double (scm_car (s)) + scm_to_double (scm_cdr (s)); Grob *s2 = Beam::last_normal_stem (beam); Grob *s1 = Beam::first_normal_stem (beam); - + Grob *common = s1->common_refpoint (s2, X_AXIS); - Real dx = s2->relative_coordinate (common, X_AXIS) - - s1->relative_coordinate (common, X_AXIS); + Real dx = s2->relative_coordinate (common, X_AXIS) + - s1->relative_coordinate (common, X_AXIS); return scm_from_double (dx ? dy / dx : 0); } else /* down stems with flags should have more sloped trems (helps avoid flag/stem collisions without making the stem very long) */ - return scm_from_double ( - (Stem::duration_log (stem) >= 3 && get_grob_direction (stem) == DOWN) ? - 0.40 : 0.25); + return scm_from_double ((Stem::duration_log (stem) >= 3 && get_grob_direction (stem) == DOWN) + ? 0.40 : 0.25); } MAKE_SCHEME_CALLBACK (Stem_tremolo, calc_width, 1) @@ -72,7 +71,7 @@ Stem_tremolo::calc_width (SCM smob) bool flag = Stem::duration_log (stem) >= 3 && !beam; /* beamed stems and up-stems with flags have shorter tremolos */ - return scm_from_double (((stemdir == UP && flag) || beam)? 1.0 : 1.5); + return scm_from_double (((stemdir == UP && flag) || beam) ? 1.0 : 1.5); } MAKE_SCHEME_CALLBACK (Stem_tremolo, calc_style, 1) @@ -95,9 +94,9 @@ Stem_tremolo::get_beam_translation (Grob *me) Spanner *beam = Stem::get_beam (stem); return (beam && beam->is_live ()) - ? Beam::get_beam_translation (beam) - : (Staff_symbol_referencer::staff_space (me) - * robust_scm2double (me->get_property ("length-fraction"), 1.0) * 0.81); + ? Beam::get_beam_translation (beam) + : (Staff_symbol_referencer::staff_space (me) + * robust_scm2double (me->get_property ("length-fraction"), 1.0) * 0.81); } Stencil @@ -144,8 +143,6 @@ Stem_tremolo::raw_stencil (Grob *me, Real slope, Direction stemdir) return mol; } - - MAKE_SCHEME_CALLBACK (Stem_tremolo, pure_height, 3); SCM Stem_tremolo::pure_height (SCM smob, SCM, SCM) @@ -179,7 +176,7 @@ Stem_tremolo::vertical_length (Grob *me) { return untranslated_stencil (me, 0.35).extent (Y_AXIS).length (); } - + Stencil Stem_tremolo::untranslated_stencil (Grob *me, Real slope) { @@ -202,7 +199,6 @@ Stem_tremolo::untranslated_stencil (Grob *me, Real slope) return raw_stencil (me, slope, stencil_dir); } - Stencil Stem_tremolo::translated_stencil (Grob *me, Real slope) { @@ -211,7 +207,7 @@ Stem_tremolo::translated_stencil (Grob *me, Real slope) Grob *stem = unsmob_grob (me->get_object ("stem")); if (!stem) return Stencil (); - + Direction stemdir = get_grob_direction (stem); if (stemdir == 0) stemdir = UP; @@ -224,7 +220,7 @@ Stem_tremolo::translated_stencil (Grob *me, Real slope) Real end_y = Stem::stem_end_position (stem) * ss / 2 - - stemdir * max (beam_count, 1) * beam_translation; + - stemdir * max (beam_count, 1) * beam_translation; if (!beam && Stem::duration_log (stem) >= 3) { @@ -252,21 +248,21 @@ SCM Stem_tremolo::print (SCM grob) { Grob *me = unsmob_grob (grob); - + Stencil s = translated_stencil (me, robust_scm2double (me->get_property ("slope"), 0.25)); return s.smobbed_copy (); } ADD_INTERFACE (Stem_tremolo, - "A beam slashing a stem to indicate a tremolo. The property" - " @code{style} can be @code{default} or @code{rectangle}.", + "A beam slashing a stem to indicate a tremolo. The property" + " @code{style} can be @code{default} or @code{rectangle}.", /* properties */ - "beam-thickness " - "beam-width " - "flag-count " - "length-fraction " - "stem " + "beam-thickness " + "beam-width " + "flag-count " + "length-fraction " + "stem " "style " - "slope " - ); + "slope " + ); diff --git a/lily/stem.cc b/lily/stem.cc index 5b1a3d5041..e83ffd9893 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -27,7 +27,7 @@ #include "stem.hh" #include "spanner.hh" -#include <cmath> // rint +#include <cmath> // rint using namespace std; #include "beam.hh" @@ -65,7 +65,7 @@ Stem::set_beaming (Grob *me, int beam_count, Direction d) lst = scm_cons (scm_from_int (i), lst); else lst = SCM_BOOL_F; - + index_set_cell (pair, d, lst); } @@ -89,7 +89,7 @@ Stem::head_positions (Grob *me) { Drul_array<Grob *> e (extremal_heads (me)); return Interval (Staff_symbol_referencer::get_position (e[DOWN]), - Staff_symbol_referencer::get_position (e[UP])); + Staff_symbol_referencer::get_position (e[UP])); } return Interval (); } @@ -100,12 +100,10 @@ Stem::chord_start_y (Grob *me) Interval hp = head_positions (me); if (!hp.is_empty ()) return hp[get_grob_direction (me)] * Staff_symbol_referencer::staff_space (me) - * 0.5; + * 0.5; return 0; } - - void Stem::set_stemend (Grob *me, Real se) { @@ -180,13 +178,13 @@ Stem::extremal_heads (Grob *me) Direction d = LEFT; do - { - if (d * p > d * extpos[d]) - { - exthead[d] = n; - extpos[d] = p; - } - } + { + if (d * p > d * extpos[d]) + { + exthead[d] = n; + extpos[d] = p; + } + } while (flip (&d) != DOWN); } return exthead; @@ -226,23 +224,21 @@ bool Stem::is_invisible (Grob *me) { return !is_normal_stem (me) - && (robust_scm2double (me->get_property ("stemlet-length"), - 0.0) == 0.0); + && (robust_scm2double (me->get_property ("stemlet-length"), + 0.0) == 0.0); } - bool Stem::is_normal_stem (Grob *me) { return head_count (me) && scm_to_int (me->get_property ("duration-log")) >= 1; } - MAKE_SCHEME_CALLBACK (Stem, pure_height, 3) SCM Stem::pure_height (SCM smob, - SCM /* start */, - SCM /* end */) + SCM /* start */, + SCM /* end */) { Grob *me = unsmob_grob (smob); Interval iv; @@ -258,29 +254,29 @@ Stem::pure_height (SCM smob, Real len_in_halfspaces; SCM user_set_len_scm = me->get_property_data ("length"); if (scm_is_number (user_set_len_scm)) - len_in_halfspaces = scm_to_double (user_set_len_scm); + len_in_halfspaces = scm_to_double (user_set_len_scm); else - len_in_halfspaces = scm_to_double (calc_length (smob)); + len_in_halfspaces = scm_to_double (calc_length (smob)); Real len = len_in_halfspaces * ss / 2; Direction dir = get_grob_direction (me); Interval hp = head_positions (me); if (dir == UP) - iv = Interval (0, len); + iv = Interval (0, len); else - iv = Interval (-len, 0); + iv = Interval (-len, 0); if (!hp.is_empty ()) - { - iv.translate (hp[dir] * ss / 2); - iv.add_point (hp[-dir] * ss / 2); - } + { + iv.translate (hp[dir] * ss / 2); + iv.add_point (hp[-dir] * ss / 2); + } /* extend the stem (away from the head) to cover the staff */ if (dir == UP) - iv[UP] = max (iv[UP], rad * ss); + iv[UP] = max (iv[UP], rad * ss); else - iv[DOWN] = min (iv[DOWN], -rad * ss); + iv[DOWN] = min (iv[DOWN], -rad * ss); } else iv = Interval (-rad * ss, rad * ss); @@ -302,7 +298,7 @@ Stem::calc_stem_end_position (SCM smob) (void) beam->get_property ("quantized-positions"); return me->get_property ("stem-end-position"); } - + vector<Real> a; /* WARNING: IN HALF SPACES */ @@ -326,7 +322,7 @@ SCM Stem::calc_length (SCM smob) { Grob *me = unsmob_grob (smob); - + SCM details = me->get_property ("details"); int durlog = duration_log (me); @@ -346,7 +342,7 @@ Stem::calc_length (SCM smob) { SCM sshorten = ly_assoc_get (ly_symbol2scm ("stem-shorten"), details, SCM_EOL); SCM scm_shorten = scm_is_pair (sshorten) - ? robust_list_ref (max (duration_log (me) - 2, 0), sshorten) : SCM_EOL; + ? robust_list_ref (max (duration_log (me) - 2, 0), sshorten) : SCM_EOL; Real shorten_property = 2 * robust_scm2double (scm_shorten, 0); /* change in length between full-size and shortened stems is executed gradually. "transition area" = stems between full-sized and fully-shortened. @@ -364,7 +360,7 @@ Stem::calc_length (SCM smob) Shortening of flagged stems begins in the same moment as unflagged ones, but not earlier than on the middle line note. */ - Real which_step = (min (1.0, quarter_stem_length - (2 * staff_rad) - 2.0)) + abs(hp[dir]); + Real which_step = (min (1.0, quarter_stem_length - (2 * staff_rad) - 2.0)) + abs (hp[dir]); Real shorten = min (max (0.0, (shortening_step * which_step)), shorten_property); length -= shorten; @@ -382,7 +378,7 @@ Stem::calc_length (SCM smob) (Stem_tremolo::raw_stencil () looks at the beam.) --hwn */ Real minlen = 1.0 - + 2 * Stem_tremolo::vertical_length (t_flag) / ss; + + 2 * Stem_tremolo::vertical_length (t_flag) / ss; /* We don't want to add the whole extent of the flag because the trem and the flag can overlap partly. beam_translation gives a good @@ -401,7 +397,7 @@ Stem::calc_length (SCM smob) } length = max (length, minlen + 1.0); } - + return scm_from_double (length); } /* The log of the duration (Number of hooks on the flag minus two) */ @@ -416,14 +412,14 @@ MAKE_SCHEME_CALLBACK (Stem, calc_positioning_done, 1); SCM Stem::calc_positioning_done (SCM smob) { - Grob *me = unsmob_grob (smob); + Grob *me = unsmob_grob (smob); if (!head_count (me)) return SCM_BOOL_T; me->set_property ("positioning-done", SCM_BOOL_T); - + extract_grob_set (me, "note-heads", ro_heads); - vector<Grob*> heads (ro_heads); + vector<Grob *> heads (ro_heads); vector_sort (heads, position_less); Direction dir = get_grob_direction (me); @@ -442,8 +438,8 @@ Stem::calc_positioning_done (SCM smob) bool is_harmonic_centered = false; for (vsize i = 0; i < heads.size (); i++) - is_harmonic_centered = is_harmonic_centered - || heads[i]->get_property ("style") == ly_symbol2scm ("harmonic"); + is_harmonic_centered = is_harmonic_centered + || heads[i]->get_property ("style") == ly_symbol2scm ("harmonic"); is_harmonic_centered = is_harmonic_centered && is_invisible (me); Real w = hed->extent (hed, X_AXIS)[dir]; @@ -452,10 +448,10 @@ Stem::calc_positioning_done (SCM smob) Real amount = w - heads[i]->extent (heads[i], X_AXIS)[dir]; if (is_harmonic_centered) - amount = - hed->extent (hed, X_AXIS).linear_combination (CENTER) - - heads[i]->extent (heads[i], X_AXIS).linear_combination (CENTER); - + amount + = hed->extent (hed, X_AXIS).linear_combination (CENTER) + - heads[i]->extent (heads[i], X_AXIS).linear_combination (CENTER); + heads[i]->translate_axis (amount, X_AXIS); } bool parity = true; @@ -463,54 +459,54 @@ Stem::calc_positioning_done (SCM smob) for (vsize i = 1; i < heads.size (); i++) { Real p = Staff_symbol_referencer::get_position (heads[i]); - Real dy = fabs (lastpos- p); + Real dy = fabs (lastpos - p); /* - dy should always be 0.5, 0.0, 1.0, but provide safety margin - for rounding errors. + dy should always be 0.5, 0.0, 1.0, but provide safety margin + for rounding errors. */ if (dy < 1.1) - { - if (parity) - { - Real ell = heads[i]->extent (heads[i], X_AXIS).length (); + { + if (parity) + { + Real ell = heads[i]->extent (heads[i], X_AXIS).length (); - Direction d = get_grob_direction (me); - /* - Reversed head should be shifted ell-thickness, but this - looks too crowded, so we only shift ell-0.5*thickness. + Direction d = get_grob_direction (me); + /* + Reversed head should be shifted ell-thickness, but this + looks too crowded, so we only shift ell-0.5*thickness. - This leads to assymetry: Normal heads overlap the - stem 100% whereas reversed heads only overlaps the - stem 50% - */ + This leads to assymetry: Normal heads overlap the + stem 100% whereas reversed heads only overlaps the + stem 50% + */ - Real reverse_overlap = 0.5; - heads[i]->translate_axis ((ell - thick * reverse_overlap) * d, - X_AXIS); + Real reverse_overlap = 0.5; + heads[i]->translate_axis ((ell - thick * reverse_overlap) * d, + X_AXIS); - if (is_invisible (me)) - heads[i]->translate_axis (-thick * (2 - reverse_overlap) * d, - X_AXIS); + if (is_invisible (me)) + heads[i]->translate_axis (-thick * (2 - reverse_overlap) * d, + X_AXIS); - /* TODO: + /* TODO: - For some cases we should kern some more: when the - distance between the next or prev note is too large, we'd - get large white gaps, eg. + For some cases we should kern some more: when the + distance between the next or prev note is too large, we'd + get large white gaps, eg. - | + | X| - |X <- kern this. - | - X - - */ - } - parity = !parity; - } + |X <- kern this. + | + X + + */ + } + parity = !parity; + } else - parity = true; + parity = true; lastpos = int (p); } @@ -535,9 +531,9 @@ Stem::calc_direction (SCM smob) SCM dd = me->get_property ("default-direction"); dir = to_dir (dd); if (!dir) - return me->get_property ("neutral-direction"); + return me->get_property ("neutral-direction"); } - + return scm_from_int (dir); } @@ -554,14 +550,13 @@ Stem::calc_default_direction (SCM smob) { int udistance = (int) (UP * hp[UP] - staff_center); int ddistance = (int) (DOWN * hp[DOWN] - staff_center); - + dir = Direction (sign (ddistance - udistance)); } - + return scm_from_int (dir); } - MAKE_SCHEME_CALLBACK (Stem, height, 1); SCM Stem::height (SCM smob) @@ -569,9 +564,9 @@ Stem::height (SCM smob) Grob *me = unsmob_grob (smob); if (!is_normal_stem (me)) return ly_interval2scm (Interval ()); - + Direction dir = get_grob_direction (me); - + Grob *beam = get_beam (me); if (beam) { @@ -588,10 +583,10 @@ Stem::height (SCM smob) if (beam) { if (dir == CENTER) - { - programming_error ("no stem direction"); - dir = UP; - } + { + programming_error ("no stem direction"); + dir = UP; + } iv[dir] += dir * Beam::get_beam_thickness (beam) * 0.5; } @@ -617,7 +612,7 @@ Stem::calc_flag (SCM smob) '() or "grace"). */ string flag_style; - SCM flag_style_scm = me->get_property ("flag-style"); + SCM flag_style_scm = me->get_property ("flag-style"); if (scm_is_symbol (flag_style_scm)) flag_style = ly_symbol2string (flag_style_scm); @@ -644,13 +639,13 @@ Stem::calc_flag (SCM smob) } else staffline_offs = "2"; - } + } else staffline_offs = ""; char dir = (get_grob_direction (me) == UP) ? 'u' : 'd'; string font_char = flag_style - + to_string (dir) + staffline_offs + to_string (log); + + to_string (dir) + staffline_offs + to_string (log); Font_metric *fm = Font_interface::get_default_font (me); Stencil flag = fm->find_by_name ("flags." + font_char); if (flag.is_empty ()) @@ -674,12 +669,11 @@ Stem::calc_flag (SCM smob) else flag.add_stencil (stroke); } - } + } return flag.smobbed_copy (); } - Stencil Stem::flag (Grob *me) { @@ -695,11 +689,14 @@ Stem::flag (Grob *me) // the grob passed as argument! Thus, we only have to check if a valid // stencil is returned. SCM flag_style_scm = me->get_property ("flag"); - if (Stencil *flag = unsmob_stencil (flag_style_scm)) { - return *flag; - } else { - return Stencil (); - } + if (Stencil *flag = unsmob_stencil (flag_style_scm)) + { + return *flag; + } + else + { + return Stencil (); + } } MAKE_SCHEME_CALLBACK (Stem, width, 1); @@ -713,7 +710,7 @@ Stem::width (SCM e) if (is_invisible (me)) r.set_empty (); else if (unsmob_grob (me->get_object ("beam")) - || abs (duration_log (me)) <= 2) + || abs (duration_log (me)) <= 2) { r = Interval (-1, 1); r *= thickness (me) / 2; @@ -730,7 +727,7 @@ Real Stem::thickness (Grob *me) { return scm_to_double (me->get_property ("thickness")) - * Staff_symbol_referencer::line_thickness (me); + * Staff_symbol_referencer::line_thickness (me); } MAKE_SCHEME_CALLBACK (Stem, calc_stem_begin_position, 1); @@ -742,8 +739,8 @@ Stem::calc_stem_begin_position (SCM smob) Real half_space = Staff_symbol_referencer::staff_space (me) * 0.5; Grob *lh = to_boolean (me->get_property ("avoid-note-head")) - ? last_head (me) - : first_head (me); + ? last_head (me) + : first_head (me); Real pos = Staff_symbol_referencer::get_position (lh); @@ -765,20 +762,20 @@ Stem::print (SCM smob) { Grob *me = unsmob_grob (smob); Grob *beam = get_beam (me); - + Stencil mol; Direction d = get_grob_direction (me); Real stemlet_length = robust_scm2double (me->get_property ("stemlet-length"), - 0.0); + 0.0); bool stemlet = stemlet_length > 0.0; /* TODO: make the stem start a direction ? This is required to avoid stems passing in tablature chords. */ Grob *lh = to_boolean (me->get_property ("avoid-note-head")) - ? last_head (me) - : first_head (me); + ? last_head (me) + : first_head (me); if (!lh && !stemlet) return SCM_EOL; @@ -786,7 +783,7 @@ Stem::print (SCM smob) if (!lh && stemlet && !beam) return SCM_EOL; - if (lh && robust_scm2int (lh->get_property ("duration-log"), 0) < 1) + if (lh && robust_scm2int (lh->get_property ("duration-log"), 0) < 1) return SCM_EOL; if (is_invisible (me)) @@ -805,9 +802,9 @@ Stem::print (SCM smob) int beam_count = beam_multiplicity (me).length () + 1; y2 -= d - * (0.5 * beam_thickness - + beam_translation * max (0, (beam_count - 1)) - + stemlet_length) / half_space; + * (0.5 * beam_thickness + + beam_translation * max (0, (beam_count - 1)) + + stemlet_length) / half_space; } Interval stem_y (min (y1, y2), max (y2, y1)); @@ -818,7 +815,7 @@ Stem::print (SCM smob) = me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter")); Box b = Box (Interval (-stem_width / 2, stem_width / 2), - Interval (stem_y[DOWN] * half_space, stem_y[UP] * half_space)); + Interval (stem_y[DOWN] * half_space, stem_y[UP] * half_space)); Stencil ss = Lookup::round_filled_box (b, blot); mol.add_stencil (ss); @@ -836,7 +833,7 @@ Stem::get_translated_flag (Grob *me) { Direction d = get_grob_direction (me); Real blot - = me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter")); + = me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter")); Real stem_width = thickness (me); Real half_space = Staff_symbol_referencer::staff_space (me) * 0.5; Real y2 = robust_scm2double (me->get_property ("stem-end-position"), 0.0); @@ -846,7 +843,6 @@ Stem::get_translated_flag (Grob *me) return fl; } - /* move the stem to right of the notehead if it is up. */ @@ -864,16 +860,15 @@ Stem::offset_callback (SCM smob) return scm_from_double (r); } - if (Grob *f = first_head (me)) { Interval head_wid = f->extent (f, X_AXIS); Real attach = 0.0; if (is_invisible (me)) - attach = 0.0; + attach = 0.0; else - attach = Note_head::stem_attachment_coordinate (f, X_AXIS); + attach = Note_head::stem_attachment_coordinate (f, X_AXIS); Direction d = get_grob_direction (me); Real real_attach = head_wid.linear_combination (d * attach); @@ -881,10 +876,10 @@ Stem::offset_callback (SCM smob) /* If not centered: correct for stem thickness. */ if (attach) - { - Real rule_thick = thickness (me); - r += -d * rule_thick * 0.5; - } + { + Real rule_thick = thickness (me); + r += -d * rule_thick * 0.5; + } return scm_from_double (r); } @@ -904,7 +899,7 @@ Stem::get_stem_info (Grob *me) { Stem_info si; si.dir_ = get_grob_direction (me); - + SCM scm_info = me->get_property ("stem-info"); si.ideal_y_ = scm_to_double (scm_car (scm_info)); si.shortest_y_ = scm_to_double (scm_cadr (scm_info)); @@ -931,7 +926,7 @@ Stem::calc_stem_info (SCM smob) { (void) beam->get_property ("beaming"); } - + Real beam_translation = Beam::get_beam_translation (beam); Real beam_thickness = Beam::get_beam_thickness (beam); int beam_count = Beam::get_direction_beam_count (beam, my_dir); @@ -941,27 +936,27 @@ Stem::calc_stem_info (SCM smob) /* Simple standard stem length */ SCM details = me->get_property ("details"); SCM lengths = ly_assoc_get (ly_symbol2scm ("beamed-lengths"), details, SCM_EOL); - + Real ideal_length = (scm_is_pair (lengths) ? (scm_to_double (robust_list_ref (beam_count - 1, lengths)) - * staff_space - * length_fraction - /* - stem only extends to center of beam - */ - - 0.5 * beam_thickness) + * staff_space + * length_fraction + /* + stem only extends to center of beam + */ + - 0.5 * beam_thickness) : 0.0); /* Condition: sane minimum free stem length (chord to beams) */ lengths = ly_assoc_get (ly_symbol2scm ("beamed-minimum-free-lengths"), - details, SCM_EOL); + details, SCM_EOL); Real ideal_minimum_free = (scm_is_pair (lengths) ? (scm_to_double (robust_list_ref (beam_count - 1, lengths)) - * staff_space - * length_fraction) + * staff_space + * length_fraction) : 0.0); Real height_of_my_trem = 0.0; @@ -969,12 +964,11 @@ Stem::calc_stem_info (SCM smob) if (trem) { height_of_my_trem - = Stem_tremolo::vertical_length (trem) - /* hack a bit of space around the trem. */ - + beam_translation; + = Stem_tremolo::vertical_length (trem) + /* hack a bit of space around the trem. */ + + beam_translation; } - /* UGH It seems that also for ideal minimum length, we must use the maximum beam count (for this direction): @@ -983,21 +977,21 @@ Stem::calc_stem_info (SCM smob) must be horizontal. */ Real height_of_my_beams = beam_thickness - + (beam_count - 1) * beam_translation; + + (beam_count - 1) * beam_translation; Real ideal_minimum_length = ideal_minimum_free - + height_of_my_beams - + height_of_my_trem - /* stem only extends to center of beam */ - - 0.5 * beam_thickness; + + height_of_my_beams + + height_of_my_trem + /* stem only extends to center of beam */ + - 0.5 * beam_thickness; ideal_length = max (ideal_length, ideal_minimum_length); /* Convert to Y position, calculate for dir == UP */ Real note_start = /* staff positions */ - head_positions (me)[my_dir] * 0.5 - * my_dir * staff_space; + head_positions (me)[my_dir] * 0.5 + * my_dir * staff_space; Real ideal_y = note_start + ideal_length; /* Conditions for Y position */ @@ -1020,36 +1014,36 @@ Stem::calc_stem_info (SCM smob) if (!no_extend && !is_knee) { /* Highest beam of (UP) beam must never be lower than middle - staffline */ + staffline */ ideal_y = max (ideal_y, 0.0); /* Lowest beam of (UP) beam must never be lower than second staffline */ ideal_y = max (ideal_y, (-staff_space - - beam_thickness + height_of_my_beams)); + - beam_thickness + height_of_my_beams)); } ideal_y -= robust_scm2double (beam->get_property ("shorten"), 0); SCM bemfl = ly_assoc_get (ly_symbol2scm ("beamed-extreme-minimum-free-lengths"), - details, SCM_EOL); - + details, SCM_EOL); + Real minimum_free = (scm_is_pair (bemfl) ? (scm_to_double (robust_list_ref (beam_count - 1, bemfl)) - * staff_space - * length_fraction) + * staff_space + * length_fraction) : 0.0); Real minimum_length = max (minimum_free, height_of_my_trem) - + height_of_my_beams - /* stem only extends to center of beam */ - - 0.5 * beam_thickness; + + height_of_my_beams + /* stem only extends to center of beam */ + - 0.5 * beam_thickness; ideal_y *= my_dir; Real minimum_y = note_start + minimum_length; Real shortest_y = minimum_y * my_dir; return scm_list_2 (scm_from_double (ideal_y), - scm_from_double (shortest_y)); + scm_from_double (shortest_y)); } Slice @@ -1078,60 +1072,60 @@ Stem::calc_cross_staff (SCM smob) /* FIXME: Too many properties */ ADD_INTERFACE (Stem, - "The stem represents the graphical stem. In addition, it" - " internally connects note heads, beams, and tremolos. Rests" - " and whole notes have invisible stems.\n" - "\n" - "The following properties may be set in the @code{details}" - " list.\n" - "\n" - "@table @code\n" - "@item beamed-lengths\n" - "List of stem lengths given beam multiplicity.\n" - "@item beamed-minimum-free-lengths\n" - "List of normal minimum free stem lengths (chord to beams)" - " given beam multiplicity.\n" - "@item beamed-extreme-minimum-free-lengths\n" - "List of extreme minimum free stem lengths (chord to beams)" - " given beam multiplicity.\n" - "@item lengths\n" - "Default stem lengths. The list gives a length for each" - " flag count.\n" - "@item stem-shorten\n" - "How much a stem in a forced direction should be shortened." - " The list gives an amount depending on the number of flags" - " and beams.\n" - "@end table\n", - - /* properties */ - "avoid-note-head " - "beam " - "beaming " - "beamlet-default-length " - "beamlet-max-length-proportion " - "default-direction " - "details " - "direction " - "duration-log " - "flag " - "flag-style " - "french-beaming " - "length " - "length-fraction " - "max-beam-connect " - "neutral-direction " - "no-stem-extend " - "note-heads " - "positioning-done " - "rests " - "stem-begin-position " - "stem-end-position " - "stem-info " - "stemlet-length " - "stroke-style " - "thickness " - "tremolo-flag " - ); + "The stem represents the graphical stem. In addition, it" + " internally connects note heads, beams, and tremolos. Rests" + " and whole notes have invisible stems.\n" + "\n" + "The following properties may be set in the @code{details}" + " list.\n" + "\n" + "@table @code\n" + "@item beamed-lengths\n" + "List of stem lengths given beam multiplicity.\n" + "@item beamed-minimum-free-lengths\n" + "List of normal minimum free stem lengths (chord to beams)" + " given beam multiplicity.\n" + "@item beamed-extreme-minimum-free-lengths\n" + "List of extreme minimum free stem lengths (chord to beams)" + " given beam multiplicity.\n" + "@item lengths\n" + "Default stem lengths. The list gives a length for each" + " flag count.\n" + "@item stem-shorten\n" + "How much a stem in a forced direction should be shortened." + " The list gives an amount depending on the number of flags" + " and beams.\n" + "@end table\n", + + /* properties */ + "avoid-note-head " + "beam " + "beaming " + "beamlet-default-length " + "beamlet-max-length-proportion " + "default-direction " + "details " + "direction " + "duration-log " + "flag " + "flag-style " + "french-beaming " + "length " + "length-fraction " + "max-beam-connect " + "neutral-direction " + "no-stem-extend " + "note-heads " + "positioning-done " + "rests " + "stem-begin-position " + "stem-end-position " + "stem-info " + "stemlet-length " + "stroke-style " + "thickness " + "tremolo-flag " + ); /****************************************************************/ diff --git a/lily/stencil-expression.cc b/lily/stencil-expression.cc index d5926c6205..27a732d523 100644 --- a/lily/stencil-expression.cc +++ b/lily/stencil-expression.cc @@ -25,16 +25,16 @@ void register_stencil_head (SCM symbol) { if (!heads) heads = scm_permanent_object (scm_cons (SCM_EOL, SCM_EOL)); - + scm_set_object_property_x (symbol, ly_symbol2scm ("stencil-head?"), SCM_BOOL_T); - scm_set_cdr_x (heads, scm_cons (symbol, scm_cdr (heads))); + scm_set_cdr_x (heads, scm_cons (symbol, scm_cdr (heads))); } bool is_stencil_head (SCM symbol) { return scm_object_property (symbol, ly_symbol2scm ("stencil-head?")) - == SCM_BOOL_T; + == SCM_BOOL_T; } SCM diff --git a/lily/stencil-interpret.cc b/lily/stencil-interpret.cc index 4f8c6bbc8b..e85ad90f43 100644 --- a/lily/stencil-interpret.cc +++ b/lily/stencil-interpret.cc @@ -21,100 +21,100 @@ void interpret_stencil_expression (SCM expr, - void (*func) (void *, SCM), - void *func_arg, - Offset o) + void (*func) (void *, SCM), + void *func_arg, + Offset o) { while (1) { if (!scm_is_pair (expr)) - return; + return; SCM head = scm_car (expr); if (head == ly_symbol2scm ("delay-stencil-evaluation")) - { - interpret_stencil_expression (scm_force (scm_cadr (expr)), func, func_arg, o); - return; - } + { + interpret_stencil_expression (scm_force (scm_cadr (expr)), func, func_arg, o); + return; + } if (head == ly_symbol2scm ("footnote")) return; if (head == ly_symbol2scm ("translate-stencil")) - { - o += ly_scm2offset (scm_cadr (expr)); - expr = scm_caddr (expr); - } + { + o += ly_scm2offset (scm_cadr (expr)); + expr = scm_caddr (expr); + } else if (head == ly_symbol2scm ("combine-stencil")) - { + { - for (SCM x = scm_cdr (expr); scm_is_pair (x); x = scm_cdr (x)) - interpret_stencil_expression (scm_car (x), func, func_arg, o); - return; - } + for (SCM x = scm_cdr (expr); scm_is_pair (x); x = scm_cdr (x)) + interpret_stencil_expression (scm_car (x), func, func_arg, o); + return; + } else if (head == ly_symbol2scm ("grob-cause")) - { - SCM grob = scm_cadr (expr); - - (*func) (func_arg, scm_list_3 (head, - ly_quote_scm (ly_offset2scm (o)), grob)); - interpret_stencil_expression (scm_caddr (expr), func, func_arg, o); - (*func) (func_arg, scm_list_1 (ly_symbol2scm ("no-origin"))); - return; - } + { + SCM grob = scm_cadr (expr); + + (*func) (func_arg, scm_list_3 (head, + ly_quote_scm (ly_offset2scm (o)), grob)); + interpret_stencil_expression (scm_caddr (expr), func, func_arg, o); + (*func) (func_arg, scm_list_1 (ly_symbol2scm ("no-origin"))); + return; + } else if (head == ly_symbol2scm ("color")) - { - SCM color = scm_cadr (expr); - SCM r = scm_car (color); - SCM g = scm_cadr (color); - SCM b = scm_caddr (color); - - (*func) (func_arg, scm_list_4 (ly_symbol2scm ("setcolor"), r, g, b)); - interpret_stencil_expression (scm_caddr (expr), func, func_arg, o); - (*func) (func_arg, scm_list_1 (ly_symbol2scm ("resetcolor"))); - - return; - } + { + SCM color = scm_cadr (expr); + SCM r = scm_car (color); + SCM g = scm_cadr (color); + SCM b = scm_caddr (color); + + (*func) (func_arg, scm_list_4 (ly_symbol2scm ("setcolor"), r, g, b)); + interpret_stencil_expression (scm_caddr (expr), func, func_arg, o); + (*func) (func_arg, scm_list_1 (ly_symbol2scm ("resetcolor"))); + + return; + } else if (head == ly_symbol2scm ("rotate-stencil")) - { - SCM args = scm_cadr (expr); - SCM angle = scm_car (args); - Offset tmp = o + robust_scm2offset (scm_cadr (args), Offset (0.0, 0.0)); + { + SCM args = scm_cadr (expr); + SCM angle = scm_car (args); + Offset tmp = o + robust_scm2offset (scm_cadr (args), Offset (0.0, 0.0)); - SCM offset = ly_offset2scm (tmp); - SCM x = scm_car (offset); - SCM y = scm_cdr (offset); + SCM offset = ly_offset2scm (tmp); + SCM x = scm_car (offset); + SCM y = scm_cdr (offset); - (*func) (func_arg, scm_list_4 (ly_symbol2scm ("setrotation"), angle, x, y)); - interpret_stencil_expression (scm_caddr (expr), func, func_arg, o); - (*func) (func_arg, scm_list_4 (ly_symbol2scm ("resetrotation"), angle, x, y)); + (*func) (func_arg, scm_list_4 (ly_symbol2scm ("setrotation"), angle, x, y)); + interpret_stencil_expression (scm_caddr (expr), func, func_arg, o); + (*func) (func_arg, scm_list_4 (ly_symbol2scm ("resetrotation"), angle, x, y)); - return; - } + return; + } else if (head == ly_symbol2scm ("scale-stencil")) - { - SCM args = scm_cadr (expr); - SCM x_scale = scm_car (args); - SCM y_scale = scm_cadr (args); - Offset unscaled = o.scale (Offset (1 / scm_to_double (x_scale), - 1 / scm_to_double (y_scale))); - - (*func) (func_arg, scm_list_3 (ly_symbol2scm ("setscale"), x_scale, - y_scale)); - interpret_stencil_expression (scm_caddr (expr), func, func_arg, - unscaled); - (*func) (func_arg, scm_list_1 (ly_symbol2scm ("resetscale"))); - - return; - } + { + SCM args = scm_cadr (expr); + SCM x_scale = scm_car (args); + SCM y_scale = scm_cadr (args); + Offset unscaled = o.scale (Offset (1 / scm_to_double (x_scale), + 1 / scm_to_double (y_scale))); + + (*func) (func_arg, scm_list_3 (ly_symbol2scm ("setscale"), x_scale, + y_scale)); + interpret_stencil_expression (scm_caddr (expr), func, func_arg, + unscaled); + (*func) (func_arg, scm_list_1 (ly_symbol2scm ("resetscale"))); + + return; + } else - { - (*func) (func_arg, - scm_list_4 (ly_symbol2scm ("placebox"), - scm_from_double (o[X_AXIS]), - scm_from_double (o[Y_AXIS]), - expr)); - return; - } + { + (*func) (func_arg, + scm_list_4 (ly_symbol2scm ("placebox"), + scm_from_double (o[X_AXIS]), + scm_from_double (o[Y_AXIS]), + expr)); + return; + } } } @@ -134,13 +134,13 @@ find_font_function (void *fs, SCM x) SCM what = scm_caddr (args); if (scm_is_pair (what)) - { - SCM head = scm_car (what); - if (ly_symbol2scm ("text") == head) - me->fonts_ = scm_cons (scm_cadr (what), me->fonts_); - else if (head == ly_symbol2scm ("char")) - me->fonts_ = scm_cons (scm_cadr (what), me->fonts_); - } + { + SCM head = scm_car (what); + if (ly_symbol2scm ("text") == head) + me->fonts_ = scm_cons (scm_cadr (what), me->fonts_); + else if (head == ly_symbol2scm ("char")) + me->fonts_ = scm_cons (scm_cadr (what), me->fonts_); + } } } @@ -152,7 +152,7 @@ find_expression_fonts (SCM expr) fl.fonts_ = SCM_EOL; interpret_stencil_expression (expr, &find_font_function, - (void *) & fl, Offset (0, 0)); + (void *) & fl, Offset (0, 0)); return fl.fonts_; } diff --git a/lily/stencil-scheme.cc b/lily/stencil-scheme.cc index 0e7f0cd8c7..958bcc44c8 100644 --- a/lily/stencil-scheme.cc +++ b/lily/stencil-scheme.cc @@ -17,7 +17,6 @@ along with LilyPond. If not, see <http://www.gnu.org/licenses/>. */ - #include "font-metric.hh" #include "libc-extension.hh" #include "lookup.hh" @@ -28,9 +27,9 @@ */ LY_DEFINE (ly_stencil_translate_axis, "ly:stencil-translate-axis", - 3, 0, 0, (SCM stil, SCM amount, SCM axis), - "Return a copy of @var{stil} but translated by @var{amount}" - " in @var{axis} direction.") + 3, 0, 0, (SCM stil, SCM amount, SCM axis), + "Return a copy of @var{stil} but translated by @var{amount}" + " in @var{axis} direction.") { Stencil *s = unsmob_stencil (stil); LY_ASSERT_SMOB (Stencil, stil, 1); @@ -46,9 +45,9 @@ LY_DEFINE (ly_stencil_translate_axis, "ly:stencil-translate-axis", } LY_DEFINE (ly_stencil_translate, "ly:stencil-translate", - 2, 0, 0, (SCM stil, SCM offset), - "Return a @var{stil}, but translated by @var{offset}" - " (a pair of numbers).") + 2, 0, 0, (SCM stil, SCM offset), + "Return a @var{stil}, but translated by @var{offset}" + " (a pair of numbers).") { Stencil *s = unsmob_stencil (stil); LY_ASSERT_SMOB (Stencil, stil, 1); @@ -62,8 +61,8 @@ LY_DEFINE (ly_stencil_translate, "ly:stencil-translate", } LY_DEFINE (ly_stencil_expr, "ly:stencil-expr", - 1, 0, 0, (SCM stil), - "Return the expression of @var{stil}.") + 1, 0, 0, (SCM stil), + "Return the expression of @var{stil}.") { Stencil *s = unsmob_stencil (stil); LY_ASSERT_SMOB (Stencil, stil, 1); @@ -71,10 +70,10 @@ LY_DEFINE (ly_stencil_expr, "ly:stencil-expr", } LY_DEFINE (ly_stencil_extent, "ly:stencil-extent", - 2, 0, 0, (SCM stil, SCM axis), - "Return a pair of numbers signifying the extent of @var{stil} in" - " @var{axis} direction (@code{0} or @code{1} for x and" - " y@tie{}axis, respectively).") + 2, 0, 0, (SCM stil, SCM axis), + "Return a pair of numbers signifying the extent of @var{stil} in" + " @var{axis} direction (@code{0} or @code{1} for x and" + " y@tie{}axis, respectively).") { Stencil *s = unsmob_stencil (stil); LY_ASSERT_SMOB (Stencil, stil, 1); @@ -84,8 +83,8 @@ LY_DEFINE (ly_stencil_extent, "ly:stencil-extent", } LY_DEFINE (ly_stencil_empty_p, "ly:stencil-empty?", - 1, 0, 0, (SCM stil), - "Return whether @var{stil} is empty.") + 1, 0, 0, (SCM stil), + "Return whether @var{stil} is empty.") { Stencil *s = unsmob_stencil (stil); LY_ASSERT_SMOB (Stencil, stil, 1); @@ -93,28 +92,28 @@ LY_DEFINE (ly_stencil_empty_p, "ly:stencil-empty?", } LY_DEFINE (ly_stencil_combine_at_edge, "ly:stencil-combine-at-edge", - 4, 2, 0, (SCM first, SCM axis, SCM direction, - SCM second, - SCM padding, - SCM minimum), - "Construct a stencil by putting @var{second} next to @var{first}." - " @var{axis} can be 0 (x-axis) or@tie{}1 (y-axis)." - " @var{direction} can be -1 (left or down) or@tie{}1 (right or" - " up). The stencils are juxtaposed with @var{padding} as extra" - " space. If this puts the reference points closer than" - " @var{minimum}, they are moved by the latter amount." - " @var{first} and @var{second} may also be @code{'()} or" - " @code{#f}.") + 4, 2, 0, (SCM first, SCM axis, SCM direction, + SCM second, + SCM padding, + SCM minimum), + "Construct a stencil by putting @var{second} next to @var{first}." + " @var{axis} can be 0 (x-axis) or@tie{}1 (y-axis)." + " @var{direction} can be -1 (left or down) or@tie{}1 (right or" + " up). The stencils are juxtaposed with @var{padding} as extra" + " space. If this puts the reference points closer than" + " @var{minimum}, they are moved by the latter amount." + " @var{first} and @var{second} may also be @code{'()} or" + " @code{#f}.") { Stencil *s1 = unsmob_stencil (first); Stencil *s2 = unsmob_stencil (second); Stencil result; SCM_ASSERT_TYPE (s1 || first == SCM_BOOL_F || first == SCM_EOL, - first, SCM_ARG1, __FUNCTION__, "Stencil, #f or ()"); + first, SCM_ARG1, __FUNCTION__, "Stencil, #f or ()"); SCM_ASSERT_TYPE (s2 || second == SCM_BOOL_F || second == SCM_EOL, - second, SCM_ARG4, __FUNCTION__, "Stencil, #f or ()"); - LY_ASSERT_TYPE (is_axis, axis, 2); + second, SCM_ARG4, __FUNCTION__, "Stencil, #f or ()"); + LY_ASSERT_TYPE (is_axis, axis, 2); LY_ASSERT_TYPE (is_direction, direction, 3); Real p = 0.0; @@ -135,14 +134,14 @@ LY_DEFINE (ly_stencil_combine_at_edge, "ly:stencil-combine-at-edge", if (s2) result.add_at_edge (Axis (scm_to_int (axis)), - Direction (scm_to_int (direction)), *s2, p); + Direction (scm_to_int (direction)), *s2, p); return result.smobbed_copy (); } LY_DEFINE (ly_stencil_add, "ly:stencil-add", - 0, 0, 1, (SCM args), - "Combine stencils. Takes any number of arguments.") + 0, 0, 1, (SCM args), + "Combine stencils. Takes any number of arguments.") { #define FUNC_NAME __FUNCTION__ SCM_VALIDATE_REST_ARGUMENT (args); @@ -156,7 +155,7 @@ LY_DEFINE (ly_stencil_add, "ly:stencil-add", { Stencil *s = unsmob_stencil (scm_car (args)); if (!s) - SCM_ASSERT_TYPE (s, scm_car (args), SCM_ARGn, __FUNCTION__, "Stencil"); + SCM_ASSERT_TYPE (s, scm_car (args), SCM_ARGn, __FUNCTION__, "Stencil"); extent.unite (s->extent_box ()); *tail = scm_cons (s->expr (), SCM_EOL); @@ -169,35 +168,34 @@ LY_DEFINE (ly_stencil_add, "ly:stencil-add", } LY_DEFINE (ly_make_stencil, "ly:make-stencil", - 1, 2, 0, (SCM expr, SCM xext, SCM yext), - "Stencils are device independent output expressions." - " They carry two pieces of information:\n" - "\n" - "@enumerate\n" - "@item\n" - "A specification of how to print this object." - " This specification is processed by the output backends," - " for example @file{scm/output-ps.scm}.\n" - "\n" - "@item\n" - "The vertical and horizontal extents of the object, given as" - " pairs. If an extent is unspecified (or if you use" - " @code{(1000 . -1000)} as its value), it is taken to be empty.\n" - "@end enumerate\n") + 1, 2, 0, (SCM expr, SCM xext, SCM yext), + "Stencils are device independent output expressions." + " They carry two pieces of information:\n" + "\n" + "@enumerate\n" + "@item\n" + "A specification of how to print this object." + " This specification is processed by the output backends," + " for example @file{scm/output-ps.scm}.\n" + "\n" + "@item\n" + "The vertical and horizontal extents of the object, given as" + " pairs. If an extent is unspecified (or if you use" + " @code{(1000 . -1000)} as its value), it is taken to be empty.\n" + "@end enumerate\n") { SCM_ASSERT_TYPE (!scm_is_pair (expr) - || is_stencil_head (scm_car (expr)), - expr, SCM_ARG1, __FUNCTION__, "registered stencil expression"); - + || is_stencil_head (scm_car (expr)), + expr, SCM_ARG1, __FUNCTION__, "registered stencil expression"); - Interval x; + Interval x; if (xext != SCM_UNDEFINED) { LY_ASSERT_TYPE (is_number_pair, xext, 2); x = ly_scm2interval (xext); } - Interval y; + Interval y; if (yext != SCM_UNDEFINED) { LY_ASSERT_TYPE (is_number_pair, yext, 3); @@ -210,10 +208,10 @@ LY_DEFINE (ly_make_stencil, "ly:make-stencil", } LY_DEFINE (ly_stencil_aligned_to, "ly:stencil-aligned-to", - 3, 0, 0, (SCM stil, SCM axis, SCM dir), - "Align @var{stil} using its own extents. @var{dir} is a number." - " @code{-1} and @code{1} are left and right, respectively." - " Other values are interpolated (so @code{0} means the center).") + 3, 0, 0, (SCM stil, SCM axis, SCM dir), + "Align @var{stil} using its own extents. @var{dir} is a number." + " @code{-1} and @code{1} are left and right, respectively." + " Other values are interpolated (so @code{0} means the center).") { LY_ASSERT_SMOB (Stencil, stil, 1); LY_ASSERT_TYPE (is_axis, axis, 2); @@ -222,14 +220,14 @@ LY_DEFINE (ly_stencil_aligned_to, "ly:stencil-aligned-to", Stencil target = *unsmob_stencil (stil); target.align_to ((Axis)scm_to_int (axis), - scm_to_double (dir)); + scm_to_double (dir)); return target.smobbed_copy (); } LY_DEFINE (ly_stencil_fonts, "ly:stencil-fonts", - 1, 0, 0, (SCM s), - "Analyze @var{s}, and return a list of fonts used" - " in@tie{}@var{s}.") + 1, 0, 0, (SCM s), + "Analyze @var{s}, and return a list of fonts used" + " in@tie{}@var{s}.") { LY_ASSERT_SMOB (Stencil, s, 1); Stencil *stil = unsmob_stencil (s); @@ -237,15 +235,15 @@ LY_DEFINE (ly_stencil_fonts, "ly:stencil-fonts", } LY_DEFINE (ly_stencil_in_color, "ly:stencil-in-color", - 4, 0, 0, (SCM stc, SCM r, SCM g, SCM b), - "Put @var{stc} in a different color.") + 4, 0, 0, (SCM stc, SCM r, SCM g, SCM b), + "Put @var{stc} in a different color.") { LY_ASSERT_SMOB (Stencil, stc, 1); Stencil *stil = unsmob_stencil (stc); return Stencil (stil->extent_box (), - scm_list_3 (ly_symbol2scm ("color"), - scm_list_3 (r, g, b), - stil->expr ())).smobbed_copy (); + scm_list_3 (ly_symbol2scm ("color"), + scm_list_3 (r, g, b), + stil->expr ())).smobbed_copy (); } struct Stencil_interpret_arguments @@ -261,9 +259,9 @@ void stencil_interpret_in_scm (void *p, SCM expr) } LY_DEFINE (ly_interpret_stencil_expression, "ly:interpret-stencil-expression", - 4, 0, 0, (SCM expr, SCM func, SCM arg1, SCM offset), - "Parse @var{expr}, feed bits to @var{func} with first arg" - " @var{arg1} having offset @var{offset}.") + 4, 0, 0, (SCM expr, SCM func, SCM arg1, SCM offset), + "Parse @var{expr}, feed bits to @var{func} with first arg" + " @var{arg1} having offset @var{offset}.") { LY_ASSERT_TYPE (ly_is_procedure, func, 2); @@ -278,12 +276,12 @@ LY_DEFINE (ly_interpret_stencil_expression, "ly:interpret-stencil-expression", } LY_DEFINE (ly_bracket, "ly:bracket", - 4, 0, 0, - (SCM a, SCM iv, SCM t, SCM p), - "Make a bracket in direction@tie{}@var{a}. The extent of the" - " bracket is given by @var{iv}. The wings protrude by an amount" - " of@tie{}@var{p}, which may be negative. The thickness is given" - " by@tie{}@var{t}.") + 4, 0, 0, + (SCM a, SCM iv, SCM t, SCM p), + "Make a bracket in direction@tie{}@var{a}. The extent of the" + " bracket is given by @var{iv}. The wings protrude by an amount" + " of@tie{}@var{p}, which may be negative. The thickness is given" + " by@tie{}@var{t}.") { LY_ASSERT_TYPE (is_axis, a, 1); LY_ASSERT_TYPE (is_number_pair, iv, 2); @@ -291,16 +289,16 @@ LY_DEFINE (ly_bracket, "ly:bracket", LY_ASSERT_TYPE (scm_is_number, p, 4); return Lookup::bracket ((Axis)scm_to_int (a), ly_scm2interval (iv), - scm_to_double (t), - scm_to_double (p), - 0.95 * scm_to_double (t)).smobbed_copy (); + scm_to_double (t), + scm_to_double (p), + 0.95 * scm_to_double (t)).smobbed_copy (); } LY_DEFINE (ly_stencil_rotate, "ly:stencil-rotate", - 4, 0, 0, (SCM stil, SCM angle, SCM x, SCM y), - "Return a stencil @var{stil} rotated @var{angle} degrees around" - " the relative offset (@var{x}, @var{y}). E.g. an offset of" - " (-1, 1) will rotate the stencil around the left upper corner.") + 4, 0, 0, (SCM stil, SCM angle, SCM x, SCM y), + "Return a stencil @var{stil} rotated @var{angle} degrees around" + " the relative offset (@var{x}, @var{y}). E.g. an offset of" + " (-1, 1) will rotate the stencil around the left upper corner.") { Stencil *s = unsmob_stencil (stil); LY_ASSERT_SMOB (Stencil, stil, 1); @@ -318,9 +316,9 @@ LY_DEFINE (ly_stencil_rotate, "ly:stencil-rotate", } LY_DEFINE (ly_stencil_rotate_absolute, "ly:stencil-rotate-absolute", - 4, 0, 0, (SCM stil, SCM angle, SCM x, SCM y), - "Return a stencil @var{stil} rotated @var{angle} degrees around" - " point (@var{x}, @var{y}), given in absolute coordinates.") + 4, 0, 0, (SCM stil, SCM angle, SCM x, SCM y), + "Return a stencil @var{stil} rotated @var{angle} degrees around" + " point (@var{x}, @var{y}), given in absolute coordinates.") { Stencil *s = unsmob_stencil (stil); LY_ASSERT_SMOB (Stencil, stil, 1); @@ -338,25 +336,25 @@ LY_DEFINE (ly_stencil_rotate_absolute, "ly:stencil-rotate-absolute", } LY_DEFINE (ly_round_filled_box, "ly:round-filled-box", - 3, 0, 0, - (SCM xext, SCM yext, SCM blot), - "Make a @code{Stencil} object that prints a black box of" - " dimensions @var{xext}, @var{yext} and roundness @var{blot}.") + 3, 0, 0, + (SCM xext, SCM yext, SCM blot), + "Make a @code{Stencil} object that prints a black box of" + " dimensions @var{xext}, @var{yext} and roundness @var{blot}.") { LY_ASSERT_TYPE (is_number_pair, xext, 1); LY_ASSERT_TYPE (is_number_pair, yext, 2); LY_ASSERT_TYPE (scm_is_number, blot, 3); return Lookup::round_filled_box (Box (ly_scm2interval (xext), ly_scm2interval (yext)), - scm_to_double (blot)).smobbed_copy (); + scm_to_double (blot)).smobbed_copy (); } LY_DEFINE (ly_round_filled_polygon, "ly:round-filled-polygon", - 2, 0, 0, - (SCM points, SCM blot), - "Make a @code{Stencil} object that prints a black polygon with" - " corners at the points defined by @var{points} (list of coordinate" - " pairs) and roundness @var{blot}.") + 2, 0, 0, + (SCM points, SCM blot), + "Make a @code{Stencil} object that prints a black polygon with" + " corners at the points defined by @var{points} (list of coordinate" + " pairs) and roundness @var{blot}.") { SCM_ASSERT_TYPE (scm_ilength (points) > 0, points, SCM_ARG1, __FUNCTION__, "list of coordinate pairs"); LY_ASSERT_TYPE (scm_is_number, blot, 2); @@ -364,19 +362,22 @@ LY_DEFINE (ly_round_filled_polygon, "ly:round-filled-polygon", for (SCM p = points; scm_is_pair (p); p = scm_cdr (p)) { SCM scm_pt = scm_car (p); - if (scm_is_pair (scm_pt)) { - pts.push_back (ly_scm2offset (scm_pt)); - } else { - // TODO: Print out warning - } + if (scm_is_pair (scm_pt)) + { + pts.push_back (ly_scm2offset (scm_pt)); + } + else + { + // TODO: Print out warning + } } return Lookup::round_filled_polygon (pts, scm_to_double (blot)).smobbed_copy (); } LY_DEFINE (ly_register_stencil_expression, "ly:register-stencil-expression", - 1, 0, 0, - (SCM symbol), - "Add @var{symbol} as head of a stencil expression.") + 1, 0, 0, + (SCM symbol), + "Add @var{symbol} as head of a stencil expression.") { LY_ASSERT_TYPE (ly_is_symbol, symbol, 1); register_stencil_head (symbol); @@ -384,17 +385,17 @@ LY_DEFINE (ly_register_stencil_expression, "ly:register-stencil-expression", } LY_DEFINE (ly_all_stencil_expressions, "ly:all-stencil-expressions", - 0, 0, 0, - (), - "Return all symbols recognized as stencil expressions.") + 0, 0, 0, + (), + "Return all symbols recognized as stencil expressions.") { return all_stencil_heads (); } LY_DEFINE (ly_stencil_scale, "ly:stencil-scale", - 3, 0, 0, (SCM stil, SCM x, SCM y), - "Scale @var{stil} using the horizontal and vertical scaling" - " factors @var{x} and @var{y}.") + 3, 0, 0, (SCM stil, SCM x, SCM y), + "Scale @var{stil} using the horizontal and vertical scaling" + " factors @var{x} and @var{y}.") { Stencil *s = unsmob_stencil (stil); LY_ASSERT_SMOB (Stencil, stil, 1); diff --git a/lily/stencil.cc b/lily/stencil.cc index 6a094d2890..25c7e15cf5 100644 --- a/lily/stencil.cc +++ b/lily/stencil.cc @@ -68,8 +68,8 @@ bool Stencil::is_empty () const { return (expr_ == SCM_EOL - || dim_[X_AXIS].is_empty () - || dim_[Y_AXIS].is_empty ()); + || dim_[X_AXIS].is_empty () + || dim_[Y_AXIS].is_empty ()); } SCM @@ -87,7 +87,7 @@ Stencil::extent_box () const void Stencil::rotate (Real a, Offset off) { - rotate_degrees (a * 180/M_PI, off); + rotate_degrees (a * 180 / M_PI, off); } /* @@ -112,9 +112,9 @@ Stencil::rotate_degrees_absolute (Real a, Offset absolute_off) */ expr_ = scm_list_n (ly_symbol2scm ("rotate-stencil"), - scm_list_2 (scm_from_double (a), - scm_cons (scm_from_double (x), scm_from_double (y))), - expr_, SCM_UNDEFINED); + scm_list_2 (scm_from_double (a), + scm_cons (scm_from_double (x), scm_from_double (y))), + expr_, SCM_UNDEFINED); /* * Calculate the new bounding box @@ -123,10 +123,10 @@ Stencil::rotate_degrees_absolute (Real a, Offset absolute_off) shifted_box.translate (-absolute_off); vector<Offset> pts; - pts.push_back (Offset (shifted_box.x ().at(LEFT), shifted_box.y ().at(DOWN))); - pts.push_back (Offset (shifted_box.x ().at(RIGHT), shifted_box.y ().at(DOWN))); - pts.push_back (Offset (shifted_box.x ().at(RIGHT), shifted_box.y ().at(UP))); - pts.push_back (Offset (shifted_box.x ().at(LEFT), shifted_box.y ().at(UP))); + pts.push_back (Offset (shifted_box.x ().at (LEFT), shifted_box.y ().at (DOWN))); + pts.push_back (Offset (shifted_box.x ().at (RIGHT), shifted_box.y ().at (DOWN))); + pts.push_back (Offset (shifted_box.x ().at (RIGHT), shifted_box.y ().at (UP))); + pts.push_back (Offset (shifted_box.x ().at (LEFT), shifted_box.y ().at (UP))); const Offset rot = complex_exp (Offset (0, a * M_PI / 180.0)); dim_.set_empty (); @@ -158,24 +158,24 @@ Stencil::translate (Offset o) while (a < NO_AXES) { if (isinf (o[a]) - || isnan (o[a]) - - // ugh, hardcoded. - || fabs (o[a]) > 1e6) - { - programming_error (String_convert::form_string ("Improbable offset for stencil: %f staff space", o[a]) - + "\n" - + "Setting to zero."); - o[a] = 0.0; - if (strict_infinity_checking) - scm_misc_error (__FUNCTION__, "Improbable offset.", SCM_EOL); - } + || isnan (o[a]) + + // ugh, hardcoded. + || fabs (o[a]) > 1e6) + { + programming_error (String_convert::form_string ("Improbable offset for stencil: %f staff space", o[a]) + + "\n" + + "Setting to zero."); + o[a] = 0.0; + if (strict_infinity_checking) + scm_misc_error (__FUNCTION__, "Improbable offset.", SCM_EOL); + } incr (a); } expr_ = scm_list_n (ly_symbol2scm ("translate-stencil"), - ly_offset2scm (o), - expr_, SCM_UNDEFINED); + ly_offset2scm (o), + expr_, SCM_UNDEFINED); if (!is_empty ()) dim_.translate (o); } @@ -192,9 +192,9 @@ void Stencil::scale (Real x, Real y) { expr_ = scm_list_3 (ly_symbol2scm ("scale-stencil"), - scm_list_2 (scm_from_double (x), - scm_from_double (y)), - expr_); + scm_list_2 (scm_from_double (x), + scm_from_double (y)), + expr_); dim_[X_AXIS] *= x; dim_[Y_AXIS] *= y; } @@ -247,7 +247,7 @@ Stencil::add_at_edge (Axis a, Direction d, Stencil const &s, Real padding) his_extent = i[-d]; Real offset = (my_extent.is_empty () ? 0.0 : my_extent[d] - his_extent) - + d * padding; + + d * padding; Stencil toadd (s); toadd.translate_axis (offset, a); @@ -258,11 +258,11 @@ Stencil Stencil::in_color (Real r, Real g, Real b) const { Stencil new_stencil (extent_box (), - scm_list_3 (ly_symbol2scm ("color"), - scm_list_3 (scm_from_double (r), - scm_from_double (g), - scm_from_double (b)), - expr ())); + scm_list_3 (ly_symbol2scm ("color"), + scm_list_3 (scm_from_double (r), + scm_from_double (g), + scm_from_double (b)), + expr ())); return new_stencil; } diff --git a/lily/stream-event-scheme.cc b/lily/stream-event-scheme.cc index 99f8a3c832..0ff9938863 100644 --- a/lily/stream-event-scheme.cc +++ b/lily/stream-event-scheme.cc @@ -20,22 +20,22 @@ #include "stream-event.hh" LY_DEFINE (ly_stream_event_p, "ly:stream-event?", - 1, 0, 0, (SCM obj), - "Is @code{@var{obj}} a @code{Stream_event} object?") + 1, 0, 0, (SCM obj), + "Is @code{@var{obj}} a @code{Stream_event} object?") { return scm_from_bool (unsmob_stream_event (obj)); } LY_DEFINE (ly_make_stream_event, "ly:make-stream-event", - 1, 1, 0, (SCM cl, SCM proplist), - "Create a stream event of class @var{cl} with the given" - " mutable property list.") + 1, 1, 0, (SCM cl, SCM proplist), + "Create a stream event of class @var{cl} with the given" + " mutable property list.") { LY_ASSERT_TYPE (ly_is_symbol, cl, 1); /* should be scm_list_p, but scm_list_p is expensive. */ LY_ASSERT_TYPE (scm_is_pair, proplist, 2); - + if (proplist == SCM_UNDEFINED) proplist = SCM_EOL; @@ -43,10 +43,10 @@ LY_DEFINE (ly_make_stream_event, "ly:make-stream-event", return e->unprotect (); } -LY_DEFINE (ly_event_property, "ly:event-property", +LY_DEFINE (ly_event_property, "ly:event-property", 2, 0, 0, (SCM sev, SCM sym), - "Get the property @var{sym} of stream event @var{mus}." - " If @var{sym} is undefined, return @code{'()}.") + "Get the property @var{sym} of stream event @var{mus}." + " If @var{sym} is undefined, return @code{'()}.") { LY_ASSERT_TYPE (unsmob_stream_event, sev, 1); LY_ASSERT_TYPE (ly_is_symbol, sym, 2); @@ -62,13 +62,13 @@ LY_DEFINE (ly_event_set_property_x, "ly:event-set-property!", { LY_ASSERT_TYPE (unsmob_stream_event, ev, 1); LY_ASSERT_TYPE (ly_is_symbol, sym, 2); - + return ly_prob_set_property_x (ev, sym, val); } LY_DEFINE (ly_event_deep_copy, "ly:event-deep-copy", - 1, 0, 0, (SCM m), - "Copy @var{m} and all sub expressions of@tie{}@var{m}.") + 1, 0, 0, (SCM m), + "Copy @var{m} and all sub expressions of@tie{}@var{m}.") { SCM copy = m; if (Stream_event *ev = unsmob_stream_event (m)) @@ -78,7 +78,7 @@ LY_DEFINE (ly_event_deep_copy, "ly:event-deep-copy", } else if (scm_is_pair (m)) copy = scm_cons (ly_event_deep_copy (scm_car (m)), - ly_event_deep_copy (scm_cdr (m))); + ly_event_deep_copy (scm_cdr (m))); return copy; } diff --git a/lily/stream-event.cc b/lily/stream-event.cc index 840695301a..489e0e0906 100644 --- a/lily/stream-event.cc +++ b/lily/stream-event.cc @@ -33,14 +33,14 @@ Stream_event::Stream_event () Stream_event::Stream_event (SCM event_class, SCM mutable_props) : Prob (ly_symbol2scm ("Stream_event"), - scm_list_1 (scm_cons (ly_symbol2scm ("class"), event_class))) + scm_list_1 (scm_cons (ly_symbol2scm ("class"), event_class))) { mutable_property_alist_ = mutable_props; } Stream_event::Stream_event (SCM class_name, Input *origin) : Prob (ly_symbol2scm ("Stream_event"), - scm_list_1 (scm_cons (ly_symbol2scm ("class"), class_name))) + scm_list_1 (scm_cons (ly_symbol2scm ("class"), class_name))) { if (origin) set_spot (origin); @@ -82,7 +82,7 @@ Stream_event::dump (SCM self) Stream_event *ev = unsmob_stream_event (self); // Reversed alists look prettier. return scm_cons (scm_reverse (ev->immutable_property_alist_), - scm_reverse (ev->mutable_property_alist_)); + scm_reverse (ev->mutable_property_alist_)); } SCM @@ -97,5 +97,5 @@ Stream_event::undump (SCM data) Stream_event * unsmob_stream_event (SCM m) { - return dynamic_cast<Stream_event*> (unsmob_prob (m)); + return dynamic_cast<Stream_event *> (unsmob_prob (m)); } diff --git a/lily/sustain-pedal.cc b/lily/sustain-pedal.cc index 74ac54930a..4ef137e7bb 100644 --- a/lily/sustain-pedal.cc +++ b/lily/sustain-pedal.cc @@ -20,7 +20,7 @@ #include "stencil.hh" #include "font-interface.hh" -// update comment --hwn +// update comment --hwn /* Urg. This is almost text @@ -61,15 +61,15 @@ Sustain_pedal::print (SCM smob) { string idx ("pedal."); if (text.substr (i, 3) == "Ped") - { - idx += "Ped"; - i += 2; - } + { + idx += "Ped"; + i += 2; + } else - idx += string (&text.c_str ()[i], 1); + idx += string (&text.c_str ()[i], 1); Stencil m = Font_interface::get_default_font (e)->find_by_name (idx); if (!m.is_empty ()) - mol.add_at_edge (X_AXIS, RIGHT, m, 0); + mol.add_at_edge (X_AXIS, RIGHT, m, 0); } return mol.smobbed_copy (); diff --git a/lily/system-start-delimiter-engraver.cc b/lily/system-start-delimiter-engraver.cc index a0bc503925..b5011db62d 100644 --- a/lily/system-start-delimiter-engraver.cc +++ b/lily/system-start-delimiter-engraver.cc @@ -40,7 +40,7 @@ public: struct Bracket_nesting_group : public Bracket_nesting_node { Spanner *delimiter_; - vector<Bracket_nesting_node*> children_; + vector<Bracket_nesting_node *> children_; SCM symbol_; void from_list (SCM); @@ -53,7 +53,6 @@ struct Bracket_nesting_group : public Bracket_nesting_node Bracket_nesting_group (); }; - struct Bracket_nesting_staff : public Bracket_nesting_node { Grob *staff_; @@ -62,7 +61,6 @@ struct Bracket_nesting_staff : public Bracket_nesting_node virtual bool add_staff (Grob *); }; - Bracket_nesting_group::Bracket_nesting_group () { symbol_ = SCM_EOL; @@ -85,9 +83,9 @@ Bracket_nesting_group::create_grobs (Engraver *engraver, SCM default_type) { SCM type = scm_is_symbol (symbol_) ? symbol_ : default_type; delimiter_ = engraver->make_spanner (ly_symbol2string (type).c_str (), - SCM_EOL); + SCM_EOL); - for (vsize i = 0 ; i < children_.size (); i++) + for (vsize i = 0; i < children_.size (); i++) children_[i]->create_grobs (engraver, default_type); } @@ -95,7 +93,7 @@ void Bracket_nesting_group::add_support (Grob *g) { Side_position_interface::add_support (g, delimiter_); - for (vsize i = 0 ; i < children_.size (); i++) + for (vsize i = 0; i < children_.size (); i++) children_[i]->add_support (g); } @@ -108,7 +106,7 @@ void Bracket_nesting_group::set_bound (Direction d, Grob *g) { delimiter_->set_bound (d, g); - for (vsize i = 0 ; i < children_.size (); i++) + for (vsize i = 0; i < children_.size (); i++) children_[i]->set_bound (d, g); } @@ -118,11 +116,10 @@ Bracket_nesting_group::set_nesting_support (Grob *parent) if (parent) Side_position_interface::add_support (delimiter_, parent); - for (vsize i = 0 ; i < children_.size (); i++) + for (vsize i = 0; i < children_.size (); i++) children_[i]->set_nesting_support (delimiter_); } - void Bracket_nesting_group::from_list (SCM x) { @@ -130,18 +127,18 @@ Bracket_nesting_group::from_list (SCM x) { SCM entry = scm_car (s); if (scm_is_pair (entry)) - { - Bracket_nesting_group *node = new Bracket_nesting_group; - node->from_list (entry); - children_.push_back (node); - } + { + Bracket_nesting_group *node = new Bracket_nesting_group; + node->from_list (entry); + children_.push_back (node); + } else if (entry == ly_symbol2scm ("SystemStartBrace") - || entry == ly_symbol2scm ("SystemStartBracket") - || entry == ly_symbol2scm ("SystemStartBar") - || entry == ly_symbol2scm ("SystemStartSquare")) - symbol_ = entry; + || entry == ly_symbol2scm ("SystemStartBracket") + || entry == ly_symbol2scm ("SystemStartBar") + || entry == ly_symbol2scm ("SystemStartSquare")) + symbol_ = entry; else - children_.push_back (new Bracket_nesting_staff (0)); + children_.push_back (new Bracket_nesting_staff (0)); } } @@ -151,18 +148,15 @@ Bracket_nesting_group::add_staff (Grob *grob) for (vsize i = 0; i < children_.size (); i++) { if (children_[i]->add_staff (grob)) - { - Pointer_group_interface::add_grob (delimiter_, - ly_symbol2scm ("elements"), grob); - return true; - } + { + Pointer_group_interface::add_grob (delimiter_, + ly_symbol2scm ("elements"), grob); + return true; + } } return false; } - - - /****************/ class System_start_delimiter_engraver : public Engraver @@ -197,7 +191,7 @@ System_start_delimiter_engraver::process_music () nesting_->from_list (hierarchy); nesting_->create_grobs (this, delimiter_name); nesting_->set_bound (LEFT, - unsmob_grob (get_property ("currentCommandColumn"))); + unsmob_grob (get_property ("currentCommandColumn"))); } } @@ -207,7 +201,7 @@ System_start_delimiter_engraver::finalize () if (nesting_) { nesting_->set_bound (RIGHT, - unsmob_grob (get_property ("currentCommandColumn"))); + unsmob_grob (get_property ("currentCommandColumn"))); nesting_->set_nesting_support (0); delete nesting_; @@ -239,23 +233,23 @@ ADD_ACKNOWLEDGER (System_start_delimiter_engraver, staff_symbol); ADD_ACKNOWLEDGER (System_start_delimiter_engraver, system_start_delimiter); ADD_TRANSLATOR (System_start_delimiter_engraver, - /* doc */ - "Create a system start delimiter (i.e., a" - " @code{SystemStartBar}, @code{SystemStartBrace}," - " @code{SystemStartBracket} or @code{SystemStartSquare}" - " spanner).", - - /* create */ - "SystemStartSquare " - "SystemStartBrace " - "SystemStartBracket " - "SystemStartBar ", - - /* read */ - "systemStartDelimiter " - "systemStartDelimiterHierarchy " - "currentCommandColumn ", - - /* write */ - "" - ); + /* doc */ + "Create a system start delimiter (i.e., a" + " @code{SystemStartBar}, @code{SystemStartBrace}," + " @code{SystemStartBracket} or @code{SystemStartSquare}" + " spanner).", + + /* create */ + "SystemStartSquare " + "SystemStartBrace " + "SystemStartBracket " + "SystemStartBar ", + + /* read */ + "systemStartDelimiter " + "systemStartDelimiterHierarchy " + "currentCommandColumn ", + + /* write */ + "" + ); diff --git a/lily/system-start-delimiter.cc b/lily/system-start-delimiter.cc index 25da049439..815d94e7cf 100644 --- a/lily/system-start-delimiter.cc +++ b/lily/system-start-delimiter.cc @@ -36,16 +36,16 @@ System_start_delimiter::staff_bracket (Grob *me, Real height) Font_metric *fm = Font_interface::get_default_font (me); Drul_array<Stencil> tips (fm->find_by_name ("brackettips.down"), - fm->find_by_name ("brackettips.up")); + fm->find_by_name ("brackettips.up")); Real thickness = robust_scm2double (me->get_property ("thickness"), 0.25); Real overlap = 0.1 * thickness; Box box (Interval (0, thickness), - Interval (-1, 1) - * (height / 2 + overlap)); - + Interval (-1, 1) + * (height / 2 + overlap)); + Stencil bracket = Lookup::filled_box (box); Direction d = DOWN; do @@ -54,7 +54,7 @@ System_start_delimiter::staff_bracket (Grob *me, Real height) bracket = Stencil (box, bracket.expr ()); bracket.translate_axis (-0.8, X_AXIS); - + return bracket; } @@ -63,18 +63,18 @@ System_start_delimiter::line_bracket (Grob *me, Real height) { Real thick = me->layout ()->get_dimension (ly_symbol2scm ("line-thickness")) - * robust_scm2double (me->get_property ("thickness"), 1); + * robust_scm2double (me->get_property ("thickness"), 1); Real w = 0.8; - + Stencil tip1 = Line_interface::make_line (thick, - Offset (0, -height/2), - Offset (w, -height/2)); + Offset (0, -height / 2), + Offset (w, -height / 2)); Stencil tip2 = Line_interface::make_line (thick, - Offset (0, height/2), - Offset (w, height/2)); + Offset (0, height / 2), + Offset (w, height / 2)); Stencil vline = Line_interface::make_line (thick, - Offset (0, -height/2), - Offset (0, height/2)); + Offset (0, -height / 2), + Offset (0, height / 2)); vline.add_stencil (tip1); vline.add_stencil (tip2); @@ -88,7 +88,7 @@ System_start_delimiter::simple_bar (Grob *me, Real h) Real lt = me->layout ()->get_dimension (ly_symbol2scm ("line-thickness")); Real w = lt * robust_scm2double (me->get_property ("thickness"), 1); return Lookup::round_filled_box (Box (Interval (0, w), Interval (-h / 2, h / 2)), - lt); + lt); } MAKE_SCHEME_CALLBACK (System_start_delimiter, print, 1); @@ -107,16 +107,16 @@ System_start_delimiter::print (SCM smob) Spanner *sp = dynamic_cast<Spanner *> (elts[i]); if (sp - && sp->get_bound (LEFT) == me->get_bound (LEFT)) - { - Interval dims = sp->extent (common, Y_AXIS); - if (!dims.is_empty ()) - { - non_empty_count ++; - ext.unite (dims); + && sp->get_bound (LEFT) == me->get_bound (LEFT)) + { + Interval dims = sp->extent (common, Y_AXIS); + if (!dims.is_empty ()) + { + non_empty_count++; + ext.unite (dims); staffspace = Staff_symbol_referencer::staff_space (sp); - } - } + } + } } SCM glyph_sym = me->get_property ("style"); @@ -155,7 +155,7 @@ System_start_delimiter::staff_brace (Grob *me, Real y) fm = Font_interface::get_default_font (me); int - lo = 0; + lo = 0; int hi = max ((int) fm->count () - 1, 2); /* do a binary search for each Y, not very efficient, but passable? */ @@ -165,48 +165,48 @@ System_start_delimiter::staff_brace (Grob *me, Real y) int cmp = (lo + hi) / 2; b = fm->get_indexed_char_dimensions (cmp); if (b[Y_AXIS].is_empty () || b[Y_AXIS].length () > y) - hi = cmp; + hi = cmp; else - lo = cmp; + lo = cmp; } while (hi - lo > 1); Stencil stil (fm->find_by_name ("brace" + to_string (lo))); - stil.translate_axis (-b[X_AXIS].length ()/2, X_AXIS); + stil.translate_axis (-b[X_AXIS].length () / 2, X_AXIS); stil.translate_axis (-0.2, X_AXIS); - + return stil; } ADD_INTERFACE (System_start_delimiter, - "The brace, bracket or bar in front of the system. The" - " following values for @code{style} are recognized:\n" - "\n" - "@table @code\n" - "@item bracket\n" - "A thick bracket, normally used to group similar" - " instruments in a score. Default for @code{StaffGroup}." - " @code{SystemStartBracket} uses this style.\n" - "@item brace\n" - "A @q{piano style} brace normally used for an instrument" - " that uses two staves. The default style for" - " @code{GrandStaff}. @code{SystemStartBrace} uses this" - " style.\n" - "@item bar-line\n" - "A simple line between the staves in a score. Default" - " for staves enclosed in @code{<<} and @code{>>}." - " @code{SystemStartBar} uses this style.\n" - "@item line-bracket\n" - "A simple square, normally used for subgrouping" - " instruments in a score. @code{SystemStartSquare} uses" - " this style.\n" - "@end table\n" - "\n" - "See also @file{input/regression/system-start-nesting.ly}.", - - /* properties */ - "collapse-height " - "style " - "thickness " - ); + "The brace, bracket or bar in front of the system. The" + " following values for @code{style} are recognized:\n" + "\n" + "@table @code\n" + "@item bracket\n" + "A thick bracket, normally used to group similar" + " instruments in a score. Default for @code{StaffGroup}." + " @code{SystemStartBracket} uses this style.\n" + "@item brace\n" + "A @q{piano style} brace normally used for an instrument" + " that uses two staves. The default style for" + " @code{GrandStaff}. @code{SystemStartBrace} uses this" + " style.\n" + "@item bar-line\n" + "A simple line between the staves in a score. Default" + " for staves enclosed in @code{<<} and @code{>>}." + " @code{SystemStartBar} uses this style.\n" + "@item line-bracket\n" + "A simple square, normally used for subgrouping" + " instruments in a score. @code{SystemStartSquare} uses" + " this style.\n" + "@end table\n" + "\n" + "See also @file{input/regression/system-start-nesting.ly}.", + + /* properties */ + "collapse-height " + "style " + "thickness " + ); diff --git a/lily/system.cc b/lily/system.cc index d151911ea5..8a071cce90 100644 --- a/lily/system.cc +++ b/lily/system.cc @@ -110,10 +110,10 @@ System::derived_mark () const Grob **ptr = &all_elements_->array_reference ()[0]; Grob **end = ptr + all_elements_->size (); while (ptr < end) - { - scm_gc_mark ((*ptr)->self_scm ()); - ptr++; - } + { + scm_gc_mark ((*ptr)->self_scm ()); + ptr++; + } } if (pscore_) @@ -136,20 +136,20 @@ System::do_break_substitution_and_fixup_refpoints () { Grob *g = all_elements_->grob (i); if (g->internal_has_interface (ly_symbol2scm ("only-prebreak-interface"))) - { - /* - Kill no longer needed grobs. - */ - Item *it = dynamic_cast<Item *> (g); - if (it && Item::is_non_musical (it)) - { - it->find_prebroken_piece (LEFT)->suicide (); - it->find_prebroken_piece (RIGHT)->suicide (); - } - g->suicide (); - } + { + /* + Kill no longer needed grobs. + */ + Item *it = dynamic_cast<Item *> (g); + if (it && Item::is_non_musical (it)) + { + it->find_prebroken_piece (LEFT)->suicide (); + it->find_prebroken_piece (RIGHT)->suicide (); + } + g->suicide (); + } else if (g->is_live ()) - g->do_break_processing (); + g->do_break_processing (); } /* @@ -162,11 +162,11 @@ System::do_break_substitution_and_fixup_refpoints () extract_grob_set (se, "all-elements", all_elts); for (vsize j = 0; j < all_elts.size (); j++) - { - Grob *g = all_elts[j]; - g->fixup_refpoint (); - } - + { + Grob *g = all_elts[j]; + g->fixup_refpoint (); + } + count += all_elts.size (); } @@ -190,11 +190,11 @@ System::do_break_substitution_and_fixup_refpoints () System *child = dynamic_cast<System *> (broken_intos_[i]); child->all_elements_->remove_duplicates (); for (vsize j = 0; j < child->all_elements_->size (); j++) - { - Grob *g = child->all_elements_->grob (j); + { + Grob *g = child->all_elements_->grob (j); - (void) g->get_property ("after-line-breaking"); - } + (void) g->get_property ("after-line-breaking"); + } } if (be_verbose_global) @@ -217,15 +217,15 @@ System::get_paper_systems () for (vsize i = 0; i < broken_intos_.size (); i++) { if (be_verbose_global) - progress_indication ("["); + progress_indication ("["); System *system = dynamic_cast<System *> (broken_intos_[i]); scm_vector_set_x (lines, scm_from_int (i), - system->get_paper_system ()); + system->get_paper_system ()); if (be_verbose_global) - progress_indication (to_string (i) + "]"); + progress_indication (to_string (i) + "]"); } return lines; } @@ -254,13 +254,13 @@ System::get_footnote_grobs_in_range (vector<Grob *> &out, vsize start, vsize end bool end_of_line_visible = true; if (Spanner *s = dynamic_cast<Spanner *>(footnote_grobs_[i])) { - Direction spanner_placement = robust_scm2dir (s->get_property ("spanner-placement"), LEFT); + Direction spanner_placement = robust_scm2dir (s->get_property ("spanner-placement"), LEFT); if (spanner_placement == CENTER) spanner_placement = LEFT; pos = s->spanned_rank_interval ()[spanner_placement]; } - + if (Item *item = dynamic_cast<Item *>(footnote_grobs_[i])) { if (!Item::break_visible (item)) @@ -345,19 +345,19 @@ System::break_into_pieces (vector<Column_x_positions> const &breaking) system->set_bound (RIGHT, c.back ()); SCM system_labels = SCM_EOL; for (vsize j = 0; j < c.size (); j++) - { - c[j]->translate_axis (breaking[i].config_[j], X_AXIS); - dynamic_cast<Paper_column *> (c[j])->set_system (system); - /* collect the column labels */ - collect_labels (c[j], &system_labels); - } + { + c[j]->translate_axis (breaking[i].config_[j], X_AXIS); + dynamic_cast<Paper_column *> (c[j])->set_system (system); + /* collect the column labels */ + collect_labels (c[j], &system_labels); + } /* - Collect labels from any loose columns too: theses will be set on - an empty bar line or a column which is otherwise unused mid-line + Collect labels from any loose columns too: theses will be set on + an empty bar line or a column which is otherwise unused mid-line */ vector<Grob *> loose (breaking[i].loose_cols_); for (vsize j = 0; j < loose.size (); j++) - collect_labels (loose[j], &system_labels); + collect_labels (loose[j], &system_labels); system->set_property ("labels", system_labels); @@ -455,8 +455,8 @@ struct Layer_entry }; bool -operator< (Layer_entry const &a, - Layer_entry const &b) +operator < (Layer_entry const &a, + Layer_entry const &b) { return a.layer_ < b.layer_; } @@ -486,18 +486,18 @@ System::get_paper_system () Stencil st = g->get_print_stencil (); if (st.expr () == SCM_EOL) - continue; + continue; Offset o; for (int a = X_AXIS; a < NO_AXES; a++) - o[Axis (a)] = g->relative_coordinate (this, Axis (a)); + o[Axis (a)] = g->relative_coordinate (this, Axis (a)); Offset extra = robust_scm2offset (g->get_property ("extra-offset"), - Offset (0, 0)) - * Staff_symbol_referencer::staff_space (g); + Offset (0, 0)) + * Staff_symbol_referencer::staff_space (g); /* Must copy the stencil, for we cannot change the stencil - cached in G. */ + cached in G. */ st.translate (o + extra); @@ -511,20 +511,20 @@ System::get_paper_system () Interval x (extent (this, X_AXIS)); Interval y (extent (this, Y_AXIS)); Stencil sys_stencil (Box (x, y), - scm_cons (ly_symbol2scm ("combine-stencil"), - exprs)); + scm_cons (ly_symbol2scm ("combine-stencil"), + exprs)); if (debug_skylines) { Skyline_pair *skylines = Skyline_pair::unsmob (get_property ("vertical-skylines")); if (skylines) - { - Stencil up - = Lookup::points_to_line_stencil (0.1, (*skylines)[UP].to_points (X_AXIS)); - Stencil down - = Lookup::points_to_line_stencil (0.1, (*skylines)[DOWN].to_points (X_AXIS)); - sys_stencil.add_stencil (up.in_color (255, 0, 0)); - sys_stencil.add_stencil (down.in_color (0, 255, 0)); - } + { + Stencil up + = Lookup::points_to_line_stencil (0.1, (*skylines)[UP].to_points (X_AXIS)); + Stencil down + = Lookup::points_to_line_stencil (0.1, (*skylines)[DOWN].to_points (X_AXIS)); + sys_stencil.add_stencil (up.in_color (255, 0, 0)); + sys_stencil.add_stencil (down.in_color (0, 255, 0)); + } } Grob *left_bound = this->get_bound (LEFT); @@ -545,10 +545,10 @@ System::get_paper_system () { extract_grob_set (align, "elements", staves); for (vsize i = 0; i < staves.size (); i++) - if (staves[i]->is_live () - && Page_layout_problem::is_spaceable (staves[i])) - staff_refpoints.add_point (staves[i]->relative_coordinate (this, - Y_AXIS)); + if (staves[i]->is_live () + && Page_layout_problem::is_spaceable (staves[i])) + staff_refpoints.add_point (staves[i]->relative_coordinate (this, + Y_AXIS)); } pl->set_property ("staff-refpoint-extent", ly_interval2scm (staff_refpoints)); @@ -573,11 +573,11 @@ System::broken_col_range (Item const *left, Item const *right) const i++; while (i < cols.size () - && Paper_column::get_rank (cols[i]) < end_rank) + && Paper_column::get_rank (cols[i]) < end_rank) { Paper_column *c = dynamic_cast<Paper_column *> (cols[i]); if (Paper_column::is_breakable (c) && !c->get_system ()) - ret.push_back (c); + ret.push_back (c); i++; } @@ -596,14 +596,14 @@ System::used_columns () const while (last_breakable--) { if (Paper_column::is_breakable (ro_columns [last_breakable])) - break; + break; } vector<Grob *> columns; for (int i = 0; i <= last_breakable; i++) { if (Paper_column::is_used (ro_columns[i])) - columns.push_back (ro_columns[i]); + columns.push_back (ro_columns[i]); } return columns; @@ -650,9 +650,9 @@ System::get_vertical_alignment () for (vsize i = 0; i < elts.size (); i++) if (Align_interface::has_interface (elts[i])) { - if (ret) - programming_error ("found multiple vertical alignments in this system"); - ret = elts[i]; + if (ret) + programming_error ("found multiple vertical alignments in this system"); + ret = elts[i]; } if (!ret) @@ -675,12 +675,12 @@ System::get_extremal_staff (Direction dir, Interval const &iv) for (vsize i = start; i != end; i += dir) { if (Hara_kiri_group_spanner::has_interface (elts[i])) - Hara_kiri_group_spanner::consider_suicide (elts[i]); + Hara_kiri_group_spanner::consider_suicide (elts[i]); Interval intersection = elts[i]->extent (this, X_AXIS); intersection.intersect (iv); if (elts[i]->is_live () && !intersection.is_empty ()) - return elts[i]; + return elts[i]; } return 0; } @@ -699,15 +699,15 @@ System::pure_refpoint_extent (vsize start, vsize end) for (vsize i = 0; i < offsets.size (); ++i) if (Page_layout_problem::is_spaceable (staves[i])) { - ret[UP] = offsets[i]; - break; + ret[UP] = offsets[i]; + break; } for (vsize i = offsets.size (); i--;) if (Page_layout_problem::is_spaceable (staves[i])) { - ret[DOWN] = offsets[i]; - break; + ret[DOWN] = offsets[i]; + break; } return ret; @@ -727,16 +727,16 @@ System::part_of_line_pure_height (vsize start, vsize end, bool begin) for (vsize i = 0; i < staves.size (); ++i) { Interval iv = begin - ? Axis_group_interface::begin_of_line_pure_height (staves[i], start) - : Axis_group_interface::rest_of_line_pure_height (staves[i], start, end); + ? Axis_group_interface::begin_of_line_pure_height (staves[i], start) + : Axis_group_interface::rest_of_line_pure_height (staves[i], start, end); if (i < offsets.size ()) - iv.translate (offsets[i]); + iv.translate (offsets[i]); ret.unite (iv); } Interval other_elements = begin - ? Axis_group_interface::begin_of_line_pure_height (this, start) - : Axis_group_interface::rest_of_line_pure_height (this, start, end); + ? Axis_group_interface::begin_of_line_pure_height (this, start) + : Axis_group_interface::rest_of_line_pure_height (this, start, end); ret.unite (other_elements); @@ -771,22 +771,22 @@ System::calc_pure_relevant_grobs (SCM smob) for (vsize i = 0; i < elts.size (); ++i) { if (!Axis_group_interface::has_interface (elts[i])) - { - if (to_boolean (scm_apply_1 (pure_relevant_p, elts[i]->self_scm (), SCM_EOL))) - relevant_grobs.push_back (elts[i]); - - if (Item *it = dynamic_cast<Item*> (elts[i])) - { - Direction d = LEFT; - do - { - Item *piece = it->find_prebroken_piece (d); - if (piece && to_boolean (scm_apply_1 (pure_relevant_p, piece->self_scm (), SCM_EOL))) - relevant_grobs.push_back (piece); - } - while (flip (&d) != LEFT); - } - } + { + if (to_boolean (scm_apply_1 (pure_relevant_p, elts[i]->self_scm (), SCM_EOL))) + relevant_grobs.push_back (elts[i]); + + if (Item *it = dynamic_cast<Item *> (elts[i])) + { + Direction d = LEFT; + do + { + Item *piece = it->find_prebroken_piece (d); + if (piece && to_boolean (scm_apply_1 (pure_relevant_p, piece->self_scm (), SCM_EOL))) + relevant_grobs.push_back (piece); + } + while (flip (&d) != LEFT); + } + } } SCM grobs_scm = Grob_array::make_array (); @@ -817,16 +817,16 @@ System::calc_pure_height (SCM smob, SCM start_scm, SCM end_scm) return ly_interval2scm (begin); } -Grob* +Grob * System::get_pure_bound (Direction d, int start, int end) { vector<vsize> ranks = pscore_->get_break_ranks (); vector<vsize> indices = pscore_->get_break_indices (); - vector<Grob*> cols = pscore_->get_columns (); + vector<Grob *> cols = pscore_->get_columns (); vsize target_rank = (d == LEFT ? start : end); - vector<vsize>::const_iterator i = - lower_bound (ranks.begin (), ranks.end (), target_rank, std::less<vsize> ()); + vector<vsize>::const_iterator i + = lower_bound (ranks.begin (), ranks.end (), target_rank, std::less<vsize> ()); if (i != ranks.end () && (*i) == target_rank) return cols[indices[i - ranks.begin ()]]; @@ -834,21 +834,21 @@ System::get_pure_bound (Direction d, int start, int end) return 0; } -Grob* +Grob * System::get_maybe_pure_bound (Direction d, bool pure, int start, int end) { return pure ? get_pure_bound (d, start, end) : get_bound (d); } ADD_INTERFACE (System, - "This is the top-level object: Each object in a score" - " ultimately has a @code{System} object as its X and" - " Y@tie{}parent.", - - /* properties */ - "all-elements " - "columns " - "labels " - "pure-Y-extent " - "skyline-horizontal-padding " - ); + "This is the top-level object: Each object in a score" + " ultimately has a @code{System} object as its X and" + " Y@tie{}parent.", + + /* properties */ + "all-elements " + "columns " + "labels " + "pure-Y-extent " + "skyline-horizontal-padding " + ); diff --git a/lily/tab-note-heads-engraver.cc b/lily/tab-note-heads-engraver.cc index 4e3f393a2d..b899ac4cda 100644 --- a/lily/tab-note-heads-engraver.cc +++ b/lily/tab-note-heads-engraver.cc @@ -86,20 +86,20 @@ void Tab_note_heads_engraver::process_music () { SCM tab_strings = articulation_list (note_events_, - tabstring_events_, - "string-number-event"); + tabstring_events_, + "string-number-event"); SCM defined_fingers = articulation_list (note_events_, - fingering_events_, - "fingering-event"); + fingering_events_, + "fingering-event"); SCM tab_notes = ly_cxx_vector_to_list (note_events_); SCM proc = get_property ("noteToFretFunction"); SCM string_fret_finger = SCM_EOL; if (ly_is_procedure (proc)) string_fret_finger = scm_call_3 (proc, - context ()->self_scm (), - tab_notes, - scm_list_2 (tab_strings, - defined_fingers)); + context ()->self_scm (), + tab_notes, + scm_list_2 (tab_strings, + defined_fingers)); SCM note_entry = SCM_EOL; SCM string_number = SCM_EOL; SCM fret = SCM_EOL; @@ -114,22 +114,22 @@ Tab_note_heads_engraver::process_music () if (string_fret_finger != SCM_EOL) for (vsize i = 0; i < fret_count; i++) { - note_entry = scm_list_ref (string_fret_finger, scm_from_int (i)); - string_number = scm_car (note_entry); + note_entry = scm_list_ref (string_fret_finger, scm_from_int (i)); + string_number = scm_car (note_entry); if (string_number != SCM_BOOL_F) { - fret = scm_cadr (note_entry); - fret_label = scm_call_3 (fret_procedure, - context ()->self_scm (), - string_number, - fret); - index = length_changed ? 0 : i; - Item *note = make_item ("TabNoteHead", note_events_[index]->self_scm ()); - note->set_property ("text", fret_label); - staff_position = scm_call_2 (staff_line_procedure, - context ()->self_scm (), - string_number); - note->set_property ("staff-position", staff_position); + fret = scm_cadr (note_entry); + fret_label = scm_call_3 (fret_procedure, + context ()->self_scm (), + string_number, + fret); + index = length_changed ? 0 : i; + Item *note = make_item ("TabNoteHead", note_events_[index]->self_scm ()); + note->set_property ("text", fret_label); + staff_position = scm_call_2 (staff_line_procedure, + context ()->self_scm (), + string_number); + note->set_property ("staff-position", staff_position); } } } @@ -143,26 +143,26 @@ Tab_note_heads_engraver::stop_translation_timestep () } ADD_TRANSLATOR (Tab_note_heads_engraver, - /* doc */ - "Generate one or more tablature note heads from event of type" - " @code{NoteEvent}.", - - /* create */ - "TabNoteHead ", - - /* read */ - "defaultStrings " - "fretLabels " - "highStringOne " - "middleCPosition " - "minimumFret " - "noteToFretFunction " - "stringOneTopmost " - "stringTunings " - "tablatureFormat " - "tabStaffLineLayoutFunction ", - - /* write */ - "" - ); + /* doc */ + "Generate one or more tablature note heads from event of type" + " @code{NoteEvent}.", + + /* create */ + "TabNoteHead ", + + /* read */ + "defaultStrings " + "fretLabels " + "highStringOne " + "middleCPosition " + "minimumFret " + "noteToFretFunction " + "stringOneTopmost " + "stringTunings " + "tablatureFormat " + "tabStaffLineLayoutFunction ", + + /* write */ + "" + ); diff --git a/lily/tab-staff-symbol-engraver.cc b/lily/tab-staff-symbol-engraver.cc index 5b33971127..0fd7f8296a 100644 --- a/lily/tab-staff-symbol-engraver.cc +++ b/lily/tab-staff-symbol-engraver.cc @@ -44,16 +44,16 @@ Tab_staff_symbol_engraver::Tab_staff_symbol_engraver () ADD_ACKNOWLEDGER (Tab_staff_symbol_engraver, staff_symbol); ADD_TRANSLATOR (Tab_staff_symbol_engraver, - /* doc */ - "Create a tablature staff symbol, but look at" - " @code{stringTunings} for the number of lines.", + /* doc */ + "Create a tablature staff symbol, but look at" + " @code{stringTunings} for the number of lines.", - /* create */ - "StaffSymbol ", + /* create */ + "StaffSymbol ", - /* read */ - "stringTunings ", + /* read */ + "stringTunings ", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/tab-tie-follow-engraver.cc b/lily/tab-tie-follow-engraver.cc index a815c5a3bb..bd2bde2987 100644 --- a/lily/tab-tie-follow-engraver.cc +++ b/lily/tab-tie-follow-engraver.cc @@ -81,12 +81,12 @@ Tab_tie_follow_engraver::stop_translation_timestep () bool spanner_start = false; for (vsize j = 0; j < slurs_.size (); j++) { - Item* left_item = slurs_[j]->get_bound (LEFT); + Item *left_item = slurs_[j]->get_bound (LEFT); if (left_item) { SCM left_cause = left_item->get_property ("cause"); Item *slur_cause = unsmob_item (left_cause); - if (slur_cause == note_heads_[k]) + if (slur_cause == note_heads_[k]) { note_heads_[k]->set_property ("span-start", SCM_BOOL_T); spanner_start = true; @@ -107,25 +107,24 @@ Tab_tie_follow_engraver::stop_translation_timestep () } slurs_.clear (); glissandi_.clear (); - note_heads_.clear(); + note_heads_.clear (); } ADD_ACKNOWLEDGER (Tab_tie_follow_engraver, slur); ADD_ACKNOWLEDGER (Tab_tie_follow_engraver, glissando); ADD_ACKNOWLEDGER (Tab_tie_follow_engraver, tab_note_head); - ADD_TRANSLATOR (Tab_tie_follow_engraver, - /* doc */ - "Adjust TabNoteHead properties when a tie is followed" - " by a slur or glissando.", + /* doc */ + "Adjust TabNoteHead properties when a tie is followed" + " by a slur or glissando.", - /* create */ - " ", + /* create */ + " ", - /* read */ + /* read */ " ", - /* write */ + /* write */ " " - ); + ); diff --git a/lily/template5.cc b/lily/template5.cc index 2537ea2bbe..267fdbdc24 100644 --- a/lily/template5.cc +++ b/lily/template5.cc @@ -32,7 +32,6 @@ Interval_t<Rational>::infinity () return infty; } - template<> string Interval_t<Rational>::T_to_string (Rational a) @@ -42,18 +41,16 @@ Interval_t<Rational>::T_to_string (Rational a) template INTERVAL__INSTANTIATE (Rational); - template<> Moment Interval_t<Moment>::infinity () { Moment infty; - + infty.main_part_.set_infinite (1); return infty; } - template<> string Interval_t<Moment>::T_to_string (Moment a) diff --git a/lily/tempo-performer.cc b/lily/tempo-performer.cc index 95de5faa83..ca580578c9 100644 --- a/lily/tempo-performer.cc +++ b/lily/tempo-performer.cc @@ -33,12 +33,12 @@ public: protected: - virtual void derived_mark () const; + virtual void derived_mark () const; void stop_translation_timestep (); void process_music (); private: Audio_tempo *audio_; - SCM last_tempo_; + SCM last_tempo_; }; void @@ -86,15 +86,15 @@ Tempo_performer::stop_translation_timestep () } ADD_TRANSLATOR (Tempo_performer, - /* doc */ - "", + /* doc */ + "", - /* create */ - "", + /* create */ + "", - /* read */ - "tempoWholesPerMinute ", + /* read */ + "tempoWholesPerMinute ", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/text-engraver.cc b/lily/text-engraver.cc index 270855febd..1073aa2fc4 100644 --- a/lily/text-engraver.cc +++ b/lily/text-engraver.cc @@ -59,7 +59,7 @@ Text_engraver::process_music () Item *text = make_item ("TextScript", r->self_scm ()); int priority = robust_scm2int (text->get_property ("script-priority"), - 200); + 200); /* see script-engraver.cc */ priority += i; @@ -68,7 +68,7 @@ Text_engraver::process_music () Direction dir = to_dir (r->get_property ("direction")); if (dir) - set_grob_direction (text, dir); + set_grob_direction (text, dir); SCM mark = r->get_property ("text"); @@ -87,15 +87,15 @@ Text_engraver::Text_engraver () } ADD_TRANSLATOR (Text_engraver, - /* doc */ - "Create text scripts.", + /* doc */ + "Create text scripts.", - /* create */ - "TextScript ", + /* create */ + "TextScript ", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/text-interface.cc b/lily/text-interface.cc index 983902f6af..7bb4ceadc0 100644 --- a/lily/text-interface.cc +++ b/lily/text-interface.cc @@ -42,7 +42,7 @@ replace_whitespace (string *str) // avoid the locale-dependent isspace if (cur == '\n' || cur == '\t' || cur == '\v') - (*str)[i] = ' '; + (*str)[i] = ' '; vsize char_len = utf8_char_len (cur); @@ -53,8 +53,8 @@ replace_whitespace (string *str) MAKE_SCHEME_CALLBACK (Text_interface, interpret_string, 3); SCM Text_interface::interpret_string (SCM layout_smob, - SCM props, - SCM markup) + SCM props, + SCM markup) { LY_ASSERT_SMOB (Output_def, layout_smob, 1); LY_ASSERT_TYPE (scm_is_string, markup, 3); @@ -71,8 +71,8 @@ Text_interface::interpret_string (SCM layout_smob, if it matches one of the music font encodings. --pmccarty */ SCM encoding = ly_chain_assoc_get (ly_symbol2scm ("font-encoding"), - props, - SCM_BOOL_F); + props, + SCM_BOOL_F); SCM music_encodings = ly_lily_module_constant ("all-music-font-encodings"); bool is_music = (scm_memq (encoding, music_encodings) != SCM_BOOL_F); @@ -80,14 +80,14 @@ Text_interface::interpret_string (SCM layout_smob, } MAKE_SCHEME_CALLBACK_WITH_OPTARGS (Text_interface, interpret_markup, 3, 0, - "Convert a text markup into a stencil." -" Takes three arguments, @var{layout}, @var{props}, and @var{markup}.\n" -"\n" -"@var{layout} is a @code{\\layout} block; it may be obtained from a grob with" -" @code{ly:grob-layout}. @var{props} is an alist chain, i.e. a list of" -" alists. This is typically obtained with" -" @code{(ly:grob-alist-chain grob (ly:output-def-lookup layout 'text-font-defaults))}." -" @var{markup} is the markup text to be processed."); + "Convert a text markup into a stencil." + " Takes three arguments, @var{layout}, @var{props}, and @var{markup}.\n" + "\n" + "@var{layout} is a @code{\\layout} block; it may be obtained from a grob with" + " @code{ly:grob-layout}. @var{props} is an alist chain, i.e. a list of" + " alists. This is typically obtained with" + " @code{(ly:grob-alist-chain grob (ly:output-def-lookup layout 'text-font-defaults))}." + " @var{markup} is the markup text to be processed."); SCM Text_interface::interpret_markup (SCM layout_smob, SCM props, SCM markup) { @@ -98,7 +98,7 @@ Text_interface::interpret_markup (SCM layout_smob, SCM props, SCM markup) SCM func = scm_car (markup); SCM args = scm_cdr (markup); if (!is_markup (markup)) - programming_error ("markup head has no markup signature"); + programming_error ("markup head has no markup signature"); return scm_apply_2 (func, layout_smob, props, args); } @@ -134,10 +134,10 @@ bool Text_interface::is_markup (SCM x) { return (scm_is_string (x) - || (scm_is_pair (x) - && SCM_BOOL_F - != scm_object_property (scm_car (x), - ly_symbol2scm ("markup-signature")))); + || (scm_is_pair (x) + && SCM_BOOL_F + != scm_object_property (scm_car (x), + ly_symbol2scm ("markup-signature")))); } bool @@ -147,20 +147,19 @@ Text_interface::is_markup_list (SCM x) return scm_is_true (scm_call_1 (music_list_p, x)); } - ADD_INTERFACE (Text_interface, - "A Scheme markup text, see @ruser{Formatting text} and" - " @rextend{New markup command definition}.\n" - "\n" - "There are two important commands:" - " @code{ly:text-interface::print}, which is a" - " grob callback, and" - " @code{ly:text-interface::interpret-markup}.", - - /* properties */ - "baseline-skip " - "text " - "word-space " - "text-direction " - ); + "A Scheme markup text, see @ruser{Formatting text} and" + " @rextend{New markup command definition}.\n" + "\n" + "There are two important commands:" + " @code{ly:text-interface::print}, which is a" + " grob callback, and" + " @code{ly:text-interface::interpret-markup}.", + + /* properties */ + "baseline-skip " + "text " + "word-space " + "text-direction " + ); diff --git a/lily/text-spanner-engraver.cc b/lily/text-spanner-engraver.cc index c18bf098f2..0338960b49 100644 --- a/lily/text-spanner-engraver.cc +++ b/lily/text-spanner-engraver.cc @@ -69,28 +69,28 @@ Text_spanner_engraver::process_music () if (event_drul_[STOP]) { if (!span_) - event_drul_[STOP]->origin ()->warning (_ ("cannot find start of text spanner")); + event_drul_[STOP]->origin ()->warning (_ ("cannot find start of text spanner")); else - { - finished_ = span_; - announce_end_grob (finished_, SCM_EOL); - span_ = 0; - current_event_ = 0; - } + { + finished_ = span_; + announce_end_grob (finished_, SCM_EOL); + span_ = 0; + current_event_ = 0; + } } if (event_drul_[START]) { if (current_event_) - event_drul_[START]->origin ()->warning (_ ("already have a text spanner")); + event_drul_[START]->origin ()->warning (_ ("already have a text spanner")); else - { - current_event_ = event_drul_[START]; - span_ = make_spanner ("TextSpanner", event_drul_[START]->self_scm ()); + { + current_event_ = event_drul_[START]; + span_ = make_spanner ("TextSpanner", event_drul_[START]->self_scm ()); - Side_position_interface::set_axis (span_, Y_AXIS); - event_drul_[START] = 0; - } + Side_position_interface::set_axis (span_, Y_AXIS); + event_drul_[START] = 0; + } } } @@ -100,10 +100,10 @@ Text_spanner_engraver::typeset_all () if (finished_) { if (!finished_->get_bound (RIGHT)) - { - Grob *e = unsmob_grob (get_property ("currentMusicalColumn")); - finished_->set_bound (RIGHT, e); - } + { + Grob *e = unsmob_grob (get_property ("currentMusicalColumn")); + finished_->set_bound (RIGHT, e); + } finished_ = 0; } } @@ -139,33 +139,33 @@ Text_spanner_engraver::acknowledge_note_column (Grob_info info) if (span_) { Pointer_group_interface::add_grob (span_, - ly_symbol2scm ("note-columns"), - info.grob ()); + ly_symbol2scm ("note-columns"), + info.grob ()); if (!span_->get_bound (LEFT)) - add_bound_item (span_, info.grob ()); + add_bound_item (span_, info.grob ()); } else if (finished_) { Pointer_group_interface::add_grob (finished_, - ly_symbol2scm ("note-columns"), - info.grob ()); + ly_symbol2scm ("note-columns"), + info.grob ()); if (!finished_->get_bound (RIGHT)) - add_bound_item (finished_, info.grob ()); + add_bound_item (finished_, info.grob ()); } } ADD_ACKNOWLEDGER (Text_spanner_engraver, note_column); ADD_TRANSLATOR (Text_spanner_engraver, - /* doc */ - "Create text spanner from an event.", + /* doc */ + "Create text spanner from an event.", - /* create */ - "TextSpanner ", + /* create */ + "TextSpanner ", - /* read */ - "currentMusicalColumn ", + /* read */ + "currentMusicalColumn ", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/tie-column.cc b/lily/tie-column.cc index 6e0eaecec0..c73694d334 100644 --- a/lily/tie-column.cc +++ b/lily/tie-column.cc @@ -39,19 +39,19 @@ void Tie_column::add_tie (Grob *tc, Grob *tie) { Spanner *me = dynamic_cast<Spanner *> (tc); - + if (tie->get_parent (Y_AXIS) && Tie_column::has_interface (tie->get_parent (Y_AXIS))) return; if (!me->get_bound (LEFT) || (Paper_column::get_rank (me->get_bound (LEFT)->get_column ()) - > Paper_column::get_rank (dynamic_cast<Spanner*> (tie)->get_bound (LEFT)->get_column ()))) + > Paper_column::get_rank (dynamic_cast<Spanner *> (tie)->get_bound (LEFT)->get_column ()))) { - me->set_bound (LEFT, Tie::head (tie, LEFT)); - me->set_bound (RIGHT, Tie::head (tie, RIGHT)); + me->set_bound (LEFT, Tie::head (tie, LEFT)); + me->set_bound (RIGHT, Tie::head (tie, RIGHT)); } - + tie->set_parent (me, Y_AXIS); Pointer_group_interface::add_grob (me, ly_symbol2scm ("ties"), tie); } @@ -69,14 +69,14 @@ Tie_column::before_line_breaking (SCM smob) Spanner *tie = dynamic_cast<Spanner *> (unsmob_grob (scm_car (s))); Direction dir = LEFT; do - { - if (dir * tie->get_bound (dir)->get_column ()->get_rank () - > dir * me->get_bound (dir)->get_column ()->get_rank ()) - me->set_bound (dir, Tie::head (tie, dir)); - } + { + if (dir * tie->get_bound (dir)->get_column ()->get_rank () + > dir * me->get_bound (dir)->get_column ()->get_rank ()) + me->set_bound (dir, Tie::head (tie, dir)); + } while (flip (&dir) != LEFT); } - + return SCM_UNSPECIFIED; } @@ -86,7 +86,7 @@ Tie_column::calc_positioning_done (SCM smob) { Grob *me = unsmob_grob (smob); extract_grob_set (me, "ties", ro_ties); - vector<Grob*> ties (ro_ties); + vector<Grob *> ties (ro_ties); if (!ties.size ()) return SCM_BOOL_T; @@ -103,26 +103,24 @@ Tie_column::calc_positioning_done (SCM smob) for (vsize i = 0; i < base.size (); i++) { SCM cp = Tie::get_control_points (ties[i], problem.common_x_refpoint (), - base[i], - problem.details_); + base[i], + problem.details_); ties[i]->set_property ("control-points", cp); set_grob_direction (ties[i], - base[i].dir_); + base[i].dir_); problem.set_debug_scoring (base); } return SCM_BOOL_T; } - - ADD_INTERFACE (Tie_column, - "Object that sets directions of multiple ties in a tied" - " chord.", + "Object that sets directions of multiple ties in a tied" + " chord.", - /* properties */ - "positioning-done " - "tie-configuration " - ); + /* properties */ + "positioning-done " + "tie-configuration " + ); diff --git a/lily/tie-configuration.cc b/lily/tie-configuration.cc index f84908c651..c415942b5d 100644 --- a/lily/tie-configuration.cc +++ b/lily/tie-configuration.cc @@ -26,13 +26,12 @@ int Tie_configuration::compare (Tie_configuration const &a, - Tie_configuration const &b) + Tie_configuration const &b) { if (a.position_ - b.position_) return sign (a.position_ - b.position_); return sign (a.dir_ - b.dir_); } - Tie_configuration::Tie_configuration () { @@ -44,19 +43,17 @@ Tie_configuration::Tie_configuration () column_ranks_ = Drul_array<int> (0, 0); } - void Tie_configuration::center_tie_vertically (Tie_details const &details) { Bezier b = get_untransformed_bezier (details); Offset middle = b.curve_point (0.5); Offset edge = b.curve_point (0.0); - Real center = (edge[Y_AXIS] + middle[Y_AXIS])/2.0; + Real center = (edge[Y_AXIS] + middle[Y_AXIS]) / 2.0; delta_y_ = - dir_ * center; } - Bezier Tie_configuration::get_transformed_bezier (Tie_details const &details) const { @@ -64,7 +61,7 @@ Tie_configuration::get_transformed_bezier (Tie_details const &details) const b.scale (1, dir_); b.translate (Offset (attachment_x_[LEFT], - delta_y_ + details.staff_space_ * 0.5 * position_)); + delta_y_ + details.staff_space_ * 0.5 * position_)); return b; } @@ -82,8 +79,8 @@ Tie_configuration::get_untransformed_bezier (Tie_details const &details) const l = 1.0; } return slur_shape (l, - details.height_limit_, - details.ratio_); + details.height_limit_, + details.ratio_); } int @@ -94,7 +91,7 @@ Tie_configuration::column_span_length () const Real Tie_configuration::distance (Tie_configuration const &a, - Tie_configuration const &b) + Tie_configuration const &b) { Real d = 3 * (a.position_ - b.position_); @@ -104,7 +101,6 @@ Tie_configuration::distance (Tie_configuration const &a, return d + (2 + (a.dir_ - b.dir_)); } - void Tie_configuration::add_score (Real s, string desc) { @@ -120,8 +116,8 @@ Tie_configuration::height (Tie_details const &details) const Real l = attachment_x_.length (); return slur_shape (l, - details.height_limit_, - details.ratio_).curve_point (0.5)[Y_AXIS]; + details.height_limit_, + details.ratio_).curve_point (0.5)[Y_AXIS]; } Ties_configuration::Ties_configuration () @@ -147,7 +143,7 @@ Ties_configuration::add_tie_score (Real s, int i, string desc) if (s) { while (tie_score_cards_.size () < size ()) - tie_score_cards_.push_back (""); + tie_score_cards_.push_back (""); tie_score_cards_[i] += to_string ("%s=%.2f ", desc.c_str (), s); } @@ -168,15 +164,14 @@ Ties_configuration::score () const return score_; } - string Ties_configuration::complete_tie_card (vsize i) const { string s; s += to_string ("%d (%.2f) %c: ", (*this)[i].position_, (*this)[i].delta_y_, - ((*this)[i].dir_ == UP ? 'u' : 'd')) - + (*this)[i].card () + (*this).tie_card (i); - + ((*this)[i].dir_ == UP ? 'u' : 'd')) + + (*this)[i].card () + (*this).tie_card (i); + /* this is a little awkward, but we must decide where to put aggregrates. @@ -186,7 +181,7 @@ Ties_configuration::complete_tie_card (vsize i) const if (i + 1 == size ()) s += to_string ("TOTAL=%.2f", score ()); - + return s; } @@ -194,7 +189,7 @@ Ties_configuration::complete_tie_card (vsize i) const string Ties_configuration::complete_score_card () const { - string s; + string s; for (vsize i = 0; i < size (); i++) { s += complete_tie_card (i); @@ -203,8 +198,6 @@ Ties_configuration::complete_score_card () const return s; } - - string Ties_configuration::card () const { diff --git a/lily/tie-details.cc b/lily/tie-details.cc index f169e1fae9..eee1aa2e91 100644 --- a/lily/tie-details.cc +++ b/lily/tie-details.cc @@ -25,9 +25,8 @@ #include "warn.hh" #include "tie-details.hh" - /* - this is a macro because we want ly_symbol2scm() + this is a macro because we want ly_symbol2scm() */ #define get_real_detail(src, defvalue) \ robust_scm2double(ly_assoc_get (ly_symbol2scm (src), details, SCM_EOL), defvalue) @@ -39,23 +38,22 @@ Tie_details::from_grob (Grob *me) { staff_symbol_referencer_ = me; staff_space_ = Staff_symbol_referencer::staff_space (me); - + neutral_direction_ = to_dir (me->get_property ("neutral-direction")); if (!neutral_direction_) neutral_direction_ = DOWN; - + SCM details = me->get_property ("details"); height_limit_ = get_real_detail ("height-limit", 0.75); - ratio_ = get_real_detail ("ratio", .333); + ratio_ = get_real_detail ("ratio", .333); between_length_limit_ = get_real_detail ("between-length-limit", 1.0); - + wrong_direction_offset_penalty_ = get_real_detail ("wrong-direction-offset-penalty", 10); - + min_length_ = get_real_detail ("min-length", 1.0); min_length_penalty_factor_ = get_real_detail ("min-length-penalty-factor", 1.0); - // in half-space center_staff_line_clearance_ = get_real_detail ("center-staff-line-clearance", 0.4); tip_staff_line_clearance_ = get_real_detail ("tip-staff-line-clearance", 0.4); @@ -73,7 +71,7 @@ Tie_details::from_grob (Grob *me) intra_space_threshold_ = get_real_detail ("intra-space-threshold", 1.0); outer_tie_length_symmetry_penalty_factor_ = get_real_detail ("outer-tie-length-symmetry-penalty-factor", 3.0); outer_tie_vertical_distance_symmetry_penalty_factor_ = get_real_detail ("outer-tie-vertical-distance-symmetry-penalty-factor", 3.0); - + outer_tie_vertical_gap_ = get_real_detail ("outer-tie-vertical-gap", 0.15); single_tie_region_size_ = get_int_detail ("single-tie-region-size", 3); @@ -83,8 +81,8 @@ Tie_details::from_grob (Grob *me) Tie_details::Tie_details () { - staff_space_ = 1.0; + staff_space_ = 1.0; height_limit_ = 1.0; - ratio_ = .333; + ratio_ = .333; } diff --git a/lily/tie-engraver.cc b/lily/tie-engraver.cc index edaba06c7c..251997ce31 100644 --- a/lily/tie-engraver.cc +++ b/lily/tie-engraver.cc @@ -67,9 +67,9 @@ struct Head_event_tuple class Tie_engraver : public Engraver { Stream_event *event_; - vector<Grob*> now_heads_; + vector<Grob *> now_heads_; vector<Head_event_tuple> heads_to_tie_; - vector<Grob*> ties_; + vector<Grob *> ties_; Spanner *tie_column_; @@ -114,7 +114,7 @@ void Tie_engraver::report_unterminated_tie (Head_event_tuple const &tie_start) // moment that created a tie, so this is not necessarily an unterminated // tie. Happens e.g. for <c e g>~ g if (!tie_start.tie_from_chord_created) - tie_start.head_->warning (_("unterminated tie")); + tie_start.head_->warning (_ ("unterminated tie")); } /* @@ -134,8 +134,8 @@ Tie_engraver::process_music () { bool busy = event_; for (vsize i = 0; !busy && i < heads_to_tie_.size (); i++) - busy |= (heads_to_tie_[i].tie_event_ - || heads_to_tie_[i].tie_stream_event_); + busy |= (heads_to_tie_[i].tie_event_ + || heads_to_tie_[i].tie_stream_event_); if (busy) context ()->set_property ("tieMelismaBusy", SCM_BOOL_T); @@ -154,51 +154,50 @@ Tie_engraver::acknowledge_note_head (Grob_info i) Stream_event *left_ev = unsmob_stream_event (th->get_property ("cause")); /* - maybe should check positions too. + maybe should check positions too. */ if (!right_ev || !left_ev) - continue; + continue; /* Make a tie only if pitches are equal or if event end was not generated by Completion_heads_engraver. */ if (ly_is_equal (right_ev->get_property ("pitch"), left_ev->get_property ("pitch")) - && (!Tie_engraver::has_autosplit_end (left_ev))) - { - Grob *p = new Spanner (heads_to_tie_[i].tie_definition_); - Moment end = heads_to_tie_[i].end_moment_; - - SCM cause = heads_to_tie_[i].tie_event_ - ? heads_to_tie_[i].tie_event_->self_scm () - : heads_to_tie_[i].tie_stream_event_->self_scm (); - - announce_grob (p, cause); - Tie::set_head (p, LEFT, th); - Tie::set_head (p, RIGHT, h); - - - if (is_direction (unsmob_stream_event (cause)->get_property ("direction"))) - { - Direction d = to_dir (unsmob_stream_event (cause)->get_property ("direction")); - p->set_property ("direction", scm_from_int (d)); - } - - ties_.push_back (p); - heads_to_tie_.erase (heads_to_tie_.begin () + i); - - /* - Prevent all other tied notes ending at the same moment (assume - implicitly the notes have also started at the same moment!) - from triggering an "unterminated tie" warning. Needed e.g. for - <c e g>~ g - */ - for (vsize j = heads_to_tie_.size (); j--;) - { - if (heads_to_tie_[j].end_moment_ == end) - heads_to_tie_[j].tie_from_chord_created = true; - } - } + && (!Tie_engraver::has_autosplit_end (left_ev))) + { + Grob *p = new Spanner (heads_to_tie_[i].tie_definition_); + Moment end = heads_to_tie_[i].end_moment_; + + SCM cause = heads_to_tie_[i].tie_event_ + ? heads_to_tie_[i].tie_event_->self_scm () + : heads_to_tie_[i].tie_stream_event_->self_scm (); + + announce_grob (p, cause); + Tie::set_head (p, LEFT, th); + Tie::set_head (p, RIGHT, h); + + if (is_direction (unsmob_stream_event (cause)->get_property ("direction"))) + { + Direction d = to_dir (unsmob_stream_event (cause)->get_property ("direction")); + p->set_property ("direction", scm_from_int (d)); + } + + ties_.push_back (p); + heads_to_tie_.erase (heads_to_tie_.begin () + i); + + /* + Prevent all other tied notes ending at the same moment (assume + implicitly the notes have also started at the same moment!) + from triggering an "unterminated tie" warning. Needed e.g. for + <c e g>~ g + */ + for (vsize j = heads_to_tie_.size (); j--;) + { + if (heads_to_tie_[j].end_moment_ == end) + heads_to_tie_[j].tie_from_chord_created = true; + } + } } if (ties_.size () && ! tie_column_) @@ -215,18 +214,18 @@ Tie_engraver::start_translation_timestep () if (heads_to_tie_.size () && !to_boolean (get_property ("tieWaitForNote"))) { Moment now = now_mom (); - for (vsize i = heads_to_tie_.size (); i--; ) - { - if (now > heads_to_tie_[i].end_moment_) - { - report_unterminated_tie (heads_to_tie_[i]); - heads_to_tie_.erase (heads_to_tie_.begin () + i); - } - } + for (vsize i = heads_to_tie_.size (); i--;) + { + if (now > heads_to_tie_[i].end_moment_) + { + report_unterminated_tie (heads_to_tie_[i]); + heads_to_tie_.erase (heads_to_tie_.begin () + i); + } + } } context ()->set_property ("tieMelismaBusy", - ly_bool2scm (heads_to_tie_.size ())); + ly_bool2scm (heads_to_tie_.size ())); } void @@ -237,14 +236,14 @@ Tie_engraver::stop_translation_timestep () { if (!wait) { - vector<Head_event_tuple>::iterator it = heads_to_tie_.begin (); - for (; it < heads_to_tie_.end (); it++) - report_unterminated_tie (*it); - heads_to_tie_.clear (); + vector<Head_event_tuple>::iterator it = heads_to_tie_.begin (); + for (; it < heads_to_tie_.end (); it++) + report_unterminated_tie (*it); + heads_to_tie_.clear (); } for (vsize i = 0; i < ties_.size (); i++) - typeset_tie (ties_[i]); + typeset_tie (ties_[i]); ties_.clear (); tie_column_ = 0; @@ -262,67 +261,67 @@ Tie_engraver::stop_translation_timestep () { Grob *head = now_heads_[i]; Stream_event *left_ev - = unsmob_stream_event (head->get_property ("cause")); + = unsmob_stream_event (head->get_property ("cause")); if (!left_ev) - { - // may happen for ambitus - continue; - } + { + // may happen for ambitus + continue; + } // We only want real notes to cause ties, not e.g. pitched trills if (!left_ev->in_event_class ("note-event")) - continue; + continue; SCM left_articulations = left_ev->get_property ("articulations"); Stream_event *tie_event = 0; Stream_event *tie_stream_event = event_; for (SCM s = left_articulations; - !tie_event && !tie_stream_event && scm_is_pair (s); - s = scm_cdr (s)) - { - Stream_event *ev = unsmob_stream_event (scm_car (s)); - if (!ev) - continue; + !tie_event && !tie_stream_event && scm_is_pair (s); + s = scm_cdr (s)) + { + Stream_event *ev = unsmob_stream_event (scm_car (s)); + if (!ev) + continue; - if (ev->in_event_class ("tie-event")) - tie_event = ev; - } + if (ev->in_event_class ("tie-event")) + tie_event = ev; + } if (left_ev && (tie_event || tie_stream_event) - && (!Tie_engraver::has_autosplit_end (left_ev))) - { - event_processed = true; - - Head_event_tuple event_tup; - - SCM start_definition - = updated_grob_properties (context (), ly_symbol2scm ("Tie")); - - event_tup.head_ = head; - event_tup.tie_definition_ = start_definition; - event_tup.tie_event_ = tie_event; - event_tup.tie_stream_event_ = tie_stream_event; - - Moment end = now_mom (); - if (end.grace_part_) - { - end.grace_part_ += get_event_length (left_ev).main_part_; - } - else - { - end += get_event_length (left_ev); - } - event_tup.end_moment_ = end; - - new_heads_to_tie.push_back (event_tup); - } + && (!Tie_engraver::has_autosplit_end (left_ev))) + { + event_processed = true; + + Head_event_tuple event_tup; + + SCM start_definition + = updated_grob_properties (context (), ly_symbol2scm ("Tie")); + + event_tup.head_ = head; + event_tup.tie_definition_ = start_definition; + event_tup.tie_event_ = tie_event; + event_tup.tie_stream_event_ = tie_stream_event; + + Moment end = now_mom (); + if (end.grace_part_) + { + end.grace_part_ += get_event_length (left_ev).main_part_; + } + else + { + end += get_event_length (left_ev); + } + event_tup.end_moment_ = end; + + new_heads_to_tie.push_back (event_tup); + } } if (!wait && new_heads_to_tie.size ()) { - vector<Head_event_tuple>::iterator it=heads_to_tie_.begin (); + vector<Head_event_tuple>::iterator it = heads_to_tie_.begin (); for (; it < heads_to_tie_.end (); it++) report_unterminated_tie (*it); heads_to_tie_.clear (); @@ -355,27 +354,27 @@ Tie_engraver::typeset_tie (Grob *her) do { if (!Tie::head (her, d)) - new_head_drul[d] = Tie::head (her, (Direction) - d); + new_head_drul[d] = Tie::head (her, (Direction) - d); } while (flip (&d) != LEFT); - Spanner *sp = dynamic_cast<Spanner*> (her); + Spanner *sp = dynamic_cast<Spanner *> (her); sp->set_bound (LEFT, new_head_drul[LEFT]); sp->set_bound (RIGHT, new_head_drul[RIGHT]); } ADD_ACKNOWLEDGER (Tie_engraver, note_head); ADD_TRANSLATOR (Tie_engraver, - /* doc */ - "Generate ties between note heads of equal pitch.", + /* doc */ + "Generate ties between note heads of equal pitch.", - /* create */ - "Tie " - "TieColumn ", + /* create */ + "Tie " + "TieColumn ", - /* read */ - "tieWaitForNote ", + /* read */ + "tieWaitForNote ", - /* write */ - "tieMelismaBusy " - ); + /* write */ + "tieMelismaBusy " + ); diff --git a/lily/tie-formatting-problem.cc b/lily/tie-formatting-problem.cc index 0c3279ce21..3e76c120b1 100644 --- a/lily/tie-formatting-problem.cc +++ b/lily/tie-formatting-problem.cc @@ -46,7 +46,7 @@ Tie_formatting_problem::print_ties_configuration (Ties_configuration const *ties char const *man_pos = (specifications_[i].has_manual_position_) ? "(M)" : ""; char const *man_dir = (specifications_[i].has_manual_dir_) ? "(M)" : ""; char const *dir = (ties->at (i).dir_ == UP) ? "up" : "dn"; - + printf ("(P%d%s, %s%s) ", ties->at (i).position_, man_pos, dir, man_dir); } printf ("\n"); @@ -55,19 +55,19 @@ Tie_formatting_problem::print_ties_configuration (Ties_configuration const *ties Interval Tie_formatting_problem::get_attachment (Real y, Drul_array<int> columns) const { - Interval attachments (0,0); + Interval attachments (0, 0); Direction d = LEFT; do { Tuple2<int> key (columns[d], int (d)); Chord_outline_map::const_iterator i (chord_outlines_.find (key)); if (i == chord_outlines_.end ()) - programming_error ("Cannot find chord outline"); + programming_error ("Cannot find chord outline"); else - attachments[d] = i->second.height (y); + attachments[d] = i->second.height (y); } while (flip (&d) != LEFT); - + return attachments; } @@ -86,9 +86,9 @@ Tie_formatting_problem::~Tie_formatting_problem () } void -Tie_formatting_problem::set_column_chord_outline (vector<Item*> bounds, - Direction dir, - int column_rank) +Tie_formatting_problem::set_column_chord_outline (vector<Item *> bounds, + Direction dir, + int column_rank) { Real staff_space = Staff_symbol_referencer::staff_space (bounds[0]); @@ -100,14 +100,14 @@ Tie_formatting_problem::set_column_chord_outline (vector<Item*> bounds, { Grob *head = bounds[i]; if (!Note_head::has_interface (head)) - continue; - + continue; + if (!stem) - stem = unsmob_grob (head->get_object ("stem")); - + stem = unsmob_grob (head->get_object ("stem")); + Real p = Staff_symbol_referencer::get_position (head); - Interval y ((p-1) * 0.5 * staff_space, - (p+1) * 0.5 * staff_space); + Interval y ((p - 1) * 0.5 * staff_space, + (p + 1) * 0.5 * staff_space); Interval x = head->extent (x_refpoint_, X_AXIS); head_boxes.push_back (Box (x, y)); @@ -115,21 +115,21 @@ Tie_formatting_problem::set_column_chord_outline (vector<Item*> bounds, Grob *dots = Rhythmic_head::get_dots (head); if (dir == LEFT && dots) - { - Interval x = dots->extent (x_refpoint_, X_AXIS); - int p = int (Staff_symbol_referencer::get_position (dots)); - - /* - TODO: shouldn't this use column-rank dependent key? - */ - dot_positions_.insert (p); - dot_x_.unite (x); - - Interval y (dots->extent (dots, Y_AXIS)); - y.translate (p * staff_space * 0.5); - - boxes.push_back (Box (x, y)); - } + { + Interval x = dots->extent (x_refpoint_, X_AXIS); + int p = int (Staff_symbol_referencer::get_position (dots)); + + /* + TODO: shouldn't this use column-rank dependent key? + */ + dot_positions_.insert (p); + dot_x_.unite (x); + + Interval y (dots->extent (dots, Y_AXIS)); + y.translate (p * staff_space * 0.5); + + boxes.push_back (Box (x, y)); + } } Tuple2<int> key (column_rank, int (dir)); @@ -137,107 +137,107 @@ Tie_formatting_problem::set_column_chord_outline (vector<Item*> bounds, if (stem) { if (Stem::is_normal_stem (stem)) - { - Interval x; - x.add_point (stem->relative_coordinate (x_refpoint_, X_AXIS)); - x.widen (staff_space / 20); // ugh. - Interval y; - - Real stem_end_position = 0.0; - if (Stem::is_cross_staff (stem)) - stem_end_position = get_grob_direction (stem) * infinity_f; - else - { - if (use_horizontal_spacing_ || !Stem::get_beam (stem)) - stem_end_position = Stem::stem_end_position (stem) * staff_space * .5; - else - stem_end_position = Stem::note_head_positions (stem)[get_grob_direction (stem)] - * staff_space * .5; - } - - y.add_point (stem_end_position); - - Direction stemdir = get_grob_direction (stem); - y.add_point (Stem::head_positions (stem)[-stemdir] - * staff_space * .5); - - /* - add extents of stem. - */ - boxes.push_back (Box (x, y)); - - stem_extents_[key].unite (Box (x, y)); - - if (dir == LEFT) - { - Box flag_box = Stem::get_translated_flag (stem).extent_box (); - flag_box.translate ( Offset (x[RIGHT], X_AXIS)); - boxes.push_back (flag_box); - } - } + { + Interval x; + x.add_point (stem->relative_coordinate (x_refpoint_, X_AXIS)); + x.widen (staff_space / 20); // ugh. + Interval y; + + Real stem_end_position = 0.0; + if (Stem::is_cross_staff (stem)) + stem_end_position = get_grob_direction (stem) * infinity_f; + else + { + if (use_horizontal_spacing_ || !Stem::get_beam (stem)) + stem_end_position = Stem::stem_end_position (stem) * staff_space * .5; + else + stem_end_position = Stem::note_head_positions (stem)[get_grob_direction (stem)] + * staff_space * .5; + } + + y.add_point (stem_end_position); + + Direction stemdir = get_grob_direction (stem); + y.add_point (Stem::head_positions (stem)[-stemdir] + * staff_space * .5); + + /* + add extents of stem. + */ + boxes.push_back (Box (x, y)); + + stem_extents_[key].unite (Box (x, y)); + + if (dir == LEFT) + { + Box flag_box = Stem::get_translated_flag (stem).extent_box (); + flag_box.translate ( Offset (x[RIGHT], X_AXIS)); + boxes.push_back (flag_box); + } + } else - { - Grob *head = Stem::support_head (stem); - - /* - In case of invisible stem, don't pass x-center of heads. - */ - Real x_center = head->extent (x_refpoint_, X_AXIS).center (); - Interval x_ext; - x_ext[-dir] = x_center; - x_ext[dir] = infinity_f * dir; - Interval y_ext; - for (vsize j = 0; j < head_boxes.size (); j++) - y_ext.unite (head_boxes[j][Y_AXIS]); - - boxes.push_back (Box (x_ext, y_ext)); - } + { + Grob *head = Stem::support_head (stem); + + /* + In case of invisible stem, don't pass x-center of heads. + */ + Real x_center = head->extent (x_refpoint_, X_AXIS).center (); + Interval x_ext; + x_ext[-dir] = x_center; + x_ext[dir] = infinity_f * dir; + Interval y_ext; + for (vsize j = 0; j < head_boxes.size (); j++) + y_ext.unite (head_boxes[j][Y_AXIS]); + + boxes.push_back (Box (x_ext, y_ext)); + } extract_grob_set (stem, "note-heads", heads); - for (vsize i = 0; i < heads.size (); i ++) - { - if (find (bounds.begin (), bounds.end (), dynamic_cast<Item*> (heads[i])) == bounds.end ()) - { - /* - other untied notes in the same chord. - */ - - Interval y = Staff_symbol_referencer::extent_in_staff (heads[i]); - Interval x = heads[i]->extent (x_refpoint_, X_AXIS); - boxes.push_back (Box (x, y)); - } - - Grob *acc = unsmob_grob (heads[i]->get_object ("accidental-grob")); - if (acc) - acc->get_property ("stencil"); /* trigger tie-related suicide */ - - if (acc && acc->is_live () && dir == RIGHT) - { - boxes.push_back (Box (acc->extent (x_refpoint_, X_AXIS), - Staff_symbol_referencer::extent_in_staff (acc))); - } - - head_positions_[column_rank].add_point (int (Staff_symbol_referencer::get_position (heads[i]))); - } - + for (vsize i = 0; i < heads.size (); i++) + { + if (find (bounds.begin (), bounds.end (), dynamic_cast<Item *> (heads[i])) == bounds.end ()) + { + /* + other untied notes in the same chord. + */ + + Interval y = Staff_symbol_referencer::extent_in_staff (heads[i]); + Interval x = heads[i]->extent (x_refpoint_, X_AXIS); + boxes.push_back (Box (x, y)); + } + + Grob *acc = unsmob_grob (heads[i]->get_object ("accidental-grob")); + if (acc) + acc->get_property ("stencil"); /* trigger tie-related suicide */ + + if (acc && acc->is_live () && dir == RIGHT) + { + boxes.push_back (Box (acc->extent (x_refpoint_, X_AXIS), + Staff_symbol_referencer::extent_in_staff (acc))); + } + + head_positions_[column_rank].add_point (int (Staff_symbol_referencer::get_position (heads[i]))); + } + } - + Direction updowndir = DOWN; do { Interval x; Interval y; if (head_boxes.size ()) - { - Box b = boundary (head_boxes, updowndir, 0); - x = b[X_AXIS]; - x[-dir] = b[X_AXIS].linear_combination (-dir / 2); - y[-updowndir] = b[Y_AXIS][updowndir]; - y[updowndir] = updowndir * infinity_f; - } + { + Box b = boundary (head_boxes, updowndir, 0); + x = b[X_AXIS]; + x[-dir] = b[X_AXIS].linear_combination (-dir / 2); + y[-updowndir] = b[Y_AXIS][updowndir]; + y[updowndir] = updowndir * infinity_f; + } if (!x.is_empty ()) - boxes.push_back (Box (x, y)); + boxes.push_back (Box (x, y)); } while (flip (&updowndir) != DOWN); @@ -247,7 +247,7 @@ Tie_formatting_problem::set_column_chord_outline (vector<Item*> bounds, { Interval iv (Axis_group_interface::staff_extent (bounds[0], x_refpoint_, X_AXIS, y_refpoint_, Y_AXIS)); if (iv.is_empty ()) - iv.add_point (bounds[0]->relative_coordinate (x_refpoint_, X_AXIS)); + iv.add_point (bounds[0]->relative_coordinate (x_refpoint_, X_AXIS)); chord_outlines_[key].set_minimum_height (iv[-dir]); } @@ -255,10 +255,10 @@ Tie_formatting_problem::set_column_chord_outline (vector<Item*> bounds, { Interval x; for (vsize j = 0; j < head_boxes.size (); j++) - { - x.unite (head_boxes[j][X_AXIS]); - } - + { + x.unite (head_boxes[j][X_AXIS]); + } + chord_outlines_[key].set_minimum_height (x[dir]); } @@ -270,8 +270,8 @@ Tie_formatting_problem::set_column_chord_outline (vector<Item*> bounds, } void -Tie_formatting_problem::set_chord_outline (vector<Item*> bounds, - Direction dir) +Tie_formatting_problem::set_chord_outline (vector<Item *> bounds, + Direction dir) { vector<int> ranks; @@ -283,23 +283,21 @@ Tie_formatting_problem::set_chord_outline (vector<Item*> bounds, for (vsize i = 0; i < ranks.size (); i++) { - vector<Item*> col_items; - for (vsize j = 0; j < bounds.size (); j ++) - { - if (bounds[j]->get_column ()->get_rank () == ranks[i]) - col_items.push_back (bounds[j]); - } + vector<Item *> col_items; + for (vsize j = 0; j < bounds.size (); j++) + { + if (bounds[j]->get_column ()->get_rank () == ranks[i]) + col_items.push_back (bounds[j]); + } set_column_chord_outline (col_items, dir, ranks[i]); } } - - void Tie_formatting_problem::from_tie (Grob *tie) { - vector<Grob*> ties; + vector<Grob *> ties; ties.push_back (tie); from_ties (ties); @@ -313,90 +311,89 @@ Tie_formatting_problem::common_x_refpoint () const } void -Tie_formatting_problem::from_ties (vector<Grob*> const &ties) +Tie_formatting_problem::from_ties (vector<Grob *> const &ties) { if (ties.empty ()) return; - + x_refpoint_ = ties[0]; y_refpoint_ = ties[0]; for (vsize i = 0; i < ties.size (); i++) { - Spanner *tie = dynamic_cast<Spanner*> (ties[i]); + Spanner *tie = dynamic_cast<Spanner *> (ties[i]); Item *l = tie->get_bound (LEFT); Item *r = tie->get_bound (RIGHT); - x_refpoint_ = l->common_refpoint (x_refpoint_, X_AXIS); + x_refpoint_ = l->common_refpoint (x_refpoint_, X_AXIS); x_refpoint_ = r->common_refpoint (x_refpoint_, X_AXIS); if (!l->break_status_dir ()) - y_refpoint_ = l->common_refpoint (y_refpoint_, Y_AXIS); + y_refpoint_ = l->common_refpoint (y_refpoint_, Y_AXIS); if (!r->break_status_dir ()) - y_refpoint_ = r->common_refpoint (y_refpoint_, Y_AXIS); + y_refpoint_ = r->common_refpoint (y_refpoint_, Y_AXIS); } details_.from_grob (ties[0]); - + Direction d = LEFT; do { - vector<Item*> bounds; - + vector<Item *> bounds; + for (vsize i = 0; i < ties.size (); i++) - { - Item *it = dynamic_cast<Spanner*> (ties[i])->get_bound (d); - if (it->break_status_dir ()) - it = it->get_column (); - - bounds.push_back (it); - } - + { + Item *it = dynamic_cast<Spanner *> (ties[i])->get_bound (d); + if (it->break_status_dir ()) + it = it->get_column (); + + bounds.push_back (it); + } + set_chord_outline (bounds, d); } while (flip (&d) != LEFT); - for (vsize i = 0; i < ties.size (); i++) { Tie_specification spec; spec.from_grob (ties[i]); - + do - { - spec.note_head_drul_[d] = Tie::head (ties[i], d); - spec.column_ranks_[d] = Tie::get_column_rank (ties[i], d); - } + { + spec.note_head_drul_[d] = Tie::head (ties[i], d); + spec.column_ranks_[d] = Tie::get_column_rank (ties[i], d); + } while (flip (&d) != LEFT); specifications_.push_back (spec); } } void -Tie_formatting_problem::from_semi_ties (vector<Grob*> const &semi_ties, Direction head_dir) +Tie_formatting_problem::from_semi_ties (vector<Grob *> const &semi_ties, Direction head_dir) { if (semi_ties.empty ()) return; - use_horizontal_spacing_ = false; + use_horizontal_spacing_ = false; details_.from_grob (semi_ties[0]); - vector<Item*> heads; + vector<Item *> heads; int column_rank = -1; for (vsize i = 0; i < semi_ties.size (); i++) { Tie_specification spec; Item *head = unsmob_item (semi_ties[i]->get_object ("note-head")); - + if (!head) - programming_error ("LV tie without head?!"); + programming_error ("LV tie without head?!"); if (head) - { - spec.position_ = int (Staff_symbol_referencer::get_position (head)); - } + { + spec.position_ = int (Staff_symbol_referencer::get_position (head)); + } spec.from_grob (semi_ties[i]); - + spec.note_head_drul_[head_dir] = head; column_rank = Tie::get_column_rank (semi_ties[i], head_dir); spec.column_ranks_ = Drul_array<int> (column_rank, column_rank); @@ -409,13 +406,13 @@ Tie_formatting_problem::from_semi_ties (vector<Grob*> const &semi_ties, Directio for (vsize i = 0; i < semi_ties.size (); i++) { - x_refpoint_ = semi_ties[i]->common_refpoint (x_refpoint_, X_AXIS); - y_refpoint_ = semi_ties[i]->common_refpoint (y_refpoint_, Y_AXIS); + x_refpoint_ = semi_ties[i]->common_refpoint (x_refpoint_, X_AXIS); + y_refpoint_ = semi_ties[i]->common_refpoint (y_refpoint_, Y_AXIS); } for (vsize i = 0; i < heads.size (); i++) { - x_refpoint_ = heads[i]->common_refpoint (x_refpoint_, X_AXIS); - y_refpoint_ = heads[i]->common_refpoint (y_refpoint_, Y_AXIS) ; + x_refpoint_ = heads[i]->common_refpoint (x_refpoint_, X_AXIS); + y_refpoint_ = heads[i]->common_refpoint (y_refpoint_, Y_AXIS); } set_chord_outline (heads, head_dir); @@ -428,48 +425,46 @@ Tie_formatting_problem::from_semi_ties (vector<Grob*> const &semi_ties, Directio chord_outlines_[open_key].set_minimum_height (extremal - head_dir * 1.5); } - Tie_specification Tie_formatting_problem::get_tie_specification (int i) const { return specifications_[i]; } - /* - Return configuration, create it if necessary. + Return configuration, create it if necessary. */ -Tie_configuration* +Tie_configuration * Tie_formatting_problem::get_configuration (int pos, Direction dir, Drul_array<int> columns, - bool tune_dy) const + bool tune_dy) const { - int key_components[] = { + int key_components[] = + { pos, dir, columns[LEFT], columns[RIGHT] }; - Tuple<int,4> key (key_components); - + Tuple<int, 4> key (key_components); + Tie_configuration_map::const_iterator f = possibilities_.find (key); if (f != possibilities_.end ()) { return (*f).second; } - Tie_configuration *conf = generate_configuration (pos, dir, columns, tune_dy); - ((Tie_formatting_problem*) this)->possibilities_[key] = conf; + ((Tie_formatting_problem *) this)->possibilities_[key] = conf; return conf; } -Tie_configuration* +Tie_configuration * Tie_formatting_problem::generate_configuration (int pos, Direction dir, - Drul_array<int> columns, bool y_tune) const + Drul_array<int> columns, bool y_tune) const { Tie_configuration *conf = new Tie_configuration; conf->position_ = pos; conf->dir_ = dir; - + conf->column_ranks_ = columns; - + Real y = conf->position_ * 0.5 * details_.staff_space_; if (dot_positions_.find (pos) != dot_positions_.end ()) @@ -477,79 +472,79 @@ Tie_formatting_problem::generate_configuration (int pos, Direction dir, conf->delta_y_ += dir * 0.25 * details_.staff_space_; y_tune = false; } - + if (y_tune && max (fabs (get_head_extent (columns[LEFT], LEFT, Y_AXIS)[dir] - y), - fabs (get_head_extent (columns[RIGHT], RIGHT, Y_AXIS)[dir] - y)) < 0.25 + fabs (get_head_extent (columns[RIGHT], RIGHT, Y_AXIS)[dir] - y)) < 0.25 && !Staff_symbol_referencer::on_line (details_.staff_symbol_referencer_, pos)) { - conf->delta_y_ = - (get_head_extent (columns[LEFT], LEFT, Y_AXIS)[dir] - y) - + dir * details_.outer_tie_vertical_gap_; + conf->delta_y_ + = (get_head_extent (columns[LEFT], LEFT, Y_AXIS)[dir] - y) + + dir * details_.outer_tie_vertical_gap_; } if (y_tune) { conf->attachment_x_ = get_attachment (y + conf->delta_y_, conf->column_ranks_); - Real h = conf->height (details_); - + Real h = conf->height (details_); + /* - TODO: + TODO: - - should make sliding criterion, should flatten ties if + - should make sliding criterion, should flatten ties if + + - they're just the wrong (ie. touching line at top & bottom) + size. - - they're just the wrong (ie. touching line at top & bottom) - size. - */ if (head_positions_slice (columns[LEFT]).contains (pos) - || head_positions_slice (columns[RIGHT]).contains (pos) - || abs (pos) < 2 * Staff_symbol_referencer::staff_radius (details_.staff_symbol_referencer_)) - { - if (h < details_.intra_space_threshold_ * 0.5 * details_.staff_space_) - { - if (!Staff_symbol_referencer::on_line (details_.staff_symbol_referencer_, pos) - && abs (pos) < 2 * Staff_symbol_referencer::staff_radius (details_.staff_symbol_referencer_)) - { - conf->center_tie_vertically (details_); - } - else if (Staff_symbol_referencer::on_line (details_.staff_symbol_referencer_, pos)) - { - conf->delta_y_ += dir * - details_.tip_staff_line_clearance_ * 0.5 * details_.staff_space_; - } - } - else - { - Real top_y = y + conf->delta_y_ + conf->dir_ * h; - Real top_pos = top_y / (0.5*details_.staff_space_); - int round_pos = int (my_round (top_pos)); - - /* TODO: should use other variable? */ - Real clearance = details_.center_staff_line_clearance_; - if (fabs (top_pos - round_pos) < clearance - && Staff_symbol_referencer::on_staff_line (details_.staff_symbol_referencer_, - round_pos)) - { - Real new_y = (round_pos + clearance * conf->dir_) * 0.5 * details_.staff_space_; - conf->delta_y_ = (new_y - top_y); - } - } - } - } + || head_positions_slice (columns[RIGHT]).contains (pos) + || abs (pos) < 2 * Staff_symbol_referencer::staff_radius (details_.staff_symbol_referencer_)) + { + if (h < details_.intra_space_threshold_ * 0.5 * details_.staff_space_) + { + if (!Staff_symbol_referencer::on_line (details_.staff_symbol_referencer_, pos) + && abs (pos) < 2 * Staff_symbol_referencer::staff_radius (details_.staff_symbol_referencer_)) + { + conf->center_tie_vertically (details_); + } + else if (Staff_symbol_referencer::on_line (details_.staff_symbol_referencer_, pos)) + { + conf->delta_y_ += dir * + details_.tip_staff_line_clearance_ * 0.5 * details_.staff_space_; + } + } + else + { + Real top_y = y + conf->delta_y_ + conf->dir_ * h; + Real top_pos = top_y / (0.5 * details_.staff_space_); + int round_pos = int (my_round (top_pos)); + + /* TODO: should use other variable? */ + Real clearance = details_.center_staff_line_clearance_; + if (fabs (top_pos - round_pos) < clearance + && Staff_symbol_referencer::on_staff_line (details_.staff_symbol_referencer_, + round_pos)) + { + Real new_y = (round_pos + clearance * conf->dir_) * 0.5 * details_.staff_space_; + conf->delta_y_ = (new_y - top_y); + } + } + } + } conf->attachment_x_ = get_attachment (y + conf->delta_y_, conf->column_ranks_); if (conf->height (details_) < details_.intra_space_threshold_ * 0.5 * details_.staff_space_) { /* - This is less sensible for long ties, since those are more - horizontal. + This is less sensible for long ties, since those are more + horizontal. */ Interval close_by = get_attachment (y - + conf->delta_y_ - + (dir * details_.intra_space_threshold_ * 0.25 - * details_.staff_space_), - conf->column_ranks_); - + + conf->delta_y_ + + (dir * details_.intra_space_threshold_ * 0.25 + * details_.staff_space_), + conf->column_ranks_); + conf->attachment_x_.intersect (close_by); } @@ -558,26 +553,26 @@ Tie_formatting_problem::generate_configuration (int pos, Direction dir, if (conf->column_span_length ()) { /* - avoid the stems that we attach to as well. We don't do this - for semities (span length = 0) + avoid the stems that we attach to as well. We don't do this + for semities (span length = 0) - It would be better to check D against HEAD-DIRECTION if - applicable. + It would be better to check D against HEAD-DIRECTION if + applicable. */ Direction d = LEFT; do - { - Real y = conf->position_ * details_.staff_space_ * 0.5 + conf->delta_y_; - if (get_stem_extent (conf->column_ranks_[d], d, X_AXIS).is_empty () - || !get_stem_extent (conf->column_ranks_[d], d, Y_AXIS).contains (y)) - continue; - - conf->attachment_x_[d] = - d * min (d * conf->attachment_x_[d], - d * (get_stem_extent (conf->column_ranks_[d], d, X_AXIS)[-d] - d * details_.stem_gap_)); - } + { + Real y = conf->position_ * details_.staff_space_ * 0.5 + conf->delta_y_; + if (get_stem_extent (conf->column_ranks_[d], d, X_AXIS).is_empty () + || !get_stem_extent (conf->column_ranks_[d], d, Y_AXIS).contains (y)) + continue; + + conf->attachment_x_[d] + = d * min (d * conf->attachment_x_[d], + d * (get_stem_extent (conf->column_ranks_[d], d, X_AXIS)[-d] - d * details_.stem_gap_)); + } while (flip (&d) != LEFT); - } + } return conf; } @@ -606,19 +601,19 @@ Tie_formatting_problem::get_stem_extent (int col, Direction d, Axis a) const */ Real Tie_formatting_problem::score_aptitude (Tie_configuration *conf, - Tie_specification const &spec, - Ties_configuration *ties_conf, int tie_idx) const + Tie_specification const &spec, + Ties_configuration *ties_conf, int tie_idx) const { Real penalty = 0.0; Real curve_y = conf->position_ * details_.staff_space_ * 0.5 + conf->delta_y_; Real tie_y = spec.position_ * details_.staff_space_ * 0.5; if (sign (curve_y - tie_y) != conf->dir_) { - Real p = details_.wrong_direction_offset_penalty_; + Real p = details_.wrong_direction_offset_penalty_; if (ties_conf) - ties_conf->add_tie_score (p, tie_idx, "wrong dir"); + ties_conf->add_tie_score (p, tie_idx, "wrong dir"); else - penalty += p; + penalty += p; } { @@ -627,29 +622,28 @@ Tie_formatting_problem::score_aptitude (Tie_configuration *conf, if (ties_conf) ties_conf->add_tie_score (p, tie_idx, "vdist"); else - penalty += p; + penalty += p; } - + Direction d = LEFT; do { if (!spec.note_head_drul_[d]) - continue; - + continue; + Interval head_x = spec.note_head_drul_[d]->extent (x_refpoint_, X_AXIS); Real dist = head_x.distance (conf->attachment_x_[d]); - /* - TODO: flatten with log or sqrt. + TODO: flatten with log or sqrt. */ Real p = details_.horizontal_distance_penalty_factor_ - * convex_amplifier (1.25, 1.0, dist); + * convex_amplifier (1.25, 1.0, dist); if (ties_conf) - ties_conf->add_tie_score (p, tie_idx, - (d == LEFT) ? "lhdist" : "rhdist"); + ties_conf->add_tie_score (p, tie_idx, + (d == LEFT) ? "lhdist" : "rhdist"); else - penalty += p; + penalty += p; } while (flip (&d) != LEFT); @@ -658,48 +652,47 @@ Tie_formatting_problem::score_aptitude (Tie_configuration *conf, && ties_conf->size () == 1) { Direction d = LEFT; - Drul_array<Grob*> stems (0, 0); + Drul_array<Grob *> stems (0, 0); do - { - if (!spec.note_head_drul_[d]) - continue; - - Grob *stem = unsmob_grob (spec.note_head_drul_[d]->get_object ("stem")); - if (stem - && Stem::is_normal_stem (stem)) - stems[d] = stem; - } + { + if (!spec.note_head_drul_[d]) + continue; + + Grob *stem = unsmob_grob (spec.note_head_drul_[d]->get_object ("stem")); + if (stem + && Stem::is_normal_stem (stem)) + stems[d] = stem; + } while (flip (&d) != LEFT); bool tie_stem_dir_ok = true; bool tie_position_dir_ok = true; if (stems[LEFT] && !stems[RIGHT]) - tie_stem_dir_ok = conf->dir_ != get_grob_direction (stems[LEFT]); + tie_stem_dir_ok = conf->dir_ != get_grob_direction (stems[LEFT]); else if (!stems[LEFT] && stems[RIGHT]) - tie_stem_dir_ok = conf->dir_ != get_grob_direction (stems[RIGHT]); + tie_stem_dir_ok = conf->dir_ != get_grob_direction (stems[RIGHT]); else if (stems[LEFT] && stems[RIGHT] - && get_grob_direction (stems[LEFT]) == get_grob_direction (stems[RIGHT])) - tie_stem_dir_ok = conf->dir_ != get_grob_direction (stems[LEFT]); + && get_grob_direction (stems[LEFT]) == get_grob_direction (stems[RIGHT])) + tie_stem_dir_ok = conf->dir_ != get_grob_direction (stems[LEFT]); else if (spec.position_) - tie_position_dir_ok = conf->dir_ == sign (spec.position_); + tie_position_dir_ok = conf->dir_ == sign (spec.position_); if (!tie_stem_dir_ok) - ties_conf->add_score (details_.same_dir_as_stem_penalty_, "tie/stem dir"); + ties_conf->add_score (details_.same_dir_as_stem_penalty_, "tie/stem dir"); if (!tie_position_dir_ok) - ties_conf->add_score (details_.same_dir_as_stem_penalty_, "tie/pos dir"); + ties_conf->add_score (details_.same_dir_as_stem_penalty_, "tie/pos dir"); } - + return penalty; } - Slice Tie_formatting_problem::head_positions_slice (int rank) const { Position_extent_map::const_iterator i (head_positions_.find (rank)); if (i != head_positions_.end ()) { - return (*i).second; + return (*i).second; } Slice empty; return empty; @@ -714,70 +707,69 @@ Tie_formatting_problem::score_configuration (Tie_configuration *conf) const { if (conf->scored_) { - return ; + return; } - + Real length = conf->attachment_x_.length (); Real length_penalty = peak_around (0.33 * details_.min_length_, details_.min_length_, length); conf->add_score (details_.min_length_penalty_factor_ - * length_penalty, "minlength"); - + * length_penalty, "minlength"); + Real tip_pos = conf->position_ + conf->delta_y_ / 0.5 * details_.staff_space_; Real tip_y = tip_pos * details_.staff_space_ * 0.5; - Real height = conf->height (details_); + Real height = conf->height (details_); Real top_y = tip_y + conf->dir_ * height; Real top_pos = 2 * top_y / details_.staff_space_; Real round_top_pos = rint (top_pos); if (Staff_symbol_referencer::on_line (details_.staff_symbol_referencer_, - int (round_top_pos)) + int (round_top_pos)) && Staff_symbol_referencer::staff_radius (details_.staff_symbol_referencer_) > top_y) { - conf->add_score ( - details_.staff_line_collision_penalty_ - * peak_around (0.1 * details_.center_staff_line_clearance_, - details_.center_staff_line_clearance_, - fabs (top_pos - round_top_pos)), - "line center"); + conf->add_score (details_.staff_line_collision_penalty_ + * peak_around (0.1 * details_.center_staff_line_clearance_, + details_.center_staff_line_clearance_, + fabs (top_pos - round_top_pos)), + "line center"); } int rounded_tip_pos = int (rint (tip_pos)); if (Staff_symbol_referencer::on_line (details_.staff_symbol_referencer_, rounded_tip_pos) && (head_positions_slice (conf->column_ranks_[LEFT]).contains (rounded_tip_pos) - || head_positions_slice (conf->column_ranks_[RIGHT]).contains (rounded_tip_pos) - || abs (rounded_tip_pos) < 2 * Staff_symbol_referencer::staff_radius (details_.staff_symbol_referencer_)) - ) + || head_positions_slice (conf->column_ranks_[RIGHT]).contains (rounded_tip_pos) + || abs (rounded_tip_pos) < 2 * Staff_symbol_referencer::staff_radius (details_.staff_symbol_referencer_)) + ) { conf->add_score (details_.staff_line_collision_penalty_ - * peak_around (0.1 * details_.tip_staff_line_clearance_, - details_.tip_staff_line_clearance_, - fabs (tip_pos - rint (tip_pos))), - "tipline"); + * peak_around (0.1 * details_.tip_staff_line_clearance_, + details_.tip_staff_line_clearance_, + fabs (tip_pos - rint (tip_pos))), + "tipline"); } if (!dot_x_.is_empty ()) { /* use left edge? */ Real x = dot_x_.center (); - + Bezier b = conf->get_transformed_bezier (details_); if (b.control_point_extent (X_AXIS).contains (x)) - { - Real y = b.get_other_coordinate (X_AXIS, x); - - for (set<int>::const_iterator i (dot_positions_.begin ()); - i != dot_positions_.end (); i ++) - { - int dot_pos = (*i); - conf->add_score (details_.dot_collision_penalty_ - * peak_around (.1 * details_.dot_collision_clearance_, - details_.dot_collision_clearance_, - fabs (dot_pos * details_.staff_space_ * 0.5 - y)), - "dot collision"); - } - } + { + Real y = b.get_other_coordinate (X_AXIS, x); + + for (set<int>::const_iterator i (dot_positions_.begin ()); + i != dot_positions_.end (); i++) + { + int dot_pos = (*i); + conf->add_score (details_.dot_collision_penalty_ + * peak_around (.1 * details_.dot_collision_clearance_, + details_.dot_collision_clearance_, + fabs (dot_pos * details_.staff_space_ * 0.5 - y)), + "dot collision"); + } + } } conf->scored_ = true; @@ -786,7 +778,7 @@ Tie_formatting_problem::score_configuration (Tie_configuration *conf) const void Tie_formatting_problem::score_ties_aptitude (Ties_configuration *ties) const { - if (ties->size () != specifications_.size ()) + if (ties->size () != specifications_.size ()) { programming_error ("Huh? Mismatch between sizes."); return; @@ -794,7 +786,7 @@ Tie_formatting_problem::score_ties_aptitude (Ties_configuration *ties) const for (vsize i = 0; i < ties->size (); i++) score_aptitude (&ties->at (i), specifications_[i], - ties, i); + ties, i); } void @@ -802,7 +794,7 @@ Tie_formatting_problem::score_ties (Ties_configuration *ties) const { if (ties->scored_) return; - + score_ties_configuration (ties); score_ties_aptitude (ties); ties->scored_ = true; @@ -816,33 +808,33 @@ Tie_formatting_problem::score_ties_configuration (Ties_configuration *ties) cons score_configuration (&ties->at (i)); ties->add_tie_score (ties->at (i).score (), i, "conf"); } - + Real last_edge = 0.0; Real last_center = 0.0; for (vsize i = 0; i < ties->size (); i++) { Bezier b (ties->at (i).get_transformed_bezier (details_)); - + Real center = b.curve_point (0.5)[Y_AXIS]; Real edge = b.curve_point (0.0)[Y_AXIS]; - + if (i) - { - if (edge <= last_edge) - ties->add_score (details_.tie_column_monotonicity_penalty_, "monoton edge"); - if (center <= last_center) - ties->add_score (details_.tie_column_monotonicity_penalty_, "monoton cent"); - - ties->add_score (details_.tie_tie_collision_penalty_ * - peak_around (0.1 * details_.tie_tie_collision_distance_, - details_.tie_tie_collision_distance_, - fabs (center - last_center)), - "tietie center"); - ties->add_score (details_.tie_tie_collision_penalty_ * - peak_around (0.1 * details_.tie_tie_collision_distance_, - details_.tie_tie_collision_distance_, - fabs (edge - last_edge)), "tietie edge"); - } + { + if (edge <= last_edge) + ties->add_score (details_.tie_column_monotonicity_penalty_, "monoton edge"); + if (center <= last_center) + ties->add_score (details_.tie_column_monotonicity_penalty_, "monoton cent"); + + ties->add_score (details_.tie_tie_collision_penalty_ * + peak_around (0.1 * details_.tie_tie_collision_distance_, + details_.tie_tie_collision_distance_, + fabs (center - last_center)), + "tietie center"); + ties->add_score (details_.tie_tie_collision_penalty_ * + peak_around (0.1 * details_.tie_tie_collision_distance_, + details_.tie_tie_collision_distance_, + fabs (edge - last_edge)), "tietie edge"); + } last_edge = edge; last_center = center; @@ -851,18 +843,18 @@ Tie_formatting_problem::score_ties_configuration (Ties_configuration *ties) cons if (ties->size () > 1) { ties->add_score (details_.outer_tie_length_symmetry_penalty_factor_ - * fabs (ties->at (0).attachment_x_.length () - ties->back ().attachment_x_.length ()), - "length symm"); - + * fabs (ties->at (0).attachment_x_.length () - ties->back ().attachment_x_.length ()), + "length symm"); + ties->add_score (details_.outer_tie_vertical_distance_symmetry_penalty_factor_ - * fabs (fabs (specifications_[0].position_ * 0.5 * details_.staff_space_ - - (ties->at (0).position_ * 0.5 * details_.staff_space_ - + ties->at (0).delta_y_)) - - - fabs (specifications_.back ().position_ * 0.5 * details_.staff_space_ - - (ties->back ().position_ * 0.5 * details_.staff_space_ - + ties->back ().delta_y_))), - "pos symmetry"); + * fabs (fabs (specifications_[0].position_ * 0.5 * details_.staff_space_ + - (ties->at (0).position_ * 0.5 * details_.staff_space_ + + ties->at (0).delta_y_)) + - + fabs (specifications_.back ().position_ * 0.5 * details_.staff_space_ + - (ties->back ().position_ * 0.5 * details_.staff_space_ + + ties->back ().delta_y_))), + "pos symmetry"); } } @@ -876,41 +868,41 @@ Tie_formatting_problem::generate_ties_configuration (Ties_configuration const &t Ties_configuration copy; for (vsize i = 0; i < ties_config.size (); i++) { - Tie_configuration * ptr = get_configuration (ties_config[i].position_, ties_config[i].dir_, - ties_config[i].column_ranks_, - !specifications_[i].has_manual_delta_y_); + Tie_configuration *ptr = get_configuration (ties_config[i].position_, ties_config[i].dir_, + ties_config[i].column_ranks_, + !specifications_[i].has_manual_delta_y_); if (specifications_[i].has_manual_delta_y_) - { - ptr->delta_y_ - = (specifications_[i].manual_position_ - ties_config[i].position_) - * 0.5 * details_.staff_space_; - } + { + ptr->delta_y_ + = (specifications_[i].manual_position_ - ties_config[i].position_) + * 0.5 * details_.staff_space_; + } copy.push_back (*ptr); } - + return copy; } Ties_configuration -Tie_formatting_problem::generate_base_chord_configuration () +Tie_formatting_problem::generate_base_chord_configuration () { Ties_configuration ties_config; - for (vsize i = 0; i < specifications_.size (); i ++) + for (vsize i = 0; i < specifications_.size (); i++) { Tie_configuration conf; if (specifications_[i].has_manual_dir_) - conf.dir_ = specifications_[i].manual_dir_; + conf.dir_ = specifications_[i].manual_dir_; if (specifications_[i].has_manual_position_) - { - conf.position_ = (int) my_round (specifications_[i].manual_position_); - if (specifications_[i].has_manual_delta_y_) - conf.delta_y_ = (specifications_[i].manual_position_ - conf.position_) - * 0.5 * details_.staff_space_; - } + { + conf.position_ = (int) my_round (specifications_[i].manual_position_); + if (specifications_[i].has_manual_delta_y_) + conf.delta_y_ = (specifications_[i].manual_position_ - conf.position_) + * 0.5 * details_.staff_space_; + } else - { - conf.position_ = specifications_[i].position_; - } + { + conf.position_ = specifications_[i].position_; + } conf.column_ranks_ = specifications_[i].column_ranks_; ties_config.push_back (conf); @@ -922,16 +914,16 @@ Tie_formatting_problem::generate_base_chord_configuration () ties_config[i].position_ += ties_config[i].dir_; ties_config = generate_ties_configuration (ties_config); - + return ties_config; } Ties_configuration Tie_formatting_problem::find_best_variation (Ties_configuration const &base, - vector<Tie_configuration_variation> const &vars) + vector<Tie_configuration_variation> const &vars) { Ties_configuration best = base; - + /* This simply is 1-opt: we have K substitions, and we try applying exactly every one for each. @@ -939,22 +931,20 @@ Tie_formatting_problem::find_best_variation (Ties_configuration const &base, for (vsize i = 0; i < vars.size (); i++) { Ties_configuration variant (base); - for (vsize j = 0; j < vars[i].index_suggestion_pairs_.size(); j++) - variant[vars[i].index_suggestion_pairs_[j].first] = *vars[i].index_suggestion_pairs_[j].second; + for (vsize j = 0; j < vars[i].index_suggestion_pairs_.size (); j++) + variant[vars[i].index_suggestion_pairs_[j].first] = *vars[i].index_suggestion_pairs_[j].second; variant.reset_score (); score_ties (&variant); - + if (variant.score () < best.score ()) - { - best = variant; - } + { + best = variant; + } } return best; } - - Ties_configuration Tie_formatting_problem::generate_optimal_configuration () @@ -962,7 +952,7 @@ Tie_formatting_problem::generate_optimal_configuration () Ties_configuration base = generate_base_chord_configuration (); score_ties (&base); - vector<Tie_configuration_variation> vars; + vector<Tie_configuration_variation> vars; if (specifications_.size () > 1) vars = generate_collision_variations (base); else @@ -982,18 +972,18 @@ void Tie_formatting_problem::set_ties_config_standard_directions (Ties_configuration *tie_configs) { if (tie_configs->empty ()) - return ; + return; if (!tie_configs->at (0).dir_) { if (tie_configs->size () == 1) - tie_configs->at (0).dir_ = Direction (sign (tie_configs->at (0).position_)); + tie_configs->at (0).dir_ = Direction (sign (tie_configs->at (0).position_)); if (!tie_configs->at (0).dir_) - tie_configs->at (0).dir_ - = (tie_configs->size() > 1) ? DOWN : details_.neutral_direction_; + tie_configs->at (0).dir_ + = (tie_configs->size () > 1) ? DOWN : details_.neutral_direction_; } - + if (!tie_configs->back ().dir_) tie_configs->back ().dir_ = UP; @@ -1003,36 +993,36 @@ Tie_formatting_problem::set_ties_config_standard_directions (Ties_configuration for (vsize i = 1; i < tie_configs->size (); i++) { Real diff = (tie_configs->at (i).position_ - -tie_configs->at (i-1).position_); - - Real span_diff - = specifications_[i].column_span () - specifications_[i-1].column_span (); + - tie_configs->at (i - 1).position_); + + Real span_diff + = specifications_[i].column_span () - specifications_[i - 1].column_span (); if (span_diff && fabs (diff) <= 2) - { - if (span_diff > 0) - tie_configs->at (i).dir_ = UP; - else if (span_diff < 0) - tie_configs->at (i-1).dir_ = DOWN; - } + { + if (span_diff > 0) + tie_configs->at (i).dir_ = UP; + else if (span_diff < 0) + tie_configs->at (i - 1).dir_ = DOWN; + } else if (fabs (diff) <= 1) - { - if (!tie_configs->at (i-1).dir_) - tie_configs->at (i-1).dir_ = DOWN; - if (!tie_configs->at (i).dir_) - tie_configs->at (i).dir_ = UP; - } + { + if (!tie_configs->at (i - 1).dir_) + tie_configs->at (i - 1).dir_ = DOWN; + if (!tie_configs->at (i).dir_) + tie_configs->at (i).dir_ = UP; + } } for (vsize i = 1; i + 1 < tie_configs->size (); i++) { Tie_configuration &conf = tie_configs->at (i); if (conf.dir_) - continue; + continue; - Direction position_dir = - Direction (sign (conf.position_)); + Direction position_dir + = Direction (sign (conf.position_)); if (!position_dir) - position_dir = DOWN; + position_dir = DOWN; conf.dir_ = position_dir; } @@ -1042,33 +1032,33 @@ vector<Tie_configuration_variation> Tie_formatting_problem::generate_extremal_tie_variations (Ties_configuration const &ties) const { vector<Tie_configuration_variation> vars; - Direction d = DOWN; + Direction d = DOWN; for (int i = 1; i <= details_.multi_tie_region_size_; i++) { - Drul_array<Tie_configuration*> configs (0, 0); + Drul_array<Tie_configuration *> configs (0, 0); do - { - const Tie_configuration &config = boundary (ties, d, 0); - if (config.dir_ == d - && !boundary (specifications_, d, 0).has_manual_position_) - { - Tie_configuration_variation var; - configs[d] = get_configuration (config.position_ + d * i, d, - config.column_ranks_, - true); - var.add_suggestion((d == DOWN) ? 0 : ties.size () - 1, - configs[d]); - vars.push_back (var); - } - } - while (flip (&d) != DOWN); + { + const Tie_configuration &config = boundary (ties, d, 0); + if (config.dir_ == d + && !boundary (specifications_, d, 0).has_manual_position_) + { + Tie_configuration_variation var; + configs[d] = get_configuration (config.position_ + d * i, d, + config.column_ranks_, + true); + var.add_suggestion ((d == DOWN) ? 0 : ties.size () - 1, + configs[d]); + vars.push_back (var); + } + } + while (flip (&d) != DOWN); if (configs[LEFT] && configs[RIGHT]) - { - Tie_configuration_variation var; - var.add_suggestion(0, configs[DOWN]); - var.add_suggestion(ties.size() - 1, configs[UP]); - vars.push_back (var); - } + { + Tie_configuration_variation var; + var.add_suggestion (0, configs[DOWN]); + var.add_suggestion (ties.size () - 1, configs[UP]); + vars.push_back (var); + } } return vars; @@ -1082,122 +1072,120 @@ Tie_formatting_problem::generate_single_tie_variations (Ties_configuration const int sz = details_.single_tie_region_size_; if (specifications_[0].has_manual_position_) sz = 1; - for (int i = 0; i < sz; i ++) + for (int i = 0; i < sz; i++) { Direction d = LEFT; do - { - if (i == 0 - && ties[0].dir_ == d) - continue; - - int p = ties[0].position_ + i * d; - - if (!specifications_[0].has_manual_dir_ - || d == specifications_[0].manual_dir_) - { - Tie_configuration_variation var; - var.add_suggestion(0, - get_configuration (p, - d, specifications_[0].column_ranks_, - !specifications_[0].has_manual_delta_y_)); - vars.push_back (var); - } - } + { + if (i == 0 + && ties[0].dir_ == d) + continue; + + int p = ties[0].position_ + i * d; + + if (!specifications_[0].has_manual_dir_ + || d == specifications_[0].manual_dir_) + { + Tie_configuration_variation var; + var.add_suggestion (0, + get_configuration (p, + d, specifications_[0].column_ranks_, + !specifications_[0].has_manual_delta_y_)); + vars.push_back (var); + } + } while (flip (&d) != LEFT); } return vars; } - vector<Tie_configuration_variation> Tie_formatting_problem::generate_collision_variations (Ties_configuration const &ties) const { Real center_distance_tolerance = 0.25; - + vector<Tie_configuration_variation> vars; Real last_center = 0.0; for (vsize i = 0; i < ties.size (); i++) { Bezier b (ties[i].get_transformed_bezier (details_)); - + Real center = b.curve_point (0.5)[Y_AXIS]; - + if (i) - { - if (center <= last_center + center_distance_tolerance) - { - if (!specifications_[i].has_manual_dir_) - { - Tie_configuration_variation var; - var.add_suggestion(i, - get_configuration (specifications_[i].position_ - - ties[i].dir_, - - ties[i].dir_, - - ties[i].column_ranks_, - !specifications_[i].has_manual_delta_y_ - )); - - vars.push_back (var); - } - - if (!specifications_[i-1].has_manual_dir_) - { - Tie_configuration_variation var; - var.add_suggestion(i-1, - get_configuration (specifications_[i-1].position_ - - ties[i-1].dir_, - - ties[i-1].dir_, - specifications_[i-1].column_ranks_, - !specifications_[i-1].has_manual_delta_y_)); - - vars.push_back (var); - } - - if (i == 1 && !specifications_[i-1].has_manual_position_ - && ties[i-1].dir_ == DOWN) - { - Tie_configuration_variation var; - var.add_suggestion(i-1, - get_configuration (specifications_[i-1].position_ - 1, DOWN, - specifications_[i-1].column_ranks_, - !specifications_[i-1].has_manual_delta_y_ - )); - vars.push_back (var); - } - if (i == ties.size () && !specifications_[i].has_manual_position_ - && ties[i].dir_ == UP) - { - Tie_configuration_variation var; - var.add_suggestion(i, - get_configuration (specifications_[i].position_ - + 1, UP, - specifications_[i].column_ranks_, - !specifications_[i].has_manual_delta_y_ - )); - vars.push_back (var); - } - } - else if (dot_positions_.find (ties[i].position_) != dot_positions_.end () - && !specifications_[i].has_manual_position_) - { - Tie_configuration_variation var; - var.add_suggestion(i, - get_configuration (ties[i].position_ + ties[i].dir_, - ties[i].dir_, - ties[i].column_ranks_, - !specifications_[i].has_manual_delta_y_ - )); - vars.push_back (var); - } - - } + { + if (center <= last_center + center_distance_tolerance) + { + if (!specifications_[i].has_manual_dir_) + { + Tie_configuration_variation var; + var.add_suggestion (i, + get_configuration (specifications_[i].position_ + - ties[i].dir_, + - ties[i].dir_, + + ties[i].column_ranks_, + !specifications_[i].has_manual_delta_y_ + )); + + vars.push_back (var); + } + + if (!specifications_[i - 1].has_manual_dir_) + { + Tie_configuration_variation var; + var.add_suggestion (i - 1, + get_configuration (specifications_[i - 1].position_ + - ties[i - 1].dir_, + - ties[i - 1].dir_, + specifications_[i - 1].column_ranks_, + !specifications_[i - 1].has_manual_delta_y_)); + + vars.push_back (var); + } + + if (i == 1 && !specifications_[i - 1].has_manual_position_ + && ties[i - 1].dir_ == DOWN) + { + Tie_configuration_variation var; + var.add_suggestion (i - 1, + get_configuration (specifications_[i - 1].position_ - 1, DOWN, + specifications_[i - 1].column_ranks_, + !specifications_[i - 1].has_manual_delta_y_ + )); + vars.push_back (var); + } + if (i == ties.size () && !specifications_[i].has_manual_position_ + && ties[i].dir_ == UP) + { + Tie_configuration_variation var; + var.add_suggestion (i, + get_configuration (specifications_[i].position_ + + 1, UP, + specifications_[i].column_ranks_, + !specifications_[i].has_manual_delta_y_ + )); + vars.push_back (var); + } + } + else if (dot_positions_.find (ties[i].position_) != dot_positions_.end () + && !specifications_[i].has_manual_position_) + { + Tie_configuration_variation var; + var.add_suggestion (i, + get_configuration (ties[i].position_ + ties[i].dir_, + ties[i].dir_, + ties[i].column_ranks_, + !specifications_[i].has_manual_delta_y_ + )); + vars.push_back (var); + } + + } last_center = center; } - return vars; } @@ -1210,40 +1198,39 @@ Tie_formatting_problem::set_manual_tie_configuration (SCM manual_configs) { SCM entry = scm_car (s); if (scm_is_pair (entry)) - { - Tie_specification &spec = specifications_[k]; - - if (scm_is_number (scm_car (entry))) - { - spec.has_manual_position_ = true; - spec.manual_position_ = scm_to_double (scm_car (entry)); - spec.has_manual_delta_y_ = (scm_inexact_p (scm_car (entry)) == SCM_BOOL_T); - } - - if (scm_is_number (scm_cdr (entry))) - { - spec.has_manual_dir_ = true; - spec.manual_dir_ = Direction (scm_to_int (scm_cdr (entry))); - } - } - k ++; + { + Tie_specification &spec = specifications_[k]; + + if (scm_is_number (scm_car (entry))) + { + spec.has_manual_position_ = true; + spec.manual_position_ = scm_to_double (scm_car (entry)); + spec.has_manual_delta_y_ = (scm_inexact_p (scm_car (entry)) == SCM_BOOL_T); + } + + if (scm_is_number (scm_cdr (entry))) + { + spec.has_manual_dir_ = true; + spec.manual_dir_ = Direction (scm_to_int (scm_cdr (entry))); + } + } + k++; } } - void Tie_formatting_problem::set_debug_scoring (Ties_configuration const &base) { #if DEBUG_TIE_SCORING if (to_boolean (x_refpoint_->layout () - ->lookup_variable (ly_symbol2scm ("debug-tie-scoring")))) + ->lookup_variable (ly_symbol2scm ("debug-tie-scoring")))) { for (vsize i = 0; i < base.size (); i++) - { - string card = base.complete_tie_card (i); - specifications_[i].tie_grob_->set_property ("annotation", - ly_string2scm (card)); - } + { + string card = base.complete_tie_card (i); + specifications_[i].tie_grob_->set_property ("annotation", + ly_string2scm (card)); + } } #endif -} +} diff --git a/lily/tie-performer.cc b/lily/tie-performer.cc index 5d237c1de3..c53ddeac7b 100644 --- a/lily/tie-performer.cc +++ b/lily/tie-performer.cc @@ -39,7 +39,6 @@ struct Head_audio_event_tuple } }; - class Tie_performer : public Performer { Stream_event *event_; @@ -90,31 +89,31 @@ Tie_performer::acknowledge_audio_element (Audio_element_info inf) else now_heads_.push_back (inf_mom); - // Find a previous note that ties to the current note. If it exists, + // Find a previous note that ties to the current note. If it exists, // remove it from the heads_to_tie vector and create the tie list<Head_audio_event_tuple>::iterator it; bool found = false; Stream_event *right_mus = inf.event_; - for (it = heads_to_tie_.begin (); - !found && (it != heads_to_tie_.end()); - it++) - { - Audio_element_info et = (*it).head_; - Audio_note *th = dynamic_cast<Audio_note *> (et.elem_); - Stream_event *left_mus = et.event_; - - if (th && right_mus && left_mus - && ly_is_equal (right_mus->get_property ("pitch"), - left_mus->get_property ("pitch"))) - { - found = true; - // (*it).moment_ already stores the end of the tied note! - Moment skip = now_mom() - (*it).end_moment_; - an->tie_to (th, skip); - // this invalidates the iterator, we are leaving the loop anyway - heads_to_tie_.erase (it); - } - } + for (it = heads_to_tie_.begin (); + !found && (it != heads_to_tie_.end ()); + it++) + { + Audio_element_info et = (*it).head_; + Audio_note *th = dynamic_cast<Audio_note *> (et.elem_); + Stream_event *left_mus = et.event_; + + if (th && right_mus && left_mus + && ly_is_equal (right_mus->get_property ("pitch"), + left_mus->get_property ("pitch"))) + { + found = true; + // (*it).moment_ already stores the end of the tied note! + Moment skip = now_mom () - (*it).end_moment_; + an->tie_to (th, skip); + // this invalidates the iterator, we are leaving the loop anyway + heads_to_tie_.erase (it); + } + } } } @@ -122,7 +121,7 @@ void Tie_performer::start_translation_timestep () { context ()->set_property ("tieMelismaBusy", - ly_bool2scm (heads_to_tie_.size ())); + ly_bool2scm (heads_to_tie_.size ())); } // a predicate implemented as a class, used to delete all tied notes with end @@ -133,7 +132,8 @@ protected: Moment now; public: end_moment_passed (Moment mom) : now (mom) {} - bool operator() (const Head_audio_event_tuple &value) { + bool operator () (const Head_audio_event_tuple &value) + { return (value.end_moment_ <= now); } }; @@ -161,15 +161,15 @@ Tie_performer::stop_translation_timestep () } ADD_TRANSLATOR (Tie_performer, - /* doc */ - "Generate ties between note heads of equal pitch.", + /* doc */ + "Generate ties between note heads of equal pitch.", - /* create */ - "", + /* create */ + "", - /* read */ - "tieWaitForNote", + /* read */ + "tieWaitForNote", - /* write */ - "tieMelismaBusy" - ); + /* write */ + "tieMelismaBusy" + ); diff --git a/lily/tie-specification.cc b/lily/tie-specification.cc index 3a7ce345cb..0413495713 100644 --- a/lily/tie-specification.cc +++ b/lily/tie-specification.cc @@ -13,13 +13,12 @@ Tie_specification::Tie_specification () position_ = 0; manual_position_ = 0; manual_dir_ = CENTER; - note_head_drul_[LEFT] = - note_head_drul_[RIGHT] = 0; - column_ranks_[RIGHT] = - column_ranks_[LEFT] = 0; + note_head_drul_[LEFT] + = note_head_drul_[RIGHT] = 0; + column_ranks_[RIGHT] + = column_ranks_[LEFT] = 0; } - void Tie_specification::from_grob (Grob *tie) { @@ -29,7 +28,7 @@ Tie_specification::from_grob (Grob *tie) manual_dir_ = to_dir (tie->get_property ("direction")); has_manual_dir_ = true; } - + position_ = Tie::get_position (tie); SCM pos_scm = tie->get_property ("staff-position"); if (scm_is_number (pos_scm)) diff --git a/lily/tie.cc b/lily/tie.cc index e8b21d8544..b52f84db0f 100644 --- a/lily/tie.cc +++ b/lily/tie.cc @@ -60,8 +60,8 @@ Tie::head (Grob *me, Direction d) Direction hd = to_dir (me->get_property ("head-direction")); return (hd == d) - ? unsmob_grob (me->get_object ("note-head")) - : 0; + ? unsmob_grob (me->get_object ("note-head")) + : 0; } Item *it = dynamic_cast<Spanner *> (me)->get_bound (d); @@ -97,7 +97,7 @@ Tie::get_position (Grob *me) { Grob *h = head (me, d); if (h) - return (int) rint (Staff_symbol_referencer::get_position (h)); + return (int) rint (Staff_symbol_referencer::get_position (h)); } while (flip (&d) != LEFT); @@ -130,11 +130,11 @@ Tie::get_default_dir (Grob *me) { Grob *one_head = head (me, d); if (!one_head && dynamic_cast<Spanner *> (me)) - one_head = Tie::head (dynamic_cast<Spanner *> (me)->broken_neighbor (d), d); + one_head = Tie::head (dynamic_cast<Spanner *> (me)->broken_neighbor (d), d); Grob *stem = one_head ? Rhythmic_head::get_stem (one_head) : 0; if (stem) - stem = Stem::is_invisible (stem) ? 0 : stem; + stem = Stem::is_invisible (stem) ? 0 : stem; stems[d] = stem; } @@ -143,8 +143,8 @@ Tie::get_default_dir (Grob *me) if (stems[LEFT] && stems[RIGHT]) { if (get_grob_direction (stems[LEFT]) == UP - && get_grob_direction (stems[RIGHT]) == UP) - return DOWN; + && get_grob_direction (stems[RIGHT]) == UP) + return DOWN; } else if (stems[LEFT] || stems[RIGHT]) { @@ -167,7 +167,7 @@ Tie::calc_direction (SCM smob) || Semi_tie_column::has_interface (yparent)) && unsmob_grob_array (yparent->get_object ("ties")) // && unsmob_grob_array (yparent->get_object ("ties"))->size () > 1 - ) + ) { /* trigger positioning. */ (void) yparent->get_property ("positioning-done"); @@ -197,14 +197,14 @@ Tie::get_default_control_points (Grob *me_grob) = problem.generate_optimal_configuration (); return get_control_points (me, problem.common_x_refpoint (), - conf[0], problem.details_); + conf[0], problem.details_); } SCM Tie::get_control_points (Grob *me, - Grob *common, - Tie_configuration const &conf, - Tie_details const &details) + Grob *common, + Tie_configuration const &conf, + Tie_details const &details) { Bezier b = conf.get_transformed_bezier (details); b.translate (Offset (- me->relative_coordinate (common, X_AXIS), 0)); @@ -213,7 +213,7 @@ Tie::get_control_points (Grob *me, for (int i = 4; i--;) { if (!b.control_[i].is_sane ()) - programming_error ("Insane offset"); + programming_error ("Insane offset"); controls = scm_cons (ly_offset2scm (b.control_[i]), controls); } return controls; @@ -232,11 +232,11 @@ Tie::calc_control_points (SCM smob) { extract_grob_set (yparent, "ties", ties); if (me->original () && ties.size () == 1 - && !to_dir (me->get_property_data ("direction"))) - { - assert (ties[0] == me); - set_grob_direction (me, Tie::get_default_dir (me)); - } + && !to_dir (me->get_property_data ("direction"))) + { + assert (ties[0] == me); + set_grob_direction (me, Tie::get_default_dir (me)); + } /* trigger positioning. */ (void) yparent->get_property ("positioning-done"); } @@ -275,9 +275,9 @@ Tie::print (SCM smob) SCM dash_definition = me->get_property ("dash-definition"); a = Lookup::slur (b, - get_grob_direction (me) * base_thick, - line_thick, - dash_definition); + get_grob_direction (me) * base_thick, + line_thick, + dash_definition); #if DEBUG_TIE_SCORING SCM annotation = me->get_property ("annotation"); @@ -287,15 +287,15 @@ Tie::print (SCM smob) SCM properties = Font_interface::text_font_alist_chain (me); Stencil tm = *unsmob_stencil (Text_interface::interpret_markup - (me->layout ()->self_scm (), properties, - annotation)); + (me->layout ()->self_scm (), properties, + annotation)); tm.translate (Offset (b.control_[3][X_AXIS] + 0.5, - b.control_[0][Y_AXIS] * 2)); + b.control_[0][Y_AXIS] * 2)); tm = tm.in_color (1, 0, 0); /* - It would be nice if we could put this in a different layer, - but alas, this must be done with a Tie override. + It would be nice if we could put this in a different layer, + but alas, this must be done with a Tie override. */ a.add_stencil (tm); } @@ -305,18 +305,18 @@ Tie::print (SCM smob) } ADD_INTERFACE (Tie, - "A horizontal curve connecting two noteheads.", - - /* properties */ - "annotation " - "avoid-slur " // UGH. - "control-points " - "dash-definition " - "details " - "direction " - "head-direction " - "line-thickness " - "neutral-direction " - "staff-position " - "thickness " - ); + "A horizontal curve connecting two noteheads.", + + /* properties */ + "annotation " + "avoid-slur " // UGH. + "control-points " + "dash-definition " + "details " + "direction " + "head-direction " + "line-thickness " + "neutral-direction " + "staff-position " + "thickness " + ); diff --git a/lily/time-signature-engraver.cc b/lily/time-signature-engraver.cc index d0621dd883..60724a66fd 100644 --- a/lily/time-signature-engraver.cc +++ b/lily/time-signature-engraver.cc @@ -66,24 +66,24 @@ Time_signature_engraver::process_music () { int den = scm_to_int (scm_cdr (fr)); if (den != (1 << intlog2 (den))) - { - /* - Todo: should make typecheck? + { + /* + Todo: should make typecheck? - OTOH, Tristan Keuris writes 8/20 in his Intermezzi. - */ - warning (_f ("strange time signature found: %d/%d", - int (scm_to_int (scm_car (fr))), - den)); - } + OTOH, Tristan Keuris writes 8/20 in his Intermezzi. + */ + warning (_f ("strange time signature found: %d/%d", + int (scm_to_int (scm_car (fr))), + den)); + } time_signature_ = make_item ("TimeSignature", SCM_EOL); time_signature_->set_property ("fraction", fr); if (last_time_fraction_ == SCM_BOOL_F) - time_signature_->set_property ("break-visibility", - get_property ("implicitTimeSignatureVisibility")); - + time_signature_->set_property ("break-visibility", + get_property ("implicitTimeSignatureVisibility")); + last_time_fraction_ = fr; } } @@ -97,17 +97,17 @@ Time_signature_engraver::stop_translation_timestep () #include "translator.icc" ADD_TRANSLATOR (Time_signature_engraver, - /* doc */ - "Create a @ref{TimeSignature} whenever" - " @code{timeSignatureFraction} changes.", - - /* create */ - "TimeSignature ", - - /* read */ - "implicitTimeSignatureVisibility " - "timeSignatureFraction ", - - /* write */ - "" - ); + /* doc */ + "Create a @ref{TimeSignature} whenever" + " @code{timeSignatureFraction} changes.", + + /* create */ + "TimeSignature ", + + /* read */ + "implicitTimeSignatureVisibility " + "timeSignatureFraction ", + + /* write */ + "" + ); diff --git a/lily/time-signature-performer.cc b/lily/time-signature-performer.cc index 54d4514231..3469737317 100644 --- a/lily/time-signature-performer.cc +++ b/lily/time-signature-performer.cc @@ -82,15 +82,15 @@ Time_signature_performer::stop_translation_timestep () #include "translator.icc" ADD_TRANSLATOR (Time_signature_performer, - /* doc */ - "", + /* doc */ + "", - /* create */ - "", + /* create */ + "", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/time-signature.cc b/lily/time-signature.cc index a1f8a38144..0b22eff640 100644 --- a/lily/time-signature.cc +++ b/lily/time-signature.cc @@ -77,22 +77,22 @@ Time_signature::special_time_signature (Grob *me, SCM scm_style, int n, int d) if (style == "C") { if /* neither C2/2 nor C4/4 */ - (((n != 2) || (d != 2)) - && ((n != 4) || (d != 4))) - return numbered_time_signature (me, n, d); + (((n != 2) || (d != 2)) + && ((n != 4) || (d != 4))) + return numbered_time_signature (me, n, d); } string char_name = style + to_string (n) + to_string (d); me->set_property ("font-encoding", ly_symbol2scm ("fetaMusic")); Stencil out = Font_interface::get_default_font (me) - ->find_by_name ("timesig." + char_name); + ->find_by_name ("timesig." + char_name); if (!out.is_empty ()) return out; /* If there is no such symbol, we default to the numbered style. (Here really with a warning!) */ me->warning (_f ("time signature symbol `%s' not found; " - "reverting to numbered style", char_name)); + "reverting to numbered style", char_name)); return numbered_time_signature (me, n, d); } @@ -101,13 +101,13 @@ Time_signature::numbered_time_signature (Grob *me, int num, int den) { SCM chain = me->get_property_alist_chain (Font_interface::text_font_alist_chain (me)); chain = scm_cons (scm_list_1 (scm_cons (ly_symbol2scm ("font-encoding"), - ly_symbol2scm ("fetaText"))), - chain); + ly_symbol2scm ("fetaText"))), + chain); SCM sn = Text_interface::interpret_markup (me->layout ()->self_scm (), chain, - ly_string2scm (to_string (num))); + ly_string2scm (to_string (num))); SCM sd = Text_interface::interpret_markup (me->layout ()->self_scm (), chain, - ly_string2scm (to_string (den))); + ly_string2scm (to_string (den))); Stencil n = *unsmob_stencil (sn); Stencil d = *unsmob_stencil (sd); @@ -132,30 +132,30 @@ Time_signature::numbered_time_signature (Grob *me, int num, int den) } ADD_INTERFACE (Time_signature, - "A time signature, in different styles. The following values" - " for @code{style} are are recognized:\n" - "\n" - "@table @code\n" - "@item C\n" - "4/4 and 2/2 are typeset as C and struck C, respectively." - " All other time signatures are written with two digits." - " The value @code{default} is equivalent to @code{C}.\n" - "@item neomensural\n" - "2/2, 3/2, 2/4, 3/4, 4/4, 6/4, 9/4, 4/8, 6/8, and 9/8 are" - " typeset with neo-mensural style mensuration marks. All" - " other time signatures are written with two digits.\n" - "@item mensural\n" - "2/2, 3/2, 2/4, 3/4, 4/4, 6/4, 9/4, 4/8, 6/8, and 9/8 are" - " typeset with mensural style mensuration marks. All other" - " time signatures are written with two digits.\n" - "@item single-digit\n" - "All time signatures are typeset with a single digit, e.g.," - " 3/2 is written as 3.\n" - "@item numbered\n" - "All time signatures are typeset with two digits.\n" - "@end table", - - /* properties */ - "fraction " - "style " - ); + "A time signature, in different styles. The following values" + " for @code{style} are are recognized:\n" + "\n" + "@table @code\n" + "@item C\n" + "4/4 and 2/2 are typeset as C and struck C, respectively." + " All other time signatures are written with two digits." + " The value @code{default} is equivalent to @code{C}.\n" + "@item neomensural\n" + "2/2, 3/2, 2/4, 3/4, 4/4, 6/4, 9/4, 4/8, 6/8, and 9/8 are" + " typeset with neo-mensural style mensuration marks. All" + " other time signatures are written with two digits.\n" + "@item mensural\n" + "2/2, 3/2, 2/4, 3/4, 4/4, 6/4, 9/4, 4/8, 6/8, and 9/8 are" + " typeset with mensural style mensuration marks. All other" + " time signatures are written with two digits.\n" + "@item single-digit\n" + "All time signatures are typeset with a single digit, e.g.," + " 3/2 is written as 3.\n" + "@item numbered\n" + "All time signatures are typeset with two digits.\n" + "@end table", + + /* properties */ + "fraction " + "style " + ); diff --git a/lily/timing-translator.cc b/lily/timing-translator.cc index d5d069270b..f4485f11a7 100644 --- a/lily/timing-translator.cc +++ b/lily/timing-translator.cc @@ -35,11 +35,11 @@ Timing_translator::stop_translation_timestep () Moment now = now_mom (); if (barleft > Moment (0)) - { - Moment nextmom = now + barleft; - nextmom.grace_part_ = Rational (0); - global->add_moment_to_process (nextmom); - } + { + Moment nextmom = now + barleft; + nextmom.grace_part_ = Rational (0); + global->add_moment_to_process (nextmom); + } } } @@ -51,15 +51,15 @@ Timing_translator::initialize () context ()->set_property ("internalBarNumber", scm_from_int (1)); context ()->set_property ("timeSignatureFraction", - scm_cons (scm_from_int (4), scm_from_int (4))); + scm_cons (scm_from_int (4), scm_from_int (4))); /* Do not init measurePosition; this should be done from global context. */ context ()->set_property ("measureLength", - Moment (Rational (1)).smobbed_copy ()); + Moment (Rational (1)).smobbed_copy ()); context ()->set_property ("baseMoment", - Moment (Rational (1, 4)).smobbed_copy ()); + Moment (Rational (1, 4)).smobbed_copy ()); } Rational @@ -106,7 +106,7 @@ Timing_translator::start_translation_timestep () { measposp = now; context ()->set_property ("measurePosition", - measposp.smobbed_copy ()); + measposp.smobbed_copy ()); } measposp += dt; @@ -121,8 +121,8 @@ Timing_translator::start_translation_timestep () while (c && measposp.main_part_ >= len) { measposp.main_part_ -= len; - current_barnumber ++; - internal_barnumber ++; + current_barnumber++; + internal_barnumber++; } context ()->set_property ("currentBarNumber", scm_from_int (current_barnumber)); @@ -133,27 +133,27 @@ Timing_translator::start_translation_timestep () #include "translator.icc" ADD_TRANSLATOR (Timing_translator, - /* doc */ - "This engraver adds the alias @code{Timing} to its containing" - " context. Responsible for synchronizing timing information" - " from staves. Normally in @code{Score}. In order to create" - " polyrhythmic music, this engraver should be removed from" - " @code{Score} and placed in @code{Staff}.", - - /* create */ - "", - - /* read */ - "internalBarNumber " - "currentBarNumber " - "measureLength " - "measurePosition ", - - /* write */ - "baseMoment " - "currentBarNumber " - "internalBarNumber " - "measureLength " - "measurePosition " - "timeSignatureFraction " - ); + /* doc */ + "This engraver adds the alias @code{Timing} to its containing" + " context. Responsible for synchronizing timing information" + " from staves. Normally in @code{Score}. In order to create" + " polyrhythmic music, this engraver should be removed from" + " @code{Score} and placed in @code{Staff}.", + + /* create */ + "", + + /* read */ + "internalBarNumber " + "currentBarNumber " + "measureLength " + "measurePosition ", + + /* write */ + "baseMoment " + "currentBarNumber " + "internalBarNumber " + "measureLength " + "measurePosition " + "timeSignatureFraction " + ); diff --git a/lily/translator-ctors.cc b/lily/translator-ctors.cc index b190a927c7..8004166e51 100644 --- a/lily/translator-ctors.cc +++ b/lily/translator-ctors.cc @@ -30,8 +30,8 @@ Scheme_hash_table *global_translator_dict = 0; LY_DEFINE (get_all_translators, "ly:get-all-translators", 0, 0, 0, (), - "Return a list of all translator objects that may be" - " instantiated.") + "Return a list of all translator objects that may be" + " instantiated.") { SCM l = global_translator_dict ? global_translator_dict->to_alist () : SCM_EOL; diff --git a/lily/translator-dispatch-list.cc b/lily/translator-dispatch-list.cc index aae00e4e1c..1c5c94d667 100644 --- a/lily/translator-dispatch-list.cc +++ b/lily/translator-dispatch-list.cc @@ -30,7 +30,7 @@ Engraver_dispatch_list::apply (Grob_info gi) { Engraver_dispatch_entry const &e (dispatch_entries_[i]); if (e.engraver_ == origin) - continue; + continue; (*e.function_) (e.engraver_, gi); } @@ -38,7 +38,7 @@ Engraver_dispatch_list::apply (Grob_info gi) SCM Engraver_dispatch_list::create (SCM trans_list, - SCM iface_list, Direction start_end) + SCM iface_list, Direction start_end) { SCM retval = Engraver_dispatch_list ().smobbed_copy (); Engraver_dispatch_list *list = Engraver_dispatch_list::unsmob (retval); @@ -48,26 +48,26 @@ Engraver_dispatch_list::create (SCM trans_list, for (SCM s = trans_list; scm_is_pair (s); s = scm_cdr (s)) { Engraver *eng - = dynamic_cast<Engraver *> (unsmob_translator (scm_car (s))); + = dynamic_cast<Engraver *> (unsmob_translator (scm_car (s))); if (!eng) - continue; + continue; entry.engraver_ = eng; for (SCM i = iface_list; scm_is_pair (i); i = scm_cdr (i)) - { - Engraver_void_function_engraver_grob_info ptr - = (start_end == START) - ? eng->get_acknowledger (scm_car (i)) - : eng->get_end_acknowledger (scm_car (i)); - - if (ptr) - { - entry.function_ = ptr; - list->dispatch_entries_.push_back (entry); - found = true; - } - } + { + Engraver_void_function_engraver_grob_info ptr + = (start_end == START) + ? eng->get_acknowledger (scm_car (i)) + : eng->get_end_acknowledger (scm_car (i)); + + if (ptr) + { + entry.function_ = ptr; + list->dispatch_entries_.push_back (entry); + found = true; + } + } } return found ? retval : SCM_EOL; @@ -81,8 +81,8 @@ Engraver_dispatch_list::mark_smob (SCM) int Engraver_dispatch_list::print_smob (SCM /* x */, - SCM p, - scm_print_state *) + SCM p, + scm_print_state *) { scm_puts ("#<Engraver_dispatch_list>", p); return 1; diff --git a/lily/translator-group-ctors.cc b/lily/translator-group-ctors.cc index 5bde18c6b9..42d587dae1 100644 --- a/lily/translator-group-ctors.cc +++ b/lily/translator-group-ctors.cc @@ -38,12 +38,12 @@ get_translator_group (SCM sym) return new Score_performer (); error (_f ("fatal error. Couldn't find type: %s", - ly_symbol2string (sym).c_str ())); + ly_symbol2string (sym).c_str ())); scm_flush (scm_current_error_port ()); scm_display (sym, scm_current_error_port ()); scm_flush (scm_current_error_port ()); - + exit (2); - + return 0; } diff --git a/lily/translator-group.cc b/lily/translator-group.cc index 487037a2dc..b91faa5e3e 100644 --- a/lily/translator-group.cc +++ b/lily/translator-group.cc @@ -54,12 +54,12 @@ Translator_group::connect_to_context (Context *c) if (context_) { programming_error ("translator group is already connected to context " - + context_->context_name ()); + + context_->context_name ()); } - + context_ = c; c->event_source ()->add_listener (GET_LISTENER (create_child_translator), - ly_symbol2scm ("AnnounceNewContext")); + ly_symbol2scm ("AnnounceNewContext")); for (SCM tr_list = simple_trans_list_; scm_is_pair (tr_list); tr_list = scm_cdr (tr_list)) { Translator *tr = unsmob_translator (scm_car (tr_list)); @@ -76,7 +76,7 @@ Translator_group::disconnect_from_context () tr->disconnect_from_context (context_); } context_->event_source ()->remove_listener (GET_LISTENER (create_child_translator), - ly_symbol2scm ("AnnounceNewContext")); + ly_symbol2scm ("AnnounceNewContext")); context_ = 0; protected_events_ = SCM_EOL; } @@ -102,9 +102,9 @@ filter_performers (SCM ell) for (SCM p = ell; scm_is_pair (p); p = scm_cdr (p)) { if (unsmob_performer (scm_car (*tail))) - *tail = scm_cdr (*tail); + *tail = scm_cdr (*tail); else - tail = SCM_CDRLOC (*tail); + tail = SCM_CDRLOC (*tail); } return ell; } @@ -116,14 +116,14 @@ filter_engravers (SCM ell) for (SCM p = ell; scm_is_pair (p); p = scm_cdr (p)) { if (unsmob_engraver (scm_car (*tail))) - *tail = scm_cdr (*tail); + *tail = scm_cdr (*tail); else - tail = SCM_CDRLOC (*tail); + tail = SCM_CDRLOC (*tail); } return ell; } -/* +/* Protects the parameter from being garbage collected. The object is protected until the next disconnect_from_context call. @@ -131,7 +131,7 @@ filter_engravers (SCM ell) this list. This eliminates the need for derived_mark methods in most translators; all incoming events are instead protected by the translator group. - + TODO: Should the list also be flushed at the beginning of each new moment? */ @@ -155,7 +155,7 @@ Translator_group::create_child_translator (SCM sev) Context *new_context = unsmob_context (cs); Context_def *def = unsmob_context_def (new_context->get_definition ()); SCM ops = new_context->get_definition_mods (); - + SCM trans_names = def->get_translator_names (ops); Translator_group *g = get_translator_group (def->get_translator_group_type ()); @@ -168,46 +168,46 @@ Translator_group::create_child_translator (SCM sev) Translator *type = 0; if (ly_is_symbol (definition)) - type = get_translator (definition); + type = get_translator (definition); else if (ly_is_pair (definition)) - { - type = get_translator (ly_symbol2scm ("Scheme_engraver")); - is_scheme = true; - } + { + type = get_translator (ly_symbol2scm ("Scheme_engraver")); + is_scheme = true; + } else if (ly_is_procedure (definition)) - { - // `definition' is a procedure, which takes the context as - // an argument and evaluates to an a-list scheme engraver - // definition. - definition = scm_call_1 (definition, cs); - type = get_translator (ly_symbol2scm ("Scheme_engraver")); - is_scheme = true; - } - + { + // `definition' is a procedure, which takes the context as + // an argument and evaluates to an a-list scheme engraver + // definition. + definition = scm_call_1 (definition, cs); + type = get_translator (ly_symbol2scm ("Scheme_engraver")); + is_scheme = true; + } + if (!type) - warning (_f ("cannot find: `%s'", ly_symbol2string (scm_car (s)).c_str ())); + warning (_f ("cannot find: `%s'", ly_symbol2string (scm_car (s)).c_str ())); else - { - Translator *instance = type->clone (); - if (is_scheme) - dynamic_cast<Scheme_engraver *> (instance)->init_from_scheme (definition); - - SCM str = instance->self_scm (); - - if (instance->must_be_last ()) - { - SCM cons = scm_cons (str, SCM_EOL); - if (scm_is_pair (trans_list)) - scm_set_cdr_x (scm_last_pair (trans_list), cons); - else - trans_list = cons; - } - else - trans_list = scm_cons (str, trans_list); - - instance->daddy_context_ = new_context; - instance->unprotect (); - } + { + Translator *instance = type->clone (); + if (is_scheme) + dynamic_cast<Scheme_engraver *> (instance)->init_from_scheme (definition); + + SCM str = instance->self_scm (); + + if (instance->must_be_last ()) + { + SCM cons = scm_cons (str, SCM_EOL); + if (scm_is_pair (trans_list)) + scm_set_cdr_x (scm_last_pair (trans_list), cons); + else + trans_list = cons; + } + else + trans_list = scm_cons (str, trans_list); + + instance->daddy_context_ = new_context; + instance->unprotect (); + } } /* Filter unwanted translator types. Required to make @@ -224,9 +224,9 @@ Translator_group::create_child_translator (SCM sev) g->unprotect (); recurse_over_translators (new_context, - &Translator::initialize, - &Translator_group::initialize, - DOWN); + &Translator::initialize, + &Translator_group::initialize, + DOWN); } SCM @@ -260,7 +260,7 @@ precomputed_recurse_over_translators (Context *c, Translator_precompute_index id void recurse_over_translators (Context *c, Translator_method ptr, - Translator_group_method tg_ptr, Direction dir) + Translator_group_method tg_ptr, Direction dir) { Translator_group *tg = dynamic_cast<Translator_group *> (c->implementation ()); @@ -278,7 +278,7 @@ recurse_over_translators (Context *c, Translator_method ptr, if (tg && dir == UP) { translator_each (tg->get_simple_trans_list (), - ptr); + ptr); (tg->*tg_ptr) (); } @@ -308,10 +308,10 @@ Translator_group::precompute_method_bindings () assert (tr); for (int i = 0; i < TRANSLATOR_METHOD_PRECOMPUTE_COUNT; i++) - { - if (ptrs[i]) - precomputed_method_bindings_[i].push_back (Translator_method_binding (tr, ptrs[i])); - } + { + if (ptrs[i]) + precomputed_method_bindings_[i].push_back (Translator_method_binding (tr, ptrs[i])); + } } fetch_precomputable_methods (precomputed_self_method_bindings_); diff --git a/lily/translator-scheme.cc b/lily/translator-scheme.cc index 7ede1b0eb4..cc6f13f8ca 100644 --- a/lily/translator-scheme.cc +++ b/lily/translator-scheme.cc @@ -23,9 +23,9 @@ #include "moment.hh" LY_DEFINE (ly_translator_name, "ly:translator-name", - 1, 0, 0, (SCM trans), - "Return the type name of the translator object @var{trans}." - " The name is a symbol.") + 1, 0, 0, (SCM trans), + "Return the type name of the translator object @var{trans}." + " The name is a symbol.") { LY_ASSERT_SMOB (Translator, trans, 1); Translator *tr = unsmob_translator (trans); @@ -34,18 +34,17 @@ LY_DEFINE (ly_translator_name, "ly:translator-name", } LY_DEFINE (ly_translator_description, "ly:translator-description", - 1, 0, 0, (SCM me), - "Return an alist of properties of translator @var{me}.") + 1, 0, 0, (SCM me), + "Return an alist of properties of translator @var{me}.") { LY_ASSERT_SMOB (Translator, me, 1); Translator *tr = unsmob_translator (me); return tr->translator_description (); } - LY_DEFINE (ly_translator_context, "ly:translator-context", - 1, 0, 0, (SCM trans), - "Return the context of the translator object @var{trans}.") + 1, 0, 0, (SCM trans), + "Return the context of the translator object @var{trans}.") { LY_ASSERT_SMOB (Translator, trans, 1); Translator *tr = unsmob_translator (trans); diff --git a/lily/translator.cc b/lily/translator.cc index 3020006f83..f101fb90e1 100644 --- a/lily/translator.cc +++ b/lily/translator.cc @@ -122,7 +122,7 @@ Translator::connect_to_context (Context *c) { for (translator_listener_record *r = get_listener_list (); r; r = r->next_) c->events_below ()->add_listener (r->get_listener_ (this, r->event_class_), - r->event_class_); + r->event_class_); } void @@ -130,7 +130,7 @@ Translator::disconnect_from_context (Context *c) { for (translator_listener_record *r = get_listener_list (); r; r = r->next_) c->events_below ()->remove_listener (r->get_listener_ (this, r->event_class_), - r->event_class_); + r->event_class_); } static SCM listened_event_class_table; @@ -141,19 +141,18 @@ ensure_listened_hash () listened_event_class_table = scm_permanent_object (scm_c_make_hash_table (61)); } - LY_DEFINE (ly_get_listened_event_classes, "ly:get-listened-event-classes", - 0, 0, 0, (), - "Return a list of all event classes that some translator listens" - " to.") + 0, 0, 0, (), + "Return a list of all event classes that some translator listens" + " to.") { ensure_listened_hash (); return ly_hash_table_keys (listened_event_class_table); } LY_DEFINE (ly_is_listened_event_class, "ly:is-listened-event-class", - 1, 0, 0, (SCM sym), - "Is @var{sym} a listened event class?") + 1, 0, 0, (SCM sym), + "Is @var{sym} a listened event class?") { ensure_listened_hash (); return scm_hashq_ref (listened_event_class_table, sym, SCM_BOOL_F); @@ -166,7 +165,6 @@ add_listened_event_class (SCM sym) scm_hashq_set_x (listened_event_class_table, sym, SCM_BOOL_T); } - /* internally called once, statically, for each translator listener. Connects the name of an event class with a procedure that @@ -177,17 +175,17 @@ add_listened_event_class (SCM sym) */ void Translator::add_translator_listener (translator_listener_record **listener_list, - translator_listener_record *r, - Listener (*get_listener) (void *, SCM), - const char *ev_class) + translator_listener_record *r, + Listener (*get_listener) (void *, SCM), + const char *ev_class) { /* ev_class is the C++ identifier name. Convert to scm symbol */ string name = string (ev_class); name = replace_all (&name, '_', '-'); name += "-event"; - + SCM class_sym = scm_from_locale_symbol (name.c_str ()); - + add_listened_event_class (class_sym); r->event_class_ = class_sym; @@ -201,34 +199,34 @@ Translator::add_translator_listener (translator_listener_record **listener_list, */ SCM Translator::static_translator_description (const char *grobs, - const char *desc, - translator_listener_record *listener_list, - const char *read, - const char *write) const -{ - SCM static_properties = SCM_EOL; - - static_properties = scm_acons (ly_symbol2scm ("grobs-created"), - parse_symbol_list (grobs), static_properties); - - static_properties = scm_acons (ly_symbol2scm ("description"), - scm_from_locale_string (desc), static_properties); - + const char *desc, + translator_listener_record *listener_list, + const char *read, + const char *write) const +{ + SCM static_properties = SCM_EOL; + + static_properties = scm_acons (ly_symbol2scm ("grobs-created"), + parse_symbol_list (grobs), static_properties); + + static_properties = scm_acons (ly_symbol2scm ("description"), + scm_from_locale_string (desc), static_properties); + SCM list = SCM_EOL; for (; listener_list; listener_list = listener_list->next_) list = scm_cons (listener_list->event_class_, list); static_properties = scm_acons (ly_symbol2scm ("events-accepted"), - list, static_properties); - - static_properties = scm_acons (ly_symbol2scm ("properties-read"), - parse_symbol_list (read), static_properties); - - static_properties = scm_acons (ly_symbol2scm ("properties-written"), - parse_symbol_list (write), static_properties); - - return static_properties; -} - + list, static_properties); + + static_properties = scm_acons (ly_symbol2scm ("properties-read"), + parse_symbol_list (read), static_properties); + + static_properties = scm_acons (ly_symbol2scm ("properties-written"), + parse_symbol_list (write), static_properties); + + return static_properties; +} + /* SMOBS */ @@ -279,8 +277,8 @@ Translator::print_smob (SCM s, SCM port, scm_print_state *) void add_acknowledger (Engraver_void_function_engraver_grob_info ptr, - char const *func_name, - vector<Acknowledge_information> *ack_array) + char const *func_name, + vector<Acknowledge_information> *ack_array) { Acknowledge_information inf; inf.function_ = ptr; @@ -303,12 +301,11 @@ generic_get_acknowledger (SCM sym, vector<Acknowledge_information> const *ack_ar for (vsize i = 0; i < ack_array->size (); i++) { if (ack_array->at (i).symbol_ == sym) - return ack_array->at (i).function_; + return ack_array->at (i).function_; } return 0; } - Moment get_event_length (Stream_event *e) { @@ -323,7 +320,7 @@ Moment get_event_length (Stream_event *e, Moment now) { Moment len = get_event_length (e); - + if (now.grace_part_) { len.grace_part_ = len.main_part_; @@ -340,15 +337,15 @@ get_event_length (Stream_event *e, Moment now) bool internal_event_assignment (Stream_event **old_ev, Stream_event *new_ev, const char *function) { - if (*old_ev && - !to_boolean (scm_equal_p ((*old_ev)->self_scm (), - new_ev->self_scm ()))) + if (*old_ev + && !to_boolean (scm_equal_p ((*old_ev)->self_scm (), + new_ev->self_scm ()))) { /* extract event class from function name */ string ev_class = function; /* This assertion fails if EVENT_ASSIGNMENT was called outside a - translator listener. Don't do that. */ + translator listener. Don't do that. */ const char *prefix = "listen_"; assert (0 == ev_class.find (prefix)); @@ -368,15 +365,15 @@ internal_event_assignment (Stream_event **old_ev, Stream_event *new_ev, const ch } ADD_TRANSLATOR (Translator, - /* doc */ - "Base class. Not instantiated.", + /* doc */ + "Base class. Not instantiated.", - /* create */ - "", + /* create */ + "", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/trill-spanner-engraver.cc b/lily/trill-spanner-engraver.cc index 5f4b38d265..21321d8e97 100644 --- a/lily/trill-spanner-engraver.cc +++ b/lily/trill-spanner-engraver.cc @@ -77,17 +77,17 @@ Trill_spanner_engraver::acknowledge_note_column (Grob_info info) if (span_) { Pointer_group_interface::add_grob (span_, - ly_symbol2scm ("note-columns"), - info.grob()); + ly_symbol2scm ("note-columns"), + info.grob ()); if (!span_->get_bound (LEFT)) - add_bound_item (span_, info.grob ()); + add_bound_item (span_, info.grob ()); } else if (finished_) { Pointer_group_interface::add_grob (finished_, ly_symbol2scm ("note-columns"), - info.grob()); + info.grob ()); if (!finished_->get_bound (RIGHT)) - add_bound_item (finished_, info.grob ()); + add_bound_item (finished_, info.grob ()); } } @@ -99,7 +99,7 @@ Trill_spanner_engraver::process_music () { Stream_event *ender = event_drul_[STOP]; if (!ender) - ender = event_drul_[START]; + ender = event_drul_[START]; finished_ = span_; announce_end_grob (finished_, ender->self_scm ()); span_ = 0; @@ -120,10 +120,10 @@ Trill_spanner_engraver::typeset_all () if (finished_) { if (!finished_->get_bound (RIGHT)) - { - Grob *e = unsmob_grob (get_property ("currentMusicalColumn")); - finished_->set_bound (RIGHT, e); - } + { + Grob *e = unsmob_grob (get_property ("currentMusicalColumn")); + finished_->set_bound (RIGHT, e); + } finished_ = 0; } } @@ -155,16 +155,16 @@ Trill_spanner_engraver::finalize () ADD_ACKNOWLEDGER (Trill_spanner_engraver, note_column); ADD_TRANSLATOR (Trill_spanner_engraver, - /* doc */ - "Create trill spanner from an event.", + /* doc */ + "Create trill spanner from an event.", - /* create */ - "TrillSpanner ", + /* create */ + "TrillSpanner ", - /* read */ - "currentCommandColumn " - "currentMusicalColumn ", + /* read */ + "currentCommandColumn " + "currentMusicalColumn ", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/ttf.cc b/lily/ttf.cc index 4bd6378f27..932f7a6c95 100644 --- a/lily/ttf.cc +++ b/lily/ttf.cc @@ -29,7 +29,6 @@ #include "main.hh" #include "open-type-font.hh" - Index_to_charcode_map make_index_to_charcode_map (FT_Face face) { @@ -45,7 +44,7 @@ make_index_to_charcode_map (FT_Face face) charcode = FT_Get_Next_Char (face, charcode, &gindex)) { m[gindex] = charcode; - j ++; + j++; } FT_Set_Charmap (face, current_cmap); @@ -68,7 +67,7 @@ print_header (void *out, FT_Face face) lily_cookie_fprintf (out, "%d dict begin\n", 11); lily_cookie_fprintf (out, "/FontName /%s def\n", - FT_Get_Postscript_Name (face)); + FT_Get_Postscript_Name (face)); lily_cookie_fprintf (out, "/Encoding StandardEncoding def\n"); lily_cookie_fprintf (out, "/PaintType 0 def\n"); @@ -78,15 +77,15 @@ print_header (void *out, FT_Face face) = (TT_Header *)FT_Get_Sfnt_Table (face, ft_sfnt_head); lily_cookie_fprintf (out, "/FontBBox [%lf %lf %lf %lf] def\n", - float (ht->xMin) / float (ht->Units_Per_EM), - float (ht->yMin) / float (ht->Units_Per_EM), - float (ht->xMax) / float (ht->Units_Per_EM), - float (ht->yMax) / float (ht->Units_Per_EM)); + float (ht->xMin) / float (ht->Units_Per_EM), + float (ht->yMin) / float (ht->Units_Per_EM), + float (ht->xMax) / float (ht->Units_Per_EM), + float (ht->yMax) / float (ht->Units_Per_EM)); lily_cookie_fprintf (out, "/FontType 42 def\n"); lily_cookie_fprintf (out, "/FontInfo 8 dict dup begin\n"); lily_cookie_fprintf (out, "/version (%.3f) def\n", - ht->Font_Revision / 65536.0); + ht->Font_Revision / 65536.0); #if 0 if (strings[0]) @@ -110,13 +109,13 @@ print_header (void *out, FT_Face face) #endif lily_cookie_fprintf (out, "/isFixedPitch %s def\n", - pt->isFixedPitch ? "true" : "false"); + pt->isFixedPitch ? "true" : "false"); lily_cookie_fprintf (out, "/UnderlinePosition %lf def\n", - float (pt->underlinePosition) - / float (ht->Units_Per_EM)); + float (pt->underlinePosition) + / float (ht->Units_Per_EM)); lily_cookie_fprintf (out, "/UnderlineThickness %lf def\n", - float (pt->underlineThickness) - / float (ht->Units_Per_EM)); + float (pt->underlineThickness) + / float (ht->Units_Per_EM)); lily_cookie_fprintf (out, "end readonly def\n"); } @@ -128,8 +127,8 @@ const FT_ULong FT_ENC_TAG (loca_tag, 'l', 'o', 'c', 'a'); static void t42_write_table (void *out, FT_Face face, unsigned char const *buffer, - size_t s, bool is_glyf, - FT_ULong head_length, FT_ULong loca_length) + size_t s, bool is_glyf, + FT_ULong head_length, FT_ULong loca_length) { vector<FT_UShort> chunks; @@ -139,59 +138,59 @@ void t42_write_table (void *out, FT_Face face, unsigned char const *buffer, unsigned char *head_buf = new unsigned char[head_length]; FT_Error error = FT_Load_Sfnt_Table (face, head_tag, 0, head_buf, NULL); if (error) - programming_error ("FT_Load_Sfnt_Table (): error."); + programming_error ("FT_Load_Sfnt_Table (): error."); /* we access the lower byte of indexToLocFormat */ - bool long_offsets = head_buf[4*4 + 2*2 + 2*8 + 4*2 + 3*2 + 1] == 1; + bool long_offsets = head_buf[4 * 4 + 2 * 2 + 2 * 8 + 4 * 2 + 3 * 2 + 1] == 1; delete[] head_buf; unsigned char *loca_buf = new unsigned char[loca_length]; error = FT_Load_Sfnt_Table (face, loca_tag, 0, loca_buf, NULL); if (error) - programming_error ("FT_Load_Sfnt_Table (): error."); + programming_error ("FT_Load_Sfnt_Table (): error."); unsigned char *p = loca_buf; unsigned char *endp = loca_buf + loca_length; FT_ULong offset = 0, last_offset = 0, last_chunk = 0; while (p < endp) - { - if (long_offsets) - { - offset = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]; - p += 4; - } - else - { - offset = ((p[0] << 8) | p[1]) << 1; - p += 2; - } - if (offset > last_offset + CHUNKSIZE) - { - if (last_chunk != last_offset) - chunks.push_back (FT_UShort (last_offset - last_chunk)); - /* - a single glyph with more than 64k data - is a pathological case but... - */ - FT_ULong rest = offset - last_offset; - while (rest > CHUNKSIZE) - { - chunks.push_back (CHUNKSIZE); - rest -= CHUNKSIZE; - } - chunks.push_back (FT_UShort (rest)); - last_chunk = offset; - } - else if (offset > last_chunk + CHUNKSIZE) - { - chunks.push_back (FT_UShort (last_offset - last_chunk)); - last_chunk = last_offset; - } - - last_offset = offset; - } + { + if (long_offsets) + { + offset = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]; + p += 4; + } + else + { + offset = ((p[0] << 8) | p[1]) << 1; + p += 2; + } + if (offset > last_offset + CHUNKSIZE) + { + if (last_chunk != last_offset) + chunks.push_back (FT_UShort (last_offset - last_chunk)); + /* + a single glyph with more than 64k data + is a pathological case but... + */ + FT_ULong rest = offset - last_offset; + while (rest > CHUNKSIZE) + { + chunks.push_back (CHUNKSIZE); + rest -= CHUNKSIZE; + } + chunks.push_back (FT_UShort (rest)); + last_chunk = offset; + } + else if (offset > last_chunk + CHUNKSIZE) + { + chunks.push_back (FT_UShort (last_offset - last_chunk)); + last_chunk = last_offset; + } + + last_offset = offset; + } chunks.push_back (FT_UShort (s - last_chunk)); delete[] loca_buf; @@ -200,17 +199,17 @@ void t42_write_table (void *out, FT_Face face, unsigned char const *buffer, { FT_ULong rest = s; while (rest > CHUNKSIZE) - { - chunks.push_back (CHUNKSIZE); - rest -= CHUNKSIZE; - } + { + chunks.push_back (CHUNKSIZE); + rest -= CHUNKSIZE; + } chunks.push_back (FT_UShort (rest)); } else chunks.push_back (CHUNKSIZE); lily_cookie_fprintf (out, "\n" - " <"); + " <"); int l = 0; static char xdigits[] = "0123456789ABCDEF"; @@ -219,32 +218,32 @@ void t42_write_table (void *out, FT_Face face, unsigned char const *buffer, for (size_t j = 0; j < s; j++) { if (l >= chunks[cur_chunk_idx]) - { - lily_cookie_fprintf (out, "\n" - " 00>\n" - " <"); - l = 0; - cur_chunk_idx ++; - } + { + lily_cookie_fprintf (out, "\n" + " 00>\n" + " <"); + l = 0; + cur_chunk_idx++; + } if (l % 31 == 0) - lily_cookie_fprintf (out, "\n" - " "); + lily_cookie_fprintf (out, "\n" + " "); /* lily_cookie_fprintf (out,"%02X",(int)buffer[j]) is too slow */ lily_cookie_putc (xdigits[(buffer[j] & 0xF0) >> 4], out); lily_cookie_putc (xdigits[buffer[j] & 0x0F], out); - l ++; + l++; } /* pad to four-byte boundary */ - while ((s ++) % 4 != 0) + while ((s++) % 4 != 0) lily_cookie_fprintf (out, "00"); lily_cookie_fprintf (out, "\n" - " 00\n" - " >"); + " 00\n" + " >"); } static void @@ -261,27 +260,27 @@ print_body (void *out, FT_Face face) contains tables which aren't indexed at all */ while (FT_Sfnt_Table_Info (face, idx, &tag, &length) - != FT_Err_Table_Missing) - { - lengths.push_back (length); - tags.push_back (tag); - if (tag == head_tag) - head_length = length; - else if (tag == loca_tag) - loca_length = length; - idx ++; - } + != FT_Err_Table_Missing) + { + lengths.push_back (length); + tags.push_back (tag); + if (tag == head_tag) + head_length = length; + else if (tag == loca_tag) + loca_length = length; + idx++; + } FT_ULong hlength = 12 + 16 * idx; unsigned char *hbuf = new unsigned char[hlength]; unsigned char *p; - hbuf[0] = 0x00; /* version */ + hbuf[0] = 0x00; /* version */ hbuf[1] = 0x01; hbuf[2] = 0x00; hbuf[3] = 0x00; - hbuf[4] = (unsigned char) ((idx & 0xFF00) >> 8); /* numTables */ + hbuf[4] = (unsigned char) ((idx & 0xFF00) >> 8); /* numTables */ hbuf[5] = idx & 0x00FF; FT_UInt searchRange, entrySelector, rangeShift; @@ -303,65 +302,65 @@ print_body (void *out, FT_Face face) FT_ULong checksum, font_checksum = 0; - FT_ULong offset = hlength; /* first table offset */ + FT_ULong offset = hlength; /* first table offset */ for (FT_UInt i = 0; i < idx; i++) - { - /* here, the buffer length must be a multiple of 4 */ - FT_ULong len = (lengths[i] + 3) & ~3; - unsigned char *buf = new unsigned char[len]; - - buf[len - 1] = 0x00; /* assure padding with zeros */ - buf[len - 2] = 0x00; - buf[len - 3] = 0x00; - - FT_Error error = FT_Load_Sfnt_Table (face, tags[i], 0, buf, NULL); - if (error) - programming_error ("FT_Load_Sfnt_Table (): error."); - - if (tag == head_tag) - { - /* - first pass of computing the font checksum - needs checkSumAdjustment = 0 - */ - buf[8] = 0x00; - buf[9] = 0x00; - buf[10] = 0x00; - buf[11] = 0x00; - } - - checksum = 0; - unsigned char *endq = buf + len; - for (unsigned char *q = buf; q < endq; q += 4) - checksum += (q[0] << 24) | (q[1] << 16) | (q[2] << 8) | q[3]; - font_checksum += checksum; - - delete[] buf; - - *(p++) = (unsigned char) ((tags[i] & 0xFF000000UL) >> 24); - *(p++) = (unsigned char) ((tags[i] & 0x00FF0000UL) >> 16); - *(p++) = (unsigned char) ((tags[i] & 0x0000FF00UL) >> 8); - *(p++) = tags[i] & 0x000000FFUL; - - *(p++) = (unsigned char) ((checksum & 0xFF000000UL) >> 24); - *(p++) = (unsigned char) ((checksum & 0x00FF0000UL) >> 16); - *(p++) = (unsigned char) ((checksum & 0x0000FF00UL) >> 8); - *(p++) = checksum & 0x000000FFUL; - - *(p++) = (unsigned char) ((offset & 0xFF000000UL) >> 24); - *(p++) = (unsigned char) ((offset & 0x00FF0000UL) >> 16); - *(p++) = (unsigned char) ((offset & 0x0000FF00UL) >> 8); - *(p++) = offset & 0x000000FFUL; - - *(p++) = (unsigned char) ((lengths[i] & 0xFF000000UL) >> 24); - *(p++) = (unsigned char) ((lengths[i] & 0x00FF0000UL) >> 16); - *(p++) = (unsigned char) ((lengths[i] & 0x0000FF00UL) >> 8); - *(p++) = lengths[i] & 0x000000FFUL; - - /* offset must be a multiple of 4 */ - offset += (lengths[i] + 3) & ~3; - } + { + /* here, the buffer length must be a multiple of 4 */ + FT_ULong len = (lengths[i] + 3) & ~3; + unsigned char *buf = new unsigned char[len]; + + buf[len - 1] = 0x00; /* assure padding with zeros */ + buf[len - 2] = 0x00; + buf[len - 3] = 0x00; + + FT_Error error = FT_Load_Sfnt_Table (face, tags[i], 0, buf, NULL); + if (error) + programming_error ("FT_Load_Sfnt_Table (): error."); + + if (tag == head_tag) + { + /* + first pass of computing the font checksum + needs checkSumAdjustment = 0 + */ + buf[8] = 0x00; + buf[9] = 0x00; + buf[10] = 0x00; + buf[11] = 0x00; + } + + checksum = 0; + unsigned char *endq = buf + len; + for (unsigned char *q = buf; q < endq; q += 4) + checksum += (q[0] << 24) | (q[1] << 16) | (q[2] << 8) | q[3]; + font_checksum += checksum; + + delete[] buf; + + *(p++) = (unsigned char) ((tags[i] & 0xFF000000UL) >> 24); + *(p++) = (unsigned char) ((tags[i] & 0x00FF0000UL) >> 16); + *(p++) = (unsigned char) ((tags[i] & 0x0000FF00UL) >> 8); + *(p++) = tags[i] & 0x000000FFUL; + + *(p++) = (unsigned char) ((checksum & 0xFF000000UL) >> 24); + *(p++) = (unsigned char) ((checksum & 0x00FF0000UL) >> 16); + *(p++) = (unsigned char) ((checksum & 0x0000FF00UL) >> 8); + *(p++) = checksum & 0x000000FFUL; + + *(p++) = (unsigned char) ((offset & 0xFF000000UL) >> 24); + *(p++) = (unsigned char) ((offset & 0x00FF0000UL) >> 16); + *(p++) = (unsigned char) ((offset & 0x0000FF00UL) >> 8); + *(p++) = offset & 0x000000FFUL; + + *(p++) = (unsigned char) ((lengths[i] & 0xFF000000UL) >> 24); + *(p++) = (unsigned char) ((lengths[i] & 0x00FF0000UL) >> 16); + *(p++) = (unsigned char) ((lengths[i] & 0x0000FF00UL) >> 8); + *(p++) = lengths[i] & 0x000000FFUL; + + /* offset must be a multiple of 4 */ + offset += (lengths[i] + 3) & ~3; + } /* add checksum of TTF header */ checksum = 0; @@ -376,41 +375,41 @@ print_body (void *out, FT_Face face) */ lily_cookie_fprintf (out, "/sfnts ["); t42_write_table (out, face, hbuf, hlength, false, - head_length, loca_length); + head_length, loca_length); delete[] hbuf; idx = 0; while (FT_Sfnt_Table_Info (face, idx, &tag, &length) - != FT_Err_Table_Missing) + != FT_Err_Table_Missing) { unsigned char *buf = new unsigned char[length]; FT_Error error = FT_Load_Sfnt_Table (face, tag, 0, buf, NULL); if (error) - programming_error ("FT_Load_Sfnt_Table (): error."); + programming_error ("FT_Load_Sfnt_Table (): error."); if (tag == head_tag) - { - /* in the second pass simply store the computed font checksum */ - buf[8] = (unsigned char) ((font_checksum & 0xFF000000UL) >> 24); - buf[9] = (unsigned char) ((font_checksum & 0x00FF0000UL) >> 16); - buf[10] = (unsigned char) ((font_checksum & 0x0000FF00UL) >> 8); - buf[11] = font_checksum & 0x000000FFUL; - } + { + /* in the second pass simply store the computed font checksum */ + buf[8] = (unsigned char) ((font_checksum & 0xFF000000UL) >> 24); + buf[9] = (unsigned char) ((font_checksum & 0x00FF0000UL) >> 16); + buf[10] = (unsigned char) ((font_checksum & 0x0000FF00UL) >> 8); + buf[11] = font_checksum & 0x000000FFUL; + } bool is_glyf_table = tag == glyf_tag && length > CHUNKSIZE; t42_write_table (out, face, buf, length, is_glyf_table, - head_length, loca_length); + head_length, loca_length); delete[] buf; - idx ++; + idx++; } lily_cookie_fprintf (out, "\n] def\n"); } static void print_trailer (void *out, - FT_Face face) + FT_Face face) { const int GLYPH_NAME_LEN = 256; char glyph_name[GLYPH_NAME_LEN]; @@ -427,40 +426,40 @@ print_trailer (void *out, { glyph_name[0] = 0; if (face->face_flags & FT_FACE_FLAG_GLYPH_NAMES) - { - FT_Error error = FT_Get_Glyph_Name (face, i, glyph_name, - GLYPH_NAME_LEN); - if (error) - { - programming_error ("FT_Get_Glyph_Name (): error."); - glyph_name[0] = 0; - } - } + { + FT_Error error = FT_Get_Glyph_Name (face, i, glyph_name, + GLYPH_NAME_LEN); + if (error) + { + programming_error ("FT_Get_Glyph_Name (): error."); + glyph_name[0] = 0; + } + } if (!glyph_name[0] && ic_map.find (i) != ic_map.end ()) - { - FT_ULong ucode = ic_map[i]; - get_unicode_name (glyph_name, ucode); - } + { + FT_ULong ucode = ic_map[i]; + get_unicode_name (glyph_name, ucode); + } if (i == 0) - sprintf (glyph_name, ".notdef"); + sprintf (glyph_name, ".notdef"); else if (glyph_name == string (".notdef")) - glyph_name[0] = '\0'; + glyph_name[0] = '\0'; if (!glyph_name[0]) - get_glyph_index_name (glyph_name, i); + get_glyph_index_name (glyph_name, i); if (glyph_name[0]) - { - lily_cookie_fprintf (out, "(%s) cvn %d def ", glyph_name, i); - output_count ++; - } + { + lily_cookie_fprintf (out, "(%s) cvn %d def ", glyph_name, i); + output_count++; + } else - programming_error (to_string ("no name for glyph %d", i)); - + programming_error (to_string ("no name for glyph %d", i)); + if (! (output_count % 5)) - lily_cookie_fprintf (out, "\n"); + lily_cookie_fprintf (out, "\n"); } lily_cookie_fprintf (out, "end readonly def\n"); @@ -477,11 +476,11 @@ create_type42_font (void *out, string name, int idx) { face = open_ft_face (name, -1); if (idx >= face->num_faces) - { - warning (_f ("font index %d too large for font `%s', using index 0", - idx, name.c_str())); - idx = 0; - } + { + warning (_f ("font index %d too large for font `%s', using index 0", + idx, name.c_str ())); + idx = 0; + } FT_Done_Face (face); } @@ -495,11 +494,11 @@ create_type42_font (void *out, string name, int idx) } LY_DEFINE (ly_ttf_ps_name, "ly:ttf-ps-name", - 1, 1, 0, (SCM ttf_file_name, SCM idx), - "Extract the PostScript name from a TrueType font. The optional" - " @var{idx} argument is useful for TrueType collections (TTC)" - " only; it specifies the font index within the TTC. The default" - " value of @var{idx} is@tie{}0.") + 1, 1, 0, (SCM ttf_file_name, SCM idx), + "Extract the PostScript name from a TrueType font. The optional" + " @var{idx} argument is useful for TrueType collections (TTC)" + " only; it specifies the font index within the TTC. The default" + " value of @var{idx} is@tie{}0.") { LY_ASSERT_TYPE (scm_is_string, ttf_file_name, 1); @@ -509,10 +508,10 @@ LY_DEFINE (ly_ttf_ps_name, "ly:ttf-ps-name", LY_ASSERT_TYPE (scm_is_integer, idx, 2); i = scm_to_int (idx); if (i < 0) - { - warning (_ ("font index must be non-negative, using index 0")); - i = 0; - } + { + warning (_ ("font index must be non-negative, using index 0")); + i = 0; + } } string file_name = ly_scm2string (ttf_file_name); @@ -526,11 +525,11 @@ LY_DEFINE (ly_ttf_ps_name, "ly:ttf-ps-name", { face = open_ft_face (file_name, -1); if (i >= face->num_faces) - { - warning (_f ("font index %d too large for font `%s', using index 0", - i, file_name.c_str())); - i = 0; - } + { + warning (_f ("font index %d too large for font `%s', using index 0", + i, file_name.c_str ())); + i = 0; + } FT_Done_Face (face); } @@ -546,12 +545,12 @@ LY_DEFINE (ly_ttf_ps_name, "ly:ttf-ps-name", } LY_DEFINE (ly_ttf_2_pfa, "ly:ttf->pfa", - 1, 1, 0, (SCM ttf_file_name, SCM idx), - "Convert the contents of a TrueType font file to PostScript" - " Type@tie{}42 font, returning it as a string. The optional" - " @var{idx} argument is useful for TrueType collections (TTC)" - " only; it specifies the font index within the TTC. The default" - " value of @var{idx} is@tie{}0.") + 1, 1, 0, (SCM ttf_file_name, SCM idx), + "Convert the contents of a TrueType font file to PostScript" + " Type@tie{}42 font, returning it as a string. The optional" + " @var{idx} argument is useful for TrueType collections (TTC)" + " only; it specifies the font index within the TTC. The default" + " value of @var{idx} is@tie{}0.") { LY_ASSERT_TYPE (scm_is_string, ttf_file_name, 1); @@ -561,10 +560,10 @@ LY_DEFINE (ly_ttf_2_pfa, "ly:ttf->pfa", LY_ASSERT_TYPE (scm_is_integer, idx, 2); i = scm_to_int (idx); if (i < 0) - { - warning (_ ("font index must be non-negative, using index 0")); - i = 0; - } + { + warning (_ ("font index must be non-negative, using index 0")); + i = 0; + } } string file_name = ly_scm2string (ttf_file_name); @@ -575,7 +574,7 @@ LY_DEFINE (ly_ttf_2_pfa, "ly:ttf->pfa", create_type42_font (&stream, file_name, i); SCM asscm = scm_from_locale_stringn (stream.get_string (), - stream.get_length ()); + stream.get_length ()); if (be_verbose_global) progress_indication ("]"); diff --git a/lily/tuplet-bracket.cc b/lily/tuplet-bracket.cc index a7e1c6c2ba..c6dfa79992 100644 --- a/lily/tuplet-bracket.cc +++ b/lily/tuplet-bracket.cc @@ -86,7 +86,7 @@ flatten_number_pair_property (Grob *me, Direction xdir, SCM sym) */ Grob * Tuplet_bracket::parallel_beam (Grob *me_grob, vector<Grob *> const &cols, - bool *equally_long) + bool *equally_long) { Spanner *me = dynamic_cast<Spanner *> (me_grob); @@ -95,12 +95,12 @@ Tuplet_bracket::parallel_beam (Grob *me_grob, vector<Grob *> const &cols, return 0; Drul_array<Grob *> stems (Note_column::get_stem (cols[0]), - Note_column::get_stem (cols.back ())); + Note_column::get_stem (cols.back ())); if (!stems[RIGHT] || !stems[LEFT] || (dynamic_cast<Item *> (stems[RIGHT])->get_column () - != me->get_bound (RIGHT)->get_column ())) + != me->get_bound (RIGHT)->get_column ())) return 0; Drul_array<Grob *> beams; @@ -135,7 +135,7 @@ Tuplet_bracket::calc_connect_to_neighbors (SCM smob) Direction dir = get_grob_direction (me); Drul_array<Item *> bounds (get_x_bound_item (me, LEFT, dir), - get_x_bound_item (me, RIGHT, dir)); + get_x_bound_item (me, RIGHT, dir)); Drul_array<bool> connect_to_other (false, false); Direction d = LEFT; @@ -145,25 +145,25 @@ Tuplet_bracket::calc_connect_to_neighbors (SCM smob) Spanner *orig_spanner = dynamic_cast<Spanner *> (me->original ()); vsize neighbor_idx = me->get_break_index () - break_dir; if (break_dir - && d == RIGHT - && neighbor_idx < orig_spanner->broken_intos_.size ()) - { - Grob *neighbor = orig_spanner->broken_intos_[neighbor_idx]; + && d == RIGHT + && neighbor_idx < orig_spanner->broken_intos_.size ()) + { + Grob *neighbor = orig_spanner->broken_intos_[neighbor_idx]; - /* trigger possible suicide*/ - (void) neighbor->get_property ("positions"); - } + /* trigger possible suicide*/ + (void) neighbor->get_property ("positions"); + } connect_to_other[d] - = (break_dir - && neighbor_idx < orig_spanner->broken_intos_.size () - && orig_spanner->broken_intos_[neighbor_idx]->is_live ()); + = (break_dir + && neighbor_idx < orig_spanner->broken_intos_.size () + && orig_spanner->broken_intos_[neighbor_idx]->is_live ()); } while (flip (&d) != LEFT); if (connect_to_other[LEFT] || connect_to_other[RIGHT]) return scm_cons (scm_from_bool (connect_to_other[LEFT]), - scm_from_bool (connect_to_other[RIGHT])); + scm_from_bool (connect_to_other[RIGHT])); return SCM_EOL; } @@ -207,7 +207,7 @@ Tuplet_bracket::calc_control_points (SCM smob) Drul_array<bool> connect_to_other = robust_scm2booldrul (me->get_property ("connect-to-neighbor"), - Drul_array<bool> (false, false)); + Drul_array<bool> (false, false)); Interval x_span; Direction d = LEFT; @@ -216,47 +216,47 @@ Tuplet_bracket::calc_control_points (SCM smob) x_span[d] = robust_relative_extent (bounds[d], commonx, X_AXIS)[d]; if (connect_to_other[d]) - { - Interval overshoot (robust_scm2drul (me->get_property ("break-overshoot"), - Interval (-0.5, 0.0))); - - if (d == RIGHT) - x_span[d] += d * overshoot[d]; - else - x_span[d] = robust_relative_extent (bounds[d], - commonx, X_AXIS)[RIGHT] - - overshoot[LEFT]; - } + { + Interval overshoot (robust_scm2drul (me->get_property ("break-overshoot"), + Interval (-0.5, 0.0))); + + if (d == RIGHT) + x_span[d] += d * overshoot[d]; + else + x_span[d] = robust_relative_extent (bounds[d], + commonx, X_AXIS)[RIGHT] + - overshoot[LEFT]; + } else if (d == RIGHT - && (columns.empty () - || (bounds[d]->get_column () - != dynamic_cast<Item *> (columns.back ())->get_column ()))) - { - /* - We're connecting to a column, for the last bit of a broken - fullLength bracket. - */ - Real padding - = robust_scm2double (me->get_property ("full-length-padding"), 1.0); - - if (bounds[d]->break_status_dir ()) - padding = 0.0; - - Real coord = bounds[d]->relative_coordinate (commonx, X_AXIS); - if (to_boolean (me->get_property ("full-length-to-extent"))) - coord = robust_relative_extent (bounds[d], commonx, X_AXIS)[LEFT]; - - coord = max (coord, x_span[LEFT]); - - x_span[d] = coord - padding; - } + && (columns.empty () + || (bounds[d]->get_column () + != dynamic_cast<Item *> (columns.back ())->get_column ()))) + { + /* + We're connecting to a column, for the last bit of a broken + fullLength bracket. + */ + Real padding + = robust_scm2double (me->get_property ("full-length-padding"), 1.0); + + if (bounds[d]->break_status_dir ()) + padding = 0.0; + + Real coord = bounds[d]->relative_coordinate (commonx, X_AXIS); + if (to_boolean (me->get_property ("full-length-to-extent"))) + coord = robust_relative_extent (bounds[d], commonx, X_AXIS)[LEFT]; + + coord = max (coord, x_span[LEFT]); + + x_span[d] = coord - padding; + } } while (flip (&d) != LEFT); x_span -= me->get_bound (LEFT)->relative_coordinate (commonx, X_AXIS); return scm_list_2 (ly_offset2scm (Offset (x_span[LEFT], positions[LEFT])), - ly_offset2scm (Offset (x_span[RIGHT], positions[RIGHT]))); + ly_offset2scm (Offset (x_span[RIGHT], positions[RIGHT]))); } /* @@ -304,7 +304,7 @@ Tuplet_bracket::print (SCM smob) */ if (!to_boolean (bracket_vis_prop) && (robust_scm2moment (me->get_bound (LEFT)->get_column ()->get_property ("when"), Moment (0)) - == robust_scm2moment (me->get_bound (RIGHT)->get_column ()->get_property ("when"), Moment (0)))) + == robust_scm2moment (me->get_bound (RIGHT)->get_column ()->get_property ("when"), Moment (0)))) bracket_visibility = false; Drul_array<Offset> points; @@ -327,12 +327,12 @@ Tuplet_bracket::print (SCM smob) { Interval ext = number_grob->extent (number_grob, X_AXIS); if (!ext.is_empty ()) - { - gap = ext.length () + 1.0; + { + gap = ext.length () + 1.0; - if ((0.75 * x_span.length () < gap) && !bracket_prop) - bracket_visibility = false; - } + if ((0.75 * x_span.length () < gap) && !bracket_prop) + bracket_visibility = false; + } } if (bracket_visibility) @@ -340,11 +340,11 @@ Tuplet_bracket::print (SCM smob) Drul_array<Real> zero (0, 0); Real ss = Staff_symbol_referencer::staff_space (me); Drul_array<Real> height - = robust_scm2drul (me->get_property ("edge-height"), zero); + = robust_scm2drul (me->get_property ("edge-height"), zero); Drul_array<Real> flare - = robust_scm2drul (me->get_property ("bracket-flare"), zero); + = robust_scm2drul (me->get_property ("bracket-flare"), zero); Drul_array<Real> shorten - = robust_scm2drul (me->get_property ("shorten-pair"), zero); + = robust_scm2drul (me->get_property ("shorten-pair"), zero); Drul_array<Stencil> edge_stencils; Direction dir = get_grob_direction (me); @@ -354,55 +354,55 @@ Tuplet_bracket::print (SCM smob) scale_drul (&shorten, ss); Drul_array<bool> connect_to_other - = robust_scm2booldrul (me->get_property ("connect-to-neighbor"), - Drul_array<bool> (false, false)); + = robust_scm2booldrul (me->get_property ("connect-to-neighbor"), + Drul_array<bool> (false, false)); Direction d = LEFT; do - { - if (connect_to_other[d]) - { - height[d] = 0.0; - flare[d] = 0.0; - shorten[d] = 0.0; - - SCM edge_text = me->get_property ("edge-text"); - - if (scm_is_pair (edge_text)) - { - SCM properties = Font_interface::text_font_alist_chain (me); - SCM text = index_get_cell (edge_text, d); - if (Text_interface::is_markup (text)) - { - SCM t - = Text_interface::interpret_markup (pap->self_scm (), - properties, text); - - Stencil *edge_text = unsmob_stencil (t); - edge_text->translate_axis (x_span[d] - x_span[LEFT], - X_AXIS); - edge_stencils[d] = *edge_text; - } - } - } - } + { + if (connect_to_other[d]) + { + height[d] = 0.0; + flare[d] = 0.0; + shorten[d] = 0.0; + + SCM edge_text = me->get_property ("edge-text"); + + if (scm_is_pair (edge_text)) + { + SCM properties = Font_interface::text_font_alist_chain (me); + SCM text = index_get_cell (edge_text, d); + if (Text_interface::is_markup (text)) + { + SCM t + = Text_interface::interpret_markup (pap->self_scm (), + properties, text); + + Stencil *edge_text = unsmob_stencil (t); + edge_text->translate_axis (x_span[d] - x_span[LEFT], + X_AXIS); + edge_stencils[d] = *edge_text; + } + } + } + } while (flip (&d) != LEFT); Stencil brack = make_bracket (me, Y_AXIS, - points[RIGHT] - points[LEFT], - height, - /* - 0.1 = more space at right due to italics - TODO: use italic correction of font. - */ - Interval (-0.5, 0.5) * gap + 0.1, - flare, shorten); + points[RIGHT] - points[LEFT], + height, + /* + 0.1 = more space at right due to italics + TODO: use italic correction of font. + */ + Interval (-0.5, 0.5) * gap + 0.1, + flare, shorten); do - { - if (!edge_stencils[d].is_empty ()) - brack.add_stencil (edge_stencils[d]); - } + { + if (!edge_stencils[d].is_empty ()) + brack.add_stencil (edge_stencils[d]); + } while (flip (&d) != LEFT); mol.add_stencil (brack); @@ -420,12 +420,12 @@ Tuplet_bracket::print (SCM smob) */ Stencil Tuplet_bracket::make_bracket (Grob *me, // for line properties. - Axis protrusion_axis, - Offset dz, - Drul_array<Real> height, - Interval gap, - Drul_array<Real> flare, - Drul_array<Real> shorten) + Axis protrusion_axis, + Offset dz, + Drul_array<Real> height, + Interval gap, + Drul_array<Real> flare, + Drul_array<Real> shorten) { Drul_array<Offset> corners (Offset (0, 0), dz); @@ -444,7 +444,7 @@ Tuplet_bracket::make_bracket (Grob *me, // for line properties. if (!gap.is_empty ()) { do - gap_corners[d] = (dz * 0.5) + gap[d] / length * dz; + gap_corners[d] = (dz * 0.5) + gap[d] / length * dz; while (flip (&d) != LEFT); } @@ -461,18 +461,18 @@ Tuplet_bracket::make_bracket (Grob *me, // for line properties. do { if (!gap.is_empty ()) - m.add_stencil (Line_interface::line (me, straight_corners[d], - gap_corners[d])); + m.add_stencil (Line_interface::line (me, straight_corners[d], + gap_corners[d])); m.add_stencil (Line_interface::line (me, straight_corners[d], - flare_corners[d])); + flare_corners[d])); } while (flip (&d) != LEFT); if (gap.is_empty ()) m.add_stencil (Line_interface::line (me, straight_corners[LEFT], - straight_corners[RIGHT])); + straight_corners[RIGHT])); return m; } @@ -528,10 +528,10 @@ Tuplet_bracket::calc_position_and_height (Grob *me_grob, Real *offset, Real *dy) { Real pad = robust_scm2double (me->get_property ("staff-padding"), -1.0); if (pad >= 0.0) - { - staff = st->extent (commony, Y_AXIS) - my_offset; - staff.widen (pad); - } + { + staff = st->extent (commony, Y_AXIS) - my_offset; + staff.widen (pad); + } } Direction dir = get_grob_direction (me); @@ -544,8 +544,8 @@ Tuplet_bracket::calc_position_and_height (Grob *me_grob, Real *offset, Real *dy) Real x0 = robust_relative_extent (lgr, commonx, X_AXIS)[LEFT]; Real x1 = robust_relative_extent (rgr, commonx, X_AXIS)[RIGHT]; bool follow_beam = par_beam - && get_grob_direction (par_beam) == dir - && !to_boolean (par_beam->get_property ("knee")); + && get_grob_direction (par_beam) == dir + && !to_boolean (par_beam->get_property ("knee")); vector<Offset> points; if (columns.size () @@ -554,18 +554,18 @@ Tuplet_bracket::calc_position_and_height (Grob *me_grob, Real *offset, Real *dy) && Note_column::get_stem (columns.back ())) { /* - trigger set_stem_ends + trigger set_stem_ends */ (void) par_beam->get_property ("quantized-positions"); Drul_array<Grob *> stems (Note_column::get_stem (columns[0]), - Note_column::get_stem (columns.back ())); + Note_column::get_stem (columns.back ())); Real ss = 0.5 * Staff_symbol_referencer::staff_space (me); Real lp = ss * robust_scm2double (stems[LEFT]->get_property ("stem-end-position"), 0.0) - + stems[LEFT]->get_parent (Y_AXIS)->relative_coordinate (commony, Y_AXIS); + + stems[LEFT]->get_parent (Y_AXIS)->relative_coordinate (commony, Y_AXIS); Real rp = ss * robust_scm2double (stems[RIGHT]->get_property ("stem-end-position"), 0.0) - + stems[RIGHT]->get_parent (Y_AXIS)->relative_coordinate (commony, Y_AXIS); + + stems[RIGHT]->get_parent (Y_AXIS)->relative_coordinate (commony, Y_AXIS); *dy = rp - lp; points.push_back (Offset (stems[LEFT]->relative_coordinate (commonx, X_AXIS) - x0, lp)); @@ -574,44 +574,44 @@ Tuplet_bracket::calc_position_and_height (Grob *me_grob, Real *offset, Real *dy) else { /* - Use outer non-rest columns to determine slope + Use outer non-rest columns to determine slope */ Grob *left_col = 0; Grob *right_col = 0; get_bounds (me, &left_col, &right_col); if (left_col && right_col) - { - Interval rv = Note_column::cross_staff_extent (right_col, commony); - Interval lv = Note_column::cross_staff_extent (left_col, commony); - rv.unite (staff); - lv.unite (staff); - - Real graphical_dy = rv[dir] - lv[dir]; - - Slice ls = Note_column::head_positions_interval (left_col); - Slice rs = Note_column::head_positions_interval (right_col); - - Interval musical_dy; - musical_dy[UP] = rs[UP] - ls[UP]; - musical_dy[DOWN] = rs[DOWN] - ls[DOWN]; - if (sign (musical_dy[UP]) != sign (musical_dy[DOWN])) - *dy = 0.0; - else if (sign (graphical_dy) != sign (musical_dy[DOWN])) - *dy = 0.0; - else - *dy = graphical_dy; - } + { + Interval rv = Note_column::cross_staff_extent (right_col, commony); + Interval lv = Note_column::cross_staff_extent (left_col, commony); + rv.unite (staff); + lv.unite (staff); + + Real graphical_dy = rv[dir] - lv[dir]; + + Slice ls = Note_column::head_positions_interval (left_col); + Slice rs = Note_column::head_positions_interval (right_col); + + Interval musical_dy; + musical_dy[UP] = rs[UP] - ls[UP]; + musical_dy[DOWN] = rs[DOWN] - ls[DOWN]; + if (sign (musical_dy[UP]) != sign (musical_dy[DOWN])) + *dy = 0.0; + else if (sign (graphical_dy) != sign (musical_dy[DOWN])) + *dy = 0.0; + else + *dy = graphical_dy; + } else - *dy = 0; + *dy = 0; for (vsize i = 0; i < columns.size (); i++) - { - Interval note_ext = Note_column::cross_staff_extent (columns[i], - commony); - Real x = columns[i]->relative_coordinate (commonx, X_AXIS) - x0; + { + Interval note_ext = Note_column::cross_staff_extent (columns[i], + commony); + Real x = columns[i]->relative_coordinate (commonx, X_AXIS) - x0; - points.push_back (Offset (x, note_ext[dir])); - } + points.push_back (Offset (x, note_ext[dir])); + } } if (!follow_beam) @@ -633,28 +633,28 @@ Tuplet_bracket::calc_position_and_height (Grob *me_grob, Real *offset, Real *dy) Interval tuplet_y (tuplets[i]->extent (commony, Y_AXIS)); if (!tuplets[i]->is_live ()) - continue; + continue; Direction d = LEFT; Drul_array<Real> positions - = robust_scm2interval (tuplets[i]->get_property ("positions"), - Interval (0,0)); + = robust_scm2interval (tuplets[i]->get_property ("positions"), + Interval (0, 0)); Real other_dy = positions[RIGHT] - positions[LEFT]; do - { - Real y - = tuplet_y.linear_combination (d * sign (other_dy)); - - /* - We don't take padding into account for nested tuplets. - the edges can come very close to the stems, likewise for - nested tuplets? - */ - - points.push_back (Offset (tuplet_x[d] - x0, y)); - } + { + Real y + = tuplet_y.linear_combination (d * sign (other_dy)); + + /* + We don't take padding into account for nested tuplets. + the edges can come very close to the stems, likewise for + nested tuplets? + */ + + points.push_back (Offset (tuplet_x[d] - x0, y)); + } while (flip (&d) != LEFT); } @@ -666,7 +666,7 @@ Tuplet_bracket::calc_position_and_height (Grob *me_grob, Real *offset, Real *dy) Real tuplety = (*dy) * x * factor + my_offset; if (points[i][Y_AXIS] * dir > (*offset + tuplety) * dir) - *offset = points[i][Y_AXIS] - tuplety; + *offset = points[i][Y_AXIS] - tuplety; } *offset += scm_to_double (me->get_property ("padding")) * dir; @@ -688,7 +688,7 @@ Tuplet_bracket::calc_position_and_height (Grob *me_grob, Real *offset, Real *dy) *offset = rint (*offset); if (Staff_symbol_referencer::on_line (me, (int) rint (*offset))) - *offset += dir; + *offset += dir; *offset *= 0.5 * ss; } @@ -714,7 +714,7 @@ Tuplet_bracket::calc_positions (SCM smob) calc_position_and_height (me, &offset, &dy); SCM x = scm_cons (scm_from_double (offset), - scm_from_double (offset + dy)); + scm_from_double (offset + dy)); return x; } @@ -734,7 +734,7 @@ Tuplet_bracket::get_default_dir (Grob *me) continue; Direction d = Note_column::dir (nc); if (d) - dirs[d]++; + dirs[d]++; } if (dirs[UP] == dirs[DOWN]) @@ -750,7 +750,7 @@ Tuplet_bracket::get_default_dir (Grob *me) for (vsize i = 0; i < columns.size (); i++) { Direction d = Note_column::dir (columns[i]); - extremal_positions[d] = minmax (d, 1.0*Note_column::head_positions_interval (columns[i])[d], extremal_positions[d]); + extremal_positions[d] = minmax (d, 1.0 * Note_column::head_positions_interval (columns[i])[d], extremal_positions[d]); } Direction d = LEFT; do @@ -801,37 +801,37 @@ Tuplet_bracket::calc_cross_staff (SCM smob) { Grob *stem = unsmob_grob (cols[i]->get_object ("stem")); if (stem && to_boolean (stem->get_property ("cross-staff"))) - return SCM_BOOL_T; + return SCM_BOOL_T; } return SCM_BOOL_F; } ADD_INTERFACE (Tuplet_bracket, - "A bracket with a number in the middle, used for tuplets." - " When the bracket spans a line break, the value of" - " @code{break-overshoot} determines how far it extends" - " beyond the staff. At a line break, the markups in the" - " @code{edge-text} are printed at the edges.", - - /* properties */ - "bracket-flare " - "bracket-visibility " - "break-overshoot " - "connect-to-neighbor " - "control-points " - "direction " - "edge-height " - "edge-text " - "full-length-padding " - "full-length-to-extent " - "gap " - "positions " - "note-columns " - "padding " - "tuplet-number " - "shorten-pair " - "staff-padding " - "thickness " - "tuplets " - ); + "A bracket with a number in the middle, used for tuplets." + " When the bracket spans a line break, the value of" + " @code{break-overshoot} determines how far it extends" + " beyond the staff. At a line break, the markups in the" + " @code{edge-text} are printed at the edges.", + + /* properties */ + "bracket-flare " + "bracket-visibility " + "break-overshoot " + "connect-to-neighbor " + "control-points " + "direction " + "edge-height " + "edge-text " + "full-length-padding " + "full-length-to-extent " + "gap " + "positions " + "note-columns " + "padding " + "tuplet-number " + "shorten-pair " + "staff-padding " + "thickness " + "tuplets " + ); diff --git a/lily/tuplet-engraver.cc b/lily/tuplet-engraver.cc index 3829c98283..c21794436c 100644 --- a/lily/tuplet-engraver.cc +++ b/lily/tuplet-engraver.cc @@ -41,7 +41,7 @@ struct Tuplet_description Moment stop_moment_; Moment start_moment_; Moment length_; - + Tuplet_description () { event_ = 0; @@ -61,8 +61,8 @@ protected: vector<Tuplet_description> tuplets_; vector<Tuplet_description> new_tuplets_; vector<Tuplet_description> stopped_tuplets_; - vector<Spanner*> last_tuplets_; - + vector<Spanner *> last_tuplets_; + DECLARE_ACKNOWLEDGER (note_column); DECLARE_TRANSLATOR_LISTENER (tuplet_span); virtual void finalize (); @@ -81,32 +81,32 @@ Tuplet_engraver::listen_tuplet_span (Stream_event *ev) d.event_ = ev; d.length_ = robust_scm2moment (d.event_->get_property ("length"), - Moment (0)); + Moment (0)); d.start_moment_ = now_mom (); d.stop_moment_ = now_mom () + d.length_; - for (vsize i=0; i < new_tuplets_.size (); i++) - { - /* - discard duplicates. - */ - if (new_tuplets_[i].stop_moment_ == d.stop_moment_) - return; - } - + for (vsize i = 0; i < new_tuplets_.size (); i++) + { + /* + discard duplicates. + */ + if (new_tuplets_[i].stop_moment_ == d.stop_moment_) + return; + } + new_tuplets_.push_back (d); } else if (dir == STOP) { if (tuplets_.size ()) - { - stopped_tuplets_.push_back (tuplets_.back ()); - tuplets_.pop_back (); - } - else if (!to_boolean (get_property ("skipTypesetting"))) - ev->origin ()->warning (_ ("No tuplet to end")); + { + stopped_tuplets_.push_back (tuplets_.back ()); + tuplets_.pop_back (); + } + else if (!to_boolean (get_property ("skipTypesetting"))) + ev->origin ()->warning (_ ("No tuplet to end")); } - else + else ev->origin ()->programming_error ("direction tuplet-span-event_ invalid."); } @@ -117,48 +117,48 @@ Tuplet_engraver::process_music () This may happen if the end of a tuplet is part of a quoted voice. */ Moment now = now_mom (); - for (vsize i = tuplets_.size (); i --; ) + for (vsize i = tuplets_.size (); i--;) { if (tuplets_[i].stop_moment_ == now) - { - stopped_tuplets_.push_back (tuplets_[i]); - tuplets_.erase (tuplets_.begin () + i); - } + { + stopped_tuplets_.push_back (tuplets_[i]); + tuplets_.erase (tuplets_.begin () + i); + } } - + for (vsize i = 0; i < stopped_tuplets_.size (); i++) { Spanner *bracket = stopped_tuplets_[i].bracket_; Spanner *number = stopped_tuplets_[i].number_; if (bracket) - { - if (stopped_tuplets_[i].full_length_) - { - Item *col = - unsmob_item (stopped_tuplets_[i].full_length_note_ - ? get_property ("currentMusicalColumn") - : get_property ("currentCommandColumn")); - - bracket->set_bound (RIGHT, col); - number->set_bound (RIGHT, col); - } - else if (!bracket->get_bound (RIGHT)) - { - if (bracket->get_bound (LEFT)) - { - bracket->set_bound (RIGHT, - bracket->get_bound (LEFT)); - number->set_bound (RIGHT, - stopped_tuplets_[i].bracket_->get_bound (LEFT)); - } - else - programming_error ("stopped tuplet bracket has neither left nor right bound"); - } - // todo: scrap last_tuplets_, use stopped_tuplets_ only. - // clear stopped_tuplets_ at start_translation_timestep - last_tuplets_.push_back (bracket); - last_tuplets_.push_back (number); - } + { + if (stopped_tuplets_[i].full_length_) + { + Item *col + = unsmob_item (stopped_tuplets_[i].full_length_note_ + ? get_property ("currentMusicalColumn") + : get_property ("currentCommandColumn")); + + bracket->set_bound (RIGHT, col); + number->set_bound (RIGHT, col); + } + else if (!bracket->get_bound (RIGHT)) + { + if (bracket->get_bound (LEFT)) + { + bracket->set_bound (RIGHT, + bracket->get_bound (LEFT)); + number->set_bound (RIGHT, + stopped_tuplets_[i].bracket_->get_bound (LEFT)); + } + else + programming_error ("stopped tuplet bracket has neither left nor right bound"); + } + // todo: scrap last_tuplets_, use stopped_tuplets_ only. + // clear stopped_tuplets_ at start_translation_timestep + last_tuplets_.push_back (bracket); + last_tuplets_.push_back (number); + } } stopped_tuplets_.clear (); @@ -169,30 +169,28 @@ Tuplet_engraver::process_music () /* i goes from size-1 downto 0, inclusively */ vsize i = j - 1; - if (tuplets_[i].bracket_) - continue; + continue; tuplets_[i].full_length_ = to_boolean (get_property ("tupletFullLength")); tuplets_[i].full_length_note_ - = to_boolean (get_property ("tupletFullLengthNote")); - + = to_boolean (get_property ("tupletFullLengthNote")); + tuplets_[i].bracket_ = make_spanner ("TupletBracket", - tuplets_[i].event_->self_scm ()); + tuplets_[i].event_->self_scm ()); tuplets_[i].number_ = make_spanner ("TupletNumber", - tuplets_[i].event_->self_scm ()); + tuplets_[i].event_->self_scm ()); tuplets_[i].number_->set_object ("bracket", tuplets_[i].bracket_->self_scm ()); tuplets_[i].number_->set_parent (tuplets_[i].bracket_, X_AXIS); tuplets_[i].number_->set_parent (tuplets_[i].bracket_, Y_AXIS); tuplets_[i].bracket_->set_object ("tuplet-number", tuplets_[i].number_->self_scm ()); tuplets_[i].stop_moment_.grace_part_ = 0; - - + if (i + 1 < tuplets_.size () && tuplets_[i + 1].bracket_) - Tuplet_bracket::add_tuplet_bracket (tuplets_[i].bracket_, tuplets_[i + 1].bracket_); - + Tuplet_bracket::add_tuplet_bracket (tuplets_[i].bracket_, tuplets_[i + 1].bracket_); + if (i > 0 && tuplets_[i - 1].bracket_) - Tuplet_bracket::add_tuplet_bracket (tuplets_[i - 1].bracket_, tuplets_[i].bracket_); + Tuplet_bracket::add_tuplet_bracket (tuplets_[i - 1].bracket_, tuplets_[i].bracket_); } } @@ -203,9 +201,9 @@ Tuplet_engraver::acknowledge_note_column (Grob_info inf) for (vsize j = 0; j < tuplets_.size (); j++) if (tuplets_[j].bracket_) { - Item *i = dynamic_cast<Item *> (inf.grob ()); - Tuplet_bracket::add_column (tuplets_[j].bracket_, i); - add_bound_item (tuplets_[j].number_, i); + Item *i = dynamic_cast<Item *> (inf.grob ()); + Tuplet_bracket::add_column (tuplets_[j].bracket_, i); + add_bound_item (tuplets_[j].number_, i); } } @@ -216,7 +214,7 @@ Tuplet_engraver::start_translation_timestep () /* May seem superfluous, but necessary for skipTypesetting. */ - new_tuplets_.clear (); + new_tuplets_.clear (); } void @@ -225,8 +223,8 @@ Tuplet_engraver::finalize () if (to_boolean (get_property ("tupletFullLength"))) for (vsize i = 0; i < last_tuplets_.size (); i++) { - Item *col = unsmob_item (get_property ("currentCommandColumn")); - last_tuplets_[i]->set_bound (RIGHT, col); + Item *col = unsmob_item (get_property ("currentCommandColumn")); + last_tuplets_[i]->set_bound (RIGHT, col); } } @@ -236,17 +234,17 @@ Tuplet_engraver::Tuplet_engraver () ADD_ACKNOWLEDGER (Tuplet_engraver, note_column); ADD_TRANSLATOR (Tuplet_engraver, - /* doc */ - "Catch tuplet events and generate appropriate bracket.", - - /* create */ - "TupletBracket " - "TupletNumber ", - - /* read */ - "tupletFullLength " - "tupletFullLengthNote ", - - /* write */ - "" - ); + /* doc */ + "Catch tuplet events and generate appropriate bracket.", + + /* create */ + "TupletBracket " + "TupletNumber ", + + /* read */ + "tupletFullLength " + "tupletFullLengthNote ", + + /* write */ + "" + ); diff --git a/lily/tuplet-iterator.cc b/lily/tuplet-iterator.cc index 97737db0f2..5f3548e490 100644 --- a/lily/tuplet-iterator.cc +++ b/lily/tuplet-iterator.cc @@ -63,8 +63,8 @@ Music * Tuplet_iterator::create_event (Direction d) { SCM ev_scm = scm_call_2 (ly_lily_module_constant ("make-span-event"), - ly_symbol2scm ("TupletSpanEvent"), - scm_from_int (d)); + ly_symbol2scm ("TupletSpanEvent"), + scm_from_int (d)); Music *mus = get_music (); @@ -75,8 +75,8 @@ Tuplet_iterator::create_event (Direction d) ev->set_property ("numerator", mus->get_property ("numerator")); ev->set_property ("denominator", mus->get_property ("denominator")); ev->set_property ("tweaks", mus->get_property ("tweaks")); - ev->set_property ("length", spanner_duration_.smobbed_copy ()); - } + ev->set_property ("length", spanner_duration_.smobbed_copy ()); + } synthesized_events_ = scm_cons (ev_scm, synthesized_events_); return ev; @@ -105,22 +105,22 @@ Tuplet_iterator::process (Moment m) { descend_to_bottom_context (); if (tuplet_handler_.get_outlet ()) - create_event (STOP)->send_to_context (tuplet_handler_.get_outlet ()); + create_event (STOP)->send_to_context (tuplet_handler_.get_outlet ()); if (m.main_part_ < music_get_length ().main_part_) - { - tuplet_handler_.set_context (get_outlet ()); - report_event (create_event (START)); + { + tuplet_handler_.set_context (get_outlet ()); + report_event (create_event (START)); - next_split_mom_ += spanner_duration_; - } + next_split_mom_ += spanner_duration_; + } else - tuplet_handler_.set_context (0); + tuplet_handler_.set_context (0); } Music_wrapper_iterator::process (m); if (child_iter_ && child_iter_->ok ()) descend_to_child (child_iter_->get_outlet ()); - + } void diff --git a/lily/tuplet-number.cc b/lily/tuplet-number.cc index 8a4499e2c3..2972942ee3 100644 --- a/lily/tuplet-number.cc +++ b/lily/tuplet-number.cc @@ -31,14 +31,13 @@ struct Tuplet_number DECLARE_SCHEME_CALLBACK (calc_cross_staff, (SCM)); DECLARE_GROB_INTERFACE (); }; - MAKE_SCHEME_CALLBACK (Tuplet_number, print, 1); -SCM +SCM Tuplet_number::print (SCM smob) { Spanner *me = unsmob_spanner (smob); - Spanner *tuplet = unsmob_spanner (me->get_object ("bracket")); + Spanner *tuplet = unsmob_spanner (me->get_object ("bracket")); if (!tuplet || !tuplet->is_live ()) { @@ -52,7 +51,7 @@ Tuplet_number::print (SCM smob) stc->align_to (X_AXIS, CENTER); stc->align_to (Y_AXIS, CENTER); - SCM cpoints = tuplet->get_property ("control-points"); + SCM cpoints = tuplet->get_property ("control-points"); Drul_array<Offset> points; if (scm_is_pair (cpoints)) { @@ -64,7 +63,7 @@ Tuplet_number::print (SCM smob) programming_error ("wrong type for control-points"); } stc->translate ((points[RIGHT] + points[LEFT]) / 2); - + return stc_scm; } @@ -77,11 +76,11 @@ Tuplet_number::calc_cross_staff (SCM smob) } ADD_INTERFACE (Tuplet_number, - "The number for a bracket.", + "The number for a bracket.", - /* properties */ - "avoid-slur " // UGH. - "bracket " - "direction " - ); + /* properties */ + "avoid-slur " // UGH. + "bracket " + "direction " + ); diff --git a/lily/tweak-engraver.cc b/lily/tweak-engraver.cc index 1f4f75d870..e65b56a7e9 100644 --- a/lily/tweak-engraver.cc +++ b/lily/tweak-engraver.cc @@ -42,25 +42,25 @@ Tweak_engraver::acknowledge_grob (Grob_info info) if (Stream_event *ev = info.event_cause ()) { for (SCM s = ev->get_property ("tweaks"); - scm_is_pair (s); s = scm_cdr (s)) - { - info.grob ()->set_property (scm_caar (s), scm_cdar (s)); - } + scm_is_pair (s); s = scm_cdr (s)) + { + info.grob ()->set_property (scm_caar (s), scm_cdar (s)); + } } } ADD_ACKNOWLEDGER (Tweak_engraver, grob); ADD_TRANSLATOR (Tweak_engraver, - /* doc */ - "Read the @code{tweaks} property from the originating event," - " and set properties.", - - /* create */ - "", + /* doc */ + "Read the @code{tweaks} property from the originating event," + " and set properties.", - /* read */ - "", + /* create */ + "", - /* write */ - "" - ); + /* read */ + "", + + /* write */ + "" + ); diff --git a/lily/unfolded-repeat-iterator.cc b/lily/unfolded-repeat-iterator.cc index 7ee50cbfe6..737b4a29b4 100644 --- a/lily/unfolded-repeat-iterator.cc +++ b/lily/unfolded-repeat-iterator.cc @@ -43,18 +43,18 @@ Unfolded_repeat_iterator::get_music_list () const for (int i = 0; i < rep_count; i++) { if (unsmob_music (body)) - *tail = scm_cons (body, SCM_EOL); + *tail = scm_cons (body, SCM_EOL); tail = SCM_CDRLOC (*tail); if (alt_count) - { - *tail = scm_cons (scm_car (alts), SCM_EOL); - tail = SCM_CDRLOC (*tail); - if (i >= rep_count - alt_count) + { + *tail = scm_cons (scm_car (alts), SCM_EOL); + tail = SCM_CDRLOC (*tail); + if (i >= rep_count - alt_count) - alts = scm_cdr (alts); - } + alts = scm_cdr (alts); + } } return l; diff --git a/lily/vaticana-ligature-engraver.cc b/lily/vaticana-ligature-engraver.cc index 5402a8fb01..c89f0e832d 100644 --- a/lily/vaticana-ligature-engraver.cc +++ b/lily/vaticana-ligature-engraver.cc @@ -64,12 +64,12 @@ class Vaticana_ligature_engraver : public Gregorian_ligature_engraver private: static bool need_extra_horizontal_space (int prev_prefix_set, int prefix_set, - int context_info, int delta_pitch); + int context_info, int delta_pitch); bool is_stacked_head (int prefix_set, - int context_info); + int context_info); Real align_heads (vector<Grob_info> primitives, - Real flexa_width, - Real thickness); + Real flexa_width, + Real thickness); void check_for_prefix_loss (Item *primitive); void check_for_ambiguous_dot_pitch (Grob_info primitive); void add_mora_column (Paper_column *column); @@ -81,7 +81,7 @@ public: protected: virtual Spanner *create_ligature_spanner (); virtual void transform_heads (Spanner *ligature, - vector<Grob_info> primitives); + vector<Grob_info> primitives); DECLARE_TRANSLATOR_LISTENER (pes_or_flexa); DECLARE_TRANSLATOR_LISTENER (ligature); }; @@ -102,8 +102,8 @@ Vaticana_ligature_engraver::listen_ligature (Stream_event *ev) Vaticana_ligature_engraver::Vaticana_ligature_engraver () { - brew_ligature_primitive_proc = - Vaticana_ligature::brew_ligature_primitive_proc; + brew_ligature_primitive_proc + = Vaticana_ligature::brew_ligature_primitive_proc; augmented_primitives_.clear (); } @@ -115,7 +115,7 @@ Vaticana_ligature_engraver::create_ligature_spanner () bool Vaticana_ligature_engraver::is_stacked_head (int prefix_set, - int context_info) + int context_info) { bool is_stacked; @@ -162,7 +162,7 @@ Vaticana_ligature_engraver::is_stacked_head (int prefix_set, */ bool Vaticana_ligature_engraver::need_extra_horizontal_space (int prev_prefix_set, int prefix_set, - int context_info, int delta_pitch) + int context_info, int delta_pitch) { if (prev_prefix_set & VIRGA) /* @@ -200,13 +200,13 @@ Vaticana_ligature_engraver::need_extra_horizontal_space (int prev_prefix_set, in Real Vaticana_ligature_engraver::align_heads (vector<Grob_info> primitives, - Real flexa_width, - Real thickness) + Real flexa_width, + Real thickness) { if (!primitives.size ()) { programming_error ("Vaticana_ligature:" - " empty ligature [ignored]"); + " empty ligature [ignored]"); return 0.0; } @@ -238,9 +238,9 @@ Vaticana_ligature_engraver::align_heads (vector<Grob_info> primitives, { Item *primitive = dynamic_cast<Item *> (primitives[i].grob ()); int prefix_set - = scm_to_int (primitive->get_property ("prefix-set")); + = scm_to_int (primitive->get_property ("prefix-set")); int context_info - = scm_to_int (primitive->get_property ("context-info")); + = scm_to_int (primitive->get_property ("context-info")); /* * Get glyph_name, delta_pitch and context_info for this head. @@ -248,28 +248,28 @@ Vaticana_ligature_engraver::align_heads (vector<Grob_info> primitives, SCM glyph_name_scm = primitive->get_property ("glyph-name"); if (glyph_name_scm == SCM_EOL) - { - primitive->programming_error ("Vaticana_ligature:" - " undefined glyph-name ->" - " ignoring grob"); - continue; - } + { + primitive->programming_error ("Vaticana_ligature:" + " undefined glyph-name ->" + " ignoring grob"); + continue; + } string glyph_name = ly_scm2string (glyph_name_scm); int delta_pitch = 0; if (prev_primitive) /* urgh, need prev_primitive only here */ - { - SCM delta_pitch_scm = prev_primitive->get_property ("delta-position"); - if (delta_pitch_scm != SCM_EOL) - delta_pitch = scm_to_int (delta_pitch_scm); - else - { - primitive->programming_error ("Vaticana_ligature:" - " delta-position undefined ->" - " ignoring grob"); - continue; - } - } + { + SCM delta_pitch_scm = prev_primitive->get_property ("delta-position"); + if (delta_pitch_scm != SCM_EOL) + delta_pitch = scm_to_int (delta_pitch_scm); + else + { + primitive->programming_error ("Vaticana_ligature:" + " delta-position undefined ->" + " ignoring grob"); + continue; + } + } /* * Now determine width and x-offset of head. @@ -279,45 +279,45 @@ Vaticana_ligature_engraver::align_heads (vector<Grob_info> primitives, Real x_offset; if (context_info & STACKED_HEAD) - { - /* - * This head is stacked upon the previous one; hence, it - * does not contribute to the total width of the ligature, - * and its width is assumed to be 0.0. Moreover, it is - * shifted to the left by its width such that the right side - * of this and the other head are horizontally aligned. - */ - head_width = 0.0; - x_offset = join_thickness - - Font_interface::get_default_font (primitive)-> - find_by_name ("noteheads.s" + glyph_name).extent (X_AXIS).length (); - } + { + /* + * This head is stacked upon the previous one; hence, it + * does not contribute to the total width of the ligature, + * and its width is assumed to be 0.0. Moreover, it is + * shifted to the left by its width such that the right side + * of this and the other head are horizontally aligned. + */ + head_width = 0.0; + x_offset = join_thickness + - Font_interface::get_default_font (primitive)-> + find_by_name ("noteheads.s" + glyph_name).extent (X_AXIS).length (); + } else if (glyph_name == "flexa" || glyph_name == "") - { - /* - * This head represents either half of a flexa shape. - * Hence, it is assigned half the width of this shape. - */ - head_width = 0.5 * flexa_width; - x_offset = 0.0; - } + { + /* + * This head represents either half of a flexa shape. + * Hence, it is assigned half the width of this shape. + */ + head_width = 0.5 * flexa_width; + x_offset = 0.0; + } else - { - /* - * This is a regular head, placed right to the previous one. - * Retrieve its width from corresponding font. - */ - head_width - = Font_interface::get_default_font (primitive)-> - find_by_name ("noteheads.s" + glyph_name).extent (X_AXIS).length (); - x_offset = 0.0; - } + { + /* + * This is a regular head, placed right to the previous one. + * Retrieve its width from corresponding font. + */ + head_width + = Font_interface::get_default_font (primitive)-> + find_by_name ("noteheads.s" + glyph_name).extent (X_AXIS).length (); + x_offset = 0.0; + } /* * Save the head's final x-offset. */ primitive->set_property ("x-offset", - scm_from_double (x_offset)); + scm_from_double (x_offset)); /* * If the head is the 2nd head of a pes or flexa (but not a @@ -325,39 +325,39 @@ Vaticana_ligature_engraver::align_heads (vector<Grob_info> primitives, * neighbour head (i.e. the previous head) by a vertical beam. */ if ((context_info & PES_UPPER) - || ((context_info & FLEXA_RIGHT) - && ! (context_info & PES_LOWER))) - { - if (!prev_primitive) - { - primitive->programming_error ("Vaticana ligature: add-join:" - " missing previous primitive"); - } - else - { - prev_primitive->set_property ("add-join", - ly_bool2scm (true)); - - /* - * Create a small overlap of adjacent heads so that the join - * can be drawn perfectly between them. - */ - ligature_width -= join_thickness; - } - } + || ((context_info & FLEXA_RIGHT) + && ! (context_info & PES_LOWER))) + { + if (!prev_primitive) + { + primitive->programming_error ("Vaticana ligature: add-join:" + " missing previous primitive"); + } + else + { + prev_primitive->set_property ("add-join", + ly_bool2scm (true)); + + /* + * Create a small overlap of adjacent heads so that the join + * can be drawn perfectly between them. + */ + ligature_width -= join_thickness; + } + } else if (glyph_name == "") - { - /* - * This is the 2nd (virtual) head of flexa shape. Join it - * tightly with 1st head, i.e. do *not* add additional - * space, such that next head will not be off from the flexa - * shape. - */ - } + { + /* + * This is the 2nd (virtual) head of flexa shape. Join it + * tightly with 1st head, i.e. do *not* add additional + * space, such that next head will not be off from the flexa + * shape. + */ + } if (need_extra_horizontal_space (prev_prefix_set, prefix_set, - context_info, delta_pitch)) - ligature_width += extra_space; + context_info, delta_pitch)) + ligature_width += extra_space; /* * Horizontally line-up this head to form a ligature. @@ -398,9 +398,9 @@ Vaticana_ligature_engraver::check_for_prefix_loss (Item *primitive) { string prefs = Gregorian_ligature::prefixes_to_str (primitive); primitive->warning (_f ("ignored prefix(es) `%s' of this head" - " according to restrictions of the selected" - " ligature style", - prefs.c_str ())); + " according to restrictions of the selected" + " ligature style", + prefs.c_str ())); } } @@ -412,15 +412,15 @@ Vaticana_ligature_engraver::add_mora_column (Paper_column *column) if (!column) // empty ligature??? { augmented_primitives_[0].grob ()-> - programming_error ("no paper column to add dot"); + programming_error ("no paper column to add dot"); return; } Item *dotcol = make_item ("DotColumn", SCM_EOL); dotcol->set_parent (column, X_AXIS); for (vsize i = 0; i < augmented_primitives_.size (); i++) { - Item *primitive = - dynamic_cast<Item *> (augmented_primitives_[i].grob ()); + Item *primitive + = dynamic_cast<Item *> (augmented_primitives_[i].grob ()); Item *dot = make_item ("Dots", primitive->self_scm ()); dot->set_property ("dot-count", scm_from_int (1)); dot->set_parent (primitive, Y_AXIS); @@ -461,19 +461,19 @@ Vaticana_ligature_engraver::check_for_ambiguous_dot_pitch (Grob_info primitive) Stream_event *cause = augmented_primitives_[i].event_cause (); int pitch = unsmob_pitch (cause->get_property ("pitch"))->steps (); if (pitch == new_pitch) - { - primitive.grob ()-> - warning ("Ambiguous use of dots in ligature: there are" - " multiple dotted notes with the same pitch." - " The ligature should be split."); - return; // supress multiple identical warnings - } + { + primitive.grob ()-> + warning ("Ambiguous use of dots in ligature: there are" + " multiple dotted notes with the same pitch." + " The ligature should be split."); + return; // supress multiple identical warnings + } } } void Vaticana_ligature_engraver::transform_heads (Spanner *ligature, - vector<Grob_info> primitives) + vector<Grob_info> primitives) { Real flexa_width = robust_scm2double (ligature->get_property ("flexa-width"), 2); @@ -492,47 +492,47 @@ Vaticana_ligature_engraver::transform_heads (Spanner *ligature, int delta_pitch; SCM delta_pitch_scm = primitive->get_property ("delta-position"); if (delta_pitch_scm != SCM_EOL) - delta_pitch = scm_to_int (delta_pitch_scm); + delta_pitch = scm_to_int (delta_pitch_scm); else - { - primitive->programming_error ("Vaticana_ligature:" - " delta-position undefined ->" - " ignoring grob"); - continue; - } + { + primitive->programming_error ("Vaticana_ligature:" + " delta-position undefined ->" + " ignoring grob"); + continue; + } /* retrieve & complete prefix_set and context_info */ int prefix_set - = scm_to_int (primitive->get_property ("prefix-set")); + = scm_to_int (primitive->get_property ("prefix-set")); int context_info - = scm_to_int (primitive->get_property ("context-info")); + = scm_to_int (primitive->get_property ("context-info")); if (Rhythmic_head::dot_count (primitive) > 0) - // remove dots from primitive and add remember primitive for - // creating a dot column - { - Rhythmic_head::get_dots (primitive)->set_property ("dot-count", - scm_from_int (0)); - // TODO: Maybe completely remove grob "Dots" (dots->suicide - // () ?) rather than setting property "dot-count" to 0. - - check_for_ambiguous_dot_pitch (primitives[i]); - augmented_primitives_.push_back (primitives[i]); - } + // remove dots from primitive and add remember primitive for + // creating a dot column + { + Rhythmic_head::get_dots (primitive)->set_property ("dot-count", + scm_from_int (0)); + // TODO: Maybe completely remove grob "Dots" (dots->suicide + // () ?) rather than setting property "dot-count" to 0. + + check_for_ambiguous_dot_pitch (primitives[i]); + augmented_primitives_.push_back (primitives[i]); + } else if (augmented_primitives_.size () > 0) - { - primitive->warning ("This ligature has a dotted head followed by" - " a non-dotted head. The ligature should be" - " split after the last dotted head before" - " this head."); - } + { + primitive->warning ("This ligature has a dotted head followed by" + " a non-dotted head. The ligature should be" + " split after the last dotted head before" + " this head."); + } if (is_stacked_head (prefix_set, context_info)) - { - context_info |= STACKED_HEAD; - primitive->set_property ("context-info", - scm_from_int (context_info)); - } + { + context_info |= STACKED_HEAD; + primitive->set_property ("context-info", + scm_from_int (context_info)); + } /* * Now determine which head to typeset (this is context sensitive @@ -542,118 +542,118 @@ Vaticana_ligature_engraver::transform_heads (Spanner *ligature, */ string glyph_name; if (prefix_set & VIRGA) - { - glyph_name = "vaticana.punctum"; - primitive->set_property ("add-stem", ly_bool2scm (true)); - } + { + glyph_name = "vaticana.punctum"; + primitive->set_property ("add-stem", ly_bool2scm (true)); + } else if (prefix_set & QUILISMA) - glyph_name = "vaticana.quilisma"; + glyph_name = "vaticana.quilisma"; else if (prefix_set & ORISCUS) - glyph_name = "solesmes.oriscus"; + glyph_name = "solesmes.oriscus"; else if (prefix_set & STROPHA) - if (prefix_set & AUCTUM) - glyph_name = "solesmes.stropha.aucta"; - else glyph_name = "solesmes.stropha"; + if (prefix_set & AUCTUM) + glyph_name = "solesmes.stropha.aucta"; + else glyph_name = "solesmes.stropha"; else if (prefix_set & INCLINATUM) - if (prefix_set & AUCTUM) - glyph_name = "solesmes.incl.auctum"; - else if (prefix_set & DEMINUTUM) - glyph_name = "solesmes.incl.parvum"; - else - glyph_name = "vaticana.inclinatum"; + if (prefix_set & AUCTUM) + glyph_name = "solesmes.incl.auctum"; + else if (prefix_set & DEMINUTUM) + glyph_name = "solesmes.incl.parvum"; + else + glyph_name = "vaticana.inclinatum"; else if (prefix_set & DEMINUTUM) - { - if (i == 0) - { - // initio debilis - glyph_name = "vaticana.reverse.plica"; - } - else if (prev_delta_pitch > 0) - { - // epiphonus - if (! (prev_context_info & FLEXA_RIGHT)) - { - /* correct head of previous primitive */ - if (prev_delta_pitch > 1) - prev_glyph_name = "vaticana.epiphonus"; - else - prev_glyph_name = "vaticana.vepiphonus"; - } - if (prev_delta_pitch > 1) - glyph_name = "vaticana.plica"; - else - glyph_name = "vaticana.vplica"; - } - else if (prev_delta_pitch < 0) - { - // cephalicus - if (! (prev_context_info & FLEXA_RIGHT)) - /* correct head of previous primitive */ - { - if (i > 1) - { - /* cephalicus head with fixed size cauda */ - prev_glyph_name = "vaticana.inner.cephalicus"; - } - else - { - /* cephalicus head without cauda */ - prev_glyph_name = "vaticana.cephalicus"; - } - - /* - * Flexa has no variable size cauda if its left head is - * stacked on the right head. This is true for - * cephalicus. Hence, remove the cauda. - * - * Urgh: for the current implementation, this rule only - * applies for cephalicus; but it is a fundamental rule. - * Therefore, the following line of code should be - * placed somewhere else. - */ - prev_primitive->set_property ("add-cauda", - ly_bool2scm (false)); - } - if (prev_delta_pitch < - 1) - glyph_name = "vaticana.reverse.plica"; - else - glyph_name = "vaticana.reverse.vplica"; - } - else // (prev_delta_pitch == 0) - { - primitive->programming_error ("Vaticana_ligature:" - " deminutum head must have different" - " pitch -> ignoring grob"); - } - } + { + if (i == 0) + { + // initio debilis + glyph_name = "vaticana.reverse.plica"; + } + else if (prev_delta_pitch > 0) + { + // epiphonus + if (! (prev_context_info & FLEXA_RIGHT)) + { + /* correct head of previous primitive */ + if (prev_delta_pitch > 1) + prev_glyph_name = "vaticana.epiphonus"; + else + prev_glyph_name = "vaticana.vepiphonus"; + } + if (prev_delta_pitch > 1) + glyph_name = "vaticana.plica"; + else + glyph_name = "vaticana.vplica"; + } + else if (prev_delta_pitch < 0) + { + // cephalicus + if (! (prev_context_info & FLEXA_RIGHT)) + /* correct head of previous primitive */ + { + if (i > 1) + { + /* cephalicus head with fixed size cauda */ + prev_glyph_name = "vaticana.inner.cephalicus"; + } + else + { + /* cephalicus head without cauda */ + prev_glyph_name = "vaticana.cephalicus"; + } + + /* + * Flexa has no variable size cauda if its left head is + * stacked on the right head. This is true for + * cephalicus. Hence, remove the cauda. + * + * Urgh: for the current implementation, this rule only + * applies for cephalicus; but it is a fundamental rule. + * Therefore, the following line of code should be + * placed somewhere else. + */ + prev_primitive->set_property ("add-cauda", + ly_bool2scm (false)); + } + if (prev_delta_pitch < - 1) + glyph_name = "vaticana.reverse.plica"; + else + glyph_name = "vaticana.reverse.vplica"; + } + else // (prev_delta_pitch == 0) + { + primitive->programming_error ("Vaticana_ligature:" + " deminutum head must have different" + " pitch -> ignoring grob"); + } + } else if (prefix_set & (CAVUM | LINEA)) - if ((prefix_set & CAVUM) && (prefix_set & LINEA)) - glyph_name = "vaticana.linea.punctum.cavum"; - else if (prefix_set & CAVUM) - glyph_name = "vaticana.punctum.cavum"; - else - glyph_name = "vaticana.linea.punctum"; + if ((prefix_set & CAVUM) && (prefix_set & LINEA)) + glyph_name = "vaticana.linea.punctum.cavum"; + else if (prefix_set & CAVUM) + glyph_name = "vaticana.punctum.cavum"; + else + glyph_name = "vaticana.linea.punctum"; else if (prefix_set & AUCTUM) - if (prefix_set & ASCENDENS) - glyph_name = "solesmes.auct.asc"; - else - glyph_name = "solesmes.auct.desc"; + if (prefix_set & ASCENDENS) + glyph_name = "solesmes.auct.asc"; + else + glyph_name = "solesmes.auct.desc"; else if ((context_info & STACKED_HEAD) - && (context_info & PES_UPPER)) - if (prev_delta_pitch > 1) - glyph_name = "vaticana.upes"; - else - glyph_name = "vaticana.vupes"; + && (context_info & PES_UPPER)) + if (prev_delta_pitch > 1) + glyph_name = "vaticana.upes"; + else + glyph_name = "vaticana.vupes"; else - glyph_name = "vaticana.punctum"; + glyph_name = "vaticana.punctum"; /* * This head needs a cauda, if it starts a flexa, is not the upper * head of a pes, and if it is a punctum. */ if ((context_info & FLEXA_LEFT) && ! (context_info & PES_UPPER)) - if (glyph_name == "vaticana.punctum") - primitive->set_property ("add-cauda", ly_bool2scm (true)); + if (glyph_name == "vaticana.punctum") + primitive->set_property ("add-cauda", ly_bool2scm (true)); /* * Execptional rule for porrectus: @@ -663,21 +663,21 @@ Vaticana_ligature_engraver::transform_heads (Spanner *ligature, * the previous head into a single curved flexa shape. */ if ((context_info & FLEXA_RIGHT) && (context_info & PES_LOWER)) - { - check_for_prefix_loss (prev_primitive); - prev_glyph_name = "flexa"; - prev_primitive->set_property ("flexa-height", - scm_from_int (prev_delta_pitch)); - prev_primitive->set_property ("flexa-width", - scm_from_double (flexa_width)); - bool add_cauda = !(prev_prefix_set && PES_OR_FLEXA); - prev_primitive->set_property ("add-cauda", - ly_bool2scm (add_cauda)); - check_for_prefix_loss (primitive); - glyph_name = ""; - primitive->set_property ("flexa-width", - scm_from_double (flexa_width)); - } + { + check_for_prefix_loss (prev_primitive); + prev_glyph_name = "flexa"; + prev_primitive->set_property ("flexa-height", + scm_from_int (prev_delta_pitch)); + prev_primitive->set_property ("flexa-width", + scm_from_double (flexa_width)); + bool add_cauda = !(prev_prefix_set && PES_OR_FLEXA); + prev_primitive->set_property ("add-cauda", + ly_bool2scm (add_cauda)); + check_for_prefix_loss (primitive); + glyph_name = ""; + primitive->set_property ("flexa-width", + scm_from_double (flexa_width)); + } /* * Exceptional rule for pes: @@ -688,22 +688,22 @@ Vaticana_ligature_engraver::transform_heads (Spanner *ligature, * current head. */ if (prefix_set & PES_OR_FLEXA) - { - if ((context_info & PES_UPPER) && (context_info & STACKED_HEAD)) - { - if (prev_glyph_name == "vaticana.punctum") - { - if (prev_delta_pitch > 1) - prev_glyph_name = "vaticana.lpes"; - else - prev_glyph_name = "vaticana.vlpes"; - } - } - } + { + if ((context_info & PES_UPPER) && (context_info & STACKED_HEAD)) + { + if (prev_glyph_name == "vaticana.punctum") + { + if (prev_delta_pitch > 1) + prev_glyph_name = "vaticana.lpes"; + else + prev_glyph_name = "vaticana.vlpes"; + } + } + } if (prev_primitive) - prev_primitive->set_property ("glyph-name", - ly_string2scm (prev_glyph_name)); + prev_primitive->set_property ("glyph-name", + ly_string2scm (prev_glyph_name)); /* * In the backend, flexa shapes and joins need to know about line @@ -721,7 +721,7 @@ Vaticana_ligature_engraver::transform_heads (Spanner *ligature, } prev_primitive->set_property ("glyph-name", - ly_string2scm (prev_glyph_name)); + ly_string2scm (prev_glyph_name)); align_heads (primitives, flexa_width, thickness); @@ -734,27 +734,27 @@ Vaticana_ligature_engraver::transform_heads (Spanner *ligature, Item *first_primitive = dynamic_cast<Item *> (primitives[0].grob ()); Paper_column *paper_column = first_primitive->get_column (); paper_column->warning (_f ("Vaticana_ligature_engraver:" - " setting `spacing-increment = %f': ptr =%ul", - ligature_width, paper_column)); + " setting `spacing-increment = %f': ptr =%ul", + ligature_width, paper_column)); paper_column-> - set_property ("forced-spacing", scm_from_double (ligature_width)); + set_property ("forced-spacing", scm_from_double (ligature_width)); #endif } ADD_ACKNOWLEDGER (Vaticana_ligature_engraver, rest); ADD_ACKNOWLEDGER (Vaticana_ligature_engraver, ligature_head); ADD_TRANSLATOR (Vaticana_ligature_engraver, - /* doc */ - "Handle ligatures by glueing special ligature heads" - " together.", + /* doc */ + "Handle ligatures by glueing special ligature heads" + " together.", - /* create */ - "VaticanaLigature " - "DotColumn ", + /* create */ + "VaticanaLigature " + "DotColumn ", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/vaticana-ligature.cc b/lily/vaticana-ligature.cc index 7a00cff300..42511f7243 100644 --- a/lily/vaticana-ligature.cc +++ b/lily/vaticana-ligature.cc @@ -31,10 +31,10 @@ Stencil vaticana_brew_cauda (Grob *me, - int pos, - int delta_pitch, - Real thickness, - Real blotdiameter) + int pos, + int delta_pitch, + Real thickness, + Real blotdiameter) { bool on_staffline = Staff_symbol_referencer::on_line (me, pos); int interspaces = Staff_symbol_referencer::line_count (me) - 1; @@ -49,25 +49,25 @@ vaticana_brew_cauda (Grob *me, if (on_staffline) { if (delta_pitch >= -1) - length = 1.30; + length = 1.30; else if (delta_pitch >= -2) - length = 1.35; + length = 1.35; else - length = 1.85; + length = 1.85; } else { if (delta_pitch >= -1) - if (above_staff) - length = 1.30; - else - length = 1.00; + if (above_staff) + length = 1.30; + else + length = 1.00; else if (delta_pitch >= -2) - length = 1.35; + length = 1.35; else if (delta_pitch >= -3) - length = 1.50; + length = 1.50; else - length = 1.85; + length = 1.85; } Box cauda_box (Interval (0, thickness), Interval (-length, 0)); return Lookup::round_filled_box (cauda_box, blotdiameter); @@ -78,8 +78,8 @@ vaticana_brew_cauda (Grob *me, */ Stencil vaticana_brew_flexa (Grob *me, - bool solid, - Real line_thickness) + bool solid, + Real line_thickness) { Real staff_space = Staff_symbol_referencer::staff_space (me); Stencil stencil; @@ -92,7 +92,7 @@ vaticana_brew_flexa (Grob *me, else { me->warning ("Vaticana_ligature: " - + _ ("flexa-height undefined; assuming 0")); + + _ ("flexa-height undefined; assuming 0")); interval = 0.0; } @@ -107,7 +107,7 @@ vaticana_brew_flexa (Grob *me, */ Real left_height = right_height - + min (0.12 * abs (interval), 0.3) * staff_space; + + min (0.12 * abs (interval), 0.3) * staff_space; /* * Compensate optical illusion regarding vertical position of left @@ -137,7 +137,7 @@ vaticana_brew_flexa (Grob *me, if (solid) { Stencil solid_head - = Lookup::bezier_sandwich (top_curve, bottom_curve, 0.0); + = Lookup::bezier_sandwich (top_curve, bottom_curve, 0.0); stencil.add_stencil (solid_head); } else // outline @@ -145,13 +145,13 @@ vaticana_brew_flexa (Grob *me, Bezier inner_top_curve = top_curve; inner_top_curve.translate (Offset (0.0, -line_thickness)); Stencil top_edge - = Lookup::bezier_sandwich (top_curve, inner_top_curve, 0.0); + = Lookup::bezier_sandwich (top_curve, inner_top_curve, 0.0); stencil.add_stencil (top_edge); Bezier inner_bottom_curve = bottom_curve; inner_bottom_curve.translate (Offset (0.0, +line_thickness)); Stencil bottom_edge - = Lookup::bezier_sandwich (bottom_curve, inner_bottom_curve, 0.0); + = Lookup::bezier_sandwich (bottom_curve, inner_bottom_curve, 0.0); stencil.add_stencil (bottom_edge); /* @@ -163,12 +163,12 @@ vaticana_brew_flexa (Grob *me, * the left end of the bezier curve. */ Box left_edge_box (Interval (0, line_thickness), - Interval (-0.5 * left_height, +0.5 * left_height)); + Interval (-0.5 * left_height, +0.5 * left_height)); Stencil left_edge = Lookup::filled_box (left_edge_box); stencil.add_stencil (left_edge); Box right_edge_box (Interval (-line_thickness, 0), - Interval (-0.5 * right_height, +0.5 * right_height)); + Interval (-0.5 * right_height, +0.5 * right_height)); Stencil right_edge = Lookup::filled_box (right_edge_box); right_edge.translate_axis (width, X_AXIS); right_edge.translate_axis (corrected_interval / 2.0, Y_AXIS); @@ -180,19 +180,19 @@ vaticana_brew_flexa (Grob *me, Stencil vaticana_brew_join (Grob *me, int delta_pitch, - Real join_thickness, Real blotdiameter) + Real join_thickness, Real blotdiameter) { Real staff_space = Staff_symbol_referencer::staff_space (me); if (!delta_pitch) { me->programming_error (_ ("Vaticana_ligature: " - "zero join (delta_pitch == 0)")); + "zero join (delta_pitch == 0)")); return Lookup::blank (Box (Interval (0, 0), Interval (0, 0))); } Interval x_extent = Interval (0, join_thickness); Interval y_extent = (delta_pitch > 0) - ? Interval (0, delta_pitch * 0.5 * staff_space) : // ascending join - Interval (delta_pitch * 0.5 * staff_space, 0); // descending join + ? Interval (0, delta_pitch * 0.5 * staff_space) : // ascending join + Interval (delta_pitch * 0.5 * staff_space, 0); // descending join Box join_box (x_extent, y_extent); return Lookup::round_filled_box (join_box, blotdiameter); } @@ -204,7 +204,7 @@ vaticana_brew_primitive (Grob *me) if (glyph_name_scm == SCM_EOL) { me->programming_error ("Vaticana_ligature: " - "undefined glyph-name -> ignoring grob"); + "undefined glyph-name -> ignoring grob"); return Lookup::blank (Box (Interval (0, 0), Interval (0, 0))); } @@ -246,15 +246,15 @@ vaticana_brew_primitive (Grob *me) Real staff_space = Staff_symbol_referencer::staff_space (me); Real flexa_width = robust_scm2double (me->get_property ("flexa-width"), 2) * staff_space; out - = Lookup::blank (Box (Interval (0, 0.5 * flexa_width), Interval (0, 0))); + = Lookup::blank (Box (Interval (0, 0.5 * flexa_width), Interval (0, 0))); } else if (glyph_name == "flexa") out = vaticana_brew_flexa (me, true, line_thickness); else { out - = Font_interface::get_default_font (me)-> - find_by_name ("noteheads.s" + glyph_name); + = Font_interface::get_default_font (me)-> + find_by_name ("noteheads.s" + glyph_name); } out.translate_axis (x_offset, X_AXIS); Real head_width = out.extent (X_AXIS).length (); @@ -262,16 +262,16 @@ vaticana_brew_primitive (Grob *me) if (add_cauda) { Stencil cauda - = vaticana_brew_cauda (me, pos, delta_pitch, - line_thickness, blotdiameter); + = vaticana_brew_cauda (me, pos, delta_pitch, + line_thickness, blotdiameter); out.add_stencil (cauda); } if (add_stem) { Stencil stem - = vaticana_brew_cauda (me, pos, -1, - line_thickness, blotdiameter); + = vaticana_brew_cauda (me, pos, -1, + line_thickness, blotdiameter); stem.translate_axis (head_width - line_thickness, X_AXIS); out.add_stencil (stem); } @@ -279,7 +279,7 @@ vaticana_brew_primitive (Grob *me) if (add_join) { Stencil join - = vaticana_brew_join (me, delta_pitch, line_thickness, blotdiameter); + = vaticana_brew_join (me, delta_pitch, line_thickness, blotdiameter); join.translate_axis (head_width - line_thickness, X_AXIS); out.add_stencil (join); } @@ -304,16 +304,16 @@ Vaticana_ligature::print (SCM) } ADD_INTERFACE (Vaticana_ligature, - "A vaticana style Gregorian ligature.", - - /* properties */ - "glyph-name " - "flexa-height " - "flexa-width " - "thickness " - "add-cauda " - "add-stem " - "add-join " - "delta-position " - "x-offset " - ); + "A vaticana style Gregorian ligature.", + + /* properties */ + "glyph-name " + "flexa-height " + "flexa-width " + "thickness " + "add-cauda " + "add-stem " + "add-join " + "delta-position " + "x-offset " + ); diff --git a/lily/vertical-align-engraver.cc b/lily/vertical-align-engraver.cc index 570340f8d9..d7184e37fd 100644 --- a/lily/vertical-align-engraver.cc +++ b/lily/vertical-align-engraver.cc @@ -50,20 +50,20 @@ protected: ADD_ACKNOWLEDGER (Vertical_align_engraver, axis_group); ADD_TRANSLATOR (Vertical_align_engraver, - /* doc */ - "Catch groups (staves, lyrics lines, etc.) and stack them" - " vertically.", + /* doc */ + "Catch groups (staves, lyrics lines, etc.) and stack them" + " vertically.", - /* create */ - "VerticalAlignment ", + /* create */ + "VerticalAlignment ", - /* read */ - "alignAboveContext " - "alignBelowContext ", + /* read */ + "alignAboveContext " + "alignBelowContext ", - /* write */ - "" - ); + /* write */ + "" + ); Vertical_align_engraver::Vertical_align_engraver () { @@ -113,9 +113,9 @@ Vertical_align_engraver::qualifies (Grob_info i) const int sz = i.origin_contexts ((Translator *)this).size (); return sz > 0 && Axis_group_interface::has_interface (i.grob ()) - && !i.grob ()->get_parent (Y_AXIS) - && !to_boolean (i.grob ()->get_property ("no-alignment")) - && Axis_group_interface::has_axis (i.grob (), Y_AXIS); + && !i.grob ()->get_parent (Y_AXIS) + && !to_boolean (i.grob ()->get_property ("no-alignment")) + && Axis_group_interface::has_axis (i.grob (), Y_AXIS); } void @@ -126,7 +126,7 @@ Vertical_align_engraver::acknowledge_axis_group (Grob_info i) string id = i.context ()->id_string (); scm_hash_set_x (id_to_group_hashtab_, ly_string2scm (id), - i.grob ()->self_scm ()); + i.grob ()->self_scm ()); SCM before_id = i.context ()->get_property ("alignAboveContext"); SCM after_id = i.context ()->get_property ("alignBelowContext"); @@ -138,40 +138,40 @@ Vertical_align_engraver::acknowledge_axis_group (Grob_info i) Grob *after_grob = unsmob_grob (after); Align_interface::add_element (valign_, i.grob ()); - + if (before_grob || after_grob) - { - Grob_array *ga = unsmob_grob_array (valign_->get_object ("elements")); - vector<Grob*> &arr = ga->array_reference (); - - Grob *added = arr.back (); - arr.pop_back (); - for (vsize i = 0; i < arr.size (); i++) - { - if (arr[i] == before_grob) - { - arr.insert (arr.begin () + i, added); - - /* Only set staff affinity if it already has one. That way we won't - set staff-affinity on things that don't want it (like staves). */ - if (scm_is_number (added->get_property ("staff-affinity"))) - added->set_property ("staff-affinity", scm_from_int (DOWN)); - break; - } - else if (arr[i] == after_grob) - { - arr.insert (arr.begin () + i + 1, added); - if (scm_is_number (added->get_property ("staff-affinity"))) - added->set_property ("staff-affinity", scm_from_int (UP)); - break; - } - } - } + { + Grob_array *ga = unsmob_grob_array (valign_->get_object ("elements")); + vector<Grob *> &arr = ga->array_reference (); + + Grob *added = arr.back (); + arr.pop_back (); + for (vsize i = 0; i < arr.size (); i++) + { + if (arr[i] == before_grob) + { + arr.insert (arr.begin () + i, added); + + /* Only set staff affinity if it already has one. That way we won't + set staff-affinity on things that don't want it (like staves). */ + if (scm_is_number (added->get_property ("staff-affinity"))) + added->set_property ("staff-affinity", scm_from_int (DOWN)); + break; + } + else if (arr[i] == after_grob) + { + arr.insert (arr.begin () + i + 1, added); + if (scm_is_number (added->get_property ("staff-affinity"))) + added->set_property ("staff-affinity", scm_from_int (UP)); + break; + } + } + } } else if (qualifies (i)) { Pointer_group_interface::add_grob (valign_, ly_symbol2scm ("elements"), i.grob ()); if (!unsmob_grob (i.grob ()->get_object ("staff-grouper"))) - i.grob ()->set_object ("staff-grouper", valign_->self_scm ()); + i.grob ()->set_object ("staff-grouper", valign_->self_scm ()); } } diff --git a/lily/volta-bracket.cc b/lily/volta-bracket.cc index 6877a1a2eb..8a42dde469 100644 --- a/lily/volta-bracket.cc +++ b/lily/volta-bracket.cc @@ -49,8 +49,8 @@ Volta_bracket_interface::print (SCM smob) Spanner *me = unsmob_spanner (smob); Spanner *orig_span = dynamic_cast<Spanner *> (me->original ()); bool broken_first_bracket = orig_span && (orig_span->broken_intos_[0] - == (Spanner *)me); - + == (Spanner *)me); + Output_def *layout = me->layout (); Real half_space = 0.5; @@ -65,67 +65,64 @@ Volta_bracket_interface::print (SCM smob) { Paper_column *pc = bound->get_column (); left = pc->break_align_width (pc, ly_symbol2scm ("break-alignment"))[RIGHT] - // For some reason, break_align_width is relative to - // the x-parent of the column. - - bound->relative_coordinate (pc->get_parent (X_AXIS), X_AXIS); + // For some reason, break_align_width is relative to + // the x-parent of the column. + - bound->relative_coordinate (pc->get_parent (X_AXIS), X_AXIS); } else { /* - the volta spanner is attached to the bar-line, which is moved - to the right. We don't need to compensate for the left edge. + the volta spanner is attached to the bar-line, which is moved + to the right. We don't need to compensate for the left edge. */ } modify_edge_height (me); if (!me->is_live ()) return SCM_EOL; - + Drul_array<Real> edge_height = robust_scm2interval (me->get_property ("edge-height"), - Interval (1.0, 1.0)); + Interval (1.0, 1.0)); Drul_array<Real> flare = robust_scm2interval (me->get_property ("bracket-flare"), - Interval (0, 0)); + Interval (0, 0)); Drul_array<Real> shorten = robust_scm2interval (me->get_property ("shorten-pair"), - Interval (0, 0)); + Interval (0, 0)); - - scale_drul (&edge_height, - Real (get_grob_direction (me))); Interval empty; Offset start; start[X_AXIS] = me->spanner_length () - left - half_space; - + /* - ugh, Tuplet_bracket should use Horizontal_bracket, not the other way around. + ugh, Tuplet_bracket should use Horizontal_bracket, not the other way around. */ Stencil total - = Tuplet_bracket::make_bracket (me, Y_AXIS, start, - edge_height, empty, flare, shorten); + = Tuplet_bracket::make_bracket (me, Y_AXIS, start, + edge_height, empty, flare, shorten); if (!orig_span || broken_first_bracket) { SCM text = me->get_property ("text"); SCM properties = me->get_property_alist_chain (SCM_EOL); SCM snum = Text_interface::interpret_markup (layout->self_scm (), - properties, text); + properties, text); Stencil num = *unsmob_stencil (snum); num.align_to (Y_AXIS, UP); num.translate_axis (-0.5, Y_AXIS); total.add_at_edge (X_AXIS, LEFT, num, - num.extent (X_AXIS).length () - - 1.0); + - 1.0); } - + total.translate_axis (left, X_AXIS); return total.smobbed_copy (); } - void Volta_bracket_interface::modify_edge_height (Spanner *me) { Spanner *orig_span = dynamic_cast<Spanner *> (me->original ()); - + bool broken_first_bracket = orig_span && (orig_span->broken_intos_[0] == (Spanner *)me); bool broken_last_bracket = orig_span && (orig_span->broken_intos_.back () == (Spanner *)me); bool no_vertical_start = orig_span && !broken_first_bracket; @@ -142,23 +139,23 @@ Volta_bracket_interface::modify_edge_height (Spanner *me) str = "|"; no_vertical_end - |= (str != ":|" - && str != "|:" - && str != "|." - && str != ":|:" - && str != ":|.|:" - && str != ":|.:" - && str != ".|"); + |= (str != ":|" + && str != "|:" + && str != "|." + && str != ":|:" + && str != ":|.|:" + && str != ":|.:" + && str != ".|"); if (no_vertical_end || no_vertical_start) { Drul_array<Real> edge_height = robust_scm2interval (me->get_property ("edge-height"), - Interval (1.0, 1.0)); + Interval (1.0, 1.0)); if (no_vertical_start) - edge_height[LEFT] = 0.0; + edge_height[LEFT] = 0.0; if (no_vertical_end) - edge_height[RIGHT] = 0.0; + edge_height[RIGHT] = 0.0; me->set_property ("edge-height", ly_interval2scm (edge_height)); } @@ -176,11 +173,11 @@ Volta_bracket_interface::add_bar (Grob *me, Item *b) } ADD_INTERFACE (Volta_bracket_interface, - "Volta bracket with number.", + "Volta bracket with number.", - /* properties */ - "bars " - "thickness " - "height " - ); + /* properties */ + "bars " + "thickness " + "height " + ); diff --git a/lily/volta-engraver.cc b/lily/volta-engraver.cc index eec8fa46ff..d632ae724f 100644 --- a/lily/volta-engraver.cc +++ b/lily/volta-engraver.cc @@ -83,14 +83,14 @@ Volta_engraver::process_music () SCM c = scm_car (cs); if (scm_is_pair (c) - && scm_car (c) == ly_symbol2scm ("volta") - && scm_is_pair (scm_cdr (c))) - { - if (scm_cadr (c) == SCM_BOOL_F) - end = true; - else - start_string_ = scm_cadr (c); - } + && scm_car (c) == ly_symbol2scm ("volta") + && scm_is_pair (scm_cdr (c))) + { + if (scm_cadr (c) == SCM_BOOL_F) + end = true; + else + start_string_ = scm_cadr (c); + } cs = scm_cdr (cs); } @@ -101,7 +101,7 @@ Volta_engraver::process_music () Moment now = now_mom (); bool early_stop = unsmob_moment (l) - && *unsmob_moment (l) <= now - started_mom_; + && *unsmob_moment (l) <= now - started_mom_; end = end || early_stop; } @@ -121,11 +121,11 @@ Volta_engraver::process_music () warning (_ ("already have a volta spanner, ending that one prematurely")); if (end_volta_bracket_) - { - warning (_ ("also already have an ended spanner")); - warning (_ ("giving up")); - return; - } + { + warning (_ ("also already have an ended spanner")); + warning (_ ("giving up")); + return; + } end_volta_bracket_ = volta_bracket_; volta_bracket_ = 0; @@ -141,7 +141,7 @@ Volta_engraver::process_music () volta_bracket_->set_property ("text", start_string_); if (!volta_spanner_) - volta_spanner_ = make_spanner ("VoltaBracketSpanner", SCM_EOL); + volta_spanner_ = make_spanner ("VoltaBracketSpanner", SCM_EOL); Axis_group_interface::add_element (volta_spanner_, volta_bracket_); } @@ -174,7 +174,7 @@ Volta_engraver::stop_translation_timestep () if (end_volta_bracket_ && !volta_bracket_) { for (SCM s = get_property ("stavesFound"); scm_is_pair (s); s = scm_cdr (s)) - Side_position_interface::add_support (volta_spanner_, unsmob_grob (scm_car (s))); + Side_position_interface::add_support (volta_spanner_, unsmob_grob (scm_car (s))); volta_spanner_ = 0; } @@ -192,18 +192,18 @@ Volta_engraver::stop_translation_timestep () */ ADD_ACKNOWLEDGER (Volta_engraver, bar_line); ADD_TRANSLATOR (Volta_engraver, - /* doc */ - "Make volta brackets.", + /* doc */ + "Make volta brackets.", - /* create */ - "VoltaBracket " - "VoltaBracketSpanner ", + /* create */ + "VoltaBracket " + "VoltaBracketSpanner ", - /* read */ - "repeatCommands " - "voltaSpannerDuration " - "stavesFound ", + /* read */ + "repeatCommands " + "voltaSpannerDuration " + "stavesFound ", - /* write */ - "" - ); + /* write */ + "" + ); diff --git a/lily/volta-repeat-iterator.cc b/lily/volta-repeat-iterator.cc index b7ac2059f1..91bf94e42a 100644 --- a/lily/volta-repeat-iterator.cc +++ b/lily/volta-repeat-iterator.cc @@ -50,7 +50,7 @@ SCM Volta_repeat_iterator::get_music_list ()const { return scm_cons (get_music ()->get_property ("element"), - get_music ()->get_property ("elements")); + get_music ()->get_property ("elements")); } void @@ -76,7 +76,7 @@ Volta_repeat_iterator::add_repeat_command (SCM what) Context *where = get_outlet ()->where_defined (reps, ¤t_reps); if (where - && (current_reps == SCM_EOL || scm_is_pair (current_reps))) + && (current_reps == SCM_EOL || scm_is_pair (current_reps))) { current_reps = scm_cons (what, current_reps); where->set_property (reps, current_reps); @@ -93,25 +93,25 @@ Volta_repeat_iterator::next_element (bool side_effect) if (side_effect) { if (alt_count_) - { - string repstr = to_string (rep_count_ - alt_count_ + done_count_) + "."; - if (done_count_ > 1) - { - add_repeat_command (scm_list_n (ly_symbol2scm ("volta"), SCM_BOOL_F, SCM_UNDEFINED)); - - if (done_count_ - 1 < alt_count_) - add_repeat_command (ly_symbol2scm ("end-repeat")); - } - - if (done_count_ == 1 && alt_count_ < rep_count_) - repstr = "1.--" + to_string (rep_count_ - alt_count_ + done_count_) + "."; - - if (done_count_ <= alt_count_) - add_repeat_command (scm_list_n (ly_symbol2scm ("volta"), - ly_string2scm (repstr), SCM_UNDEFINED)); - } + { + string repstr = to_string (rep_count_ - alt_count_ + done_count_) + "."; + if (done_count_ > 1) + { + add_repeat_command (scm_list_n (ly_symbol2scm ("volta"), SCM_BOOL_F, SCM_UNDEFINED)); + + if (done_count_ - 1 < alt_count_) + add_repeat_command (ly_symbol2scm ("end-repeat")); + } + + if (done_count_ == 1 && alt_count_ < rep_count_) + repstr = "1.--" + to_string (rep_count_ - alt_count_ + done_count_) + "."; + + if (done_count_ <= alt_count_) + add_repeat_command (scm_list_n (ly_symbol2scm ("volta"), + ly_string2scm (repstr), SCM_UNDEFINED)); + } else - add_repeat_command (ly_symbol2scm ("end-repeat")); + add_repeat_command (ly_symbol2scm ("end-repeat")); } } |