iso. edge-widen.
* lily/piano-pedal-engraver.cc (process_music): change from
process_acknowledged ()
* lily/piano-pedal-bracket.cc: new file. Change
setup_pedal_bracket in after_line_breaking callback. Thoroughly
cleaned up.
* lily/text-spanner.cc (setup_pedal_bracket): cleanup.
2003-07-23 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ * lily/text-spanner.cc (brew_molecule): use bracket-flare
+ iso. edge-widen.
+
+ * lily/piano-pedal-engraver.cc (process_music): change from
+ process_acknowledged ()
+
+ * lily/piano-pedal-bracket.cc: new file. Change
+ setup_pedal_bracket in after_line_breaking callback. Thoroughly
+ cleaned up.
+
+ * lily/text-spanner.cc (setup_pedal_bracket): cleanup.
+
* input/regression/tuplets.ly (texidoc): rename file.
* po/fr.po: update
public:
DECLARE_SCHEME_CALLBACK (brew_molecule, (SCM));
DECLARE_SCHEME_CALLBACK(after_line_breaking, (SCM));
- static Molecule line_molecule (Grob* me, Real thick, Real dx, Real dy);
+ static Molecule line_molecule (Grob* me, Real thick,
+ Offset f, Offset t);
static bool has_interface (Grob*);
private:
#include <math.h>
+/*
+ TODO: convert all Molecule functions to taking arguments of the form
+
+ Offset FROM, Offset TO.
+
+
+ TODO:
+
+ Introduce line-interface that allows dots/dashes/etc. to be set as
+ grob-properties. Make arbitrary paths.
+
+ */
/*
slightishly clumsy interface?
Molecule
-Line_spanner::line_molecule (Grob *me, Real thick, Real dx, Real dy)
+Line_spanner::line_molecule (Grob *me, Real thick,
+ Offset from,
+ Offset to)
{
+ Offset dz = to -from ;
Molecule mol;
SCM type = me->get_grob_property ("style");
if (gh_symbol_p (type)
&& (type == ly_symbol2scm ("line")
|| type == ly_symbol2scm ("dashed-line")
|| type == ly_symbol2scm ("dotted-line")
- || (type == ly_symbol2scm ("trill") && dy != 0)))
+ || type == ly_symbol2scm ("zigzag")
+ || (type == ly_symbol2scm ("trill") && dz[Y_AXIS] != 0)))
{
- Box b (Interval (-0.5* thick + (0 <? dx) ,0.5* thick+ (0 >? dx)),
- Interval (- 0.5* thick + (0<? dy), 0.5*thick + (0 >? dy)));
- mol = Molecule (b, line_atom (me, thick, dx, dy));
- }
- else if (gh_symbol_p (type)
- && type == ly_symbol2scm ("zigzag"))
- {
- // TODO:
- Box b (Interval (-0.5* thick + (0 <? dx) ,0.5* thick+ (0 >? dx)),
- Interval (- 0.5* thick + (0<? dy), 0.5*thick + (0 >? dy)));
- mol = Molecule (b, zigzag_atom (me, thick, dx, dy));
-
+ Box b;
+ b.add_point (Offset (0,0));
+ b.add_point (dz);
+ b[X_AXIS].widen (thick/2);
+ b[Y_AXIS].widen (thick/2);
+
+ SCM atom = (type == ly_symbol2scm ("zigzag"))
+ ? zigzag_atom (me, thick, dz[X_AXIS], dz[Y_AXIS])
+ : line_atom (me, thick, dz[X_AXIS], dz[Y_AXIS]);
+
+ mol = Molecule (b, atom);
+ mol.translate (from);
}
else if (gh_symbol_p (type)
&& type == ly_symbol2scm ("trill"))
mol.add_at_edge (X_AXIS, RIGHT, m, 0,0);
while (m.extent (X_AXIS).length ()
&& mol.extent (X_AXIS).length ()
- + m.extent (X_AXIS).length () < dx);
+ + m.extent (X_AXIS).length () < dz[X_AXIS]);
/*
FIXME: should center element on x/y
*/
mol.translate_axis (m.extent (X_AXIS).length () / 2, X_AXIS);
mol.translate_axis (-(mol.extent (Y_AXIS)[DOWN]
- + mol.extent (Y_AXIS).length ())/2, Y_AXIS);
+ + mol.extent (Y_AXIS).length ())/2, Y_AXIS);
+
+ mol.translate (from);
}
+
return mol;
}
dz = (dz.length () - 2*gap) *dir;
- Molecule l (line_molecule (me, thick, dz[X_AXIS],
- dz[Y_AXIS]));
+ Molecule l (line_molecule (me, thick, Offset(0, 0), dz));
l.translate (dir * gap + p1
- Offset (me->relative_coordinate (commonx, X_AXIS),
ofxy = dxy * (off/dxy.length ());
dxy -= 2*ofxy;
- Molecule line = line_molecule (me, thick, dxy[X_AXIS], dxy[Y_AXIS]);
- line.translate_axis (bound[LEFT]->extent (bound[LEFT],
- X_AXIS).length ()/2, X_AXIS);
+ Molecule line = line_molecule (me, thick, Offset (0,0),dxy);
+
+ line.translate_axis (bound[LEFT]->extent (bound[LEFT], X_AXIS).length ()/2, X_AXIS);
line.translate (ofxy - my_off + his_off);
return line.smobbed_copy ();
}
--- /dev/null
+/*
+ piano-pedal-bracket.cc -- implement Piano_pedal_bracket
+
+source file of the GNU LilyPond music typesetter
+
+(c) 2003 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+based on smouldering remains by
+
+ Chris Jackson <chris@fluffhouse.org.uk>
+
+
+*/
+/*
+ Piano pedal brackets are a special case of a text spanner.
+ Pedal up-down (restart) indicated by the angled right and left edges
+ of consecutive pedals touching exactly to form an __/\__
+
+*/
+
+
+/*
+ TODO: this should be moved somewhere else (?).
+
+ Perhaps make separate function for pedal-bracket.
+ */
+#include "molecule.hh"
+#include "spanner.hh"
+#include "item.hh"
+#include "paper-def.hh"
+
+struct Piano_pedal_bracket
+{
+ DECLARE_SCHEME_CALLBACK(after_line_breaking,(SCM));
+ static bool has_interface (Grob*);
+};
+
+ADD_INTERFACE (Piano_pedal_bracket,"piano-pedal-bracket-interface",
+ "",
+ "pedal-text");
+
+MAKE_SCHEME_CALLBACK(Piano_pedal_bracket,after_line_breaking,1);
+SCM
+Piano_pedal_bracket::after_line_breaking (SCM smob)
+{
+ Spanner *me = dynamic_cast<Spanner*> (unsmob_grob (smob));
+
+ Drul_array<bool> broken;
+ Drul_array<Real> height(0,0), shorten(0,0);
+
+ SCM eh = me->get_grob_property ("edge-height");
+ SCM sp = me->get_grob_property ("shorten-pair");
+
+ Direction d = LEFT;
+
+ do
+ {
+ Item *b = me->get_bound (d);
+ broken[d] = b->break_status_dir () != CENTER;
+
+ if (!broken[d] && (ly_number_pair_p (eh)))
+ height[d] += gh_scm2double (index_get_cell (eh, d));
+ if (ly_number_pair_p (sp))
+ shorten[d] += gh_scm2double (index_get_cell (sp, d));
+ }
+ while (flip (&d) != LEFT);
+
+ /* For 'Mixed' style pedals, i.e. a bracket preceded by text: Ped._____|
+ need to shorten by the extent of the text grob
+
+
+ Urg. - why not hang bracket between text items? --hwn
+ */
+ if (Grob *textbit = unsmob_grob (me->get_grob_property("pedal-text")))
+ {
+ height[LEFT] = 0;
+ SCM pa = me->get_grob_property ("if-text-padding"); // UGH.
+ Real padding =0.;
+ if (gh_number_p (pa))
+ padding = gh_scm2double (pa);
+
+ shorten[LEFT] += padding + textbit->extent (textbit, X_AXIS)[RIGHT];
+ }
+
+ if (broken[LEFT])
+ {
+ shorten[LEFT] -= me->get_broken_left_end_align () ;
+ }
+
+ // Also shorten so that it ends just before the spanned note.
+ Grob *rb = me->get_bound (RIGHT);
+ shorten[RIGHT] += rb->extent (rb, X_AXIS)[RIGHT];
+
+ me->set_grob_property ("edge-height", ly_interval2scm (height));
+ me->set_grob_property ("shorten-pair", ly_interval2scm (shorten));
+
+ return SCM_UNSPECIFIED;
+}
+
struct Pedal_info
{
char const * name_;
- Music* start_req_;
- Drul_array<Music*> req_l_drul_;
+
+ /*
+ Event for currently running pedal.
+ */
+ Music* current_bracket_ev_;
+ /*
+ Event for currently starting pedal, (necessary?
+
+ distinct from current_bracket_ev_, since current_bracket_ev_ only
+ necessary for brackets, not for text style.
+ */
+ Music* start_ev_;
+
+
+
+ /*
+ Events that were found in this timestep.
+ */
+ Drul_array<Music*> event_drul_;
Item* item_;
Spanner* bracket_; // A single portion of a pedal bracket
Spanner* finished_bracket_;
*/
Spanner* line_spanner_;
Spanner* finished_line_spanner_;
- Music* current_bracket_req_;
};
virtual void stop_translation_timestep ();
virtual void start_translation_timestep ();
virtual void acknowledge_grob (Grob_info);
- virtual void process_acknowledged_grobs ();
+ virtual void process_music ();
private:
Link_array<Spanner> previous_;
- int spanner_count_;
-
- /*
- Left and right flare widths of a \___/, as specified by the grob
- property edge-widen.
- UGR. No GC protection.
-
- */
- Drul_array<SCM> edge_width_drul_;
- void create_text_grobs (Pedal_info *p, SCM pedaltype);
- void create_bracket_grobs (Pedal_info *p, SCM pedaltype);
+ void create_text_grobs (Pedal_info *p, bool);
+ void create_bracket_grobs (Pedal_info *p, bool);
void typeset_all ();
};
void
Piano_pedal_engraver::initialize ()
{
- info_list_ = new Pedal_info[4];
- Pedal_info *p = info_list_;
- spanner_count_ = 0;
previous_.clear ();
char * names [] = { "Sostenuto", "Sustain", "UnaCorda", 0 };
+
+ info_list_ = new Pedal_info[sizeof (names)/ sizeof (const char*)];
+ Pedal_info *p = info_list_;
+
char **np = names ;
do
{
p->finished_bracket_ = 0;
p->line_spanner_ = 0;
p->finished_line_spanner_ = 0;
- p->current_bracket_req_ = 0;
- p->req_l_drul_[START] = 0;
- p->req_l_drul_[STOP] = 0;
- p->start_req_ = 0;
+ p->current_bracket_ev_ = 0;
+ p->event_drul_[START] = 0;
+ p->event_drul_[STOP] = 0;
+ p->start_ev_ = 0;
p++;
}
{
for (Pedal_info*p = info_list_; p->name_; p ++)
{
- p->req_l_drul_[START] = 0;
- p->req_l_drul_[STOP] = 0;
+ p->event_drul_[START] = 0;
+ p->event_drul_[STOP] = 0;
- if (p->bracket_)
- p->bracket_->suicide (); /* as in dynamic-engraver.cc */
- p->bracket_ = 0;
- }
+ if (p->bracket_)
+ p->bracket_->suicide ();
+ p->bracket_ = 0;
+ }
}
else if (m->is_mus_type ("pedal-event"))
{
gh_symbol2scm (nm.to_str0())))
{
Direction d = to_dir (m->get_mus_property ("span-direction"));
- p->req_l_drul_[d] = m;
+ p->event_drul_[d] = m;
return true;
}
}
}
void
-Piano_pedal_engraver::process_acknowledged_grobs ()
+Piano_pedal_engraver::process_music ()
{
for (Pedal_info*p = info_list_; p && p->name_; p ++)
{
- if (p->req_l_drul_[STOP] || p->req_l_drul_[START])
+ if (p->event_drul_[STOP] || p->event_drul_[START])
{
if (!p->line_spanner_)
{
p->line_spanner_ = new Spanner (get_property (name.to_str0 ()));
- Music * rq = (p->req_l_drul_[START] ? p->req_l_drul_[START] : p->req_l_drul_[STOP]);
+ Music * rq = (p->event_drul_[START] ? p->event_drul_[START] : p->event_drul_[STOP]);
announce_grob (p->line_spanner_, rq->self_scm ());
}
/* Choose the appropriate grobs to add to the line spanner
These can be text items or text-spanners
*/
- SCM type = ly_cdr (scm_assoc (ly_symbol2scm ("pedal-type"),
- get_property ( (String (p->name_) + "Pedal").to_str0 ())));
- if (type == ly_symbol2scm ("text") || // Ped. *Ped. *
- type == ly_symbol2scm ("mixed") ) // Ped. _____/\____|
+
+ /*
+ ugh, code dup, should read grob to create from other
+ property.
+
+ bracket: |_________/\____|
+ text: Ped. *Ped. *
+ mixed: Ped. _____/\____|
+ */
+
+
+ String prop = String ("pedal") + p->name_ + "Style";
+ SCM style = get_property (prop.to_str0 ());
+ bool mixed = style == ly_symbol2scm ("mixed");
+ if (style == ly_symbol2scm ("text") ||
+ mixed)
{
if (! p->item_)
- create_text_grobs (p, type);
+ create_text_grobs (p, mixed);
}
- if (type == ly_symbol2scm ("bracket") || // |_________/\____|
- type == ly_symbol2scm ("mixed") )
+ if (style == ly_symbol2scm ("bracket") ||
+ mixed)
{
- create_bracket_grobs (p, type);
+ create_bracket_grobs (p, mixed);
}
}
}
}
-
void
-Piano_pedal_engraver::create_text_grobs (Pedal_info *p, SCM pedaltype)
+Piano_pedal_engraver::create_text_grobs (Pedal_info *p, bool mixed)
{
SCM s = SCM_EOL;
SCM strings = get_property ( ("pedal" + String (p->name_) + "Strings").to_str0 ());
if (scm_ilength (strings) < 3)
{
- Music * m = p->req_l_drul_[START];
- if (!m) m = p->req_l_drul_ [STOP];
+ Music * m = p->event_drul_[START];
+ if (!m) m = p->event_drul_ [STOP];
String msg = _ ("Need 3 strings for piano pedals. No pedal made. ");
if (m)
return ;
}
-
- if (p->req_l_drul_[STOP] && p->req_l_drul_[START])
+ if (p->event_drul_[STOP] && p->event_drul_[START])
{
- if (pedaltype == ly_symbol2scm ("text"))
+ if (!mixed)
{
- if (!p->start_req_)
+ if (!p->start_ev_)
{
- p->req_l_drul_[STOP]->origin ()->warning (_f ("can't find start of piano pedal: `%s'", p->name_));
+ p->event_drul_[STOP]->origin ()->warning (_f ("can't find start of piano pedal: `%s'", p->name_));
}
else
{
s = ly_cadr (strings);
}
- p->start_req_ = p->req_l_drul_[START];
+ p->start_ev_ = p->event_drul_[START];
}
}
- else if (p->req_l_drul_[STOP])
+ else if (p->event_drul_[STOP])
{
- if (pedaltype == ly_symbol2scm ("text"))
+ if (!mixed)
{
- if (!p->start_req_)
+ if (!p->start_ev_)
{
- p->req_l_drul_[STOP]->origin ()->warning (_f ("can't find start of piano pedal: `%s'", p->name_));
+ p->event_drul_[STOP]->origin ()->warning (_f ("can't find start of piano pedal: `%s'", p->name_));
}
else
{
s = ly_caddr (strings);
- spanner_count_ --;
if (previous_.size ())
previous_.pop();
}
- p->start_req_ = 0;
+ p->start_ev_ = 0;
}
}
- else if (p->req_l_drul_[START])
+ else if (p->event_drul_[START])
{
- p->start_req_ = p->req_l_drul_[START];
+ p->start_ev_ = p->event_drul_[START];
s = ly_car (strings);
- if (pedaltype == ly_symbol2scm ("text"))
+ if (!mixed)
{
- spanner_count_ ++;
-
/*
Code dup?! see below.
*/
Axis_group_interface::add_element (p->line_spanner_, p->item_);
announce_grob (p->item_,
- (p->req_l_drul_[START]
- ? p->req_l_drul_[START]
- : p->req_l_drul_[STOP])->self_scm ());
-
+ (p->event_drul_[START]
+ ? p->event_drul_[START]
+ : p->event_drul_[STOP])->self_scm ());
}
- if (pedaltype == ly_symbol2scm ("text"))
+ if (!mixed)
{
- p->req_l_drul_[START] = 0;
- p->req_l_drul_[STOP] = 0;
+ p->event_drul_[START] = 0;
+ p->event_drul_[STOP] = 0;
}
}
void
-Piano_pedal_engraver::create_bracket_grobs (Pedal_info *p, SCM pedaltype)
+Piano_pedal_engraver::create_bracket_grobs (Pedal_info *p, bool mixed)
{
+ if (!p->bracket_ && p->event_drul_[STOP])
+ {
+ String msg =_f ("can't find start of piano pedal bracket: `%s'", p->name_);
+ p->event_drul_[STOP]->origin ()->warning (msg);
+ p->event_drul_[STOP] = 0;
+ }
- if (p->req_l_drul_[STOP])
+ if (p->event_drul_[STOP])
{
- if (!p->start_req_)
- {
- p->req_l_drul_[STOP]->origin ()->warning (_f ("can't find start of piano pedal: `%s'", p->name_));
- }
- else if (!p->req_l_drul_[START])
+ if (!p->event_drul_[START])
{
- spanner_count_ -- ;
if (previous_.size())
previous_.pop();
}
- assert (!p->finished_bracket_ && p->bracket_);
+ assert (!p->finished_bracket_);
Grob *cmc = unsmob_grob (get_property ("currentMusicalColumn"));
p->bracket_->set_bound (RIGHT, cmc);
Set properties so that the molecule-creating function will
know whether the right edge should be flared ___/
*/
- SCM eleft = ly_car (p->bracket_->get_grob_property ("edge-widen"));
- SCM eright = (p->req_l_drul_[START] ? edge_width_drul_[RIGHT] : gh_double2scm (0));
- p->bracket_->set_grob_property ("edge-widen", gh_cons (eleft, eright));
-
+
+ if (!p->event_drul_[START])
+ {
+ SCM flare = p->bracket_->get_grob_property ("bracket-flare");
+ p->bracket_->set_grob_property ("bracket-flare", scm_cons (gh_car (flare),
+ gh_double2scm (0)));
+ }
+
p->finished_bracket_ = p->bracket_;
p->bracket_ = 0;
- p->current_bracket_req_ = 0;
- p->start_req_ = p->req_l_drul_[START];
+ p->current_bracket_ev_ = 0;
}
- if (p->req_l_drul_[START])
+ if (p->event_drul_[START])
{
- p->start_req_ = p->req_l_drul_[START];
- p->current_bracket_req_ = p->req_l_drul_[START];
+ p->start_ev_ = p->event_drul_[START];
+ p->current_bracket_ev_ = p->event_drul_[START];
p->bracket_ = new Spanner (get_property ("PianoPedalBracket"));
know whether the left edge should be flared \___
*/
- SCM ew = p->bracket_->get_grob_property ("edge-widen");
-
- /*
- WTF is this doing here?
-
- This must go to the backend.
+ if (!p->finished_bracket_)
+ {
+ SCM flare = p->bracket_->get_grob_property ("bracket-flare");
+ p->bracket_->set_grob_property ("bracket-flare", scm_cons (gh_double2scm (0),gh_cdr (flare)));
+ }
- --HWN.
- */
- edge_width_drul_[LEFT] = ly_car (ew);
- edge_width_drul_[RIGHT] = ly_cdr (ew);
-
- SCM eleft = ( (bool) p->req_l_drul_[STOP] ?
- edge_width_drul_[LEFT] :
- gh_double2scm (0));
- SCM eright = gh_double2scm (0);
- p->bracket_->set_grob_property ("edge-widen", gh_cons (eleft, eright));
/* Set this property for 'mixed style' pedals, Ped._______/\ ,
so the molecule function will shorten the ____ line by the length of the Ped. text.
*/
- p->bracket_->set_grob_property ("text-start",
- pedaltype == ly_symbol2scm ("mixed")
- ? gh_bool2scm ( (bool) ! p->req_l_drul_[STOP])
- : gh_bool2scm (false));
+ if (mixed)
+ {
+ /*
+ Mixed style: Store a pointer to the preceding text for use in
+ calculating the length of the line
+
+
+ TODO:
+
+ WTF is pedal-text not the bound of the object? --hwn
+ */
+ if (p->item_)
+ p->bracket_->set_grob_property ("pedal-text", p->item_->self_scm ());
+ }
- /*
- Mixed style: Store a pointer to the preceding text for use in
- calculating the length of the line
- */
- if (p->item_)
- p->bracket_->set_grob_property ("pedal-text", p->item_->self_scm ());
-
p->bracket_->set_bound (LEFT, unsmob_grob (get_property ("currentMusicalColumn")));
Axis_group_interface::add_element (p->line_spanner_, p->bracket_);
add_bound_item (p->line_spanner_, p->bracket_->get_bound (LEFT));
- announce_grob (p->bracket_, p->req_l_drul_[START]->self_scm ());
+ announce_grob (p->bracket_, p->event_drul_[START]->self_scm ());
- if (!p->req_l_drul_[STOP])
+ if (!p->event_drul_[STOP])
{
/*
- code dup.
- */
- spanner_count_ ++;
- if (previous_.size())
+ code dup. --hwn.
+
// position new pedal spanner below the current one
+ */
+ if (previous_.size())
Side_position_interface::add_support (p->line_spanner_, previous_.top());
previous_.push (p->line_spanner_);
}
}
- p->req_l_drul_[START] = 0;
- p->req_l_drul_[STOP] = 0;
+ p->event_drul_[START] = 0;
+ p->event_drul_[STOP] = 0;
}
void
if (p->bracket_
&& !p->bracket_->live())
p->bracket_ = 0;
+
if (p->bracket_)
{
- p->current_bracket_req_->origin ()->warning (_ ("unterminated pedal bracket"));
+ p->current_bracket_ev_->origin ()->warning (_ ("unterminated pedal bracket"));
p->bracket_->suicide ();
p->bracket_ = 0;
}
{
for (Pedal_info*p = info_list_; p->name_; p ++)
{
- p->req_l_drul_[STOP] = 0;
- p->req_l_drul_[START] = 0;
+ p->event_drul_[STOP] = 0;
+ p->event_drul_[START] = 0;
}
}
+
ENTER_DESCRIPTION (Piano_pedal_engraver,
/* descr */ "Engrave piano pedal symbols and brackets.",
/* creats*/ "SostenutoPedal SustainPedal UnaCordaPedal SostenutoPedalLineSpanner SustainPedalLineSpanner UnaCordaPedalLineSpanner",
/* accepts */ "pedal-event abort-event",
-/* acks */ "note-column-interface",
-/* reads */ "pedalSostenutoStrings pedalSustainStrings pedalUnaCordaStrings",
+/* acks */ "note-column-interface",
+/* reads */ "pedalSostenutoStrings pedalSustainStrings pedalUnaCordaStrings pedalSostenutoStyle pedalSustainStyle pedalUnaCordaStyle",
/* write */ "");
Properties:
- glyph -- text string (TODO: make one large glyph of the Ped symbol, removes need for member_brew_molecule ())
+ glyph -- text string (TODO: make one large glyph of the Ped symbol, removes need for member_brew_molecule ())
*/
SCM glyph = e->get_grob_property ("text");
if (!gh_string_p (glyph))
return mol.smobbed_copy ();
+
String text = ly_scm2string (glyph);
for (int i = 0; i < text.length (); i++)
/*
-
text-spanner.cc -- implement Text_spanner
source file of the GNU LilyPond music typesetter
(c) 2000--2003 Jan Nieuwenhuizen <janneke@gnu.org>
+
+ Revised over good by Han-Wen.
*/
#include "molecule.hh"
Grob *me= unsmob_grob (smob);
Spanner *spanner = dynamic_cast<Spanner*> (me);
- if (spanner->internal_has_interface (ly_symbol2scm ("piano-pedal-interface")))
- {
- setup_pedal_bracket(spanner);
- }
-
/* Ugh, must be same as Hairpin::brew_molecule. */
Real padding = 0.0;
SCM itp= me->get_grob_property ("if-text-padding");
shorten[LEFT] = 0;
shorten[RIGHT] = 0;
- SCM ew = me->get_grob_property ("edge-flare");
+ SCM ew = me->get_grob_property ("bracket-flare");
SCM s = me->get_grob_property ("shorten-pair");
if (gh_pair_p (s))
{
Real dy = gh_scm2double (index_get_cell (s, d)) * - dir;
if (dy)
- edge_line[d] = Line_spanner::line_molecule (me, thick, dx, dy);
+ edge_line[d] = Line_spanner::line_molecule (me, thick, Offset(0,0),
+ Offset (dx, dy));
}
while (flip (&d) != LEFT);
}
while (flip (&d) != LEFT);
Molecule l =Line_spanner::line_molecule (me, thick,
- span_points.length (), 0);
- l.translate_axis (span_points[LEFT], X_AXIS);
+ Offset (span_points[LEFT], 0),
+ Offset (span_points[RIGHT], 0));
m.add_molecule (l);
m.translate_axis (- me->relative_coordinate (common, X_AXIS), X_AXIS);
-/*
- Piano pedal brackets are a special case of a text spanner.
- Pedal up-down (restart) indicated by the angled right and left edges
- of consecutive pedals touching exactly to form an __/\__
- Chris Jackson <chris@fluffhouse.org.uk>
-*/
-/*
- TODO: this should be moved somewhere else (?).
-
- Perhaps make separate function for pedal-bracket.
- */
-/*
- UGH UGH UGH .
-
- This is broken broken.
-
- All the tweak props should be unnecessary.
-
- This should not be linked with Text_spanner.
- */
-
-void
-Text_spanner::setup_pedal_bracket(Spanner *me)
-{
-
- Real thick = me->get_paper ()->get_var ("linethickness");
- SCM st = me->get_grob_property ("thickness");
- if (gh_number_p (st))
- {
- thick *= gh_scm2double (st);
- }
-
- Drul_array<bool> broken;
- Drul_array<Real> height, width, shorten, r;
-
- SCM pa = me->get_grob_property ("if-text-padding");
- SCM eh = me->get_grob_property ("edge-height");
- SCM sp = me->get_grob_property ("shorten-pair");
-
- Direction d = LEFT;
- Interval e;
- Real padding = 0;
-
- if (gh_number_p (pa))
- padding = gh_scm2double (pa);
-
- do
- {
- Item *b = me->get_bound (d);
-
- e = b->extent (b, X_AXIS);
- if (!e.empty_b ())
- r[d] = d * (e[-d] + padding);
-
- broken[d] = b->break_status_dir () != CENTER;
- width[d] = 0;
- height[d] = 0;
- shorten[d] = 0;
- if (!broken[d] && (ly_number_pair_p (eh)))
- height[d] += gh_scm2double (index_get_cell (eh, d));
- if (ly_number_pair_p (sp))
- shorten[d] += gh_scm2double (index_get_cell (sp, d));
- }
- while (flip (&d) != LEFT);
-
- Real extra_short = 0;
-
- // For 'Mixed' style pedals, i.e. a bracket preceded by text: Ped._____|
- // need to shorten by the extent of the text grob
- if (to_boolean (me->get_grob_property ("text-start")))
- {
- height[LEFT] = 0;
- extra_short = padding;
- if (Grob *textbit = unsmob_grob (me->get_grob_property("pedal-text")))
- {
- if (textbit->internal_has_interface(ly_symbol2scm("text-interface")))
- // for plain text, e.g., Sost. Ped.
- {
- SCM text = textbit->get_grob_property("text");
- if (gh_string_p (text)) {
- SCM properties = Font_interface::font_alist_chain (me);
-
- Molecule mol = Text_item::interpret_new_markup (me->self_scm (),
- properties, text);
- extra_short += mol.extent(X_AXIS).length() / 2;
- }
- }
- }
- shorten[RIGHT] -= thick;
- }
-
- shorten[LEFT] += extra_short ;
-
- if (broken[LEFT])
- {
- shorten[LEFT] -= me->get_broken_left_end_align () ;
- shorten[RIGHT] += abs(width[RIGHT]) + thick - r[RIGHT];
- }
-
- else
- {
- // Shorten a ____/ on the right so that it will touch an adjoining \___
- shorten[RIGHT] += abs(width[LEFT]) + abs(width[RIGHT]) + thick;
- // Also shorten so that it ends just before the spanned note.
- shorten[RIGHT] -= (r[LEFT] + r[RIGHT]);
- }
-
- me->set_grob_property ("edge-height", ly_interval2scm (height));
- me->set_grob_property ("shorten-pair", ly_interval2scm (shorten));
-}
-
-
-struct Pianopedal
-{
- static bool has_interface (Grob*);
-};
-ADD_INTERFACE (Pianopedal,"piano-pedal-interface",
- "",
- "pedal-type edge-widen edge-height shorten-pair text-start left-widen right-widen pedal-text");
-
ADD_INTERFACE (Text_spanner,"text-spanner-interface",
"generic text spanner",
- "dash-period if-text-padding dash-length edge-height edge-widen edge-text shorten-pair style thickness enclose-bounds width-correct");
+ "dash-period if-text-padding dash-length edge-height bracket-flare edge-text shorten-pair style thickness enclose-bounds width-correct");
verticalAlignmentChildCallback = #Align_interface::alignment_callback
pedalSustainStrings = #'("Ped." "*Ped." "*")
+ pedalSustainStyle = #'text
pedalUnaCordaStrings = #'("una corda" "" "tre corde")
+ pedalUnaCordaStyle = #'text
%% These are in ordinary italic font, including the *,
%% but they are unlikely to be used,
%% as the default pedal-style for SostenutoPedal is 'mixed':
%% i.e. Sost. Ped_____________________
pedalSostenutoStrings = #'("Sost. Ped." "*Sost. Ped." "*")
+ pedalSostenutoStyle = #'mixed
+
tupletNumberFormatFunction = #denominator-tuplet-formatter
subdivideBeams = ##f
(grob-property-description 'right-position number? "position of right part of spanner.")
(grob-property-description 'left-padding ly:dimension? "space left of accs.")
-(grob-property-description 'left-widen boolean? "Whether the left edge of a piano pedal bracket should be widened by the first element of edge-widen.")
-
(grob-property-description 'length ly:dimension? "Stem length for unbeamed stems, only for user override.")
(grob-property-description 'lengths list? "Stem length given
multiplicity of flag. The Nth element of the list gives the stem
(grob-property-description 'oriscus boolean? "is this neume an oriscus?.")
(grob-property-description 'enclose-bounds boolean? "whether a text spanner should extend to the outer edge of the spanned notes")
(grob-property-description 'padding ly:dimension? "add this much extra space between objects that are next to each other.")
-(grob-property-description 'pedal-type symbol? "Style of piano pedal: text, bracket or mixed.")
(grob-property-description 'pedal-text ly:grob? "Pointer to the text of a mixed-style piano pedal.")
(grob-property-description 'penalty number? "Penalty for breaking at
this column. 10000 or more means forbid linebreak, -10000 or less
(grob-property-description 'ratio number? "Slur parameter. See height-limit.")
(grob-property-description 'right-padding ly:dimension? "space right of accs.")
(grob-property-description 'right-trim-amount ly:dimension? "shortening of the lyric extender on the right.")
-(grob-property-description 'right-widen boolean? "Whether the right edge of a piano pedal bracket should be widened by the second element of edge-widen")
(grob-property-description 'script-priority number? "A sorting key that determines in what order a script is within a stack of scripts.")
(grob-property-description 'self-alignment-X number-or-grob? "real number: -1 =
left aligned, 0 = center, 1 right-aligned in X direction.
(grob-property-description 'support-head ly:grob? "the note head at
one end of the stem.")
(grob-property-description 'text markup? "Text markup. See reference manual for more information.")
-(grob-property-description 'text-start boolean? "Indicator for whether a piano pedal bracket has leading text, such as Ped.")
(grob-property-description 'thick-thickness number? "thickness, measured in stafflinethickness.")
(grob-property-description 'thickness number? "thickness, measured in stafflinethickness.")
(grob-property-description 'thin-kern number? "space after a hair-line.")
(gap . 0.0)
(padding . 2.0)
(thickness . 1.6)
- (edge-widen . (0.0 . 0.0))
(edge-height . (0.7 . 0.7))
(shorten-pair . (-0.2 . -0.2))
(before-line-breaking-callback . ,Tuplet_bracket::before_line_breaking)
(PianoPedalBracket ;; an example of a text spanner
. (
(molecule-callback . ,Text_spanner::brew_molecule)
+ (after-line-breaking-callback . ,Piano_pedal_bracket::after_line_breaking)
(font-family . roman)
(style . line)
(if-text-padding . 1.0)
(width-correct . 0)
(enclose-bounds . #t)
(direction . -1)
- (edge-widen . (0.5 . 0.5))
+ (bracket-flare . (0.5 . 0.5))
(edge-height . (1.0 . 1.0))
(shorten-pair . (0.0 . 0.0))
(thickness . 1.0)
- (meta . ((interfaces . (text-spanner-interface piano-pedal-interface spanner-interface))))
+ (meta . ((interfaces . (text-spanner-interface piano-pedal-bracket-interface spanner-interface))))
))
(RepeatSlash
(X-offset-callbacks . (,Self_alignment_interface::aligned_on_self))
(no-spacing-rods . #t)
(padding . 0.0) ;; padding relative to SostenutoPedalLineSpanner
- (pedal-type . mixed)
(font-family . roman)
(font-shape . italic)
(self-alignment-X . 0)
(self-alignment-X . 0)
(direction . 1)
(padding . 0.0) ;; padding relative to SustainPedalLineSpanner
- (pedal-type . text)
(X-offset-callbacks . (,Self_alignment_interface::aligned_on_self))
(meta . ((interfaces . (piano-pedal-interface text-spanner-interface text-interface self-alignment-interface font-interface item-interface))))
))
(gap . 2.0)
(padding . 0.9)
(thickness . 1.6)
- (edge-widen . (0.0 . 0.0))
(edge-height . (0.7 . 0.7))
(shorten-pair . (-0.2 . -0.2))
(before-line-breaking-callback . ,Tuplet_bracket::before_line_breaking)
(no-spacing-rods . #t)
(self-alignment-X . 0)
(direction . 1)
- (pedal-type . text)
(padding . 0.0) ;; padding relative to UnaCordaPedalLineSpanner
(X-offset-callbacks . (,Self_alignment_interface::aligned_on_self))
(meta . ((interfaces . (text-interface self-alignment-interface font-interface item-interface ))))
this is done with the pedal.")
(translator-property-description 'pedalUnaCordaStrings list? "see pedalSustainStrings.")
(translator-property-description 'pedalSostenutoStrings list? "see pedalSustainStrings.")
+(translator-property-description 'pedalSustainStyle symbol? "A symbol
+that indicates how to print sustain pedals: text, bracket or mixed
+(both).")
+(translator-property-description 'pedalUnaCordaStyle symbol? "see pedalSustainStyle.")
+(translator-property-description 'pedalSostenutoStyle symbol? "see pedalSustainStyle.")
(translator-property-description 'phrasingPunctuation string?
"A string of characters that are considered