]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.0.21
authorfred <fred>
Fri, 3 Jan 1997 13:40:14 +0000 (13:40 +0000)
committerfred <fred>
Fri, 3 Jan 1997 13:40:14 +0000 (13:40 +0000)
hdr/textdef.hh [new file with mode: 0644]
src/script.cc [new file with mode: 0644]
src/textdef.cc [new file with mode: 0644]

diff --git a/hdr/textdef.hh b/hdr/textdef.hh
new file mode 100644 (file)
index 0000000..784420c
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+  textdef.hh -- part of LilyPond
+
+  (c) 1996 Han-Wen Nienhuys
+*/
+
+#ifndef TEXTDEF_HH
+#define TEXTDEF_HH
+
+#include "string.hh"
+
+struct Text_def {
+    int align;
+    String text;
+    String style;
+
+    /*****************/
+    
+    Text_def();
+    void print()const;
+    Atom create(Paperdef*)const;
+};
+#endif // TEXTDEF_HH
+
diff --git a/src/script.cc b/src/script.cc
new file mode 100644 (file)
index 0000000..493c682
--- /dev/null
@@ -0,0 +1,95 @@
+#include "request.hh"
+#include "paper.hh"
+#include "script.hh"
+#include "stem.hh"
+#include "molecule.hh"
+#include "lookup.hh"
+
+Script::Script(Script_req* rq, Item*i , int staflen, Stem*st_p)
+{
+    dependencies.add(st_p);
+    dependencies.add(i);
+    
+    staffsize =staflen;
+    specs = rq->scriptdef;
+    support= i;
+    stem_ = st_p;
+    pos = 0;
+    symdir=1;
+    dir =rq->dir;
+}
+
+void
+Script::set_symdir()
+{
+    if (specs->invertsym)
+       symdir = (dir < 0) ? -1:1;
+}
+
+void
+Script::set_default_dir()
+{
+    if (specs->stemdir) {
+       if (!stem_)
+           dir = 1;
+       else
+           dir = stem_->dir * specs->stemdir;
+    }
+}
+
+void
+Script::set_default_pos()
+{
+    assert(dir);
+    Real y;
+    Real inter= paper()->internote();
+
+    int d = specs->staffdir;
+    if (!d) {
+       Interval v= support->height();
+       pos = rint(v[dir]/inter) + dir* 2;
+    } else {
+       y  = (d > 0) ? staffsize + 2: -2; // ug
+       y *=inter;
+       Interval v= support->height();
+
+       if (dir > 0) {
+           y = y >? v.max();
+       }else if (dir < 0) {
+           y = y <? v.min();
+       }
+       pos = int(rint(Real(y)/inter));
+    }
+}
+
+Interval
+Script::width() const
+{
+    return paper()->lookup_->script(specs->symidx).dim.x;
+}
+
+void
+Script::do_pre_processing()
+{
+    set_default_dir();
+    set_symdir();
+}
+
+void
+Script::do_post_processing()
+{
+    set_default_pos();
+}
+Molecule*
+Script::brew_molecule() const
+{
+    Paperdef *p =paper();
+
+    Real dy = p->internote();
+    String preidx = (symdir < 0) ?"-" :"";
+    Symbol ss =p->lookup_->script(preidx+specs->symidx);
+    Molecule*out = new Molecule(Atom(ss));
+    out->translate(Offset(0,dy * pos));
+    return
+       out;
+}
diff --git a/src/textdef.cc b/src/textdef.cc
new file mode 100644 (file)
index 0000000..58c6661
--- /dev/null
@@ -0,0 +1,24 @@
+#include "debug.hh"
+#include "lookup.hh"
+#include "paper.hh"
+#include "molecule.hh"
+#include "textdef.hh"
+
+Text_def::Text_def()
+{   
+    align = 1;                 // right
+    style = "roman";
+}
+
+Atom
+Text_def::create(Paperdef*p) const
+{
+    return p->lookup_->text(style, text, -align);
+}
+
+void
+Text_def::print() const
+{
+    mtor << "Text `" << text << "\', style " <<
+       style << "align " <<align<<'\n';
+}