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 *,Axis);
18 typedef Real (*Offset_callback)(Score_element *,Axis);
23 for administration of what was done already
25 enum Score_element_status {
26 ORPHAN=0, // not yet added to pstaff
27 VIRGIN, // added to pstaff
29 PRECALCED, // calcs before spacing done
30 POSTCALCING, // busy calculating. This is used to trap cyclic deps.
31 POSTCALCED, // after spacing calcs done
36 typedef void (Score_element::*Score_element_method_pointer) (void);
43 transparent -- boolean: if true, do not print anything black.
45 dependencies -- list of score-element pointers that indicate who to
48 interfaces -- list of symbols indicating the interfaces supported
51 extra-offset -- pair of reals (a cons) forcing an extra offset
54 glyph -- afm character name to output.
59 The lookup, determined by the font size. Cache this value.
64 properties specific for this element. Destructor will not call
65 scm_unprotect, so as to allow more flexible GC arrangements. The
66 real alist is in (cdr element_property_alist_), to reduce the
67 need for more scm_protect calls.
71 SCM immutable_property_alist_;
72 SCM mutable_property_alist_;
75 Score_element *original_l_;
78 Administration: Where are we?. This is mainly used by Super_element and
79 Score_element::calcalute_dependencies ()
84 char const * name () const;
87 IDEA: make this a global variable. This is the same for all
88 elements, I think it is safe to assume that we will not have
89 scores being formatted multithreadedly.
91 Paper_score *pscore_l_;
93 Score_element (SCM basic_props);
94 Score_element (Score_element const&);
99 SCM get_elt_property (const char*) const;
100 SCM get_elt_property (SCM) const;
101 void set_elt_property (const char * , SCM val);
102 void set_immutable_elt_property (const char * , SCM val);
103 void set_immutable_elt_property (SCM key, SCM val);
104 void set_elt_property (SCM , SCM val);
105 void set_elt_pointer (const char*, SCM val);
106 friend class Property_engraver; // UGHUGHUGH.
107 SCM remove_elt_property (const char* nm);
112 Paper_def *paper_l () const;
113 Lookup const *lookup_l () const;
115 void add_processing ();
118 add a dependency. It may be the 0 pointer, in which case, it is ignored.
120 void add_dependency (Score_element*);
121 virtual Line_of_score * line_l () const;
122 bool linked_b () const;
125 VIRTUAL_COPY_CONS(Score_element);
128 Recursively track all dependencies of this Score_element. The
129 status_i_ field is used as a mark-field. It is marked with
130 #busy# during execution of this function, and marked with #final#
133 #funcptr# is the function to call to update this element.
135 void calculate_dependencies (int final, int busy, SCM funcname);
138 static SCM handle_broken_smobs (SCM, SCM criterion);
140 virtual void do_break_processing ();
141 virtual Score_element *find_broken_piece (Line_of_score*) const;
142 /// generate rods & springs
143 virtual void do_space_processing ();
144 virtual void discretionary_processing ();
145 virtual void do_derived_mark ();
147 Molecule get_molecule () const;
150 static Interval preset_extent (Score_element *,Axis);
151 static Interval point_dimension_callback (Score_element *,Axis );
152 static Interval molecule_extent (Score_element *,Axis);
156 Junk score element. This is protected because this is supposed to
157 be handled by GUILE gc. */
158 virtual ~Score_element ();
160 ///executed directly after the item is added to the Paper_score
161 virtual void do_add_processing ();
162 static Interval dim_cache_callback (Dimension_cache const*);
165 static SCM ly_set_elt_property (SCM, SCM,SCM);
166 static SCM ly_get_elt_property (SCM, SCM);
168 bool has_interface (SCM intf);
169 void set_interface (SCM intf);
172 static SCM brew_molecule (SCM);
173 virtual void handle_broken_dependencies ();
174 virtual void handle_prebroken_dependencies ();
181 Dimension_cache dim_cache_[NO_AXES];
184 bool empty_b (Axis a) const;
185 Interval extent (Axis) const;
188 translate in one direction
191 void translate_axis (Real, Axis);
194 Find the offset relative to D. If D equals THIS, then it is 0.
195 Otherwise, it recursively defd as
197 OFFSET_ + PARENT_L_->relative_coordinate (D)
199 Real relative_coordinate (Score_element const* refp, Axis) const;
201 Find the group-element which has both #this# and #s#
203 Score_element*common_refpoint (Score_element const* s, Axis a) const;
204 Score_element*common_refpoint (SCM elt_list, Axis a) const;
206 bool has_offset_callback_b (Offset_callback, Axis)const;
207 void add_offset_callback (Offset_callback, Axis);
208 bool has_extent_callback_b (Extent_callback, Axis)const;
209 void set_extent_callback (Extent_callback , Axis);
212 Invoke callbacks to get offset relative to parent.
214 Real get_offset (Axis a) const;
216 Set the parent refpoint of THIS to E
218 void set_parent (Score_element* e, Axis);
220 Score_element *parent_l (Axis a) const;
221 static SCM fixup_refpoint (SCM);
224 Score_element * unsmob_element (SCM);
226 #endif // STAFFELEM_HH