]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/dimension-cache.hh
release: 1.3.13
[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   Dimension_cache(Dimension_cache const&);
59   Dimension_cache ();
60
61
62   /**
63      Find the offset relative to D.  If   D equals THIS, then it is 0.
64      Otherwise, it recursively defd as
65
66      OFFSET_ + PARENT_L_->relative_coordinate (D)
67    */
68   Real relative_coordinate (Dimension_cache *d) const;
69   Dimension_cache*common_refpoint (Dimension_cache const* s) const;
70   Dimension_cache*common_refpoint (Link_array<Dimension_cache> caches) const;
71   void set_empty (bool);
72   void translate (Real);
73
74   bool valid_b () const { return valid_b_; }
75   bool empty_b() const;
76   Interval get_dim () const;
77 };
78
79
80 #endif /* DIMENSION_CACHE_HH */
81