freetype-commit
[Top][All Lists]
Advanced

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

[freetype2-demos] gsoc-2022-chariri-3 7b4fb4f 12/36: [ftinspect] Rewrite


From: Werner Lemberg
Subject: [freetype2-demos] gsoc-2022-chariri-3 7b4fb4f 12/36: [ftinspect] Rewrite the GUI layout of "Continuous View"
Date: Wed, 27 Jul 2022 06:32:44 -0400 (EDT)

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

    [ftinspect] Rewrite the GUI layout of "Continuous View"
    
    We no longer use sub-tabs to switch between "All Glyphs", "Text String" or
    other modes, and use a combo box instead. This makes the two major options
    clear:
    
    - Render Mode: Normal, Fancy, Stroked etc...
    - Text Source: All Glyphs, Text String etc...
    
    Move most code in the original "All Glyphs" sub-tab to `ContinuousTab`, and
    add other options. However, they're not implemented yet.
    
    * src/ftinspect/panels/continuous.hpp, src/ftinspect/panels/continuous.cpp:
      As described.
    
    * src/ftinspect/rendering/glyphcontinuous.cpp,
      src/ftinspect/rendering/glyphcontinuous.hpp:
      Add new options as properties. Rename "Mode" to "Source", "SubMode" to
      "Mode".
---
 src/ftinspect/panels/continuous.cpp         | 446 +++++++++++++---------------
 src/ftinspect/panels/continuous.hpp         |  91 ++----
 src/ftinspect/rendering/glyphcontinuous.cpp |  24 +-
 src/ftinspect/rendering/glyphcontinuous.hpp |  35 ++-
 4 files changed, 265 insertions(+), 331 deletions(-)

