]> git.donarmstrong.com Git - lilypond.git/commitdiff
Merge branch 'master' into translation
authorJean-Charles Malahieude <lilyfan@orange.fr>
Tue, 21 Feb 2017 14:32:06 +0000 (15:32 +0100)
committerJean-Charles Malahieude <lilyfan@orange.fr>
Tue, 21 Feb 2017 14:32:06 +0000 (15:32 +0100)
18 files changed:
Documentation/changes.tely
Documentation/notation/editorial.itely
Documentation/snippets/analysis-brackets-with-labels.ly [new file with mode: 0644]
Documentation/snippets/editorial-annotations.snippet-list
Documentation/snippets/new/analysis-brackets-with-labels.ly [new file with mode: 0644]
Documentation/snippets/tweaks-and-overrides.snippet-list
input/regression/horizontal-bracket-broken-texted.ly [new file with mode: 0644]
input/regression/horizontal-bracket-texted.ly [new file with mode: 0644]
lily/horizontal-bracket-engraver.cc
lily/horizontal-bracket.cc
lily/lexer.ll
lily/lily-modules.cc
lily/module-scheme.cc
lily/one-page-breaking.cc
scm/define-grob-interfaces.scm
scm/define-grob-properties.scm
scm/define-grobs.scm
scm/output-lib.scm

index 2a647782442518f0e8eb42656a5a04ca1378193b..f205d0014cb270556d9d6c1bf52de721d4d0e13b 100644 (file)
@@ -61,6 +61,24 @@ which scares away people.
 
 @end ignore
 
+@item
+It is now possible to add text to analysis brackets through the
+@code{HorizontalBracketText} object.
+@lilypond[quote,verbatim]
+\layout {
+  \context {
+    \Voice
+    \consists "Horizontal_bracket_engraver"
+  }
+}
+
+{
+  \once \override HorizontalBracketText.text = "a"
+  c''\startGroup d''\stopGroup
+  e''-\tweak text "a'" \startGroup d''\stopGroup
+}
+@end lilypond
+
 @item
 The ends of hairpins may now be fine-tuned using the @code{shorten-pair}
 grob property, which previously only affected text-spanners like
index 458fce1ff4d97dbd8c6f27c6afb0f14ed297f2df..8dc3ac9612991082a43eac6d014d02f065a893c9 100644 (file)
@@ -879,12 +879,19 @@ Analysis brackets may be nested.
 }
 @end lilypond
 
-@seealso
-Snippets:
-@rlsr{Editorial annotations}.
+@snippets
 
+@lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
+{analysis-brackets-above-the-staff.ly}
+
+@lilypondfile[verbatim,quote,ragged-right,texidoc,doctitle]
+{analysis-brackets-with-labels.ly}
+
+@seealso
 Internals Reference:
 @rinternals{Horizontal_bracket_engraver},
 @rinternals{HorizontalBracket},
 @rinternals{horizontal-bracket-interface},
+@rinternals{HorizontalBracketText},
+@rinternals{horizontal-bracket-text-interface},
 @rinternals{Staff}.
