2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 1996--2012 Han-Wen Nienhuys
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
24 #include "virtual-methods.hh"
25 #include "dimension-cache.hh"
26 #include "grob-interface.hh"
34 DECLARE_CLASSNAME (Grob);
40 Dimension_cache dim_cache_[NO_AXES];
45 SCM immutable_property_alist_;
46 SCM mutable_property_alist_;
50 If this is a property, it accounts for 25% of the property
55 void substitute_object_links (SCM, SCM);
56 Real get_offset (Axis a) const;
57 SCM try_callback (SCM, SCM);
58 SCM try_callback_on_alist (SCM *, SCM, SCM);
59 void internal_set_value_on_alist (SCM *alist, SCM sym, SCM val);
66 friend SCM ly_grob_properties (SCM);
67 friend SCM ly_grob_basic_properties (SCM);
69 /* standard callbacks */
70 DECLARE_SCHEME_CALLBACK (x_parent_positioning, (SCM));
71 DECLARE_SCHEME_CALLBACK (y_parent_positioning, (SCM));
72 DECLARE_SCHEME_CALLBACK (stencil_height, (SCM smob));
73 DECLARE_SCHEME_CALLBACK (stencil_width, (SCM smob));
74 DECLARE_SCHEME_CALLBACK (simple_vertical_skylines_from_stencil, (SCM smob));
75 DECLARE_SCHEME_CALLBACK (vertical_skylines_from_stencil, (SCM smob));
76 DECLARE_SCHEME_CALLBACK (vertical_skylines_from_element_stencils, (SCM smob));
77 DECLARE_SCHEME_CALLBACK (simple_horizontal_skylines_from_stencil, (SCM smob));
78 DECLARE_SCHEME_CALLBACK (horizontal_skylines_from_stencil, (SCM smob));
79 DECLARE_SCHEME_CALLBACK (horizontal_skylines_from_element_stencils, (SCM smob));
82 Output_def *layout () const { return layout_; }
83 Grob *original () const { return original_; }
84 SCM interfaces () const { return interfaces_; }
87 Grob (SCM basic_props);
89 virtual Grob *clone () const;
93 bool is_live () const;
99 SCM get_property_alist_chain (SCM) const;
100 SCM internal_get_property (SCM symbol) const;
101 SCM internal_get_property_data (SCM symbol) const;
102 SCM internal_get_pure_property (SCM symbol, int start, int end) const;
103 SCM internal_get_maybe_pure_property (SCM symbol, bool pure, int start, int end) const;
104 SCM internal_get_non_callback_marker_property_data (SCM symbol) const;
105 SCM internal_get_object (SCM symbol) const;
106 void internal_set_object (SCM sym, SCM val);
107 void internal_del_property (SCM symbol);
108 void instrumented_set_property (SCM, SCM, char const *, int, char const *);
109 void internal_set_property (SCM sym, SCM val);
112 void warning (string) const;
113 void programming_error (string) const;
115 /* class hierarchy */
116 virtual System *get_system () const;
117 static System *get_system (Grob *);
118 virtual void do_break_processing ();
119 virtual Grob *find_broken_piece (System *) const;
120 virtual void discretionary_processing ();
121 virtual void derived_mark () const;
122 virtual void handle_broken_dependencies ();
123 virtual void handle_prebroken_dependencies ();
126 Stencil *get_stencil () const;
127 Stencil get_print_stencil () const;
130 bool internal_has_interface (SCM intf);
131 DECLARE_GROB_INTERFACE ();
134 void translate_axis (Real, Axis);
135 Real relative_coordinate (Grob const *refp, Axis) const;
136 Real pure_relative_y_coordinate (Grob const *refp, int start, int end);
137 Real maybe_pure_coordinate (Grob const *refp, Axis a, bool pure, int start, int end);
140 Interval extent (Grob *refpoint, Axis) const;
141 void flush_extent_cache (Axis);
142 virtual Interval pure_height (Grob *refpoint, int start_col, int end_col);
143 Interval maybe_pure_extent (Grob *refpoint, Axis, bool pure, int start, int end);
146 Grob *common_refpoint (Grob const *s, Axis a) const;
147 void set_parent (Grob *e, Axis);
148 Grob *get_parent (Axis a) const;
149 void fixup_refpoint ();
151 /* vertical ordering */
152 static bool internal_vertical_less (Grob *g1, Grob *g2, bool pure);
153 static Grob *get_root_vertical_alignment (Grob *g);
154 static Grob *get_vertical_axis_group (Grob *g);
155 static bool vertical_less (Grob *g1, Grob *g2);
156 static bool pure_vertical_less (Grob *g1, Grob *g2);
157 static int get_vertical_axis_group_index (Grob *g);
160 virtual Interval_t<int> spanned_rank_interval () const;
161 virtual bool pure_is_visible (int start, int end) const;
162 bool check_cross_staff (Grob *common);
163 static bool less (Grob *g1, Grob *g2);
164 static SCM internal_simple_skylines_from_stencil (SCM, Axis);
165 static SCM internal_skylines_from_element_stencils (SCM, Axis);
169 DECLARE_UNSMOB (Grob, grob);
170 Spanner *unsmob_spanner (SCM);
171 Item *unsmob_item (SCM);
174 Grob *common_refpoint_of_list (SCM elt_list, Grob *, Axis a);
175 Grob *common_refpoint_of_array (vector<Grob *> const &, Grob *, Axis a);
176 Grob *common_refpoint_of_array (set<Grob *> const &, Grob *, Axis a);
177 System *get_root_system (Grob *me);
180 Interval robust_relative_extent (Grob *, Grob *, Axis);
182 /* offset/extent callbacks. */
183 void add_offset_callback (Grob *g, SCM proc, Axis a);
184 void chain_offset_callback (Grob *g, SCM proc, Axis a);
185 void chain_callback (Grob *g, SCM proc, SCM sym);
186 SCM axis_offset_symbol (Axis a);
187 SCM axis_parent_positioning (Axis a);
189 SCM call_pure_function (SCM unpure, SCM args, int start, int end);
191 void set_nested_property (Grob *, SCM property_path, SCM value);