\translator Staff=treble
\property Voice.Slur \pop #'direction
\property Voice.Slur \push #'direction = #1
- %% 8va
\property PianoStaff.connectArpeggios = ##t
- cis''''4^"m.g."\arpeggio (
+ \property Voice.TextSpanner \pop #'type
+ \property Voice.TextSpanner \push #'type = #"dotted-line"
+ \property Voice.TextSpanner \push #'edge-height = #'(0 . 1.5)
+ \property Voice.TextSpanner \push #'edge-text = #'("8va " . "")
+ \property Staff."c0-position" = #-13
+ cis''''4^"m.g."\arpeggio \spanrequest \start "text" (
#ifndef FAKE_GRACE
\property Grace.Stem \pop #'direction
\property Grace.Stem \push #'direction = #0
\property Grace.Beam \push #'space-function = #grace-beam-space-function
- %urg, dim. during grace dumps core here
- %%[a16-5( fis dis] [cis'32 a-1 fis-4 dis] [cis a )fis-2]
- [a16-5( fis dis] [cis32 a-1 fis-4 dis] [cis a )fis-2]
+ %% urg, dim. during grace dumps core here
+ %% [a16-5( fis dis \spanrequest \stop "text" ]
+ %% [cis'32 a-1 fis-4 dis] [cis a )fis-2]
+ [a16-5( fis dis \spanrequest \stop "text" ]
+ \property Staff."c0-position" = #-6
+ [cis32 a-1 fis-4 dis] [cis a )fis-2]
}
#else % FAKE_GRACE
)cis16
\property Voice.Stem \pop #'direction
\property Voice.Stem \push #'direction = #0
- %%[a16^5( fis dis] [cis'32 a-1 fis-4 dis] [cis a )fis-2] s s s
- [a16^5( fis dis] [cis32 a^1 fis^4 dis] [cis a )fis-2] s % s s
+ %% [a16^5( fis dis \spanrequest \stop "text" ]
+ %% [cis'32 a-1 fis-4 dis] [cis a )fis-2] s s s
+ [a16^5( fis dis \spanrequest \stop "text" ]
+ \property Staff."c0-position" = #-6
+ [cis32 a^1 fis^4 dis] [cis a )fis-2] s % s s
\property Voice.NoteHead \pop #'font-size
\property Voice.Stem \pop #'font-size
--- /dev/null
+\score{
+ \notes\relative c'''{
+ \property Voice.TextSpanner \pop #'type
+ \property Voice.TextSpanner \push #'type = #"dotted-line"
+ \property Voice.TextSpanner \push #'edge-height = #'(0 . 1.5)
+ \property Voice.TextSpanner \push #'edge-text = #'("8va " . "")
+ \property Staff."c0-position" = #-13
+
+ a\spanrequest \start "text" b c a \spanrequest \stop "text"
+
+ \property Staff."c0-position" = #-6
+ a b c a
+
+ \property Staff."c0-position" = #1
+ \property Voice.TextSpanner \push #'edge-text = #'("8bass " . "")
+ \property Voice.TextSpanner \push #'direction = #-1
+ a\spanrequest \start "text" b c a \spanrequest \stop "text"
+ }
+}
--- /dev/null
+\score{
+ \notes\relative c''{
+ \property Voice.TextSpanner \push #'edge-text = #'("8 " . "")
+ a \spanrequest \start "text"
+ b c
+ a \spanrequest \stop "text"
+
+ \property Voice.TextSpanner \pop #'type
+ \property Voice.TextSpanner \push #'type = #"dotted-line"
+ a \spanrequest \start "text"
+ b c
+ a \spanrequest \stop "text"
+
+ \property Voice.TextSpanner \pop #'type
+ \property Voice.TextSpanner \push #'type = #"dashed-line"
+ \property Voice.TextSpanner \push #'edge-height = #'(1 . -2)
+ a \spanrequest \start "text"
+ b c
+ a \spanrequest \stop "text"
+
+
+ \property Staff."c0-position" = #-13
+
+ \property Voice.TextSpanner \push #'dash-length = #5
+ \property Voice.TextSpanner \push #'line-thickness = #10
+ a \spanrequest \start "text"
+ b c
+ a \spanrequest \stop "text"
+ \property Staff."c0-position" = #-6
+ }
+}
/// where is c-0 in the staff?
class Clef_engraver : public Engraver
{
+public:
+ VIRTUAL_COPY_CONS (Translator);
+ Clef_engraver ();
+
+ Direction octave_dir_;
+ bool first_b_;
+
+protected:
+ virtual void do_process_music ();
+ virtual void do_pre_move_processing ();
+ virtual void do_creation_processing ();
+ virtual void do_post_move_processing ();
+ virtual bool do_try_music (Music*);
+ virtual void acknowledge_element (Score_element_info);
+
+private:
Item * clef_p_;
Item * octavate_p_;
Clef_change_req * clef_req_l_;
- void create_clef();
+ void create_clef ();
bool set_type (String);
-protected:
- virtual void do_process_music();
- virtual void do_pre_move_processing();
- virtual void do_creation_processing();
- virtual void do_post_move_processing();
- virtual bool do_try_music (Music*);
- virtual void acknowledge_element (Score_element_info);
-public:
- VIRTUAL_COPY_CONS(Translator);
- int c0_position_i_;
- int clef_position_i_;
- // junkme.
- Direction octave_dir_;
- SCM clef_glyph_; // no need for protection. Always referenced somewhere else.
-
- Clef_engraver();
-
- bool first_b_;
};
-Clef_engraver::Clef_engraver()
+Clef_engraver::Clef_engraver ()
{
first_b_ = true;
- clef_glyph_ = SCM_EOL;
clef_p_ = 0;
clef_req_l_ = 0;
- c0_position_i_ = 0;
- clef_position_i_ = 0;
octave_dir_ = CENTER;
octavate_p_ = 0;
}
bool
Clef_engraver::set_type (String s)
{
- if (s.right_str(2) == "_8") // Down one octave
+ if (s.right_str (2) == "_8") // Down one octave
{
octave_dir_ = DOWN;
- s = s.left_str(s.length_i() - 2);
+ s = s.left_str (s.length_i () - 2);
}
- else if (s.right_str(2) == "^8") // Up one octave
+ else if (s.right_str (2) == "^8") // Up one octave
{
octave_dir_ = UP;
- s = s.left_str(s.length_i() - 2);
+ s = s.left_str (s.length_i () - 2);
}
else
octave_dir_ = CENTER;
if (gh_list_p (c))
{
- SCM found = scm_assoc (ly_str02scm (s.ch_C()), c);
+ SCM found = scm_assoc (ly_str02scm (s.ch_C ()), c);
if (found == SCM_BOOL_F)
return false;
- clef_glyph_ = gh_cadr (found);
- SCM pos = gh_caddr (found);
+ SCM glyph = gh_cadr (found);
+ SCM pos = gh_caddr (found);
- clef_position_i_ = gh_scm2int (pos);
+ daddy_trans_l_->set_property ("glyph", glyph);
+ daddy_trans_l_->set_property ("position", pos);
- found = scm_assoc (clef_glyph_, p);
+ found = scm_assoc (glyph, p);
if (found == SCM_BOOL_F)
return false;
- c0_position_i_ = clef_position_i_ + gh_scm2int (gh_cdr (found));
+ int c0_position = gh_scm2int (pos) + gh_scm2int (gh_cdr (found));
+ daddy_trans_l_->set_property ("c0-position", gh_int2scm (c0_position));
}
- c0_position_i_ -= (int) octave_dir_ * 7;
+ int c0_position = gh_scm2int (get_property ("c0-position"));
+ c0_position -= (int)octave_dir_ * 7;
+ daddy_trans_l_->set_property ("c0-position", gh_int2scm (c0_position));
+
SCM basic = ly_symbol2scm ("Clef");
SCM c0 = ly_symbol2scm ("c0-position");
SCM gl = ly_symbol2scm ("glyph");
+
daddy_trans_l_->execute_single_pushpop_property (basic, gl, SCM_UNDEFINED);
daddy_trans_l_->execute_single_pushpop_property (basic, c0, SCM_UNDEFINED);
- daddy_trans_l_->execute_single_pushpop_property (basic, gl, clef_glyph_);
- daddy_trans_l_->execute_single_pushpop_property (basic, c0, gh_int2scm (c0_position_i_));
-
+ daddy_trans_l_->execute_single_pushpop_property (basic, gl,
+ get_property ("glyph"));
+ daddy_trans_l_->execute_single_pushpop_property (basic, c0,
+ get_property ("c0_position")
+ );
return true;
}
if (item)
{
if (Bar::has_interface (info.elem_l_)
- && gh_string_p (clef_glyph_))
- create_clef();
+ && gh_string_p (get_property ("glyph")))
+ create_clef ();
if (Note_head::has_interface (item)
|| Local_key_item::has_interface (item))
{
- int p = int (Staff_symbol_referencer::position_f (item)) + c0_position_i_;
- Staff_symbol_referencer::set_position (item,p);
+ int p = int (Staff_symbol_referencer::position_f (item))
+ + gh_scm2int (get_property ("c0-position"));
+ Staff_symbol_referencer::set_position (item, p);
}
else if (Key_item::has_interface (item))
{
- item->set_elt_property ("c0-position", gh_int2scm (c0_position_i_));
+ item->set_elt_property ("c0-position", get_property ("c0-position"));
}
}
}
void
-Clef_engraver::do_creation_processing()
+Clef_engraver::do_creation_processing ()
{
+ daddy_trans_l_->set_property ("position", gh_int2scm (0));
+ daddy_trans_l_->set_property ("glyph", SCM_EOL);
+ daddy_trans_l_->set_property ("c0-position", gh_int2scm (0));
+
SCM def = get_property ("defaultClef");
if (gh_string_p (def))
{
return true;
}
- else
- return false;
-
+ return false;
}
void
-Clef_engraver::create_clef()
+Clef_engraver::create_clef ()
{
if (!clef_p_)
{
clef_p_ = c;
}
- Staff_symbol_referencer::set_position(clef_p_, clef_position_i_);
+ Staff_symbol_referencer::set_position (clef_p_,
+ gh_scm2int (get_property ("position")
+ ));
if (octave_dir_)
{
Item * g = new Item (get_property ("OctavateEight"));
}
}
-
void
-Clef_engraver::do_process_music()
+Clef_engraver::do_process_music ()
{
if (clef_req_l_ || first_b_)
{
- create_clef();
+ create_clef ();
clef_p_->set_elt_property ("non-default", SCM_BOOL_T);
}
}
void
-Clef_engraver::do_pre_move_processing()
+Clef_engraver::do_pre_move_processing ()
{
if (clef_p_)
{
SCM vis = 0;
- if(to_boolean (clef_p_->get_elt_property("non-default")))
+ if (to_boolean (clef_p_->get_elt_property ("non-default")))
{
vis = get_property ("explicitClefVisibility");
}
if (vis)
{
- clef_p_->set_elt_property("visibility-lambda", vis);
+ clef_p_->set_elt_property ("visibility-lambda", vis);
if (octavate_p_)
- octavate_p_->set_elt_property("visibility-lambda", vis);
+ octavate_p_->set_elt_property ("visibility-lambda", vis);
}
typeset_element (clef_p_);
clef_p_ =0;
if (octavate_p_)
- typeset_element(octavate_p_);
+ typeset_element (octavate_p_);
octavate_p_ = 0;
}
}
void
-Clef_engraver::do_post_move_processing()
+Clef_engraver::do_post_move_processing ()
{
clef_req_l_ = 0;
}
-ADD_THIS_TRANSLATOR(Clef_engraver);
+ADD_THIS_TRANSLATOR (Clef_engraver);
--- /dev/null
+/*
+ text-spanner-engraver.cc -- implement Text_spanner_engraver
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2000 Jan Nieuwenhuizen <janneke@gnu.org>
+*/
+
+#include "dimensions.hh"
+#include "musical-request.hh"
+#include "paper-column.hh"
+#include "note-column.hh"
+#include "item.hh"
+#include "side-position-interface.hh"
+#include "engraver.hh"
+#include "group-interface.hh"
+#include "directional-element-interface.hh"
+#include "translator-group.hh"
+#include "axis-group-interface.hh"
+
+
+class Text_spanner_engraver : public Engraver
+{
+public:
+ VIRTUAL_COPY_CONS (Translator);
+ Text_spanner_engraver ();
+
+protected:
+ virtual void do_removal_processing ();
+ virtual void acknowledge_element (Score_element_info);
+ virtual bool do_try_music (Music *);
+ virtual void do_process_music ();
+ virtual void do_pre_move_processing ();
+ virtual void do_post_move_processing ();
+
+private:
+ Spanner *span_;
+ Spanner *finished_;
+ Span_req *current_req_;
+ Drul_array<Span_req*> req_drul_;
+ void typeset_all ();
+};
+
+ADD_THIS_TRANSLATOR (Text_spanner_engraver);
+
+
+Text_spanner_engraver::Text_spanner_engraver ()
+{
+ finished_ = 0;
+ current_req_ = 0;
+ span_ =0;
+ req_drul_[START] = 0;
+ req_drul_[STOP] = 0;
+}
+
+void
+Text_spanner_engraver::do_post_move_processing ()
+{
+ req_drul_[START] = 0;
+ req_drul_[STOP] = 0;
+}
+
+bool
+Text_spanner_engraver::do_try_music (Music *m)
+{
+ if (Span_req *s = dynamic_cast <Span_req*> (m))
+ {
+ if (s->span_type_str_ == "abort")
+ {
+ req_drul_[LEFT] = 0;
+ req_drul_[RIGHT] = 0;
+ if (span_)
+ span_->suicide ();
+ span_ = 0;
+ }
+ else if (s->span_type_str_ == "text")
+ {
+ req_drul_[s->span_dir_] = s;
+ return true;
+ }
+ }
+ return false;
+}
+
+void
+Text_spanner_engraver::do_process_music ()
+{
+ if (req_drul_[STOP])
+ {
+ if (!span_)
+ {
+ req_drul_[STOP]->origin ()->warning
+ (_ ("can't find start of text spanner"));
+ }
+ else
+ {
+ assert (!finished_);
+ Score_element* e = unsmob_element (get_property ("currentMusicalColumn"));
+ span_->set_bound (RIGHT, e);
+
+ finished_ = span_;
+ span_ = 0;
+ current_req_ = 0;
+ }
+ }
+
+ if (req_drul_[START])
+ {
+ if (current_req_)
+ {
+ req_drul_[START]->origin ()->warning
+ (_ ("already have a text spanner"));
+ }
+ else
+ {
+ current_req_ = req_drul_[START];
+ span_ = new Spanner (get_property ("TextSpanner"));
+ Side_position::set_axis (span_, Y_AXIS);
+ Score_element *e = unsmob_element (get_property ("currentMusicalColumn"));
+ span_->set_bound (LEFT, e);
+ announce_element (span_, req_drul_[START]);
+ }
+ }
+}
+
+void
+Text_spanner_engraver::acknowledge_element (Score_element_info info)
+{
+ if (span_ && Note_column::has_interface (info.elem_l_))
+ {
+ Side_position::add_support (span_, info.elem_l_);
+ add_bound_item (span_, dynamic_cast<Item*> (info.elem_l_));
+ }
+}
+
+void
+Text_spanner_engraver::typeset_all ()
+{
+ if (finished_)
+ {
+ Side_position::add_staff_support (finished_);
+ typeset_element (finished_);
+ finished_ = 0;
+ }
+}
+
+void
+Text_spanner_engraver::do_pre_move_processing ()
+{
+ typeset_all ();
+}
+
+void
+Text_spanner_engraver::do_removal_processing ()
+{
+ typeset_all ();
+ if (span_)
+ {
+ current_req_->origin ()->warning (_ ("unterminated text spanner"));
+ span_->suicide ();
+ span_ = 0;
+ }
+}
+
stroke
} bind def
%
-/draw_dashed_line % dash thickness width
+/draw_dashed_line % dash thickness dx dy
{
1 setlinecap
1 setlinejoin
setdash
setlinewidth
0 0 moveto
- 0 lineto
+ lineto
+ stroke
+} bind def
+%
+/xdraw_dashed_line % dash thickness dx dy
+{
+ 1 setlinecap
+ 1 setlinejoin
+ setdash
+ dup
+ setlinewidth
+ 2 div
+ dup
+ 0 moveto
+ neg add
+ lineto
stroke
} bind def
%