]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/beam.hh
Run grand-replace (issue 3765)
[lilypond.git] / lily / include / beam.hh
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 1996--2014 Han-Wen Nienhuys <hanwen@xs4all.nl>
5   Jan Nieuwenhuizen <janneke@gnu.org>
6
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
9   the Free Software Foundation, either version 3 of the License, or
10   (at your option) any later version.
11
12   LilyPond is distributed in the hope that it will be useful,
13   but WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   GNU General Public License for more details.
16
17   You should have received a copy of the GNU General Public License
18   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #ifndef BEAM_HH
22 #define BEAM_HH
23
24 #include "grob-interface.hh"
25 #include "std-vector.hh"
26 #include "lily-proto.hh"
27 #include "stem-info.hh"
28
29 struct Beam_segment
30 {
31   int vertical_count_;
32   Interval horizontal_;
33   Beam_segment ();
34 };
35
36 bool beam_segment_less (Beam_segment const &a, Beam_segment const &b);
37
38 struct Beam_stem_segment
39 {
40   Beam_stem_segment ();
41
42   Grob *stem_;
43   Real width_;
44   Real stem_x_;
45   int rank_;
46   vsize stem_index_;
47   bool gapped_;
48   Direction dir_;
49   int max_connect_;
50 };
51
52 bool operator <(Beam_stem_segment const &a, Beam_stem_segment const &b);
53
54 class Beam
55 {
56 public:
57   static int normal_stem_count (Grob *);
58   static Grob *first_normal_stem (Grob *);
59   static Grob *last_normal_stem (Grob *);
60   DECLARE_GROB_INTERFACE ();
61   static void add_stem (Grob *, Grob *);
62   static bool is_cross_staff (Grob *);
63   static bool is_knee (Grob *);
64   static void set_beaming (Grob *, Beaming_pattern const *);
65   static void set_stemlens (Grob *);
66   static int get_beam_count (Grob *me);
67   static Real get_beam_translation (Grob *me);
68   static Real get_beam_thickness (Grob *me);
69   static void connect_beams (Grob *me);
70   static vector<Beam_segment> get_beam_segments (Grob *me_grob, Grob **common);
71
72   DECLARE_SCHEME_CALLBACK (rest_collision_callback, (SCM element, SCM prev_off));
73   DECLARE_SCHEME_CALLBACK (pure_rest_collision_callback, (SCM element, SCM, SCM, SCM prev_off));
74   DECLARE_SCHEME_CALLBACK (print, (SCM));
75   DECLARE_SCHEME_CALLBACK (calc_beaming, (SCM));
76   DECLARE_SCHEME_CALLBACK (calc_stem_shorten, (SCM));
77   DECLARE_SCHEME_CALLBACK (calc_direction, (SCM));
78   DECLARE_SCHEME_CALLBACK (calc_positions, (SCM));
79   DECLARE_SCHEME_CALLBACK (calc_normal_stems, (SCM));
80   DECLARE_SCHEME_CALLBACK (set_stem_lengths, (SCM));
81   DECLARE_SCHEME_CALLBACK (calc_cross_staff, (SCM));
82   DECLARE_SCHEME_CALLBACK (calc_beam_segments, (SCM));
83   /* position callbacks */
84   DECLARE_SCHEME_CALLBACK (quanting, (SCM, SCM, SCM));
85   DECLARE_SCHEME_CALLBACK (calc_x_positions, (SCM));
86
87   static int get_direction_beam_count (Grob *me, Direction d);
88
89 private:
90   friend class Beam_scoring_problem;
91
92   static Direction get_default_dir (Grob *);
93   static vector<Beam_segment> get_beam_segments (Grob *);
94   static void set_stem_directions (Grob *, Direction);
95   static void consider_auto_knees (Grob *);
96   static void set_stem_shorten (Grob *);
97   static int forced_stem_count (Grob *);
98   static Real calc_stem_y (Grob *, Grob *s, Grob **c,
99                            Real, Real, Direction,
100                            Drul_array<Real> pos, bool french);
101 };
102
103 #endif /* BEAM_HH */
104