]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/flag.cc
Web-es: translate a subheading.
[lilypond.git] / lily / flag.cc
index a349a205d9b50cde98218417cd86a99e1de1432f..f997d6fe457f44626cddc7bec2579788b4046a69 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 1996--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  Copyright (C) 1996--2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
   Jan Nieuwenhuizen <janneke@gnu.org>
 
   LilyPond is free software: you can redistribute it and/or modify
@@ -35,11 +35,12 @@ public:
   DECLARE_SCHEME_CALLBACK (print, (SCM));
   DECLARE_SCHEME_CALLBACK (width, (SCM));
   DECLARE_SCHEME_CALLBACK (calc_y_offset, (SCM));
+  DECLARE_SCHEME_CALLBACK (pure_calc_y_offset, (SCM, SCM, SCM));
   DECLARE_SCHEME_CALLBACK (calc_x_offset, (SCM));
   DECLARE_GROB_INTERFACE ();
-};
-
 
+  static SCM internal_calc_y_offset (SCM smob, bool pure);
+};
 
 MAKE_SCHEME_CALLBACK (Flag, width, 1);
 SCM
@@ -67,6 +68,7 @@ Flag::print (SCM smob)
   Grob *me = unsmob_grob (smob);
   Grob *stem = me->get_parent (X_AXIS);
 
+  Direction d = get_grob_direction (stem);
   int log = Stem::duration_log (stem);
   string flag_style;
 
@@ -91,7 +93,8 @@ Flag::print (SCM smob)
     {
       if (adjust)
         {
-          int p = (int) (rint (Stem::stem_end_position (stem)));
+          Real ss = Staff_symbol_referencer::staff_space (me);
+          int p = (int) (rint (stem->extent (stem, Y_AXIS)[d] * 2 / ss));
           staffline_offs
             = Staff_symbol_referencer::on_line (stem, p) ? "0" : "1";
         }
@@ -101,7 +104,7 @@ Flag::print (SCM smob)
   else
     staffline_offs = "";
 
-  char dir = (get_grob_direction (stem) == UP) ? 'u' : 'd';
+  char dir = (d == UP) ? 'u' : 'd';
   string font_char = flag_style
                      + to_string (dir) + staffline_offs + to_string (log);
   Font_metric *fm = Font_interface::get_default_font (me);
@@ -136,9 +139,24 @@ Flag::print (SCM smob)
   return flag.smobbed_copy ();
 }
 
+MAKE_SCHEME_CALLBACK (Flag, pure_calc_y_offset, 3);
+SCM
+Flag::pure_calc_y_offset (SCM smob,
+                          SCM /* beg */,
+                          SCM /* end */)
+{
+  return internal_calc_y_offset (smob, true);
+}
+
 MAKE_SCHEME_CALLBACK (Flag, calc_y_offset, 1);
 SCM
 Flag::calc_y_offset (SCM smob)
+{
+  return internal_calc_y_offset (smob, false);
+}
+
+SCM
+Flag::internal_calc_y_offset (SCM smob, bool pure)
 {
   Grob *me = unsmob_grob (smob);
   Grob *stem = me->get_parent (X_AXIS);
@@ -146,10 +164,12 @@ Flag::calc_y_offset (SCM smob)
 
   Real blot
     = me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter"));
-  Real half_space = Staff_symbol_referencer::staff_space (me) * 0.5;
-  Real y2 = robust_scm2double (stem->get_property ("stem-end-position"), 0.0);
 
-  return scm_from_double (y2 * half_space - d * blot / 2);
+  Real y2 = pure
+            ? stem->pure_height (stem, 0, INT_MAX)[d]
+            : stem->extent (stem, Y_AXIS)[d];
+
+  return scm_from_double (y2 - d * blot / 2);
 }
 
 MAKE_SCHEME_CALLBACK (Flag, calc_x_offset, 1);
@@ -172,4 +192,4 @@ ADD_INTERFACE (Flag,
                /* properties */
                "style "
                "stroke-style "
-              );
\ No newline at end of file
+              );