X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fledger-line-spanner.cc;h=b0e8fee3c2321b8e7f078a7946048714deca168a;hb=831d149c5240b038667d4973660a63a474605aae;hp=83304acff7a4b39cd2a814827f4bf5b24d9da083;hpb=d61cf3bbdb1c6670a127ba3baddf2f04d3e34fd3;p=lilypond.git diff --git a/lily/ledger-line-spanner.cc b/lily/ledger-line-spanner.cc index 83304acff7..b0e8fee3c2 100644 --- a/lily/ledger-line-spanner.cc +++ b/lily/ledger-line-spanner.cc @@ -1,7 +1,7 @@ /* This file is part of LilyPond, the GNU music typesetter. - Copyright (C) 2004--2012 Han-Wen Nienhuys + Copyright (C) 2004--2015 Han-Wen Nienhuys LilyPond is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -32,7 +32,6 @@ struct Ledger_line_spanner { DECLARE_SCHEME_CALLBACK (print, (SCM)); DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM)); - DECLARE_GROB_INTERFACE (); }; static void @@ -40,20 +39,15 @@ set_rods (Drul_array const ¤t_extents, Drul_array const &previous_extents, Item *current_column, Item *previous_column, - Real min_length_fraction) + Real min_length) { - Direction d = UP; - do + for (UP_and_DOWN (d)) { 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) + rod.distance_ = 2 * min_length /* we go from right to left. */ @@ -65,14 +59,13 @@ set_rods (Drul_array const ¤t_extents, rod.add_to_cols (); } } - while (flip (&d) != DOWN); } MAKE_SCHEME_CALLBACK (Ledger_line_spanner, set_spacing_rods, 1); SCM Ledger_line_spanner::set_spacing_rods (SCM smob) { - Spanner *me = dynamic_cast (unsmob_grob (smob)); + Spanner *me = unsmob (smob); // find size of note heads. Grob *staff = Staff_symbol_referencer::get_staff_symbol (me); @@ -87,6 +80,7 @@ Ledger_line_spanner::set_spacing_rods (SCM smob) Drul_array current_extents; Drul_array previous_extents; + Real current_head_width = 0.0; Item *previous_column = 0; Item *current_column = 0; @@ -105,7 +99,12 @@ Ledger_line_spanner::set_spacing_rods (SCM smob) Item *h = heads[i]; int pos = Staff_symbol_referencer::get_rounded_position (h); - if (staff_extent.contains (pos)) + if (Staff_symbol::ledger_positions (staff, pos).empty ()) + continue; + + /* Ambitus heads can appear out-of-order in heads[], + * but as part of prefatory matter, they need no rods */ + if (h->internal_has_interface (ly_symbol2scm ("ambitus-interface"))) continue; Item *column = h->get_column (); @@ -113,7 +112,7 @@ Ledger_line_spanner::set_spacing_rods (SCM smob) { set_rods (current_extents, previous_extents, current_column, previous_column, - min_length_fraction); + current_head_width * min_length_fraction); previous_column = current_column; current_column = column; @@ -121,6 +120,7 @@ Ledger_line_spanner::set_spacing_rods (SCM smob) current_extents[DOWN].set_empty (); current_extents[UP].set_empty (); + current_head_width = 0.0; } Interval head_extent = h->extent (column, X_AXIS); @@ -129,12 +129,13 @@ Ledger_line_spanner::set_spacing_rods (SCM smob) continue; current_extents[vdir].unite (head_extent); + current_head_width = max (current_head_width, head_extent.length ()); } if (previous_column && current_column) set_rods (current_extents, previous_extents, current_column, previous_column, - min_length_fraction); + current_head_width * min_length_fraction); return SCM_UNSPECIFIED; } @@ -144,7 +145,6 @@ struct Ledger_request Interval ledger_extent_; Interval head_extent_; int position_; - bool excentric_; Ledger_request () { ledger_extent_.set_empty (); @@ -163,7 +163,7 @@ MAKE_SCHEME_CALLBACK (Ledger_line_spanner, print, 1); SCM Ledger_line_spanner::print (SCM smob) { - Spanner *me = dynamic_cast (unsmob_grob (smob)); + Spanner *me = unsmob (smob); extract_grob_set (me, "note-heads", heads); @@ -192,7 +192,7 @@ 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"))) + if (Grob *g = unsmob (me->get_object ("accidental-grob"))) common[a] = common[a]->common_refpoint (g, a); } @@ -227,8 +227,7 @@ Ledger_line_spanner::print (SCM smob) if (last == reqs.end ()) continue; - Direction d = DOWN; - do + for (DOWN_and_UP (d)) { if (!staff_extent.contains (last->second[d].position_) && !staff_extent.contains (i->second[d].position_)) @@ -237,8 +236,7 @@ Ledger_line_spanner::print (SCM smob) = (last->second[d].head_extent_[RIGHT] + i->second[d].head_extent_[LEFT]) / 2; - Direction which = LEFT; - do + for (LEFT_and_RIGHT (which)) { Ledger_request &lr = ((which == LEFT) ? * last : *i).second[d]; @@ -253,10 +251,8 @@ Ledger_line_spanner::print (SCM smob) lr.ledger_extent_.at (-which) = which * max (which * lr.ledger_extent_[-which], which * limit); } - while (flip (&which) != LEFT); } } - while (flip (&d) != DOWN); } // create ledgers for note heads @@ -290,7 +286,7 @@ Ledger_line_spanner::print (SCM smob) Interval x_extent = ledger_size; if (i == 0) - if (Grob *g = unsmob_grob (h->get_object ("accidental-grob"))) + if (Grob *g = unsmob (h->get_object ("accidental-grob"))) { Interval accidental_size = g->extent (common[X_AXIS], X_AXIS); Real d @@ -329,19 +325,19 @@ Ledger_line_spanner::print (SCM smob) 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.", + " collisions between all note heads. The thickness of ledger" + " lines is controlled by the @code{ledger-line-thickness}" + " property of the @ref{StaffSymbol} grob.", /* properties */ "gap " "length-fraction " "minimum-length-fraction " "note-heads " - "thickness " ); struct Ledgered_interface { - DECLARE_GROB_INTERFACE (); }; ADD_INTERFACE (Ledgered_interface,