freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2-demos] master 5142e07: [ftinspect] Display axes.


From: Werner LEMBERG
Subject: [freetype2-demos] master 5142e07: [ftinspect] Display axes.
Date: Sun, 8 May 2016 18:26:27 +0000 (UTC)

branch: master
commit 5142e079104432ac7fb10a69ab3846e081b7bc66
Author: Werner Lemberg <address@hidden>
Commit: Werner Lemberg <address@hidden>

    [ftinspect] Display axes.
    
    & src/ftinspect.cpp (Grid::Grid): Add second parameter to pass axis
    pen.
    (Grid::paint): Add axes.
    Increase grid size.
    (Grid::boundingRect):Updated.
    (MainGUI::createLayout): Updated.
    
    * src/ftinspect.h: Updated.
---
 ChangeLog         |   13 +++++++++++++
 src/ftinspect.cpp |   32 ++++++++++++++++++++++----------
 src/ftinspect.h   |    6 ++++--
 3 files changed, 39 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 47653db..913876c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
 2016-05-08  Werner Lemberg  <address@hidden>
 
+       [ftinspect] Display axes.
+
+       & src/ftinspect.cpp (Grid::Grid): Add second parameter to pass axis
+       pen.
+       (Grid::paint): Add axes.
+       Increase grid size.
+       (Grid::boundingRect):Updated.
+       (MainGUI::createLayout): Updated.
+
+       * src/ftinspect.h: Updated.
+
+2016-05-08  Werner Lemberg  <address@hidden>
+
        [ftinspect] Display grid.
 
        The dimensions are still arbitrary, though.
diff --git a/src/ftinspect.cpp b/src/ftinspect.cpp
index 91e4d82..2cf8ecf 100644
--- a/src/ftinspect.cpp
+++ b/src/ftinspect.cpp
@@ -446,8 +446,10 @@ Engine::update()
 }
 
 
-Grid::Grid(const QPen& p)
-: pen(p)
+Grid::Grid(const QPen& gridP,
+           const QPen& axisP)
+: gridPen(gridP),
+  axisPen(axisP)
 {
  // empty
 }
@@ -459,11 +461,14 @@ Grid::boundingRect() const
   // XXX fix size
 
   // no need to take care of pen width
-  return QRectF(0, 0,
-                100, 100);
+  return QRectF(-100, -100,
+                200, 200);
 }
 
 
+// XXX call this in a `myQDraphicsView::drawBackground' derived method
+//     to always fill the complete viewport
+
 void
 Grid::paint(QPainter* painter,
             const QStyleOptionGraphicsItem* option,
@@ -472,19 +477,26 @@ Grid::paint(QPainter* painter,
   const qreal lod = option->levelOfDetailFromTransform(
                               painter->worldTransform());
 
-  painter->setPen(pen);
+  painter->setPen(gridPen);
 
   // don't draw grid if magnification is too small
   if (lod >= 5)
   {
     // XXX fix size
-    for (qreal x = 0; x <= 100; x++ )
-      painter->drawLine(x, 0,
+    for (qreal x = -100; x <= 100; x++)
+      painter->drawLine(x, -100,
                         x, 100);
-    for (qreal y = 0; y <= 100; y++)
-      painter->drawLine(0, y,
+    for (qreal y = -100; y <= 100; y++)
+      painter->drawLine(-100, y,
                         100, y);
   }
+
+  painter->setPen(axisPen);
+
+  painter->drawLine(0, -100,
+                    0, 100);
+  painter->drawLine(-100, 0,
+                    100, 0);
 }
 
 
@@ -1234,7 +1246,7 @@ MainGUI::createLayout()
 
   // right side
   glyphScene = new QGraphicsScene;
-  glyphScene->addItem(new Grid(gridPen));
+  glyphScene->addItem(new Grid(gridPen, axisPen));
 
   glyphView = new QGraphicsView;
   glyphView->setRenderHint(QPainter::Antialiasing, true);
diff --git a/src/ftinspect.h b/src/ftinspect.h
index 435aaeb..caae8b8 100644
--- a/src/ftinspect.h
+++ b/src/ftinspect.h
@@ -157,12 +157,14 @@ class Grid
 : public QGraphicsItem
 {
 public:
-  Grid(const QPen&);
+  Grid(const QPen&,
+       const QPen&);
   QRectF boundingRect() const;
   void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*);
 
 private:
-  QPen pen;
+  QPen gridPen;
+  QPen axisPen;
 };
 
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]