From a211794c0968603f176964e20c4f733450f4dcb8 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Thu, 16 Mar 2000 13:30:41 +0100 Subject: [PATCH] patch::: 1.3.34.jcn3 1.3.34.jcn3 =========== * Small enhancements to Staff_margin_engraver: - by default, the marginScript left aligns the text - to set the text style, use property marginScriptTextStyle - to change the alignment, use property marginScriptHorizontalAlignment (centred and right alignment require manual padding settings). --- CHANGES | 9 +++++ VERSION | 2 +- input/test/coriolan-margin.ly | 8 ++++- lily/staff-margin-engraver.cc | 63 ++++++++++++++++++++++++++++++----- ly/engraver.ly | 2 ++ 5 files changed, 74 insertions(+), 10 deletions(-) diff --git a/CHANGES b/CHANGES index 1b19b2dcd6..17988e6c44 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,12 @@ +1.3.34.jcn3 +=========== + +* Small enhancements to Staff_margin_engraver: + - by default, the marginScript left aligns the text + - to set the text style, use property marginScriptTextStyle + - to change the alignment, use property marginScriptHorizontalAlignment + (centred and right alignment require manual padding settings). + 1.3.34.jcn2 =========== diff --git a/VERSION b/VERSION index 035504b9c9..8bbc082e15 100644 --- a/VERSION +++ b/VERSION @@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=1 MINOR_VERSION=3 PATCH_LEVEL=34 -MY_PATCH_LEVEL=jcn2 +MY_PATCH_LEVEL=jcn3 # use the above to send patches: MY_PATCH_LEVEL is always empty for a # released version. diff --git a/input/test/coriolan-margin.ly b/input/test/coriolan-margin.ly index 3f323c24e0..ed5103356d 100644 --- a/input/test/coriolan-margin.ly +++ b/input/test/coriolan-margin.ly @@ -3,6 +3,8 @@ flauti = \notes \relative c' { \property Staff.instr = #"Fl." c1 \break c +% \break c +% \break c \bar"|."; } @@ -61,7 +63,8 @@ violino2 = \notes \relative c' { viola = \notes \relative c' { \property Staff.instrument = #"Viola" \property Staff.instr = #"Vla." - c1 c + c1 c + %c } violoncello = \notes \relative c' { @@ -121,6 +124,9 @@ violoncello = \notes \relative c' { \ScoreContext instrumentScriptPadding = #55 %% urg, this is in pt instrScriptPadding = #35 + marginScriptHorizontalAlignment = #1 + %marginScriptPadding = #15 + %marginScriptHorizontalAlignment = #0 } } } diff --git a/lily/staff-margin-engraver.cc b/lily/staff-margin-engraver.cc index 3472bcf54f..88adb28af6 100644 --- a/lily/staff-margin-engraver.cc +++ b/lily/staff-margin-engraver.cc @@ -10,6 +10,7 @@ #include "engraver.hh" #include "bar.hh" #include "dimension-cache.hh" +#include "directional-element-interface.hh" #include "timing-translator.hh" #include "text-item.hh" #include "side-position-interface.hh" @@ -20,7 +21,8 @@ /* TODO: - * padding + * align over full score + * text aligment: left, centred, right * merge with/derive from/add functionality to Bar_script_engraver */ @@ -105,28 +107,73 @@ Staff_margin_engraver::create_text (SCM text) // 'just to be sure': see Clef_item::do_add_processing l->add_dependency (t); - announce_element (Score_element_info (t, 0)); /* Hmm. In almost every score that uses "instrument" and "instr" we need two different paddings. Let's try one of those first: - instrumentScriptPadding/instrScriptPadding - */ + instrumentScriptPadding/instrScriptPadding + */ SCM s = get_property (String (now_mom () ? "instr" : "instrument") + "ScriptPadding"); if (!gh_number_p (s)) s = get_property (type_ + "ScriptPadding"); + + Real padding = 0; if (gh_number_p (s)) + padding = gh_scm2double (s); + + s = get_property (type_ + "ScriptTextStyle"); + if (gh_string_p (s)) + t->set_elt_property ("style", s); + + s = get_property (type_ + "ScriptHorizontalAlignment"); + /* + Allow centred, + */ + if (gh_number_p (s) && !gh_scm2int (s)) + { + t->set_elt_property ("self-alignment-X", gh_int2scm (0)); + t->add_offset_callback (Side_position_interface::aligned_on_self, X_AXIS); + /* +% Centred is still broken, it always requires proper padding. + */ + padding *= -1; + if (padding) + t->translate_axis (padding, X_AXIS); + } + /* + left or right alignment. + */ + else { - //t->set_elt_property ("padding", s); - t->translate_axis (-gh_scm2double (s), X_AXIS); + side_position (t).set_axis (X_AXIS); + side_position (t).add_support (l); + + Direction d; + if (isdir_b (s)) + d = to_dir (s); + /* + By default, align at left edge of Left_edge_item, + (which makes text right-aligned) + so that we don't collide with staff. + */ + else + d = LEFT; + + directional_element (t).set (d); + padding *= -d; + if (padding) + t->set_elt_property ("padding", gh_double2scm (padding)); } + + + announce_element (Score_element_info (t, 0)); text_p_ = t; } - //text_p_->set_elt_property ("style", s); - //text_p_->set_elt_property ("direction", gh_int2scm (RIGHT)); + + text_p_->set_elt_property ("text", text); } diff --git a/ly/engraver.ly b/ly/engraver.ly index 0f179cb3c9..a97abe6d6e 100644 --- a/ly/engraver.ly +++ b/ly/engraver.ly @@ -322,6 +322,8 @@ ScoreContext = \translator { \type Score_engraver; \name Score; + marginScriptPadding = #10 % urg, in \pt + \consists "Timing_engraver"; \consists "Output_property_engraver"; -- 2.39.5