TODO
Glissando
+
+ merge rulesym and filledbox.
*/
#include <ctype.h>
Adobe_font_char_metric cm = afm_l_->find_char (s, warn);
Molecule m;
if (cm.code () < 0)
- return m;
-
+ {
+ /*
+ don't want people relying on this kind of dimension.
+ */
+ m.set_empty (false);
+ return m;
+ }
+
Atom at (gh_list (char_scm_sym,
gh_int2scm (cm.code ()),
SCM_UNDEFINED));
}
Atom at
- (gh_list (ly_symbol ("dashed-slur"),
- gh_double2scm (thick),
- gh_double2scm (dash),
- ly_quote_scm (array_to_list (sc, 4)),
- SCM_UNDEFINED));
+ (gh_list (ly_symbol ("dashed-slur"),
+ gh_double2scm (thick),
+ gh_double2scm (dash),
+ ly_quote_scm (array_to_list (sc, 4)),
+ SCM_UNDEFINED));
m.add_atom (&at);
Lookup::rule_symbol (Real height, Real width) const
{
Atom at (gh_list (rulesym_scm_sym,
- gh_double2scm (height),
- gh_double2scm (width),
- SCM_UNDEFINED));
+ gh_double2scm (height),
+ gh_double2scm (width),
+ SCM_UNDEFINED));
Molecule m;
m.dim_.x () = Interval (0, width);
Molecule m;
Atom at (gh_list (filledbox_scm_sym,
- gh_double2scm (-b[X_AXIS][LEFT]),
- gh_double2scm (b[X_AXIS][RIGHT]),
- gh_double2scm (-b[Y_AXIS][DOWN]),
- gh_double2scm (b[Y_AXIS][UP]),
- SCM_UNDEFINED));
+ gh_double2scm (-b[X_AXIS][LEFT]),
+ gh_double2scm (b[X_AXIS][RIGHT]),
+ gh_double2scm (-b[Y_AXIS][DOWN]),
+ gh_double2scm (b[Y_AXIS][UP]),
+ SCM_UNDEFINED));
m.dim_ = b;
m.add_atom (&at);
/*
UGH.
- */
+ */
SCM l = gh_eval_str (("(style-to-cmr \"" + style + "\")").ch_C());
if (l != SCM_BOOL_F)
{
}
-/*
- */
Molecule
Lookup::time_signature (int num, int den) const
{
String sty = "number";
Molecule n (text (sty, to_str (num)));
Molecule d (text (sty, to_str (den)));
- n.do_center (X_AXIS);
- d.do_center (X_AXIS);
+ n.align_to (X_AXIS, CENTER);
+ d.align_to (X_AXIS, CENTER);
Molecule m;
if (den)
{
else
{
m = n;
- m.do_center (Y_AXIS);
+ m.align_to (Y_AXIS, CENTER);
}
return m;
}
Molecule m;
Atom at (gh_list (pianobrace_scm_sym,
- gh_double2scm (y),
- SCM_UNDEFINED
- ));
+ gh_double2scm (y),
+ SCM_UNDEFINED
+ ));
m.dim_[Y_AXIS] = Interval (-y/2,y/2);
m.dim_[X_AXIS] = Interval (0,0);
String hairpin = String (decresc ? "de" : "") + "crescendo";
Atom at (gh_list (ly_symbol (hairpin),
- gh_double2scm (width),
- gh_double2scm (height),
- gh_double2scm (continued ? height/2 : 0.0),
- SCM_UNDEFINED));
+ gh_double2scm (width),
+ gh_double2scm (height),
+ gh_double2scm (continued ? height/2 : 0.0),
+ SCM_UNDEFINED));
m.dim_.x () = Interval (0, width);
m.dim_.y () = Interval (-2*height, 2*height);
{
t = paper_l_->get_realvar (thick);
}
-
+
+ Real interline_f = paper_l_->get_realvar (interline_scm_sym);
Atom at (gh_list(tuplet_scm_sym,
- gh_double2scm (dx),
- gh_double2scm (dy),
- gh_double2scm (t),
- gh_int2scm (dir),
- SCM_UNDEFINED));
-m.add_atom (&at);
+ gh_double2scm (interline_f),
+ gh_double2scm (dx),
+ gh_double2scm (dy),
+ gh_double2scm (t),
+ gh_int2scm (dir),
+ SCM_UNDEFINED));
+ m.add_atom (&at);
return m;
}
Atom at (gh_list (ly_symbol ("bezier-sandwich"),
- ly_quote_scm (array_to_list (scontrols, 8)),
- SCM_UNDEFINED));
+ ly_quote_scm (array_to_list (scontrols, 8)),
+ SCM_UNDEFINED));
m.dim_[X_AXIS] = Interval (0, delta_off[X_AXIS]);
m.dim_[Y_AXIS] = Interval (0 <? delta_off[Y_AXIS], 0 >? delta_off[Y_AXIS]);
{
Molecule m;
Atom at ( gh_list (bracket_scm_sym,
- gh_double2scm (y),
- SCM_UNDEFINED));
+ gh_double2scm (y),
+ SCM_UNDEFINED));
m.add_atom (&at);
m.dim_[Y_AXIS] = Interval (-y/2,y/2);
m.dim_[X_AXIS] = Interval (0,4 PT);
t = paper_l_->get_realvar (thick);
}
Atom at (gh_list (volta_scm_sym,
- gh_double2scm (w),
- gh_double2scm (t),
- gh_int2scm (last_b),
- SCM_UNDEFINED));
+ gh_double2scm (w),
+ gh_double2scm (t),
+ gh_int2scm (last_b),
+ SCM_UNDEFINED));
Real interline_f = paper_l_->get_realvar (interline_scm_sym);
{
UNBOX_ATOM(UNBOX_PTR(ptr))->off_ += o;
}
- dim_.translate (o);
+ if (!empty_b ())
+ dim_.translate (o);
}
void
for (CELLTYPE ptr = atom_list_; ptr != MOL_EOL; ptr = NEXT_CELL(ptr))
UNBOX_ATOM (UNBOX_PTR(ptr))->off_[a] += x;
- dim_[a] += x;
+ if (!empty_b ())
+ dim_[a] += x;
}
void
atom_list_ = NEWCELL(BOX_ATOM(a), atom_list_);
}
-
-
-
void
Molecule::operator=(Molecule const & src)
{
- if (&src == this)
- return;
-
-
+ if (&src == this) return;
#ifndef ATOM_SMOB
delete atom_list_;
add_molecule (src);
}
+void
+Molecule::set_empty (bool e)
+{
+ if (e)
+ {
+ dim_[X_AXIS].set_empty ();
+ dim_[Y_AXIS].set_empty ();
+ }
+ else
+ {
+ dim_[X_AXIS] = Interval(0,0);
+ dim_[Y_AXIS] = Interval (0,0);
+ }
+}
+
Molecule::Molecule (Molecule const &s)
{
atom_list_ = MOL_EOL;
+ set_empty (true);
add_molecule (s);
}
}
void
-Molecule::do_center (Axis a)
+Molecule::align_to (Axis a, Direction d)
{
- Interval i (extent (a));
- translate_axis (-i.center (), a);
+ if (d == CENTER)
+ {
+ Interval i (extent (a));
+ translate_axis (-i.center (), a);
+ }
+ else
+ {
+ translate_axis (-extent (a)[d], a);
+ }
}
Molecule::Molecule ()
{
- dim_ = Box (Interval(0,0),Interval( 0,0 ));
+ dim_[X_AXIS].set_empty ();
+ dim_[Y_AXIS].set_empty ();
atom_list_ = MOL_EOL;
}
void
Molecule::add_at_edge (Axis a, Direction d, Molecule const &m, Real padding)
{
- Real my_extent= dim_[a][d];
+ Real my_extent= empty_b () ? 0.0 : dim_[a][d];
+ Interval i (m.extent ()[a]);
+ if (i.empty_b ())
+ warning ("Molecule::add_at_edge: adding empty molecule. [PROGRAMMING ERROR]");
- Real offset = my_extent - m.extent ()[a][-d];
+ Real his_extent = i[-d];
+ Real offset = my_extent - his_extent;
Molecule toadd (m);
toadd.translate_axis (offset + d * padding, a);
add_molecule (toadd);
}
bool
-Molecule::empty_b() const
+Molecule::empty_b () const
{
return atom_list_ == MOL_EOL;
}