X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fdot-configuration.cc;h=25d35eb6916c51b9d40af8b8c5eb0a672ee9a2cb;hb=77267b700c377fd170abcbf4863728937038eb5e;hp=e2680bd2d2292992b29f7e7febed0edb41ea3767;hpb=a6a4b3fc2009f17a1a48cca0c11bfd3f38645937;p=lilypond.git diff --git a/lily/dot-configuration.cc b/lily/dot-configuration.cc index e2680bd2d2..25d35eb691 100644 --- a/lily/dot-configuration.cc +++ b/lily/dot-configuration.cc @@ -1,18 +1,27 @@ /* - dot-implement.cc -- declare Dot_configuration + This file is part of LilyPond, the GNU music typesetter. - Source file of the GNU LilyPond music typesetter. Distributed under - terms of the GNU General Public License. LilyPond comes with NO - WARRANTY. + Copyright (C) 1997--2015 Han-Wen Nienhuys - (c) 1997--2008 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 #include "dot-configuration.hh" #include "dot-formatting-problem.hh" #include "staff-symbol-referencer.hh" - int Dot_configuration::badness () const { @@ -24,16 +33,11 @@ Dot_configuration::badness () const int demerit = sqr (p - i->second.pos_) * 2; int dot_move_dir = sign (p - i->second.pos_); - if (i->second.extremal_head_) - { - if (i->second.dir_ - && dot_move_dir != i->second.dir_) - demerit += 3; - else if (dot_move_dir != UP) - demerit += 2; - } + if (i->second.dir_ + && dot_move_dir != i->second.dir_) + demerit += 2; else if (dot_move_dir != UP) - demerit += 1; + demerit += 1; t += demerit; } @@ -67,55 +71,55 @@ Dot_configuration::shifted (int k, Direction d) const if (d > 0) { for (Dot_configuration::const_iterator i (begin ()); - i != end (); i++) - { - int p = i->first; - if (p == k) - { - if (Staff_symbol_referencer::on_line (i->second.dot_, p)) - p += d; - else - p += 2* d; - - offset = 2*d; - - new_cfg[p] = i->second; - } - else - { - if (new_cfg.find (p) == new_cfg.end ()) - offset = 0; - new_cfg[p + offset] = i->second; - } - } + i != end (); i++) + { + int p = i->first; + if (p == k) + { + if (Staff_symbol_referencer::on_line (i->second.dot_, p)) + p += d; + else + p += 2 * d; + + offset = 2 * d; + + new_cfg[p] = i->second; + } + else + { + if (new_cfg.find (p) == new_cfg.end ()) + offset = 0; + new_cfg[p + offset] = i->second; + } + } } else { Dot_configuration::const_iterator i (end ()); do - { - i--; - - int p = i->first; - if (p == k) - { - if (Staff_symbol_referencer::on_line (i->second.dot_, p)) - p += d; - else - p += 2* d; - - offset = 2*d; - - new_cfg[p] = i->second; - } - else - { - if (new_cfg.find (p) == new_cfg.end ()) - offset = 0; - - new_cfg[p + offset] = i->second; - } - } + { + i--; + + int p = i->first; + if (p == k) + { + if (Staff_symbol_referencer::on_line (i->second.dot_, p)) + p += d; + else + p += 2 * d; + + offset = 2 * d; + + new_cfg[p] = i->second; + } + else + { + if (new_cfg.find (p) == new_cfg.end ()) + offset = 0; + + new_cfg[p + offset] = i->second; + } + } while (i != begin ()); }