2 molecule.cc -- implement Molecule
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 ugh. Rewrite not finished yet. Still must copy atom lists.
16 #include "font-metric.hh"
17 #include "dimensions.hh"
18 #include "interval.hh"
20 #include "molecule.hh"
23 #include "killing-cons.tcc"
27 Molecule::extent() const
33 Molecule::extent(Axis a) const
38 Molecule::Molecule (Box b, SCM func)
51 Molecule::translate (Offset o)
57 || isinf (o[a]) || isnan (o[a]))
59 programming_error ("Improbable offset for translation: setting to zero");
65 expr_ = gh_list (ly_symbol2scm ("translate-molecule"),
67 expr_, SCM_UNDEFINED);
74 Molecule::translate_axis (Real x,Axis a)
84 Molecule::add_molecule (Molecule const &m)
86 expr_ = gh_list (ly_symbol2scm ("combine-molecule"),
88 expr_, SCM_UNDEFINED);
93 Molecule::set_empty (bool e)
97 dim_[X_AXIS].set_empty ();
98 dim_[Y_AXIS].set_empty ();
102 dim_[X_AXIS] = Interval(0,0);
103 dim_[Y_AXIS] = Interval (0,0);
109 Molecule::align_to (Axis a, Direction d)
111 Interval i (extent (a));
112 Real r = (d == CENTER) ? i.center () : i[d];
113 translate_axis (-r, a);
118 Molecule::add_at_edge (Axis a, Direction d, Molecule const &m, Real padding)
120 Real my_extent= empty_b () ? 0.0 : dim_[a][d];
121 Interval i (m.extent ()[a]);
123 programming_error ("Molecule::add_at_edge: adding empty molecule.");
125 Real his_extent = i[-d];
126 Real offset = my_extent - his_extent;
128 toadd.translate_axis (offset + d * padding, a);
129 add_molecule (toadd);
133 Molecule::empty_b () const
135 return expr_ == SCM_EOL;
140 fontify_atom(Font_metric * met, SCM f)
142 return gh_list (ly_symbol2scm ("fontify"),
143 ly_quote_scm (met->description ()), f, SCM_UNDEFINED);