diff --git a/Documentation/snippets/analysis-brackets-with-labels.ly b/Documentation/snippets/analysis-brackets-with-labels.ly
new file mode 100644 (file)
index 0000000..750ba8b
--- /dev/null
@@ -0,0 +1,46 @@
+% DO NOT EDIT this file manually; it is automatically
+% generated from Documentation/snippets/new
+% Make any changes in Documentation/snippets/new/
+% and then run scripts/auxiliar/makelsr.py
+%
+% This file is in the public domain.
+%% Note: this file works from version 2.19.55
+\version "2.19.55"
+
+\header {
+  lsrtags = "editorial-annotations, tweaks-and-overrides"
+
+  texidoc = "
+Text may be added to analysis brackets through the @code{text} property
+of the @code{HorizontalBracketText} grob.  Adding different texts to
+brackets beginning at the same time requires the @code{\\tweak} command.
+Bracket text will be parenthesized after a line break.
+
+"
+  doctitle = "Analysis brackets with labels"
+} % begin verbatim
+
+
+\layout {
+  \context {
+    \Voice
+    \consists "Horizontal_bracket_engraver"
+    \override HorizontalBracket.direction = #UP
+  }
+}
+
+{
+  \once\override HorizontalBracketText.text = "a"
+  c''\startGroup d''\stopGroup
+  \once\override HorizontalBracketText.text = "a'"
+  e''\startGroup d''\stopGroup
+  c''
+  -\tweak text \markup \bold \huge "b" \startGroup
+  -\tweak text "a" \startGroup
+  d''\stopGroup
+  e''-\tweak text "a'" \startGroup
+  d''\stopGroup\stopGroup
+  c''-\tweak text foo \startGroup d'' e'' f''
+  \break
+  g'' a'' b'' c'''\stopGroup
+}
index bfe4bfffdc32dd8c83dac03a2f0109bffb3616cb..62db50fef809198722caa591c4fe950e1cdfd71c 100644 (file)
@@ -4,6 +4,7 @@ adding-markups-in-a-tablature.ly
 allowing-fingerings-to-be-printed-inside-the-staff.ly
 alternative-bar-numbering.ly
 analysis-brackets-above-the-staff.ly
+analysis-brackets-with-labels.ly
 applying-note-head-styles-depending-on-the-step-of-the-scale.ly
 avoiding-collisions-with-chord-fingerings.ly
 blanking-staff-lines-using-the--whiteout-command.ly
diff --git a/Documentation/snippets/new/analysis-brackets-with-labels.ly b/Documentation/snippets/new/analysis-brackets-with-labels.ly
new file mode 100644 (file)
index 0000000..30ae349
--- /dev/null
@@ -0,0 +1,38 @@
+\version "2.19.55"
+
+\header {
+  lsrtags = "editorial-annotations, tweaks-and-overrides"
+
+  texidoc = "
+Text may be added to analysis brackets through the @code{text} property
+of the @code{HorizontalBracketText} grob.  Adding different texts to
+brackets beginning at the same time requires the @code{\tweak} command.
+Bracket text will be parenthesized after a line break.
+
+"
+  doctitle = "Analysis brackets with labels"
+}
+
+\layout {
+  \context {
+    \Voice
+    \consists "Horizontal_bracket_engraver"
+    \override HorizontalBracket.direction = #UP
+  }
+}
+
+{
+  \once\override HorizontalBracketText.text = "a"
+  c''\startGroup d''\stopGroup
+  \once\override HorizontalBracketText.text = "a'"
+  e''\startGroup d''\stopGroup
+  c''
+  -\tweak text \markup \bold \huge "b" \startGroup
+  -\tweak text "a" \startGroup
+  d''\stopGroup
+  e''-\tweak text "a'" \startGroup
+  d''\stopGroup\stopGroup
+  c''-\tweak text foo \startGroup d'' e'' f''
+  \break
+  g'' a'' b'' c'''\stopGroup
+}
index b0bf51340d84c1233da34532774be4cb0e5ae1c6..7461b97e98eebf29f8367eedcd018d7f8e571c87 100644 (file)
@@ -7,6 +7,7 @@ adjusting-lyrics-vertical-spacing.ly
 altering-the-length-of-beamed-stems.ly
 alternative-bar-numbering.ly
 analysis-brackets-above-the-staff.ly
+analysis-brackets-with-labels.ly
 asymmetric-slurs.ly
 avoiding-collisions-with-chord-fingerings.ly
 caesura-railtracks-with-fermata.ly
