]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/spanner.hh
cf77c086c03066c55c9d2eeb16823f38e6e5c39e
[lilypond.git] / lily / include / spanner.hh
1 /*
2   spanner.hh -- part of GNU LilyPond
3
4   (c) 1996--2007 Han-Wen Nienhuys
5 */
6
7 #ifndef SPANNER_HH
8 #define SPANNER_HH
9
10 #include "grob.hh"
11 #include "rod.hh"
12
13 /** A symbol which is attached between two columns. A spanner is a
14     symbol which spans across several columns, so its final appearance
15     can only be calculated after the breaking problem is solved.
16
17     Examples
18
19     * (de)crescendo
20     * slur
21     * beam
22     * bracket
23
24     Spanner should know about the items which it should consider:
25     e.g. slurs should be steep enough to "enclose" all those items. This
26     is absolutely necessary for beams, since they have to adjust the
27     length of stems of notes they encompass.
28 */
29 class Spanner : public Grob
30 {
31   Drul_array<Item *> spanned_drul_;
32   vsize break_index_;
33
34   DECLARE_CLASSNAME(Spanner);
35
36 public:
37   DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM));
38   DECLARE_SCHEME_CALLBACK (bounds_width, (SCM));
39
40   vector<Spanner*> broken_intos_;
41
42   vsize get_break_index () const;
43   Spanner *broken_neighbor (Direction d) const;
44   
45   // todo: move to somewhere else.
46   Real get_broken_left_end_align () const;
47   void substitute_one_mutable_property (SCM sym, SCM val);
48
49   Interval_t<Moment> spanned_time () const;
50   virtual Interval_t<int> spanned_rank_interval () const;
51   void set_bound (Direction d, Grob *);
52   Item *get_bound (Direction d) const;
53
54   Spanner (SCM);
55   Spanner (Spanner const &);
56   bool is_broken () const;
57   void do_break ();
58   Real spanner_length () const;
59
60   static int compare (Spanner *const &, Spanner *const &);
61   static bool less (Spanner *const &, Spanner *const &);
62   virtual Grob *find_broken_piece (System *) const;
63   virtual void derived_mark () const;
64   DECLARE_GROB_INTERFACE();
65   virtual System *get_system () const;
66
67 protected:
68   void set_my_columns ();
69   virtual Grob *clone () const;
70   virtual void do_break_processing ();
71   bool fast_substitute_grob_array (SCM sym, Grob_array *);
72 };
73
74 void add_bound_item (Spanner *, Grob *);
75
76 bool spanner_less (Spanner *s1, Spanner *s2);
77 int broken_spanner_index (Spanner const *sp);
78 #endif