]> git.donarmstrong.com Git - lilypond.git/commitdiff
patch::: 1.3.33.jcn1
authorJan Nieuwenhuizen <janneke@gnu.org>
Tue, 14 Mar 2000 22:38:12 +0000 (23:38 +0100)
committerJan Nieuwenhuizen <janneke@gnu.org>
Tue, 14 Mar 2000 22:38:12 +0000 (23:38 +0100)
1.3.33.jcn1
===========

* Rewrote Staff_margin_engraver.  Staff margin texts now hang on a new
  breakable item: Left_edge_item.

* Fixed vertical alignment for dynamic elements.  Orphaned dynamic items
  (not supported by a Dynamic_line_spanner) still collide with Staff,
  although they now have staff support, which was supposed to fix this.

1.3.32.jcn4
===========

* Fixed Staff_margin_engraver for "instrument", "instr" is still broken.

* Dynamic elements are only put in a Dynamic_line_spanner if there
  actually is more than one adjacent note-column with a dynamic.
  This breaks the fine looks of all dynamics, again :-)

13 files changed:
CHANGES
VERSION
input/test/bar-break.ly [new file with mode: 0644]
input/test/bb.ly [new file with mode: 0644]
lily/dynamic-engraver.cc
lily/include/lily-proto.hh
lily/include/staff-margin-engraver.hh
lily/staff-margin-engraver.cc
ly/engraver.ly
ly/params.ly
mutopia/Coriolan/coriolan-paper.ly
mutopia/Coriolan/coriolan-part-paper.ly
scm/lily.scm

diff --git a/CHANGES b/CHANGES
index 5ee74be6f69105a9c61c0421691c320b503eb882..b12d85721c50b9a4780d2c23e7735855cc7aa47f 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,22 @@
+1.3.33.jcn1
+===========
+
+* Rewrote Staff_margin_engraver.  Staff margin texts now hang on a new
+  breakable item: Left_edge_item.
+
+* Fixed vertical alignment for dynamic elements.  Orphaned dynamic items
+  (not supported by a Dynamic_line_spanner) still collide with Staff,
+  although they now have staff support, which was supposed to fix this.
+
+1.3.32.jcn4
+===========
+
+* Fixed Staff_margin_engraver for "instrument", "instr" is still broken.
+
+* Dynamic elements are only put in a Dynamic_line_spanner if there
+  actually is more than one adjacent note-column with a dynamic.
+  This breaks the fine looks of all dynamics, again :-)
+
 1.3.33
 ======
 
diff --git a/VERSION b/VERSION
index 0c7ec166467859805a3dfccb00fe9411d32ca06f..3aec424aab5c19401d35b1f380fabc3c0fb17d07 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond
 MAJOR_VERSION=1
 MINOR_VERSION=3
 PATCH_LEVEL=33
-MY_PATCH_LEVEL=
+MY_PATCH_LEVEL=jcn1
 
 # use the above to send patches: MY_PATCH_LEVEL is always empty for a
 # released version.
diff --git a/input/test/bar-break.ly b/input/test/bar-break.ly
new file mode 100644 (file)
index 0000000..d45a9dd
--- /dev/null
@@ -0,0 +1,23 @@
+\score
+{
+  \context StaffGroup = a < 
+    \context PianoStaff = b <
+      \context Staff = "c" \notes\relative c'' { b1 \break b }
+      \context Staff = "d" \notes\relative c'' { b1 \break b }
+    >
+  >
+
+  \paper {
+       indent=100.0\mm;
+       linewidth=150.0\mm;
+    \translator
+    {
+      \StaffContext
+        \consists "Staff_margin_engraver";
+       numberOfStaffLines  = #1
+        marginScriptPadding = #10  % urg: this is in PT
+       instrument = #"Foo"
+       instr = #"Foo"
+    }
+  }
+}
diff --git a/input/test/bb.ly b/input/test/bb.ly
new file mode 100644 (file)
index 0000000..0c01477
--- /dev/null
@@ -0,0 +1,23 @@
+\score
+{
+  \context StaffGroup = a < 
+    \context PianoStaff = b <
+      \context Staff = "c" \notes\relative c'' { b1 \break b }
+      \context Staff = "d" \notes\relative c'' { b1 \break b }
+    >
+  >
+
+  \paper {
+       indent=100.0\mm;
+       linewidth=150.0\mm;
+    \translator
+    {
+      \StaffContext
+        \consists "Staff_margin_engraver";
+       numberOfStaffLines  = #1
+        marginScriptPadding = #30  % urg: this is in PT
+       instrument = #"Foo"
+       instr = #"Bar"
+    }
+  }
+}
index 87ab488ac69d193b33f935a6bb5ac922e6d0e968..dff3e7259325bfbbb768d40d0e4fafe8d564660f 100644 (file)
@@ -7,6 +7,7 @@
 */
 #include "debug.hh"
 #include "dimensions.hh"