diff --git a/src/ftinspect/panels/continuous.cpp 
b/src/ftinspect/panels/continuous.cpp
index c78a825..ebb7ceb 100644
--- a/src/ftinspect/panels/continuous.cpp
+++ b/src/ftinspect/panels/continuous.cpp
@@ -13,6 +13,14 @@ ContinuousTab::ContinuousTab(QWidget* parent,
 : QWidget(parent), engine_(engine)
 {
   createLayout();
+
+  std::vector<CharMapInfo> tempCharMaps;
+  setCharMaps(tempCharMaps); // pass in an empty one
+
+  checkMode();
+  checkSource();
+  setDefaults();
+
   createConnections();
 }
 
@@ -22,7 +30,7 @@ ContinuousTab::repaintGlyph()
 {
   sizeSelector_->applyToEngine(engine_);
   
-  updateFromCurrentSubTab();
+  syncSettings();
   canvas_->repaint();
 }
 
@@ -31,181 +39,35 @@ void
 ContinuousTab::reloadFont()
 {
   currentGlyphCount_ = engine_->currentFontNumberOfGlyphs();
-  updateCurrentSubTab();
+  setGlyphCount(qBound(0, currentGlyphCount_, INT_MAX));
+  setCharMaps(engine_->currentFontCharMaps());
   repaintGlyph();
 }
 
 
 void
-ContinuousTab::changeTab()
-{
-  updateCurrentSubTab();
-  repaintGlyph();
-}
-
-
-void
-ContinuousTab::wheelNavigate(int steps)
-{
-  if (tabWidget_->currentIndex() == AllGlyphs)
-    allGlyphsTab_->setGlyphBeginindex(allGlyphsTab_->glyphBeginindex()
-                                      + steps);
-}
-
-
-void
-ContinuousTab::wheelResize(int steps)
-{
-  sizeSelector_->handleWheelResizeBySteps(steps);
-}
-
-
-void
-ContinuousTab::createLayout()
-{
-  canvas_ = new GlyphContinuous(this, engine_);
-  sizeSelector_ = new FontSizeSelector(this);
-  allGlyphsTab_ = new ContinousAllGlyphsTab(this);
-
-  tabWidget_ = new QTabWidget(this);
-  tabWidget_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
-  // Must be in sync with `Tabs` enum.
-  tabWidget_->addTab(allGlyphsTab_, tr("All Glyphs"));
-
-  mainLayout_ = new QVBoxLayout;
-  mainLayout_->addWidget(canvas_);
-  mainLayout_->addWidget(sizeSelector_);
-  mainLayout_->addWidget(tabWidget_);
-
-  setLayout(mainLayout_);
-}
-
-
-void
-ContinuousTab::createConnections()
-{
-  connect(tabWidget_, &QTabWidget::currentChanged,
-          this, &ContinuousTab::changeTab);
-
-  connect(allGlyphsTab_, &ContinousAllGlyphsTab::changed, 
-          this, &ContinuousTab::repaintGlyph);
-
-  connect(sizeSelector_, &FontSizeSelector::valueChanged,
-          this, &ContinuousTab::repaintGlyph);
-
-  connect(canvas_, &GlyphContinuous::wheelResize, 
-          this, &ContinuousTab::wheelResize);
-  connect(canvas_, &GlyphContinuous::wheelNavigate, 
-          this, &ContinuousTab::wheelNavigate);
-  connect(canvas_, &GlyphContinuous::displayingCountUpdated, 
-          allGlyphsTab_, &ContinousAllGlyphsTab::setDisplayingCount);
-}
-
-
-void
-ContinuousTab::updateCurrentSubTab()
+ContinuousTab::syncSettings()
 {
-  switch (tabWidget_->currentIndex())
-  {
-  case AllGlyphs:
-    allGlyphsTab_->setGlyphCount(qBound(0, 
-                                        currentGlyphCount_,
-                                        INT_MAX));
-    allGlyphsTab_->setCharMaps(engine_->currentFontCharMaps());
-    break;
-  }
-}
-
-
-void
-ContinuousTab::updateFromCurrentSubTab()
-{
-  switch (tabWidget_->currentIndex())
-  {
-  case AllGlyphs:
-    canvas_->setMode(GlyphContinuous::AllGlyphs);
-    canvas_->setSubModeAllGlyphs(allGlyphsTab_->subMode());
-    // Begin index is selected from All Glyphs subtab,
-    // and Limit index is calculated by All Glyphs subtab
-    canvas_->setBeginIndex(allGlyphsTab_->glyphBeginindex());
-    canvas_->setLimitIndex(allGlyphsTab_->glyphLimitIndex());
-    canvas_->setCharMapIndex(allGlyphsTab_->charMapIndex());
-
-    canvas_->setFancyParams(allGlyphsTab_->xEmboldening(),
-                            allGlyphsTab_->yEmboldening(),
-                            allGlyphsTab_->slanting());
-    canvas_->setStrokeRadius(allGlyphsTab_->strokeRadius());
-    break;
-  }
-}
-
-
-ContinousAllGlyphsTab::ContinousAllGlyphsTab(QWidget* parent)
-: QWidget(parent)
-{
-  createLayout();
-
-  std::vector<CharMapInfo> tempCharMaps;
-  setCharMaps(tempCharMaps); // pass in an empty one
-
-  checkSubMode();
-  setDefaults();
-  createConnections();
-}
-
-
-int
-ContinousAllGlyphsTab::glyphBeginindex()
-{
-  return indexSelector_->currentIndex();
+  auto mode = 
static_cast<GlyphContinuous::Mode>(modeSelector_->currentIndex());
+  auto src
+    = static_cast<GlyphContinuous::Source>(sourceSelector_->currentIndex());
+  canvas_->setMode(mode);
+  canvas_->setSource(src);
+  canvas_->setBeginIndex(indexSelector_->currentIndex());
+  canvas_->setLimitIndex(glyphLimitIndex_);
+  canvas_->setCharMapIndex(charMapIndex()); // Not directly from the combo box
+
+  canvas_->setFancyParams(xEmboldeningSpinBox_->value(),
+                          yEmboldeningSpinBox_->value(),
+                          slantSpinBox_->value());
+  canvas_->setStrokeRadius(strokeRadiusSpinBox_->value());
+  canvas_->setRotation(rotationSpinBox_->value());
+  canvas_->setVertical(verticalCheckBox_->isChecked());
 }
 
 
 int
-ContinousAllGlyphsTab::glyphLimitIndex()
-{
-  return glyphLimitIndex_;
-}
-
-
-GlyphContinuous::SubModeAllGlyphs
-ContinousAllGlyphsTab::subMode()
-{
-  return static_cast<GlyphContinuous::SubModeAllGlyphs>(
-           modeSelector_->currentIndex());
-}
-
-
-double
-ContinousAllGlyphsTab::xEmboldening()
-{
-  return xEmboldeningSpinBox_->value();
-}
-
-
-double
-ContinousAllGlyphsTab::yEmboldening()
-{
-  return yEmboldeningSpinBox_->value();
-}
-
-
-double
-ContinousAllGlyphsTab::slanting()
-{
-  return slantSpinBox_->value();
-}
-
-
-double
-ContinousAllGlyphsTab::strokeRadius()
-{
-  return strokeRadiusSpinBox_->value();
-}
-
-
-int
-ContinousAllGlyphsTab::charMapIndex()
+ContinuousTab::charMapIndex()
 {
   auto index = charMapSelector_->currentIndex() - 1;
   if (index <= -1)
@@ -217,30 +79,30 @@ ContinousAllGlyphsTab::charMapIndex()
 
 
 void
-ContinousAllGlyphsTab::setGlyphBeginindex(int index)
+ContinuousTab::setGlyphCount(int count)
 {
-  indexSelector_->setCurrentIndex(index);
+  currentGlyphCount_ = count;
+  updateLimitIndex();
 }
 
 
 void
-ContinousAllGlyphsTab::setGlyphCount(int count)
+ContinuousTab::setDisplayingCount(int count)
 {
-  currentGlyphCount_ = count;
-  updateLimitIndex();
+  indexSelector_->setShowingCount(count);
 }
 
 
 void
-ContinousAllGlyphsTab::setDisplayingCount(int count)
+ContinuousTab::setGlyphBeginindex(int index)
 {
-  indexSelector_->setShowingCount(count);
+  indexSelector_->setCurrentIndex(index);
 }
 
 
 #define EncodingRole (Qt::UserRole + 10)
 void
-ContinousAllGlyphsTab::setCharMaps(std::vector<CharMapInfo>& charMaps)
+ContinuousTab::setCharMaps(std::vector<CharMapInfo>& charMaps)
 {
   charMaps_ = charMaps;
   int oldIndex = charMapSelector_->currentIndex();
@@ -287,7 +149,7 @@ 
ContinousAllGlyphsTab::setCharMaps(std::vector<CharMapInfo>& charMaps)
 
 
 void
-ContinousAllGlyphsTab::updateLimitIndex()
+ContinuousTab::updateLimitIndex()
 {
   if (charMapSelector_->currentIndex() <= 0)
     glyphLimitIndex_ = currentGlyphCount_;
@@ -299,49 +161,128 @@ ContinousAllGlyphsTab::updateLimitIndex()
 
 
 void
-ContinousAllGlyphsTab::checkSubMode()
+ContinuousTab::checkMode()
 {
-  auto isFancy = subMode() == GlyphContinuous::AG_Fancy;
-  auto isStroked = subMode() == GlyphContinuous::AG_Stroked;
+  auto isFancy = modeSelector_->currentIndex() == GlyphContinuous::M_Fancy;
+  auto isStroked = modeSelector_->currentIndex() == GlyphContinuous::M_Stroked;
   xEmboldeningSpinBox_->setEnabled(isFancy);
   yEmboldeningSpinBox_->setEnabled(isFancy);
   slantSpinBox_->setEnabled(isFancy);
   strokeRadiusSpinBox_->setEnabled(isStroked);
 
-  emit changed();
+  repaintGlyph();
 }
 
 
 void
-ContinousAllGlyphsTab::createLayout()
+ContinuousTab::checkSource()
 {
+  auto src
+      = static_cast<GlyphContinuous::Source>(sourceSelector_->currentIndex());
+  auto isText = src == GlyphContinuous::SRC_TextString
+                || src == GlyphContinuous::SRC_TextStringRepeated;
+  indexSelector_->setEnabled(src == GlyphContinuous::SRC_AllGlyphs);
+  sourceTextEdit_->setEnabled(isText);
+  verticalCheckBox_->setEnabled(isText);
+
+  repaintGlyph();
+}
+
+
+void
+ContinuousTab::charMapChanged()
+{
+  int newIndex = charMapSelector_->currentIndex();
+  if (newIndex != lastCharMapIndex_)
+  {
+    if (newIndex <= 0
+        || charMaps_.size() <= static_cast<unsigned>(newIndex - 1))
+      setGlyphBeginindex(0);
+    else if (charMaps_[newIndex - 1].maxIndex <= 20)
+      setGlyphBeginindex(charMaps_[newIndex - 1].maxIndex - 1);
+    else
+      setGlyphBeginindex(0x20);
+  }
+  updateLimitIndex();
+
+  repaintGlyph();
+
+  lastCharMapIndex_ = newIndex;
+}
+
+
+void
+ContinuousTab::sourceTextChanged()
+{
+  canvas_->setSourceText(sourceTextEdit_->toPlainText());
+  repaintGlyph();
+}
+
+
+void
+ContinuousTab::wheelNavigate(int steps)
+{
+  if (sourceSelector_->currentIndex() == GlyphContinuous::SRC_AllGlyphs)
+    setGlyphBeginindex(indexSelector_->currentIndex() + steps);
+}
+
+
+void
+ContinuousTab::wheelResize(int steps)
+{
+  sizeSelector_->handleWheelResizeBySteps(steps);
+}
+
+
+void
+ContinuousTab::createLayout()
+{
+  canvas_ = new GlyphContinuous(this, engine_);
+  sizeSelector_ = new FontSizeSelector(this);
+
   indexSelector_ = new GlyphIndexSelector(this);
   indexSelector_->setSingleMode(false);
   indexSelector_->setNumberRenderer([this](int index)
                                     { return formatIndex(index); });
+  sourceTextEdit_ = new QPlainTextEdit(
+      tr("The quick brown fox jumps over the lazy dog."), this);
 
   modeSelector_ = new QComboBox(this);
   charMapSelector_ = new QComboBox(this);
+  sourceSelector_ = new QComboBox(this);
 
   // Note: in sync with the enum!!
-  modeSelector_->insertItem(GlyphContinuous::AG_AllGlyphs, tr("All Glyphs"));
-  modeSelector_->insertItem(GlyphContinuous::AG_Fancy, 
+  modeSelector_->insertItem(GlyphContinuous::M_Normal, tr("Normal"));
+  modeSelector_->insertItem(GlyphContinuous::M_Fancy,
                             tr("Fancy (Embolding & Slanting)"));
-  modeSelector_->insertItem(GlyphContinuous::AG_Stroked, tr("Stroked"));
-  modeSelector_->insertItem(GlyphContinuous::AG_Waterfall, tr("Waterfall"));
-  modeSelector_->setCurrentIndex(GlyphContinuous::AG_AllGlyphs);
+  modeSelector_->insertItem(GlyphContinuous::M_Stroked, tr("Stroked"));
+  modeSelector_->insertItem(GlyphContinuous::M_Waterfall, tr("Waterfall"));
+  modeSelector_->setCurrentIndex(GlyphContinuous::M_Normal);
+
+  // Note: in sync with the enum!!
+  sourceSelector_->insertItem(GlyphContinuous::SRC_AllGlyphs,
+                              tr("All Glyphs"));
+  sourceSelector_->insertItem(GlyphContinuous::SRC_TextString, 
+                              tr("Text String"));
+  sourceSelector_->insertItem(GlyphContinuous::SRC_TextStringRepeated,
+                              tr("Text String (Repeated)"));
+
+  verticalCheckBox_ = new QCheckBox(tr("Vertical Layout"), this);
 
   modeLabel_ = new QLabel(tr("Mode:"), this);
+  sourceLabel_ = new QLabel(tr("Text Source:"), this);
   charMapLabel_ = new QLabel(tr("Char Map:"), this);
   xEmboldeningLabel_ = new QLabel(tr("Hori. Embolding:"), this);
   yEmboldeningLabel_ = new QLabel(tr("Vert. Embolding:"), this);
   slantLabel_ = new QLabel(tr("Slanting:"), this);
   strokeRadiusLabel_ = new QLabel(tr("Stroke Radius:"), this);
+  rotationLabel_ = new QLabel(tr("Rotation:"), this);
 
   xEmboldeningSpinBox_ = new QDoubleSpinBox(this);
   yEmboldeningSpinBox_ = new QDoubleSpinBox(this);
   slantSpinBox_ = new QDoubleSpinBox(this);
   strokeRadiusSpinBox_ = new QDoubleSpinBox(this);
+  rotationSpinBox_ = new QDoubleSpinBox(this);
 
   xEmboldeningSpinBox_->setSingleStep(0.005);
   xEmboldeningSpinBox_->setMinimum(-0.1);
@@ -355,93 +296,108 @@ ContinousAllGlyphsTab::createLayout()
   strokeRadiusSpinBox_->setSingleStep(0.005);
   strokeRadiusSpinBox_->setMinimum(0);
   strokeRadiusSpinBox_->setMaximum(0.05);
+  rotationSpinBox_->setSingleStep(5);
+  rotationSpinBox_->setMinimum(-180);
+  rotationSpinBox_->setMaximum(180);
+
+  bottomLayout_ = new QGridLayout;
+  bottomLayout_->addWidget(sourceLabel_, 0, 0);
+  bottomLayout_->addWidget(modeLabel_, 1, 0);
+  bottomLayout_->addWidget(charMapLabel_, 2, 0);
+  bottomLayout_->addWidget(sourceSelector_, 0, 1);
+  bottomLayout_->addWidget(modeSelector_, 1, 1);
+  bottomLayout_->addWidget(charMapSelector_, 2, 1);
+
+  bottomLayout_->addWidget(xEmboldeningLabel_, 1, 2);
+  bottomLayout_->addWidget(yEmboldeningLabel_, 2, 2);
+  bottomLayout_->addWidget(slantLabel_, 3, 2);
+  bottomLayout_->addWidget(strokeRadiusLabel_, 3, 0);
+  bottomLayout_->addWidget(rotationLabel_, 0, 2);
+
+  bottomLayout_->addWidget(xEmboldeningSpinBox_, 1, 3);
+  bottomLayout_->addWidget(yEmboldeningSpinBox_, 2, 3);
+  bottomLayout_->addWidget(slantSpinBox_, 3, 3);
+  bottomLayout_->addWidget(strokeRadiusSpinBox_, 3, 1);
+  bottomLayout_->addWidget(rotationSpinBox_, 0, 3);
+
+  bottomLayout_->addWidget(indexSelector_, 0, 4, 1, 1);
+  bottomLayout_->addWidget(sourceTextEdit_, 1, 4, 3, 2);
+  bottomLayout_->addWidget(verticalCheckBox_, 0, 5);
+
+  bottomLayout_->setColumnStretch(4, 1);
 
-  layout_ = new QGridLayout;
-  layout_->addWidget(indexSelector_, 0, 0, 1, 2);
-  layout_->addWidget(modeLabel_, 1, 0);
-  layout_->addWidget(charMapLabel_, 2, 0);
-  layout_->addWidget(modeSelector_, 1, 1);
-  layout_->addWidget(charMapSelector_, 2, 1);
-
-  layout_->addWidget(xEmboldeningLabel_, 1, 2);
-  layout_->addWidget(yEmboldeningLabel_, 2, 2);
-  layout_->addWidget(slantLabel_, 3, 2);
-  layout_->addWidget(strokeRadiusLabel_, 3, 0);
-  layout_->addWidget(xEmboldeningSpinBox_, 1, 3);
-  layout_->addWidget(yEmboldeningSpinBox_, 2, 3);
-  layout_->addWidget(slantSpinBox_, 3, 3);
-  layout_->addWidget(strokeRadiusSpinBox_, 3, 1);
-
-  layout_->setColumnStretch(1, 1);
-  layout_->setColumnStretch(3, 1);
-
-  setLayout(layout_);
+  mainLayout_ = new QVBoxLayout;
+  mainLayout_->addWidget(canvas_);
+  mainLayout_->addWidget(sizeSelector_);
+  mainLayout_->addLayout(bottomLayout_);
+
+  setLayout(mainLayout_);
 }
 
+
 void
-ContinousAllGlyphsTab::createConnections()
+ContinuousTab::createConnections()
 {
+  connect(sizeSelector_, &FontSizeSelector::valueChanged,
+          this, &ContinuousTab::repaintGlyph);
+
+  connect(canvas_, &GlyphContinuous::wheelResize, 
+          this, &ContinuousTab::wheelResize);
+  connect(canvas_, &GlyphContinuous::wheelNavigate, 
+          this, &ContinuousTab::wheelNavigate);
+  connect(canvas_, &GlyphContinuous::displayingCountUpdated, 
+          this, &ContinuousTab::setDisplayingCount);
+
   connect(indexSelector_, &GlyphIndexSelector::currentIndexChanged,
-          this, &ContinousAllGlyphsTab::changed);
+          this, &ContinuousTab::repaintGlyph);
   connect(modeSelector_, QOverload<int>::of(&QComboBox::currentIndexChanged),
-          this, &ContinousAllGlyphsTab::checkSubMode);
+          this, &ContinuousTab::checkMode);
   connect(charMapSelector_, 
QOverload<int>::of(&QComboBox::currentIndexChanged),
-          this, &ContinousAllGlyphsTab::charMapChanged);
+          this, &ContinuousTab::charMapChanged);
+  connect(sourceSelector_, QOverload<int>::of(&QComboBox::currentIndexChanged),
+          this, &ContinuousTab::checkSource);
 
   connect(xEmboldeningSpinBox_, 
           QOverload<double>::of(&QDoubleSpinBox::valueChanged),
-          this, &ContinousAllGlyphsTab::changed);
+          this, &ContinuousTab::repaintGlyph);
   connect(yEmboldeningSpinBox_, 
           QOverload<double>::of(&QDoubleSpinBox::valueChanged),
-          this, &ContinousAllGlyphsTab::changed);
+          this, &ContinuousTab::repaintGlyph);
   connect(slantSpinBox_, 
           QOverload<double>::of(&QDoubleSpinBox::valueChanged),
-          this, &ContinousAllGlyphsTab::changed);
+          this, &ContinuousTab::repaintGlyph);
   connect(strokeRadiusSpinBox_, 
           QOverload<double>::of(&QDoubleSpinBox::valueChanged),
-          this, &ContinousAllGlyphsTab::changed);
-}
-
-
-QString
-ContinousAllGlyphsTab::formatIndex(int index)
-{
-  if (charMapSelector_->currentIndex() <= 0) // glyph order
-    return QString::number(index);
-  return charMaps_[charMapSelector_->currentIndex() - 1]
-           .stringifyIndexShort(index);
-}
-
-
-void
-ContinousAllGlyphsTab::charMapChanged()
-{
-  int newIndex = charMapSelector_->currentIndex();
-  if (newIndex != lastCharMapIndex_)
-  {
-    if (newIndex <= 0
-        || charMaps_.size() <= static_cast<unsigned>(newIndex - 1))
-      setGlyphBeginindex(0);
-    else if (charMaps_[newIndex - 1].maxIndex <= 20)
-      setGlyphBeginindex(charMaps_[newIndex - 1].maxIndex - 1);
-    else
-      setGlyphBeginindex(0x20);
-  }
-  updateLimitIndex();
-
-  emit changed();
+          this, &ContinuousTab::repaintGlyph);
+  connect(rotationSpinBox_, 
+          QOverload<double>::of(&QDoubleSpinBox::valueChanged),
+          this, &ContinuousTab::repaintGlyph);
 
