X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fvaticana-ligature.cc;h=b10d197230f703640e1f12f3da852d207c6a8bb4;hb=b782f68f927fa02b3ea895dd1bd801082e5bda6e;hp=e97a7f0f083695eb0831f83dcd11d6fae7e45e6f;hpb=48189914f51eb9c2f1c14931c72d267a25d5f812;p=lilypond.git diff --git a/lily/vaticana-ligature.cc b/lily/vaticana-ligature.cc index e97a7f0f08..b10d197230 100644 --- a/lily/vaticana-ligature.cc +++ b/lily/vaticana-ligature.cc @@ -3,22 +3,23 @@ source file of the GNU LilyPond music typesetter - (c) 2003 Juergen Reuter + (c) 2003--2004 Juergen Reuter */ +#include "vaticana-ligature.hh" + #include + #include "item.hh" -#include "vaticana-ligature.hh" #include "font-interface.hh" -#include "molecule.hh" #include "lookup.hh" #include "staff-symbol-referencer.hh" #include "note-head.hh" -#include "paper-def.hh" +#include "output-def.hh" #include "bezier.hh" #include "warn.hh" -Molecule +Stencil vaticana_brew_cauda (Grob *me, int pos, int delta_pitch, @@ -65,20 +66,20 @@ vaticana_brew_cauda (Grob *me, /* * TODO: move this function to class Lookup? */ -Molecule +Stencil vaticana_brew_flexa (Grob *me, bool solid, Real line_thickness) { Real staff_space = Staff_symbol_referencer::staff_space (me); - Molecule molecule = Molecule (); + Stencil stencil; Real right_height = 0.6 * staff_space; Real interval; - SCM flexa_height_scm = me->get_grob_property ("flexa-height"); + SCM flexa_height_scm = me->get_property ("flexa-height"); if (flexa_height_scm != SCM_EOL) { - interval = gh_scm2int (flexa_height_scm); + interval = scm_to_int (flexa_height_scm); } else { @@ -92,18 +93,7 @@ vaticana_brew_flexa (Grob *me, me->warning (_ ("ascending vaticana style flexa")); } - Real width; - SCM flexa_width_scm = me->get_grob_property ("flexa-width"); - if (flexa_width_scm != SCM_EOL) - { - width = gh_scm2double (flexa_width_scm); - } - else - { - me->warning ("Vaticana_ligature: " - "flexa-width undefined; assuming 2.0"); - width = 2.0 * staff_space; - } + Real width = robust_scm2double ( me->get_property ("flexa-width"), 2); /* * Compensate curve thickness that appears to be smaller in steep @@ -111,14 +101,14 @@ 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 * and right endings due to curved shape. */ - Real ypos_correction = -0.1*staff_space * sign(interval); - Real interval_correction = 0.2*staff_space * sign(interval); + Real ypos_correction = -0.1*staff_space * sign (interval); + Real interval_correction = 0.2*staff_space * sign (interval); Real corrected_interval = interval*staff_space + interval_correction; /* @@ -140,23 +130,23 @@ vaticana_brew_flexa (Grob *me, if (solid) { - Molecule solid_head = + Stencil solid_head = Lookup::bezier_sandwich (top_curve, bottom_curve); - molecule.add_molecule (solid_head); + stencil.add_stencil (solid_head); } else // outline { Bezier inner_top_curve = top_curve; inner_top_curve.translate (Offset (0.0, -line_thickness)); - Molecule top_edge = + Stencil top_edge = Lookup::bezier_sandwich (top_curve, inner_top_curve); - molecule.add_molecule(top_edge); + stencil.add_stencil (top_edge); Bezier inner_bottom_curve = bottom_curve; inner_bottom_curve.translate (Offset (0.0, +line_thickness)); - Molecule bottom_edge = + Stencil bottom_edge = Lookup::bezier_sandwich (bottom_curve, inner_bottom_curve); - molecule.add_molecule(bottom_edge); + stencil.add_stencil (bottom_edge); /* * TODO: Use horizontal slope with proper slope value rather @@ -168,21 +158,21 @@ vaticana_brew_flexa (Grob *me, */ Box left_edge_box (Interval (0, line_thickness), Interval (-0.5*left_height, +0.5*left_height)); - Molecule left_edge = Lookup::filled_box (left_edge_box); - molecule.add_molecule(left_edge); + 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)); - Molecule right_edge = Lookup::filled_box (right_edge_box); + 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); - molecule.add_molecule(right_edge); + stencil.add_stencil (right_edge); } - molecule.translate_axis (ypos_correction, Y_AXIS); - return molecule; + stencil.translate_axis (ypos_correction, Y_AXIS); + return stencil; } -Molecule +Stencil vaticana_brew_join (Grob *me, int delta_pitch, Real join_thickness, Real blotdiameter) { @@ -191,7 +181,7 @@ vaticana_brew_join (Grob *me, int delta_pitch, { me->programming_error (_f ("Vaticana_ligature: " "zero join (delta_pitch == 0)")); - return Molecule (); + return Stencil (); } Interval x_extent = Interval (0, join_thickness); Interval y_extent = (delta_pitch > 0) ? @@ -201,87 +191,42 @@ vaticana_brew_join (Grob *me, int delta_pitch, return Lookup::round_filled_box (join_box, blotdiameter); } -void -vaticana_add_ledger_lines (Grob *me, Molecule *out, int pos, Real offs, - bool ledger_take_space) -{ - int interspaces = Staff_symbol_referencer::line_count (me)-1; - if (abs (pos) - interspaces > 1) - { - Interval hd = out->extent (X_AXIS); - Real left_ledger_protusion = hd.length ()/4; - Real right_ledger_protusion = left_ledger_protusion; - - Interval l_extents = Interval (hd[LEFT] - left_ledger_protusion, - hd[RIGHT] + right_ledger_protusion); - Molecule ledger_lines = - Note_head::brew_ledger_lines (me, pos, interspaces, - l_extents, - ledger_take_space); - ledger_lines.translate_axis (offs, Y_AXIS); - out->add_molecule (ledger_lines); - } -} - -Molecule -vaticana_brew_primitive (Grob *me, bool ledger_take_space) +Stencil +vaticana_brew_primitive (Grob *me) { - SCM glyph_name_scm = me->get_grob_property ("glyph-name"); + SCM glyph_name_scm = me->get_property ("glyph-name"); if (glyph_name_scm == SCM_EOL) { me->programming_error ("Vaticana_ligature: " "undefined glyph-name -> ignoring grob"); - return Molecule (); + return Stencil (); } String glyph_name = ly_scm2string (glyph_name_scm); - Molecule out; - int flexa_height = 0; - Real thickness; - - SCM thickness_scm = me->get_grob_property ("thickness"); - if (thickness_scm != SCM_EOL) - { - thickness = gh_scm2double (thickness_scm); - } - else - { - me->programming_error ("Vaticana_ligature: " - "thickness undefined; assuming 1.0"); - thickness = 1.0; - } + Stencil out; + Real thickness = robust_scm2double ( me->get_property ("thickness"), 1); Real line_thickness = - thickness * me->get_paper ()->get_realvar (ly_symbol2scm ("linethickness")); + thickness * me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness")); Real blotdiameter = - (me->get_paper ()->get_realvar (ly_symbol2scm ("blotdiameter"))); + (me->get_layout ()->get_dimension (ly_symbol2scm ("blotdiameter"))); - int pos = (int)rint (Staff_symbol_referencer::get_position (me)); + int pos = Staff_symbol_referencer::get_rounded_position (me); - SCM delta_pitch_scm = me->get_grob_property ("delta-pitch"); + SCM delta_pitch_scm = me->get_property ("delta-pitch"); int delta_pitch; if (delta_pitch_scm != SCM_EOL) - delta_pitch = gh_scm2int (delta_pitch_scm); + delta_pitch = scm_to_int (delta_pitch_scm); else delta_pitch = 0; - Real x_offset = 0.0; - SCM x_offset_scm = me->get_grob_property ("x-offset"); - if (x_offset_scm != SCM_EOL) - { - x_offset = gh_scm2double (x_offset_scm); - } - else - { - me->programming_error ("Vaticana_ligature: " - "x-offset undefined; assuming 0.0"); - } + Real x_offset = robust_scm2double ( me->get_property ("x-offset"), 0); - bool add_stem = to_boolean (me->get_grob_property ("add-stem")); - bool add_cauda = to_boolean (me->get_grob_property ("add-cauda")); - bool add_join = to_boolean (me->get_grob_property ("add-join")); + bool add_stem = to_boolean (me->get_property ("add-stem")); + bool add_cauda = to_boolean (me->get_property ("add-cauda")); + bool add_join = to_boolean (me->get_property ("add-join")); if (!String::compare (glyph_name, "")) { @@ -293,18 +238,7 @@ vaticana_brew_primitive (Grob *me, bool ledger_take_space) * flexa_width.) */ Real staff_space = Staff_symbol_referencer::staff_space (me); - Real flexa_width; - SCM flexa_width_scm = me->get_grob_property ("flexa-width"); - if (flexa_width_scm != SCM_EOL) - { - flexa_width = gh_scm2double (flexa_width_scm); - } - else - { - me->warning ("Vaticana_ligature: " - "flexa-width undefined; assuming 2.0"); - flexa_width = 2.0 * staff_space; - } + 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))); } @@ -323,35 +257,27 @@ vaticana_brew_primitive (Grob *me, bool ledger_take_space) if (add_cauda) { - Molecule cauda = + Stencil cauda = vaticana_brew_cauda (me, pos, delta_pitch, line_thickness, blotdiameter); - out.add_molecule (cauda); + out.add_stencil (cauda); } if (add_stem) { - Molecule stem = + Stencil stem = vaticana_brew_cauda (me, pos, -1, line_thickness, blotdiameter); stem.translate_axis (head_width - line_thickness, X_AXIS); - out.add_molecule (stem); + out.add_stencil (stem); } if (add_join) { - Molecule join = + Stencil join = vaticana_brew_join (me, delta_pitch, line_thickness, blotdiameter); join.translate_axis (head_width - line_thickness, X_AXIS); - out.add_molecule (join); - } - - vaticana_add_ledger_lines(me, &out, pos, 0, ledger_take_space); - if (!String::compare (glyph_name, "flexa")) - { - pos += flexa_height; - vaticana_add_ledger_lines(me, &out, pos, 0.5*flexa_height, - ledger_take_space); + out.add_stencil (join); } return out; @@ -362,13 +288,13 @@ SCM Vaticana_ligature::brew_ligature_primitive (SCM smob) { Grob *me = unsmob_grob (smob); - SCM primitive = vaticana_brew_primitive (me, false).smobbed_copy (); + SCM primitive = vaticana_brew_primitive (me).smobbed_copy (); return primitive; } -MAKE_SCHEME_CALLBACK (Vaticana_ligature, brew_molecule, 1); +MAKE_SCHEME_CALLBACK (Vaticana_ligature, print, 1); SCM -Vaticana_ligature::brew_molecule (SCM) +Vaticana_ligature::print (SCM) { return SCM_EOL; }