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

« back to all changes in this revision

Viewing changes to lily/text-spanner.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 Jan Nieuwenhuizen <janneke@gnu.org>
 
6
  (c) 2000--2006 Jan Nieuwenhuizen <janneke@gnu.org>
7
7
 
8
 
  Revised over good by Han-Wen. 
 
8
  Revised over good by Han-Wen.
9
9
*/
10
10
 
11
 
#include "stencil.hh"
12
 
#include "text-item.hh"
13
11
#include "text-spanner.hh"
 
12
 
 
13
#include "text-interface.hh"
14
14
#include "line-spanner.hh"
15
15
#include "spanner.hh"
16
16
#include "font-interface.hh"
17
17
#include "dimensions.hh"
18
 
#include "paper-def.hh"
 
18
#include "output-def.hh"
19
19
#include "warn.hh"
20
20
#include "paper-column.hh"
21
21
#include "staff-symbol-referencer.hh"
34
34
  TODO: this function is too long
35
35
*/
36
36
SCM
37
 
Text_spanner::print (SCM smob) 
 
37
Text_spanner::print (SCM smob)
38
38
{
39
 
  Grob *me= unsmob_grob (smob);
40
 
  Spanner *spanner = dynamic_cast<Spanner*> (me);
41
 
  
 
39
  Grob *me = unsmob_grob (smob);
 
40
  Spanner *spanner = dynamic_cast<Spanner *> (me);
 
41
 
42
42
  /* Ugh, must be same as Hairpin::print.  */
43
43
 
44
44
  Grob *common = spanner->get_bound (LEFT)->common_refpoint (spanner->get_bound (RIGHT), X_AXIS);
45
 
  Paper_def * paper = me->get_paper ();
 
45
  Output_def *layout = me->layout ();
46
46
 
47
47
  SCM flare = me->get_property ("bracket-flare");
48
48
  SCM shorten = me->get_property ("shorten-pair");
63
63
            span_points[d] = b->relative_coordinate (common, X_AXIS);
64
64
        }
65
65
      else
66
 
          {
67
 
            Real encl = robust_scm2double (me->get_property ("enclose-bounds"), 0.0);
68
 
            span_points[d] = b->extent (common, X_AXIS).linear_combination (d * encl);
69
 
 
70
 
            if (is_number_pair (shorten))
71
 
              span_points -= d * gh_scm2double (index_get_cell (shorten, d));
72
 
          }
73
 
      
 
66
        {
 
67
          Real encl = robust_scm2double (me->get_property ("enclose-bounds"), 0.0);
 
68
          Interval ext = b->extent (common, X_AXIS);
 
69
 
 
70
          span_points[d]
 
71
            = robust_relative_extent (b, common, X_AXIS).linear_combination (d * encl);
 
72
 
 
73
          if (is_number_pair (shorten))
 
74
            span_points -= d * scm_to_double (index_get_cell (shorten, d));
 
75
        }
 
76
 
74
77
      if (is_number_pair (flare))
75
 
        span_points -= d * gh_scm2double (index_get_cell (flare, d));
 
78
        span_points -= d * scm_to_double (index_get_cell (flare, d));
76
79
    }
77
80
  while (flip (&d) != LEFT);
78
81
 
79
 
 
80
82
  SCM properties = Font_interface::text_font_alist_chain (me);
81
83
  SCM edge_text = me->get_property ("edge-text");
82
84
  Drul_array<Stencil> edge;
83
 
  if (gh_pair_p (edge_text))
 
85
  if (scm_is_pair (edge_text))
84
86
    {
85
87
      Direction d = LEFT;
86
88
      do
87
89
        {
88
90
          if (broken[d])
89
91
            continue;
90
 
          
 
92
 
91
93
          SCM text = index_get_cell (edge_text, d);
92
94
 
93
 
          if (Text_item::markup_p (text)) 
94
 
            edge[d] = *unsmob_stencil (Text_item::interpret_markup (paper->self_scm (), properties, text));
95
 
          
 
95
          if (Text_interface::is_markup (text))
 
96
            edge[d] = *unsmob_stencil (Text_interface::interpret_markup (layout->self_scm (), properties, text));
 
97
 
96
98
          if (!edge[d].is_empty ())
97
99
            edge[d].align_to (Y_AXIS, CENTER);
98
100
        }
99
101
      while (flip (&d) != LEFT);
100
102
    }
