From 283736960a9b254fbfc3e166e7750ffcfc7c382e Mon Sep 17 00:00:00 2001 From: hanwen Date: Sun, 18 Jan 2004 19:47:20 +0000 Subject: [PATCH] * lily/line-interface.cc (line): remove thickness from calling interface. * lily/hairpin.cc: use Line_interface * lily/line-interface.cc: new file. Line_interface for everything with dotted/dashed lines. * lily/tuplet-bracket.cc (make_bracket): use Line_interface. * lily/ottava-bracket.cc (brew_molecule): new file, separate routine for constructing ottava brackets. * lily/lookup.cc: remove Lookup::horizontal_slope (): it is functionally identical to beam. --- ChangeLog | 2 ++ lily/balloon.cc | 3 ++- lily/hairpin.cc | 9 ++------- lily/include/line-interface.hh | 5 +++-- lily/include/line-spanner.hh | 3 +-- lily/include/lookup.hh | 1 - lily/include/tuplet-bracket.hh | 2 +- lily/line-interface.cc | 32 +++++++++++++++++++++++++++++--- lily/line-spanner.cc | 34 +++++++++------------------------- lily/lookup.cc | 28 ++-------------------------- lily/ottava-bracket.cc | 5 +---- lily/text-spanner.cc | 18 ++---------------- lily/tuplet-bracket.cc | 14 ++++---------- lily/volta-bracket.cc | 9 ++++----- scm/define-grobs.scm | 2 +- 15 files changed, 63 insertions(+), 104 deletions(-) diff --git a/ChangeLog b/ChangeLog index c3ee2c36a8..978247bfd5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2004-01-18 Han-Wen Nienhuys + * lily/line-interface.cc (line): remove thickness from calling interface. + * lily/hairpin.cc: use Line_interface * lily/line-interface.cc: new file. Line_interface for everything diff --git a/lily/balloon.cc b/lily/balloon.cc index dfb4d86f2e..78938c9914 100644 --- a/lily/balloon.cc +++ b/lily/balloon.cc @@ -4,6 +4,7 @@ #include "text-item.hh" #include "grob.hh" +#include "line-interface.hh" #include "lookup.hh" #include "font-interface.hh" #include "molecule.hh" @@ -83,7 +84,7 @@ Balloon_interface::brew_molecule (SCM smob) Offset z2 = z1 + off; - fr.add_molecule (Lookup::line (0.1, z1, z2)); + fr.add_molecule (Line_interface::line (me, z1, z2)); text_mol->translate (z2); fr.add_molecule (*text_mol); diff --git a/lily/hairpin.cc b/lily/hairpin.cc index 8dc7cda20d..66a9931df8 100644 --- a/lily/hairpin.cc +++ b/lily/hairpin.cc @@ -25,8 +25,6 @@ Hairpin::brew_molecule (SCM smob) Grob *me= unsmob_grob (smob); Spanner *spanner = dynamic_cast (me); - Real line = me->get_paper ()->get_realvar (ly_symbol2scm ("linethickness")); - SCM s = me->get_grob_property ("grow-direction"); if (!is_direction (s)) { @@ -103,7 +101,6 @@ Hairpin::brew_molecule (SCM smob) bool continued = broken[Direction (-grow_dir)]; Real height = gh_scm2double (me->get_grob_property ("height")); - Real thick = line * gh_scm2double (me->get_grob_property ("thickness")); Real starth, endh; if (grow_dir < 0) @@ -122,12 +119,10 @@ Hairpin::brew_molecule (SCM smob) */ Molecule mol; - mol = Line_interface::dashed_line (me, - thick, + mol = Line_interface::line (me, Offset (0, starth), Offset (width, endh)); - mol.add_molecule (Line_interface::dashed_line (me, - thick, + mol.add_molecule (Line_interface::line (me, Offset (0, -starth), Offset (width, -endh))); diff --git a/lily/include/line-interface.hh b/lily/include/line-interface.hh index f81d9f68c1..0bf56707a0 100644 --- a/lily/include/line-interface.hh +++ b/lily/include/line-interface.hh @@ -14,11 +14,12 @@ source file of the GNU LilyPond music typesetter struct Line_interface { - static Molecule dashed_line (Grob *me, Real thick, Offset from, Offset to); + static Molecule line (Grob *me, Offset from, Offset to); static bool has_interface (Grob*); static Molecule make_dashed_line (Real th, Offset from, Offset to, Real, Real); - + static Molecule make_line (Real th, Offset from, Offset to); }; + #endif /* LINE_INTERFACE_HH */ diff --git a/lily/include/line-spanner.hh b/lily/include/line-spanner.hh index a3d32d7c62..d120bb8d42 100644 --- a/lily/include/line-spanner.hh +++ b/lily/include/line-spanner.hh @@ -17,8 +17,7 @@ class Line_spanner public: DECLARE_SCHEME_CALLBACK (brew_molecule, (SCM)); DECLARE_SCHEME_CALLBACK(after_line_breaking, (SCM)); - static Molecule line_molecule (Grob* me, Real thick, - Offset f, Offset t); + static Molecule line_molecule (Grob* me, Offset f, Offset t); static bool has_interface (Grob*); private: diff --git a/lily/include/lookup.hh b/lily/include/lookup.hh index 959b278a8d..e4bcbb7244 100644 --- a/lily/include/lookup.hh +++ b/lily/include/lookup.hh @@ -31,7 +31,6 @@ struct Lookup static Molecule filled_box (Box b); static Molecule round_filled_box (Box b, Real blotdiameter); static Molecule repeat_slash (Real w, Real slope, Real th); - static Molecule line (Real th, Offset from, Offset to); static Molecule horizontal_line (Interval w, Real th); static Molecule triangle (Interval, Real, Real); }; diff --git a/lily/include/tuplet-bracket.hh b/lily/include/tuplet-bracket.hh index 46ff0bd006..004e1485a3 100644 --- a/lily/include/tuplet-bracket.hh +++ b/lily/include/tuplet-bracket.hh @@ -33,7 +33,7 @@ public: DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM )); static Molecule make_bracket (Grob *me, Axis protusion_axis, - Offset dz, Real thick, Drul_array height, + Offset dz, Drul_array height, Real gap, Drul_array widen, Drul_array shorten); static Direction get_default_dir (Grob*); diff --git a/lily/line-interface.cc b/lily/line-interface.cc index cac08cc08e..e3660924f8 100644 --- a/lily/line-interface.cc +++ b/lily/line-interface.cc @@ -12,7 +12,7 @@ source file of the GNU LilyPond music typesetter #include "grob.hh" #include "staff-symbol-referencer.hh" #include "lookup.hh" - +#include "paper-def.hh" Molecule @@ -42,12 +42,38 @@ Line_interface::make_dashed_line (Real thick, Offset from, Offset to, m.translate (from); return m; } + +Molecule +Line_interface::make_line (Real th, Offset from, Offset to) +{ + SCM at = scm_list_n (ly_symbol2scm ("draw-line"), + gh_double2scm (th), + gh_double2scm (from[X_AXIS]), + gh_double2scm (from[Y_AXIS]), + gh_double2scm (to[X_AXIS]), + gh_double2scm (to[Y_AXIS]), + SCM_UNDEFINED); + + Box box; + box.add_point (from); + box.add_point (to); + + box[X_AXIS].widen (th/2); + box[Y_AXIS].widen (th/2); + + return Molecule (box, at); +} + + /* TODO: read THICK from ME */ Molecule -Line_interface::dashed_line (Grob *me, Real thick, Offset from, Offset to) +Line_interface::line (Grob *me, Offset from, Offset to) { + Real thick = me->get_paper()->get_realvar (ly_symbol2scm ("linethickness")); + thick *= robust_scm2double (me->get_grob_property ("thickness"), 1.0); // todo: staff sym referencer? + SCM type = me->get_grob_property ("style"); if (type == ly_symbol2scm ("dotted-line") || type == ly_symbol2scm ("dashed-line")) @@ -67,7 +93,7 @@ Line_interface::dashed_line (Grob *me, Real thick, Offset from, Offset to) } else { - return Lookup::line (thick, from, to); + return make_line (thick, from, to); } } diff --git a/lily/line-spanner.cc b/lily/line-spanner.cc index c6b0ff9df8..578206975d 100644 --- a/lily/line-spanner.cc +++ b/lily/line-spanner.cc @@ -21,28 +21,17 @@ #include "lookup.hh" #include "line-interface.hh" -/* - TODO: convert all Molecule functions to taking arguments of the form - - Offset FROM, Offset TO. - - - TODO: - - Introduce line-interface that allows dots/dashes/etc. to be set as - grob-properties. Make arbitrary paths. - - */ - - Molecule -zigzag_molecule (Grob *me, Real thick, +zigzag_molecule (Grob *me, Offset from, Offset to) { Offset dz = to -from; Real dx = dz[X_AXIS]; Real dy = dz[Y_AXIS]; + + Real thick = me->get_paper()->get_realvar (ly_symbol2scm ("linethickness")); + thick *= robust_scm2double (me->get_grob_property ("thickness"), 1.0); // todo: staff sym referencer? Real staff_space = Staff_symbol_referencer::staff_space (me); SCM ws = me->get_grob_property ("zigzag-width"); @@ -104,7 +93,7 @@ Line_spanner::after_line_breaking (SCM g) Molecule -Line_spanner::line_molecule (Grob *me, Real thick, +Line_spanner::line_molecule (Grob *me, Offset from, Offset to) { @@ -118,8 +107,8 @@ Line_spanner::line_molecule (Grob *me, Real thick, || (type == ly_symbol2scm ("trill") && dz[Y_AXIS] != 0))) { return (type == ly_symbol2scm ("zigzag")) - ? zigzag_molecule (me, thick, from, to) - : Line_interface::dashed_line (me, thick, from, to); + ? zigzag_molecule (me, from, to) + : Line_interface::line (me, from, to); } else if (gh_symbol_p (type) && type == ly_symbol2scm ("trill")) @@ -201,11 +190,6 @@ Line_spanner::brew_molecule (SCM smob) Offset my_off; Offset his_off; - Real thick = me->get_paper ()->get_realvar (ly_symbol2scm ("linethickness")); - - SCM s = me->get_grob_property ("thickness"); - if (gh_number_p (s)) - thick *= gh_scm2double (s); if (bound[RIGHT]->break_status_dir()) { @@ -262,7 +246,7 @@ Line_spanner::brew_molecule (SCM smob) dz = (dz.length () - 2*gap) *dir; - Molecule l (line_molecule (me, thick, Offset(0, 0), dz)); + Molecule l (line_molecule (me, Offset(0, 0), dz)); l.translate (dir * gap + p1 - Offset (me->relative_coordinate (commonx, X_AXIS), @@ -297,7 +281,7 @@ Line_spanner::brew_molecule (SCM smob) ofxy = dxy * (off/dxy.length ()); dxy -= 2*ofxy; - Molecule line = line_molecule (me, thick, Offset (0,0),dxy); + Molecule line = line_molecule (me, Offset (0,0),dxy); line.translate_axis (bound[LEFT]->extent (bound[LEFT], X_AXIS).length ()/2, X_AXIS); line.translate (ofxy - my_off + his_off); diff --git a/lily/lookup.cc b/lily/lookup.cc index 4bb7c2d8a6..4182cd434d 100644 --- a/lily/lookup.cc +++ b/lily/lookup.cc @@ -6,13 +6,11 @@ (c) 1997--2003 Han-Wen Nienhuys Jan Nieuwenhuizen - - TODO - Glissando */ #include #include +#include "line-interface.hh" #include "warn.hh" #include "dimensions.hh" #include "bezier.hh" @@ -97,26 +95,6 @@ Lookup::dashed_slur (Bezier b, Real thick, Real dash) return Molecule (box, at); } -Molecule -Lookup::line (Real th, Offset from, Offset to) -{ - SCM at = scm_list_n (ly_symbol2scm ("draw-line"), - gh_double2scm (th), - gh_double2scm (from[X_AXIS]), - gh_double2scm (from[Y_AXIS]), - gh_double2scm (to[X_AXIS]), - gh_double2scm (to[Y_AXIS]), - SCM_UNDEFINED); - - Box box; - box.add_point (from); - box.add_point (to); - - box[X_AXIS].widen (th/2); - box[Y_AXIS].widen (th/2); - - return Molecule (box, at); -} Molecule @@ -275,7 +253,7 @@ Lookup::round_filled_polygon (Array points, Real blotdiameter) if (points.size () == 1) return dot (points[0], 0.5 * blotdiameter); if (points.size () == 2) - return line (blotdiameter, points[0], points[1]); + return Line_interface::make_line (blotdiameter, points[0], points[1]); /* shrink polygon in size by 0.5 * blotdiameter */ Array shrinked_points; @@ -346,8 +324,6 @@ Lookup::round_filled_polygon (Array points, Real blotdiameter) /* TODO: deprecate? - - should use rounded corners. */ Molecule Lookup::frame (Box b, Real thick, Real blot) diff --git a/lily/ottava-bracket.cc b/lily/ottava-bracket.cc index f72ccf9adc..bd64057891 100644 --- a/lily/ottava-bracket.cc +++ b/lily/ottava-bracket.cc @@ -97,9 +97,6 @@ Ottava_bracket::brew_molecule (SCM smob) Interval bracket_span_points = span_points; bracket_span_points[LEFT] += text_offset; - Real thick = paper->get_realvar (ly_symbol2scm ("linethickness")); - thick *= robust_scm2double (me->get_grob_property ("thickness"), 1.0); - Drul_array edge_height = robust_scm2interval (me->get_grob_property ("edge-height"), Interval (1.0, 1.0)); @@ -118,7 +115,7 @@ Ottava_bracket::brew_molecule (SCM smob) if (!bracket_span_points.is_empty ()) b = Tuplet_bracket::make_bracket (me, Y_AXIS, Offset (bracket_span_points.length (), 0), - thick, edge_height, + edge_height, 0.0, flare, shorten); diff --git a/lily/text-spanner.cc b/lily/text-spanner.cc index 9b4bcadaab..b575850ed4 100644 --- a/lily/text-spanner.cc +++ b/lily/text-spanner.cc @@ -32,8 +32,6 @@ MAKE_SCHEME_CALLBACK (Text_spanner, brew_molecule, 1); /* TODO: this function is too long - - */ SCM Text_spanner::brew_molecule (SCM smob) @@ -105,13 +103,6 @@ Text_spanner::brew_molecule (SCM smob) } while (flip (&d) != LEFT); } - - Real thick = paper->get_realvar (ly_symbol2scm ("linethickness")); - SCM st = me->get_grob_property ("thickness"); - if (gh_number_p (st)) - { - thick *= gh_scm2double (st); - } Drul_array edge_height = robust_scm2interval (me->get_grob_property ("edge-height"), Interval (1.0, 1.0)); @@ -130,8 +121,7 @@ Text_spanner::brew_molecule (SCM smob) Real dy = - dir * edge_height[d] ; if (dy) - edge_line[d] = Line_spanner::line_molecule (me, thick, Offset(0,0), - Offset (dx, dy)); + edge_line[d] = Line_spanner::line_molecule (me, Offset(0,0), Offset (dx, dy)); } while (flip (&d) != LEFT); } @@ -160,8 +150,7 @@ Text_spanner::brew_molecule (SCM smob) if (!span_points.is_empty ()) { - Molecule l =Line_spanner::line_molecule (me, thick, - Offset (span_points[LEFT], 0), + Molecule l =Line_spanner::line_molecule (me, Offset (span_points[LEFT], 0), Offset (span_points[RIGHT], 0)); m.add_molecule (l); } @@ -169,9 +158,6 @@ Text_spanner::brew_molecule (SCM smob) return m.smobbed_copy (); } - - - ADD_INTERFACE (Text_spanner,"text-spanner-interface", "generic text spanner", "text-repeat-if-broken dash-period if-text-padding dash-fraction edge-height bracket-flare edge-text shorten-pair style thickness enclose-bounds width-correct"); diff --git a/lily/tuplet-bracket.cc b/lily/tuplet-bracket.cc index 4b4d76383f..a499f29690 100644 --- a/lily/tuplet-bracket.cc +++ b/lily/tuplet-bracket.cc @@ -196,12 +196,6 @@ Tuplet_bracket::brew_molecule (SCM smob) if (bracket_visibility) { - Real lt = pap->get_realvar (ly_symbol2scm ("linethickness")); - - SCM thick = me->get_grob_property ("thickness"); - if (gh_number_p (thick)) - lt *= gh_scm2double (thick); - SCM gap = me->get_grob_property ("gap"); SCM fl = me->get_grob_property ("bracket-flare"); @@ -222,7 +216,7 @@ Tuplet_bracket::brew_molecule (SCM smob) while (flip (&d) != LEFT); Molecule brack = make_bracket (me, Y_AXIS, - Offset (w, ry - ly), lt, + Offset (w, ry - ly), height, gh_scm2double (gap), flare, @@ -245,7 +239,7 @@ Molecule Tuplet_bracket::make_bracket (Grob *me, // for line properties. Axis protusion_axis, Offset dz, - Real thick, Drul_array height, + Drul_array height, Real gap, Drul_array flare, Drul_array shorten) @@ -275,10 +269,10 @@ Tuplet_bracket::make_bracket (Grob *me, // for line properties. Molecule m; do { - m.add_molecule (Line_interface::dashed_line (me, thick, straight_corners[d], + m.add_molecule (Line_interface::line (me, straight_corners[d], gap_corners[d])); - m.add_molecule (Line_interface::dashed_line (me, thick, straight_corners[d], + m.add_molecule (Line_interface::line (me, straight_corners[d], flare_corners[d])); } while (flip (&d) != LEFT); diff --git a/lily/volta-bracket.cc b/lily/volta-bracket.cc index 195b0a7d60..740054f775 100644 --- a/lily/volta-bracket.cc +++ b/lily/volta-bracket.cc @@ -11,6 +11,7 @@ #include "box.hh" #include "warn.hh" #include "font-interface.hh" +#include "line-interface.hh" #include "molecule.hh" #include "paper-column.hh" #include "paper-def.hh" @@ -66,7 +67,6 @@ Volta_bracket_interface::brew_molecule (SCM smob) && strcmp(cs,":|:")!=0 && strcmp(cs,".|")!=0); Paper_def * paper =me->get_paper (); - Real staff_thick = paper->get_realvar (ly_symbol2scm ("linethickness")); Real half_space = 0.5; Item * bound = dynamic_cast (me)->get_bound (LEFT); @@ -90,16 +90,15 @@ Volta_bracket_interface::brew_molecule (SCM smob) Real w = dynamic_cast (me)->spanner_length () - left - half_space; Real h = gh_scm2double (me->get_grob_property ("height")); - Real t = staff_thick * gh_scm2double (me->get_grob_property ("thickness")); Molecule start,end ; if (!no_vertical_start) - start = Lookup::line (t, Offset (0,0), Offset (0, h)); + start = Line_interface::line (me, Offset (0,0), Offset (0, h)); if (!no_vertical_end) - end = Lookup::line (t, Offset (w, 0), Offset (w,h)); + end = Line_interface::line (me, Offset (w, 0), Offset (w,h)); - Molecule mol = Lookup::line (t, Offset (0, h), Offset (w,h)); + Molecule mol = Line_interface::line (me, Offset (0, h), Offset (w,h)); mol.add_molecule (start); mol.add_molecule (end); diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 41b052e138..c30a1637ac 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -1214,7 +1214,7 @@ (minimum-space . 5) (font-family . number) (font-size . -4) - (meta . ((interfaces . (volta-bracket-interface text-interface side-position-interface font-interface spanner-interface)))) + (meta . ((interfaces . (volta-bracket-interface line-interface text-interface side-position-interface font-interface spanner-interface)))) )) (VerticalAlignment -- 2.39.2