~ubuntu-branches/ubuntu/precise/lilypond/precise

« back to all changes in this revision

Viewing changes to lily/rest-engraver.cc

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Bushnell, BSG
  • Date: 2006-12-19 10:18:12 UTC
  • mfrom: (3.1.4 feisty)
  • Revision ID: james.westby@ubuntu.com-20061219101812-7awtjkp0i393wxty
Tags: 2.8.7-3
scripts/midi2ly.py: When setting DATADIR, find Lilypond python files
in the @TOPLEVEL_VERSION@ directory, not 'current'.  Patch thanks to
Chris Lamb (chris@chris-lamb.co.uk).  (Closes: #400550)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
  rest-grav.cc -- implement Rest_engraver
 
2
  rest-engraver.cc -- implement Rest_engraver
3
3
 
4
4
  source file of the GNU LilyPond music typesetter
5
5
 
6
 
  (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 
6
  (c) 1997--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
7
7
*/
 
8
 
 
9
#include "engraver.hh"
 
10
 
 
11
#include "duration.hh"
8
12
#include "item.hh"
9
13
#include "staff-symbol-referencer.hh"
10
 
#include "event.hh"
11
14
#include "dots.hh"
12
15
#include "rhythmic-head.hh"
13
 
#include "engraver.hh"
14
 
 
 
16
#include "music.hh"
15
17
 
16
18
class Rest_engraver : public Engraver
17
19
{
18
 
  Music *rest_req_;
19
 
  Item * dot_;
20
 
  Grob* rest_;
 
20
  Music *rest_event_;
 
21
  Item *dot_;
 
22
  Grob *rest_;
21
23
protected:
22
24
  virtual bool try_music (Music *);
23
 
  virtual void stop_translation_timestep ();
24
 
  virtual void start_translation_timestep ();
25
 
  virtual void process_music ();
 
25
  void start_translation_timestep ();
 
26
  void process_music ();
26
27
 
27
28
public:
28
29
  TRANSLATOR_DECLARATIONS (Rest_engraver);
29
30
};
30
31
 
31
 
 
32
32
/*
33
33
  Should merge with Note_head_engraver
34
 
 */
 
34
*/
35
35
Rest_engraver::Rest_engraver ()
36
36
{
37
 
  rest_req_ =0;
38
 
  rest_ =0;
39
 
  dot_ =0;
 
37
  rest_event_ = 0;
 
38
  rest_ = 0;
 
39
  dot_ = 0;
40
40
}
41
41
 
42
42
void
43
43
Rest_engraver::start_translation_timestep ()
44
44
{
45
 
  rest_req_ =0;
46
 
}
47
 
 
48
 
void
49
 
Rest_engraver::stop_translation_timestep ()
50
 
{
51
 
  if (rest_)
52
 
    {
53
 
      typeset_grob (rest_);
54
 
      rest_ =0;
55
 
    }
56
 
  if (dot_)
57
 
    {
58
 
      typeset_grob (dot_);
59
 
      dot_ =0;
60
 
    }    
 
45
  rest_event_ = 0;
 
46
  rest_ = 0;
 
47
  dot_ = 0;
61
48
}
62
49
 
63
50
void
64
51
Rest_engraver::process_music ()
65
52
{
66
 
  if (rest_req_ && !rest_) 
 
53
  if (rest_event_ && !rest_)
67
54
    {
68
 
      rest_ = make_item ("Rest");
69
 
 
70
 
      int durlog  = unsmob_duration (rest_req_->get_property ("duration"))-> duration_log ();
71
 
      
 
55
      rest_ = make_item ("Rest", rest_event_->self_scm ());
 
56
 
 
57
      int durlog = unsmob_duration (rest_event_->get_property ("duration"))->duration_log ();
 
58
 
72
59
      rest_->set_property ("duration-log",
73
 
                                  gh_int2scm (durlog));
74
 
 
75
 
      int dots =unsmob_duration (rest_req_->get_property ("duration"))->dot_count ();
76
 
      
 
60
                           scm_from_int (durlog));
 
61
 
 
62
      int dots = unsmob_duration (rest_event_->get_property ("duration"))->dot_count ();
 
63
 
77
64
      if (dots)
78
65
        {
79
 
          dot_ = make_item ("Dots");
 
66
          dot_ = make_item ("Dots", SCM_EOL);
80
67
 
81
68
          Rhythmic_head::set_dots (rest_, dot_);
82
69
          dot_->set_parent (rest_, Y_AXIS);
83
 
          dot_->set_property ("dot-count", gh_int2scm (dots));
84
 
          announce_grob (dot_, SCM_EOL);
 
70
          dot_->set_property ("dot-count", scm_from_int (dots));
85
71
        }
86
72
 
87
 
      Pitch *p = unsmob_pitch (rest_req_->get_property ("pitch"));
 
73
      Pitch *p = unsmob_pitch (rest_event_->get_property ("pitch"));
88
74
 
89
75
      /*
90
76
        This is ridiculous -- rests don't have pitch, but we act as if
91
77
        our nose is bleeding.
92
 
       */
 
78
      */
93
79
      if (p)
94
80
        {
95
 
          int pos= p->steps ();
 
81
          int pos = p->steps ();
96
82
          SCM c0 = get_property ("middleCPosition");
97
 
          if (gh_number_p (c0))
98
 
            pos += gh_scm2int (c0);
99
 
          
100
 
          rest_->set_property ("staff-position", gh_int2scm (pos));
 
83
          if (scm_is_number (c0))
 
84
            pos += scm_to_int (c0);
 
85
 
 
86
          rest_->set_property ("staff-position", scm_from_int (pos));
101
87
        }
102
 
      
103
 
      announce_grob (rest_, rest_req_->self_scm ());
104
88
    }
105
89
}
106
90
 
109
93
{
110
94
  if (m->is_mus_type ("rest-event"))
111
95
    {
112
 
      rest_req_ = m;
 
96
      rest_event_ = m;
113
97
      return true;
114
98
    }
115
99
  return false;
116
100
}
117
101
 
118
 
ENTER_DESCRIPTION (Rest_engraver,
119
 
/* descr */       "",
120
 
/* creats*/       "Rest Dots",
121
 
/* accepts */     "rest-event",
122
 
/* acks  */      "",
123
 
/* reads */       "middleCPosition",
124
 
/* write */       "");
 
102
#include "translator.icc"
 
103
 
 
104
ADD_TRANSLATOR (Rest_engraver,
 
105
                /* doc */ "",
 
106
                /* create */ "Rest Dots",
 
107
                /* accept */ "rest-event",
 
108
                /* read */ "middleCPosition",
 
109
                /* write */ "");