-  lastCharMapIndex_ = newIndex;
+  connect(verticalCheckBox_, &QCheckBox::clicked,
+          this, &ContinuousTab::repaintGlyph);
+  connect(sourceTextEdit_, &QPlainTextEdit::textChanged,
+          this, &ContinuousTab::sourceTextChanged);
 }
 
 
 void
-ContinousAllGlyphsTab::setDefaults()
+ContinuousTab::setDefaults()
 {
   xEmboldeningSpinBox_->setValue(0.04);
   yEmboldeningSpinBox_->setValue(0.04);
   slantSpinBox_->setValue(0.22);
   strokeRadiusSpinBox_->setValue(0.02);
+  rotationSpinBox_->setValue(0);
+}
+
+
+QString
+ContinuousTab::formatIndex(int index)
+{
+  if (charMapSelector_->currentIndex() <= 0) // glyph order
+    return QString::number(index);
+  return charMaps_[charMapSelector_->currentIndex() - 1].stringifyIndexShort(
+      index);
 }
 
 
diff --git a/src/ftinspect/panels/continuous.hpp 
b/src/ftinspect/panels/continuous.hpp
index 9eff04d..373b4fe 100644
--- a/src/ftinspect/panels/continuous.hpp
+++ b/src/ftinspect/panels/continuous.hpp
@@ -18,8 +18,8 @@
 #include <QComboBox>
 #include <QGridLayout>
 #include <QBoxLayout>
