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

« back to all changes in this revision

Viewing changes to lily/ottava-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:
3
3
 
4
4
  source file of the GNU LilyPond music typesetter
5
5
 
6
 
  (c) 2000--2004 Han-Wen Nienhuys
 
6
  (c) 2000--2006 Han-Wen Nienhuys
7
7
*/
8
8
 
9
9
#include "protected-scm.hh"
10
10
#include "note-column.hh"
11
 
#include "item.hh"
12
11
#include "side-position-interface.hh"
13
12
#include "engraver.hh"
14
13
 
15
14
class Ottava_spanner_engraver : public Engraver
16
15
{
17
16
public:
18
 
  TRANSLATOR_DECLARATIONS (Ottava_spanner_engraver);  
 
17
  TRANSLATOR_DECLARATIONS (Ottava_spanner_engraver);
19
18
protected:
20
19
  virtual void finalize ();
21
 
  virtual void acknowledge_grob (Grob_info);
22
 
  virtual void process_music ();
23
 
  virtual void stop_translation_timestep ();
 
20
 
 
21
  DECLARE_ACKNOWLEDGER (note_column);
 
22
 
 
23
  void process_music ();
 
24
  void stop_translation_timestep ();
 
25
  virtual void derived_mark () const;
24
26
private:
25
27
  Spanner *span_;
26
28
  Spanner *finished_;
27
 
  
28
 
  Protected_scm last_ottavation_;
29
 
  
 
29
 
 
30
  SCM last_ottavation_;
 
31
 
30
32
  void typeset_all ();
31
33
};
32
34
 
 
35
void
 
36
Ottava_spanner_engraver::derived_mark () const
 
37
{
 
38
  scm_gc_mark (last_ottavation_);
 
39
}
33
40
 
34
41
Ottava_spanner_engraver::Ottava_spanner_engraver ()
35
42
{
36
43
  finished_ = 0;
37
 
  span_ =0;
 
44
  span_ = 0;
38
45
  last_ottavation_ = SCM_EOL;
39
46
}
40
47
 
44
51
  SCM ott = get_property ("ottavation");
45
52
  if (ott != last_ottavation_)
46
53
    {
47
 
      finished_= span_;
 
54
      finished_ = span_;
48
55
      span_ = 0;
49
 
      if (gh_string_p (ott))
 
56
      if (scm_is_string (ott))
50
57
        {
51
 
          span_  = make_spanner ("OttavaBracket");
 
58
          span_ = make_spanner ("OttavaBracket", SCM_EOL);
52
59
          span_->set_property ("text", ott);
53
 
          announce_grob (span_, SCM_EOL);
54
60
 
55
61
          SCM c0 (get_property ("middleCPosition"));
56
62
          SCM oc0 (get_property ("originalCentralCPosition"));
57
63
          if (scm_less_p (oc0, c0) == SCM_BOOL_T)
58
 
            span_->set_property ("direction", gh_int2scm (DOWN));
 
64
            span_->set_property ("direction", scm_from_int (DOWN));
59
65
        }
60
66
    }
61
67
  last_ottavation_ = ott;
62
68
}
63
69
 
64
70
void
65
 
Ottava_spanner_engraver::acknowledge_grob (Grob_info info)
 
71
Ottava_spanner_engraver::acknowledge_note_column (Grob_info info)
66
72
{
67
 
  Item *it = dynamic_cast<Item*> (info.grob_);
68
 
  if (span_ && it && Note_column::has_interface (info.grob_))
 
73
  Item *it = info.item ();
 
74
  if (span_ && it)
69
75
    {
70
76
      Side_position_interface::add_support (span_, it);
71
77
 
77
83
 
78
84
void
79
85
Ottava_spanner_engraver::typeset_all ()
80
 
{  
 
86
{
81
87
  if (finished_)
82
88
    {
83
89
      Direction d = LEFT;
85
91
        {
86
92
          if (!finished_->get_bound (RIGHT))
87
93
            {
88
 
              Grob* e = unsmob_grob (get_property ("currentMusicalColumn"));
 
94
              Grob *e = unsmob_grob (get_property ("currentMusicalColumn"));
89
95
              finished_->set_bound (d, e);
90
96
            }
91
97
        }
92
98
      while (flip (&d) != LEFT);
93
 
      
94
 
      typeset_grob (finished_);
 
99
 
95
100
      finished_ = 0;
96
101
    }
97
102
}
101
106
{
102
107
  if (span_ && !span_->get_bound (LEFT))
103
108
    {
104
 
      Grob* e = unsmob_grob (get_property ("currentMusicalColumn"));
 
109
      Grob *e = unsmob_grob (get_property ("currentMusicalColumn"));
105
110
      span_->set_bound (LEFT, e);
106
111
    }
107
112
 
118
123
  last_ottavation_ = SCM_EOL;
119
124
}
120
125
 
121
 
ENTER_DESCRIPTION (Ottava_spanner_engraver,
122
 
/* descr */       "Create a text spanner when the ottavation property changes..",
123
 
/* creats*/       "OttavaBracket",
124
 
/* accepts */     "",
125
 
/* acks  */      "note-column-interface",
126
 
/* reads */       "ottavation",
127
 
/* write */       "");
 
126
#include "translator.icc"
 
127
 
 
128
ADD_ACKNOWLEDGER (Ottava_spanner_engraver, note_column);
 
129
 
 
130
ADD_TRANSLATOR (Ottava_spanner_engraver,
 
131
                /* doc */ "Create a text spanner when the ottavation property changes..",
 
132
                /* create */ "OttavaBracket",
 
133
                /* accept */ "",
 
134
                /* read */ "ottavation",
 
135
                /* write */ "");