]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/grob.hh
* lily/system.cc (do_derived_mark): don't mark from object_alist_
[lilypond.git] / lily / include / grob.hh
1 /*
2   grob.hh -- declare Grob
3
4   source file of the LilyPond music typesetter
5
6   (c) 1996--2005 Han-Wen Nienhuys
7 */
8
9 #ifndef GROB_HH
10 #define GROB_HH
11
12 #include "virtual-methods.hh"
13 #include "dimension-cache.hh"
14 #include "grob-interface.hh"
15 #include "object-key.hh"
16
17 enum Grob_status
18   {
19     ORPHAN = 0, // not yet added to Paper_score
20     PRECALCING,
21     PRECALCED, // calcs before spacing done
22     POSTCALCING, // busy calculating. This is used to trap cyclic deps.
23     POSTCALCED, // after spacing calcs done
24   };
25
26 typedef void (Grob:: *Grob_method_pointer) (void);
27
28 class Grob
29 {
30 private:
31   DECLARE_SMOBS (Grob, foo);
32   void init ();
33 protected:
34   Object_key const *key_;
35   SCM immutable_property_alist_;
36   SCM mutable_property_alist_;
37   SCM object_alist_;
38
39   /*
40     If this is a property, it accounts for 25% of the property
41     lookups.
42    */
43   SCM interfaces_;
44
45   
46   
47   /* BARF */
48   friend class Spanner;
49   friend SCM ly_grob_properties (SCM);
50   friend SCM ly_grob_basic_properties (SCM);
51   friend void check_interfaces_for_property  (Grob const*, SCM);
52   void substitute_object_links (SCM, SCM);
53   char status_;
54
55 public:
56   Object_key const *get_key () const;
57
58   Grob *original_;
59
60   /* TODO: junk this member. */
61   Paper_score *pscore_;
62
63   Dimension_cache dim_cache_[NO_AXES];
64
65   Grob (SCM basic_props, Object_key const *);
66   Grob (Grob const &, int copy_count);
67
68   virtual Grob *clone (int count) const;
69   DECLARE_SCHEME_CALLBACK (stencil_extent, (SCM smob, SCM axis));
70
71   String name () const;
72   /*
73     Properties
74   */
75   SCM internal_get_property (SCM) const;
76   SCM internal_get_object (SCM) const;
77
78   void internal_set_property (SCM sym, SCM val);
79   void internal_set_object (SCM sym, SCM val);
80
81   /*
82     JUNKME.
83    */
84   void add_to_list_property (SCM, SCM);
85   void add_to_object_list (SCM sym, SCM thing);
86
87   SCM get_property_alist_chain (SCM) const;
88   static SCM ly_grob_set_property (SCM, SCM, SCM);
89   static SCM ly_grob_property (SCM, SCM);
90
91   void warning (String) const;
92   void programming_error (String) const;
93
94   Output_def *get_layout () const;
95   void add_dependency (Grob *);
96   virtual System *get_system () const;
97
98   void calculate_dependencies (int final, int busy, SCM funcname);
99
100   virtual void do_break_processing ();
101   virtual Grob *find_broken_piece (System *) const;
102   virtual void discretionary_processing ();
103   virtual SCM do_derived_mark () const;
104
105   Stencil *get_stencil () const;
106   SCM get_uncached_stencil () const;
107
108   void suicide ();
109   bool is_live () const;
110   bool is_empty (Axis a) const;
111
112   bool internal_has_interface (SCM intf);
113   static bool has_interface (Grob *me);
114
115   virtual void handle_broken_dependencies ();
116   virtual void handle_prebroken_dependencies ();
117
118   Interval extent (Grob *refpoint, Axis) const;
119
120   void translate_axis (Real, Axis);
121   Real relative_coordinate (Grob const *refp, Axis) const;
122   Grob *common_refpoint (Grob const *s, Axis a) const;
123
124   // duh. slim down interface here. (todo)
125   bool has_offset_callback (SCM callback, Axis) const;
126   void add_offset_callback (SCM callback, Axis);
127   bool has_extent_callback (SCM, Axis) const;
128   void flush_extent_cache (Axis);
129   void set_extent (SCM, Axis);
130   void set_extent_callback (SCM, Axis);
131   Real get_offset (Axis a) const;
132
133   void set_parent (Grob *e, Axis);
134
135   // URG
136   Grob *get_parent (Axis a) const;
137   void fixup_refpoint ();
138 };
139
140 DECLARE_UNSMOB (Grob, grob);
141 Spanner *unsmob_spanner (SCM);
142 Item *unsmob_item (SCM);
143
144 Grob *common_refpoint_of_list (SCM elt_list, Grob *, Axis a);
145 Grob *common_refpoint_of_array (Link_array<Grob> const &, Grob *, Axis a);
146
147 void set_break_subsititution (SCM criterion);
148 SCM substitute_object_alist (SCM alist, SCM dest);
149
150 Link_array<Grob> ly_scm2grobs (SCM ell);
151 SCM ly_grobs2scm (Link_array<Grob> a);
152
153 Interval robust_relative_extent (Grob *, Grob *, Axis);
154
155 #endif /* GROB_HH */