X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fatom.cc;h=cc2bde40be01f211d289b59360968f200294e2f9;hb=aaa52903d633cdeaa642c20ab42ec268f4e17a2b;hp=48b5c737202b1b126d42d32321c13942750ebe57;hpb=1cf3d59c1559fb9774c4c1c8cae155cfe54a927c;p=lilypond.git diff --git a/lily/atom.cc b/lily/atom.cc index 48b5c73720..cc2bde40be 100644 --- a/lily/atom.cc +++ b/lily/atom.cc @@ -3,107 +3,78 @@ source file of the GNU LilyPond music typesetter - (c) 1997--1998 Han-Wen Nienhuys + (c) 1997--2000 Han-Wen Nienhuys */ +#include +#include "ly-smobs.icc" #include "atom.hh" -#include "tex.hh" #include "interval.hh" -#include "dimension.hh" #include "string.hh" #include "array.hh" #include "debug.hh" +#include "dimensions.hh" +#include "lookup.hh" #include "main.hh" +#include "global-ctor.hh" +#include "font-metric.hh" -inline bool -Atom::check_infinity_b ()const +Atom::Atom(SCM s) { - bool ridiculous = false; -#ifndef NDEBUG - - /* infinity checks. */ - for (int a = X_AXIS; a < NO_AXES; a++) - { - Axis ax = (Axis)a; - if (abs (off_[ax]) >= 100 CM) - { - warning (_f ("ridiculous dimension: %s, %s", axis_name_str (ax), - print_dimen(off_[ax]))); - - if (experimental_features_global_b) - assert (false); - - ((Atom*)this)->off_[ax] = 0.0; - ridiculous = true; - } - } -#endif - return ridiculous; -} - - -void -Atom::print() const -{ -#ifndef NPRINT - DOUT << "texstring: " << tex_ << '\n'; - - DOUT << "dim:"; - for (Axis i=X_AXIS; i < NO_AXES; incr(i)) - DOUT << axis_name_str(i) << " = " << dim_[i].str(); - - DOUT << "\noffset: " << off_.str (); -#endif -} - -Box -Atom::extent() const -{ - Box b (dim_); - b.translate (off_); - return b; + SCM onstack = s; // protection. just to be sure. + func_ = s; + self_scm_ = SCM_EOL; + smobify_self (); } - -Atom::Atom() - : dim_ (Interval (0,0),Interval (0,0)) +SCM +Atom::mark_smob (SCM s) { - tex_ = "\\unknown"; + Atom* a = SMOB_TO_TYPE(Atom, s); + assert (s == a->self_scm_); + return a->func_; } -Atom::Atom (String s, Box b) - : dim_ (b) +void +Atom::fontify (Font_metric * met) { - tex_ = s; + SCM desc = ly_quote_scm (met->description ()); + SCM font_switch = gh_list (ly_symbol2scm ("select-font"), + desc, + SCM_UNDEFINED); + + SCM f =func_; + func_ = gh_list (ly_symbol2scm ("string-append"), + font_switch , f, + SCM_UNDEFINED); } - -String -Atom::str() const +void +Atom::do_smobify_self () { - return String ("Atom (\'") + tex_ + "\', (" + dim_.x().str () + ", " - + dim_.y ().str () + "))"; } -Offset -Atom::offset () const +Atom::Atom (Atom const &s) { - return off_; + off_ = s.off_; + func_ = s.func_; + self_scm_= SCM_EOL; + smobify_self (); } - - - -void -Atom::translate_axis (Real r, Axis a) +int +Atom::print_smob (SCM s, SCM p, scm_print_state*) { - off_[a] += r; - check_infinity_b (); + Atom * a = unsmob_atom (s); + + scm_puts ("#off_.str ()); + scm_puts ((char *)str.ch_C(), p); + scm_display (a->func_, p); + scm_puts ("> ",p); + return 1; } + +IMPLEMENT_UNSMOB(Atom, atom) +IMPLEMENT_SMOBS(Atom) -void -Atom::translate (Offset o) -{ - off_ += o; - check_infinity_b (); -}