]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.1.11
authorfred <fred>
Sun, 24 Mar 2002 19:55:50 +0000 (19:55 +0000)
committerfred <fred>
Sun, 24 Mar 2002 19:55:50 +0000 (19:55 +0000)
lily/beam-grav.cc [new file with mode: 0644]
lily/clef-item.cc
lily/include/bar.hh
lily/include/beam.hh

diff --git a/lily/beam-grav.cc b/lily/beam-grav.cc
new file mode 100644 (file)
index 0000000..dcdce82
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+  beam-grav.cc -- implement Beam_engraver
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+#include "duration-convert.hh"
+#include "time-description.hh"
+#include "beam-grav.hh"
+#include "stem.hh"
+#include "beam.hh"
+#include "musical-request.hh"
+#include "grouping.hh"
+#include "text-spanner.hh"
+#include "text-def.hh"
+
+Beam_engraver::Beam_engraver()
+{
+  span_reqs_drul_[LEFT] = span_reqs_drul_[RIGHT] =0;
+  beam_p_ =0;
+  current_grouping_p_ =0;
+}
+
+bool
+Beam_engraver::do_try_request(Request*r)
+{
+  Musical_req* mus_l = r->musical();
+  if (!mus_l)
+    return false;
+  
+  Beam_req * b = mus_l->beam();
+
+  if (!b)
+    return false;
+    
+  if (bool (beam_p_) == bool (b->spantype == Span_req::START))
+    return false;
+  
+  Direction d = (!beam_p_) ? LEFT : RIGHT;
+  if (span_reqs_drul_[d] && !span_reqs_drul_[d]->equal_b (mus_l))
+    return false;
+  
+  span_reqs_drul_[d] = b;
+  return true;
+}
+
+void
+Beam_engraver::do_process_requests()
+{
+  if ( !beam_p_ && span_reqs_drul_[LEFT]) {
+    current_grouping_p_ = new Rhythmic_grouping;
+    beam_p_ = new Beam;
+    if (span_reqs_drul_[LEFT]->nplet) 
+      {
+       Text_spanner* t = new Text_spanner();
+       Text_def *defp = new Text_def;
+       t->set_support (beam_p_);
+       defp->align_i_ = 0;
+       defp->text_str_ = span_reqs_drul_[LEFT]->nplet;
+       defp->style_str_="italic";
+       t->spec_p_  = defp;
+       announce_element (Score_elem_info (t,0));
+       typeset_element (t);
+      }
+    announce_element (Score_elem_info (beam_p_, span_reqs_drul_[LEFT]));
+  }
+}
+
+void
+Beam_engraver::do_pre_move_processing()
+{
+  if (beam_p_ && span_reqs_drul_[RIGHT]) {
+    Rhythmic_grouping const * rg_C = get_staff_info().rhythmic_C_;
+    rg_C->extend (current_grouping_p_->interval());
+    beam_p_->set_grouping (*rg_C, *current_grouping_p_);
+    typeset_element (beam_p_);
+    beam_p_ = 0;
+
+    delete current_grouping_p_;
+    current_grouping_p_ = 0;
+
+    span_reqs_drul_[RIGHT] =
+      span_reqs_drul_[LEFT] = 0;
+  }
+}
+
+void
+Beam_engraver::do_removal_processing()
+{
+  if (beam_p_) 
+    {
+      span_reqs_drul_[LEFT]->warning ("unterminated beam");
+      typeset_element (beam_p_);
+      beam_p_ =0;
+    }
+}
+
+
+void
+Beam_engraver::acknowledge_element (Score_elem_info i)
+{
+  if (beam_p_ && i.elem_l_->is_type_b (Stem::static_name()))
+    {
+      Stem * s = (Stem*)i.elem_l_->item();
+      Rhythmic_req *rhythmic_req = i.req_l_->musical ()->rhythmic ();
+      if (rhythmic_req->duration_.durlog_i_<= 2) 
+       {
+         rhythmic_req->warning ("Stem doesn't fit in Beam");
+         return ;
+       }
+       
+      /*
+       TODO: do something sensible if it doesn't fit in the beam.
+       */
+      current_grouping_p_->add_child (get_staff_info().time_C_->whole_in_measure_,
+                                     rhythmic_req->duration());
+      /* 
+        TODO
+        should change rep. of flags too.k
+       */
+      s->flag_i_ = Duration_convert::type2_i
+       (rhythmic_req->duration_.durlog_i_);    
+      s->print_flag_b_ = false;
+      beam_p_->add (s);
+    }
+} 
+       
+IMPLEMENT_IS_TYPE_B1(Beam_engraver, Engraver);
+ADD_THIS_ENGRAVER(Beam_engraver);
index 8a2534b111782dab90037a25b793821db102c259..fc579ec3475298fb3b631e87e482ba53a342ec5d 100644 (file)
@@ -21,8 +21,8 @@ Clef_item::do_pre_processing()
 
   if (default_b_)
     {
-       empty_b_ = (break_status_i() != 1);
-       transparent_b_ = (break_status_i() != 1);
+      empty_b_ = (break_status_i() != 1);
+      transparent_b_ = (break_status_i() != 1);
     }
 }
 
