source file of the GNU LilyPond music typesetter
- (c) 1997--1998 Han-Wen Nienhuys <hanwen@stack.nl>
+ (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-#include <ctype.h>
-#include "clef-item.hh"
+
+#include "clef.hh"
#include "string.hh"
#include "molecule.hh"
-#include "paper-def.hh"
-#include "lookup.hh"
-#include "clef-grav.hh"
-#include "text-item.hh"
+#include "item.hh"
-void
-Clef_item::do_pre_processing()
-{
- change_b_ = ! (break_status_i() == 1);
-
- if (default_b_)
- {
- set_empty(break_status_i() != 1);
- transparent_b_ = (break_status_i() != 1);
- }
-}
+/*
+FIXME: should use symbol.
-Clef_item::Clef_item()
+*/
+MAKE_SCHEME_CALLBACK(Clef,before_line_breaking);
+SCM
+Clef::before_line_breaking (SCM smob)
{
- breakable_b_ =true;
- default_b_ = false;
- change_b_ = true;
- octave_dir_ = CENTER;
- read ("violin");
- // Ugh: This should be const, I guess.
- octave_marker_td_p_ = new Text_def();
- octave_marker_td_p_->text_str_ = "8";
- octave_marker_td_p_->style_str_ = "italic";
-}
+ Item * s = dynamic_cast<Item*> (unsmob_element (smob));
-/*
- * 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")
+ SCM style_sym =s->get_elt_property ("style");
+ String style;
+ if (gh_string_p (style_sym))
+ style = ly_scm2string (style_sym);
+
+ SCM glyph = s->get_elt_property ("glyph");
+
+ if (gh_string_p (glyph))
{
- symbol_ = "bass";
- y_position_i_ = 2;
+ String str = ly_scm2string (glyph);
+
+ /*
+ FIXME: should use fontsize property to set clef changes.
+ */
+ if (s->get_elt_property ("non-default") &&
+ s->break_status_dir() != RIGHT && style != "fullSizeChanges")
+ {
+ str += "_change";
+ s->set_elt_property ("glyph", ly_str02scm (str.ch_C()));
+ }
}
- else if (t == "subbass")
+ else
{
- symbol_ = "bass";
- y_position_i_ = 4;
+ s->suicide ();
+ return SCM_UNDEFINED;
}
- 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;
- }
+
+ return SCM_UNDEFINED;
}
-void
-Clef_item::read (Clef_engraver const &k)
+bool
+Clef::has_interface (Score_element* me)
{
- read (k.clef_type_str_);
- octave_dir_ = k.octave_dir_;
+ return me->has_interface (ly_symbol2scm ("clef-interface"));
}
-Molecule*
-Clef_item::brew_molecule_p() const
+
+void
+Clef::set_interface (Score_element* me)
{
- String t = symbol_;
- if (change_b_)
- t += "_change";
- Atom s = paper()->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)));
- return output;
+ me->set_interface (ly_symbol2scm ("clef-interface"));
}
-IMPLEMENT_IS_TYPE_B1(Clef_item,Item);