+#include "dimension-cache.hh"
 #include "crescendo.hh"
 #include "musical-request.hh"
 #include "lookup.hh"
 #include "staff-symbol-referencer.hh"
 #include "translator-group.hh"
 
+
+/*
+  TODO:
+
+  * fix vertical placement of orphaned items
+  * fix padding 
+ */
+
 class Dynamic_line_spanner : public Spanner
 {
 public:
@@ -71,6 +80,9 @@ class Dynamic_engraver : public Engraver
 
   Dynamic_line_spanner* line_spanner_;
   Moment last_request_mom_;
+
+  Note_column* pending_column_;
+  Link_array<Score_element> pending_element_arr_;
   
   void  typeset_all ();
 
@@ -87,6 +99,7 @@ protected:
   virtual void do_process_music ();
   virtual void do_pre_move_processing ();
   virtual void do_post_move_processing ();
+  virtual void typeset_element (Score_element*);
 };
 
 ADD_THIS_TRANSLATOR (Dynamic_engraver);
@@ -107,6 +120,7 @@ Dynamic_engraver::Dynamic_engraver ()
   line_spanner_ = 0;
   span_start_req_l_ = 0;
   cresc_p_ =0;
+  pending_column_ = 0;
 
   text_req_l_ = 0;
   span_req_l_drul_[START] = 0;
@@ -153,18 +167,32 @@ Dynamic_engraver::do_try_music (Music * m)
 void
 Dynamic_engraver::do_process_music ()
 {
-  if ((span_req_l_drul_[START] || text_req_l_) && !line_spanner_)
+  if ((span_req_l_drul_[START] || text_req_l_)
+      && !line_spanner_
+      && pending_element_arr_.size ())
     {
       line_spanner_ = new Dynamic_line_spanner;
+      assert (pending_column_);
+      line_spanner_->add_column (pending_column_);
       side_position (line_spanner_).set_axis (Y_AXIS);
       announce_element (Score_element_info
                        (line_spanner_,
                         text_req_l_ ? text_req_l_ : span_req_l_drul_[START]));
 
     }
-         
+
+  if (line_spanner_ && pending_element_arr_.size ())
+    {
+      for (int i = 0; i < pending_element_arr_.size (); i++)
+       pending_element_arr_[i]->set_parent (line_spanner_, Y_AXIS);
+      pending_element_arr_.clear ();
+    }
+
   if (span_req_l_drul_[START] || text_req_l_)
     last_request_mom_ = now_mom ();
+  else
+    pending_element_arr_.clear ();
+
   
   if (text_req_l_)
     {
@@ -176,9 +204,10 @@ Dynamic_engraver::do_process_music ()
       text_p_->set_elt_property ("style", gh_str02scm ("dynamic"));
       text_p_->set_elt_property ("script-priority",
                                          gh_int2scm (100));
-         
-      assert (line_spanner_);
-      text_p_->set_parent (line_spanner_, Y_AXIS);
+      pending_element_arr_.push (text_p_);
+      text_p_->set_elt_property ("self-alignment-Y", gh_int2scm (0));
+      text_p_->dim_cache_[Y_AXIS]->off_callbacks_.push
+       (Side_position_interface::aligned_on_self);
       announce_element (Score_element_info (text_p_, text_req_l_));
     }
 
@@ -193,7 +222,6 @@ Dynamic_engraver::do_process_music ()
        {
          assert (!finished_cresc_p_);
          cresc_p_->set_bound(RIGHT, get_staff_info ().musical_pcol_l ());
-         //      cresc_p_->add_dependency (get_staff_info ().musical_pcol_l ());
          finished_cresc_p_ = cresc_p_;
          cresc_p_ = 0;
          span_start_req_l_ = 0;
@@ -238,8 +266,6 @@ Dynamic_engraver::do_process_music ()
          cresc_p_->set_bound(LEFT, get_staff_info ().musical_pcol_l ());
 
 
-         // cresc_p_->add_dependency (get_staff_info ().musical_pcol_l ());
-
          /* 
              We know how wide the text is, if we can be sure that the
              text already has relevant pointers into the paperdef,
@@ -247,6 +273,12 @@ Dynamic_engraver::do_process_music ()
 
              Since font-size may be set by a context higher up, we
              can not be sure of the size.
+
+
+             We shouldn't try to do this stuff here, the Item should
+             do it when the score is finished.  We could maybe
+             set a callback to have the Item do the alignment if
+             it is not a special symbol, like Crescendo.
          */
 
             
@@ -258,10 +290,10 @@ Dynamic_engraver::do_process_music ()
                index_set_cell (finished_cresc_p_->get_elt_property ("dynamic-drul"),
                                RIGHT, SCM_BOOL_T);
            }
-
-         assert (line_spanner_);
-         cresc_p_->set_parent (line_spanner_, Y_AXIS);
-         // cresc_p_->add_dependency (line_spanner_);
+         pending_element_arr_.push (cresc_p_);
+         cresc_p_->set_elt_property ("self-alignment-Y", gh_int2scm (0));
+         cresc_p_->dim_cache_[Y_AXIS]->off_callbacks_.push
+           (Side_position_interface::aligned_on_self);
          announce_element (Score_element_info (cresc_p_, span_req_l_drul_[START]));
        }
     }
