freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] master dc2df0f: [ftinspect] Make `previous font' and `


From: Werner LEMBERG
Subject: [freetype2-demos] master dc2df0f: [ftinspect] Make `previous font' and `next font' button logic work.
Date: Tue, 03 May 2016 21:19:46 +0000

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

    [ftinspect] Make `previous font' and `next font' button logic work.
    
    * src/ftinspect.h (MainGUI): New slots `checkCurrentFontFileIndex',
    `previousFont, and `nextFont'.
    
    * src/ftinspect.cpp
    (MainGUI::checkCurrentFontFileIndex, MainGUI::previousFont,
    MainGUI::nextFont): New methods.
    (MainGUI::createConnections): Register connections for
    `previousFontButton' and `nextFontButton'.
    (MainGUI::loadFonts, MainGUI::closeFont, MainGUI::setDefaults):
    Updated.
---
 ChangeLog         |   15 ++++++++++++++
 src/ftinspect.cpp |   60 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/ftinspect.h   |    3 +++
 3 files changed, 78 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index cbfe334..dfba077 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
 2016-05-03  Werner Lemberg  <address@hidden>
 
+       [ftinspect] Make `previous font' and `next font' button logic work.
+
+       * src/ftinspect.h (MainGUI): New slots `checkCurrentFontFileIndex',
+       `previousFont, and `nextFont'.
+
+       * src/ftinspect.cpp
+       (MainGUI::checkCurrentFontFileIndex, MainGUI::previousFont,
+       MainGUI::nextFont): New methods.
+       (MainGUI::createConnections): Register connections for
+       `previousFontButton' and `nextFontButton'.
+       (MainGUI::loadFonts, MainGUI::closeFont, MainGUI::setDefaults):
+       Updated.
+
+2016-05-03  Werner Lemberg  <address@hidden>
+
        [ftinspect] Add file dialogs.
 
        * src/ftinspect.h: Include some more Qt headers.
diff --git a/src/ftinspect.cpp b/src/ftinspect.cpp
index ef1d2c7..f9c3370 100644
--- a/src/ftinspect.cpp
+++ b/src/ftinspect.cpp
@@ -163,6 +163,10 @@ MainGUI::loadFonts()
 
   if (!fontFileNames.isEmpty() && currentFontFileIndex == -1)
     currentFontFileIndex = 0;
+
+  checkCurrentFontFileIndex();
+
+  // XXX trigger redisplay
 }
 
 
@@ -174,6 +178,8 @@ MainGUI::closeFont()
   if (currentFontFileIndex >= fontFileNames.size())
     currentFontFileIndex--;
 
+  checkCurrentFontFileIndex();
+
   // XXX trigger redisplay
 }
 
@@ -258,6 +264,54 @@ MainGUI::checkUnits()
 }
 
 
+void
+MainGUI::checkCurrentFontFileIndex()
+{
+  if (currentFontFileIndex == -1)
+  {
+    previousFontButton->setEnabled(false);
+    nextFontButton->setEnabled(false);
+  }
+  else if (currentFontFileIndex == 0)
+  {
+    previousFontButton->setEnabled(false);
+    nextFontButton->setEnabled(true);
+  }
+  else if (currentFontFileIndex == fontFileNames.size() - 1)
+  {
+    previousFontButton->setEnabled(true);
+    nextFontButton->setEnabled(false);
+  }
+  else
+  {
+    previousFontButton->setEnabled(true);
+    nextFontButton->setEnabled(true);
+  }
+}
+
+
+void
+MainGUI::previousFont()
+{
+  if (currentFontFileIndex > 0)
+  {
+    currentFontFileIndex--;
+    checkCurrentFontFileIndex();
+  }
+}
+
+
+void
+MainGUI::nextFont()
+{
+  if (currentFontFileIndex < fontFileNames.size() - 1)
+  {
+    currentFontFileIndex++;
+    checkCurrentFontFileIndex();
+  }
+}
+
+
 // XXX distances are specified in pixels,
 //     making the layout dependent on the output device resolution
 void
@@ -541,6 +595,11 @@ MainGUI::createConnections()
 
   connect(unitsComboBox, SIGNAL(currentIndexChanged(int)), this,
           SLOT(checkUnits()));
+
+  connect(previousFontButton, SIGNAL(clicked()), this,
+          SLOT(previousFont()));
+  connect(nextFontButton, SIGNAL(clicked()), this,
+          SLOT(nextFont()));
 }
 
 
@@ -618,6 +677,7 @@ MainGUI::setDefaults()
   checkAntiAliasing();
   checkShowPoints();
   checkUnits();
+  checkCurrentFontFileIndex();
 }
 
 
diff --git a/src/ftinspect.h b/src/ftinspect.h
index c96b476..5bd2ebb 100644
--- a/src/ftinspect.h
+++ b/src/ftinspect.h
@@ -112,11 +112,14 @@ protected:
 private slots:
   void about();
   void checkAntiAliasing();
+  void checkCurrentFontFileIndex();
   void checkHintingMode();
   void checkShowPoints();
   void checkUnits();
   void closeFont();
   void loadFonts();
+  void nextFont();
+  void previousFont();
 
 private:
   QStringList fontFileNames;



reply via email to

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