From 356630da8aa72637768bf2da2cb99b7969960233 Mon Sep 17 00:00:00 2001 From: fred Date: Sun, 24 Mar 2002 20:05:11 +0000 Subject: [PATCH] lilypond-0.1.42 --- VERSION | 2 +- lily/include/lookup.hh | 1 + lily/include/plet-engraver.hh | 39 ++++++++++++++ lily/include/text-def.hh | 4 +- lily/plet-engraver.cc | 95 +++++++++++++++++++++++++++++++++++ lily/ps-plet.cc | 32 ++++++++++++ tex/lily-ps-defs.tex | 20 ++++++++ 7 files changed, 191 insertions(+), 2 deletions(-) create mode 100644 lily/include/plet-engraver.hh create mode 100644 lily/plet-engraver.cc create mode 100644 lily/ps-plet.cc diff --git a/VERSION b/VERSION index 11280fe443..5617d6b5ef 100644 --- a/VERSION +++ b/VERSION @@ -1,6 +1,6 @@ TOPLEVEL_MAJOR_VERSION = 0 TOPLEVEL_MINOR_VERSION = 1 -TOPLEVEL_PATCH_LEVEL = 41 +TOPLEVEL_PATCH_LEVEL = 42 TOPLEVEL_MY_PATCH_LEVEL = # use the above to send patches, always empty for released version: diff --git a/lily/include/lookup.hh b/lily/include/lookup.hh index 39dc5ae9b0..e5cf3f10e9 100644 --- a/lily/include/lookup.hh +++ b/lily/include/lookup.hh @@ -51,6 +51,7 @@ struct Lookup { Atom dots () const; Atom slur (Real &dy, Real &dx, Direction dir) const; + Atom plet (Real &dy, Real &dx, Direction dir) const; Atom tex_slur (int dy, Real &dx, Direction dir) const; Atom ps_slur (Real dy, Real dx, Real dir) const; Atom half_slur (int dy, Real &dx, Direction dir, int xpart) const; diff --git a/lily/include/plet-engraver.hh b/lily/include/plet-engraver.hh new file mode 100644 index 0000000000..3a4e4d31c6 --- /dev/null +++ b/lily/include/plet-engraver.hh @@ -0,0 +1,39 @@ +/* + plet-engraver.hh -- declare Plet_engraver + + source file of the GNU LilyPond music typesetter + + (c) 1997 Jan Nieuwenhuizen +*/ + +#ifndef PLET_ENGRAVER_HH +#define PLET_ENGRAVER_HH + +#include "engraver.hh" +#include "drul-array.hh" +#include "plet-spanner.hh" + +/** + Generate a plet. + Should make a Plet_spanner that typesets a nice bracket. + */ +class Plet_engraver : public Engraver +{ +public: + TRANSLATOR_CLONE(Plet_engraver); + DECLARE_MY_RUNTIME_TYPEINFO; + Plet_engraver (); + +protected: + virtual void acknowledge_element (Score_elem_info); + virtual void do_removal_processing(); + virtual void do_process_requests(); + virtual bool do_try_request (Request*); + virtual void do_pre_move_processing(); + +private: + Drul_array span_reqs_drul_; + Plet_spanner* plet_spanner_p_; +}; + +#endif // PLET_ENGRAVER_HH diff --git a/lily/include/text-def.hh b/lily/include/text-def.hh index 78dd152e9a..48faa16f15 100644 --- a/lily/include/text-def.hh +++ b/lily/include/text-def.hh @@ -14,7 +14,8 @@ class Text_def : public General_script_def { protected: - virtual Atom get_atom (Paper_def* p, Direction dir_) const; +// huh? move to public +// virtual Atom get_atom (Paper_def* p, Direction dir_) const; DECLARE_MY_RUNTIME_TYPEINFO; VIRTUAL_COPY_CONS(Text_def,General_script_def); public: @@ -29,6 +30,7 @@ public: String style_str_; virtual void do_print() const; + virtual Atom get_atom (Paper_def* p, Direction dir_) const; virtual ~Text_def() {}; virtual bool do_equal_b (const General_script_def*) const; Text_def(); diff --git a/lily/plet-engraver.cc b/lily/plet-engraver.cc new file mode 100644 index 0000000000..16caaf6333 --- /dev/null +++ b/lily/plet-engraver.cc @@ -0,0 +1,95 @@ +/* + plet-engraver.cc -- implement Plet_engraver + + (c) 1997 Jan Nieuwenhuizen +*/ + +#include "proto.hh" +#include "musical-request.hh" +#include "plet-engraver.hh" +#include "plet-spanner.hh" +#include "text-def.hh" +#include "stem.hh" + +IMPLEMENT_IS_TYPE_B1 (Plet_engraver,Engraver); +ADD_THIS_TRANSLATOR (Plet_engraver); + +Plet_engraver::Plet_engraver () +{ + plet_spanner_p_ = 0; + span_reqs_drul_[RIGHT] = span_reqs_drul_[LEFT] = 0; +} + +void +Plet_engraver::acknowledge_element (Score_elem_info i) +{ + if (!i.elem_l_->is_type_b (Stem::static_name ())) + return; + if (!plet_spanner_p_) + return; + if (!span_reqs_drul_[LEFT]) + return; + + if (!plet_spanner_p_->stem_l_drul_[LEFT]) + plet_spanner_p_->set_stem (LEFT, (Stem*)i.elem_l_->item ()); + else + if (span_reqs_drul_[RIGHT] && !plet_spanner_p_->stem_l_drul_[RIGHT]) + plet_spanner_p_->set_stem (RIGHT, (Stem*)i.elem_l_->item()); +} + +bool +Plet_engraver::do_try_request (Request* req_l) +{ + Musical_req* mus_l = req_l->musical (); + if (!mus_l) + return false; + + Plet_req* p = mus_l->plet (); + if (!p) + return false; + + if (bool (plet_spanner_p_) == bool (p->spantype == Span_req::START)) + return false; + + Direction d = (!plet_spanner_p_) ? LEFT : RIGHT; + if (span_reqs_drul_[d] && !span_reqs_drul_[d]->equal_b (mus_l)) + return false; + + span_reqs_drul_[d] = p; + return true; +} + +void +Plet_engraver::do_removal_processing () +{ + if (plet_spanner_p_) + { + span_reqs_drul_[LEFT]->warning (_("unterminated plet")); + typeset_element (plet_spanner_p_); + plet_spanner_p_ = 0; + } +} + +void +Plet_engraver::do_process_requests () +{ + if (plet_spanner_p_ || !span_reqs_drul_[LEFT]) + return; + + plet_spanner_p_ = new Plet_spanner; + plet_spanner_p_->tdef_p_->text_str_ = span_reqs_drul_[LEFT]->plet_i_; + + announce_element (Score_elem_info (plet_spanner_p_, span_reqs_drul_[LEFT])); +} + +void +Plet_engraver::do_pre_move_processing () +{ + if (!plet_spanner_p_ || !span_reqs_drul_[RIGHT]) + return; + + typeset_element (plet_spanner_p_); + plet_spanner_p_ = 0; + span_reqs_drul_[RIGHT] = span_reqs_drul_[LEFT] = 0; +} + diff --git a/lily/ps-plet.cc b/lily/ps-plet.cc new file mode 100644 index 0000000000..8d08783f15 --- /dev/null +++ b/lily/ps-plet.cc @@ -0,0 +1,32 @@ +/* + ps-plet.cc -- implement Lookup::*plet + + source file of the GNU LilyPond music typesetter + + (c) 1997 Jan Nieuwenhuizen +*/ + +#include +#include "main.hh" +#include "misc.hh" +#include "lookup.hh" +#include "molecule.hh" +#include "dimen.hh" +#include "debug.hh" +#include "paper-def.hh" +#include "string-convert.hh" + +Atom +Lookup::plet (Real& dy , Real& dx, Direction dir) const +{ + String ps = "\\embeddedps{\n"; + + ps += String_convert::double_str (dx) + " " + + String_convert::double_str (dy) + " " + + String_convert::int_str ((int)dir) + + " draw_plet}"; + + Atom s; + s.tex_ = ps; + return s; +} diff --git a/tex/lily-ps-defs.tex b/tex/lily-ps-defs.tex index 92d9825afe..503d559f64 100644 --- a/tex/lily-ps-defs.tex +++ b/tex/lily-ps-defs.tex @@ -97,6 +97,26 @@ def /lily_distance { 1 copy mul exch 1 copy mul add sqrt } bind def + /draw_plet + { + staffrulethickness setlinewidth + /dir exch def + /plet_dy exch def + /plet_dx exch def + staffheight 2 div /plet_gap exch def + staffheight 4 div dir mul /plet_h exch def +% + plet_dy plet_dx lily_distance /plet_w exch def + plet_dy plet_dx atan rotate + 0 0 moveto + 0 plet_h lineto + plet_w plet_gap sub 2 div plet_h lineto + plet_w plet_gap add 2 div plet_h moveto + plet_w plet_h lineto + plet_w 0 lineto + stroke + } + bind def staffheight 2 div /slurhtlimit exch def /slurratio 0.3333 def -- 2.39.5