-
-class ContinousAllGlyphsTab;
+#include <QPlainTextEdit>
+#include <QCheckBox>
 
 class ContinuousTab
 : public QWidget, public AbstractTab
@@ -31,106 +31,71 @@ public:
 
   void repaintGlyph() override;
   void reloadFont() override;
-
-  // Info about current font (glyph count, charmaps...) is flowed to subtab
-  // via `updateCurrentSubTab`.
-  // Settings and parameters (e.g. mode) are flowed from subtab to `this` via
-  // `updateFromCurrentSubTab`.
-  // SubTabs can notify `this` via signals, see `createConnections`
-  void updateCurrentSubTab();
-  void updateFromCurrentSubTab();
-
-private slots:
-  void changeTab();
-  void wheelNavigate(int steps);
-  void wheelResize(int steps);
-
-private:
-  Engine* engine_;
-
-  int currentGlyphCount_;
-  GlyphContinuous* canvas_;
-  
-  FontSizeSelector* sizeSelector_;
-
-  QTabWidget* tabWidget_;
-  ContinousAllGlyphsTab* allGlyphsTab_;
-
-  enum Tabs
-  {
-    AllGlyphs = 0
-  };
-
-  QVBoxLayout* mainLayout_;
-  
-  void createLayout();
-  void createConnections();
-};
-
-
-class ContinousAllGlyphsTab
-: public QWidget
-{
-  Q_OBJECT
-public:
-  explicit ContinousAllGlyphsTab(QWidget* parent);
-  ~ContinousAllGlyphsTab() override = default;
-
-  int glyphBeginindex();
-  int glyphLimitIndex();
-  GlyphContinuous::SubModeAllGlyphs subMode();
-  double xEmboldening();
-  double yEmboldening();
-  double slanting();
-  double strokeRadius();
+  void syncSettings();
 
   // -1: Glyph order, otherwise the char map index in the original list
   int charMapIndex();
-  void setGlyphBeginindex(int index);
 
   // This doesn't trigger immediate repaint
   void setGlyphCount(int count);
   void setDisplayingCount(int count);
+  void setGlyphBeginindex(int index);
 
   void setCharMaps(std::vector<CharMapInfo>& charMaps);
   // This doesn't trigger either.
   void updateLimitIndex();
+  void checkMode();
+  void checkSource();
+  void charMapChanged();
+  void sourceTextChanged();
 
-  void checkSubMode();
-
-signals:
-  void changed();
+private slots:
+  void wheelNavigate(int steps);
+  void wheelResize(int steps);
 
 private:
-  int lastCharMapIndex_ = 0;
+  Engine* engine_;
+
   int currentGlyphCount_;
+  int lastCharMapIndex_ = 0;
   int glyphLimitIndex_ = 0;
 
-  GlyphIndexSelector* indexSelector_;
+  GlyphContinuous* canvas_;
+  FontSizeSelector* sizeSelector_;
+
   QComboBox* modeSelector_;
+  QComboBox* sourceSelector_;
   QComboBox* charMapSelector_;
 
   QLabel* modeLabel_;
+  QLabel* sourceLabel_;
   QLabel* charMapLabel_;
   QLabel* xEmboldeningLabel_;
   QLabel* yEmboldeningLabel_;
   QLabel* slantLabel_;
   QLabel* strokeRadiusLabel_;
+  QLabel* rotationLabel_;
 
   QDoubleSpinBox* xEmboldeningSpinBox_;
   QDoubleSpinBox* yEmboldeningSpinBox_;
   QDoubleSpinBox* slantSpinBox_;
   QDoubleSpinBox* strokeRadiusSpinBox_;
+  QDoubleSpinBox* rotationSpinBox_;
+
+  QCheckBox* verticalCheckBox_;
 
-  QGridLayout* layout_;
+  GlyphIndexSelector* indexSelector_;
+  QPlainTextEdit* sourceTextEdit_;
 
   std::vector<CharMapInfo> charMaps_;
 
+  QGridLayout* bottomLayout_;
+  QVBoxLayout* mainLayout_;
+  
   void createLayout();
   void createConnections();
 
   QString formatIndex(int index);
-  void charMapChanged();
 
   void setDefaults();
 };
