2 score-element.hh -- declare Score_element
4 (c) 1996-1999--2000 Han-Wen Nienhuys
11 #include "virtual-methods.hh"
12 #include "lily-guile.hh"
13 #include "lily-proto.hh"
15 #include "dimension-cache.hh"
17 typedef Interval (*Extent_callback)(Score_element const *,Axis);
18 typedef Real (*Offset_callback)(Score_element const *,Axis);
20 #define READONLY_PROPS // FIXME.
24 for administration of what was done already
26 enum Score_element_status {
27 ORPHAN=0, // not yet added to pstaff
28 VIRGIN, // added to pstaff
30 PRECALCED, // calcs before spacing done
31 POSTCALCING, // busy calculating. This is used to trap cyclic deps.
32 POSTCALCED, // after spacing calcs done
37 typedef void (Score_element::*Score_element_method_pointer) (void);
44 transparent -- boolean: if true, do not print anything black.
46 dependencies -- list of score-element pointers that indicate who to
49 interfaces -- list of symbols indicating the interfaces supported
52 extra-offset -- pair of reals (a cons) forcing an extra offset
55 glyph -- afm character name to output.
60 The lookup, determined by the font size. Cache this value.
65 properties specific for this element. Destructor will not call
66 scm_unprotect, so as to allow more flexible GC arrangements. The
67 real alist is in (cdr element_property_alist_), to reduce the
68 need for more scm_protect calls.
74 #ifndef READONLY_PROPS
75 SCM basic_property_list_;
78 Score_element *original_l_;
81 Administration: Where are we?. This is mainly used by Super_element and
82 Score_element::calcalute_dependencies ()
87 char const * name () const;
90 IDEA: make this a global variable. This is the same for all
91 elements, I think it is safe to assume that we will not have
92 scores being formatted multithreadedly.
94 Paper_score *pscore_l_;
96 Score_element (SCM basic_props);
97 Score_element (Score_element const&);
102 SCM get_elt_property (String nm) const;
103 void set_elt_property (String, SCM val);
106 Pointers are like properties, but they are subject to a substitution
109 SCM get_elt_pointer (const char*) const;
110 void set_elt_pointer (const char*, SCM val);
111 friend class Property_engraver; // UGHUGHUGH.
115 This gets messy because it changes state
121 s->remove_elt_property ("foo")
124 twice may do weird things if Bar::foo has a default set.
127 SCM remove_elt_property (const char* nm);
132 Paper_def *paper_l () const;
133 Lookup const *lookup_l () const;
135 void add_processing ();
138 add a dependency. It may be the 0 pointer, in which case, it is ignored.
140 void add_dependency (Score_element*);
141 virtual Line_of_score * line_l () const;
142 bool linked_b () const;
145 VIRTUAL_COPY_CONS(Score_element);
148 Recursively track all dependencies of this Score_element. The
149 status_i_ field is used as a mark-field. It is marked with
150 #busy# during execution of this function, and marked with #final#
153 #funcptr# is the function to call to update this element.
155 void calculate_dependencies (int final, int busy, Score_element_method_pointer funcptr);
158 static SCM handle_broken_smobs (SCM, SCM criterion);
160 virtual void do_break_processing ();
161 virtual Score_element *find_broken_piece (Line_of_score*) const;
162 /// generate rods & springs
163 virtual void do_space_processing ();
164 virtual void discretionary_processing ();
166 /// do calculations before determining horizontal spacing
167 virtual void before_line_breaking ();
168 /// do calculations after determining horizontal spacing
169 virtual void after_line_breaking ();
171 Molecule get_molecule () const;
174 static Interval preset_extent (Score_element const*,Axis);
175 static Interval point_dimension_callback (Score_element const*,Axis );
176 static Interval molecule_extent (Score_element const*,Axis);
181 Junk score element. This is protected because this is supposed to
182 be handled by GUILE gc. */
183 virtual ~Score_element ();
185 /// generate the molecule
186 virtual Molecule do_brew_molecule () const;
187 ///executed directly after the item is added to the Paper_score
188 virtual void do_add_processing ();
190 static Interval dim_cache_callback (Dimension_cache const*);
193 static SCM ly_set_elt_property (SCM, SCM,SCM);
194 static SCM ly_get_elt_property (SCM, SCM);
196 virtual void handle_broken_dependencies ();
197 virtual void handle_prebroken_dependencies ();
204 Dimension_cache dim_cache_[NO_AXES];
207 bool empty_b (Axis a) const;
208 Interval extent (Axis) const;
211 translate in one direction
214 void translate_axis (Real, Axis);
217 Find the offset relative to D. If D equals THIS, then it is 0.
218 Otherwise, it recursively defd as
220 OFFSET_ + PARENT_L_->relative_coordinate (D)
222 Real relative_coordinate (Score_element const* refp, Axis) const;
224 Find the group-element which has both #this# and #s#
226 Score_element*common_refpoint (Score_element const* s, Axis a) const;
227 Score_element*common_refpoint (SCM elt_list, Axis a) const;
229 bool has_offset_callback_b (Offset_callback, Axis)const;
230 void add_offset_callback (Offset_callback, Axis);
231 bool has_extent_callback_b (Extent_callback, Axis)const;
232 void set_extent_callback (Extent_callback , Axis);
235 Invoke callbacks to get offset relative to parent.
237 Real get_offset (Axis a) const;
239 Set the parent refpoint of THIS to E
241 void set_parent (Score_element* e, Axis);
243 Score_element *parent_l (Axis a) const;
244 void fixup_refpoint ();
247 Score_element * unsmob_element (SCM);
251 #endif // STAFFELEM_HH