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

« back to all changes in this revision

Viewing changes to lily/horizontal-bracket.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
 
/*   
2
 
  horizontal-bracket.cc --  implement  Horizontal_bracket
 
1
/*
 
2
  horizontal-bracket.cc -- implement Horizontal_bracket
3
3
 
4
4
  source file of the GNU LilyPond music typesetter
5
5
 
6
 
(c) 2002--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7
 
 
8
 
 */
9
 
 
 
6
  (c) 2002--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
7
*/
 
8
 
 
9
#include "horizontal-bracket.hh"        
 
10
 
 
11
#include "lookup.hh"
10
12
#include "side-position-interface.hh"
11
 
#include "lookup.hh"
12
 
#include "group-interface.hh"
 
13
#include "pointer-group-interface.hh"
13
14
#include "directional-element-interface.hh"
14
 
#include "paper-def.hh"
 
15
#include "output-def.hh"
15
16
#include "staff-symbol-referencer.hh"
16
 
 
17
 
struct Horizontal_bracket
18
 
{
19
 
  DECLARE_SCHEME_CALLBACK (print, (SCM));
20
 
  static bool has_interface (Grob*);
21
 
};
 
17
#include "tuplet-bracket.hh"
 
18
#include "axis-group-interface.hh"
 
19
 
 
20
 
 
21
Stencil
 
22
Horizontal_bracket::make_bracket (Grob *me,
 
23
                                  Real length,
 
24
                                  Axis a, Direction dir)                                 
 
25
{
 
26
  Drul_array<Real> edge_height = robust_scm2interval (me->get_property ("edge-height"),
 
27
                                                      Interval (1.0, 1.0));
 
28
  Drul_array<Real> flare = robust_scm2interval (me->get_property ("bracket-flare"),
 
29
                                                Interval (0, 0));
 
30
  Drul_array<Real> shorten = robust_scm2interval (me->get_property ("shorten-pair"),
 
31
                                                  Interval (0, 0));
 
32
 
 
33
  // Make sure that it points in the correct direction:
 
34
  scale_drul (&edge_height, Real (-dir));
 
35
 
 
36
  Interval empty;
 
37
  Offset start;
 
38
  start[a] = length;
 
39
 
 
40
  /*
 
41
    ugh, Tuplet_bracket should use Horizontal_bracket, not the other way around. 
 
42
  */
 
43
  return Tuplet_bracket::make_bracket (me, other_axis (a), start, 
 
44
                                       edge_height, empty, flare, shorten);
 
45
}
 
46
 
 
47
 
 
48
Stencil
 
49
Horizontal_bracket::make_enclosing_bracket (Grob *me, Grob *refpoint,
 
50
                                            vector<Grob*> grobs,
 
51
                                            Axis a, Direction dir)
 
52
{
 
53
  Grob *common = common_refpoint_of_array (grobs, refpoint, a);
 
54
  Interval ext = Axis_group_interface::relative_group_extent (grobs, common, a);
 
55
 
 
56
  Stencil b = make_bracket (me, ext.length(), a, dir);
 
57
  b.translate_axis (ext[LEFT] - refpoint->relative_coordinate (common, a), a);
 
58
 
 
59
  return b;
 
60
}
22
61
 
23
62
 
24
63
/*
25
64
  TODO:
26
65
 
27
 
  This doesn't look very elegant: should support winged edges.
28
 
 
29
66
  Support texts on the brackets?
30
67
*/
 
68
 
31
69
MAKE_SCHEME_CALLBACK (Horizontal_bracket, print, 1);
32
 
 
33
70
SCM
34
71
Horizontal_bracket::print (SCM smob)
35
72
{
36
 
  Grob * me = unsmob_grob (smob);
37
 
  Spanner *sp = dynamic_cast<Spanner*> (me);
38
 
  Link_array<Grob> gs = Pointer_group_interface__extract_grobs (me,(Grob*)0, "columns");
39
 
 
 
73
  Grob *me = unsmob_grob (smob);
 
74
  extract_grob_set (me, "columns", gs);
40
75
  if (!gs.size ())
41
76
    {
42
77
      me->suicide ();
43
78
      return SCM_EOL;
44
79
    }
45
 
  Grob * cx = common_refpoint_of_array (gs, me, X_AXIS);
46
 
  cx = cx->common_refpoint (sp->get_bound (LEFT), X_AXIS);
47
 
  cx = cx->common_refpoint (sp->get_bound (RIGHT),X_AXIS);
48
 
 
49
 
  Interval ext = gs.top ()->extent (cx, X_AXIS);
50
 
  ext.unite (gs[0]->extent (cx, X_AXIS));
51
 
 
52
 
  Direction d = get_grob_direction (me);
53
 
 
54
 
  Real thickness = Staff_symbol_referencer::line_thickness (me);
55
 
  thickness *= robust_scm2double (me->get_property ("thickness"), 1.0);
56
 
  
57
 
  Stencil b = Lookup::bracket (X_AXIS, ext, thickness, - d* 1.0, thickness/2); 
58
 
  
59
 
  b.translate_axis ( - sp->get_bound (LEFT)->relative_coordinate (cx, X_AXIS), X_AXIS);
60
 
 
61
 
  return b.smobbed_copy ();  
 
80
 
 
81
  Stencil b = make_enclosing_bracket (me, me, gs, X_AXIS, get_grob_direction (me));
 
82
  return b.smobbed_copy ();
62
83
}
63
84
 
64
 
ADD_INTERFACE (Horizontal_bracket,"horizontal-bracket-interface",
65
 
  "A horizontal bracket encompassing notes.",
66
 
  "thickness columns direction");
 
85
ADD_INTERFACE (Horizontal_bracket,
 
86
 
 
87
               "horizontal-bracket-interface",
 
88
               "A horizontal bracket encompassing notes.",
 
89
 
 
90
               /* props */                
 
91
               "bracket-flare "
 
92
               "columns "
 
93
               "edge-height "
 
94
               "shorten-pair "
 
95
               );
67
96