From: fred Date: Tue, 26 Mar 2002 23:24:18 +0000 (+0000) Subject: lilypond-1.3.68 X-Git-Tag: release/1.5.59~1503 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=7647136592896eb3ad0fe75804f931dc61c7c246;p=lilypond.git lilypond-1.3.68 --- diff --git a/lily/align-interface.cc b/lily/align-interface.cc index c377935871..fdeefe5d29 100644 --- a/lily/align-interface.cc +++ b/lily/align-interface.cc @@ -18,7 +18,7 @@ not compute anything, but a side effect of a->do_side_processing () is that the elements are placed correctly. */ Real -Align_interface::alignment_callback (Score_element const *sc, Axis ax) +Align_interface::alignment_callback (Score_element *sc, Axis ax) { Score_element * par = sc->parent_l (ax); if (par && par->get_elt_property ("alignment-done") == SCM_UNDEFINED) @@ -30,7 +30,7 @@ Align_interface::alignment_callback (Score_element const *sc, Axis ax) Real -Align_interface::center_on_element (Score_element const *me, Axis a) +Align_interface::center_on_element (Score_element *me, Axis a) { Score_element *cent = unsmob_element (me->get_elt_pointer ("group-center-element")); diff --git a/lily/align-note-column-engraver.cc b/lily/align-note-column-engraver.cc index f346fb9191..2ffb4d178a 100644 --- a/lily/align-note-column-engraver.cc +++ b/lily/align-note-column-engraver.cc @@ -11,7 +11,6 @@ #include "grace-align-item.hh" #include "align-interface.hh" #include "note-column.hh" -#include "local-key-item.hh" #include "warn.hh" #include "directional-element-interface.hh" #include "side-position-interface.hh" @@ -23,7 +22,7 @@ class Align_note_column_engraver: public Engraver { Grace_align_item * align_item_p_; Note_column * now_column_l_; - Local_key_item * accidental_l_; + Score_element * accidental_l_; virtual void process_acknowledged (); virtual void do_post_move_processing (); @@ -74,9 +73,9 @@ Align_note_column_engraver::acknowledge_element (Score_element_info inf) { now_column_l_ =n; } - else if (Local_key_item * it = dynamic_cast (inf.elem_l_)) + else if (to_boolean (inf.elem_l_->get_elt_property ("accidentals-interface"))) { - accidental_l_ = it; + accidental_l_ = inf.elem_l_; } } void diff --git a/lily/auto-beam-engraver.cc b/lily/auto-beam-engraver.cc index 1d88248b40..433f469f67 100644 --- a/lily/auto-beam-engraver.cc +++ b/lily/auto-beam-engraver.cc @@ -9,9 +9,7 @@ #include "beaming.hh" #include "auto-beam-engraver.hh" #include "musical-request.hh" -#include "bar.hh" #include "beam.hh" -#include "rest.hh" #include "stem.hh" #include "debug.hh" #include "timing-engraver.hh" @@ -310,7 +308,7 @@ Auto_beam_engraver::acknowledge_element (Score_element_info info) { end_beam (); } - else if (Bar *b = dynamic_cast (info.elem_l_)) + else if (to_boolean (info.elem_l_->get_elt_property ("bar-interface"))) { end_beam (); } diff --git a/lily/axis-group-interface.cc b/lily/axis-group-interface.cc index 00c4c8d32c..f426b856c9 100644 --- a/lily/axis-group-interface.cc +++ b/lily/axis-group-interface.cc @@ -59,7 +59,7 @@ Axis_group_interface::relative_group_extent (Axis a, Score_element *common, SCM } Interval -Axis_group_interface::group_extent_callback (Score_element const*me, Axis a) +Axis_group_interface::group_extent_callback (Score_element *me, Axis a) { Score_element * common =(Score_element*) me; diff --git a/lily/beam.cc b/lily/beam.cc index 5b50831fca..c007e311bf 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -857,7 +857,7 @@ Beam::last_visible_stem () const rest -> stem -> beam -> interpolate_y_position () */ Real -Beam::rest_collision_callback (Score_element const *rest, Axis a ) +Beam::rest_collision_callback (Score_element *rest, Axis a ) { assert (a == Y_AXIS); diff --git a/lily/break-align-item.cc b/lily/break-align-item.cc index bbea713e2b..2977cde738 100644 --- a/lily/break-align-item.cc +++ b/lily/break-align-item.cc @@ -10,13 +10,12 @@ #include "side-position-interface.hh" #include "warn.hh" -#include "dimension-cache.hh" #include "lily-guile.hh" #include "break-align-item.hh" #include "dimensions.hh" -#include "paper-score.hh" #include "paper-def.hh" #include "paper-column.hh" + #include "group-interface.hh" #include "align-interface.hh" diff --git a/lily/breathing-sign-engraver.cc b/lily/breathing-sign-engraver.cc index 151fbbff79..1088b39d33 100644 --- a/lily/breathing-sign-engraver.cc +++ b/lily/breathing-sign-engraver.cc @@ -36,7 +36,7 @@ protected: private: Breathing_sign_req * breathing_sign_req_l_; - Breathing_sign * breathing_sign_p_; + Score_element * breathing_sign_p_; }; Breathing_sign_engraver::Breathing_sign_engraver() @@ -63,9 +63,9 @@ Breathing_sign_engraver::do_process_music() if(breathing_sign_req_l_) { SCM b = get_property ("basicBreathingSignProperties"); - breathing_sign_p_ = new Breathing_sign (b); - Staff_symbol_referencer_interface st (breathing_sign_p_); - st.set_interface (); + breathing_sign_p_ = new Item (b); + + Breathing_sign::set_interface (breathing_sign_p_); announce_element (Score_element_info (breathing_sign_p_, breathing_sign_req_l_)); } diff --git a/lily/breathing-sign.cc b/lily/breathing-sign.cc index cc743c5a28..73580c0f2c 100644 --- a/lily/breathing-sign.cc +++ b/lily/breathing-sign.cc @@ -21,12 +21,6 @@ #include "direction.hh" -Breathing_sign::Breathing_sign (SCM s) - : Item (s) -{ -} - - MAKE_SCHEME_SCORE_ELEMENT_CALLBACK(Breathing_sign,brew_molecule); @@ -45,20 +39,25 @@ Breathing_sign::brew_molecule (SCM smob) return sc->lookup_l()->filledbox(b).create_scheme (); } -GLUE_SCORE_ELEMENT(Breathing_sign,after_line_breaking); -SCM -Breathing_sign::member_after_line_breaking () +Real +Breathing_sign::offset_callback (Score_element * b, Axis a) { - Real space = Staff_symbol_referencer_interface (this).staff_space(); - Direction d = Directional_element_interface (this). get (); + Score_element * me = (Score_element*)b; + + Real space = Staff_symbol_referencer_interface (b).staff_space(); + Direction d = Directional_element_interface (b). get (); if (!d) { d = UP; - Directional_element_interface (this).set (d); + Directional_element_interface (me).set (d); } - translate_axis(2.0 * space * d, Y_AXIS); - - return SCM_UNDEFINED; + return 2.0 * space * d; } +void +Breathing_sign::set_interface (Score_element *b) +{ + Staff_symbol_referencer_interface::set_interface (b); + b->add_offset_callback (Breathing_sign::offset_callback,Y_AXIS); +} diff --git a/lily/chord-name-engraver.cc b/lily/chord-name-engraver.cc index cab0239b3c..3e82a77350 100644 --- a/lily/chord-name-engraver.cc +++ b/lily/chord-name-engraver.cc @@ -6,8 +6,9 @@ (c) 1998--2000 Jan Nieuwenhuizen */ -#include "chord-name-engraver.hh" +#include "engraver.hh" #include "chord-name.hh" +#include "chord.hh" #include "musical-request.hh" #include "paper-def.hh" #include "lookup.hh" @@ -15,7 +16,27 @@ #include "main.hh" #include "dimensions.hh" #include "item.hh" +#include "musical-pitch.hh" +class Chord_name_engraver : public Engraver +{ +public: + Chord_name_engraver (); + VIRTUAL_COPY_CONS (Translator); + +protected: + virtual void do_pre_move_processing (); + virtual void acknowledge_element (Score_element_info i); + virtual void do_process_music (); + virtual bool do_try_music (Music* m); + +private: + Array pitch_arr_; + Item* chord_name_p_; + Tonic_req* tonic_req_; + Inversion_req* inversion_req_; + Bass_req* bass_req_; +}; ADD_THIS_TRANSLATOR (Chord_name_engraver); @@ -73,7 +94,7 @@ Chord_name_engraver::do_process_music () if (gh_boolean_p (chord_inversion)) find_inversion_b = gh_scm2bool (chord_inversion); - chord_name_p_ = new Chord_name (get_property ("basicChordNameProperties")); + chord_name_p_ = new Item (get_property ("basicChordNameProperties")); Chord chord = to_chord (pitch_arr_, tonic_req_, inversion_req_, bass_req_, find_inversion_b); diff --git a/lily/chord-name.cc b/lily/chord-name.cc index 0d4ff13849..bcc0abea3d 100644 --- a/lily/chord-name.cc +++ b/lily/chord-name.cc @@ -7,14 +7,10 @@ */ #include "chord-name.hh" -#include "musical-request.hh" -#include "warn.hh" -#include "debug.hh" #include "molecule.hh" #include "paper-def.hh" #include "lookup.hh" -#include "staff-symbol-referencer.hh" - +#include "score-element.hh" /* TODO: move text lookup out of Chord_name @@ -27,7 +23,7 @@ */ Molecule -Chord_name::ly_word2molecule (SCM word, Real* x) const +Chord_name::ly_word2molecule (Score_element * me, SCM word, Real* x) { *x = 0; @@ -43,10 +39,10 @@ Chord_name::ly_word2molecule (SCM word, Real* x) const /* UGH. Should read from font metric structure. */ - Real ex = lookup_l ()->text ("", "x", - paper_l ()).extent (Y_AXIS).length (); - Real em = lookup_l ()->text ("", "m", - paper_l ()).extent (X_AXIS).length (); + Real ex = me->lookup_l ()->text ("", "x", + me->paper_l ()).extent (Y_AXIS).length (); + Real em = me->lookup_l ()->text ("", "m", + me->paper_l ()).extent (X_AXIS).length (); String w = ly_scm2string (word); @@ -90,9 +86,9 @@ Chord_name::ly_word2molecule (SCM word, Real* x) const Molecule mol; s = scm_assoc (ly_symbol2scm ("font"), options_alist); if (s != SCM_BOOL_F && ly_scm2string (gh_cdr (s)) == "feta") - mol = paper_l ()->lookup_l (size)->afm_find (w); + mol = me->paper_l ()->lookup_l (size)->afm_find (w); else - mol = paper_l ()->lookup_l (size)->text (style, w, paper_l ()); + mol = me->paper_l ()->lookup_l (size)->text (style, w, me->paper_l ()); mol.translate (offset); return mol; @@ -106,7 +102,7 @@ Chord_name::ly_word2molecule (SCM word, Real* x) const ;; property: align, kern, font (?), size */ Molecule -Chord_name::ly_text2molecule (SCM text) const +Chord_name::ly_text2molecule (Score_element * me, SCM text) { Molecule mol; if (gh_list_p (text)) @@ -114,7 +110,7 @@ Chord_name::ly_text2molecule (SCM text) const while (gh_cdr (text) != SCM_EOL) { Real x; - Molecule m = ly_word2molecule (gh_car (text), &x); + Molecule m = ly_word2molecule (me, gh_car (text), &x); if (!m.empty_b ()) mol.add_at_edge (X_AXIS, RIGHT, m, x); text = gh_cdr (text); @@ -122,7 +118,7 @@ Chord_name::ly_text2molecule (SCM text) const text = gh_car (text); } Real x; - Molecule m = ly_word2molecule (text, &x); + Molecule m = ly_word2molecule (me,text, &x); if (!m.empty_b ()) mol.add_at_edge (X_AXIS, RIGHT, m, x); return mol; @@ -154,11 +150,5 @@ Chord_name::brew_molecule (SCM smob) ly_quote_scm (gh_cons (inversion, bass)), SCM_UNDEFINED)); - return dynamic_cast (sc)-> - ly_text2molecule (text).create_scheme (); -} - -Chord_name::Chord_name (SCM s) - : Item (s) -{ + return ly_text2molecule (sc, text).create_scheme (); } diff --git a/lily/clef-engraver.cc b/lily/clef-engraver.cc index def1a62622..4267a35779 100644 --- a/lily/clef-engraver.cc +++ b/lily/clef-engraver.cc @@ -11,14 +11,8 @@ #include #include "staff-symbol-referencer.hh" -#include "bar.hh" - #include "debug.hh" #include "command-request.hh" -#include "timing-translator.hh" -#include "rhythmic-head.hh" -#include "key-item.hh" -#include "local-key-item.hh" #include "array.hh" #include "engraver.hh" #include "direction.hh" @@ -126,22 +120,23 @@ Clef_engraver::set_type (String s) void Clef_engraver::acknowledge_element (Score_element_info info) { - if (dynamic_cast(info.elem_l_) - && gh_string_p (clef_glyph_)) - create_clef(); - - Item * it_l =dynamic_cast (info.elem_l_); - if (it_l) + Item * item =dynamic_cast (info.elem_l_); + if (item) { - if (to_boolean (it_l->get_elt_property("note-head-interface")) - || dynamic_cast (it_l)) + if (to_boolean (info.elem_l_->get_elt_property ("bar-interface")) + && gh_string_p (clef_glyph_)) + create_clef(); + + + if (to_boolean (item->get_elt_property("note-head-interface")) + || to_boolean (item->get_elt_property ("accidentals-interface"))) { - Staff_symbol_referencer_interface si (it_l); + Staff_symbol_referencer_interface si (item); si.set_position (int (si.position_f ()) + c0_position_i_); } - else if (Key_item *k = dynamic_cast(it_l)) + else if (to_boolean (item->get_elt_property ("key-item-interface"))) { - k->set_elt_property ("c0-position", gh_int2scm (c0_position_i_)); + item->set_elt_property ("c0-position", gh_int2scm (c0_position_i_)); } } } @@ -180,8 +175,7 @@ Clef_engraver::create_clef() Item *c= new Item ( current_settings_); announce_element (Score_element_info (c, clef_req_l_)); - Staff_symbol_referencer_interface si(c); - si.set_interface (); + Staff_symbol_referencer_interface::set_interface (c); clef_p_ = c; } diff --git a/lily/collision.cc b/lily/collision.cc index 9cedc34479..9316fcd2f3 100644 --- a/lily/collision.cc +++ b/lily/collision.cc @@ -22,7 +22,7 @@ Collision::add_column (Note_column* ncol_l) } Real -Collision::force_shift_callback (Score_element const * c, Axis a) +Collision::force_shift_callback (Score_element * c, Axis a) { assert (a == X_AXIS); diff --git a/lily/dot-column-engraver.cc b/lily/dot-column-engraver.cc index d555327c8e..908851d168 100644 --- a/lily/dot-column-engraver.cc +++ b/lily/dot-column-engraver.cc @@ -7,10 +7,25 @@ */ -#include "dot-column-engraver.hh" + #include "rhythmic-head.hh" #include "dot-column.hh" #include "side-position-interface.hh" +#include "engraver.hh" + +class Dot_column_engraver : public Engraver +{ + Score_element *dotcol_p_ ; + Link_array head_l_arr_; +public: + VIRTUAL_COPY_CONS(Translator); + Dot_column_engraver(); + +protected: + virtual void acknowledge_element (Score_element_info); + virtual void do_pre_move_processing (); +}; + Dot_column_engraver::Dot_column_engraver () { @@ -31,22 +46,21 @@ Dot_column_engraver::do_pre_move_processing () void Dot_column_engraver::acknowledge_element (Score_element_info info) { - Rhythmic_head * h = dynamic_cast(info.elem_l_); - if (!h) - return; + Score_element *d = unsmob_element (info.elem_l_->get_elt_pointer ("dot")); + if (d) + { + if (!dotcol_p_) + { + dotcol_p_ = new Item(get_property ("basicDotColumnProperties")); - if (!h->dots_l ()) - return; + Dot_column::set_interface (dotcol_p_); + Side_position_interface (dotcol_p_).set_axis (X_AXIS); + Side_position_interface (dotcol_p_).set_direction (RIGHT); + announce_element (Score_element_info (dotcol_p_, 0)); + } - if (!dotcol_p_) - { - dotcol_p_ = new Dot_column(get_property ("basicDotColumnProperties")); - Side_position_interface (dotcol_p_).set_axis (X_AXIS); - Side_position_interface (dotcol_p_).set_direction (RIGHT); - announce_element (Score_element_info (dotcol_p_, 0)); + Dot_column::add_head (dotcol_p_, info.elem_l_); } - - dotcol_p_->add_head (h); } diff --git a/lily/dot-column.cc b/lily/dot-column.cc index a725998bcf..f3ce19ad83 100644 --- a/lily/dot-column.cc +++ b/lily/dot-column.cc @@ -18,20 +18,18 @@ void -Dot_column::add_head (Rhythmic_head *r) +Dot_column::add_head (Score_element * dc, Score_element *rh) { - if (!r->dots_l ()) - return ; - - Side_position_interface (this).add_support (r); - Item * d = r->dots_l (); + Score_element * d = unsmob_element (rh->get_elt_pointer ("dot")); if (d) { - Pointer_group_interface gi (this, "dots"); + Side_position_interface (dc).add_support (rh); + + Pointer_group_interface gi (dc, "dots"); gi.add_element (d); d->add_offset_callback (force_shift_callback , Y_AXIS); - Axis_group_interface (this).add_element (d); + Axis_group_interface (dc).add_element (d); } } @@ -46,14 +44,14 @@ Dot_column::compare (Score_element * const &d1, Score_element * const &d2) } -Dot_column::Dot_column (SCM s) - : Item (s) +void +Dot_column::set_interface (Score_element* dc) { - this->set_elt_pointer ("dots", SCM_EOL); - Directional_element_interface (this).set (RIGHT); + dc->set_elt_pointer ("dots", SCM_EOL); + Directional_element_interface (dc).set (RIGHT); - Axis_group_interface (this).set_interface (); - Axis_group_interface (this).set_axes(X_AXIS,X_AXIS); + Axis_group_interface (dc).set_interface (); + Axis_group_interface (dc).set_axes(X_AXIS,X_AXIS); } /* @@ -74,7 +72,7 @@ Dot_column::Dot_column (SCM s) Real -Dot_column::force_shift_callback (Score_element const * dot, Axis a) +Dot_column::force_shift_callback (Score_element * dot, Axis a) { assert (a == Y_AXIS); Score_element * me = dot->parent_l (X_AXIS); diff --git a/lily/dots.cc b/lily/dots.cc index 6a037d9f80..929aabf96f 100644 --- a/lily/dots.cc +++ b/lily/dots.cc @@ -16,7 +16,7 @@ Real -Dots::quantised_position_callback (Score_element const* me, Axis a) +Dots::quantised_position_callback (Score_element * me, Axis a) { assert (a == Y_AXIS); diff --git a/lily/include/align-interface.hh b/lily/include/align-interface.hh index c9e42d7be1..04b2cca234 100644 --- a/lily/include/align-interface.hh +++ b/lily/include/align-interface.hh @@ -38,7 +38,7 @@ struct Align_interface { Score_element * elt_l_; Align_interface (Score_element const*); - static Real alignment_callback (Score_element const*,Axis); + static Real alignment_callback (Score_element *,Axis); void do_side_processing (Axis a); void set_axis (Axis); Axis axis () const; @@ -46,7 +46,7 @@ struct Align_interface { int get_count (Score_element*)const; void set_interface (); bool has_interface_b (); - static Real center_on_element (Score_element const *c, Axis); + static Real center_on_element (Score_element *c, Axis); }; #endif /* ALIGN_INTERFACE_HH */ diff --git a/lily/include/axis-group-interface.hh b/lily/include/axis-group-interface.hh index 3d72a99494..f99d232133 100644 --- a/lily/include/axis-group-interface.hh +++ b/lily/include/axis-group-interface.hh @@ -31,7 +31,7 @@ struct Axis_group_interface Score_element *elt_l_; Axis_group_interface (Score_element*); - static Interval group_extent_callback (Score_element const*,Axis); + static Interval group_extent_callback (Score_element *,Axis); static Interval relative_group_extent (Axis, Score_element * common, SCM list); void add_element (Score_element*); diff --git a/lily/include/beam.hh b/lily/include/beam.hh index 9a85134d64..3efb7c2827 100644 --- a/lily/include/beam.hh +++ b/lily/include/beam.hh @@ -35,7 +35,7 @@ public: int visible_stem_count () const; Stem* first_visible_stem () const; Stem* last_visible_stem () const; - static Real rest_collision_callback (Score_element const*,Axis); + static Real rest_collision_callback (Score_element *,Axis); Beam (SCM); void add_stem (Stem*); void set_grouping (Rhythmic_grouping def, Rhythmic_grouping current); diff --git a/lily/include/breathing-sign.hh b/lily/include/breathing-sign.hh index dd495b1db8..a3c3bb9be0 100644 --- a/lily/include/breathing-sign.hh +++ b/lily/include/breathing-sign.hh @@ -10,24 +10,18 @@ #ifndef BREATHING_SIGN_HH #define BREATHING_SIGN_HH -#include "item.hh" -#include "parray.hh" +#include "lily-guile.hh" /* breathing sign (apostrophe within staff, not the comma above staff type) */ -class Breathing_sign : public Item +class Breathing_sign { public: static SCM brew_molecule (SCM); - - VIRTUAL_COPY_CONS(Score_element); - Breathing_sign (SCM s); -public: - SCM member_after_line_breaking (); - static SCM after_line_breaking (SCM); - SCM member_brew_molecule () const; + static Real offset_callback (Score_element *, Axis); + static void set_interface (Score_element*); }; #endif // BREATHING_SIGN_HH diff --git a/lily/include/chord-name.hh b/lily/include/chord-name.hh index fae9d217b0..b4b55b318b 100644 --- a/lily/include/chord-name.hh +++ b/lily/include/chord-name.hh @@ -9,8 +9,7 @@ #ifndef CHORD_NAME_HH #define CHORD_NAME_HH -#include "chord.hh" -#include "item.hh" +#include "lily-guile.hh" #include "molecule.hh" /** @@ -19,18 +18,12 @@ inversion(optional): musical-pitch bass(optional): musical-pitch */ -class Chord_name : public Item +class Chord_name { public: static SCM brew_molecule (SCM); - - VIRTUAL_COPY_CONS (Score_element); - Molecule ly_word2molecule (SCM scm, Real* x) const; - Molecule ly_text2molecule (SCM scm) const; - Chord_name(SCM s); -public: - SCM member_brew_molecule () const; - + static Molecule ly_word2molecule (Score_element*, SCM scm, Real* x) ; + static Molecule ly_text2molecule (Score_element*, SCM scm) ; }; #endif // CHORD_NAME_HH diff --git a/lily/include/collision.hh b/lily/include/collision.hh index 6f7ffbb471..3e88c982b2 100644 --- a/lily/include/collision.hh +++ b/lily/include/collision.hh @@ -42,7 +42,7 @@ public: Score_element* elt_l_; static SCM automatic_shift (Score_element*); static SCM forced_shift (Score_element*); - static Real force_shift_callback (Score_element const*, Axis); + static Real force_shift_callback (Score_element *, Axis); static void do_shifts (Score_element*); void add_column (Note_column*ncol_l); diff --git a/lily/include/dimension-cache-callback.hh b/lily/include/dimension-cache-callback.hh index 6c58b1d2e9..b14b0b16aa 100644 --- a/lily/include/dimension-cache-callback.hh +++ b/lily/include/dimension-cache-callback.hh @@ -11,8 +11,8 @@ #define DIMENSION_CACHE_CALLBACK_HH -typedef Interval (*Dim_cache_callback)(Score_element const *,Axis); -typedef Real (*Offset_callback)(Score_element const *,Axis); +typedef Interval (*Dim_cache_callback)(Score_element *,Axis); +typedef Real (*Offset_callback)(Score_element *,Axis); #endif /* DIMENSION_CACHE_CALLBACK_HH */ diff --git a/lily/include/dot-column.hh b/lily/include/dot-column.hh index e812875e99..db18bf572d 100644 --- a/lily/include/dot-column.hh +++ b/lily/include/dot-column.hh @@ -10,21 +10,18 @@ #ifndef DOT_COLUMN_HH #define DOT_COLUMN_HH -#include "item.hh" - +#include "lily-guile.hh" /** Group dots. This is needed because, the dots have to be aligned per voice */ -class Dot_column : public Item +class Dot_column // interface { - static int compare (Score_element * const&,Score_element * const&); public: - VIRTUAL_COPY_CONS (Score_element); - void add_head (Rhythmic_head*); - Dot_column (SCM); - - static Real force_shift_callback (Score_element const* , Axis); + static int compare (Score_element * const&,Score_element * const&); + static void add_head (Score_element * dotcol, Score_element* rh ); + static void set_interface (Score_element*); + static Real force_shift_callback (Score_element * , Axis); static SCM do_shifts (SCM dotlist); }; #endif // DOT_COLUMN_HH diff --git a/lily/include/dots.hh b/lily/include/dots.hh index 21be4f7747..76189d65f6 100644 --- a/lily/include/dots.hh +++ b/lily/include/dots.hh @@ -27,7 +27,7 @@ class Dots // interface { public: - static Real quantised_position_callback(Score_element const*, Axis); + static Real quantised_position_callback(Score_element*, Axis); static SCM brew_molecule (SCM); }; diff --git a/lily/include/key-item.hh b/lily/include/key-item.hh index 756a2b0139..e77703b9a3 100644 --- a/lily/include/key-item.hh +++ b/lily/include/key-item.hh @@ -7,9 +7,8 @@ #ifndef KEYITEM_HH #define KEYITEM_HH -#include "item.hh" -#include "array.hh" - +#include "lily-guile.hh" +#include "lily-proto.hh" /** A group of accidentals. @@ -22,18 +21,11 @@ new-accidentals -- list of (pitch, accidental) pairs */ -class Key_item :public Item +struct Key_item { - int calculate_position(SCM pair) const; - -public: - VIRTUAL_COPY_CONS(Score_element); - Key_item (SCM); + static int calculate_position(Score_element*,SCM pair) ; + void set_interface (Score_element*); static SCM brew_molecule (SCM); - - - - SCM member_brew_molecule() const; }; #endif // KEYITEM_HH diff --git a/lily/include/local-key-item.hh b/lily/include/local-key-item.hh index 0006c857bc..01eba65007 100644 --- a/lily/include/local-key-item.hh +++ b/lily/include/local-key-item.hh @@ -6,6 +6,8 @@ #ifndef LOCALKEYITEM_HH #define LOCALKEYITEM_HH + + #include "item.hh" #include "array.hh" #include "musical-pitch.hh" diff --git a/lily/include/rest-collision.hh b/lily/include/rest-collision.hh index 4eaddd45d7..baf03668b4 100644 --- a/lily/include/rest-collision.hh +++ b/lily/include/rest-collision.hh @@ -22,7 +22,7 @@ public: Rest_collision(Score_element*); void set_interface (); - static Real force_shift_callback (Score_element const*, Axis); + static Real force_shift_callback (Score_element *, Axis); static SCM do_shift (Score_element*,SCM); }; #endif // REST_COLLISION_HH diff --git a/lily/include/score-element.hh b/lily/include/score-element.hh index 32398bb089..9ae036d0d5 100644 --- a/lily/include/score-element.hh +++ b/lily/include/score-element.hh @@ -14,8 +14,8 @@ #include "smobs.hh" #include "dimension-cache.hh" -typedef Interval (*Extent_callback)(Score_element const *,Axis); -typedef Real (*Offset_callback)(Score_element const *,Axis); +typedef Interval (*Extent_callback)(Score_element *,Axis); +typedef Real (*Offset_callback)(Score_element *,Axis); #define READONLY_PROPS // FIXME. @@ -167,9 +167,9 @@ public: Molecule get_molecule () const; void suicide (); - static Interval preset_extent (Score_element const*,Axis); - static Interval point_dimension_callback (Score_element const*,Axis ); - static Interval molecule_extent (Score_element const*,Axis); + static Interval preset_extent (Score_element *,Axis); + static Interval point_dimension_callback (Score_element *,Axis ); + static Interval molecule_extent (Score_element *,Axis); protected: /** diff --git a/lily/include/script-column.hh b/lily/include/script-column.hh index 9c580c5083..1e41d86583 100644 --- a/lily/include/script-column.hh +++ b/lily/include/script-column.hh @@ -10,15 +10,13 @@ #ifndef Script_COLUMN_HH #define Script_COLUMN_HH -#include "item.hh" +#include "lily-guile.hh" +#include "lily-proto.hh" -class Script_column : public Item +class Script_column { public: - Script_column(SCM); - void add_staff_sided (Item*); - - SCM member_before_line_breaking (); + static void add_staff_sided (Score_element*, Item*); static SCM before_line_breaking (SCM); }; diff --git a/lily/include/script.hh b/lily/include/script.hh index 4d7bc39cfd..df31d40d15 100644 --- a/lily/include/script.hh +++ b/lily/include/script.hh @@ -20,18 +20,12 @@ */ class Script : public Item { - Molecule get_molecule (Direction d) const; public: + static Molecule get_molecule (Score_element*,Direction d); Script (SCM); - static SCM brew_molecule (SCM); - - - - SCM member_before_line_breaking (); - static SCM before_line_breaking (SCM); + static SCM brew_molecule (SCM); SCM member_after_line_breaking (); static SCM after_line_breaking (SCM); - SCM member_brew_molecule () const; }; #endif /* Stem_SCRIPT_HH */ diff --git a/lily/include/separating-group-spanner.hh b/lily/include/separating-group-spanner.hh index bfbe265062..f947eb57ba 100644 --- a/lily/include/separating-group-spanner.hh +++ b/lily/include/separating-group-spanner.hh @@ -15,7 +15,7 @@ class Separating_group_spanner : public Spanner { public: - void add_spacing_unit (Single_malt_grouping_item*); + void add_spacing_unit (Item*); Separating_group_spanner(SCM); protected: VIRTUAL_COPY_CONS(Score_element); diff --git a/lily/include/separating-line-group-engraver.hh b/lily/include/separating-line-group-engraver.hh index eccb4b0ee4..6a26cd3194 100644 --- a/lily/include/separating-line-group-engraver.hh +++ b/lily/include/separating-line-group-engraver.hh @@ -9,26 +9,5 @@ #ifndef SEPARATING_LINE_GROUP_GRAV_HH #define SEPARATING_LINE_GROUP_GRAV_HH - -#include "engraver.hh" - -class Separating_line_group_engraver : public Engraver -{ -protected: - Single_malt_grouping_item * break_malt_p_; - Single_malt_grouping_item* nobreak_malt_p_; - Separating_group_spanner * sep_span_p_; - - virtual void acknowledge_element (Score_element_info); - virtual void do_creation_processing (); - virtual void do_removal_processing (); - virtual void do_pre_move_processing (); -public: - Separating_line_group_engraver (); - VIRTUAL_COPY_CONS (Translator); - -}; - - #endif /* SEPARATING_LINE_GROUP_GRAV_HH */ diff --git a/lily/include/separation-item.hh b/lily/include/separation-item.hh new file mode 100644 index 0000000000..a7bfa6e21d --- /dev/null +++ b/lily/include/separation-item.hh @@ -0,0 +1,36 @@ +/* + single-malt-grouping-item.hh -- declare Separation_item + + source file of the GNU LilyPond music typesetter + + (c) 1997--2000 Han-Wen Nienhuys + + */ + +#ifndef SINGLE_MALT_GROUPING_ITEM_HH +#define SINGLE_MALT_GROUPING_ITEM_HH + +#include "lily-proto.hh" + +/** Calc dimensions for the Separating_group_spanner; this has to be + an item to get dependencies correct. It can't be an element_group + since these usually are in a different X_group + + Properties: + + + elements -- list of items. + + no-spacing-rods -- read from elements: boolean that makes Separation_item ignore + this item + +*/ +struct Separation_item +{ + static void set_interface (Score_element*); + static Interval my_width (Score_element*) ; + static void add_item (Score_element*,Item*); +}; + +#endif /* SINGLE_MALT_GROUPING_ITEM_HH */ + diff --git a/lily/include/side-position-interface.hh b/lily/include/side-position-interface.hh index 8ace8fcad8..117fd8caed 100644 --- a/lily/include/side-position-interface.hh +++ b/lily/include/side-position-interface.hh @@ -39,11 +39,11 @@ struct Side_position_interface Score_element * elt_l_; public: Side_position_interface (Score_element const*); - static Real side_position (Score_element const *, Axis); - static Real aligned_on_self (Score_element const *, Axis); - static Real aligned_side (Score_element const *, Axis); - static Real quantised_position (Score_element const*, Axis); - static Real centered_on_parent (Score_element const*, Axis); + static Real side_position (Score_element *, Axis); + static Real aligned_on_self (Score_element *, Axis); + static Real aligned_side (Score_element *, Axis); + static Real quantised_position (Score_element *, Axis); + static Real centered_on_parent (Score_element *, Axis); void set_axis (Axis); void set_minimum_space (Real); void set_padding (Real); diff --git a/lily/include/span-bar.hh b/lily/include/span-bar.hh index 9ccb4d65b3..52079f0a5a 100644 --- a/lily/include/span-bar.hh +++ b/lily/include/span-bar.hh @@ -31,7 +31,7 @@ public: void add_bar (Score_element*); void evaluate_empty (); - static Interval width_callback(Score_element const*, Axis) ; + static Interval width_callback(Score_element *, Axis) ; virtual Real get_bar_size () const; SCM member_before_line_breaking (); diff --git a/lily/include/staff-symbol-referencer.hh b/lily/include/staff-symbol-referencer.hh index 9734cf17af..202f27f0de 100644 --- a/lily/include/staff-symbol-referencer.hh +++ b/lily/include/staff-symbol-referencer.hh @@ -21,12 +21,12 @@ class Staff_symbol_referencer_interface { public: - Score_element * elt_l_; + Score_element * elt_l_; // junkme. Staff_symbol_referencer_interface (Score_element const*); - void set_interface (); - bool has_interface_b (); + static void set_interface (Score_element*); + static bool has_interface_b (Score_element*); void set_position (Real); - static Real callback (Score_element const*, Axis a); + static Real callback (Score_element *, Axis a); /** Leading are the lead strips between the sticks (lines) of diff --git a/lily/include/stem.hh b/lily/include/stem.hh index ed0f619d0f..2897b07d53 100644 --- a/lily/include/stem.hh +++ b/lily/include/stem.hh @@ -88,12 +88,12 @@ public: void position_noteheads(); Real stem_end_position () const; - static Real off_callback (Score_element const*, Axis); + static Real off_callback (Score_element *, Axis); Molecule flag () const; SCM member_before_line_breaking (); static SCM before_line_breaking (SCM); - static Interval dim_callback (Score_element const*,Axis); + static Interval dim_callback (Score_element *,Axis); SCM member_brew_molecule() const; void set_spacing_hints () ; diff --git a/lily/include/time-signature.hh b/lily/include/time-signature.hh index 80a08ac7a6..f25d12c866 100644 --- a/lily/include/time-signature.hh +++ b/lily/include/time-signature.hh @@ -8,34 +8,20 @@ #define METER_HH #include "item.hh" -#include "array.hh" -#include "real.hh" /** Print a time_signature sign. - TODO: - C style time_signatures, 2+3+2/8 time_signatures, alla breve. + TODO: + + 2+3+2/8 time_signatures */ -class Time_signature: public Item +struct Time_signature { - Molecule special_time_signature (String,int,int) const; - Molecule time_signature (int, int)const; - -public: - SCM member_brew_molecule() const; - - Time_signature (SCM); - static SCM brew_molecule (SCM); - - - /* - TODO: make this SCM! - */ - Array args_; - - VIRTUAL_COPY_CONS(Score_element); + static Molecule special_time_signature (Score_element*,String,int,int) ; + static Molecule time_signature (Score_element*,int, int); + static SCM brew_molecule (SCM); }; #endif // METER_HH diff --git a/lily/key-engraver.cc b/lily/key-engraver.cc index 524d32cffa..3d5f48e83a 100644 --- a/lily/key-engraver.cc +++ b/lily/key-engraver.cc @@ -32,8 +32,8 @@ public: VIRTUAL_COPY_CONS(Translator); Key_change_req * keyreq_l_; - Key_item * item_p_; - Protected_scm old_accs_; + Item * item_p_; + Protected_scm old_accs_; // ugh. -> property protected: virtual void do_creation_processing(); @@ -56,16 +56,15 @@ Key_engraver::create_key (bool def) { if (!item_p_) { - item_p_ = new Key_item ( get_property ("basicKeyProperties")); - + item_p_ = new Item ( get_property ("basicKeyProperties")); + item_p_->set_elt_property ("c0-position", gh_int2scm (0)); // todo: put this in basic props. item_p_->set_elt_property ("old-accidentals", old_accs_); item_p_->set_elt_property ("new-accidentals", get_property ("keySignature")); - Staff_symbol_referencer_interface st (item_p_); - st.set_interface (); + Staff_symbol_referencer_interface::set_interface (item_p_); SCM prop = get_property ("keyOctaviation"); bool multi = to_boolean (prop); diff --git a/lily/key-item.cc b/lily/key-item.cc index 77a9e10418..871abd31ce 100644 --- a/lily/key-item.cc +++ b/lily/key-item.cc @@ -8,20 +8,13 @@ keyplacement by Mats Bengtsson */ -#include "group-interface.hh" +#include "item.hh" #include "key-item.hh" #include "molecule.hh" #include "paper-def.hh" #include "lookup.hh" #include "staff-symbol-referencer.hh" -Key_item::Key_item (SCM s) - : Item (s) -{ - set_elt_property ("c0-position", gh_int2scm (0)); -} - - /* FIXME: too much hardcoding here. */ @@ -34,18 +27,18 @@ const int SHARP_TOP_PITCH=4; /* ais and bis typeset in lower octave */ the thinking to other parties. */ int -Key_item::calculate_position(SCM pair) const +Key_item::calculate_position(Score_element *ki, SCM pair) { int p = gh_scm2int (gh_car (pair)); int a = gh_scm2int (gh_cdr (pair)); - - if (to_boolean (get_elt_property ("multi-octave"))) + int c0p = gh_scm2int (ki->get_elt_property ("c0-position")); + if (to_boolean (ki->get_elt_property ("multi-octave"))) { - return p + gh_scm2int (get_elt_property ("c0-position")); + return p + c0p; } else { // Find the c in the range -4 through 2 - int from_bottom_pos = gh_scm2int (get_elt_property ("c0-position")) + 4; + int from_bottom_pos = c0p + 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; @@ -78,17 +71,18 @@ Key_item::calculate_position(SCM pair) const TODO - space the `natural' signs wider */ -GLUE_SCORE_ELEMENT(Key_item,brew_molecule); +MAKE_SCHEME_SCORE_ELEMENT_CALLBACK(Key_item,brew_molecule); SCM -Key_item::member_brew_molecule () const +Key_item::brew_molecule (SCM smob) { - Molecule mol; + Score_element*me =unsmob_element (smob); - Staff_symbol_referencer_interface si (this); + + Staff_symbol_referencer_interface si (me); Real inter = si.staff_space ()/2.0; - SCM newas = get_elt_property ("new-accidentals"); - + SCM newas = me->get_elt_property ("new-accidentals"); + Molecule mol; /* SCM lists are stacks, so we work from right to left, ending with the cancellation signature. @@ -96,14 +90,15 @@ Key_item::member_brew_molecule () const for (SCM s = newas; gh_pair_p (s); s = gh_cdr (s)) { int a = gh_scm2int (gh_cdar (s)); - Molecule m = lookup_l ()->afm_find ("accidentals-" + to_str (a)); - m.translate_axis (calculate_position(gh_car (s)) * inter, Y_AXIS); + Molecule m = me->lookup_l ()->afm_find ("accidentals-" + to_str (a)); + m.translate_axis (calculate_position(me, gh_car (s)) * inter, Y_AXIS); mol.add_at_edge (X_AXIS, LEFT, m, 0); } - - if (break_status_dir () != RIGHT) + + Item *it = dynamic_cast (me) ; + if (it->break_status_dir () != RIGHT) { - SCM old = get_elt_property ("old-accidentals"); + SCM old = me->get_elt_property ("old-accidentals"); /* Add half a space between cancellation and key sig. @@ -112,7 +107,7 @@ Key_item::member_brew_molecule () const Interval x(0, inter); Interval y(0,0); - mol.add_at_edge (X_AXIS, LEFT, lookup_l()->blank (Box(x,y)),0); + mol.add_at_edge (X_AXIS, LEFT, me->lookup_l()->blank (Box(x,y)),0); for (; gh_pair_p (old); old = gh_cdr (old)) { @@ -127,9 +122,9 @@ Key_item::member_brew_molecule () const if (found == SCM_EOL || gh_cdr (found) != gh_cdar (old)) { - Molecule m =lookup_l ()->afm_find ("accidentals-0"); + Molecule m =me->lookup_l ()->afm_find ("accidentals-0"); - m.translate_axis (calculate_position(gh_car(old)) * inter, Y_AXIS); + m.translate_axis (calculate_position (me, gh_car (old)) * inter, Y_AXIS); mol.add_at_edge (X_AXIS, LEFT, m,0); } } diff --git a/lily/lookup.cc b/lily/lookup.cc index 61326091ea..a139f21ca5 100644 --- a/lily/lookup.cc +++ b/lily/lookup.cc @@ -220,7 +220,7 @@ sanitise_PS_string (String t) } /** -TODO: move into Text_item +TODO: move into Text_item. UGH: paper_l argument shoudl be junked. */ Molecule Lookup::text (String style, String text, Paper_def *paper_l) diff --git a/lily/note-head.cc b/lily/note-head.cc index c072d2f461..035b18a378 100644 --- a/lily/note-head.cc +++ b/lily/note-head.cc @@ -16,8 +16,6 @@ #include "dimension-cache.hh" #include "staff-symbol-referencer.hh" - - /* build a ledger line for small pieces. */ diff --git a/lily/note-heads-engraver.cc b/lily/note-heads-engraver.cc index fa72a59e2f..49524aea21 100644 --- a/lily/note-heads-engraver.cc +++ b/lily/note-heads-engraver.cc @@ -87,8 +87,8 @@ Note_heads_engraver::do_process_music() { Rhythmic_head *note_p = new Rhythmic_head (get_property ("basicNoteHeadProperties")); - Staff_symbol_referencer_interface si (note_p); - si.set_interface (); + Staff_symbol_referencer_interface::set_interface (note_p); + Note_req * note_req_l = note_req_l_arr_[i]; @@ -100,8 +100,7 @@ Note_heads_engraver::do_process_music() { Item * d = new Item (get_property ("basicDotsProperties")); - Staff_symbol_referencer_interface sd (d); - sd.set_interface (); + Staff_symbol_referencer_interface::set_interface (d); note_p->set_dots (d); @@ -114,7 +113,8 @@ Note_heads_engraver::do_process_music() announce_element (Score_element_info (d,0)); dot_p_arr_.push (d); } - si.set_position(note_req_l->pitch_.steps ()); + + note_p->set_elt_property("staff-position", gh_int2scm (note_req_l->pitch_.steps ())); Score_element_info itinf (note_p,note_req_l); announce_element (itinf); diff --git a/lily/rest-collision.cc b/lily/rest-collision.cc index 2a38b27d2b..969741809b 100644 --- a/lily/rest-collision.cc +++ b/lily/rest-collision.cc @@ -20,7 +20,7 @@ #include "duration.hh" Real -Rest_collision::force_shift_callback (Score_element const*them, Axis a) +Rest_collision::force_shift_callback (Score_element *them, Axis a) { assert (a == Y_AXIS); diff --git a/lily/rest-engraver.cc b/lily/rest-engraver.cc index ccc80a3f82..35df3f18ec 100644 --- a/lily/rest-engraver.cc +++ b/lily/rest-engraver.cc @@ -65,8 +65,8 @@ Rest_engraver::do_process_music () if (rest_req_l_ && !rest_p_) { rest_p_ = new Rhythmic_head (get_property ("basicRestProperties")); - Staff_symbol_referencer_interface si (rest_p_); - si.set_interface (); + Staff_symbol_referencer_interface::set_interface (rest_p_); + rest_p_->set_elt_property ("duration-log", gh_int2scm (rest_req_l_->duration_.durlog_i_)); @@ -75,8 +75,8 @@ Rest_engraver::do_process_music () { dot_p_ = new Item (get_property ("basicDotsProperties")); - Staff_symbol_referencer_interface si (dot_p_); - si.set_interface (); + Staff_symbol_referencer_interface::set_interface (dot_p_); + rest_p_->set_dots (dot_p_); dot_p_->set_parent (rest_p_, Y_AXIS); diff --git a/lily/rhythmic-column-engraver.cc b/lily/rhythmic-column-engraver.cc index dba6143faa..632beeb3af 100644 --- a/lily/rhythmic-column-engraver.cc +++ b/lily/rhythmic-column-engraver.cc @@ -21,7 +21,7 @@ class Rhythmic_column_engraver :public Engraver Link_array grace_slur_endings_; Stem * stem_l_; Note_column *ncol_p_; - Dot_column *dotcol_l_; + Score_element *dotcol_l_; protected: VIRTUAL_COPY_CONS(Translator); @@ -67,7 +67,7 @@ Rhythmic_column_engraver::process_acknowledged () if (ncol_p_) { if (dotcol_l_ - && !dotcol_l_->parent_l(X_AXIS)) + && !dotcol_l_->parent_l (X_AXIS)) { ncol_p_->set_dotcol (dotcol_l_); } @@ -108,9 +108,10 @@ Rhythmic_column_engraver::acknowledge_element (Score_element_info i) { rhead_l_arr_.push (r); } - else if (Dot_column*d =dynamic_cast (item)) + else if (item + && to_boolean (item->get_elt_property ("dot-column-interface"))) { - dotcol_l_ = d; + dotcol_l_ = item; } else if (Slur *s = dynamic_cast (i.elem_l_)) { diff --git a/lily/rod.cc b/lily/rod.cc index 90af9edf1b..7d287f84ba 100644 --- a/lily/rod.cc +++ b/lily/rod.cc @@ -10,7 +10,7 @@ #include "paper-column.hh" #include "debug.hh" #include "dimensions.hh" -#include "single-malt-grouping-item.hh" +#include "separation-item.hh" Rod::Rod () diff --git a/lily/score-element.cc b/lily/score-element.cc index 5e929206f4..c79813468c 100644 --- a/lily/score-element.cc +++ b/lily/score-element.cc @@ -138,14 +138,14 @@ Score_element::set_elt_pointer (const char* k, SCM v) Interval -Score_element::molecule_extent (Score_element const *s, Axis a ) +Score_element::molecule_extent (Score_element *s, Axis a) { Molecule m = s->get_molecule (); return m.extent(a); } Interval -Score_element::preset_extent (Score_element const *s , Axis a ) +Score_element::preset_extent (Score_element *s , Axis a) { SCM ext = s->get_elt_property ((a == X_AXIS) ? "extent-X" @@ -508,7 +508,7 @@ Score_element::get_offset (Axis a) const Interval -Score_element::point_dimension_callback (Score_element const* , Axis) +Score_element::point_dimension_callback (Score_element* , Axis) { return Interval (0,0); } @@ -529,7 +529,7 @@ Score_element::extent (Axis a) const } else if (!d->valid_b_) { - d->dim_= (*d->extent_callback_l_ ) (this, a); + d->dim_= (*d->extent_callback_l_ ) ((Score_element*)this, a); d->valid_b_ = true; } diff --git a/lily/script-column-engraver.cc b/lily/script-column-engraver.cc index 9fbf4f567d..e76d3c41a7 100644 --- a/lily/script-column-engraver.cc +++ b/lily/script-column-engraver.cc @@ -9,15 +9,15 @@ #include "engraver.hh" #include "script-column.hh" +#include "item.hh" #include "side-position-interface.hh" -#include "dimension-cache.hh" /** Find potentially colliding scripts, and put them in a Script_column, that will fix the collisions. */ class Script_column_engraver : public Engraver { - Script_column *scol_p_; + Score_element *scol_p_; Link_array script_l_arr_; public: @@ -73,14 +73,16 @@ Script_column_engraver::process_acknowledged () { if (!scol_p_ && script_l_arr_.size () > 1) { - scol_p_ = new Script_column (SCM_EOL); + scol_p_ = new Item (get_property ("basicScriptColumnProperties")); + scol_p_->set_elt_pointer ("scripts", SCM_EOL); + announce_element (Score_element_info (scol_p_, 0)); } if (scol_p_) { for (int i=0; i < script_l_arr_.size (); i++) - scol_p_->add_staff_sided (script_l_arr_[i]); + Script_column::add_staff_sided (scol_p_, script_l_arr_[i]); script_l_arr_.clear (); } } diff --git a/lily/script-column.cc b/lily/script-column.cc index cc8cfcacb0..7d047b97f5 100644 --- a/lily/script-column.cc +++ b/lily/script-column.cc @@ -12,28 +12,21 @@ #include "group-interface.hh" void -Script_column::add_staff_sided (Item *i) +Script_column::add_staff_sided (Score_element *me, Item *i) { SCM p = i->get_elt_property ("script-priority"); if (!gh_number_p (p)) return; - - Pointer_group_interface gi (this, "scripts"); + Pointer_group_interface gi (me, "scripts"); gi.add_element (i); - add_dependency (i); -} - -Script_column::Script_column (SCM s) - : Item (s) -{ - set_elt_pointer ("scripts", SCM_EOL); + me->add_dependency (i); } static int -staff_side_compare (Item * const &i1, - Item * const &i2) +staff_side_compare (Score_element * const &i1, + Score_element * const &i2) { SCM p1 = i1->get_elt_property ("script-priority"); SCM p2 = i2->get_elt_property ("script-priority"); @@ -41,13 +34,15 @@ staff_side_compare (Item * const &i1, return gh_scm2int (p1) - gh_scm2int (p2); } -GLUE_SCORE_ELEMENT(Script_column,before_line_breaking); +MAKE_SCHEME_SCORE_ELEMENT_CALLBACK(Script_column,before_line_breaking); + SCM -Script_column::member_before_line_breaking () +Script_column::before_line_breaking (SCM smob) { - Drul_array > arrs; - Link_array staff_sided - = Pointer_group_interface__extract_elements (this, (Item*)0, "scripts"); + Score_element* me = unsmob_element (smob); + Drul_array > arrs; + Link_array staff_sided + = Pointer_group_interface__extract_elements (me, (Score_element*)0, "scripts"); for (int i=0; i < staff_sided.size (); i++) @@ -58,11 +53,11 @@ Script_column::member_before_line_breaking () Direction d = DOWN; do { - Link_array &arr(arrs[d]); + Link_array &arr(arrs[d]); arr.sort (staff_side_compare); - Item * last = 0; + Score_element * last = 0; for (int i=0; i < arr.size (); i++) { Side_position_interface s (arr[i]); diff --git a/lily/script-engraver.cc b/lily/script-engraver.cc index 04f8bf4f8d..a12f671bbd 100644 --- a/lily/script-engraver.cc +++ b/lily/script-engraver.cc @@ -71,6 +71,8 @@ Script_engraver::do_process_music() } // todo -> use result of articulation-to-scriptdef directly as basic prop list. Script *p =new Script (get_property ("basicScriptProperties")); + + p->add_offset_callback (Side_position_interface::centered_on_parent, X_AXIS); Side_position_interface stafy (p); diff --git a/lily/script.cc b/lily/script.cc index 326667e7b4..5ad45f28ca 100644 --- a/lily/script.cc +++ b/lily/script.cc @@ -20,40 +20,29 @@ Script ::Script (SCM s) } Molecule -Script::get_molecule(Direction d) const +Script::get_molecule(Score_element * me, Direction d) { - SCM s = get_elt_property ("molecule"); + SCM s = me->get_elt_property ("molecule"); assert (gh_pair_p (s)); SCM key = gh_car (s); if (key == ly_symbol2scm ("feta")) { - return lookup_l ()->afm_find ("scripts-" + + return me->lookup_l ()->afm_find ("scripts-" + ly_scm2string (index_cell (gh_cdr (s), d))); } else if (key == ly_symbol2scm ("accordion")) { - return lookup_l ()->accordion (gh_cdr (s), paper_l()->get_var("interline")); + return me->lookup_l ()->accordion (gh_cdr (s), me->paper_l()->get_var("interline")); } - - else assert (false); + else + assert (false); return Molecule (); } -GLUE_SCORE_ELEMENT(Script,before_line_breaking); -SCM -Script::member_before_line_breaking () -{ - /* - center my self on the note head. - */ - Score_element * e = parent_l(X_AXIS); - translate_axis (e->extent (X_AXIS).center (), X_AXIS); - return SCM_UNDEFINED; -} GLUE_SCORE_ELEMENT(Script,after_line_breaking); SCM @@ -67,17 +56,18 @@ Script::member_after_line_breaking () } -GLUE_SCORE_ELEMENT(Script,brew_molecule); +MAKE_SCHEME_SCORE_ELEMENT_CALLBACK(Script,brew_molecule); SCM -Script::member_brew_molecule () const +Script::brew_molecule (SCM smob) { + Score_element *me= unsmob_element (smob); Direction dir = DOWN; - SCM d = get_elt_property ("direction"); + SCM d = me->get_elt_property ("direction"); if (isdir_b (d)) dir = to_dir (d); - return get_molecule (dir).create_scheme(); + return get_molecule (me, dir).create_scheme(); } diff --git a/lily/separating-group-spanner.cc b/lily/separating-group-spanner.cc index 9ce1156d17..d627cb6da1 100644 --- a/lily/separating-group-spanner.cc +++ b/lily/separating-group-spanner.cc @@ -8,19 +8,19 @@ */ #include "separating-group-spanner.hh" -#include "single-malt-grouping-item.hh" +#include "separation-item.hh" #include "paper-column.hh" #include "paper-def.hh" #include "dimensions.hh" #include "group-interface.hh" static Rod -make_rod (Single_malt_grouping_item *l, Single_malt_grouping_item *r) +make_rod (Item *l, Item *r) { Rod rod; - Interval li (l->my_width ()); - Interval ri (r->my_width ()); + Interval li (Separation_item::my_width (l)); + Interval ri (Separation_item::my_width (r)); rod.item_l_drul_[LEFT] =l; rod.item_l_drul_[RIGHT]=r; @@ -48,17 +48,17 @@ Separating_group_spanner::get_rods () const SCM elt = gh_cadr (s); SCM next_elt = gh_car (s); - Single_malt_grouping_item *l = dynamic_cast (unsmob_element (elt)); - Single_malt_grouping_item *r = dynamic_cast (unsmob_element ( next_elt)); + Item *l = dynamic_cast (unsmob_element (elt)); + Item *r = dynamic_cast (unsmob_element ( next_elt)); if (!r || !l) continue; - Single_malt_grouping_item *lb - = dynamic_cast(l->find_prebroken_piece (RIGHT)); + Item *lb + = dynamic_cast(l->find_prebroken_piece (RIGHT)); - Single_malt_grouping_item *rb - = dynamic_cast(r->find_prebroken_piece (LEFT)); + Item *rb + = dynamic_cast(r->find_prebroken_piece (LEFT)); a.push (make_rod(l, r)); if (lb) @@ -99,7 +99,7 @@ Separating_group_spanner::get_rods () const } void -Separating_group_spanner::add_spacing_unit (Single_malt_grouping_item*i) +Separating_group_spanner::add_spacing_unit (Item*i) { Pointer_group_interface (this, "elements").add_element (i); add_dependency (i); diff --git a/lily/separating-line-group-engraver.cc b/lily/separating-line-group-engraver.cc index a46608d0ab..8b5c2f2327 100644 --- a/lily/separating-line-group-engraver.cc +++ b/lily/separating-line-group-engraver.cc @@ -7,11 +7,27 @@ */ -#include "separating-line-group-engraver.hh" #include "separating-group-spanner.hh" -#include "single-malt-grouping-item.hh" +#include "separation-item.hh" #include "paper-column.hh" #include "paper-def.hh" +#include "engraver.hh" + +class Separating_line_group_engraver : public Engraver +{ +protected: + Item * break_malt_p_; + Item * nobreak_malt_p_; + Separating_group_spanner * sep_span_p_; + + virtual void acknowledge_element (Score_element_info); + virtual void do_creation_processing (); + virtual void do_removal_processing (); + virtual void do_pre_move_processing (); +public: + Separating_line_group_engraver (); + VIRTUAL_COPY_CONS (Translator); +}; Separating_line_group_engraver::Separating_line_group_engraver () { @@ -43,20 +59,20 @@ Separating_line_group_engraver::acknowledge_element (Score_element_info i) if (it && !it->parent_l (X_AXIS)) { bool ib =it->breakable_b (); - Single_malt_grouping_item *&p_ref_ (ib ? break_malt_p_ - : nobreak_malt_p_); + Item *&p_ref_ (ib ? break_malt_p_ + : nobreak_malt_p_); if (!p_ref_) { p_ref_ - = new Single_malt_grouping_item + = new Item (get_property ("basicSingleMaltGroupingItemProperties")); if (ib) p_ref_->set_elt_property ("breakable", SCM_BOOL_T); announce_element (Score_element_info (p_ref_, 0)); } - p_ref_->add_item (it); + Separation_item::add_item (p_ref_,it); } } diff --git a/lily/separation-item.cc b/lily/separation-item.cc new file mode 100644 index 0000000000..f51345bdc2 --- /dev/null +++ b/lily/separation-item.cc @@ -0,0 +1,70 @@ +/* + single-malt-grouping-item.cc -- implement Separation_item + + source file of the GNU LilyPond music typesetter + + (c) 1998--2000 Han-Wen Nienhuys + + */ + +#include "separation-item.hh" +#include "paper-column.hh" +#include "debug.hh" +#include "group-interface.hh" + +void +Separation_item::set_interface (Score_element*s) +{ + s->set_elt_pointer ("elements", SCM_EOL); + s->set_extent_callback (0, X_AXIS); + s->set_extent_callback (0, Y_AXIS); +} + +void +Separation_item::add_item (Score_element*s,Item* i) +{ + assert (i); + Pointer_group_interface (s).add_element (i); + s->add_dependency (i); +} + +Interval +Separation_item::my_width (Score_element *me) +{ + Item *item = dynamic_cast (me); + Paper_column * pc = item->column_l (); + Interval w; + + for (SCM s = me->get_elt_pointer ("elements"); gh_pair_p (s); s = gh_cdr (s)) + { + SCM elt = gh_car (s); + if (!SMOB_IS_TYPE_B(Score_element, elt)) + continue; + + Item *il = dynamic_cast (unsmob_element (elt)); + if (pc != il->column_l ()) + { + /* this shouldn't happen, but let's continue anyway. */ + programming_error (_("Separation_item: I've been drinking too much")); + continue; /*UGH UGH*/ + } + + if (to_boolean (il->get_elt_property ("no-spacing-rods"))) + { + continue; + } + + Interval iv (il->extent (X_AXIS)); + if (!iv.empty_b ()) + { + Real off = il->relative_coordinate (pc, X_AXIS); + w.unite (iv + off); + } + } + + return w; + // add this->offset_ ? this-> relative_coordinate ()? +} + + + diff --git a/lily/side-position-interface.cc b/lily/side-position-interface.cc index 21f8d227dc..c52646506a 100644 --- a/lily/side-position-interface.cc +++ b/lily/side-position-interface.cc @@ -59,7 +59,7 @@ Side_position_interface::get_direction () const */ Real -Side_position_interface::side_position (Score_element const *cme, Axis axis) +Side_position_interface::side_position (Score_element *cme, Axis axis) { Score_element* me = (Score_element*)cme; Score_element *common = me->parent_l (axis); @@ -114,7 +114,7 @@ Side_position_interface::side_position (Score_element const *cme, Axis axis) callback that centers the element on itself */ Real -Side_position_interface::aligned_on_self (Score_element const*elm, Axis ax) +Side_position_interface::aligned_on_self (Score_element *elm, Axis ax) { String s ("self-alignment-"); @@ -156,14 +156,14 @@ directed_round (Real f, Direction d) Callback that quantises in staff-spaces, rounding in the direction of the elements "direction" elt property. */ Real -Side_position_interface::quantised_position (Score_element const *me, Axis a) +Side_position_interface::quantised_position (Score_element *me, Axis a) { Side_position_interface s(me); Direction d = s.get_direction (); - Staff_symbol_referencer_interface si (me); - if (si.has_interface_b ()) + if (Staff_symbol_referencer_interface::has_interface_b (me)) { + Staff_symbol_referencer_interface si (me); Real p = si.position_f (); Real rp = directed_round (p, d); @@ -183,7 +183,7 @@ Side_position_interface::quantised_position (Score_element const *me, Axis a) Position next to support, taking into account my own dimensions and padding. */ Real -Side_position_interface::aligned_side (Score_element const*me, Axis ax) +Side_position_interface::aligned_side (Score_element *me, Axis ax) { Side_position_interface s(me); Direction d = s.get_direction (); @@ -206,7 +206,7 @@ Side_position_interface::aligned_side (Score_element const*me, Axis ax) Position centered on parent. */ Real -Side_position_interface::centered_on_parent (Score_element const* me, Axis a) +Side_position_interface::centered_on_parent (Score_element * me, Axis a) { Score_element *him = me->parent_l (a); diff --git a/lily/span-bar.cc b/lily/span-bar.cc index 91ab2a0ab2..0012dab45f 100644 --- a/lily/span-bar.cc +++ b/lily/span-bar.cc @@ -26,7 +26,7 @@ Span_bar::add_bar (Score_element*b) Interval -Span_bar::width_callback (Score_element const *se, Axis ) +Span_bar::width_callback (Score_element *se, Axis ) { Span_bar* s= dynamic_cast ((Score_element*)se); String gl = ly_scm2string (s->get_elt_property ("glyph")); @@ -101,7 +101,7 @@ Span_bar::evaluate_empty () Interval Span_bar::get_spanned_interval () const { - return Axis_group_interface::group_extent_callback (this, Y_AXIS); + return Axis_group_interface::group_extent_callback ((Span_bar*)this, Y_AXIS); } diff --git a/lily/staff-symbol-referencer.cc b/lily/staff-symbol-referencer.cc index ca3c938ed8..b2ed112f90 100644 --- a/lily/staff-symbol-referencer.cc +++ b/lily/staff-symbol-referencer.cc @@ -19,19 +19,19 @@ Staff_symbol_referencer_interface::Staff_symbol_referencer_interface (Score_elem } void -Staff_symbol_referencer_interface::set_interface () +Staff_symbol_referencer_interface::set_interface (Score_element * e) { - if (!gh_number_p (elt_l_->get_elt_property ("staff-position"))) - elt_l_->set_elt_property ("staff-position", gh_double2scm (0.0)); + if (!gh_number_p (e->get_elt_property ("staff-position"))) + e->set_elt_property ("staff-position", gh_double2scm (0.0)); - elt_l_->add_offset_callback (callback, Y_AXIS); + e->add_offset_callback (callback, Y_AXIS); } bool -Staff_symbol_referencer_interface::has_interface_b () +Staff_symbol_referencer_interface::has_interface_b (Score_element*e) { - return unsmob_element (elt_l_->get_elt_pointer ("staff-symbol")) - || gh_number_p (elt_l_->get_elt_property ("staff-position")); + return unsmob_element (e->get_elt_pointer ("staff-symbol")) + || gh_number_p (e->get_elt_property ("staff-position")); } @@ -91,7 +91,7 @@ Staff_symbol_referencer_interface::position_f () const should use offset callback! */ Real -Staff_symbol_referencer_interface::callback (Score_element const* sc,Axis ) +Staff_symbol_referencer_interface::callback (Score_element * sc,Axis ) { Score_element* me = (Score_element*)sc; // UGH. diff --git a/lily/stem.cc b/lily/stem.cc index 694be6fde2..cbbc19ddec 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -440,7 +440,7 @@ Stem::flag () const } Interval -Stem::dim_callback (Score_element const *se, Axis ) +Stem::dim_callback (Score_element *se, Axis ) { Stem * s = dynamic_cast ((Score_element*)se); @@ -498,7 +498,7 @@ Stem::member_brew_molecule () const } Real -Stem::off_callback (Score_element const* se, Axis) +Stem::off_callback (Score_element * se, Axis) { Stem *st = dynamic_cast ((Score_element*)se); diff --git a/lily/text-item.cc b/lily/text-item.cc index 84a006243d..931c5b843d 100644 --- a/lily/text-item.cc +++ b/lily/text-item.cc @@ -1,5 +1,5 @@ /* - text-item.cc -- implement Item + text-item.cc -- implement Text_item source file of the GNU LilyPond music typesetter diff --git a/lily/time-signature-engraver.cc b/lily/time-signature-engraver.cc index 77f1e75e94..9b44c6ded4 100644 --- a/lily/time-signature-engraver.cc +++ b/lily/time-signature-engraver.cc @@ -6,12 +6,29 @@ (c) 1997--2000 Han-Wen Nienhuys */ -#include "time-signature-engraver.hh" #include "time-signature.hh" #include "command-request.hh" +#include "engraver.hh" + #include "timing-engraver.hh" #include "engraver-group-engraver.hh" + +/** + generate time_signatures. + */ +class Time_signature_engraver : public Engraver { +protected: + virtual void do_process_music(); + virtual void do_pre_move_processing(); +public: + VIRTUAL_COPY_CONS(Translator); + Item * time_signature_p_; + + Time_signature_engraver(); +}; + + Time_signature_engraver::Time_signature_engraver() { time_signature_p_ =0; @@ -20,6 +37,10 @@ Time_signature_engraver::Time_signature_engraver() void Time_signature_engraver::do_process_music() { + /* + UGH. + this should use properties. + */ Translator * result = daddy_grav_l()->get_simple_translator ("Timing_engraver"); // ugh @@ -35,8 +56,7 @@ Time_signature_engraver::do_process_music() Time_signature_change_req *req = timing_grav_l->time_signature_req_l(); if (req) { - time_signature_p_ = new Time_signature (get_property ("basicTimeSignatureProperties")); - + time_signature_p_ = new Item (get_property ("basicTimeSignatureProperties")); time_signature_p_->set_elt_property ("fraction", gh_cons (gh_int2scm (req->beats_i_), gh_int2scm (req->one_beat_i_))); diff --git a/lily/time-signature.cc b/lily/time-signature.cc index 50c45abd4c..95cc942a59 100644 --- a/lily/time-signature.cc +++ b/lily/time-signature.cc @@ -13,21 +13,14 @@ #include "paper-def.hh" #include "lookup.hh" -Time_signature::Time_signature (SCM s) - : Item (s) -{ - -} +MAKE_SCHEME_SCORE_ELEMENT_CALLBACK(Time_signature,brew_molecule); -// ugh.! - -GLUE_SCORE_ELEMENT(Time_signature,brew_molecule); SCM -Time_signature::member_brew_molecule () const +Time_signature::brew_molecule (SCM smob) { - SCM st = get_elt_property ("style"); - - SCM frac = get_elt_property ("fraction"); + Score_element * me = unsmob_element (smob); + SCM st = me->get_elt_property ("style"); + SCM frac = me->get_elt_property ("fraction"); int n = 4; int d = 4; if (gh_pair_p (frac)) @@ -42,47 +35,47 @@ Time_signature::member_brew_molecule () const String style (ly_scm2string (st)); if (style[0]=='1') { - return time_signature (n, 0).create_scheme(); + return time_signature (me, n, 0).create_scheme(); } else { - return special_time_signature (style, n, d).create_scheme(); + return special_time_signature (me, style, n, d).create_scheme(); } } else - return time_signature (n,d).create_scheme(); + return time_signature (me, n,d).create_scheme(); } Molecule -Time_signature::special_time_signature (String s, int n, int d) const +Time_signature::special_time_signature (Score_element*me, String s, int n, int d) { // First guess: s contains only the signature style String symbolname = "timesig-" + s + to_str (n) + "/" + to_str (d); - Molecule m = lookup_l ()->afm_find (symbolname, false); + Molecule m = me->lookup_l ()->afm_find (symbolname, false); if (!m.empty_b()) return m; // Second guess: s contains the full signature name - m = lookup_l ()->afm_find ("timesig-"+s, false); + m = me->lookup_l ()->afm_find ("timesig-"+s, false); if (!m.empty_b ()) return m; // Resort to default layout with numbers - return time_signature (n,d); + return time_signature (me, n,d); } Molecule -Time_signature::time_signature (int num, int den) const +Time_signature::time_signature (Score_element*me,int num, int den) { String sty = "timesig"; /* UGH: need to look at fontsize. */ - Molecule n (lookup_l ()->text (sty, to_str (num), paper_l ())); - Molecule d (lookup_l ()->text (sty, to_str (den), paper_l ())); + Molecule n (me->lookup_l ()->text (sty, to_str (num), me->paper_l ())); + Molecule d (me->lookup_l ()->text (sty, to_str (den), me->paper_l ())); n.align_to (X_AXIS, CENTER); d.align_to (X_AXIS, CENTER); Molecule m;