diff --git a/input/regression/horizontal-bracket-broken-texted.ly b/input/regression/horizontal-bracket-broken-texted.ly
new file mode 100644 (file)
index 0000000..1f84552
--- /dev/null
@@ -0,0 +1,25 @@
+\version "2.19.55"
+
+\header {
+  texidoc = "Text is parenthesized when analysis brackets cross line
+breaks.
+"
+}
+
+\layout {
+  \context {
+    \Voice
+    \consists "Horizontal_bracket_engraver"
+  }
+}
+
+{
+  c''
+  -\tweak text \markup \draw-circle #1 #0.5 ##f \startGroup
+  -\tweak text "a" \startGroup
+  d'' e'' f''
+  g'' a'' b'' c'''\stopGroup
+  c'''-\tweak text "a'" \startGroup b'' a'' g''
+  \break
+  f'' e'' d'' c''\stopGroup\stopGroup
+}
diff --git a/input/regression/horizontal-bracket-texted.ly b/input/regression/horizontal-bracket-texted.ly
new file mode 100644 (file)
index 0000000..dc1a673
--- /dev/null
@@ -0,0 +1,36 @@
+\version "2.19.55"
+
+\header {
+  texidoc = "Labels may be added to analysis brackets through the
+@code{text} property of the @code{HorizontalBracketText} object.  Use of
+the @code{\tweak} command is necessary for assigning text uniquely to
+brackets beginning at the same moment.  Text assignments reflect the
+usual nesting order of brackets.
+"
+}
+
+\layout {
+  \context {
+    \Voice
+    \consists "Horizontal_bracket_engraver"
+    \override HorizontalBracket.direction = #UP
+  }
+}
+
+\relative c'' {
+  \time 3/4
+  \key f \major
+  c4
+  -\tweak text "contrasting period" \startGroup
+  -\tweak text "a" \startGroup
+  a8( bes c f)
+  f4( e d)
+  c d8( c bes c)
+  \appoggiatura bes4 a2 g4\stopGroup
+  \once\override HorizontalBracketText.text = "b"
+  f'8 \startGroup
+  r a, r d r
+  c4( e, f)
+  g8( bes) a4 g8( f)
+  f2 \stopGroup \stopGroup r4
+}
index 6dd34c17855f564989dcf79ccedfa9da3a6f018a..1f176a321591a5c18b5446e506ed8182c3266199 100644 (file)
@@ -33,6 +33,7 @@ class Horizontal_bracket_engraver : public Engraver
 public:
   TRANSLATOR_DECLARATIONS (Horizontal_bracket_engraver);
   vector<Spanner *> bracket_stack_;
+  vector<Spanner *> text_stack_;
   vector<Stream_event *> events_;
   vsize pop_count_;
   vsize push_count_;
@@ -81,6 +82,8 @@ Horizontal_bracket_engraver::acknowledge_note_column (Grob_info gi)
                                          ly_symbol2scm ("columns"), gi.grob ());
       add_bound_item (bracket_stack_[i],
                       gi.grob ());
+      add_bound_item (text_stack_[i],
+                      gi.grob ());
     }
 }
 
@@ -91,10 +94,25 @@ Horizontal_bracket_engraver::process_music ()
     {
       Spanner *sp = make_spanner ("HorizontalBracket", events_[k]->self_scm ());
 
+      Spanner *hbt = make_spanner ("HorizontalBracketText", events_[k]->self_scm ());
+
+      sp->set_object ("bracket-text", hbt->self_scm ());
+
+      Side_position_interface::add_support (hbt, sp);
+
+      hbt->set_parent (sp, X_AXIS);
+      hbt->set_parent (sp, Y_AXIS);
+      hbt->set_object ("bracket", sp->self_scm ());
+
       for (vsize i = 0; i < bracket_stack_.size (); i++)
         /* sp is the smallest, it should be added to the bigger brackets.  */
-        Side_position_interface::add_support (bracket_stack_[i], sp);
+        {
+          Side_position_interface::add_support (bracket_stack_[i], sp);
+          Side_position_interface::add_support (bracket_stack_[i], hbt);
+        }
+
       bracket_stack_.push_back (sp);
+      text_stack_.push_back (hbt);
     }
 }
 
