From 2994fed6da167b2259556a98d46e297aeb5b9f35 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Mon, 16 Nov 1998 17:35:16 +0100 Subject: [PATCH] partial: 1.1.6.jcn --- .../{plet-spanner.hh => tuplet-spanner.hh} | 20 ++-- lily/tuplet-spanner.cc | 98 +++++++++++++++++++ 2 files changed, 106 insertions(+), 12 deletions(-) rename lily/include/{plet-spanner.hh => tuplet-spanner.hh} (66%) create mode 100644 lily/tuplet-spanner.cc diff --git a/lily/include/plet-spanner.hh b/lily/include/tuplet-spanner.hh similarity index 66% rename from lily/include/plet-spanner.hh rename to lily/include/tuplet-spanner.hh index 39e7cac57d..1a41440aaa 100644 --- a/lily/include/plet-spanner.hh +++ b/lily/include/tuplet-spanner.hh @@ -6,35 +6,31 @@ #ifndef PLET_SPANNER_HH #define PLET_SPANNER_HH - -#include "bow.hh" +#include "text-def.hh" +#include "pointer.hh" +#include "directional-spanner.hh" /** supportable plet: triplets, eentweetjes, ottava, etc. */ -class Plet_spanner : public Bow +class Plet_spanner : public Directional_spanner { public: - Plet_spanner (); - virtual ~Plet_spanner (); - void set_stem (Direction, Stem*); + void add_column (Note_column*); - Text_def* tdef_p_; - Drul_array stem_l_drul_; + P tdef_p_; + Link_array column_arr_; int visibility_i_; protected: virtual Molecule* brew_molecule_p () const; - - DECLARE_MY_RUNTIME_TYPEINFO; - SCORE_ELEMENT_CLONE(Plet_spanner); + VIRTUAL_COPY_CONS(Score_element); virtual void do_add_processing (); virtual void do_post_processing (); virtual void set_default_dir (); virtual void do_substitute_dependency (Score_element*,Score_element*); - Plet_spanner (Plet_spanner const&); }; #endif // PLET_SPANNER_HH diff --git a/lily/tuplet-spanner.cc b/lily/tuplet-spanner.cc new file mode 100644 index 0000000000..0d415a9dc1 --- /dev/null +++ b/lily/tuplet-spanner.cc @@ -0,0 +1,98 @@ +/* + plet-spanner.cc -- implement Plet_spanner + + source file of the GNU LilyPond music typesetter + + (c) 1997--1998 Jan Nieuwenhuizen +*/ + +#include "atom.hh" +#include "box.hh" +#include "debug.hh" +#include "lookup.hh" +#include "molecule.hh" +#include "p-col.hh" +#include "paper-def.hh" +#include "tuplet-spanner.hh" +#include "stem.hh" +#include "text-def.hh" +#include "note-column.hh" + +Plet_spanner::Plet_spanner () +{ + visibility_i_ = 3; + + tdef_p_.set_p(new Text_def); + tdef_p_->align_dir_ = CENTER; + tdef_p_->style_str_ = "italic"; +} + +Molecule* +Plet_spanner::brew_molecule_p () const +{ + Molecule* mol_p = new Molecule; + + if (column_arr_.size ()){ + Real w = width ().length (); + Real dy = column_arr_.top ()->extent (Y_AXIS) [dir_] + - column_arr_[0]->extent (Y_AXIS) [dir_]; + + + Atom num (tdef_p_->get_atom (paper (), CENTER)); + num.translate (Offset (w/2, dy/2)); + + if (visibility_i_ >= 1) + mol_p->add_atom (num); + + mol_p->add_atom (lookup_l ()->plet (dy, w, dir_)); + } + return mol_p; +} + +void +Plet_spanner::do_add_processing () +{ + if (column_arr_.size ()) + { + + set_bounds (LEFT, column_arr_[0]); + set_bounds (RIGHT, column_arr_.top ()); + } +} + +void +Plet_spanner::do_post_processing () +{ + if (column_arr_.size()) + translate_axis (column_arr_[0]->extent (Y_AXIS)[dir_], Y_AXIS); +} + +void +Plet_spanner::do_substitute_dependency (Score_element* o, Score_element* n) +{ + if (Note_column *onc = dynamic_cast (o)) + column_arr_.substitute (onc, dynamic_cast (n)); +} + +void +Plet_spanner::set_default_dir () +{ + dir_ = UP; + for (int i=0; i < column_arr_.size (); i ++) + { + if (column_arr_[i]->dir_ < 0) + { + dir_ = DOWN; + break; + } + } +} + + +void +Plet_spanner::add_column (Note_column*n) +{ + column_arr_.push (n); + add_dependency (n); +} + -- 2.39.5