]> git.donarmstrong.com Git - lilypond.git/blob - lily/break-align-item.cc
release: 1.1.46
[lilypond.git] / lily / break-align-item.cc
1 /*
2   break-align-item.cc -- implement Break_align_item
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "lily-guile.hh"
10 #include "break-align-item.hh"
11 #include "dimensions.hh"
12 #include "p-score.hh"
13 #include "paper-def.hh"
14
15 void
16 Break_align_item::do_pre_processing()
17 {
18   align_dir_ = break_status_dir();
19   flip (&align_dir_);
20   sort_elements ();
21
22   
23   Link_array<Score_element> elems;
24   for (int i=0; i < elem_l_arr_.size(); i++) 
25     {
26       Interval y = elem_l_arr_[i]->extent(axis ());
27       if (!y.empty_b())
28         elems.push (dynamic_cast<Score_element*> (elem_l_arr_[i]));
29     }
30   
31
32   if (elems.size ())
33     {
34       Score_element *current_elt =elems[0];
35       SCM current_origin = current_elt->get_elt_property (origin_scm_sym);
36
37       if (current_origin != SCM_BOOL_F)
38         current_origin = SCM_CDR (current_origin);
39       
40       for (int i=1; i < elems.size (); i++)
41         {
42           Score_element *next_elt  = elems[i];
43           SCM next_origin = next_elt->get_elt_property (origin_scm_sym);
44           if (next_origin != SCM_BOOL_F)
45             {
46               next_origin = SCM_CDR(next_origin);
47               SCM extra_space = scm_eval (scm_listify (ly_symbol ("break-align-spacer"),
48                                                             current_origin,
49                                                             next_origin,
50                                                             SCM_UNDEFINED));
51
52               
53               Real spc = gh_scm2double (extra_space);
54               spc *= paper_l ()->get_realvar (interline_scm_sym);       
55               
56               current_elt->set_elt_property (extra_space_scm_sym,
57                                              scm_cons (gh_double2scm (0.0),
58                                                        gh_double2scm (spc)));
59               
60             }
61           current_elt = next_elt;
62           current_origin = next_origin;   
63         }
64
65     }
66   Axis_align_item::do_pre_processing();
67 }
68
69
70
71
72 Break_align_item::Break_align_item ()
73 {
74   stacking_dir_ = RIGHT;
75   threshold_interval_[SMALLER] = 1.5 PT;
76   set_axis (X_AXIS);
77 }
78
79 void
80 Break_align_item::add_breakable_item (Item *it)
81 {
82   SCM pr = it->remove_elt_property (break_priority_scm_sym); 
83
84   if (pr == SCM_BOOL_F)
85     return;
86
87   int priority = gh_scm2int (SCM_CDR (pr));
88
89   Score_element * column_l = get_elt_by_priority (priority);
90   Axis_group_item * hg=0;
91   if (column_l)
92     {
93       hg = dynamic_cast<Axis_group_item*> (column_l);
94     }
95   else
96     {
97       hg = new Axis_group_item;
98       hg->set_axes (X_AXIS,X_AXIS);
99
100       /*
101         this is quite ridiculous, but we do this anyway, to ensure that no
102         warning bells about missing Y refpoints go off later on.
103       */
104       hg->dim_cache_[Y_AXIS]->parent_l_ = dim_cache_[Y_AXIS];
105       hg->set_elt_property (ly_symbol("origin"), gh_str02scm (it->name()));
106
107       pscore_l_->typeset_element (hg);
108       add_element_priority (hg, priority);
109
110       if (priority == 0)
111         center_l_ = hg;
112     }
113   
114   /*
115   hg->set_elt_property (ly_symbol("origin"),
116                         scm_cons (gh_str02scm (it->name()),
117                                   hg->get_elt_property (ly_symbol ("origin"))));
118   */
119   hg->add_element (it);
120
121
122 }