From ad300ca4fff3ea3109961a10a789529e001174e1 Mon Sep 17 00:00:00 2001 From: Erlend Aasland Date: Tue, 18 Apr 2006 09:15:46 +0000 Subject: [PATCH] Move rotated_box () from Stem_tremolo:: to Lookup:: --- ChangeLog | 9 +++++++++ lily/include/lookup.hh | 1 + lily/include/stem-tremolo.hh | 1 - lily/lookup.cc | 16 ++++++++++++++++ lily/stem-tremolo.cc | 26 ++++++-------------------- 5 files changed, 32 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0a2b6c46f4..0f97b589d2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2006-04-18 Erlend Aasland + + * lily/include/stem-tremolo.hh: + * lily/stem-tremolo.cc: move rotated_box () to Lookup:: and update + callers. + + * lily/lookup.cc: add rotated_box () + * lily/include/lookup.hh: + 2006-04-18 Heikki Junes * scripts/GNUmakefile: bugfix: run help2man only after scripts have diff --git a/lily/include/lookup.hh b/lily/include/lookup.hh index 54ad282f9f..db5f2d9cc7 100644 --- a/lily/include/lookup.hh +++ b/lily/include/lookup.hh @@ -18,6 +18,7 @@ struct Lookup static Stencil dot (Offset p, Real radius); static Stencil bracket (Axis a, Interval iv, Real thick, Real protude, Real blot); static Stencil accordion (SCM arg, Real interline_f, Font_metric *fm); + static Stencil rotated_box (Real slope, Real width, Real thick, Real blot); static Stencil round_filled_polygon (vector const &points, Real blotdiameter); static Stencil frame (Box b, Real thick, Real blot); static Stencil slur (Bezier controls, Real cthick, Real thick); diff --git a/lily/include/stem-tremolo.hh b/lily/include/stem-tremolo.hh index fb8f57ff5e..731d2462d3 100644 --- a/lily/include/stem-tremolo.hh +++ b/lily/include/stem-tremolo.hh @@ -22,7 +22,6 @@ public: DECLARE_SCHEME_CALLBACK (print, (SCM)); DECLARE_SCHEME_CALLBACK (height, (SCM)); DECLARE_SCHEME_CALLBACK (calc_style, (SCM)); - static Stencil rotated_box (Real slope, Real width, Real thick, Real blot); static Stencil raw_stencil (Grob *, Real, Direction stemdir); static Real get_beam_translation (Grob *me); }; diff --git a/lily/lookup.cc b/lily/lookup.cc index fb64bc1604..d8c20c044f 100644 --- a/lily/lookup.cc +++ b/lily/lookup.cc @@ -110,6 +110,22 @@ Lookup::dashed_slur (Bezier b, Real thick, Real dash_period, Real dash_fraction) return Stencil (box, at); } +Stencil +Lookup::rotated_box (Real slope, Real width, Real thick, Real blot) +{ + vector pts; + Offset rot (1, 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); + pts.push_back (Offset (0, thick / 2) * rot); + return Lookup::round_filled_polygon (pts, blot); +} + Stencil Lookup::horizontal_line (Interval w, Real th) { diff --git a/lily/stem-tremolo.cc b/lily/stem-tremolo.cc index b3ea13d30d..cec65cbcaf 100644 --- a/lily/stem-tremolo.cc +++ b/lily/stem-tremolo.cc @@ -86,23 +86,6 @@ Stem_tremolo::get_beam_translation (Grob *me) return beam ? Beam::get_beam_translation (beam) : 0.81; } -/* FIXME: move to Lookup? */ -Stencil -Stem_tremolo::rotated_box (Real slope, Real width, Real thick, Real blot) -{ - vector pts; - Offset rot (1, 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); - pts.push_back (Offset (0, thick / 2) * rot); - return Lookup::round_filled_polygon (pts, blot); -} - Stencil Stem_tremolo::raw_stencil (Grob *me, Real slope, Direction stemdir) { @@ -117,9 +100,12 @@ Stem_tremolo::raw_stencil (Grob *me, Real slope, Direction stemdir) width *= ss; thick *= ss; - Stencil a = style == ly_symbol2scm ("rectangle") ? - rotated_box (slope, width, thick, blot) : - Lookup::beam (slope, width, thick, blot); + Stencil a; + if (style == ly_symbol2scm ("rectangle")) + a = Lookup::rotated_box (slope, width, thick, blot); + else + a = Lookup::beam (slope, width, thick, blot); + a.align_to (X_AXIS, CENTER); a.align_to (Y_AXIS, CENTER); -- 2.39.2