@@ -291,6 +323,12 @@ Dynamic_engraver::do_removal_processing ()
     }
 }
 
+void
+Dynamic_engraver::typeset_element (Score_element* e)
+{
+  side_position (e).add_staff_support ();
+  Engraver::typeset_element (e);
+}
 
 void
 Dynamic_engraver::typeset_all ()
@@ -314,9 +352,6 @@ Dynamic_engraver::typeset_all ()
       * continue through piece */
   if (line_spanner_ && last_request_mom_ < now_mom ())
     {
-
-      side_position (line_spanner_).add_staff_support ();
-      
       typeset_element (line_spanner_);
       line_spanner_ = 0;
     }
@@ -325,12 +360,16 @@ Dynamic_engraver::typeset_all ()
 void
 Dynamic_engraver::acknowledge_element (Score_element_info i)
 {
-  if (line_spanner_)
+  if (Note_column* n = dynamic_cast<Note_column*> (i.elem_l_))
     {
-      if (Note_column* n = dynamic_cast<Note_column*> (i.elem_l_))
+      if (line_spanner_)
        {
          side_position (line_spanner_).add_support (n);
          line_spanner_->add_column (n);
        }
+      else
+       {
+         pending_column_ = n;
+       }
     }
 }
index d5f93d6a06baf6954efe074d84d92da186fe9079..8309d245a93783f3bd60f7257d01268ecb0f7f51 100644 (file)
@@ -113,6 +113,7 @@ struct Key_item;
 struct Key_performer;
 struct Keyword;
 struct Keyword_table;
+struct Left_edge_item;
 struct Lily_stream;
 struct Line_group_engraver;
 struct Line_of_score;
index 3841da0debe8783777f28ea1ad874a063e0bfc5f..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,27 +0,0 @@
-/*
-  staff-margin-engraver.hh -- declare Staff_margin_engraver
-
-  source file of the GNU LilyPond music typesetter
-
-  (c) 1998--2000 Jan Nieuwenhuizen <janneke@gnu.org>
-*/
-
-
-#ifndef STAFF_MARGIN_ENGRAVER_HH
-#define STAFF_MARGIN_ENGRAVER_HH
-
-#include "bar-script-engraver.hh"
-
-/**
-  put (instrument) text to left of line
- */
-class Staff_margin_engraver : public Bar_script_engraver
-{
-public:
-  VIRTUAL_COPY_CONS(Translator);
-  Staff_margin_engraver ();
-protected:
-  void acknowledge_element (Score_element_info);
-};
-
-#endif // STAFF_MARGIN_ENGRAVER_HH
index 8aecb00f3a45c941fa38577ea3b01eac08c05fbb..f3344955e429068361effaaba8b3fa4987194d70 100644 (file)
   (c) 1998--2000 Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
