]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/lookup.cc (triangle): rewrite, obviating symmetric_x_triangle().
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 14 Nov 2004 02:06:30 +0000 (02:06 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 14 Nov 2004 02:06:30 +0000 (02:06 +0000)
* lily/context.cc (Context): take key argument in ctor.
(create_context): new function

* lily/include/object-key.hh (class Object_key): new file.

ChangeLog
lily/context.cc
lily/include/context.hh
lily/include/object-key.hh
lily/lookup.cc
ps/music-drawing-routines.ps
scm/lily.scm
scm/output-ps.scm
scm/output-tex.scm

index 14afb90984c00d52524cbdfb7124d3641213d509..023d20da131920d546babeb225027415429ef4d3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,9 @@
 2004-11-14  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
+       * lily/lookup.cc (triangle): rewrite, obviating symmetric_x_triangle().
+
        * lily/context.cc (Context): take key argument in ctor.
+       (create_context): new function
 
        * lily/grob.cc (Grob): take key argument in ctor.  
 
index cf678b4e215d4643891afc07784f722ff6dd5cf1..b57a98459e72c6660502aaa5d2bd8c4a24eeca2c 100644 (file)
@@ -148,18 +148,11 @@ Context::find_create_context (SCM n, String id, SCM operations)
            {
              this_id = id;
            }
-         
-         Object_key const *key = get_context_key (ly_symbol2string (path[i]->get_context_name()), this_id);
-                                                       
-         Context * new_group
-           = path[i]->instantiate (ops, key);
-         scm_gc_unprotect_object (key->self_scm ());
-         
-         new_group->id_string_ = this_id;
-         current->add_context (new_group);
-         apply_property_operations (new_group, ops);
-         
-         current = new_group;
+
+
+         current = create_context (path[i],
+                                   this_id,
+                                   ops); 
        }
 
       return current;
@@ -181,6 +174,25 @@ Context::find_create_context (SCM n, String id, SCM operations)
   return ret;
 }
 
+
+Context*
+Context::create_context (Context_def * cdef,
+                        String id,
+                        SCM ops)
+{
+  String type = ly_symbol2string (cdef->get_context_name());
+  Object_key const *key = get_context_key (type, id);
+  Context * new_group
+    = cdef->instantiate (ops, key);
+  scm_gc_unprotect_object (key->self_scm ());
+         
+  new_group->id_string_ = this_id;
+  add_context (new_group);
+  apply_property_operations (new_group, ops);
+
+  return new_group;
+}
+
 Object_key const*
 Context::get_context_key (String type, String id)
 {
@@ -256,10 +268,7 @@ Context::get_default_interpreter ()
          t = unsmob_context_def (this->definition_);
        }
 
-      Object_key const *key = get_context_key (name, "");
-      
-      Context *tg = t->instantiate (SCM_EOL, key);
-      add_context (tg);
+      Context *tg = create_context (t, "", SCM_EOL)
       if (!tg->is_bottom_context ())
        return tg->get_default_interpreter ();
       else
index bb45f7254bdece9cd43ee3ab3bb4ae45818a7144..8c2901e3726a210dc5bef3a3386c39ac23c4bd2e 100644 (file)
@@ -51,6 +51,7 @@ public:
   Object_key const *get_grob_key (String);
   Object_key const *get_context_key (String, String);
 
+  Context *create_context (Context_def*, String, SCM); 
   String id_string () const { return id_string_; } 
   SCM children_contexts () const { return context_list_; }
   SCM default_child_context_name () const;
index c64fcc9deb488a6fabd64486387eb29c267f3799..400ee4c12ade9301fca1ab867c445797a5737742 100644 (file)
@@ -28,6 +28,7 @@ protected:
   virtual void derived_mark () const;
   virtual int get_type () const;
   virtual int do_compare (Object_key const * other) const;
+
 public:
   int compare (Object_key const *other) const;
 };
@@ -45,10 +46,12 @@ class Copied_key : public Object_key
 private:
   Object_key const * original_;
   int copy_count_;
+
 protected:
   virtual void derived_mark () const;
   virtual int get_type () const;
   virtual int do_compare (Object_key const * other) const;
+
 public:
   Copied_key (Object_key const*, int); 
 };
index 69db6c10868843f9577d138053f901363f579df8..42fbb1cf29ea54956231f1910e0bc36105d202a9 100644 (file)
@@ -690,14 +690,16 @@ Lookup::triangle (Interval iv, Real thick, Real protude)
   b[X_AXIS] = Interval (0, iv.length());
   b[Y_AXIS] = Interval (0 <? protude , 0 >? protude);
 
-  SCM s = scm_list_n (ly_symbol2scm ("symmetric-x-triangle"),
-                     scm_make_real (thick),
-                     scm_make_real (iv.length ()), 
-                     scm_make_real (protude), SCM_UNDEFINED);
-
-  Stencil stc (b, s);
-  stc.translate_axis (iv[LEFT], X_AXIS);
-  return stc;  
+
+  Offset z1(iv[LEFT], 0);
+  Offset z2(iv[RIGHT], 0);
+  Offset z3(z2[X_AXIS]/2, protude);
+   
+  Stencil tri = make_line (z1, z2);
+  tri.add_stencil (make_line (z2, z3));
+  tri.add_stencil (make_line (z3, z1));
+
+  return tri;
 }
 
 
index 7ee1498305514a3c91fb72cc3fe783d1eac16a97..ed6b76bb09be3e7f35ed022e522f5c90ded3d173 100644 (file)
 } bind def
 
 
-/draw_symmetric_x_triangle % h w th
-{
-    setlinewidth
-    0 0 moveto
-    dup 0 lineto
-    2 div 
-    exch lineto
-    0 0 lineto
-    stroke
-} bind def
-
 /draw_round_box % breapth width depth height blot
 {
        /blot exch def
index 0b69cc7ebe2cc5f0539e08dffc5ef3fa3eb6b8a2..d9c9a01492971b0e787e82065354de980c4579e4 100644 (file)
@@ -134,7 +134,6 @@ predicates. Print a message at LOCATION if any predicate failed."
     polygon
     repeat-slash
     round-filled-box
-    symmetric-x-triangle
     text
     tuplet
     white-dot
index 5db157f282e82603b90fa11e4604bd80bcb63cab..e150896a66f760203ae974a6186a68c4c880e64e 100644 (file)
@@ -29,7 +29,6 @@
             char
             dashed-line
             zigzag-line
-            symmetric-x-triangle
             ez-ball
             comment
             repeat-slash
    (ly:numbers->string (list breapth width depth height))
    " draw_box" ))
 
-(define (symmetric-x-triangle thick w h)
-  (string-append
-   (ly:numbers->string (list h w thick))
-   " draw_symmetric_x_triangle"))
 
 (define (text font s)
   (let*
index 4ea8fbe77d2419d82e7e156251f7bf411cc99cd8..70da599df2445f1213d38e16dc38db4013f7bec2 100644 (file)
@@ -32,7 +32,6 @@
             char
             dashed-line
             zigzag-line
-            symmetric-x-triangle
             ez-ball
             comment
             repeat-slash
 (define (zigzag-line centre? zzw zzh thick dx dy)
   (embedded-ps (list 'zigzag-line centre? zzw zzh thick dx dy)))
 
-(define (symmetric-x-triangle t w h)
-  (embedded-ps (list 'symmetric-x-triangle t w h)))
-
-
 (define (ez-ball c l b)
   (embedded-ps (list 'ez-ball  c  l b)))