X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FChanges.cpp;h=0d464d8fa26912b47e2dd74c78f2e0c70394366c;hb=d3c63f97c4fce4e091277ced6c1829473c311231;hp=616daf029f50aa615d4bba3a5a919d6cbf8fc798;hpb=6d4e6aad24edb7bcfbc49f03d2432fc9fa06954d;p=lyx.git diff --git a/src/Changes.cpp b/src/Changes.cpp index 616daf029f..0d464d8fa2 100644 --- a/src/Changes.cpp +++ b/src/Changes.cpp @@ -19,8 +19,10 @@ #include "BufferParams.h" #include "Encoding.h" #include "LaTeXFeatures.h" +#include "MetricsInfo.h" #include "OutputParams.h" #include "Paragraph.h" +#include "texstream.h" #include "TocBackend.h" #include "support/debug.h" @@ -30,6 +32,8 @@ #include "support/mutex.h" #include "frontends/alert.h" +#include "frontends/FontMetrics.h" +#include "frontends/Painter.h" #include @@ -37,6 +41,9 @@ using namespace std; namespace lyx { +using frontend::Painter; +using frontend::FontMetrics; + /* * Class Change has a changetime field that specifies the exact time at which * a specific change was made. The change time is used as a guidance for the @@ -138,6 +145,8 @@ void Changes::set(Change const & change, pos_type const start, pos_type const en << ", author: " << change.author << ", time: " << long(change.changetime) << ") in range (" << start << ", " << end << ")"); + if (!isChanged()) + is_update_required_ = true; } Range const newRange(start, end); @@ -521,16 +530,14 @@ void Changes::addToToc(DocIterator const & cdit, Buffer const & buffer, Toc::iterator it = TocBackend::findItem(*change_list, 0, author); if (it == change_list->end()) { change_list->push_back(TocItem(dit, 0, author, true)); - change_list->push_back(TocItem(dit, 1, str, output_active, - support::wrapParas(str, 4))); + change_list->push_back(TocItem(dit, 1, str, output_active)); continue; } for (++it; it != change_list->end(); ++it) { if (it->depth() == 0 && it->str() != author) break; } - change_list->insert(it, TocItem(dit, 1, str, output_active, - support::wrapParas(str, 4))); + change_list->insert(it, TocItem(dit, 1, str, output_active)); } } @@ -543,6 +550,49 @@ void Changes::updateBuffer(Buffer const & buf) } +void Change::paintCue(PainterInfo & pi, double const x1, double const y, + double const x2, FontInfo const & font) const +{ + if (!changed()) + return; + // Calculate 1/3 height of font + FontMetrics const & fm = theFontMetrics(font); + double const y_bar = deleted() ? y - fm.maxAscent() / 3 + : y + 2 * pi.base.solidLineOffset() + pi.base.solidLineThickness(); + pi.pain.line(int(x1), int(y_bar), int(x2), int(y_bar), color(), + Painter::line_solid, pi.base.solidLineThickness()); +} + + +void Change::paintCue(PainterInfo & pi, double const x1, double const y1, + double const x2, double const y2) const +{ + /* + * y1 / + * / + * / + * / + * / + * y2 /_____ + * x1 x2 + */ + switch(type) { + case UNCHANGED: + return; + case INSERTED: + pi.pain.line(int(x1), int(y2) + 1, int(x2), int(y2) + 1, + color(), Painter::line_solid, + pi.base.solidLineThickness()); + return; + case DELETED: + // FIXME: we cannot use antialias since we keep drawing on the same + // background with the current painting mechanism. + pi.pain.line(int(x1), int(y2), int(x2), int(y1), + color(), Painter::line_solid_aliased, + pi.base.solidLineThickness()); + return; + } +} } // namespace lyx