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