freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] master b952aa1 5/5: [ftinspect] Add buttons for instan


From: Werner LEMBERG
Subject: [freetype2-demos] master b952aa1 5/5: [ftinspect] Add buttons for instances.
Date: Wed, 04 May 2016 19:33:05 +0000

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

    [ftinspect] Add buttons for instances.
    
    * src/ftinspect.cpp (MainGUI::checkCurrentInstanceIndex,
    MainGUI::previousInstance, MainGUI::nextInstance): New methods.
    (MainGUI::createLayout): Updated.  We now use a grid layout for the
    font buttons.
    (MainGUI::createConnections, MainGUI::setDefaults): Updated.
    
    * src/ftinspect.h: Updated.
---
 ChangeLog         |   12 +++++++
 src/ftinspect.cpp |   93 +++++++++++++++++++++++++++++++++++++++++++++++------
 src/ftinspect.h   |    9 +++++-
 3 files changed, 103 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d0d202c..30d3011 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2016-05-04  Werner Lemberg  <address@hidden>
 
+       [ftinspect] Add buttons for instances.
+
+       * src/ftinspect.cpp (MainGUI::checkCurrentInstanceIndex,
+       MainGUI::previousInstance, MainGUI::nextInstance): New methods.
+       (MainGUI::createLayout): Updated.  We now use a grid layout for the
+       font buttons.
+       (MainGUI::createConnections, MainGUI::setDefaults): Updated.
+
+       * src/ftinspect.h: Updated.
+
+2016-05-04  Werner Lemberg  <address@hidden>
+
        [ftinspect] Redesign font handling.
 
        At this early stage, it's not always clear to me how to do things
diff --git a/src/ftinspect.cpp b/src/ftinspect.cpp
index 4a2c0a0..90f252d 100644
--- a/src/ftinspect.cpp
+++ b/src/ftinspect.cpp
@@ -357,6 +357,45 @@ MainGUI::checkCurrentFaceIndex()
 
 
 void
+MainGUI::checkCurrentInstanceIndex()
+{
+  int numInstances;
+
+  if (currentFontIndex < 0)
+    numInstances = 0;
+  else
+  {
+    if (currentFaceIndex < 0)
+      numInstances = 0;
+    else
+      numInstances = fonts[currentFontIndex].
+                       numInstancesList[currentFaceIndex];
+  }
+
+  if (numInstances < 2)
+  {
+    previousInstanceButton->setEnabled(false);
+    nextInstanceButton->setEnabled(false);
+  }
+  else if (currentInstanceIndex == 0)
+  {
+    previousInstanceButton->setEnabled(false);
+    nextInstanceButton->setEnabled(true);
+  }
+  else if (currentInstanceIndex == numInstances - 1)
+  {
+    previousInstanceButton->setEnabled(true);
+    nextInstanceButton->setEnabled(false);
+  }
+  else
+  {
+    previousInstanceButton->setEnabled(true);
+    nextInstanceButton->setEnabled(true);
+  }
+}
+
+
+void
 MainGUI::previousFont()
 {
   if (currentFontIndex > 0)
@@ -393,6 +432,7 @@ void
 MainGUI::nextFace()
 {
   int numFaces = fonts[currentFontIndex].numInstancesList.size();
+
   if (currentFaceIndex < numFaces - 1)
   {
     currentFaceIndex++;
@@ -401,6 +441,31 @@ MainGUI::nextFace()
 }
 
 
+void
+MainGUI::previousInstance()
+{
+  if (currentInstanceIndex > 0)
+  {
+    currentInstanceIndex--;
+    checkCurrentInstanceIndex();
+  }
+}
+
+
+void
+MainGUI::nextInstance()
+{
+  int numInstances = fonts[currentFontIndex].
+                       numInstancesList[currentFaceIndex];
+
+  if (currentInstanceIndex < numInstances - 1)
+  {
+    currentInstanceIndex++;
+    checkCurrentInstanceIndex();
+  }
+}
+
+
 // XXX distances are specified in pixels,
 //     making the layout dependent on the output device resolution
 void
@@ -608,6 +673,8 @@ MainGUI::createLayout()
   nextFontButton = new QPushButton(tr("Next Font"));
   previousFaceButton = new QPushButton(tr("Previous Face"));
   nextFaceButton = new QPushButton(tr("Next Face"));
+  previousInstanceButton = new QPushButton(tr("Previous Instance"));
+  nextInstanceButton = new QPushButton(tr("Next Instance"));
 
   navigationLayout = new QHBoxLayout;
   navigationLayout->setSpacing(0);
@@ -637,16 +704,17 @@ MainGUI::createLayout()
   sizeLayout->addWidget(zoomSpinBox);
   sizeLayout->addStretch(2);
 
-  fontLayout = new QHBoxLayout;
-  fontLayout->addStretch(2);
-  fontLayout->addWidget(previousFontButton);
-  fontLayout->addStretch(1);
-  fontLayout->addWidget(nextFontButton);
-  fontLayout->addStretch(1);
-  fontLayout->addWidget(previousFaceButton);
-  fontLayout->addStretch(1);
-  fontLayout->addWidget(nextFaceButton);
-  fontLayout->addStretch(2);
+  fontLayout = new QGridLayout;
+  fontLayout->setColumnStretch(0, 2);
+  fontLayout->addWidget(nextFontButton, 0, 1);
+  fontLayout->addWidget(previousFontButton, 1, 1);
+  fontLayout->setColumnStretch(2, 1);
+  fontLayout->addWidget(nextFaceButton, 0, 3);
+  fontLayout->addWidget(previousFaceButton, 1, 3);
+  fontLayout->setColumnStretch(4, 1);
+  fontLayout->addWidget(nextInstanceButton, 0, 5);
+  fontLayout->addWidget(previousInstanceButton, 1, 5);
+  fontLayout->setColumnStretch(6, 2);
 
   rightLayout = new QVBoxLayout;
   rightLayout->addWidget(glyphView);
@@ -694,6 +762,10 @@ MainGUI::createConnections()
           SLOT(previousFace()));
   connect(nextFaceButton, SIGNAL(clicked()), this,
           SLOT(nextFace()));
+  connect(previousInstanceButton, SIGNAL(clicked()), this,
+          SLOT(previousInstance()));
+  connect(nextInstanceButton, SIGNAL(clicked()), this,
+          SLOT(nextInstance()));
 }
 
 
