X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fclef-item.cc;h=285d904a099bdfc45a0ca707b1b5a4c0cd851bd8;hb=1cf3d59c1559fb9774c4c1c8cae155cfe54a927c;hp=234b85fbb4af1963ba0466d896e7f5903255bc42;hpb=1e95a0be01466d1c98644f7705c8e07e41cc645c;p=lilypond.git diff --git a/lily/clef-item.cc b/lily/clef-item.cc index 234b85fbb4..285d904a09 100644 --- a/lily/clef-item.cc +++ b/lily/clef-item.cc @@ -3,7 +3,7 @@ source file of the GNU LilyPond music typesetter - (c) 1997--1998 Han-Wen Nienhuys + (c) 1997--1998 Han-Wen Nienhuys */ #include @@ -12,18 +12,19 @@ #include "molecule.hh" #include "paper-def.hh" #include "lookup.hh" -#include "clef-grav.hh" +#include "clef-engraver.hh" #include "text-item.hh" void Clef_item::do_pre_processing() { - change_b_ = ! (break_status_i() == 1); + bool b= (break_status_dir() != RIGHT); + change_b_ = b; if (default_b_) { - set_empty(break_status_i() != 1); - transparent_b_ = (break_status_i() != 1); + set_empty(b); + transparent_b_ = b; } } @@ -33,107 +34,21 @@ Clef_item::Clef_item() default_b_ = false; change_b_ = true; octave_dir_ = CENTER; - read ("violin"); + symbol_ = "violin"; + y_position_i_ = -2; + // Ugh: This should be const, I guess. - octave_marker_td_p_ = new Text_def(); + octave_marker_td_p_.set_p (new Text_def()); octave_marker_td_p_->text_str_ = "8"; octave_marker_td_p_->style_str_ = "italic"; } -/* - * Convert input clef string to - * a clef symbol and a line position. - * This would be better done in the lexer (more efficient) - * or as a table-lookup. - */ -void -Clef_item::read (String t) -{ - symbol_= t; - if (t == "violin") - { - y_position_i_ = -2; - } - else if (t == "bass") - { - y_position_i_ = 2; - } - else if (t == "G" || t == "G2" || t == "treble") - { - symbol_ = "violin"; - y_position_i_ = -2; - } - else if (t == "french" || t == "G1") - { - symbol_="violin"; - y_position_i_ = -4; - } - else if (t == "soprano" || t == "C1") - { - symbol_="alto"; - y_position_i_ = -4; - } - else if (t == "mezzosoprano" || t == "C2") - { - symbol_ = "alto"; - y_position_i_ = -2; - } - else if (t == "alto") - { - symbol_ = "alto"; - y_position_i_ = 0; - } - else if (t == "C3") - { - symbol_ = "alto"; - y_position_i_ = 0; - } - else if (t == "tenor" || t == "C4") - { - symbol_ = "alto"; - y_position_i_ = 2; - } - else if (t == "baritone" || t == "C5") - { - symbol_ = "alto"; - y_position_i_ = 4; - } - else if (t == "varbaritone" || t == "F3") - { - symbol_ = "bass"; - y_position_i_ = 0; - } - else if (t == "F" || t == "F4") - { - symbol_ = "bass"; - y_position_i_ = 2; - } - else if (t == "subbass") - { - symbol_ = "bass"; - y_position_i_ = 4; - } - else if (isdigit(t[1])) - switch (t[0]) - { // we've already dealt with plain F, G or C clef - // position 0 is line 3. - case 'G': - case 'g': - symbol_ = "violin"; - y_position_i_ = 2 * (t[1] - '0') - 6; - break; - case 'F': - case 'f': - symbol_ = "bass"; - y_position_i_ = 2 * (t[1] - '0') - 6; - break; - } -} void Clef_item::read (Clef_engraver const &k) { - read (k.clef_type_str_); + symbol_ = k.clef_type_str_; + y_position_i_ = k.clef_position_i_; octave_dir_ = k.octave_dir_; } @@ -143,16 +58,26 @@ Clef_item::brew_molecule_p() const String t = symbol_; if (change_b_) t += "_change"; - Atom s = paper()->lookup_l ()->clef (t); + Atom s = lookup_l ()->clef (t); Molecule*output = new Molecule (Atom (s)); output->translate_axis (paper()->internote_f () * y_position_i_, Y_AXIS); - if (octave_dir_) - output->add_at_edge (Y_AXIS, - octave_dir_, - Molecule(octave_marker_td_p_->get_atom(paper(), - CENTER))); + if (octave_dir_) { + Molecule octave_marker = Molecule(octave_marker_td_p_->get_atom(paper(), + CENTER)); + Real offset = output->extent()[Y_AXIS][octave_dir_] + - octave_marker.extent()[Y_AXIS][- octave_dir_]; + if (octave_dir_ == DOWN) + offset += octave_marker.extent()[Y_AXIS][UP] * 0.35 ; + octave_marker.translate_axis (offset, Y_AXIS); + output->add_molecule (octave_marker); + } return output; } IMPLEMENT_IS_TYPE_B1(Clef_item,Item); + +#include "pointer.tcc" +template class P; // ugh + +