X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fscript-column.cc;h=3e4092f7c694ad87b6b3c0fa08294e92f05ece3c;hb=794a037c19a838dd56ceb59e2280059fb80d944a;hp=16eccc8a41acea70a62d33ce9af7de1877b18856;hpb=67a763d2c94cf4e24c01186d9f2df06b31778778;p=lilypond.git diff --git a/lily/script-column.cc b/lily/script-column.cc index 16eccc8a41..3e4092f7c6 100644 --- a/lily/script-column.cc +++ b/lily/script-column.cc @@ -3,119 +3,158 @@ source file of the GNU LilyPond music typesetter - (c) 1997--1999 Han-Wen Nienhuys + (c) 1999--2007 Han-Wen Nienhuys */ #include "script-column.hh" -#include "debug.hh" -#include "script.hh" -#include "note-head.hh" -#include "stem.hh" -#include "general-script-def.hh" +#include "accidental-placement.hh" +#include "arpeggio.hh" +#include "directional-element-interface.hh" +#include "side-position-interface.hh" +#include "warn.hh" +#include "grob.hh" +#include "pointer-group-interface.hh" +#include +typedef map > Grob_scripts_map; void -Script_column::add_script (Script*s_l) +Script_column::add_side_positioned (Grob *me, Grob *script) { - script_l_arr_.push (s_l); - add_dependency (s_l); - add_element (s_l); -} - + SCM p = script->get_property ("script-priority"); + if (!scm_is_number (p)) + return; -void -Script_column::do_print() const -{ -#ifndef NPRINT - DOUT << "scripts: " << script_l_arr_.size() << '\n'; -#endif + Pointer_group_interface::add_grob (me, ly_symbol2scm ("scripts"), script); } -static int -idx (bool inside, int dir) +LY_DEFINE (ly_grob_script_priority_less, "ly:grob-script-priority-less", + 2, 0, 0, (SCM a, SCM b), + "Compare two grobs by script priority. For internal use.") { - int j = (dir+1); - if (!inside) - j ++; - return j; -} + Grob *i1 = unsmob_grob (a); + Grob *i2 = unsmob_grob (b); + SCM p1 = i1->get_property ("script-priority"); + SCM p2 = i2->get_property ("script-priority"); -Script_column::Script_column () -{ - set_axes (X_AXIS,X_AXIS); + return scm_to_int (p1) < scm_to_int (p2) ? SCM_BOOL_T : SCM_BOOL_F; } -void -Script_column::do_pre_processing() +MAKE_SCHEME_CALLBACK (Script_column, row_before_line_breaking, 1); +SCM +Script_column::row_before_line_breaking (SCM smob) { - if (!script_l_arr_.size()) - return; - - /* up+inside, up+outside, down+inside, down+outside */ - Array placed_l_arr_a[4]; - for (int i=0; i < script_l_arr_.size(); i++) - { - Script*s_l = script_l_arr_[i]; - placed_l_arr_a[idx (s_l->specs_p_->inside_b(), - s_l->dir_) ].push (s_l); - } - - for (int j =0; j <4; j++) - { - placed_l_arr_a[j].sort (Script::compare); - } + Grob *me = unsmob_grob (smob); + vector horizontal_grobs; + extract_grob_set (me, "scripts", scripts); - - for (int j =0; j < 4; j++) + Grob_scripts_map head_scripts_map; + vector affect_all_grobs; + for (vsize i = 0; i < scripts.size (); i++) { - if (placed_l_arr_a[j].size()) - for (int i=0; i < support_l_arr_.size(); i++) - placed_l_arr_a[j][0]->add_support (support_l_arr_[i]); - } - - Item * support_l=0; - int j = 0; - for (; j < 2; j++) - { - for (int i=0; i < placed_l_arr_a[j].size(); i++) + Grob *sc = scripts[i]; + + /* + Don't want to consider scripts horizontally next to notes. + */ + if (Accidental_placement::has_interface (sc) + || Arpeggio::has_interface (sc)) { - if (support_l) - placed_l_arr_a[j][i]->add_support (support_l); - support_l = placed_l_arr_a[j][i]; + affect_all_grobs.push_back (sc); } - } - support_l = 0; - for (; j < 4; j++) - { - for (int i=0; i < placed_l_arr_a[j].size(); i++) + else if (sc->get_property_data ("Y-offset") != + Side_position_interface::x_aligned_side_proc) { - if (support_l) - placed_l_arr_a[j][i]->add_support (support_l); - support_l = placed_l_arr_a[j][i]; + head_scripts_map[sc->get_parent (Y_AXIS)].push_back (sc); } } + + for (Grob_scripts_map::const_iterator i (head_scripts_map.begin ()); + i != head_scripts_map.end (); + i++) + { + vector grobs = (*i).second; + + // this isn't right in all cases, but in general a safe assumption. + concat (grobs, affect_all_grobs); + order_grobs (grobs); + } + + return SCM_UNSPECIFIED; } -void -Script_column::add_support (Item*i_l) +MAKE_SCHEME_CALLBACK (Script_column, before_line_breaking, 1); +SCM +Script_column::before_line_breaking (SCM smob) { - support_l_arr_.push (i_l); - add_dependency (i_l); - add_element (i_l); + Grob *me = unsmob_grob (smob); + vector staff_sided; + + extract_grob_set (me, "scripts", scripts); + for (vsize i = 0; i < scripts.size (); i++) + { + Grob *sc = scripts[i]; + /* + Don't want to consider scripts horizontally next to notes. + */ + if (sc->get_property_data ("X-offset") != + Side_position_interface::x_aligned_side_proc) + staff_sided.push_back (sc); + } + + order_grobs (staff_sided); + return SCM_UNSPECIFIED; } void -Script_column::do_substitute_element_pointer (Score_element*o,Score_element*n) +Script_column::order_grobs (vector grobs) { - if (dynamic_cast (o)) + Drul_array scripts_drul (SCM_EOL, SCM_EOL); + for (vsize i = 0; i < grobs.size (); i++) + { + Grob *g = grobs[i]; + Direction d = get_grob_direction (g); + + scripts_drul[d] = scm_cons (g->self_scm (), scripts_drul[d]); + } + + Direction d = DOWN; + do { - script_l_arr_.substitute (dynamic_cast