]> git.lyx.org Git - lyx.git/blobdiff - src/Changes.cpp
Painter: Add a line style to disable antialiasing
[lyx.git] / src / Changes.cpp
index 877c3f104281fec2c8cee5b3f4b31b10e67be6a6..e9191e37d80210958a8fa909e4fe31f0460b85f0 100644 (file)
@@ -19,6 +19,7 @@
 #include "BufferParams.h"
 #include "Encoding.h"
 #include "LaTeXFeatures.h"
+#include "MetricsInfo.h"
 #include "OutputParams.h"
 #include "Paragraph.h"
 #include "TocBackend.h"
@@ -30,6 +31,8 @@
 #include "support/mutex.h"
 
 #include "frontends/alert.h"
+#include "frontends/FontMetrics.h"
+#include "frontends/Painter.h"
 
 #include <ostream>
 
@@ -37,6 +40,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
@@ -523,16 +529,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));
        }
 }
 
@@ -545,6 +549,48 @@ 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
+        */
+       double y = 0;
+       switch(type) {
+       case UNCHANGED:
+               return;
+       case INSERTED:
+               y = y2;
+               break;
+       case DELETED:
+               y = y1;
+               break;
+       }
+       // we cannot use antialias since we keep drawing on the same background
+       pi.pain.line(int(x1), int(y2), int(x2), int(y),
+                    color(), Painter::line_solid_aliased,
+                    pi.base.solidLineThickness());
+}
 
 
 } // namespace lyx