lilypond-1.3.100
[lilypond.git] / lily / include / score-element.hh
blob59e4a49e5290406cc754b203a60b0b35d4952086
1 /*
2 score-element.hh -- declare Score_element
4 (c) 1996-1999--2000 Han-Wen Nienhuys
5 */
7 #ifndef STAFFELEM_HH
8 #define STAFFELEM_HH
10 #include "parray.hh"
11 #include "virtual-methods.hh"
12 #include "lily-guile.hh"
13 #include "lily-proto.hh"
14 #include "smobs.hh"
15 #include "dimension-cache.hh"
17 /**
18 for administration of what was done already
20 enum Score_element_status {
21 ORPHAN=0, // not yet added to Paper_score
22 VIRGIN,
23 PRECALCING,
24 PRECALCED, // calcs before spacing done
25 POSTCALCING, // busy calculating. This is used to trap cyclic deps.
26 POSTCALCED, // after spacing calcs done
29 typedef void (Score_element::*Score_element_method_pointer) (void);
32 Basic output object.
34 class Score_element {
35 public:
36 SCM immutable_property_alist_;
37 SCM mutable_property_alist_;
38 Score_element *original_l_;
40 /**
41 Administration: Where are we?. This is mainly used by Super_element and
42 Score_element::calcalute_dependencies ()
44 0 means ORPHAN,
46 char status_i_;
47 String name () const;
50 IDEA: make this a global variable. This is the same for all
51 elements, I think it is safe to assume that we will not have
52 scores being formatted multithreadedly.
54 Paper_score *pscore_l_;
56 Score_element (SCM basic_props);
57 Score_element (Score_element const&);
60 properties
62 SCM get_elt_property (const char*) const;
63 SCM get_elt_property (SCM) const;
64 void set_elt_property (const char * , SCM val);
65 void set_immutable_elt_property (const char * , SCM val);
66 void set_immutable_elt_property (SCM key, SCM val);
67 void set_elt_property (SCM , SCM val);
68 void set_elt_pointer (const char*, SCM val);
69 friend class Property_engraver; // UGHUGHUGH.
70 SCM remove_elt_property (const char* nm);
73 related classes.
75 Paper_def *paper_l () const;
77 /**
78 add a dependency. It may be the 0 pointer, in which case, it is ignored.
80 void add_dependency (Score_element*);
81 virtual Line_of_score * line_l () const;
82 bool linked_b () const;
85 VIRTUAL_COPY_CONS(Score_element);
87 /**
88 Recursively track all dependencies of this Score_element. The
89 status_i_ field is used as a mark-field. It is marked with
90 #busy# during execution of this function, and marked with #final#
91 when finished.
93 #funcptr# is the function to call to update this element.
95 void calculate_dependencies (int final, int busy, SCM funcname);
96 static SCM handle_broken_smobs (SCM, SCM criterion);
98 virtual void do_break_processing ();
99 virtual Score_element *find_broken_piece (Line_of_score*) const;
100 virtual void discretionary_processing ();
101 virtual SCM do_derived_mark ();
103 Molecule get_molecule () const;
104 void suicide ();
106 DECLARE_SCHEME_CALLBACK(preset_extent, (SCM smob, SCM axis));
107 DECLARE_SCHEME_CALLBACK(point_dimension_callback, (SCM smob, SCM axis));
108 DECLARE_SCHEME_CALLBACK(molecule_extent, (SCM smob, SCM axis));
111 static SCM ly_set_elt_property (SCM, SCM,SCM);
112 static SCM ly_get_elt_property (SCM, SCM);
114 bool has_interface (SCM intf);
115 void set_interface (SCM intf);
117 virtual void handle_broken_dependencies ();
118 virtual void handle_prebroken_dependencies ();
121 DECLARE_SMOBS(Score_element,foo);
123 void init ();
125 Dimension_cache dim_cache_[NO_AXES];
127 public:
128 bool empty_b (Axis a) const;
130 Interval extent (Score_element * refpoint, Axis) const;
133 translate in one direction
136 void translate_axis (Real, Axis);
139 Find the offset relative to D. If D equals THIS, then it is 0.
140 Otherwise, it recursively defd as
142 OFFSET_ + PARENT_L_->relative_coordinate (D)
144 Real relative_coordinate (Score_element const* refp, Axis) const;
146 Find the group-element which has both #this# and #s#
148 Score_element*common_refpoint (Score_element const* s, Axis a) const;
149 Score_element*common_refpoint (SCM elt_list, Axis a) const;
151 // duh. slim down interface here. (todo)
152 bool has_offset_callback_b (SCM callback, Axis)const;
153 void add_offset_callback (SCM callback, Axis);
154 bool has_extent_callback_b (SCM, Axis)const;
155 void set_extent_callback (SCM , Axis);
156 bool has_extent_callback_b (Axis) const;
160 Invoke callbacks to get offset relative to parent.
162 Real get_offset (Axis a) const;
164 Set the parent refpoint of THIS to E
166 void set_parent (Score_element* e, Axis);
168 Score_element *parent_l (Axis a) const;
169 DECLARE_SCHEME_CALLBACK(fixup_refpoint, (SCM));
172 Score_element * unsmob_element (SCM);
174 #endif // STAFFELEM_HH