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

« back to all changes in this revision

Viewing changes to lily/staff-symbol-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) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 
6
  (c) 1997--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
7
7
*/
8
8
 
9
 
 
10
 
#include "score.hh"
11
 
#include "paper-column.hh"
12
 
#include "paper-def.hh"
13
 
#include "side-position-interface.hh"
14
 
#include "engraver.hh"
15
 
#include "moment.hh"
16
 
 
17
 
/**
18
 
  Manage the staff symbol.
19
 
 */
20
 
class Staff_symbol_engraver : public Engraver { 
21
 
public:
22
 
  TRANSLATOR_DECLARATIONS (Staff_symbol_engraver);
23
 
  
24
 
protected:
25
 
  Spanner *span_;
26
 
  
27
 
  virtual ~Staff_symbol_engraver ();
28
 
  virtual void acknowledge_grob (Grob_info);
29
 
  virtual void finalize ();
30
 
  virtual void process_music ();
31
 
};
32
 
 
 
9
#include "staff-symbol-engraver.hh"
 
10
#include "spanner.hh"
33
11
 
34
12
Staff_symbol_engraver::~Staff_symbol_engraver ()
35
13
{
38
16
 
39
17
Staff_symbol_engraver::Staff_symbol_engraver ()
40
18
{
 
19
  finished_span_ = 0;
 
20
  first_start_ = true;
41
21
  span_ = 0;
 
22
  span_events_[LEFT] = 0;
 
23
  span_events_[RIGHT] = 0;
 
24
}
 
25
 
 
26
bool
 
27
Staff_symbol_engraver::try_music (Music *music)
 
28
{
 
29
  Direction d = to_dir (music->get_property ("span-direction"));
 
30
  if (d)
 
31
    {
 
32
      span_events_[d] = music;
 
33
      return true;
 
34
    }
 
35
 
 
36
  return false;
42
37
}
43
38
 
44
39
void
45
40
Staff_symbol_engraver::process_music ()
46
41
{
 
42
  if (span_events_[STOP])
 
43
    {
 
44
      finished_span_ = span_;
 
45
      span_ = 0;
 
46
      if (first_start_)
 
47
        first_start_ = false;
 
48
    }
 
49
 
 
50
  if (span_events_[START]
 
51
      || (first_start_ && !span_events_[STOP]))
 
52
    start_spanner ();
 
53
}
 
54
 
 
55
void
 
56
Staff_symbol_engraver::start_spanner ()
 
57
{
47
58
  if (!span_)
 
59
    span_ = make_spanner ("StaffSymbol", SCM_EOL);
 
60
}
 
61
 
 
62
void
 
63
Staff_symbol_engraver::stop_spanner ()
 
64
{
 
65
  if (finished_span_ && !finished_span_->get_bound (RIGHT))
 
66
    finished_span_->set_bound (RIGHT, unsmob_grob (get_property ("currentCommandColumn")));
 
67
  finished_span_ = 0;
 
68
}
 
69
 
 
70
void
 
71
Staff_symbol_engraver::stop_translation_timestep ()
 
72
{
 
73
  if ((span_events_[START] || first_start_)
 
74
      && span_
 
75
      && !span_->get_bound (LEFT))
48
76
    {
49
 
      span_ = make_spanner ("StaffSymbol");
50
 
  
51
77
      span_->set_bound (LEFT, unsmob_grob (get_property ("currentCommandColumn")));
52
 
 
53
 
      announce_grob (span_, SCM_EOL);
 
78
      first_start_ = false;
54
79
    }
 
80
 
 
81
  span_events_[START] = 0;
 
82
  span_events_[STOP] = 0;
 
83
  stop_spanner ();
55
84
}
56
85
 
57
86
void
58
87
Staff_symbol_engraver::finalize ()
59
88
{
60
 
  if (span_)
61
 
    {
62
 
      span_->set_bound (RIGHT,unsmob_grob (get_property ("currentCommandColumn")));
63
 
      typeset_grob (span_);
64
 
    }
65
 
  span_ =0;
 
89
  finished_span_ = span_;
 
90
  span_ = 0;
 
91
  stop_spanner ();
66
92
}
67
93
 
 
94
/*
 
95
  Todo: staff-symbol-referencer iface.
 
96
*/
68
97
void
69
98
Staff_symbol_engraver::acknowledge_grob (Grob_info s)
70
99
{
71
 
  s.grob_->set_property ("staff-symbol", span_->self_scm ());
72
 
 
73
 
  // remove this. probly not necessary?
74
 
  s.grob_->add_dependency (span_); // UGH. UGH. UGH
75
 
}
76
 
 
77
 
 
78
 
 
79
 
 
80
 
ENTER_DESCRIPTION (Staff_symbol_engraver,
81
 
/* descr */       "Create the constellation of five (default) "
82
 
"staff lines.",
83
 
/* creats*/       "StaffSymbol",
84
 
/* accepts */     "",
85
 
/* acks  */      "grob-interface",
86
 
/* reads */       "",
87
 
/* write */       "");
88
 
 
89
 
/****************************************************************/
90
 
 
91
 
 
92
 
class Tab_staff_symbol_engraver : public Staff_symbol_engraver
93
 
{
94
 
public:
95
 
  TRANSLATOR_DECLARATIONS (Tab_staff_symbol_engraver);
96
 
protected:
97
 
  virtual void process_music ();
98
 
};
99
 
 
100
 
void
101
 
Tab_staff_symbol_engraver::process_music ()
102
 
{
103
 
  bool init = !span_;
104
 
  Staff_symbol_engraver::process_music ();
105
 
  if (init)
 
100
  /*
 
101
    Perhaps should try to take SeparationItem as bound of the staff
 
102
    symbol?
 
103
  */
 
104
  if (span_ || finished_span_)
106
105
    {
107
 
      int k = scm_ilength (get_property ("stringTunings"));
108
 
      if (k>=0)
109
 
        span_->set_property ("line-count", gh_int2scm (k));
 
106
      Spanner *my = span_ ? span_ : finished_span_;
 
107
      s.grob ()->set_object ("staff-symbol", my->self_scm ());
110
108
    }
111
109
}
112
110
 
113
 
Tab_staff_symbol_engraver::Tab_staff_symbol_engraver ()
114
 
{
115
 
}
116
 
 
117
 
ENTER_DESCRIPTION (Tab_staff_symbol_engraver,
118
 
/* descr */       "Create a staff-symbol, but look at stringTunings for the number of lines."
119
 
"staff lines.",
120
 
/* creats*/       "StaffSymbol",
121
 
/* accepts */     "",
122
 
/* acks  */      "grob-interface",
123
 
/* reads */       "stringTunings",
124
 
/* write */       "");
 
111
#include "translator.icc"
 
112
ADD_ACKNOWLEDGER (Staff_symbol_engraver, grob);
 
113
ADD_TRANSLATOR (Staff_symbol_engraver,
 
114
                /* doc */ "Create the constellation of five (default) "
 
115
                "staff lines.",
 
116
                /* create */ "StaffSymbol",
 
117
                /* accept */ "staff-span-event",
 
118
                /* read */ "",
 
119
                /* write */ "");