101
 
  
 
103
 
102
104
  Drul_array<Real> edge_height = robust_scm2interval (me->get_property ("edge-height"),
103
105
                                                      Interval (0.0, 0.0));
104
106
  Drul_array<Stencil> edge_line;
105
 
    {
106
 
      Direction d = LEFT;
107
 
      int dir = to_dir (me->get_property ("direction"));
108
 
      do
109
 
        {
110
 
          if (broken[d])
111
 
            continue;
112
 
          
113
 
          Real dx = 0.0;
114
 
          if (is_number_pair (flare))
115
 
            dx = gh_scm2double (index_get_cell (flare, d)) * d;
116
 
 
117
 
          Real dy = - dir * edge_height[d] ;
118
 
          if (dy)
119
 
            edge_line[d] = Line_spanner::line_stencil (me, Offset (0,0), Offset (dx, dy));
120
 
        }
121
 
      while (flip (&d) != LEFT);
122
 
    }
123
 
  
 
107
  {
 
108
    Direction d = LEFT;
 
109
    int dir = to_dir (me->get_property ("direction"));
 
110
    do
 
111
      {
 
112
        if (broken[d])
 
113
          continue;
 
114
 
 
115
        Real dx = 0.0;
 
116
        if (is_number_pair (flare))
 
117
          dx = scm_to_double (index_get_cell (flare, d)) * d;
 
118
 
 
119
        Real dy = -dir * edge_height[d];
 
120
        if (dy)
 
121
          edge_line[d] = Line_spanner::line_stencil (me, Offset (0, 0), Offset (dx, dy));
 
122
      }
 
123
    while (flip (&d) != LEFT);
 
124
  }
 
125
 
124
126
  Stencil m;
125
127
  do
126
128
    {
127
129
      Interval ext = edge[d].extent (X_AXIS);
128
130
      if (!ext.is_empty ())
129
131
        {
 
132
          Real pad = robust_scm2double (me->get_property ("bound-padding"), 0.0);
130
133
          edge[d].translate_axis (span_points[d], X_AXIS);
131
134
          m.add_stencil (edge[d]);
132
 
          span_points[d] += -d *  ext[-d];
 
135
          span_points[d] += -d * (ext[-d] + pad);
133
136
        }
134
137
    }
135
138
  while (flip (&d) != LEFT);
 
139
 
136
140
  do
137
141
    {
138
 
      if (d* span_points[d] > d * edge[-d].extent (X_AXIS)[d])
 
142
      if (d * span_points[d] > d * edge[-d].extent (X_AXIS)[d])
139
143
        {
140
144
          edge_line[d].translate_axis (span_points[d], X_AXIS);
141
145
          m.add_stencil (edge_line[d]);
143
147
    }
144
148
  while (flip (&d) != LEFT);
145
149
 
146
 
  if (!span_points.is_empty ())
 
150
  
 
151
  if (!span_points.is_empty ()
 
152
      && span_points.length () > robust_scm2double (me->get_property ("dash-period"), 0.0))
147
153
    {
148
 
      Stencil l =Line_spanner::line_stencil (me, Offset (span_points[LEFT], 0),
149
 
                                               Offset (span_points[RIGHT], 0));
 
154
      Stencil l = Line_spanner::line_stencil (me,
 
155
                                              Offset (span_points[LEFT], 0),
 
156
                                              Offset (span_points[RIGHT], 0));
150
157
      m.add_stencil (l);
151
158
    }
152
159
  m.translate_axis (- me->relative_coordinate (common, X_AXIS), X_AXIS);
153
160
  return m.smobbed_copy ();
154
161
}
155
162
 
156
 
ADD_INTERFACE (Text_spanner,"text-spanner-interface",
 
163
ADD_INTERFACE (Text_spanner,
 
164
               "text-spanner-interface",
 
165
 
157
166
               "generic text spanner",
158
 
               "dash-period if-text-padding dash-fraction edge-height bracket-flare edge-text shorten-pair style thickness enclose-bounds");
 
167
 
 
168
               "bound-padding "
 
169
               "bracket-flare "
 
170
               "dash-fraction "
 
171
               "dash-period "
 
172
               "edge-height "
 
173
               "edge-text "
 
174
               "enclose-bounds "
 
175
               "shorten-pair "
 
176
               "style "
 
177
               "thickness "
 
178
               );
159
179