2 horizontal-bracket-engraver.cc -- implement
3 Horizontal_bracket_engraver
5 source file of the GNU LilyPond music typesetter
7 (c) 2002--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
11 #include "engraver.hh"
12 #include "side-position-interface.hh"
13 #include "note-column.hh"
14 #include "group-interface.hh"
16 class Horizontal_bracket_engraver
: public Engraver
19 TRANSLATOR_DECLARATIONS (Horizontal_bracket_engraver
);
20 Link_array
<Spanner
> bracket_stack_
;
21 Link_array
<Music
> events_
;
25 virtual bool try_music (Music
*);
26 virtual void stop_translation_timestep ();
27 virtual void process_music ();
28 virtual void acknowledge_grob (Grob_info
);
31 ENTER_DESCRIPTION (Horizontal_bracket_engraver
,
32 "Create horizontal brackets over notes for musical analysis purposes.",
34 "note-grouping-event",
35 "note-column-interface",
39 Horizontal_bracket_engraver::Horizontal_bracket_engraver ()
47 Horizontal_bracket_engraver::try_music (Music
*m
)
49 if (m
->is_mus_type ("note-grouping-event"))
51 Direction d
= to_dir (m
->get_property ("span-direction"));
56 if (pop_count_
> bracket_stack_
.size ())
57 m
->origin ()->warning (_("Don't have that many brackets."));
65 if (pop_count_
&& push_count_
)
66 m
->origin ()->warning (_("Conflicting note group events."));
74 Horizontal_bracket_engraver::acknowledge_grob (Grob_info gi
)
76 if (Note_column::has_interface (gi
.grob_
))
78 for (int i
= 0; i
< bracket_stack_
.size (); i
++)
80 Side_position_interface::add_support (bracket_stack_
[i
], gi
.grob_
);
81 Pointer_group_interface::add_grob (bracket_stack_
[i
],
82 ly_symbol2scm ("columns"), gi
.grob_
);
83 add_bound_item (bracket_stack_
[i
],
90 Horizontal_bracket_engraver::process_music ()
92 for (int k
= 0; k
< push_count_
; k
++)
94 Spanner
* sp
= make_spanner ("HorizontalBracket");
96 announce_grob (sp
, events_
[k
]->self_scm ());
97 for (int i
= 0; i
< bracket_stack_
.size (); i
++)
100 sp is the smallest, it should be added to the bigger brackets.
102 Side_position_interface::add_support (bracket_stack_
[i
], sp
);
104 bracket_stack_
.push (sp
);
110 Horizontal_bracket_engraver::stop_translation_timestep ()
112 for (int i
= pop_count_
; i
--;)
114 if (bracket_stack_
.size ())
115 typeset_grob (bracket_stack_
.pop ());