diff --git a/src/ftinspect/rendering/glyphcontinuous.cpp 
b/src/ftinspect/rendering/glyphcontinuous.cpp
index e59ed20..faea765 100644
--- a/src/ftinspect/rendering/glyphcontinuous.cpp
+++ b/src/ftinspect/rendering/glyphcontinuous.cpp
@@ -41,21 +41,21 @@ GlyphContinuous::paintEvent(QPaintEvent* event)
   {
     prePaint();
 
-    switch (mode_)
+    switch (source_)
     {
-    case AllGlyphs:
-      switch (modeAG_)
+    case SRC_AllGlyphs:
+      switch (mode_)
       {
-      case AG_AllGlyphs:
-      case AG_Fancy:
-      case AG_Stroked:
+      case M_Normal:
+      case M_Fancy:
+      case M_Stroked:
         paintAG(&painter);
         break;
-      case AG_Waterfall:
+      case M_Waterfall:
         break;
       }
       break;
-    case TextString:
+    case SRC_TextString:
       break;
     }
     emit displayingCountUpdated(displayingCount_);
@@ -79,7 +79,7 @@ GlyphContinuous::wheelEvent(QWheelEvent* event)
 void
 GlyphContinuous::paintAG(QPainter* painter)
 {
-  if (modeAG_ == AG_Stroked)
+  if (mode_ == M_Stroked)
   {
     auto radius = static_cast<FT_Fixed>(metrics_.y_ppem * 64 * strokeRadius_);
     FT_Stroker_Set(stroker_, radius,
@@ -98,12 +98,12 @@ GlyphContinuous::paintAG(QPainter* painter)
       break;
 
     // All Glyphs need no tranformation, and Waterfall isn't handled here.
-    switch (modeAG_)
+    switch (mode_)
     {
-    case AG_Fancy:
+    case M_Fancy:
       transformGlyphAGFancy();
       break;
-    case AG_Stroked:
+    case M_Stroked:
       transformGlyphAGStroked();
       break;
     default:;
diff --git a/src/ftinspect/rendering/glyphcontinuous.hpp 
b/src/ftinspect/rendering/glyphcontinuous.hpp
index 9df2452..eca2f00 100644
--- a/src/ftinspect/rendering/glyphcontinuous.hpp
+++ b/src/ftinspect/rendering/glyphcontinuous.hpp
@@ -5,12 +5,17 @@
 #pragma once
 
 #include "graphicsdefault.hpp"
+
+#include <utility>
+
 #include <QWidget>
+
 #include <freetype/freetype.h>
 #include <freetype/ftglyph.h>
 #include <freetype/ftoutln.h>
 #include <freetype/ftstroke.h>
 
+
 class Engine;
 class GlyphContinuous
 : public QWidget
@@ -20,18 +25,19 @@ public:
   GlyphContinuous(QWidget* parent, Engine* engine);
   ~GlyphContinuous() override;
 
-  enum Mode : int
+  enum Source : int
   {
-    AllGlyphs,
-    TextString
+    SRC_AllGlyphs,
+    SRC_TextString,
+    SRC_TextStringRepeated
   };
 
-  enum SubModeAllGlyphs : int
+  enum Mode : int
   {
-    AG_AllGlyphs,
-    AG_Fancy,
-    AG_Stroked,
-    AG_Waterfall
+    M_Normal,
+    M_Fancy,
+    M_Stroked,
+    M_Waterfall
   };
 
   int displayingCount() { return displayingCount_; }
@@ -40,8 +46,8 @@ public:
   void setBeginIndex(int index) { beginIndex_ = index; }
   void setLimitIndex(int index) { limitIndex_ = index; }
   void setCharMapIndex(int index) { charMapIndex_ = index; }
+  void setSource(Source mode) { source_ = mode; }
   void setMode(Mode mode) { mode_ = mode; }
-  void setSubModeAllGlyphs(SubModeAllGlyphs modeAg) { modeAG_ = modeAg; }
   void setFancyParams(double boldX, double boldY, double slant)
   {
     boldX_ = boldX;
@@ -49,6 +55,10 @@ public:
     slant_ = slant;
   }
   void setStrokeRadius(double radius) { strokeRadius_ = radius; }
+  void setRotation(double rotation) { rotation_ = rotation; }
+  void setVertical(bool vertical) { vertical_ = vertical; }
+  void setSourceText(QString text) { text_ = std::move(text); }
+
 
 signals:
   void wheelNavigate(int steps);
@@ -63,13 +73,16 @@ private:
   Engine* engine_;
   GraphicsDefault* graphicsDefault_;
 
-  Mode mode_ = AllGlyphs;
-  SubModeAllGlyphs modeAG_ = AG_AllGlyphs;
+  Source source_ = SRC_AllGlyphs;
+  Mode mode_ = M_Normal;
   int beginIndex_;
   int limitIndex_;
   int charMapIndex_;
   double boldX_, boldY_, slant_;
   double strokeRadius_;
+  double rotation_;
+  bool vertical_;
+  QString text_;
 
   int displayingCount_ = 0;
   FT_Size_Metrics metrics_;



reply via email to

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