-#include "staff-margin-engraver.hh"
+#include "translator.hh"
+#include "engraver.hh"
 #include "bar.hh"
+#include "dimension-cache.hh"
 #include "timing-translator.hh"
 #include "text-item.hh"
 #include "side-position-interface.hh"
+#include "bar-script-engraver.hh"
 #include "staff-symbol-referencer.hh"
+#include "staff-symbol.hh"
+
+/*
+  TODO:
+
+    * padding
+    * merge with/derive from/add functionality to Bar_script_engraver
+ */
+
+/**
+   Hang on left edge of staff to provide suppor for simple items.
+ */
+class Left_edge_item : public Item
+{
+public:
+  VIRTUAL_COPY_CONS (Score_element);
+};
+
+/**
+  put (instrument) text to left of line
+ */
+class Staff_margin_engraver : public Engraver
+{
+public:
+  VIRTUAL_COPY_CONS (Translator);
+  Staff_margin_engraver ();
+
+protected:
+  virtual void do_pre_move_processing ();
+  virtual void acknowledge_element (Score_element_info);
+
+private:
+  String type_;
+  Text_item* text_p_;
+  Left_edge_item* left_edge_p_;
+  void create_text (SCM);
+};
 
 ADD_THIS_TRANSLATOR (Staff_margin_engraver);
 
+
 Staff_margin_engraver::Staff_margin_engraver ()
 {
-  axis_ = X_AXIS;
   type_ = "margin";
+  text_p_ = 0;
+  left_edge_p_ = 0;
 }
 
+void
+Staff_margin_engraver::acknowledge_element (Score_element_info info)
+{
+  SCM s = get_property ("instrument");
+  
+  if (now_mom () > Moment (0))
+    s = get_property ("instr");
+
+  //s = ly_str02scm ("HALLO");
+  
+  if (dynamic_cast<Bar*> (info.elem_l_) && gh_string_p (s))
+    create_text (s);
+}
 
-/*
-    TODO
-
-    should be able to set whole paragraph (multiple lines, center) to
-    left (right?) of staff, e.g.:
-                    ______
-                   |_______
-      2 Clarinetti |________
-         (Bb)      |___________
-                  |______________
-*/
 void