@@ -39,13 +39,13 @@ Clef_item::read (String t)
 {
   type_= t;
   if (type_ == "violin")
-       y_off = 2;
+    y_off = 2;
   if (type_ == "alto")
-       y_off = 4;
+    y_off = 4;
   if (type_ == "tenor")
-       y_off = 6;
+    y_off = 6;
   if (type_ == "bass")
-       y_off = 6;
+    y_off = 6;
 }
 void
 Clef_item::read (Clef_engraver const &k)
@@ -54,11 +54,11 @@ Clef_item::read (Clef_engraver const &k)
 }
 
 Molecule*
-Clef_item::brew_molecule_p()const
+Clef_item::brew_molecule_p() const
 {
   String t = type_;
   if  (change_b_)
-       t += "_change";
+    t += "_change";
   Symbol s = paper()->lookup_l ()->clef (t);
   Molecule*output = new Molecule (Atom (s));
   output->translate (paper()->internote_f () * y_off, Y_AXIS);
index c03527e6ccdc78ad91bcaa8b5dbecc94a810c458..ce886830b0e69e08aacd8b449e0ce5b0563b1878 100644 (file)
  */
 class Bar:public Item {
 public:
-    String type_str_;
-    int spanned_i_;
+  String type_str_;
+  int spanned_i_;
     
-    DECLARE_MY_RUNTIME_TYPEINFO;
-    SCORE_ELEM_CLONE(Bar);
-    Bar();
+  DECLARE_MY_RUNTIME_TYPEINFO;
+  SCORE_ELEM_CLONE(Bar);
+  Bar();
 private:
-    void do_print() const;
+  void do_print() const;
 protected:
-    virtual void do_pre_processing();
-    Molecule*brew_molecule_p()const;
+  virtual void do_pre_processing();
+  Molecule*brew_molecule_p() const;
 };
 #endif // BAR_HH
 
index 48b4f9bb4cbfa62e33897064e7d1c03d64730383..ad775b7a3c8e60db44ab0967c36a14fbd66d8005 100644 (file)
   direction */
 class Beam:  public Directional_spanner {
 public:
-    Link_array<Stem> stems;
-    /// the slope of the beam in posns / point (dimension)   
-    Real slope;
+  Link_array<Stem> stems;
+  /// the slope of the beam in posns / point (dimension)   
+  Real slope;
 
-    /// position of leftmost end of beam  
-    Real left_pos;
+  /// position of leftmost end of beam  
+  Real left_pos;
    
 
-    /* *************** */
-    DECLARE_MY_RUNTIME_TYPEINFO;
-    Beam();
-    void add (Stem*);
+  /* *************** */
+  DECLARE_MY_RUNTIME_TYPEINFO;
+  Beam();
+  void add (Stem*);
 
-    void set_grouping (Rhythmic_grouping def, Rhythmic_grouping current);
-    void set_stemlens();
-    SCORE_ELEM_CLONE(Beam);
+  void set_grouping (Rhythmic_grouping def, Rhythmic_grouping current);
+  void set_stemlens();
+  SCORE_ELEM_CLONE(Beam);
 protected:
-    virtual Interval do_width()const;    
-    virtual Offset center() const;
-    virtual void set_default_dir();
-    virtual void do_pre_processing();
-    virtual void do_post_processing();
-    virtual void do_substitute_dependent (Score_elem*, Score_elem*);
+  virtual Interval do_width() const;    
+  virtual Offset center() const;
+  virtual void set_default_dir();
+  virtual void do_pre_processing();
+  virtual void do_post_processing();
+  virtual void do_substitute_dependent (Score_elem*, Score_elem*);
 
-    virtual void do_print() const;
+  virtual void do_print() const;
 
 private:
-    Molecule stem_beams (Stem *here, Stem *next, Stem *prev)const;
-    void solve_slope();
-    Molecule*brew_molecule_p()const;
+  Molecule stem_beams (Stem *here, Stem *next, Stem *prev) const;
+  void solve_slope();
+  Molecule*brew_molecule_p() const;
 };
 
 #endif // BEAM_HH