freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] gsoc-2022-chariri-3 506f3fa 23/36: [ftinspect] Reflect


From: Werner Lemberg
Subject: [freetype2-demos] gsoc-2022-chariri-3 506f3fa 23/36: [ftinspect] Reflect the conflict of options in the GUI.
Date: Wed, 27 Jul 2022 06:32:46 -0400 (EDT)

branch: gsoc-2022-chariri-3
commit 506f3fa3b9065c16b1d157cde3b416892bb48fde
Author: Charlie Jiang <w@chariri.moe>
Commit: Charlie Jiang <w@chariri.moe>

    [ftinspect] Reflect the conflict of options in the GUI.
    
    In "Continous View", some options conflict with each other. This should be
    reflected in the GUI by graying out the conflicting options.
    
    Because the enabled state of "Vertical" checkbox involves multiple factors,
    check function for mode and source are unified as `checkModeSource`.
    
    * src/ftinspect/panels/continuous.cpp, src/ftinspect/panels/continuous.hpp:
      As described.
---
 src/ftinspect/panels/continuous.cpp | 38 ++++++++++++++++++++++---------------
 src/ftinspect/panels/continuous.hpp |  3 +--
 2 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/src/ftinspect/panels/continuous.cpp 
b/src/ftinspect/panels/continuous.cpp
index 284fcad..49ef47b 100644
--- a/src/ftinspect/panels/continuous.cpp
+++ b/src/ftinspect/panels/continuous.cpp
@@ -17,8 +17,7 @@ ContinuousTab::ContinuousTab(QWidget* parent,
   std::vector<CharMapInfo> tempCharMaps;
   setCharMaps(tempCharMaps); // pass in an empty one
 
-  checkMode();
-  checkSource();
+  checkModeSource();
   setDefaults();
 
   createConnections();
@@ -174,7 +173,7 @@ ContinuousTab::updateLimitIndex()
 
 
 void
-ContinuousTab::checkMode()
+ContinuousTab::checkModeSource()
 {
   auto isFancy = modeSelector_->currentIndex() == GlyphContinuous::M_Fancy;
   auto isStroked = modeSelector_->currentIndex() == GlyphContinuous::M_Stroked;
@@ -183,23 +182,32 @@ ContinuousTab::checkMode()
   slantSpinBox_->setEnabled(isFancy);
   strokeRadiusSpinBox_->setEnabled(isStroked);
 
-  repaintGlyph();
-}
-
-
-void
-ContinuousTab::checkSource()
-{
   auto src
       = static_cast<GlyphContinuous::Source>(sourceSelector_->currentIndex());
+  auto isTextStrict = src == GlyphContinuous::SRC_TextString;
   auto isText = src == GlyphContinuous::SRC_TextString
                 || src == GlyphContinuous::SRC_TextStringRepeated;
   indexSelector_->setEnabled(src == GlyphContinuous::SRC_AllGlyphs);
   sourceTextEdit_->setEnabled(isText);
-  verticalCheckBox_->setEnabled(isText);
   positionSlider_->setEnabled(isText);
   canvas_->setSource(src);
 
+  {
+    auto wf = waterfallCheckBox_->isChecked();
+    QSignalBlocker blocker(verticalCheckBox_);
+    if (wf || !isTextStrict)
+      verticalCheckBox_->setChecked(false);
+    verticalCheckBox_->setEnabled(!wf && isTextStrict);
+  }
+
+  {
+    auto vert = verticalCheckBox_->isChecked();
+    QSignalBlocker blocker(waterfallCheckBox_);
+    if (vert)
+      waterfallCheckBox_->setChecked(false);
+    waterfallCheckBox_->setEnabled(!vert);
+  }
+
   repaintGlyph();
 }
 
@@ -390,11 +398,11 @@ ContinuousTab::createConnections()
   connect(indexSelector_, &GlyphIndexSelector::currentIndexChanged,
           this, &ContinuousTab::repaintGlyph);
   connect(modeSelector_, QOverload<int>::of(&QComboBox::currentIndexChanged),
-          this, &ContinuousTab::checkMode);
+          this, &ContinuousTab::checkModeSource);
   connect(charMapSelector_, 
QOverload<int>::of(&QComboBox::currentIndexChanged),
           this, &ContinuousTab::charMapChanged);
   connect(sourceSelector_, QOverload<int>::of(&QComboBox::currentIndexChanged),
-          this, &ContinuousTab::checkSource);
+          this, &ContinuousTab::checkModeSource);
 
   connect(xEmboldeningSpinBox_, 
           QOverload<double>::of(&QDoubleSpinBox::valueChanged),
@@ -413,9 +421,9 @@ ContinuousTab::createConnections()
           this, &ContinuousTab::repaintGlyph);
 
   connect(waterfallCheckBox_, &QCheckBox::clicked,
-          this, &ContinuousTab::repaintGlyph);
+          this, &ContinuousTab::checkModeSource);
   connect(verticalCheckBox_, &QCheckBox::clicked,
-          this, &ContinuousTab::repaintGlyph);
+          this, &ContinuousTab::checkModeSource);
   connect(kerningCheckBox_, &QCheckBox::clicked,
           this, &ContinuousTab::reloadGlyphsAndRepaint);
   connect(sourceTextEdit_, &QPlainTextEdit::textChanged,
diff --git a/src/ftinspect/panels/continuous.hpp 
b/src/ftinspect/panels/continuous.hpp
index b76141d..85a154b 100644
--- a/src/ftinspect/panels/continuous.hpp
+++ b/src/ftinspect/panels/continuous.hpp
@@ -44,8 +44,7 @@ public:
   void setCharMaps(std::vector<CharMapInfo>& charMaps);
   // This doesn't trigger either.
   void updateLimitIndex();
-  void checkMode();
-  void checkSource();
+  void checkModeSource();
   void charMapChanged();
   void sourceTextChanged();
   void reloadGlyphsAndRepaint();



reply via email to

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