source file of the GNU LilyPond music typesetter
- (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.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 "g-text-item.hh"
-#include "p-score.hh"
-
-void
-Clef_item::do_pre_processing()
-{
- dim_cache_[Y_AXIS].translate (paper()->internote_f () * y_position_i_);
- change_b_ = (break_status_dir() != RIGHT);
-}
+#include "item.hh"
/*
- FIXME
+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;
- symbol_ = "treble";
- y_position_i_ = -2;
-}
+ Item * s = dynamic_cast<Item*> (unsmob_element (smob));
-void
-Clef_item::do_add_processing ()
-{
- if (!break_status_dir_) // broken stuff takes care of their own texts
+ 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))
{
- SCM defvis = gh_eval_str ("(lambda (d) (if (= d 1) '(#f . #f) '(#t . #t)))");
- G_text_item *g =0;
- if (octave_dir_)
- {
- g = new G_text_item;
- pscore_l_->typeset_element (g);
-
- g->text_str_ = "8";
- g->style_str_ = "italic";
- g->dim_cache_[Y_AXIS].parent_l_ = &dim_cache_[Y_AXIS];
- g->dim_cache_[X_AXIS].parent_l_ = &dim_cache_[X_AXIS];
- add_dependency (g); // just to be sure.
+ String str = ly_scm2string (glyph);
- Real r = do_height ()[octave_dir_] + g->extent (Y_AXIS)[-octave_dir_];
- g->dim_cache_[Y_AXIS].set_offset (r);
- }
- if (default_b_)
+ /*
+ FIXME: should use fontsize property to set clef changes.
+ */
+ if (s->get_elt_property ("non-default") &&
+ s->break_status_dir() != RIGHT && style != "fullSizeChanges")
{
- visibility_lambda_ = defvis;
- if (g)
- g->visibility_lambda_ = defvis;
+ str += "_change";
+ s->set_elt_property ("glyph", ly_str02scm (str.ch_C()));
}
}
+ else
+ {
+ s->suicide ();
+ return SCM_UNDEFINED;
+ }
-
+ return SCM_UNDEFINED;
}
+bool
+Clef::has_interface (Score_element* me)
+{
+ return me->has_interface (ly_symbol2scm ("clef-interface"));
+}
-
-
-Molecule*
-Clef_item::do_brew_molecule_p() const
+void
+Clef::set_interface (Score_element* me)
{
- String t = symbol_;
- if (change_b_)
- t += "_change";
-
- Molecule*output = new Molecule (lookup_l ()->clef (t));
- return output;
+ me->set_interface (ly_symbol2scm ("clef-interface"));
}
-