]> git.donarmstrong.com Git - lilypond.git/blob - lily/pure-from-neighbor-interface.cc
Improves horizontal spacing of axis groups that SpanBars traverse (issue 1846).
[lilypond.git] / lily / pure-from-neighbor-interface.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2011 Mike Solomon <mike@apollinemike.com>
5
6   LilyPond is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "grob.hh"
21 #include "grob-array.hh"
22 #include "pointer-group-interface.hh"
23 #include "pure-from-neighbor-interface.hh"
24 #include "spanner.hh"
25 #include "system.hh"
26
27 MAKE_SCHEME_CALLBACK (Pure_from_neighbor_interface, filter_elements, 1);
28 SCM
29 Pure_from_neighbor_interface::filter_elements (SCM smob)
30 {
31   Grob *me = unsmob_grob (smob);
32   extract_grob_set (me, "elements", elts);
33   vector<Grob *> new_elts;
34   Interval_t<int> srl = me->get_system ()->spanned_rank_interval ();
35   for (vsize i = 0; i < elts.size (); i++)
36     if (srl.contains (elts[i]->spanned_rank_interval ()[LEFT]))
37       new_elts.push_back (elts[i]);
38
39   SCM elements_scm = me->get_object ("elements");
40   if (Grob_array::unsmob (elements_scm))
41     {
42       vector<Grob *> &arr
43         = unsmob_grob_array (elements_scm)->array_reference ();
44       arr = new_elts;
45     }
46
47   return SCM_BOOL_T;
48 }
49
50 ADD_INTERFACE (Pure_from_neighbor_interface,
51                "A collection of routines to allow for objects' pure"
52                "heights and heights to be calculated based on the"
53                "heights of the objects' neighbors.",
54
55                /* properties */
56                "elements-filtered "
57               );