freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] master 6f8c1cb 1/2: [ftinspect] Add DPI control.


From: Werner LEMBERG
Subject: [freetype2-demos] master 6f8c1cb 1/2: [ftinspect] Add DPI control.
Date: Mon, 02 May 2016 10:26:59 +0000

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

    [ftinspect] Add DPI control.
    
    * src/ftinspect.cpp: Add `unitsComboBox' to select between px and
    pt.
    Add `dpiLabel' and `dpiSpinBox' to select the DPI value.
    (MainGUI::checkUnits): New function.
    (MainGUI::createConnections, MainGUI::setDefaults): Updated.
    
    * src/ftinspect.h: Updated.
---
 ChangeLog         |   12 ++++++++++++
 src/ftinspect.cpp |   39 ++++++++++++++++++++++++++++++++++++++-
 src/ftinspect.h   |    9 +++++++++
 3 files changed, 59 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 008f0ef..acf51f6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2016-05-01  Werner Lemberg  <address@hidden>
 
+       [ftinspect] Add DPI control.
+
+       * src/ftinspect.cpp: Add `unitsComboBox' to select between px and
+       pt.
+       Add `dpiLabel' and `dpiSpinBox' to select the DPI value.
+       (MainGUI::checkUnits): New function.
+       (MainGUI::createConnections, MainGUI::setDefaults): Updated.
+
+       * src/ftinspect.h: Updated.
+
+2016-05-01  Werner Lemberg  <address@hidden>
+
        [ftinspect] Some more GUI initialization defaults.
 
        * src/ftinspect.cpp (MainGUI::setDefaults): Updated.
diff --git a/src/ftinspect.cpp b/src/ftinspect.cpp
index 04a8473..1ded29b 100644
--- a/src/ftinspect.cpp
+++ b/src/ftinspect.cpp
@@ -135,6 +135,24 @@ MainGUI::checkShowPoints()
 }
 
 
+void
+MainGUI::checkUnits()
+{
+  int index = unitsComboBox->currentIndex();
+
+  if (index == Units_px)
+  {
+    dpiLabel->setEnabled(false);
+    dpiSpinBox->setEnabled(false);
+  }
+  else
+  {
+    dpiLabel->setEnabled(true);
+    dpiSpinBox->setEnabled(true);
+  }
+}
+
+
 // XXX distances are specified in pixels,
 //     making the layout dependent on the output device resolution
 void
@@ -301,11 +319,22 @@ MainGUI::createLayout()
   sizeDoubleSpinBox->setAlignment(Qt::AlignRight);
   sizeDoubleSpinBox->setDecimals(1);
   sizeDoubleSpinBox->setRange(1, 500);
-  sizeDoubleSpinBox->setSuffix("px");
   sizeDoubleSpinBox->setSingleStep(0.5);
   sizeDoubleSpinBox->setValue(20); // XXX default
   sizeLabel->setBuddy(sizeDoubleSpinBox);
 
+  unitsComboBox = new QComboBox;
+  unitsComboBox->insertItem(Units_px, "px");
+  unitsComboBox->insertItem(Units_pt, "pt");
+
+  dpiLabel = new QLabel(tr("DPI "));
+  dpiLabel->setAlignment(Qt::AlignRight);
+  dpiSpinBox = new QSpinBox;
+  dpiSpinBox->setAlignment(Qt::AlignRight);
+  dpiSpinBox->setRange(10, 600);
+  dpiSpinBox->setValue(96); // XXX default
+  dpiLabel->setBuddy(dpiSpinBox);
+
   toStartButton = new QPushButton("|<");
   toStartButton->setFixedWidth(40);
   toM1000Button = new QPushButton("-1000");
@@ -344,6 +373,10 @@ MainGUI::createLayout()
   navigationLayout->setSpacing(0);
   navigationLayout->addWidget(sizeLabel);
   navigationLayout->addWidget(sizeDoubleSpinBox);
+  navigationLayout->addWidget(unitsComboBox);
+  navigationLayout->addSpacing(10); // XXX px
+  navigationLayout->addWidget(dpiLabel);
+  navigationLayout->addWidget(dpiSpinBox);
   navigationLayout->addSpacing(10); // XXX px
   navigationLayout->addStretch(1);
   navigationLayout->addWidget(toStartButton);
@@ -400,6 +433,9 @@ MainGUI::createConnections()
 
   connect(showPointsCheckBox, SIGNAL(clicked()), this,
           SLOT(checkShowPoints()));
+
+  connect(unitsComboBox, SIGNAL(currentIndexChanged(int)), this,
+          SLOT(checkUnits()));
 }
 
 
@@ -464,6 +500,7 @@ MainGUI::setDefaults()
   checkHintingMode();
   checkAntiAliasing();
   checkShowPoints();
+  checkUnits();
 }
 
 
diff --git a/src/ftinspect.h b/src/ftinspect.h
index 9dd2394..7110386 100644
--- a/src/ftinspect.h
+++ b/src/ftinspect.h
@@ -49,6 +49,7 @@ private slots:
   void checkAntiAliasing();
   void checkHintingMode();
   void checkShowPoints();
+  void checkUnits();
 
 private:
   QAction *aboutAct;
@@ -68,6 +69,7 @@ private:
   QComboBox *antiAliasingComboBox;
   QComboBox *hintingModeComboBox;
   QComboBox *lcdFilterComboBox;
+  QComboBox *unitsComboBox;
 
   QDoubleSpinBox *sizeDoubleSpinBox;
 
@@ -83,6 +85,7 @@ private:
   QHBoxLayout *watchLayout;
 
   QLabel *antiAliasingLabel;
+  QLabel *dpiLabel;
   QLabel *gammaLabel;
   QLabel *hintingModeLabel;
   QLabel *lcdFilterLabel;
@@ -110,6 +113,7 @@ private:
 
   QSlider *gammaSlider;
 
+  QSpinBox *dpiSpinBox;
   QSpinBox *zoomSpinBox;
 
   QTabWidget *tabWidget;
@@ -150,6 +154,11 @@ private:
     LCDFilter_None,
     LCDFilter_Legacy
   };
+  enum Units
+  {
+    Units_px,
+    Units_pt
+  };
 
   void createActions();
   void createConnections();



reply via email to

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