-Staff_margin_engraver::acknowledge_element (Score_element_info inf)
+Staff_margin_engraver::create_text (SCM text)
 {
-  Item *i = cast_to_interesting_item (inf.elem_l_);
-  if (!i || inf.origin_trans_l_arr (this).size() != 1)
-    return;
+  if (!text_p_)
+    {
+      assert (!left_edge_p_);
+      Left_edge_item* l = new Left_edge_item;
+      
+      l->set_elt_property ("breakable", SCM_BOOL_T);
+      l->set_elt_property ("break-aligned", SCM_BOOL_T);
 
+      announce_element (Score_element_info (l, 0));
 
-  SCM long_name = get_property ("instrument");
-  SCM short_name = get_property ("instr");
+      Staff_symbol_referencer_interface sl (l);
+      sl.set_interface ();
+      left_edge_p_ = l;
+      
+      Text_item* t = new Text_item;
 
-  if (now_mom () > Moment (0))
-    long_name = short_name;
+      t->set_elt_property ("self-alignment-Y", gh_int2scm (0));
+      t->dim_cache_[Y_AXIS]->off_callbacks_.push
+       (Side_position_interface::aligned_on_self);
 
-  if (gh_string_p (long_name))
-    {
-      create_items (0);
-      text_p_->set_elt_property ("text", long_name);
-      text_p_->set_elt_property ("direction", gh_int2scm (LEFT));
-      Bar_script_engraver::attach_script_to_item (i);
-
-      /*
-    UGH. ignores font size settings.
-   */
-      Interval iv(text_p_->extent (Y_AXIS));
-      text_p_->translate_axis (- iv.center (),  Y_AXIS);
-
-      Real staff_space = Staff_symbol_referencer_interface (text_p_).staff_space ();
-      SCM s = get_property ("staffMarginHorizontalPadding");
-      if (gh_number_p (s))
-       {
-         text_p_->translate_axis (gh_scm2double (s) * staff_space, X_AXIS);
-       }
-      s = get_property ("staffMarginVerticalPadding");
+      t->set_parent (l, X_AXIS);
+      t->set_parent (l, Y_AXIS);
+
+      // 'just to be sure': see Clef_item::do_add_processing
+      l->add_dependency (t);
+
+      announce_element (Score_element_info (t, 0));
+
+      SCM s = get_property (type_ + "ScriptPadding");
       if (gh_number_p (s))
        {
-         text_p_->translate_axis (gh_scm2double (s) * staff_space, Y_AXIS);
+         //t->set_elt_property ("padding", s);
+         t->translate_axis (-gh_scm2double (s), X_AXIS);
        }
+      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);
 }
 
+void
+Staff_margin_engraver::do_pre_move_processing ()
+{
+  if (text_p_)
+    {
+      text_p_->set_elt_property("visibility-lambda",
+                             ly_eval_str ("begin-of-line-visible"));
+      typeset_element (text_p_);
+      text_p_ = 0;
+      assert (left_edge_p_);
+      typeset_element (left_edge_p_);
+      left_edge_p_ = 0;
+    }
+}
index 93ca721d078c1d89fd6350cfad20aa06abf45131..f95e8cdf8dc92374c67d23eb57e020f01b277827 100644 (file)
@@ -113,7 +113,7 @@ VoiceContext = \translator {
        \type "Engraver_group_engraver";
        \name Voice;
 
-       dynamicPadding = #5.0
+       dynamicPadding = #2.0
        Generic_property_list = #generic-voice-properties
        \consists "Output_property_engraver";   
 
@@ -329,6 +329,7 @@ ScoreContext = \translator {
 %      \consists "Score_priority_engraver";
        \consists "Break_align_engraver";
        breakAlignOrder = #'(
+         "Left_edge_item"
          "Span_bar"
          "Breathing_sign"
          "Clef_item"
index 0f3052930e15da759c4424db7e8490d44c81b597..c57a1120d5e6bcb4df9bfd061f9c9eb20a7276e0 100644 (file)
@@ -41,6 +41,7 @@ arithmetic_multiplier = 0.9 * \quartwidth ;
 
 #'Stem_tremolo::beam-width = 1.5 * \quartwidth ; 
 
+#'Left_edge_item::visibility-lambda = #begin-of-line-visible
 #'Clef_item::visibility-lambda = #begin-of-line-visible
 #'Key_item::visibility-lambda = #begin-of-line-visible
 #'Breathing_sign::visibility-lambda = #begin-of-line-invisible
index 9c059b4e025af998d6a5e7158c67524ab31dc589..a7f4dbb1d5d2519f0b4254163185d6de5229eaed 100644 (file)
@@ -28,6 +28,7 @@
        }
        \translator { 
                \HaraKiriStaffContext 
+               marginScriptPadding = #10  %% urg, this is in pt
                \accepts "VoiceOne";
                \accepts "VoiceTwo";
        }
index 67df401e1517e8e39bc3d8bf6e8cbaa7550617fa..5f863ca3e2db3235cd2b0f03dcbd15ef92e7f4bf 100644 (file)
@@ -1,5 +1,8 @@
 \paper {
-       \translator { \OrchestralPartStaffContext }
+       \translator { 
+               \OrchestralPartStaffContext 
+               marginScriptPadding = #10  %% urg, this is in pt
+       }
        \translator {
                \VoiceContext
                \name "VoiceOne";
index aef1ec55ccb4970797617fca71aac480252c7f8a..f5965cb7f286a72e7dfa82ed987aa8d85076a3eb 100644 (file)
 ;; (Measured in staff space)
 (define space-alist
  '(
+   (("" "Left_edge_item") . (minimum-space -15.0))
    (("" "Clef_item") . (minimum-space 1.0))
    (("" "Staff_bar") . (minimum-space 0.0))
    (("" "Clef_item") . (minimum-space 1.0))