]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/mark-engraver.cc
release: 1.3.46
[lilypond.git] / lily / mark-engraver.cc
index 1158daec6e39ffbabfbd866886958c650950c67a..0c2b543d465c02acc38006f2e221b4e11bf55466 100644 (file)
@@ -6,19 +6,41 @@
  (c) 1998--2000 Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
+
+#include "bar.hh"
+#include "clef-item.hh"
 #include "command-request.hh"
-#include "bar-script-engraver.hh"
+#include "dimension-cache.hh"
 #include "engraver-group-engraver.hh"
+#include "engraver.hh"
+#include "lily-guile.hh"
+#include "paper-column.hh"
+#include "paper-def.hh"
+#include "protected-scm.hh"
+#include "side-position-interface.hh"
+#include "staff-symbol-referencer.hh"
+#include "staff-symbol.hh"
 #include "text-item.hh"
 
-/**Print rehearsal marks.
-  */
-class Mark_engraver : public Bar_script_engraver 
+/**
+  put stuff over or next to  bars.  Examples: bar numbers, marginal notes,
+  rehearsal marks.
+ */
+class Mark_engraver : public Engraver
 {
 public:
-  Mark_engraver ();
   VIRTUAL_COPY_CONS(Translator);
+  Mark_engraver ();
 protected:
+  Text_item* text_p_;
+  Protected_scm visibility_lambda_;
+  Protected_scm staffs_;
+  
+protected:
+  virtual void do_creation_processing ();
+  virtual void do_pre_move_processing ();
+  virtual void acknowledge_element (Score_element_info);
+  void create_items(Request*);
   virtual bool do_try_music (Music *req_l);
   virtual void do_process_music ();
   virtual void do_post_move_processing ();
@@ -29,13 +51,94 @@ private:
 
 ADD_THIS_TRANSLATOR (Mark_engraver);
 
+
 Mark_engraver::Mark_engraver ()
 {
+  text_p_ =0;
   mark_req_l_ = 0;
-  axis_ = Y_AXIS;
-  type_ = "mark";
+  staffs_ = SCM_EOL;
+}
+
+void
+Mark_engraver::do_creation_processing ()
+{
+  String t = "markVisibilityFunction";
+  SCM proc = get_property (t);
+
+  if (gh_procedure_p (proc))
+    visibility_lambda_ = proc;
+}
+
+
+
+void
+Mark_engraver::acknowledge_element (Score_element_info inf)
+{
+  Score_element * s = inf.elem_l_;
+  if (dynamic_cast<Staff_symbol*> (s))
+    {
+      staffs_ = gh_cons (inf.elem_l_->self_scm_, staffs_);
+    }
+  else if (text_p_ && dynamic_cast<Bar*> (s))
+    {
+      /*
+       Ugh. Figure out how to do this right at beginning of line, (without
+       creating class Bar_script : public Text_item).
+      */
+      text_p_->set_parent (s, X_AXIS);
+    }
 }
 
+void 
+Mark_engraver::do_pre_move_processing ()
+{
+  if (text_p_)
+    {
+      text_p_->set_elt_property ("side-support" , staffs_);
+      typeset_element (text_p_);
+      text_p_ =0;
+    }
+}
+
+
+void
+Mark_engraver::create_items (Request *rq)
+{
+  if (text_p_)
+    return;
+  
+  text_p_ = new Text_item;
+  text_p_->set_elt_property ("breakable", SCM_BOOL_T); // ugh
+  Side_position_interface staffside(text_p_);
+  staffside.set_axis (Y_AXIS);
+
+  SCM prop = get_property ("markDirection");
+  if (!isdir_b (prop))
+    {
+      prop = gh_int2scm (UP);
+    }
+  text_p_->set_elt_property ("direction", prop);
+
+  SCM padding = get_property ("markScriptPadding");
+  if (gh_number_p(padding))
+    {
+      text_p_->set_elt_property ("padding", padding);
+    }
+  else
+    {
+      text_p_
+       ->set_elt_property ("padding",
+                           gh_double2scm(paper_l ()->get_var ("interline")));
+    }
+
+  if (gh_procedure_p (visibility_lambda_))
+      text_p_->set_elt_property ("visibility-lambda",
+                                visibility_lambda_);
+  
+  announce_element (Score_element_info (text_p_, rq));
+}
+
+
 void
 Mark_engraver::do_post_move_processing ()
 {
@@ -67,6 +170,9 @@ Mark_engraver::do_process_music ()
 
       String t;
 
+      /*
+       automatic marks.
+       */
       SCM m = (mark_req_l_->mark_label_ == SCM_UNDEFINED)
        ? get_property ("rehearsalMark")
        : SCM(mark_req_l_->mark_label_);