]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/dimension-cache.hh
release: 1.3.19
[lilypond.git] / lily / include / dimension-cache.hh
1 /*   
2   dimension-cache.hh -- declare Dimension_cache
3   
4   source file of the GNU LilyPond music typesetter
5   
6   (c) 1998--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   
8  */
9
10 #ifndef DIMENSION_CACHE_HH
11 #define DIMENSION_CACHE_HH
12
13 #include "interval.hh"
14 #include "real.hh"
15 #include "lily-proto.hh"
16 #include "parray.hh"
17
18 class Dimension_cache;
19 typedef Interval (*Dim_cache_callback)(Dimension_cache const *);
20 typedef Real (*Offset_cache_callback)(Dimension_cache const *);
21
22 /**
23   Adminstration of offset dimension info. 
24  */
25 class Dimension_cache
26 {
27   bool valid_b_;
28   Interval dim_;
29   /**
30     The offset wrt. to the center of #parent_l_#
31    */
32
33   Real extra_offset_;
34   Real basic_offset_;
35   bool off_valid_b_;
36
37   Score_element *elt_l_;
38   friend class Score_element;
39
40   void init ();
41 public:
42   Array<Offset_cache_callback> off_callbacks_;
43   /**
44      What to call to find extent.  Nil means empty. 
45    */
46   Dim_cache_callback callback_l_;
47   static Interval point_dimension_callback (Dimension_cache const* );
48   Axis axis () const;
49   Real get_offset () const;
50   void set_callback (Dim_cache_callback);
51   Dimension_cache * parent_l_;
52
53   Score_element *element_l () const { return elt_l_; }
54
55   Dimension_cache(Dimension_cache const&);
56   Dimension_cache ();
57
58
59   /**
60      Find the offset relative to D.  If   D equals THIS, then it is 0.
61      Otherwise, it recursively defd as
62
63      OFFSET_ + PARENT_L_->relative_coordinate (D)
64    */
65   Real relative_coordinate (Dimension_cache *d) const;
66   Dimension_cache*common_refpoint (Dimension_cache const* s) const;
67   Dimension_cache*common_refpoint (Link_array<Dimension_cache> caches) const;
68   void set_empty (bool);
69   void translate (Real);
70
71   bool valid_b () const { return valid_b_; }
72   bool empty_b() const;
73   Interval get_dim () const;
74 };
75
76
77 #endif /* DIMENSION_CACHE_HH */
78