]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/staff-margin-engraver.cc
release: 1.1.41
[lilypond.git] / lily / staff-margin-engraver.cc
index 9b51b97c7c0fae918ee9c9548b4e74387224ae4e..2d352365f62fa3f82a015421a8e96e240a2e5bd3 100644 (file)
@@ -3,33 +3,30 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1998 Jan Nieuwenhuizen <janneke@gnu.org>
+  (c) 1998--1999 Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
 #include "staff-margin-engraver.hh"
-#include "script.hh"
-#include "text-def.hh"
-#include "paper-def.hh"
-#include "command-request.hh"
 #include "bar.hh"
-#include "stem.hh"
 #include "time-description.hh"
-
+#include "g-text-item.hh"
+#include "g-staff-side.hh"
 
 ADD_THIS_TRANSLATOR (Staff_margin_engraver);
 
 Staff_margin_engraver::Staff_margin_engraver ()
 {
-  script_p_ = 0;
+  axis_ = X_AXIS;
+  type_ = "margin";
+  visibility_lambda_
+    = gh_eval_str ("postbreak_only_visibility");
 }
 
 
-
 /*
     TODO
-    fix alignment/support
 
-    should be able to set whole paragraph (multiple lines, centre) to
+    should be able to set whole paragraph (multiple lines, center) to
     left (right?) of staff, e.g.:
                     ______
                    |_______
@@ -38,54 +35,31 @@ Staff_margin_engraver::Staff_margin_engraver ()
                   |______________
 */
 void
-Staff_margin_engraver::acknowledge_element (Score_element_info i)
+Staff_margin_engraver::acknowledge_element (Score_element_info inf)
 {
-  Item * it =  dynamic_cast <Item *> (i.elem_l_);
-
-  if (!it
-      || script_p_ 
-      || !(dynamic_cast<Bar *> (it))
-      || (i.origin_grav_l_arr_.size() != 1))
+  Item *i = cast_to_interesting_item (inf.elem_l_);
+  if (!i || inf.origin_grav_l_arr_.size() != 1)
     return;
 
-  String string = get_property ("instrument");
-  String str = get_property ("instr");
-  if (now_moment () > Moment (0))
-    string = str;
 
-  if (!string.length_i ())
-    return;
+  String long_str = get_property ("instrument", 0);
+  String str = get_property ("instr", 0);
+  if (now_mom () > Moment (0) && str.length_i ())
+    long_str = str;
 
-  script_p_ = new Script;
-  script_p_->axis_ = X_AXIS;
-  
-  Text_def *td_p =new Text_def;
-  td_p->align_dir_ = LEFT;
-  td_p->text_str_ = string;
-  // huh?
-  script_p_->dir_ = RIGHT;
-  script_p_->specs_p_ = td_p;
-  script_p_->breakable_b_ = true;
+  if (long_str.empty_b ())
+    return;
 
-  
-  Scalar pri = get_property ("marginBreakPriority");
-  if (pri.length_i () && pri.isnum_b ())
-    {
-      script_p_->break_priority_i_ = int (pri);
-    }
-  else
-    script_p_ ->break_priority_i_ = it->break_priority_i_;
+  create_items (0);
+  text_p_->text_str_ = long_str;
+  staff_side_p_->dir_ = LEFT;
+  Bar_script_engraver::do_acknowledge_element (i);
 
-  announce_element (Score_element_info (script_p_, 0));
+  /*
+    UGH. ignores font size settings.
+   */
+  Interval iv(text_p_->extent (Y_AXIS));
+  text_p_->translate_axis (- iv.center (),  Y_AXIS);
 }
 
-void
-Staff_margin_engraver::do_pre_move_processing ()
-{
-  if (script_p_) 
-    {
-      typeset_element (script_p_);
-      script_p_ =0;
-    }
-}