summaryrefslogtreecommitdiff
path: root/lily/vertical-align-engraver.cc
blob: 442731b5f355cd1038abc1b8a0dd1c6f1a53b68b (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
  vertical-align-grav.cc -- implement Vertical_align_engraver

  source file of the GNU LilyPond music typesetter

  (c)  1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "translator-group.hh"
#include "paper-column.hh"
#include "align-interface.hh"
#include "span-bar.hh"
#include "axis-group-interface.hh"
#include "engraver.hh"
#include "spanner.hh"

class Vertical_align_engraver : public Engraver
{
  Spanner * valign_p_;
  bool qualifies_b (Grob_info) const;  
public:
  VIRTUAL_COPY_CONS(Translator);
  Vertical_align_engraver();
protected:
  virtual void acknowledge_grob (Grob_info);
  virtual void initialize();
  virtual void finalize();
};

Vertical_align_engraver::Vertical_align_engraver()
{
  valign_p_ =0;
}

void
Vertical_align_engraver::initialize()
{
  valign_p_ =new Spanner (get_property ("VerticalAlignment"));
  valign_p_->set_bound(LEFT,unsmob_grob (get_property ("currentCommandColumn")));
  announce_grob (valign_p_ , 0);
}

void
Vertical_align_engraver::finalize()
{
  valign_p_->set_bound(RIGHT,unsmob_grob (get_property ("currentCommandColumn")));
  typeset_grob (valign_p_);
  valign_p_ =0;
}


bool
Vertical_align_engraver::qualifies_b (Grob_info i) const
{
  int sz = i.origin_trans_l_arr ((Translator*)this).size()  ;

  return sz > 1 && Axis_group_interface::has_interface (i.elem_l_)
    && !i.elem_l_->parent_l (Y_AXIS) && Axis_group_interface::axis_b (i.elem_l_, Y_AXIS);
}

void
Vertical_align_engraver::acknowledge_grob (Grob_info i)
{
  if (qualifies_b (i))
    {
      Align_interface::add_element (valign_p_,i.elem_l_);
    }
}

ADD_THIS_TRANSLATOR(Vertical_align_engraver);