X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Farpeggio.cc;h=3f0d32fe81149baf362cf25e2ebc6126a9f4d1a5;hb=50ba2171c6a88789ef5ed3673a4c6a4549400113;hp=3cdfe4c06ab5c88ef5995897fc904165701bb4b5;hpb=97b34b56e2cf3f8465f651717b5e0f6ea10d7543;p=lilypond.git diff --git a/lily/arpeggio.cc b/lily/arpeggio.cc index 3cdfe4c06a..3f0d32fe81 100644 --- a/lily/arpeggio.cc +++ b/lily/arpeggio.cc @@ -1,7 +1,7 @@ /* This file is part of LilyPond, the GNU music typesetter. - Copyright (C) 2000--2011 Jan Nieuwenhuizen + Copyright (C) 2000--2015 Jan Nieuwenhuizen LilyPond is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,10 +19,10 @@ #include "arpeggio.hh" -#include "all-font-metrics.hh" #include "bezier.hh" #include "font-interface.hh" #include "grob.hh" +#include "international.hh" #include "lookup.hh" #include "output-def.hh" #include "pointer-group-interface.hh" @@ -56,11 +56,34 @@ Arpeggio::get_common_y (Grob *me) return common; } +MAKE_SCHEME_CALLBACK (Arpeggio, calc_cross_staff, 1); +SCM +Arpeggio::calc_cross_staff (SCM grob) +{ + Grob *me = unsmob (grob); + + extract_grob_set (me, "stems", stems); + Grob *vag = 0; + + for (vsize i = 0; i < stems.size (); i++) + { + if (!i) + vag = Grob::get_vertical_axis_group (stems[i]); + else + { + if (vag != Grob::get_vertical_axis_group (stems[i])) + return SCM_BOOL_T; + } + } + + return SCM_BOOL_F; +} + MAKE_SCHEME_CALLBACK (Arpeggio, calc_positions, 1); SCM Arpeggio::calc_positions (SCM grob) { - Grob *me = unsmob_grob (grob); + Grob *me = unsmob (grob); Grob *common = get_common_y (me); /* @@ -93,7 +116,7 @@ MAKE_SCHEME_CALLBACK (Arpeggio, print, 1); SCM Arpeggio::print (SCM smob) { - Grob *me = unsmob_grob (smob); + Grob *me = unsmob (smob); Interval heads = robust_scm2interval (me->get_property ("positions"), Interval ()) * Staff_symbol_referencer::staff_space (me); @@ -112,7 +135,7 @@ Arpeggio::print (SCM smob) } else { - me->warning ("no heads for arpeggio found?"); + me->warning (_ ("no heads for arpeggio found?")); me->suicide (); return SCM_EOL; } @@ -140,7 +163,7 @@ Arpeggio::print (SCM smob) if (dir) { Font_metric *fm = Font_interface::get_default_font (me); - arrow = fm->find_by_name ("scripts.arpeggio.arrow." + to_string (dir)); + arrow = fm->find_by_name ("scripts.arpeggio.arrow." + ::to_string (dir)); heads[dir] -= dir * arrow.extent (Y_AXIS).length (); } @@ -161,79 +184,47 @@ MAKE_SCHEME_CALLBACK (Arpeggio, brew_chord_bracket, 1); SCM Arpeggio::brew_chord_bracket (SCM smob) { - Grob *me = unsmob_grob (smob); + Grob *me = unsmob (smob); Interval heads = robust_scm2interval (me->get_property ("positions"), Interval ()) * Staff_symbol_referencer::staff_space (me); - Real lt = me->layout ()->get_dimension (ly_symbol2scm ("line-thickness")); + Real th + = me->layout ()->get_dimension (ly_symbol2scm ("line-thickness")) + * robust_scm2double (me->get_property ("thickness"), 1); Real sp = 1.5 * Staff_symbol_referencer::staff_space (me); Real dy = heads.length () + sp; - Real x = 0.7; + Real x = robust_scm2double (me->get_property ("protrusion"), 0.4); - Stencil mol (Lookup::bracket (Y_AXIS, Interval (0, dy), lt, x, lt)); + Stencil mol (Lookup::bracket (Y_AXIS, Interval (0, dy), th, x, th)); mol.translate_axis (heads[LEFT] - sp / 2.0, Y_AXIS); return mol.smobbed_copy (); } -MAKE_SCHEME_CALLBACK (Arpeggio, brew_chord_brace, 1); -SCM -Arpeggio::brew_chord_brace (SCM smob) -{ - Grob *me = unsmob_grob (smob); - Interval heads = robust_scm2interval (me->get_property ("positions"), - Interval ()) - * Staff_symbol_referencer::staff_space (me); - int minimum_brace_height = robust_scm2int ( - me->get_property ("minimum-brace-height"), 1); - Font_metric *fm = Font_interface::get_default_font (me); - - int - lo = 0; - int hi = max ((int) fm->count () - 1, 2); - - /* do a binary search for each Y, not very efficient, but passable? */ - Box b; - do - { - int cmp = (lo + hi) / 2; - b = fm->get_indexed_char_dimensions (cmp); - if (b[Y_AXIS].is_empty () || b[Y_AXIS].length () > heads.length ()+1) - hi = cmp; - else - lo = cmp; - } - while (hi - lo > 1); - - if (lo < minimum_brace_height) - lo = minimum_brace_height; - - Stencil mol (unsmob_metrics (me->get_property ("font")) - ->find_by_name ("brace" + to_string (lo))); - mol.translate_axis ((heads[RIGHT] + heads[LEFT]) / 2, Y_AXIS); - - return mol.smobbed_copy (); -} - MAKE_SCHEME_CALLBACK (Arpeggio, brew_chord_slur, 1); SCM Arpeggio::brew_chord_slur (SCM smob) { - Grob *me = unsmob_grob (smob); + Grob *me = unsmob (smob); SCM dash_definition = me->get_property ("dash-definition"); Interval heads = robust_scm2interval (me->get_property ("positions"), Interval ()) * Staff_symbol_referencer::staff_space (me); - Real lt = me->layout ()->get_dimension (ly_symbol2scm ("line-thickness")); + Real lt + = me->layout ()->get_dimension (ly_symbol2scm ("line-thickness")) + * robust_scm2double (me->get_property ("line-thickness"), 1.0); + Real th + = me->layout ()->get_dimension (ly_symbol2scm ("line-thickness")) + * robust_scm2double (me->get_property ("thickness"), 1.0); Real dy = heads.length (); Real height_limit = 1.5; Real ratio = .33; Bezier curve = slur_shape (dy, height_limit, ratio); - curve.rotate (M_PI / 2); + curve.rotate (90.0); - Stencil mol (Lookup::slur (curve, lt, lt, dash_definition)); + Stencil mol (Lookup::slur (curve, th, lt, dash_definition)); mol.translate_axis (heads[LEFT], Y_AXIS); return mol.smobbed_copy (); } @@ -246,7 +237,7 @@ MAKE_SCHEME_CALLBACK (Arpeggio, width, 1); SCM Arpeggio::width (SCM smob) { - Grob *me = unsmob_grob (smob); + Grob *me = unsmob (smob); return ly_interval2scm (get_squiggle (me).extent (X_AXIS)); } @@ -254,7 +245,7 @@ MAKE_SCHEME_CALLBACK (Arpeggio, pure_height, 3); SCM Arpeggio::pure_height (SCM smob, SCM, SCM) { - Grob *me = unsmob_grob (smob); + Grob *me = unsmob (smob); if (to_boolean (me->get_property ("cross-staff"))) return ly_interval2scm (Interval ()); @@ -266,10 +257,12 @@ ADD_INTERFACE (Arpeggio, /* properties */ "arpeggio-direction " - "minimum-brace-height " + "dash-definition " // TODO: make apply to non-slur arpeggios + "line-thickness " "positions " + "protrusion " "script-priority " // TODO: make around-note-interface "stems " - "dash-definition " // TODO: make apply to non-slur arpeggios + "thickness " );