/*
This file is part of LilyPond, the GNU music typesetter.
- Copyright (C) 1996--2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ Copyright (C) 1996--2014 Han-Wen Nienhuys <hanwen@xs4all.nl>
LilyPond is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include "pointer-group-interface.hh"
#include "skyline-pair.hh"
#include "staff-symbol-referencer.hh"
+#include "system-start-delimiter.hh"
#include "text-interface.hh"
#include "warn.hh"
#include "unpure-pure-container.hh"
System::init_elements ()
{
SCM scm_arr = Grob_array::make_array ();
- all_elements_ = unsmob_grob_array (scm_arr);
+ all_elements_ = Grob_array::unsmob (scm_arr);
all_elements_->set_ordered (false);
set_object ("all-elements", scm_arr);
}
SCM ret = SCM_EOL;
for (vsize i = 0; i < broken_intos_.size (); i++)
ret = scm_cons (broken_intos_[i]->self_scm (), ret);
- return scm_reverse (ret);
+ return scm_reverse_x (ret, SCM_EOL);
}
SCM
scm_vector_set_x (lines, scm_from_int (i),
system->get_paper_system ());
- debug_output (to_string (i) + "]", false);
+ debug_output (::to_string (i) + "]", false);
}
return lines;
}
if (Item *item = dynamic_cast<Item *>(at_bat))
{
+ /*
+ We use this to weed out grobs that fall at the end
+ of the line when we want grobs at the beginning.
+ */
+ end_of_line_visible = item->break_status_dir () == LEFT;
+
if (!Item::break_visible (item))
continue;
// safeguard to bring down the column rank so that end of line footnotes show up on the correct line
continue;
if (!at_bat->is_live ())
continue;
+ /*
+ TODO
+ Sometimes, there are duplicate entries in the all_elements_
+ list. In a separate patch, this practice should be squashed
+ so that the check below can be eliminated.
+ */
+ if (find (out.begin (), out.end (), at_bat) != out.end ())
+ continue;
out.push_back (at_bat);
}
SCM footnote_stl = Text_interface::interpret_markup (pscore_->layout ()->self_scm (),
props, footnote_markup);
- Stencil *footnote_stencil = unsmob_stencil (footnote_stl);
+ Stencil *footnote_stencil = Stencil::unsmob (footnote_stl);
out.push_back (footnote_stencil->extent (Y_AXIS).length ());
}
SCM
System::footnotes_before_line_breaking (SCM smob)
{
- Grob *me = unsmob_grob (smob);
+ Grob *me = Grob::unsmob (smob);
vector<Grob *> footnotes;
SCM grobs_scm = Grob_array::make_array ();
extract_grob_set (me, "all-elements", elts);
if (elts[i]->internal_has_interface (ly_symbol2scm ("footnote-interface")))
footnotes.push_back (elts[i]);
- unsmob_grob_array (grobs_scm)->set_array (footnotes);
+ Grob_array::unsmob (grobs_scm)->set_array (footnotes);
return grobs_scm;
}
SCM
System::footnotes_after_line_breaking (SCM smob)
{
- Spanner *sys_span = unsmob_spanner (smob);
+ Spanner *sys_span = Spanner::unsmob (smob);
System *sys = dynamic_cast<System *> (sys_span);
Interval_t<int> sri = sys->spanned_rank_interval ();
vector<Grob *> footnote_grobs = sys->get_footnote_grobs_in_range (sri[LEFT], sri[RIGHT]);
vector_sort (footnote_grobs, grob_2D_less);
SCM grobs_scm = Grob_array::make_array ();
- unsmob_grob_array (grobs_scm)->set_array (footnote_grobs);
+ Grob_array::unsmob (grobs_scm)->set_array (footnote_grobs);
+ return grobs_scm;
+}
+
+MAKE_SCHEME_CALLBACK (System, vertical_skyline_elements, 1);
+SCM
+System::vertical_skyline_elements (SCM smob)
+{
+ Grob *me_grob = Grob::unsmob (smob);
+ vector<Grob *> vertical_skyline_grobs;
+ extract_grob_set (me_grob, "elements", my_elts);
+ for (vsize i = 0; i < my_elts.size (); i++)
+ if (System_start_delimiter::has_interface (my_elts[i]))
+ vertical_skyline_grobs.push_back (my_elts[i]);
+
+ System *me = dynamic_cast<System *> (me_grob);
+ Grob *align = Grob::unsmob (me->get_object ("vertical-alignment"));
+ if (!align)
+ {
+ SCM grobs_scm = Grob_array::make_array ();
+ Grob_array::unsmob (grobs_scm)->set_array (vertical_skyline_grobs);
+ return grobs_scm;
+ }
+
+ extract_grob_set (align, "elements", elts);
+
+ for (vsize i = 0; i < elts.size (); i++)
+ if (Hara_kiri_group_spanner::has_interface (elts[i]))
+ vertical_skyline_grobs.push_back (elts[i]);
+
+ SCM grobs_scm = Grob_array::make_array ();
+ Grob_array::unsmob (grobs_scm)->set_array (vertical_skyline_grobs);
return grobs_scm;
}
System::add_column (Paper_column *p)
{
Grob *me = this;
- Grob_array *ga = unsmob_grob_array (me->get_object ("columns"));
+ Grob_array *ga = Grob_array::unsmob (me->get_object ("columns"));
if (!ga)
{
SCM scm_ga = Grob_array::make_array ();
me->set_object ("columns", scm_ga);
- ga = unsmob_grob_array (scm_ga);
+ ga = Grob_array::unsmob (scm_ga);
}
p->set_rank (ga->size ());
anyway. */
vector<Grob *> all_elts_sorted (all_elements_->array ());
- vector_sort (all_elts_sorted, std::less<Grob *> ());
- uniq (all_elts_sorted);
+ uniquify (all_elts_sorted);
this->get_stencil ();
for (vsize i = all_elts_sorted.size (); i--;)
{
pl->set_property ("last-in-score", SCM_BOOL_T);
Interval staff_refpoints;
- if (Grob *align = get_vertical_alignment ())
+ if (Grob *align = Grob::unsmob (get_object ("vertical-alignment")))
{
extract_grob_set (align, "elements", staves);
for (vsize i = 0; i < staves.size (); i++)
return dynamic_cast<System *> (system_grob);
}
-Grob *
-System::get_vertical_alignment ()
+MAKE_SCHEME_CALLBACK (System, get_vertical_alignment, 1);
+SCM
+System::get_vertical_alignment (SCM smob)
{
- extract_grob_set (this, "elements", elts);
+ Grob *me = Grob::unsmob (smob);
+ extract_grob_set (me, "elements", elts);
Grob *ret = 0;
for (vsize i = 0; i < elts.size (); i++)
if (Align_interface::has_interface (elts[i]))
{
if (ret)
- programming_error ("found multiple vertical alignments in this system");
+ me->programming_error ("found multiple vertical alignments in this system");
ret = elts[i];
}
if (!ret)
- programming_error ("didn't find a vertical alignment in this system");
- return ret;
+ {
+ me->programming_error ("didn't find a vertical alignment in this system");
+ return SCM_EOL;
+ }
+ return ret->self_scm ();
}
// Finds the furthest staff in the given direction whose x-extent
Grob *
System::get_extremal_staff (Direction dir, Interval const &iv)
{
- Grob *align = get_vertical_alignment ();
+ Grob *align = Grob::unsmob (get_object ("vertical-alignment"));
if (!align)
return 0;
Grob *
System::get_neighboring_staff (Direction dir, Grob *vertical_axis_group, Interval_t<int> bounds)
{
- Grob *align = get_vertical_alignment ();
+ Grob *align = Grob::unsmob (get_object ("vertical-alignment"));
if (!align)
return 0;
System::pure_refpoint_extent (vsize start, vsize end)
{
Interval ret;
- Grob *alignment = get_vertical_alignment ();
+ Grob *alignment = Grob::unsmob (get_object ("vertical-alignment"));
if (!alignment)
return Interval ();
Interval
System::part_of_line_pure_height (vsize start, vsize end, bool begin)
{
- Grob *alignment = get_vertical_alignment ();
+ Grob *alignment = Grob::unsmob (get_object ("vertical-alignment"));
if (!alignment)
return Interval ();
SCM
System::calc_pure_relevant_grobs (SCM smob)
{
- Grob *me = unsmob_grob (smob);
+ Grob *me = Grob::unsmob (smob);
extract_grob_set (me, "elements", elts);
vector<Grob *> relevant_grobs;
- SCM pure_relevant_p = ly_lily_module_constant ("pure-relevant?");
for (vsize i = 0; i < elts.size (); ++i)
{
if (!Axis_group_interface::has_interface (elts[i]))
{
- if (to_boolean (scm_apply_1 (pure_relevant_p, elts[i]->self_scm (), SCM_EOL)))
- relevant_grobs.push_back (elts[i]);
+ relevant_grobs.push_back (elts[i]);
if (Item *it = dynamic_cast<Item *> (elts[i]))
{
- Direction d = LEFT;
- do
+ for (LEFT_and_RIGHT (d))
{
Item *piece = it->find_prebroken_piece (d);
- if (piece && to_boolean (scm_apply_1 (pure_relevant_p, piece->self_scm (), SCM_EOL)))
+ if (piece && piece->is_live ())
relevant_grobs.push_back (piece);
}
- while (flip (&d) != LEFT);
}
}
}
SCM grobs_scm = Grob_array::make_array ();
- unsmob_grob_array (grobs_scm)->set_array (relevant_grobs);
+ Grob_array::unsmob (grobs_scm)->set_array (relevant_grobs);
return grobs_scm;
}
SCM
System::calc_pure_height (SCM smob, SCM start_scm, SCM end_scm)
{
- System *me = dynamic_cast<System *> (unsmob_grob (smob));
+ System *me = dynamic_cast<System *> (Grob::unsmob (smob));
int start = scm_to_int (start_scm);
int end = scm_to_int (end_scm);
static SCM
get_maybe_spaceable_staves (SCM smob, int filter)
{
- System *me = dynamic_cast<System *> (unsmob_grob (smob));
- Grob *align = me->get_vertical_alignment ();
+ System *me = dynamic_cast<System *> (Grob::unsmob (smob));
+ Grob *align = Grob::unsmob (me->get_object ("vertical_alignment"));
SCM ret = SCM_EOL;
if (align)
"in-note-stencil "
"labels "
"pure-Y-extent "
- "skyline-horizontal-padding "
+ "vertical-alignment "
);