X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Frest.cc;h=b3e5668d35c303f28e7f8e1829cc46cf18d50178;hb=df4a7c4a55148e065d878dcc2f7e09ac27ea9c32;hp=acfcc3617b6d3e65e5782b56c0c8442d37ff5165;hpb=622b379cd71af8dde94f68135a489b2536309e6f;p=lilypond.git diff --git a/lily/rest.cc b/lily/rest.cc index acfcc3617b..b3e5668d35 100644 --- a/lily/rest.cc +++ b/lily/rest.cc @@ -1,50 +1,92 @@ /* - rest.cc -- implement Rest + rest.cc -- implement Rest source file of the GNU LilyPond music typesetter - (c) 1997--1998 Han-Wen Nienhuys + (c) 1997--2000 Han-Wen Nienhuys */ #include "molecule.hh" #include "paper-def.hh" -#include "lookup.hh" +#include "font-interface.hh" #include "rest.hh" #include "dots.hh" -#include "axis-group-element.hh" -#include "p-score.hh" +#include "paper-score.hh" +#include "staff-symbol-referencer.hh" -void -Rest::do_add_processing () +// -> offset callback +MAKE_SCHEME_CALLBACK(Rest,after_line_breaking,1); +SCM +Rest::after_line_breaking (SCM smob) { - if (balltype_i_ > 1) - position_i_ -= 4; - else if (balltype_i_ == 0) - position_i_ += 2; + Grob *me = unsmob_element (smob); + int bt = gh_scm2int (me->get_grob_property ("duration-log")); + if (bt == 0) + { + me->translate_axis (Staff_symbol_referencer::staff_space (me) , Y_AXIS); + } - Rhythmic_head::do_add_processing (); - if (dots_l_ && balltype_i_ > 1) + Grob * d = unsmob_element (me->get_grob_property ("dot")); + if (d && bt > 4) // UGH. { - dots_l_->position_i_ = position_i_ + 4; + d->set_grob_property ("staff-position", + gh_int2scm ((bt == 7) ? 4 : 3)); } -} -Rest::Rest () -{ - position_i_ =0; + return SCM_UNSPECIFIED; } -Molecule * -Rest::do_brew_molecule_p () const + +MAKE_SCHEME_CALLBACK(Rest,brew_molecule,1); + +SCM +Rest::brew_internal_molecule (SCM smob) { - int staff_size_i_ = 8; - bool streepjes_b = abs(position_i_) > staff_size_i_ /2 && - (balltype_i_ == 0 || balltype_i_ == 1); + Grob* me = unsmob_element (smob); + + bool ledger_b =false; + + SCM balltype = me->get_grob_property ("duration-log"); + + if (balltype == gh_int2scm (0) || balltype == gh_int2scm (1)) + { + int sz = Staff_symbol_referencer::line_count (me); + Real dif = abs(Staff_symbol_referencer::position_f (me) - (2* gh_scm2int (balltype) - 1)); + ledger_b = dif > sz; + } - Molecule s(lookup_l ()->rest (balltype_i_, streepjes_b)); - Molecule * m = new Molecule ( Molecule (s)); - m->translate_axis (position_i_ * paper ()->internote_f (), Y_AXIS); - return m; + String style; + SCM style_sym =me->get_grob_property ("style"); + if (gh_scm2int (balltype) >= 2 && gh_symbol_p (style_sym)) + { + style = ly_scm2string (scm_symbol_to_string (style_sym)); + } + + String idx = ("rests-") + to_str (gh_scm2int (balltype)) + + (ledger_b ? "o" : "") + style; + + return Font_interface::get_default_font (me)->find_by_name (idx).smobbed_copy(); } +SCM +Rest::brew_molecule (SCM smob) +{ + return brew_internal_molecule (smob); +} +MAKE_SCHEME_CALLBACK(Rest,extent_callback,2); +/* + We need the callback. The real molecule has ledgers depending on + Y-position. The Y-position is known only after line breaking. */ +SCM +Rest::extent_callback (SCM smob, SCM ax) +{ + Axis a = (Axis) gh_scm2int (ax); + SCM m = brew_internal_molecule (smob); + return ly_interval2scm (unsmob_molecule (m)->extent (a)); +} +bool +Rest::has_interface (Grob*m) +{ + return m && m->has_interface (ly_symbol2scm ("rest-interface")); +}