]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.0.39
authorfred <fred>
Tue, 4 Mar 1997 22:02:08 +0000 (22:02 +0000)
committerfred <fred>
Tue, 4 Mar 1997 22:02:08 +0000 (22:02 +0000)
lily/text-item.cc [new file with mode: 0644]
lily/text-reg.cc [new file with mode: 0644]

diff --git a/lily/text-item.cc b/lily/text-item.cc
new file mode 100644 (file)
index 0000000..7cdab7c
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+  textitem.cc -- implement Text_item
+
+  source file of the LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+
+  #include "musicalrequest.hh"
+#include "paper-def.hh"
+#include "text-item.hh"
+#include "stem.hh"
+#include "molecule.hh"
+#include "lookup.hh"
+
+
+
+Text_item::Text_item(Text_req* treq_l, int staffsize_i)
+{
+    staffsize_i_ = staffsize_i;
+    dir_i_ = treq_l->dir_i_;
+    if (!dir_i_)
+       dir_i_ = -1;
+    tdef_l_ = treq_l->tdef_p_;
+}
+
+void
+Text_item::set_default_index()
+{
+    pos_i_  = (dir_i_ > 0) ? staffsize_i_ + 2: -4;
+}
+
+void
+Text_item::do_pre_processing()
+{
+    set_default_index();
+}
+
+    
+Molecule*
+Text_item::brew_molecule_p() const
+{
+    Molecule* mol_p = new Molecule(tdef_l_->create_atom(paper()));
+    mol_p->translate(Offset(0, pos_i_ * paper()->internote()));
+
+    if(dir_i_<0)
+       mol_p->translate(Offset(0, -mol_p->extent().y.length() ));
+    
+    return mol_p;
+}
diff --git a/lily/text-reg.cc b/lily/text-reg.cc
new file mode 100644 (file)
index 0000000..5461b83
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+  text-reg.cc -- implement Text_register
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+#include "musicalrequest.hh"
+#include "text-reg.hh"
+#include "text-item.hh"
+
+Text_register::Text_register()
+{
+    text_p_ = 0;
+    set_feature(Features::dir(0));
+    post_move_processing();
+}
+
+bool
+Text_register::try_request(Request*req_l)
+{
+    if (!req_l->text())
+       return false;
+    if (text_req_l_ &&
+       Text_req::compare(*req_l->text(), *text_req_l_))
+
+       return false;
+
+    text_req_l_ = req_l->text();
+    return true;
+}
+
+void
+Text_register::process_requests()
+{
+    
+    if (text_req_l_) {
+       text_p_ = new Text_item(text_req_l_, 10); // UGH
+       announce_element(Staff_elem_info(text_p_, text_req_l_));
+    }
+}
+void
+Text_register::pre_move_processing()
+{
+    if (text_p_) {
+       text_p_->dir_i_ = dir_i_;
+       typeset_element(text_p_);
+       text_p_ = 0;
+    }
+}
+void
+Text_register::set_feature(Features i)
+{
+    dir_i_ = i.direction_i_;
+}
+void
+Text_register::post_move_processing()
+{
+    text_req_l_ = 0;
+}