* lexer-gcc-3.1.sh: Remove.
[lilypond/patrick.git] / lily / break-align-engraver.cc
blob461ead59caec1cd409e34fe7df959ae5079abac9
1 /*
2 break-align-engraver.cc -- implement Break_align_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8 #include "engraver.hh"
9 #include "protected-scm.hh"
10 #include "break-align-interface.hh"
11 #include "align-interface.hh"
12 #include "axis-group-interface.hh"
13 #include "context.hh"
14 #include "translator-group.hh"
16 #include "translator.icc"
18 class Break_align_engraver : public Engraver
20 Item *align_;
21 SCM column_alist_;
22 Item *left_edge_;
24 void add_to_group (SCM, Item *);
25 protected:
26 void stop_translation_timestep ();
27 virtual void derived_mark () const;
28 public:
29 TRANSLATOR_DECLARATIONS (Break_align_engraver);
30 DECLARE_ACKNOWLEDGER (break_aligned);
33 void
34 Break_align_engraver::stop_translation_timestep ()
36 column_alist_ = SCM_EOL;
38 align_ = 0;
39 left_edge_ = 0;
42 Break_align_engraver::Break_align_engraver ()
44 column_alist_ = SCM_EOL;
45 left_edge_ = 0;
46 align_ = 0;
49 void
50 Break_align_engraver::derived_mark () const
52 scm_gc_mark (column_alist_);
55 void
56 Break_align_engraver::acknowledge_break_aligned (Grob_info inf)
58 if (Item *item = dynamic_cast<Item *> (inf.grob ()))
61 Removed check for item->empty (X_AXIS). --hwn 20/1/04
63 if (item->get_parent (X_AXIS))
64 return;
66 if (!Item::is_non_musical (item))
67 return;
69 SCM align_name = item->get_property ("break-align-symbol");
70 if (!scm_is_symbol (align_name))
71 return;
73 if (!align_)
75 align_ = make_item ("BreakAlignment", SCM_EOL);
77 Context *origin = inf.origin_contexts (this)[0];
79 Translator_group *tg = origin->implementation ();
80 Engraver *random_source = dynamic_cast<Engraver *> (unsmob_translator (scm_car (tg->get_simple_trans_list ())));
83 Make left edge appear to come from same context as clef/bar-line etc.
85 left_edge_ = random_source->make_item ("LeftEdge", SCM_EOL);
86 add_to_group (left_edge_->get_property ("break-align-symbol"),
87 left_edge_);
90 add_to_group (align_name, item);
94 void
95 Break_align_engraver::add_to_group (SCM align_name, Item *item)
97 SCM s = scm_assoc (align_name, column_alist_);
98 Item *group = 0;
100 if (s != SCM_BOOL_F)
102 Grob *e = unsmob_grob (scm_cdr (s));
103 group = dynamic_cast<Item *> (e);
105 else
107 group = make_item ("BreakAlignGroup", item->self_scm ());
109 group->set_property ("break-align-symbol", align_name);
110 group->set_parent (align_, Y_AXIS);
112 column_alist_ = scm_assoc_set_x (column_alist_, align_name, group->self_scm ());
114 Break_align_interface::add_element (align_, group);
116 Axis_group_interface::add_element (group, item);
118 ADD_ACKNOWLEDGER (Break_align_engraver, break_aligned);
119 ADD_TRANSLATOR (Break_align_engraver,
120 "Align grobs with corresponding @code{break-align-symbols} into "
121 "groups, and order the groups according to @code{breakAlignOrder}. "
122 "The left edge of the alignment gets a separate group, with a symbol @code{left-edge}. ",
123 /* create */ "BreakAlignment BreakAlignGroup LeftEdge",
124 /* accept */ "",
125 /* read */ "",
126 /* write */ "");