@@ -776,6 +848,7 @@ MainGUI::setDefaults()
   checkUnits();
   checkCurrentFontIndex();
   checkCurrentFaceIndex();
+  checkCurrentInstanceIndex();
 }
 
 
diff --git a/src/ftinspect.h b/src/ftinspect.h
index 0aecdd5..4e4ebed 100644
--- a/src/ftinspect.h
+++ b/src/ftinspect.h
@@ -18,6 +18,7 @@
 #include <QDoubleSpinBox>
 #include <QFileDialog>
 #include <QGraphicsView>
+#include <QGridLayout>
 #include <QHBoxLayout>
 #include <QLabel>
 #include <QMainWindow>
@@ -143,6 +144,7 @@ private slots:
   void checkAntiAliasing();
   void checkCurrentFaceIndex();
   void checkCurrentFontIndex();
+  void checkCurrentInstanceIndex();
   void checkHintingMode();
   void checkShowPoints();
   void checkUnits();
@@ -150,8 +152,10 @@ private slots:
   void loadFonts();
   void nextFace();
   void nextFont();
+  void nextInstance();
   void previousFace();
   void previousFont();
+  void previousInstance();
 
 private:
   const Engine* engine;
@@ -186,8 +190,9 @@ private:
 
   QGraphicsView *glyphView;
 
+  QGridLayout *fontLayout;
+
   QHBoxLayout *antiAliasingLayout;
-  QHBoxLayout *fontLayout;
   QHBoxLayout *gammaLayout;
   QHBoxLayout *hintingModeLayout;
   QHBoxLayout *ftinspectLayout;
@@ -211,8 +216,10 @@ private:
 
   QPushButton *nextFaceButton;
   QPushButton *nextFontButton;
+  QPushButton *nextInstanceButton;
   QPushButton *previousFaceButton;
   QPushButton *previousFontButton;
+  QPushButton *previousInstanceButton;
   QPushButton *watchButton;
 
   QPushButtonx *toEndButtonx;



reply via email to

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