LEFT | RIGHT |
(no file at all) | |
1 /* | 1 /* |
2 This file is part of LilyPond, the GNU music typesetter. | 2 This file is part of LilyPond, the GNU music typesetter. |
3 | 3 |
4 Copyright (C) 1997--2011 Han-Wen Nienhuys <hanwen@xs4all.nl> | 4 Copyright (C) 1997--2011 Han-Wen Nienhuys <hanwen@xs4all.nl> |
5 Jan Nieuwenhuizen <janneke@gnu.org> | 5 Jan Nieuwenhuizen <janneke@gnu.org> |
6 | 6 |
7 LilyPond is free software: you can redistribute it and/or modify | 7 LilyPond is free software: you can redistribute it and/or modify |
8 it under the terms of the GNU General Public License as published by | 8 it under the terms of the GNU General Public License as published by |
9 the Free Software Foundation, either version 3 of the License, or | 9 the Free Software Foundation, either version 3 of the License, or |
10 (at your option) any later version. | 10 (at your option) any later version. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 #include "item.hh" | 47 #include "item.hh" |
48 #include "least-squares.hh" | 48 #include "least-squares.hh" |
49 #include "lookup.hh" | 49 #include "lookup.hh" |
50 #include "main.hh" | 50 #include "main.hh" |
51 #include "misc.hh" | 51 #include "misc.hh" |
52 #include "note-head.hh" | 52 #include "note-head.hh" |
53 #include "output-def.hh" | 53 #include "output-def.hh" |
54 #include "pointer-group-interface.hh" | 54 #include "pointer-group-interface.hh" |
55 #include "rhythmic-head.hh" | 55 #include "rhythmic-head.hh" |
56 #include "spanner.hh" | 56 #include "spanner.hh" |
| 57 #include "staff-symbol.hh" |
57 #include "staff-symbol-referencer.hh" | 58 #include "staff-symbol-referencer.hh" |
58 #include "stem.hh" | 59 #include "stem.hh" |
59 #include "warn.hh" | 60 #include "warn.hh" |
60 | 61 |
61 #if DEBUG_BEAM_SCORING | 62 #if DEBUG_BEAM_SCORING |
62 #include "text-interface.hh" // debug output. | 63 #include "text-interface.hh" // debug output. |
63 #include "font-interface.hh" // debug output. | 64 #include "font-interface.hh" // debug output. |
64 #endif | 65 #endif |
65 | 66 |
66 #include <map> | 67 #include <map> |
(...skipping 1656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1723 | 1724 |
1724 /* Inside staff, move by whole spaces*/ | 1725 /* Inside staff, move by whole spaces*/ |
1725 if ((rest_extent[d] + staff_space * shift) * d | 1726 if ((rest_extent[d] + staff_space * shift) * d |
1726 < rad | 1727 < rad |
1727 || (rest_extent[-d] + staff_space * shift) * -d | 1728 || (rest_extent[-d] + staff_space * shift) * -d |
1728 < rad) | 1729 < rad) |
1729 shift = ceil (fabs (shift)) * sign (shift); | 1730 shift = ceil (fabs (shift)) * sign (shift); |
1730 | 1731 |
1731 return scm_from_double (offset + staff_space * shift); | 1732 return scm_from_double (offset + staff_space * shift); |
1732 } | 1733 } |
| 1734 |
| 1735 MAKE_SCHEME_CALLBACK_WITH_OPTARGS (Beam, pure_rest_collision_callback, 4, 1, "")
; |
| 1736 SCM |
| 1737 Beam::pure_rest_collision_callback (SCM smob, |
| 1738 SCM, /* prev_offset */ |
| 1739 SCM, /* start */ |
| 1740 SCM /* end */) |
| 1741 { |
| 1742 Real amount = 0.0; |
| 1743 |
| 1744 Grob *me = unsmob_grob (smob); |
| 1745 Grob *stem = unsmob_grob (me->get_object ("stem")); |
| 1746 if (!stem) |
| 1747 return scm_from_double (amount); |
| 1748 Grob *beam = unsmob_grob (stem->get_object ("beam")); |
| 1749 if (!beam |
| 1750 || !Beam::normal_stem_count (beam)) |
| 1751 return scm_from_double (amount); |
| 1752 |
| 1753 Real ss = Staff_symbol_referencer::staff_space (me); |
| 1754 |
| 1755 /* |
| 1756 This gives the extrema of rest positions. |
| 1757 In general, beams are never typeset more than one staff space away |
| 1758 from the staff in either direction. |
| 1759 */ |
| 1760 Grob *staff = Staff_symbol_referencer::get_staff_symbol (me); |
| 1761 Interval rest_max_pos = staff ? Staff_symbol::line_span (staff) : Interval (0.
0, 0.0); |
| 1762 rest_max_pos.widen (1); |
| 1763 rest_max_pos *= ss / 2; |
| 1764 |
| 1765 extract_grob_set (beam, "stems", stems); |
| 1766 vector<Grob *> my_stems; |
| 1767 |
| 1768 for (vsize i = 0; i < stems.size (); i++) |
| 1769 if (Stem::head_count (stems[i]) || stems[i] == stem) |
| 1770 my_stems.push_back (stems[i]); |
| 1771 |
| 1772 vsize idx = -1; |
| 1773 |
| 1774 for (vsize i = 0; i < my_stems.size (); i++) |
| 1775 if (my_stems[i] == stem) |
| 1776 { |
| 1777 idx = i; |
| 1778 break; |
| 1779 } |
| 1780 Grob *left; |
| 1781 Grob *right; |
| 1782 |
| 1783 if (idx == -1 || my_stems.size () == 1) |
| 1784 return scm_from_double (amount); |
| 1785 else if (idx == 0) |
| 1786 left = right = my_stems[1]; |
| 1787 else if (idx == my_stems.size () - 1) |
| 1788 left = right = my_stems[idx - 1]; |
| 1789 else |
| 1790 { |
| 1791 left = my_stems[idx - 1]; |
| 1792 right = my_stems[idx + 1]; |
| 1793 } |
| 1794 Direction beamdir = get_grob_direction (beam); |
| 1795 /* |
| 1796 Take the position between the two bounding head_positions, |
| 1797 then bound it by the minimum and maximum positions outside the staff. |
| 1798 4.0 = 2.0 to get out of staff space * 2.0 for the average |
| 1799 */ |
| 1800 amount = min (max ((Stem::head_positions (left)[beamdir] + Stem::head_position
s (right)[beamdir]) / 4.0, rest_max_pos[DOWN]), rest_max_pos[UP]); |
| 1801 |
| 1802 return scm_from_double (amount); |
| 1803 } |
| 1804 |
1733 | 1805 |
1734 bool | 1806 bool |
1735 Beam::is_knee (Grob *me) | 1807 Beam::is_knee (Grob *me) |
1736 { | 1808 { |
1737 SCM k = me->get_property ("knee"); | 1809 SCM k = me->get_property ("knee"); |
1738 if (scm_is_bool (k)) | 1810 if (scm_is_bool (k)) |
1739 return ly_scm2bool (k); | 1811 return ly_scm2bool (k); |
1740 | 1812 |
1741 bool knee = false; | 1813 bool knee = false; |
1742 int d = 0; | 1814 int d = 0; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1857 "knee " | 1929 "knee " |
1858 "length-fraction " | 1930 "length-fraction " |
1859 "least-squares-dy " | 1931 "least-squares-dy " |
1860 "neutral-direction " | 1932 "neutral-direction " |
1861 "normal-stems " | 1933 "normal-stems " |
1862 "positions " | 1934 "positions " |
1863 "quantized-positions " | 1935 "quantized-positions " |
1864 "shorten " | 1936 "shorten " |
1865 "stems " | 1937 "stems " |
1866 ); | 1938 ); |
LEFT | RIGHT |