]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/spanner.hh
cce03ee4372035978320839b57213f6e8e9628f9
[lilypond.git] / lily / include / spanner.hh
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 1996--2012 Han-Wen Nienhuys
5
6   LilyPond is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef SPANNER_HH
21 #define SPANNER_HH
22
23 #include "grob.hh"
24 #include "rod.hh"
25
26 /** A symbol which is attached between two columns. A spanner is a
27     symbol which spans across several columns, so its final appearance
28     can only be calculated after the breaking problem is solved.
29
30     Examples
31
32     * (de)crescendo
33     * slur
34     * beam
35     * bracket
36
37     Spanner should know about the items which it should consider:
38     e.g. slurs should be steep enough to "enclose" all those items. This
39     is absolutely necessary for beams, since they have to adjust the
40     length of stems of notes they encompass.
41 */
42 class Spanner : public Grob
43 {
44   Drul_array<Item *> spanned_drul_;
45   vsize break_index_;
46
47   DECLARE_CLASSNAME (Spanner);
48
49 public:
50   DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM));
51   DECLARE_SCHEME_CALLBACK (calc_normalized_endpoints, (SCM));
52   DECLARE_SCHEME_CALLBACK (bounds_width, (SCM));
53   DECLARE_SCHEME_CALLBACK (kill_zero_spanned_time, (SCM));
54
55   vector<Spanner *> broken_intos_;
56
57   vsize get_break_index () const;
58   Spanner *broken_neighbor (Direction d) const;
59
60   // todo: move to somewhere else.
61   Real get_broken_left_end_align () const;
62   void substitute_one_mutable_property (SCM sym, SCM val);
63
64   Interval_t<Moment> spanned_time () const;
65   virtual Interval_t<int> spanned_rank_interval () const;
66   void set_bound (Direction d, Grob *);
67   Item *get_bound (Direction d) const;
68
69   Spanner (SCM);
70   Spanner (Spanner const &);
71   bool is_broken () const;
72   void do_break ();
73   Real spanner_length () const;
74
75   static int compare (Spanner *const &, Spanner *const &);
76   static bool less (Spanner *const &, Spanner *const &);
77   virtual Grob *find_broken_piece (System *) const;
78   virtual void derived_mark () const;
79   DECLARE_GROB_INTERFACE ();
80   virtual System *get_system () const;
81
82   SCM get_cached_pure_property (SCM sym, int start, int end);
83   void cache_pure_property (SCM sym, int start, int end, SCM value);
84
85 protected:
86   SCM pure_property_cache_;
87
88   void set_my_columns ();
89   virtual Grob *clone () const;
90   virtual void do_break_processing ();
91   bool fast_substitute_grob_array (SCM sym, Grob_array *);
92 };
93
94 void add_bound_item (Spanner *, Grob *);
95
96 bool spanner_less (Spanner *s1, Spanner *s2);
97 #endif