@@ -102,8 +120,12 @@ void
 Horizontal_bracket_engraver::stop_translation_timestep ()
 {
   for (vsize i = pop_count_; i--;)
-    if (bracket_stack_.size ())
-      bracket_stack_.pop_back ();
+    {
+      if (bracket_stack_.size ())
+        bracket_stack_.pop_back ();
+      if (text_stack_.size ())
+        text_stack_.pop_back ();
+    }
   pop_count_ = 0;
   push_count_ = 0;
   events_.clear ();
@@ -122,7 +144,8 @@ ADD_TRANSLATOR (Horizontal_bracket_engraver,
                 " purposes.",
 
                 /* create */
-                "HorizontalBracket ",
+                "HorizontalBracket "
+                "HorizontalBracketText ",
 
                 /* read */
                 "",
index ddeec44d750e74b12fd0cef139280846dc62293d..cf37516d5c0c0b697659f10d003ffafd05ec9392 100644 (file)
@@ -92,11 +92,6 @@ Horizontal_bracket::make_enclosing_bracket (Grob *me, Grob *refpoint,
     }
 }
 
-/*
-  TODO:
-
-  Support texts on the brackets?
-*/
 MAKE_SCHEME_CALLBACK (Horizontal_bracket, print, 1);
 SCM
 Horizontal_bracket::print (SCM smob)
@@ -127,6 +122,7 @@ ADD_INTERFACE (Horizontal_bracket,
 
                /* properties */
                "bracket-flare "
+               "bracket-text "
                "columns "
                "edge-height "
                "shorten-pair "
index bfd2449e6b3e23ba2ec88b7a509791851fef2751..534823118034810f182efae2f71898f1f70d74cf 100644 (file)
@@ -689,9 +689,9 @@ BOM_UTF8    \357\273\277
                for (; scm_is_pair(s); s = scm_cdr(s)) {
                  SCM predicate = scm_car(s);
 
-                 if (predicate == Lily::markup_list_p)
+                 if (scm_is_eq (predicate, SCM (Lily::markup_list_p)))
                    push_extra_token (here_input (), EXPECT_MARKUP_LIST);
-                 else if (predicate == Lily::markup_p)
+                 else if (scm_is_eq (predicate, SCM (Lily::markup_p)))
                    push_extra_token (here_input (), EXPECT_MARKUP);
                  else
                    push_extra_token (here_input (), EXPECT_SCM, predicate);
@@ -967,9 +967,9 @@ Lily_lexer::scan_scm_id (SCM sid)
                        cs = SCM_CAR (cs);
                }
 
-               if (scm_is_eq (cs, Lily::ly_music_p))
+               if (scm_is_eq (cs, SCM (Lily::ly_music_p)))
                        funtype = MUSIC_FUNCTION;
-               else if (scm_is_eq (cs, Lily::ly_event_p))
+               else if (scm_is_eq (cs, SCM (Lily::ly_event_p)))
                        funtype = EVENT_FUNCTION;
                else if (ly_is_procedure (cs))
                        funtype = SCM_FUNCTION;
index 5d35018e72e734d498c237cb83e8c937f2ec6e58..ef3a11cc2c84648fa25be8f63cca186c9882cbc7 100644 (file)
@@ -77,7 +77,7 @@ Scm_module::boot (void (*init) ())
   for (Variable_record *p = variables_; p; )
     {
       Variable_record *next = p->next_;
-      if (SCM_UNBNDP (*p->var_))
+      if (SCM_UNBNDP (SCM (*p->var_)))
         error (_f ("Uninitialized variable `%s' in module (%s)", p->name_, name_));
       delete p;
       p = next;
index 8ea17ddb26d6d434594ac59e4459669ed0972190..eda467fe68b259336663f08ccfaf72f1e2818afb 100644 (file)
@@ -33,7 +33,7 @@ module_define_closure_func (void *closure,
                             SCM val,
                             SCM /* result */)
 {
-  SCM module = (SCM) closure;
+  SCM module = *static_cast<SCM *> (closure);
   if (to_boolean (scm_variable_bound_p (val)))
     scm_module_define (module, key, scm_variable_ref (val));
   return SCM_EOL;
@@ -46,7 +46,7 @@ LY_DEFINE (ly_module_copy, "ly:module-copy",
 #define FUNC_NAME __FUNCTION__
   SCM_VALIDATE_MODULE (1, src);
   scm_internal_hash_fold ((scm_t_hash_fold_fn) &module_define_closure_func,
-                          (void *) dest,
+                          static_cast<void *> (&dest),
                           SCM_EOL, SCM_MODULE_OBARRAY (src));
   return SCM_UNSPECIFIED;
 }
index 6962aaf20508b1ce93a0e39ba691bb031cccb46a..bba283d9612382eb9a9f5e6de3cd46f15970b9ff 100644 (file)
@@ -94,7 +94,7 @@ One_page_breaking::solve ()
     {
       SCM this_pos = scm_car (c);
       line_posns.push_back (scm_to_double (this_pos));
-      if (scm_gr_p (this_pos, lowest_line_pos))
+      if (scm_is_true (scm_gr_p (this_pos, lowest_line_pos)))
         lowest_line_pos = this_pos;
     }
 
index d5f23113961f88049016d1670f252d535c9fb3ee..ffcfc355113af36777ec91bb8bce72930e5a870b 100644 (file)
@@ -149,6 +149,11 @@ or 15 (two octaves), but LilyPond allows any integer here."
  '(columns
    common-shortest-duration))
 
+(ly:add-interface
+ 'horizontal-bracket-text-interface
+ "Label for an analysis bracket."
+ '(bracket columns))
+
 (ly:add-interface
  'inline-accidental-interface
  "An inlined accidental (i.e. normal accidentals, cautionary
index 34450a9d23000eb79d4b1ec71be38abb90540ab3..e950d53b3a712f32d7020a794f3a69a7fb94762c 100644 (file)
@@ -1250,6 +1250,7 @@ for positioning elements that align with a column.")
 column as start/@/begin point.  Only columns that have grobs or act as
 bounds are spaced.")
      (bracket ,ly:grob? "The bracket for a number.")
+     (bracket-text ,ly:grob? "The text for an analysis bracket.")
 
      (c0-position ,integer? "An integer indicating the position of
 middle@tie{}C.")
index a04e07018cc0a3a07c27550927ef8a9052a39af8..45cac04bd3d65b1146beec8acdf89b42bcf8be7c 100644 (file)
                                 side-position-interface
                                 spanner-interface))))))
 
