]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/dimension-cache.hh
patch::: 1.3.9.hwn2
[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--1999 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   /** The #offset_# is defined with regard to this graphical_element/
52     dimension_cache.  */
53   void set_offset_callback (Offset_cache_callback);
54   Dimension_cache * parent_l_;
55
56   Score_element *element_l () const { return elt_l_; }
57
58   void invalidate ();
59   void invalidate_dependencies ();
60   
61   Dimension_cache(Dimension_cache const&);
62   Dimension_cache ();
63
64
65   /**
66      Find the offset relative to D.  If   D equals THIS, then it is 0.
67      Otherwise, it recursively defd as
68
69      OFFSET_ + PARENT_L_->relative_coordinate (D)
70    */
71   Real relative_coordinate (Dimension_cache *d) const;
72   Dimension_cache*common_refpoint (Dimension_cache const* s) const;
73   Dimension_cache*common_refpoint (Link_array<Dimension_cache> caches) const;
74   void set_empty (bool);
75   void translate (Real);
76
77   // junkme.
78   void set_offset (Real);
79
80   bool valid_b () const { return valid_b_; }
81   bool empty_b() const;
82   Interval get_dim () const;
83 };
84
85
86 #endif /* DIMENSION_CACHE_HH */
87