Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(364)

Unified Diff: lily/side-position-interface.cc

Issue 7185044: Caches the interior skylines of vertical axis groups and systems. Base URL: http://git.savannah.gnu.org/gitweb/?p=lilypond.git/trunk/
Patch Set: Gives Hairpin outside-staff-interface Created 11 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: lily/side-position-interface.cc
diff --git a/lily/side-position-interface.cc b/lily/side-position-interface.cc
index 026a3286c55e9fae2c8d275aa5fb089dc1072c34..327719bdf7ab819b04325ea214fab0da82bf332d 100644
--- a/lily/side-position-interface.cc
+++ b/lily/side-position-interface.cc
@@ -33,6 +33,7 @@ using namespace std;
#include "grob.hh"
#include "grob-array.hh"
#include "international.hh"
+#include "interval-set.hh"
#include "item.hh"
#include "main.hh"
#include "misc.hh"
@@ -126,7 +127,11 @@ Side_position_interface::x_aligned_side (SCM smob, SCM current_off)
return axis_aligned_side_helper (smob, X_AXIS, true, 0, 0, current_off);
}
-MAKE_SCHEME_CALLBACK_WITH_OPTARGS (Side_position_interface, y_aligned_side, 2, 1, "");
+MAKE_SCHEME_CALLBACK_WITH_OPTARGS (Side_position_interface, y_aligned_side, 2, 1,
+"Shifts a Grob over or below @code{side-position-elements} by @code{padding}."
+" If @code{outside-staff-priority} is set, the grob is positioned outside"
+" the staff so that it is farther from the staff than grobs that have a lower"
+" @code{outside-staff-priority}.");
SCM
Side_position_interface::y_aligned_side (SCM smob, SCM current_off)
{
@@ -155,7 +160,7 @@ Side_position_interface::calc_cross_staff (SCM smob)
// which need the direction for positioning. So the get_grob_direction call
// may lead to circular dependencies.
// #if 0
- Direction my_dir = get_grob_direction (me) ;
+ Direction my_dir = get_grob_direction (me);
// if a cross-staff grob is pointing in a different direction than
// that of an aligning element, we assume that the alignment
@@ -186,9 +191,20 @@ SCM
Side_position_interface::aligned_side (Grob *me, Axis a, bool pure, int start, int end,
Real *current_off)
{
+ Real total_off = 0.0;
Direction dir = get_grob_direction (me);
-
set<Grob *> support = get_support_set (me);
+ Grob *staff_symbol = Staff_symbol_referencer::get_staff_symbol (me);
+ bool quantize_position = to_boolean (me->get_maybe_pure_property ("quantize-position", pure, start, end));
+
+ bool include_staff
+ = staff_symbol
+ && a == Y_AXIS
+ && !to_boolean (me->get_property ("cross-staff"))
+ && scm_is_number (me->get_maybe_pure_property ("staff-padding", pure, start, end))
+ && !quantize_position;
+
+ Real ss = Staff_symbol_referencer::staff_space (me);
Grob *common[2];
for (Axis ax = X_AXIS; ax < NO_AXES; incr (ax))
@@ -198,26 +214,19 @@ Side_position_interface::aligned_side (Grob *me, Axis a, bool pure, int start, i
: me),
ax);
- Grob *staff_symbol = Staff_symbol_referencer::get_staff_symbol (me);
- bool quantize_position = to_boolean (me->get_maybe_pure_property ("quantize-position", pure, start, end));
-
- bool include_staff
- = staff_symbol
- && a == Y_AXIS
- && scm_is_number (me->get_maybe_pure_property ("staff-padding", pure, start, end))
- && !quantize_position;
if (include_staff)
common[Y_AXIS] = staff_symbol->common_refpoint (common[Y_AXIS], Y_AXIS);
Skyline my_dim;
- Skyline_pair *skyp = Skyline_pair::unsmob (
- me->get_maybe_pure_property (a == X_AXIS
- ? "horizontal-skylines"
- : "vertical-skylines",
- pure,
- start,
- end));
+ SCM skyp_scm = me->get_maybe_pure_property (a == X_AXIS
+ ? "horizontal-skylines"
+ : "vertical-skylines",
+ pure,
+ start,
+ end);
+ Skyline_pair *skyp = Skyline_pair::unsmob (skyp_scm);
+
if (skyp)
{
// for spanner pure heights, we don't know horizontal spacing,
@@ -242,7 +251,6 @@ Side_position_interface::aligned_side (Grob *me, Axis a, bool pure, int start, i
else
me->warning ("cannot find skylines - strange alignment will follow");
-
vector<Box> boxes;
vector<Skyline_pair> skyps;
set<Grob *>::iterator it;
@@ -266,13 +274,13 @@ Side_position_interface::aligned_side (Grob *me, Axis a, bool pure, int start, i
bool cross_staff = to_boolean (e->get_property ("cross-staff"));
- Skyline_pair *sp = Skyline_pair::unsmob
- (e->get_maybe_pure_property (a == X_AXIS
- ? "horizontal-skylines"
- : "vertical-skylines",
- pure || cross_staff,
- start,
- end));
+ SCM sp_scm = e->get_maybe_pure_property (a == X_AXIS
+ ? "horizontal-skylines"
+ : "vertical-skylines",
+ pure || cross_staff,
+ start,
+ end);
+ Skyline_pair *sp = Skyline_pair::unsmob (sp_scm);
aligns_to_cross_staff |= cross_staff;
if (sp)
@@ -288,7 +296,7 @@ Side_position_interface::aligned_side (Grob *me, Axis a, bool pure, int start, i
Skyline_pair copy = Skyline_pair (*sp);
if (a == Y_AXIS
&& Stem::has_interface (e)
- && to_boolean (me->get_maybe_pure_property ("add-stem-support", pure, start, end)))
+ && to_boolean (me->get_property ("add-stem-support")))
copy[dir].set_minimum_height (copy[dir].max_height ());
copy.shift (a == X_AXIS ? yc : xc);
copy.raise (a == X_AXIS ? xc : yc);
@@ -344,14 +352,12 @@ Side_position_interface::aligned_side (Grob *me, Axis a, bool pure, int start, i
if (aligns_to_cross_staff)
dim.set_minimum_height (dim.max_height ());
- Real ss = Staff_symbol_referencer::staff_space (me);
Real dist = dim.distance (my_dim, robust_scm2double (me->get_maybe_pure_property ("horizon-padding", pure, start, end), 0.0));
- Real total_off = !isinf (dist) ? dir * dist : 0.0;
+ total_off = !isinf (dist) ? dir * dist : 0.0;
total_off += dir * ss * robust_scm2double (me->get_maybe_pure_property ("padding", pure, start, end), 0.0);
Real minimum_space = ss * robust_scm2double (me->get_maybe_pure_property ("minimum-space", pure, start, end), -1);
-
if (minimum_space >= 0
&& dir
&& total_off * dir < minimum_space)
@@ -404,7 +410,9 @@ Side_position_interface::aligned_side (Grob *me, Axis a, bool pure, int start, i
total_off += dir * 0.5 * ss;
}
}
- else if (scm_is_number (me->get_maybe_pure_property ("staff-padding", pure, start, end)) && dir)
+ else if (scm_is_number (me->get_maybe_pure_property ("staff-padding", pure, start, end))
+ && dir
+ && !to_boolean (me->get_property ("cross-staff")))
{
Interval iv = me->maybe_pure_extent (me, a, pure, start, end);
@@ -423,6 +431,7 @@ Side_position_interface::aligned_side (Grob *me, Axis a, bool pure, int start, i
total_off += dir * max (diff, 0.0);
}
}
+
return scm_from_double (total_off);
}
@@ -517,5 +526,4 @@ ADD_INTERFACE (Side_position_interface,
"side-support-elements "
"slur-padding "
"staff-padding "
- "use-skylines "
);
« lily/axis-group-interface.cc ('K') | « lily/script-interface.cc ('k') | lily/slur.cc » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b