+    (HorizontalBracketText
+     . (
+        (direction . ,ly:horizontal-bracket-text::calc-direction)
+        (font-size . -1)
+        (padding . 0.5)
+        (parent-alignment-X . ,CENTER)
+        (self-alignment-X . ,CENTER)
+        (side-axis . ,Y)
+        (stencil . ,ly:horizontal-bracket-text::print)
+        (X-offset . ,ly:self-alignment-interface::aligned-on-x-parent)
+        (Y-offset . ,side-position-interface::y-aligned-side)
+        (meta . ((class . Spanner)
+                 (interfaces . (font-interface
+                                horizontal-bracket-text-interface
+                                outside-staff-interface
+                                self-alignment-interface
+                                side-position-interface
+                                text-interface))))))
 
     (InstrumentName
      . (
index 5184fdb3377fae3444b6d3a6b40a3d7075ab7611..8df9b56ef2489c4bcbd6737c71523016bf405d27 100644 (file)
@@ -1548,6 +1548,33 @@ numbered in parentheses."
              X)))
     num))
 
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; HorizontalBracketText
+
+(define-public (ly:horizontal-bracket-text::print grob)
+  (let ((text (ly:grob-property grob 'text)))
+    (if (or (null? text)
+            (equal? text "")
+            (equal? text empty-markup))
+        (begin
+          (ly:grob-suicide! grob)
+          '())
+        (let* ((orig (ly:grob-original grob))
+               (siblings (ly:spanner-broken-into orig))
+               (text
+                 (if (or (null? siblings)
+                         (eq? grob (car siblings)))
+                     text
+                     (if (string? text)
+                         (string-append "(" text ")")
+                         (make-parenthesize-markup text)))))
+          (grob-interpret-markup grob text)))))
+
+(define-public (ly:horizontal-bracket-text::calc-direction grob)
+  (let* ((bracket (ly:grob-object grob 'bracket))
+         (bracket-dir (ly:grob-property bracket 'direction DOWN)))
+    bracket-dir))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; make-engraver helper macro