--- /dev/null
+
+\key e; c2 \clef "treble";\key es; c \break c1
}
else if (Key_item *k = dynamic_cast<Key_item*>(it_l))
{
- k-> set_c_position (c0_position_i_);
+ k->set_elt_property ("c0-position", gh_int2scm (c0_position_i_));
}
}
}
void
Key_change_req::do_print () const
{
-#ifndef NPRINT
- for (int i=0; i < key_.pitch_arr_.size (); i++)
- {
- key_.pitch_arr_[i].print ();
- }
+#if 0
+ key_->print();
#endif
}
Key_change_req::Key_change_req ()
{
+ key_ = 0;
+}
+Key_change_req::Key_change_req (Key_change_req const&s)
+ : Request (s)
+{
+ key_ = new Key_def (*s.key_);
}
+Key_change_req::~Key_change_req ()
+{
+ delete key_;
+}
+
Break_req::Break_req ()
{
void
Key_change_req::transpose (Musical_pitch p)
{
- key_.transpose (p);
+ key_->transpose (p);
}
-
-
Engraver::announce_element (Score_element_info i)
{
Score_element * e = i.elem_l_;
- group (e, "interfaces").add_thing (ly_symbol2scm (e->name()));
+
+ if (e->get_elt_property ("interfaces") == SCM_EOL)
+ group (e, "interfaces").add_thing (ly_symbol2scm (e->name()));
if (!i.origin_trans_l_)
i.origin_trans_l_ = this;
{
public:
Key_change_req ();
- Key_def key_;
+ ~Key_change_req();
+ Key_change_req(Key_change_req const &);
+ Key_def *key_;
protected:
VIRTUAL_COPY_CONS(Music);
source file of the GNU LilyPond music typesetter
- (c) 1999 Jan Nieuwenhuizen <janneke@gnu.org>
+ (c) 1999--2000 Jan Nieuwenhuizen <janneke@gnu.org>
*/
/**
Universal key definition (Should rename class Key to 'Accidentals'?)
+
+ FIXME: merge key.hh and key-def.hh classes.
*/
class Key_def
{
#include "array.hh"
-/// An item which places accidentals at the start of the line
+/** An item which places accidentals at the start of the line
+
+ TODO: Schemify me.
+ */
class Key_item :public Item
{
Array<int> pitch_arr_;
Array<int> acc_arr_;
Array<int> old_pitch_arr_;
Array<int> old_acc_arr_;
- int c0_position_;
-
public:
- bool multi_octave_b_;
-
- int get_c_position () const;
-
-
VIRTUAL_COPY_CONS(Score_element);
-
Key_item ();
void add (int pitch, int acc);
void add_old (int pitch, int acc);
- void set_c_position (int);
+
int calculate_position(int p, int a) const;
protected:
void
Key_engraver::read_req (Key_change_req const * r)
{
+ if (!r->key_)
+ return;
+
old_accidental_idx_arr_ = accidental_idx_arr_;
key_.clear ();
SCM prop = get_property ("keyOctaviation");
accidental_idx_arr_.clear ();
- if (r->key_.ordinary_key_b_)
+ if (r->key_->ordinary_key_b_)
{
- int no_of_acc = r->key_.ordinary_accidentals_i ();
+ int no_of_acc = r->key_->ordinary_accidentals_i ();
// Hmm, can't these be handled/constructed by Key_change_req?
if (no_of_acc < 0)
}
else // Special key
{
- for (int i = 0; i < r->key_.pitch_arr_.size (); i ++)
+ for (int i = 0; i < r->key_->pitch_arr_.size (); i ++)
{
- Musical_pitch m_l =r->key_.pitch_arr_[i];
+ Musical_pitch m_l =r->key_->pitch_arr_[i];
if (key_.multi_octave_b_)
key_.set (m_l);
else
source file of the GNU LilyPond music typesetter
- (c) 1996, 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1996--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
keyplacement by Mats Bengtsson
*/
Key_item::Key_item ()
{
set_elt_property ("breakable", SCM_BOOL_T);
- set_c_position (0);
+ set_elt_property ("c0-position", gh_int2scm (0));
}
-int
-Key_item::get_c_position () const
-{
- // Find the c in the range -4 through 2
- int from_bottom_pos = c0_position_ + 4;
- from_bottom_pos = from_bottom_pos%7;
- from_bottom_pos = (from_bottom_pos + 7)%7; // Precaution to get positive.
- return from_bottom_pos - 4;
-}
-
-
-void
-Key_item::set_c_position (int c0)
-{
- c0_position_ = c0;
-}
-
-
void
Key_item::add (int p, int a)
{
{
if (to_boolean (get_elt_property ("multi-octave")))
{
- return p + c0_position_;
+ return p + gh_scm2int (get_elt_property ("c0-position"));
}
else {
- if ((a<0 && ((p>FLAT_TOP_PITCH) || (p+get_c_position ()>4)) && (p+get_c_position ()>1))
+ // Find the c in the range -4 through 2
+ int from_bottom_pos = gh_scm2int (get_elt_property ("c0-position")) + 4;
+ from_bottom_pos = from_bottom_pos%7;
+ from_bottom_pos = (from_bottom_pos + 7)%7; // Precaution to get positive.
+ int c0 = from_bottom_pos - 4;
+
+
+ if ((a<0 && ((p>FLAT_TOP_PITCH) || (p+c0>4)) && (p+c0>1))
||
- (a>0 && ((p>SHARP_TOP_PITCH) || (p+get_c_position ()>5)) && (p+get_c_position ()>2)))
+ (a>0 && ((p>SHARP_TOP_PITCH) || (p+c0>5)) && (p+c0>2)))
{
p -= 7; /* Typeset below c_position */
}
/* Provide for the four cases in which there's a glitch */
/* it's a hack, but probably not worth */
/* the effort of finding a nicer solution. dl. */
- if (get_c_position ()==2 && a>0 && p==3)
+ if (c0==2 && a>0 && p==3)
p -= 7;
- if (get_c_position ()==-3 && a>0 && p==-1)
+ if (c0==-3 && a>0 && p==-1)
p += 7;
- if (get_c_position ()==-4 && a<0 && p==-1)
+ if (c0==-4 && a<0 && p==-1)
p += 7;
- if (get_c_position ()==-2 && a<0 && p==-3)
+ if (c0==-2 && a<0 && p==-3)
p += 7;
- return p + get_c_position ();
+
+ return p + c0;
}
}
void
Key_performer::do_process_music ()
{
- if (key_req_l_)
+ if (key_req_l_ && key_req_l_->key_)
{
- audio_p_ = new Audio_key (key_req_l_->key_);
+ audio_p_ = new Audio_key (*key_req_l_->key_);
Audio_element_info info (audio_p_, key_req_l_);
announce_element (info);
key_req_l_ = 0;
Array<String> lines = String_convert::split_arr (text, '\n');
- Molecule mol;
-
Real kern = paper_l->get_var ("line_kern");
- for (i = 0; i< lines.size (); i++)
+ for (int i=0; i < lines.size (); i++)
{
- /*
- Huh? This way we'll still see \foo sequences in ps output.
- */
- String str = lines[i];
+ String str (lines[i]);
if (output_global_ch == "tex")
str = sanitise_TeX_string (str);
else if (output_global_ch == "ps")
str = sanitise_PS_string (str);
+ lines[i] = str;
+ }
+
+
+ SCM first = gh_list (ly_symbol2scm ("text"),
+ ly_str02scm (lines[0].ch_C()),
+ SCM_UNDEFINED);
+ first = fontify_atom (metric_l, first);
+
+
+ Molecule mol (metric_l->text_dimension (lines[0]), first);
+
+ for (i = 1; i < lines.size (); i++)
+ {
SCM line = (gh_list (ly_symbol2scm ("text"),
- ly_str02scm (str.ch_C ()),
+ ly_str02scm (lines[i].ch_C ()),
SCM_UNDEFINED));
line = fontify_atom (metric_l, line);
mol.add_at_edge (Y_AXIS, DOWN,
- Molecule (metric_l->text_dimension (str), line),
+ Molecule (metric_l->text_dimension (lines[i]), line),
kern);
}
source file of the GNU LilyPond music typesetter
- (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
Jan Nieuwenhuizen <janneke@gnu.org>
*/
$$ = new Clef_change_req (ly_scm2string ($2));
}
+ | KEY {
+ Key_change_req *key_p= new Key_change_req;
+ key_p->key_ = 0;
+ $$ = key_p;
+ }
/* UGH. optional. */
+
| KEY NOTENAME_PITCH optional_modality {
Key_change_req *key_p= new Key_change_req;
- key_p->key_.pitch_arr_.push (*$2);
- key_p->key_.ordinary_key_b_ = true;
- key_p->key_.modality_i_ = $3;
+ Key_def d;
+ d.pitch_arr_.push (*$2);
+ d.ordinary_key_b_ = true;
+ d.modality_i_ = $3;
+
+ key_p->key_ = new Key_def (d);
$$ = key_p;
delete $2;
}
| KEYSIGNATURE pitch_list {
Key_change_req *key_p= new Key_change_req;
- key_p->key_.pitch_arr_ = *$2;
- key_p->key_.ordinary_key_b_ = false;
+ Key_def d;
+ d.pitch_arr_ = *$2;
+ d.ordinary_key_b_ = false;
+
+ key_p->key_ = new Key_def(d);
$$ = key_p;
delete $2;
}