X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Faxis-group-interface.cc;h=c253b4adfbb6d26402507039e19781c40a5d07c5;hb=893b347387eb61f602cf44d4db244cda429c2328;hp=87abab3a2f845484a9d9c6c26d2a3c08d92ec804;hpb=c96dc4cfcb9ca9be790b4cca05f70538bbab9b05;p=lilypond.git diff --git a/lily/axis-group-interface.cc b/lily/axis-group-interface.cc index 87abab3a2f..c253b4adfb 100644 --- a/lily/axis-group-interface.cc +++ b/lily/axis-group-interface.cc @@ -1,24 +1,36 @@ /* - axis-group-interface.cc -- implement Axis_group_interface + This file is part of LilyPond, the GNU music typesetter. - source file of the GNU LilyPond music typesetter + Copyright (C) 2000--2009 Han-Wen Nienhuys - (c) 2000--2009 Han-Wen Nienhuys + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . */ #include "axis-group-interface.hh" #include "align-interface.hh" #include "directional-element-interface.hh" -#include "pointer-group-interface.hh" #include "grob-array.hh" #include "hara-kiri-group-spanner.hh" #include "international.hh" #include "lookup.hh" #include "paper-column.hh" #include "paper-score.hh" +#include "pointer-group-interface.hh" #include "separation-item.hh" #include "skyline-pair.hh" +#include "staff-grouper-interface.hh" #include "stencil.hh" #include "system.hh" #include "warn.hh" @@ -76,6 +88,15 @@ Axis_group_interface::relative_group_extent (vector const &elts, Interval Axis_group_interface::cached_pure_height (Grob *me, int start, int end) +{ + Interval iv = begin_of_line_pure_height (me, start); + iv.unite (rest_of_line_pure_height (me, start, end)); + + return iv; +} + +Interval +Axis_group_interface::rest_of_line_pure_height (Grob *me, int start, int end) { SCM adjacent_pure_heights = me->get_property ("adjacent-pure-heights"); @@ -579,7 +600,7 @@ add_grobs_of_one_priority (Skyline_pair *const skylines, b.translate (Offset (0, dir*dist)); elements[i]->translate_axis (dir*dist, Y_AXIS); } - (*skylines)[dir].insert (b, 0, X_AXIS); + skylines->insert (b, 0, X_AXIS); elements[i]->set_property ("outside-staff-priority", SCM_BOOL_F); last_affected_position[dir] = b[X_AXIS][RIGHT]; } @@ -641,7 +662,11 @@ Axis_group_interface::skyline_spacing (Grob *me, vector elements) current_elts.push_back (elements[i]); while (i + 1 < elements.size () && scm_eq_p (elements[i+1]->get_property ("outside-staff-priority"), priority)) - current_elts.push_back (elements[++i]); + { + if (!to_boolean (elements[i+1]->get_property ("cross-staff"))) + current_elts.push_back (elements[i+1]); + ++i; + } add_grobs_of_one_priority (&skylines, current_elts, x_common, y_common); } @@ -649,21 +674,6 @@ Axis_group_interface::skyline_spacing (Grob *me, vector elements) return skylines; } -MAKE_SCHEME_CALLBACK (Axis_group_interface, calc_max_stretch, 1) -SCM -Axis_group_interface::calc_max_stretch (SCM smob) -{ - Grob *me = unsmob_grob (smob); - Real ret = 0; - extract_grob_set (me, "elements", elts); - - for (vsize i = 0; i < elts.size (); i++) - if (Axis_group_interface::has_interface (elts[i])) - ret += robust_scm2double (elts[i]->get_property ("max-stretch"), 0.0); - - return scm_from_double (ret); -} - MAKE_SCHEME_CALLBACK (Axis_group_interface, print, 1) SCM Axis_group_interface::print (SCM smob) @@ -683,20 +693,61 @@ Axis_group_interface::print (SCM smob) return ret.smobbed_copy (); } +MAKE_SCHEME_CALLBACK (Axis_group_interface, calc_next_staff_spacing, 1) +SCM +Axis_group_interface::calc_next_staff_spacing (SCM smob) +{ + Grob *me = unsmob_grob (smob); + Grob *grouper = unsmob_grob (me->get_object ("staff-grouper")); + + if (grouper) + { + Grob *last_in_group = Staff_grouper_interface::get_last_grob (grouper); + if (me == last_in_group) + return grouper->get_property ("after-last-staff-spacing"); + else + return grouper->get_property ("between-staff-spacing"); + } + return me->get_property ("default-next-staff-spacing"); +} + +Real +Axis_group_interface::minimum_distance (Grob *g1, Grob *g2, Axis a) +{ + SCM sym = ly_symbol2scm ((a == Y_AXIS) ? "vertical-skylines" : "horizontal-skylines"); + + Skyline_pair *s1 = Skyline_pair::unsmob (g1->get_property (sym)); + Skyline_pair *s2 = Skyline_pair::unsmob (g2->get_property (sym)); + if (s1 && s2) + return (*s1)[DOWN].distance ((*s2)[UP]); + return 0; +} + ADD_INTERFACE (Axis_group_interface, "An object that groups other layout objects.", + // TODO: some of these properties are specific to + // VerticalAxisGroup. We should split off a + // vertical-axis-group-interface. /* properties */ "X-common " "Y-common " "adjacent-pure-heights " "axes " + "default-next-staff-spacing " "elements " + "inter-loose-line-spacing " + "inter-staff-spacing " "keep-fixed-while-stretching " "max-stretch " + "non-affinity-spacing " + "next-staff-spacing " "no-alignment " "pure-Y-common " "pure-relevant-items " "pure-relevant-spanners " + "staff-affinity " + "staff-grouper " + "system-Y-offset " "vertical-skylines " );