]> git.donarmstrong.com Git - lilypond.git/blob - lily/script-column-engraver.cc
*** empty log message ***
[lilypond.git] / lily / script-column-engraver.cc
1 /*   
2   script-column-engraver.cc --  implement Script_column_engraver
3   
4   source file of the GNU LilyPond music typesetter
5   
6   (c) 1999--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   
8  */
9
10 #include "engraver.hh"
11 #include "script-column.hh"
12 #include "side-position-interface.hh"
13
14 /**
15    Find potentially colliding scripts, and put them in a
16    Script_column, that will fix the collisions.  */
17 class Script_column_engraver : public Engraver
18 {
19   Grob *scol_;
20   Link_array<Item> scripts_;
21
22 public:
23   TRANSLATOR_DECLARATIONS (Script_column_engraver);
24 protected:
25   virtual void acknowledge_grob (Grob_info);
26   virtual void process_acknowledged_grobs ();
27   virtual void stop_translation_timestep ();
28 };
29
30
31 Script_column_engraver::Script_column_engraver ()
32 {
33   scol_ = 0;
34 }
35
36 void
37 Script_column_engraver::stop_translation_timestep ()
38 {
39   scol_ = 0;
40   scripts_.clear ();
41 }
42
43 void
44 Script_column_engraver::acknowledge_grob (Grob_info inf) 
45 {
46   Item *thing = dynamic_cast<Item*> (inf.grob_);
47   if (thing && Side_position_interface::has_interface (inf.grob_)) // ugh FIXME
48     {
49       if (!Item::is_breakable (thing)
50           && Side_position_interface::get_axis (inf.grob_) == Y_AXIS)
51         {
52           scripts_.push (thing);
53         }
54     }
55 }
56
57 void
58 Script_column_engraver::process_acknowledged_grobs ()
59 {
60   if (!scol_ && scripts_.size () > 1)
61     {
62       scol_ = make_item ("ScriptColumn", SCM_EOL);
63       
64     }
65
66   if (scol_)
67     {
68       for (int i = 0; i < scripts_.size (); i++)
69         Script_column::add_staff_sided (scol_, scripts_[i]);
70       scripts_.clear ();
71     }
72
73 }
74
75 ENTER_DESCRIPTION (Script_column_engraver,
76 /* descr */       "",
77 /* creats*/       "ScriptColumn",
78 /* accepts */     "",
79 /* acks  */      "side-position-interface",
80 /* reads */       "",
81 /* write */       "");