[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2-demos] master 52f70d1 2/7: [ftinspect] Disable unavailable it
From: |
Werner LEMBERG |
Subject: |
[freetype2-demos] master 52f70d1 2/7: [ftinspect] Disable unavailable items in anti-aliasing combo box. |
Date: |
Fri, 06 May 2016 14:20:49 +0000 |
branch: master
commit 52f70d13dd385536bb4b94f52f7f3808ee5b13cf
Author: Werner Lemberg <address@hidden>
Commit: Werner Lemberg <address@hidden>
[ftinspect] Disable unavailable items in anti-aliasing combo box.
* src/ftinspect.h (MainGUI): Make `setDefaults' public.
(hintingModesTrueTypeHash, hintingModesCFFHash): New maps.
(hintingModesAlwaysDisabled): New list.
* src/ftinspect.cpp (MainGUI::setDefaults): Set up mappings between
GUI enumerations and FreeType property values.
Use them to create `hintingModesAlwaysDisabled', a list of enum
values that gets fed to the anti-alias combo box's `setItemDisabled'
method.
(MainGUI::MainGUI): Don't call `setDefaults'
here but...
(main): ... here, after FreeType initialization.
---
ChangeLog | 18 ++++++++++++++++++
src/ftinspect.cpp | 39 +++++++++++++++++++++++++++++++++++----
src/ftinspect.h | 10 +++++++++-
3 files changed, 62 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index dcff0e5..3473e1c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2016-05-06 Werner Lemberg <address@hidden>
+
+ [ftinspect] Disable unavailable items in anti-aliasing combo box.
+
+ * src/ftinspect.h (MainGUI): Make `setDefaults' public.
+ (hintingModesTrueTypeHash, hintingModesCFFHash): New maps.
+ (hintingModesAlwaysDisabled): New list.
+
+ * src/ftinspect.cpp (MainGUI::setDefaults): Set up mappings between
+ GUI enumerations and FreeType property values.
+
+ Use them to create `hintingModesAlwaysDisabled', a list of enum
+ values that gets fed to the anti-alias combo box's `setItemDisabled'
+ method.
+ (MainGUI::MainGUI): Don't call `setDefaults'
+ here but...
+ (main): ... here, after FreeType initialization.
+
2016-05-05 Werner Lemberg <address@hidden>
[ftinspect] Handle engine properties.
diff --git a/src/ftinspect.cpp b/src/ftinspect.cpp
index 7ea8b14..3a7e143 100644
--- a/src/ftinspect.cpp
+++ b/src/ftinspect.cpp
@@ -308,7 +308,6 @@ MainGUI::MainGUI()
createMenus();
createStatusBar();
- setDefaults();
readSettings();
setUnifiedTitleAndToolBarOnMac(true);
@@ -1086,13 +1085,44 @@ MainGUI::clearStatusBar()
void
MainGUI::setDefaults()
{
- currentFontIndex = -1;
-
- // XXX only dummy values right now
+ // set up mappings between property values and combo box indices
+ hintingModesTrueTypeHash[TT_INTERPRETER_VERSION_35] =
HintingMode_TrueType_v35;
+ hintingModesTrueTypeHash[TT_INTERPRETER_VERSION_38] =
HintingMode_TrueType_v38;
+ // TT_INTERPRETER_VERSION_40, not yet implemented
+ hintingModesTrueTypeHash[40] = HintingMode_TrueType_v40;
+
+ hintingModesCFFHash[FT_CFF_HINTING_FREETYPE] = HintingMode_CFF_FreeType;
+ hintingModesCFFHash[FT_CFF_HINTING_ADOBE] = HintingMode_CFF_Adobe;
+
+ // make copies and remove existing elements...
+ QHash<int, int> hmTTHash = hintingModesTrueTypeHash;
+ if (hmTTHash.contains(engine->ttInterpreterVersionDefault))
+ hmTTHash.remove(engine->ttInterpreterVersionDefault);
+ if (hmTTHash.contains(engine->ttInterpreterVersionOther))
+ hmTTHash.remove(engine->ttInterpreterVersionOther);
+ if (hmTTHash.contains(engine->ttInterpreterVersionOther1))
+ hmTTHash.remove(engine->ttInterpreterVersionOther1);
+
+ QHash<int, int> hmCFFHash = hintingModesCFFHash;
+ if (hmCFFHash.contains(engine->cffHintingEngineDefault))
+ hmCFFHash.remove(engine->cffHintingEngineDefault);
+ if (hmCFFHash.contains(engine->cffHintingEngineOther))
+ hmCFFHash.remove(engine->cffHintingEngineOther);
+
+ // ... to construct a list of always disabled hinting mode combo box items
+ hintingModesAlwaysDisabled = hmTTHash.values();
+ hintingModesAlwaysDisabled += hmCFFHash.values();
+
+ for (int i = 0; i < hintingModesAlwaysDisabled.size(); i++)
+ hintingModeComboBoxx->setItemEnabled(hintingModesAlwaysDisabled[i],
+ false);
+ currentFontIndex = -1;
currentFaceIndex = -1;
currentInstanceIndex = -1;
+ // XXX only dummy values right now
+
hintingModeComboBoxx->setCurrentIndex(HintingMode_TrueType_v35);
antiAliasingComboBoxx->setCurrentIndex(AntiAliasing_LCD);
lcdFilterComboBox->setCurrentIndex(LCDFilter_Light);
@@ -1196,6 +1226,7 @@ main(int argc,
Engine engine(&gui);
gui.update(&engine);
+ gui.setDefaults();
gui.show();
diff --git a/src/ftinspect.h b/src/ftinspect.h
index 7878cbc..5a06039 100644
--- a/src/ftinspect.h
+++ b/src/ftinspect.h
@@ -22,8 +22,10 @@
#include <QFileDialog>
#include <QGraphicsView>
#include <QGridLayout>
+#include <QHash>
#include <QHBoxLayout>
#include <QLabel>
+#include <QList>
#include <QMainWindow>
#include <QMenu>
#include <QMenuBar>
@@ -144,6 +146,7 @@ public:
MainGUI();
~MainGUI();
+ void setDefaults();
void update(Engine*);
friend class Engine;
@@ -181,6 +184,7 @@ private:
int currentFaceIndex;
int currentInstanceIndex;
+ // layout related stuff
QAction *aboutAct;
QAction *aboutQtAct;
QAction *closeFontAct;
@@ -208,6 +212,9 @@ private:
QGridLayout *fontLayout;
+ QHash<int, int> hintingModesTrueTypeHash;
+ QHash<int, int> hintingModesCFFHash;
+
QHBoxLayout *antiAliasingLayout;
QHBoxLayout *gammaLayout;
QHBoxLayout *hintingModeLayout;
@@ -225,6 +232,8 @@ private:
QLabel *sizeLabel;
QLabel *zoomLabel;
+ QList<int> hintingModesAlwaysDisabled;
+
QLocale *locale;
QMenu *menuFile;
@@ -305,7 +314,6 @@ private:
void clearStatusBar();
void createStatusBar();
void readSettings();
- void setDefaults();
void showFont();
void writeSettings();
};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2-demos] master 52f70d1 2/7: [ftinspect] Disable unavailable items in anti-aliasing combo box.,
Werner LEMBERG <=