]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/dimension-cache.hh
release: 1.2.4
[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 *);
20
21 /**
22   Adminstration of offset dimension info. 
23  */
24 class Dimension_cache
25 {
26   bool valid_b_;
27   /** Is this element dimensionless?.
28     This is private to guarantee correctness of the cache
29    */
30   bool empty_b_;
31   Interval dim_;
32   /**
33     The offset wrt. to the center of #parent_l_#
34    */
35   Real offset_;
36   Graphical_element *elt_l_;
37   Dim_cache_callback callback_l_;
38   friend class Graphical_element;
39
40   void init ();
41 public:
42   void set_callback (Dim_cache_callback);
43   /** The #offset_# is defined with regard to this graphical_element/
44     dimension_cache.  */
45   
46   Dimension_cache * parent_l_;
47   Link_array<Dimension_cache> dependencies_l_arr_;
48   Graphical_element *element_l () { return elt_l_; }
49
50   void invalidate ();
51   void invalidate_dependencies ();
52   
53   Dimension_cache(Dimension_cache const&);
54   Dimension_cache ();
55
56
57   /**
58      Find the offset relative to D.  If   D equals THIS, then it is 0.
59      Otherwise, it recursively defd as
60
61      OFFSET_ + PARENT_L_->relative_coordinate (D)
62    */
63   Real relative_coordinate (Dimension_cache *d) const;
64   Dimension_cache*common_refpoint (Dimension_cache const* s) const;
65   Dimension_cache*common_refpoint (Link_array<Dimension_cache> caches) const;
66   void set_empty (bool);
67   void translate (Real);
68
69   // junkme.
70   void set_offset (Real);
71
72   bool valid_b () const { return valid_b_; }
73   bool empty_b() const { return empty_b_; }
74   Interval get_dim () const;
75 };
76
77
78 #endif /* DIMENSION_CACHE_HH */
79