freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype-demos][reorg-maingui] [ftinspect] WIP: Move sett


From: Charlie Jiang (@cqjjjzr)
Subject: [Git][freetype/freetype-demos][reorg-maingui] [ftinspect] WIP: Move settings panel to a separate class
Date: Fri, 01 Jul 2022 16:37:00 +0000

Charlie Jiang pushed to branch reorg-maingui at FreeType / FreeType Demo Programs

Commits:

  • 620b9669
    by Charlie Jiang at 2022-07-02T00:36:17+08:00
    [ftinspect] WIP: Move settings panel to a separate class
    
    This commit moves the settings on the left to a new `SettingPanel` class.
    `check*` functions were re-organized so all manipulations against `Engine`
    was grouped together and made clear. Also, when a repaint or reload is
    triggered was clarified.
    
    (commit message WIP)
    

7 changed files:

Changes:

  • src/ftinspect/CMakeLists.txt
    ... ... @@ -34,6 +34,8 @@ add_executable(ftinspect
    34 34
       "widgets/qspinboxx.cpp"
    
    35 35
     
    
    36 36
       "models/ttsettingscomboboxmodel.cpp"
    
    37
    +
    
    38
    +  "panels/settingpanel.cpp"
    
    37 39
     )
    
    38 40
     target_link_libraries(ftinspect
    
    39 41
       Qt5::Core Qt5::Widgets
    

  • src/ftinspect/engine/engine.cpp
    ... ... @@ -435,6 +435,7 @@ Engine::setCFFHintingMode(int mode)
    435 435
       {
    
    436 436
         // reset the cache
    
    437 437
         FTC_Manager_Reset(cacheManager_);
    
    438
    +    ftSize_ = NULL;
    
    438 439
       }
    
    439 440
     }
    
    440 441
     
    
    ... ... @@ -450,6 +451,7 @@ Engine::setTTInterpreterVersion(int version)
    450 451
       {
    
    451 452
         // reset the cache
    
    452 453
         FTC_Manager_Reset(cacheManager_);
    
    454
    +    ftSize_ = NULL;
    
    453 455
       }
    
    454 456
     }
    
    455 457
     
    

  • src/ftinspect/maingui.cpp
    ... ... @@ -189,10 +189,10 @@ MainGUI::showFont()
    189 189
       checkCurrentFontIndex();
    
    190 190
       checkCurrentFaceIndex();
    
    191 191
       checkCurrentNamedInstanceIndex();
    
    192
    -  checkHinting();
    
    192
    +  auto state = settingPanel_->blockSignals(true);
    
    193
    +  settingPanel_->checkHinting();
    
    194
    +  settingPanel_->blockSignals(state);
    
    193 195
       adjustGlyphIndex(0);
    
    194
    -
    
    195
    -  drawGlyph();
    
    196 196
     }
    
    197 197
     
    
    198 198
     
    
    ... ... @@ -207,17 +207,7 @@ MainGUI::syncSettings()
    207 207
       else
    
    208 208
         engine_->setSizeByPoint(sizeDoubleSpinBox_->value());
    
    209 209
     
    
    210
    -  engine_->setHinting(hintingCheckBox_->isChecked());
    
    211
    -  engine_->setAutoHinting(autoHintingCheckBox_->isChecked());
    
    212
    -  engine_->setHorizontalHinting(horizontalHintingCheckBox_->isChecked());
    
    213
    -  engine_->setVerticalHinting(verticalHintingCheckBox_->isChecked());
    
    214
    -  engine_->setBlueZoneHinting(blueZoneHintingCheckBox_->isChecked());
    
    215
    -  engine_->setShowSegments(segmentDrawingCheckBox_->isChecked());
    
    216
    -
    
    217
    -  engine_->setGamma(gammaSlider_->value());
    
    218
    -
    
    219
    -  engine_->setAntiAliasingTarget(antiAliasingComboBoxModel_->indexToValue(
    
    220
    -    antiAliasingComboBox_->currentIndex()));
    
    210
    +  settingPanel_->syncSettings();
    
    221 211
     }
    
    222 212
     
    
    223 213
     
    
    ... ... @@ -229,161 +219,6 @@ MainGUI::clearStatusBar()
    229 219
     }
    
    230 220
     
    
    231 221
     
    
    232
    -void
    
    233
    -MainGUI::checkHinting()
    
    234
    -{
    
    235
    -  if (hintingCheckBox_->isChecked())
    
    236
    -  {
    
    237
    -    if (engine_->currentFontType() == Engine::FontType_CFF)
    
    238
    -    {
    
    239
    -      hintingModeComboBoxModel_->setCurrentEngineType(
    
    240
    -        HintingModeComboBoxModel::HintingEngineType_CFF);
    
    241
    -      hintingModeComboBox_->setCurrentIndex(currentCFFHintingMode_);
    
    242
    -    }
    
    243
    -    else if (engine_->currentFontType() == Engine::FontType_TrueType)
    
    244
    -    {
    
    245
    -      hintingModeComboBoxModel_->setCurrentEngineType(
    
    246
    -        HintingModeComboBoxModel::HintingEngineType_TrueType);
    
    247
    -      hintingModeComboBox_->setCurrentIndex(currentTTInterpreterVersion_);
    
    248
    -    }
    
    249
    -    else
    
    250
    -    {
    
    251
    -      hintingModeLabel_->setEnabled(false);
    
    252
    -      hintingModeComboBox_->setEnabled(false);
    
    253
    -    }
    
    254
    -
    
    255
    -    autoHintingCheckBox_->setEnabled(true);
    
    256
    -    checkAutoHinting();
    
    257
    -  }
    
    258
    -  else
    
    259
    -  {
    
    260
    -    hintingModeLabel_->setEnabled(false);
    
    261
    -    hintingModeComboBox_->setEnabled(false);
    
    262
    -
    
    263
    -    autoHintingCheckBox_->setEnabled(false);
    
    264
    -    horizontalHintingCheckBox_->setEnabled(false);
    
    265
    -    verticalHintingCheckBox_->setEnabled(false);
    
    266
    -    blueZoneHintingCheckBox_->setEnabled(false);
    
    267
    -    segmentDrawingCheckBox_->setEnabled(false);
    
    268
    -
    
    269
    -    antiAliasingComboBoxModel_->setLightAntiAliasingEnabled(false);
    
    270
    -    if (antiAliasingComboBox_->currentIndex()
    
    271
    -      == AntiAliasingComboBoxModel::AntiAliasing_Light)
    
    272
    -      antiAliasingComboBox_->setCurrentIndex(
    
    273
    -        AntiAliasingComboBoxModel::AntiAliasing_Normal);
    
    274
    -  }
    
    275
    -
    
    276
    -  drawGlyph();
    
    277
    -}
    
    278
    -
    
    279
    -
    
    280
    -void
    
    281
    -MainGUI::checkHintingMode()
    
    282
    -{
    
    283
    -  int index = hintingModeComboBox_->currentIndex();
    
    284
    -
    
    285
    -  if (engine_->currentFontType() == Engine::FontType_CFF)
    
    286
    -  {
    
    287
    -    engine_->setCFFHintingMode(
    
    288
    -      hintingModeComboBoxModel_->indexToCFFMode(index));
    
    289
    -    currentCFFHintingMode_ = index;
    
    290
    -  }
    
    291
    -  else if (engine_->currentFontType() == Engine::FontType_TrueType)
    
    292
    -  {
    
    293
    -    engine_->setTTInterpreterVersion(
    
    294
    -      hintingModeComboBoxModel_->indexToTTInterpreterVersion(index));
    
    295
    -    currentTTInterpreterVersion_ = index;
    
    296
    -  }
    
    297
    -
    
    298
    -  // this enforces reloading of the font
    
    299
    -  showFont();
    
    300
    -}
    
    301
    -
    
    302
    -
    
    303
    -void
    
    304
    -MainGUI::checkAutoHinting()
    
    305
    -{
    
    306
    -  if (autoHintingCheckBox_->isChecked())
    
    307
    -  {
    
    308
    -    hintingModeLabel_->setEnabled(false);
    
    309
    -    hintingModeComboBox_->setEnabled(false);
    
    310
    -
    
    311
    -    horizontalHintingCheckBox_->setEnabled(true);
    
    312
    -    verticalHintingCheckBox_->setEnabled(true);
    
    313
    -    blueZoneHintingCheckBox_->setEnabled(true);
    
    314
    -    segmentDrawingCheckBox_->setEnabled(true);
    
    315
    -
    
    316
    -    antiAliasingComboBoxModel_->setLightAntiAliasingEnabled(true);
    
    317
    -  }
    
    318
    -  else
    
    319
    -  {
    
    320
    -    if (engine_->currentFontType() == Engine::FontType_CFF
    
    321
    -        || engine_->currentFontType() == Engine::FontType_TrueType)
    
    322
    -    {
    
    323
    -      hintingModeLabel_->setEnabled(true);
    
    324
    -      hintingModeComboBox_->setEnabled(true);
    
    325
    -    }
    
    326
    -
    
    327
    -    horizontalHintingCheckBox_->setEnabled(false);
    
    328
    -    verticalHintingCheckBox_->setEnabled(false);
    
    329
    -    blueZoneHintingCheckBox_->setEnabled(false);
    
    330
    -    segmentDrawingCheckBox_->setEnabled(false);
    
    331
    -
    
    332
    -    antiAliasingComboBoxModel_->setLightAntiAliasingEnabled(false);
    
    333
    -
    
    334
    -    if (antiAliasingComboBox_->currentIndex()
    
    335
    -        == AntiAliasingComboBoxModel::AntiAliasing_Light)
    
    336
    -      antiAliasingComboBox_->setCurrentIndex(
    
    337
    -          AntiAliasingComboBoxModel::AntiAliasing_Normal);
    
    338
    -  }
    
    339
    -
    
    340
    -  drawGlyph();
    
    341
    -}
    
    342
    -
    
    343
    -
    
    344
    -void
    
    345
    -MainGUI::checkAntiAliasing()
    
    346
    -{
    
    347
    -  int index = antiAliasingComboBox_->currentIndex();
    
    348
    -
    
    349
    -  if (index == AntiAliasingComboBoxModel::AntiAliasing_None
    
    350
    -      || index == AntiAliasingComboBoxModel::AntiAliasing::AntiAliasing_Normal
    
    351
    -      || index == AntiAliasingComboBoxModel::AntiAliasing_Light)
    
    352
    -  {
    
    353
    -    lcdFilterLabel_->setEnabled(false);
    
    354
    -    lcdFilterComboBox_->setEnabled(false);
    
    355
    -  }
    
    356
    -  else
    
    357
    -  {
    
    358
    -    lcdFilterLabel_->setEnabled(true);
    
    359
    -    lcdFilterComboBox_->setEnabled(true);
    
    360
    -  }
    
    361
    -
    
    362
    -  drawGlyph();
    
    363
    -}
    
    364
    -
    
    365
    -
    
    366
    -void
    
    367
    -MainGUI::checkLcdFilter()
    
    368
    -{
    
    369
    -  int index = lcdFilterComboBox_->currentIndex();
    
    370
    -  engine_->setLcdFilter(static_cast<FT_LcdFilter>(
    
    371
    -    lcdFilterComboboxModel_->indexToValue(index)));
    
    372
    -}
    
    373
    -
    
    374
    -
    
    375
    -void
    
    376
    -MainGUI::checkShowPoints()
    
    377
    -{
    
    378
    -  if (showPointsCheckBox_->isChecked())
    
    379
    -    showPointNumbersCheckBox_->setEnabled(true);
    
    380
    -  else
    
    381
    -    showPointNumbersCheckBox_->setEnabled(false);
    
    382
    -
    
    383
    -  drawGlyph();
    
    384
    -}
    
    385
    -
    
    386
    -
    
    387 222
     void
    
    388 223
     MainGUI::checkUnits()
    
    389 224
     {
    
    ... ... @@ -671,11 +506,11 @@ MainGUI::drawGlyph()
    671 506
       FT_Outline* outline = engine_->loadOutline(currentGlyphIndex_);
    
    672 507
       if (outline)
    
    673 508
       {
    
    674
    -    if (showBitmapCheckBox_->isChecked())
    
    509
    +    if (settingPanel_->showBitmapChecked())
    
    675 510
         {
    
    676 511
           // XXX support LCD
    
    677 512
           FT_Pixel_Mode pixelMode = FT_PIXEL_MODE_GRAY;
    
    678
    -      if (antiAliasingComboBox_->currentIndex()
    
    513
    +      if (settingPanel_->antiAliasingModeIndex()
    
    679 514
               == AntiAliasingComboBoxModel::AntiAliasing_None)
    
    680 515
             pixelMode = FT_PIXEL_MODE_MONO;
    
    681 516
     
    
    ... ... @@ -687,18 +522,18 @@ MainGUI::drawGlyph()
    687 522
           glyphScene_->addItem(currentGlyphBitmapItem_);
    
    688 523
         }
    
    689 524
     
    
    690
    -    if (showOutlinesCheckBox_->isChecked())
    
    525
    +    if (settingPanel_->showOutLinesChecked())
    
    691 526
         {
    
    692 527
           currentGlyphOutlineItem_ = new GlyphOutline(outlinePen_, outline);
    
    693 528
           glyphScene_->addItem(currentGlyphOutlineItem_);
    
    694 529
         }
    
    695 530
     
    
    696
    -    if (showPointsCheckBox_->isChecked())
    
    531
    +    if (settingPanel_->showPointsChecked())
    
    697 532
         {
    
    698 533
           currentGlyphPointsItem_ = new GlyphPoints(onPen_, offPen_, outline);
    
    699 534
           glyphScene_->addItem(currentGlyphPointsItem_);
    
    700 535
     
    
    701
    -      if (showPointNumbersCheckBox_->isChecked())
    
    536
    +      if (settingPanel_->showPointNumbersChecked())
    
    702 537
           {
    
    703 538
             currentGlyphPointNumbersItem_ = new GlyphPointNumbers(onPen_,
    
    704 539
                                                                  offPen_,
    
    ... ... @@ -720,142 +555,14 @@ MainGUI::createLayout()
    720 555
       // left side
    
    721 556
       fontFilenameLabel_ = new QLabel;
    
    722 557
     
    
    723
    -  hintingCheckBox_ = new QCheckBox(tr("Hinting"));
    
    724
    -
    
    725
    -  hintingModeLabel_ = new QLabel(tr("Hinting Mode"));
    
    726
    -  hintingModeLabel_->setAlignment(Qt::AlignRight);
    
    727
    -
    
    728
    -  hintingModeComboBoxModel_ = new HintingModeComboBoxModel;
    
    729
    -  hintingModeComboBox_ = new QComboBox;
    
    730
    -  hintingModeComboBox_->setModel(hintingModeComboBoxModel_);
    
    731
    -  hintingModeLabel_->setBuddy(hintingModeComboBox_);
    
    732
    -
    
    733
    -  autoHintingCheckBox_ = new QCheckBox(tr("Auto-Hinting"));
    
    734
    -  horizontalHintingCheckBox_ = new QCheckBox(tr("Horizontal Hinting"));
    
    735
    -  verticalHintingCheckBox_ = new QCheckBox(tr("Vertical Hinting"));
    
    736
    -  blueZoneHintingCheckBox_ = new QCheckBox(tr("Blue-Zone Hinting"));
    
    737
    -  segmentDrawingCheckBox_ = new QCheckBox(tr("Segment Drawing"));
    
    738
    -
    
    739
    -  antiAliasingLabel_ = new QLabel(tr("Anti-Aliasing"));
    
    740
    -  antiAliasingLabel_->setAlignment(Qt::AlignRight);
    
    741
    -
    
    742
    -  antiAliasingComboBoxModel_ = new AntiAliasingComboBoxModel;
    
    743
    -  antiAliasingComboBox_ = new QComboBox;
    
    744
    -  antiAliasingComboBox_->setModel(antiAliasingComboBoxModel_);
    
    745
    -  antiAliasingLabel_->setBuddy(antiAliasingComboBox_);
    
    746
    -
    
    747
    -  lcdFilterLabel_ = new QLabel(tr("LCD Filter"));
    
    748
    -  lcdFilterLabel_->setAlignment(Qt::AlignRight);
    
    749
    -
    
    750
    -  lcdFilterComboboxModel_ = new LCDFilterComboBoxModel;
    
    751
    -  lcdFilterComboBox_ = new QComboBox;
    
    752
    -  lcdFilterComboBox_->setModel(lcdFilterComboboxModel_);
    
    753
    -  lcdFilterLabel_->setBuddy(lcdFilterComboBox_);
    
    754
    -
    
    755
    -  int width;
    
    756
    -  // make all labels have the same width
    
    757
    -  width = hintingModeLabel_->minimumSizeHint().width();
    
    758
    -  width = qMax(antiAliasingLabel_->minimumSizeHint().width(), width);
    
    759
    -  width = qMax(lcdFilterLabel_->minimumSizeHint().width(), width);
    
    760
    -  hintingModeLabel_->setMinimumWidth(width);
    
    761
    -  antiAliasingLabel_->setMinimumWidth(width);
    
    762
    -  lcdFilterLabel_->setMinimumWidth(width);
    
    763
    -
    
    764
    -  // ensure that all items in combo boxes fit completely;
    
    765
    -  // also make all combo boxes have the same width
    
    766
    -  width = hintingModeComboBox_->minimumSizeHint().width();
    
    767
    -  width = qMax(antiAliasingComboBox_->minimumSizeHint().width(), width);
    
    768
    -  width = qMax(lcdFilterComboBox_->minimumSizeHint().width(), width);
    
    769
    -  hintingModeComboBox_->setMinimumWidth(width);
    
    770
    -  antiAliasingComboBox_->setMinimumWidth(width);
    
    771
    -  lcdFilterComboBox_->setMinimumWidth(width);
    
    772
    -
    
    773
    -  gammaLabel_ = new QLabel(tr("Gamma"));
    
    774
    -  gammaLabel_->setAlignment(Qt::AlignRight);
    
    775
    -  gammaSlider_ = new QSlider(Qt::Horizontal);
    
    776
    -  gammaSlider_->setRange(0, 30); // in 1/10th
    
    777
    -  gammaSlider_->setTickPosition(QSlider::TicksBelow);
    
    778
    -  gammaSlider_->setTickInterval(5);
    
    779
    -  gammaLabel_->setBuddy(gammaSlider_);
    
    780
    -
    
    781
    -  showBitmapCheckBox_ = new QCheckBox(tr("Show Bitmap"));
    
    782
    -  showPointsCheckBox_ = new QCheckBox(tr("Show Points"));
    
    783
    -  showPointNumbersCheckBox_ = new QCheckBox(tr("Show Point Numbers"));
    
    784
    -  showOutlinesCheckBox_ = new QCheckBox(tr("Show Outlines"));
    
    785
    -
    
    786 558
       infoLeftLayout_ = new QHBoxLayout;
    
    787 559
       infoLeftLayout_->addWidget(fontFilenameLabel_);
    
    788 560
     
    
    789
    -  hintingModeLayout_ = new QHBoxLayout;
    
    790
    -  hintingModeLayout_->addWidget(hintingModeLabel_);
    
    791
    -  hintingModeLayout_->addWidget(hintingModeComboBox_);
    
    792
    -
    
    793
    -  horizontalHintingLayout_ = new QHBoxLayout;
    
    794
    -  horizontalHintingLayout_->addSpacing(20); // XXX px
    
    795
    -  horizontalHintingLayout_->addWidget(horizontalHintingCheckBox_);
    
    796
    -
    
    797
    -  verticalHintingLayout_ = new QHBoxLayout;
    
    798
    -  verticalHintingLayout_->addSpacing(20); // XXX px
    
    799
    -  verticalHintingLayout_->addWidget(verticalHintingCheckBox_);
    
    800
    -
    
    801
    -  blueZoneHintingLayout_ = new QHBoxLayout;
    
    802
    -  blueZoneHintingLayout_->addSpacing(20); // XXX px
    
    803
    -  blueZoneHintingLayout_->addWidget(blueZoneHintingCheckBox_);
    
    804
    -
    
    805
    -  segmentDrawingLayout_ = new QHBoxLayout;
    
    806
    -  segmentDrawingLayout_->addSpacing(20); // XXX px
    
    807
    -  segmentDrawingLayout_->addWidget(segmentDrawingCheckBox_);
    
    808
    -
    
    809
    -  antiAliasingLayout_ = new QHBoxLayout;
    
    810
    -  antiAliasingLayout_->addWidget(antiAliasingLabel_);
    
    811
    -  antiAliasingLayout_->addWidget(antiAliasingComboBox_);
    
    812
    -
    
    813
    -  lcdFilterLayout_ = new QHBoxLayout;
    
    814
    -  lcdFilterLayout_->addWidget(lcdFilterLabel_);
    
    815
    -  lcdFilterLayout_->addWidget(lcdFilterComboBox_);
    
    816
    -
    
    817
    -  gammaLayout_ = new QHBoxLayout;
    
    818
    -  gammaLayout_->addWidget(gammaLabel_);
    
    819
    -  gammaLayout_->addWidget(gammaSlider_);
    
    820
    -
    
    821
    -  pointNumbersLayout_ = new QHBoxLayout;
    
    822
    -  pointNumbersLayout_->addSpacing(20); // XXX px
    
    823
    -  pointNumbersLayout_->addWidget(showPointNumbersCheckBox_);
    
    824
    -
    
    825
    -  generalTabLayout_ = new QVBoxLayout;
    
    826
    -  generalTabLayout_->addWidget(hintingCheckBox_);
    
    827
    -  generalTabLayout_->addLayout(hintingModeLayout_);
    
    828
    -  generalTabLayout_->addWidget(autoHintingCheckBox_);
    
    829
    -  generalTabLayout_->addLayout(horizontalHintingLayout_);
    
    830
    -  generalTabLayout_->addLayout(verticalHintingLayout_);
    
    831
    -  generalTabLayout_->addLayout(blueZoneHintingLayout_);
    
    832
    -  generalTabLayout_->addLayout(segmentDrawingLayout_);
    
    833
    -  generalTabLayout_->addSpacing(20); // XXX px
    
    834
    -  generalTabLayout_->addStretch(1);
    
    835
    -  generalTabLayout_->addLayout(antiAliasingLayout_);
    
    836
    -  generalTabLayout_->addLayout(lcdFilterLayout_);
    
    837
    -  generalTabLayout_->addSpacing(20); // XXX px
    
    838
    -  generalTabLayout_->addStretch(1);
    
    839
    -  generalTabLayout_->addLayout(gammaLayout_);
    
    840
    -  generalTabLayout_->addSpacing(20); // XXX px
    
    841
    -  generalTabLayout_->addStretch(1);
    
    842
    -  generalTabLayout_->addWidget(showBitmapCheckBox_);
    
    843
    -  generalTabLayout_->addWidget(showPointsCheckBox_);
    
    844
    -  generalTabLayout_->addLayout(pointNumbersLayout_);
    
    845
    -  generalTabLayout_->addWidget(showOutlinesCheckBox_);
    
    846
    -
    
    847
    -  generalTabWidget_ = new QWidget;
    
    848
    -  generalTabWidget_->setLayout(generalTabLayout_);
    
    849
    -
    
    850
    -  mmgxTabWidget_ = new QWidget;
    
    851
    -
    
    852
    -  tabWidget_ = new QTabWidget;
    
    853
    -  tabWidget_->addTab(generalTabWidget_, tr("General"));
    
    854
    -  tabWidget_->addTab(mmgxTabWidget_, tr("MM/GX"));
    
    561
    +  settingPanel_ = new SettingPanel(engine_);
    
    855 562
     
    
    856 563
       leftLayout_ = new QVBoxLayout;
    
    857 564
       leftLayout_->addLayout(infoLeftLayout_);
    
    858
    -  leftLayout_->addWidget(tabWidget_);
    
    565
    +  leftLayout_->addWidget(settingPanel_);
    
    859 566
     
    
    860 567
       // we don't want to expand the left side horizontally;
    
    861 568
       // to change the policy we have to use a widget wrapper
    
    ... ... @@ -881,7 +588,6 @@ MainGUI::createLayout()
    881 588
       currentGlyphOutlineItem_ = NULL;
    
    882 589
       currentGlyphPointsItem_ = NULL;
    
    883 590
       currentGlyphPointNumbersItem_ = NULL;
    
    884
    -  drawGlyph();
    
    885 591
     
    
    886 592
       glyphView_ = new QGraphicsViewx;
    
    887 593
       glyphView_->setRenderHint(QPainter::Antialiasing, true);
    
    ... ... @@ -1009,27 +715,10 @@ MainGUI::createLayout()
    1009 715
     void
    
    1010 716
     MainGUI::createConnections()
    
    1011 717
     {
    
    1012
    -  connect(hintingCheckBox_, SIGNAL(clicked()),
    
    1013
    -          SLOT(checkHinting()));
    
    1014
    -
    
    1015
    -  connect(hintingModeComboBox_, SIGNAL(currentIndexChanged(int)),
    
    1016
    -          SLOT(checkHintingMode()));
    
    1017
    -  connect(antiAliasingComboBox_, SIGNAL(currentIndexChanged(int)),
    
    1018
    -          SLOT(checkAntiAliasing()));
    
    1019
    -  connect(lcdFilterComboBox_, SIGNAL(currentIndexChanged(int)),
    
    1020
    -          SLOT(checkLcdFilter()));
    
    1021
    -
    
    1022
    -  connect(autoHintingCheckBox_, SIGNAL(clicked()),
    
    1023
    -          SLOT(checkAutoHinting()));
    
    1024
    -  connect(showBitmapCheckBox_, SIGNAL(clicked()),
    
    1025
    -          SLOT(drawGlyph()));
    
    1026
    -  connect(showPointsCheckBox_, SIGNAL(clicked()),
    
    1027
    -          SLOT(checkShowPoints()));
    
    1028
    -  connect(showPointNumbersCheckBox_, SIGNAL(clicked()),
    
    1029
    -          SLOT(drawGlyph()));
    
    1030
    -  connect(showOutlinesCheckBox_, SIGNAL(clicked()),
    
    718
    +  connect(settingPanel_, SIGNAL(fontReloadNeeded()),
    
    719
    +          SLOT(showFont()));
    
    720
    +  connect(settingPanel_, SIGNAL(repaintNeeded()),
    
    1031 721
               SLOT(drawGlyph()));
    
    1032
    -
    
    1033 722
       connect(sizeDoubleSpinBox_, SIGNAL(valueChanged(double)),
    
    1034 723
               SLOT(drawGlyph()));
    
    1035 724
       connect(unitsComboBox_, SIGNAL(currentIndexChanged(int)),
    
    ... ... @@ -1141,53 +830,17 @@ MainGUI::createStatusBar()
    1141 830
     void
    
    1142 831
     MainGUI::setDefaults()
    
    1143 832
     {
    
    1144
    -  Engine::EngineDefaultValues& defaults = engine_->engineDefaults();
    
    1145
    -
    
    1146
    -  hintingModeComboBoxModel_->setSupportedModes(
    
    1147
    -    { defaults.ttInterpreterVersionDefault,
    
    1148
    -      defaults.ttInterpreterVersionOther,
    
    1149
    -      defaults.ttInterpreterVersionOther1 },
    
    1150
    -    { defaults.cffHintingEngineDefault, 
    
    1151
    -      defaults.cffHintingEngineOther });
    
    1152
    -
    
    1153 833
       // the next four values always non-negative
    
    1154 834
       currentFontIndex_ = 0;
    
    1155 835
       currentFaceIndex_ = 0;
    
    1156 836
       currentNamedInstanceIndex_ = 0;
    
    1157 837
       currentGlyphIndex_ = 0;
    
    1158 838
     
    
    1159
    -  currentCFFHintingMode_
    
    1160
    -    = hintingModeComboBoxModel_->cffModeToIndex(
    
    1161
    -    defaults.cffHintingEngineDefault);
    
    1162
    -  currentTTInterpreterVersion_
    
    1163
    -    = hintingModeComboBoxModel_->ttInterpreterVersionToIndex(
    
    1164
    -        defaults.ttInterpreterVersionDefault);
    
    1165
    -
    
    1166
    -  hintingCheckBox_->setChecked(true);
    
    1167
    -
    
    1168
    -  antiAliasingComboBox_->setCurrentIndex(
    
    1169
    -    AntiAliasingComboBoxModel::AntiAliasing_Normal);
    
    1170
    -  lcdFilterComboBox_->setCurrentIndex(
    
    1171
    -    LCDFilterComboBoxModel::LCDFilter_Light);
    
    1172
    -
    
    1173
    -  horizontalHintingCheckBox_->setChecked(true);
    
    1174
    -  verticalHintingCheckBox_->setChecked(true);
    
    1175
    -  blueZoneHintingCheckBox_->setChecked(true);
    
    1176
    -
    
    1177
    -  showBitmapCheckBox_->setChecked(true);
    
    1178
    -  showOutlinesCheckBox_->setChecked(true);
    
    1179
    -
    
    1180
    -  gammaSlider_->setValue(18); // 1.8
    
    1181 839
       sizeDoubleSpinBox_->setValue(20);
    
    1182 840
       dpiSpinBox_->setValue(96);
    
    1183 841
       zoomSpinBox_->setValue(20);
    
    1184 842
     
    
    1185
    -  checkHinting();
    
    1186
    -  checkHintingMode();
    
    1187
    -  checkAutoHinting();
    
    1188
    -  checkAntiAliasing();
    
    1189
    -  checkLcdFilter();
    
    1190
    -  checkShowPoints();
    
    843
    +  // todo run check for settingpanel
    
    1191 844
       checkUnits();
    
    1192 845
       checkCurrentFontIndex();
    
    1193 846
       checkCurrentFaceIndex();
    

  • src/ftinspect/maingui.hpp
    ... ... @@ -15,6 +15,7 @@
    15 15
     #include "widgets/qpushbuttonx.hpp"
    
    16 16
     #include "widgets/qspinboxx.hpp"
    
    17 17
     #include "models/ttsettingscomboboxmodel.hpp"
    
    18
    +#include "panels/settingpanel.hpp"
    
    18 19
     
    
    19 20
     #include <QAction>
    
    20 21
     #include <QCheckBox>
    
    ... ... @@ -71,17 +72,12 @@ private slots:
    71 72
       void about();
    
    72 73
       void aboutQt();
    
    73 74
       void adjustGlyphIndex(int);
    
    74
    -  void checkAntiAliasing();
    
    75
    -  void checkAutoHinting();
    
    76 75
       void checkCurrentFaceIndex();
    
    77 76
       void checkCurrentFontIndex();
    
    78 77
       void checkCurrentNamedInstanceIndex();
    
    79
    -  void checkHinting();
    
    80
    -  void checkHintingMode();
    
    81
    -  void checkLcdFilter();
    
    82
    -  void checkShowPoints();
    
    83 78
       void checkUnits();
    
    84 79
       void closeFont();
    
    80
    +  void showFont();
    
    85 81
       void drawGlyph();
    
    86 82
       void loadFonts();
    
    87 83
       void nextFace();
    
    ... ... @@ -107,9 +103,6 @@ private:
    107 103
       int currentNumberOfGlyphs_;
    
    108 104
       int currentGlyphIndex_;
    
    109 105
     
    
    110
    -  int currentCFFHintingMode_;
    
    111
    -  int currentTTInterpreterVersion_;
    
    112
    -
    
    113 106
       // layout related stuff
    
    114 107
       GlyphOutline *currentGlyphOutlineItem_;
    
    115 108
       GlyphPoints *currentGlyphPointsItem_;
    
    ... ... @@ -122,24 +115,6 @@ private:
    122 115
       QAction *exitAct_;
    
    123 116
       QAction *loadFontsAct_;
    
    124 117
     
    
    125
    -  QCheckBox *autoHintingCheckBox_;
    
    126
    -  QCheckBox *blueZoneHintingCheckBox_;
    
    127
    -  QCheckBox *hintingCheckBox_;
    
    128
    -  QCheckBox *horizontalHintingCheckBox_;
    
    129
    -  QCheckBox *segmentDrawingCheckBox_;
    
    130
    -  QCheckBox *showBitmapCheckBox_;
    
    131
    -  QCheckBox *showOutlinesCheckBox_;
    
    132
    -  QCheckBox *showPointNumbersCheckBox_;
    
    133
    -  QCheckBox *showPointsCheckBox_;
    
    134
    -  QCheckBox *verticalHintingCheckBox_;
    
    135
    -
    
    136
    -  AntiAliasingComboBoxModel* antiAliasingComboBoxModel_;
    
    137
    -  HintingModeComboBoxModel* hintingModeComboBoxModel_;
    
    138
    -  LCDFilterComboBoxModel* lcdFilterComboboxModel_;
    
    139
    -
    
    140
    -  QComboBox *antiAliasingComboBox_;
    
    141
    -  QComboBox *hintingModeComboBox_;
    
    142
    -  QComboBox *lcdFilterComboBox_;
    
    143 118
       QComboBox *unitsComboBox_;
    
    144 119
     
    
    145 120
       QDoubleSpinBox *sizeDoubleSpinBox_;
    
    ... ... @@ -150,29 +125,16 @@ private:
    150 125
       QGridLayout *fontLayout;
    
    151 126
       QGridLayout *infoRightLayout;
    
    152 127
     
    
    153
    -  QHBoxLayout *antiAliasingLayout_;
    
    154
    -  QHBoxLayout *blueZoneHintingLayout_;
    
    155 128
       QHBoxLayout *ftinspectLayout_;
    
    156
    -  QHBoxLayout *gammaLayout_;
    
    157
    -  QHBoxLayout *hintingModeLayout_;
    
    158
    -  QHBoxLayout *horizontalHintingLayout_;
    
    159 129
       QHBoxLayout *infoLeftLayout_;
    
    160
    -  QHBoxLayout *lcdFilterLayout_;
    
    161 130
       QHBoxLayout *navigationLayout_;
    
    162
    -  QHBoxLayout *pointNumbersLayout_;
    
    163
    -  QHBoxLayout *segmentDrawingLayout_;
    
    164 131
       QHBoxLayout *sizeLayout_;
    
    165
    -  QHBoxLayout *verticalHintingLayout_;
    
    166 132
     
    
    167
    -  QLabel *antiAliasingLabel_;
    
    168 133
       QLabel *dpiLabel_;
    
    169 134
       QLabel *fontFilenameLabel_;
    
    170 135
       QLabel *fontNameLabel_;
    
    171
    -  QLabel *gammaLabel_;
    
    172 136
       QLabel *glyphIndexLabel_;
    
    173 137
       QLabel *glyphNameLabel_;
    
    174
    -  QLabel *hintingModeLabel_;
    
    175
    -  QLabel *lcdFilterLabel_;
    
    176 138
       QLabel *sizeLabel_;
    
    177 139
       QLabel *zoomLabel_;
    
    178 140
     
    
    ... ... @@ -209,14 +171,9 @@ private:
    209 171
     
    
    210 172
       QSignalMapper *glyphNavigationMapper_;
    
    211 173
     
    
    212
    -  QSlider *gammaSlider_;
    
    213
    -
    
    214 174
       QSpinBox *dpiSpinBox_;
    
    215 175
       QSpinBoxx *zoomSpinBox_;
    
    216
    -
    
    217
    -  QTabWidget *tabWidget_;
    
    218
    -
    
    219
    -  QVBoxLayout *generalTabLayout_;
    
    176
    +  
    
    220 177
       QVBoxLayout *leftLayout_;
    
    221 178
       QVBoxLayout *rightLayout_;
    
    222 179
     
    
    ... ... @@ -224,10 +181,10 @@ private:
    224 181
       QVector<QRgb> monoColorTable_;
    
    225 182
     
    
    226 183
       QWidget *ftinspectWidget_;
    
    227
    -  QWidget *generalTabWidget_;
    
    228 184
       QWidget *leftWidget_;
    
    229 185
       QWidget *rightWidget_;
    
    230
    -  QWidget *mmgxTabWidget_;
    
    186
    +
    
    187
    +  SettingPanel* settingPanel_;
    
    231 188
     
    
    232 189
       enum Units
    
    233 190
       {
    
    ... ... @@ -235,7 +192,6 @@ private:
    235 192
         Units_pt
    
    236 193
       };
    
    237 194
     
    
    238
    -  void showFont();
    
    239 195
       void syncSettings();
    
    240 196
       void clearStatusBar();
    
    241 197
     
    

  • src/ftinspect/meson.build
    ... ... @@ -36,6 +36,8 @@ if qt5_dep.found()
    36 36
     
    
    37 37
         'models/ttsettingscomboboxmodel.cpp',
    
    38 38
     
    
    39
    +    'panels/settingpanel.cpp'
    
    40
    +
    
    39 41
         'ftinspect.cpp',
    
    40 42
         'maingui.cpp',
    
    41 43
     ])
    
    ... ... @@ -48,6 +50,7 @@ if qt5_dep.found()
    48 50
           'widgets/qspinboxx.hpp',
    
    49 51
           'maingui.hpp',
    
    50 52
           'models/ttsettingscomboboxmodel.cpp',
    
    53
    +      'panels/settingpanel.cpp',
    
    51 54
         ],
    
    52 55
         dependencies: qt5_dep)
    
    53 56
     
    

  • src/ftinspect/panels/settingpanel.cpp
    1
    +// settingpanel.cpp
    
    2
    +
    
    3
    +// Copyright (C) 2022 by Charlie Jiang.
    
    4
    +
    
    5
    +
    
    6
    +#include "settingpanel.hpp"
    
    7
    +
    
    8
    +SettingPanel::SettingPanel(Engine* engine)
    
    9
    +: engine_(engine)
    
    10
    +{
    
    11
    +  createLayout();
    
    12
    +  setDefaults();
    
    13
    +  createConnections();
    
    14
    +  checkAllSettings();
    
    15
    +}
    
    16
    +
    
    17
    +
    
    18
    +int
    
    19
    +SettingPanel::antiAliasingModeIndex()
    
    20
    +{
    
    21
    +  return antiAliasingComboBox_->currentIndex();
    
    22
    +}
    
    23
    +
    
    24
    +
    
    25
    +bool
    
    26
    +SettingPanel::showBitmapChecked()
    
    27
    +{
    
    28
    +  return showBitmapCheckBox_->isChecked();
    
    29
    +}
    
    30
    +
    
    31
    +
    
    32
    +bool
    
    33
    +SettingPanel::showOutLinesChecked()
    
    34
    +{
    
    35
    +  return showOutlinesCheckBox_->isChecked();
    
    36
    +}
    
    37
    +
    
    38
    +
    
    39
    +bool
    
    40
    +SettingPanel::showPointNumbersChecked()
    
    41
    +{
    
    42
    +  return showPointNumbersCheckBox_->isChecked();
    
    43
    +}
    
    44
    +
    
    45
    +
    
    46
    +bool
    
    47
    +SettingPanel::showPointsChecked()
    
    48
    +{
    
    49
    +  return showPointsCheckBox_->isChecked();
    
    50
    +}
    
    51
    +
    
    52
    +
    
    53
    +void
    
    54
    +SettingPanel::checkAllSettings()
    
    55
    +{
    
    56
    +  checkHinting();
    
    57
    +  checkAutoHinting();
    
    58
    +  checkAntiAliasing();
    
    59
    +  checkLCDFilter();
    
    60
    +  checkShowPoints();
    
    61
    +}
    
    62
    +
    
    63
    +void
    
    64
    +SettingPanel::checkHinting()
    
    65
    +{
    
    66
    +  if (hintingCheckBox_->isChecked())
    
    67
    +  {
    
    68
    +    if (engine_->currentFontType() == Engine::FontType_CFF)
    
    69
    +    {
    
    70
    +      hintingModeComboBoxModel_->setCurrentEngineType(
    
    71
    +        HintingModeComboBoxModel::HintingEngineType_CFF);
    
    72
    +      hintingModeComboBox_->setCurrentIndex(currentCFFHintingMode_);
    
    73
    +    }
    
    74
    +    else if (engine_->currentFontType() == Engine::FontType_TrueType)
    
    75
    +    {
    
    76
    +      hintingModeComboBoxModel_->setCurrentEngineType(
    
    77
    +        HintingModeComboBoxModel::HintingEngineType_TrueType);
    
    78
    +      hintingModeComboBox_->setCurrentIndex(currentTTInterpreterVersion_);
    
    79
    +    }
    
    80
    +    else
    
    81
    +    {
    
    82
    +      hintingModeLabel_->setEnabled(false);
    
    83
    +      hintingModeComboBox_->setEnabled(false);
    
    84
    +    }
    
    85
    +
    
    86
    +    autoHintingCheckBox_->setEnabled(true);
    
    87
    +    checkAutoHinting();
    
    88
    +  }
    
    89
    +  else
    
    90
    +  {
    
    91
    +    hintingModeLabel_->setEnabled(false);
    
    92
    +    hintingModeComboBox_->setEnabled(false);
    
    93
    +
    
    94
    +    autoHintingCheckBox_->setEnabled(false);
    
    95
    +    horizontalHintingCheckBox_->setEnabled(false);
    
    96
    +    verticalHintingCheckBox_->setEnabled(false);
    
    97
    +    blueZoneHintingCheckBox_->setEnabled(false);
    
    98
    +    segmentDrawingCheckBox_->setEnabled(false);
    
    99
    +
    
    100
    +    antiAliasingComboBoxModel_->setLightAntiAliasingEnabled(false);
    
    101
    +    if (antiAliasingComboBox_->currentIndex()
    
    102
    +      == AntiAliasingComboBoxModel::AntiAliasing_Light)
    
    103
    +      antiAliasingComboBox_->setCurrentIndex(
    
    104
    +        AntiAliasingComboBoxModel::AntiAliasing_Normal);
    
    105
    +  }
    
    106
    +
    
    107
    +  emit repaintNeeded();
    
    108
    +}
    
    109
    +
    
    110
    +
    
    111
    +void
    
    112
    +SettingPanel::checkHintingMode()
    
    113
    +{
    
    114
    +  // This must not be combined into `syncSettings`:
    
    115
    +  // those engine manipulations will reset the whole cache!!
    
    116
    +  int index = hintingModeComboBox_->currentIndex();
    
    117
    +
    
    118
    +  if (engine_->currentFontType() == Engine::FontType_CFF)
    
    119
    +  {
    
    120
    +    engine_->setCFFHintingMode(
    
    121
    +        hintingModeComboBoxModel_->indexToCFFMode(index));
    
    122
    +    currentCFFHintingMode_ = index;
    
    123
    +  }
    
    124
    +  else if (engine_->currentFontType() == Engine::FontType_TrueType)
    
    125
    +  {
    
    126
    +    engine_->setTTInterpreterVersion(
    
    127
    +        hintingModeComboBoxModel_->indexToTTInterpreterVersion(index));
    
    128
    +    currentTTInterpreterVersion_ = index;
    
    129
    +  }
    
    130
    +
    
    131
    +  emit fontReloadNeeded();
    
    132
    +}
    
    133
    +
    
    134
    +
    
    135
    +void
    
    136
    +SettingPanel::checkAutoHinting()
    
    137
    +{
    
    138
    +  if (autoHintingCheckBox_->isChecked())
    
    139
    +  {
    
    140
    +    hintingModeLabel_->setEnabled(false);
    
    141
    +    hintingModeComboBox_->setEnabled(false);
    
    142
    +
    
    143
    +    horizontalHintingCheckBox_->setEnabled(true);
    
    144
    +    verticalHintingCheckBox_->setEnabled(true);
    
    145
    +    blueZoneHintingCheckBox_->setEnabled(true);
    
    146
    +    segmentDrawingCheckBox_->setEnabled(true);
    
    147
    +
    
    148
    +    antiAliasingComboBoxModel_->setLightAntiAliasingEnabled(true);
    
    149
    +  }
    
    150
    +  else
    
    151
    +  {
    
    152
    +    if (engine_->currentFontType() == Engine::FontType_CFF
    
    153
    +        || engine_->currentFontType() == Engine::FontType_TrueType)
    
    154
    +    {
    
    155
    +      hintingModeLabel_->setEnabled(true);
    
    156
    +      hintingModeComboBox_->setEnabled(true);
    
    157
    +    }
    
    158
    +
    
    159
    +    horizontalHintingCheckBox_->setEnabled(false);
    
    160
    +    verticalHintingCheckBox_->setEnabled(false);
    
    161
    +    blueZoneHintingCheckBox_->setEnabled(false);
    
    162
    +    segmentDrawingCheckBox_->setEnabled(false);
    
    163
    +
    
    164
    +    antiAliasingComboBoxModel_->setLightAntiAliasingEnabled(false);
    
    165
    +
    
    166
    +    if (antiAliasingComboBox_->currentIndex()
    
    167
    +        == AntiAliasingComboBoxModel::AntiAliasing_Light)
    
    168
    +      antiAliasingComboBox_->setCurrentIndex(
    
    169
    +          AntiAliasingComboBoxModel::AntiAliasing_Normal);
    
    170
    +  }
    
    171
    +  emit repaintNeeded();
    
    172
    +}
    
    173
    +
    
    174
    +
    
    175
    +void
    
    176
    +SettingPanel::checkAntiAliasing()
    
    177
    +{
    
    178
    +  int index = antiAliasingComboBox_->currentIndex();
    
    179
    +
    
    180
    +  if (index == AntiAliasingComboBoxModel::AntiAliasing_None
    
    181
    +      || index == AntiAliasingComboBoxModel::AntiAliasing::AntiAliasing_Normal
    
    182
    +      || index == AntiAliasingComboBoxModel::AntiAliasing_Light)
    
    183
    +  {
    
    184
    +    lcdFilterLabel_->setEnabled(false);
    
    185
    +    lcdFilterComboBox_->setEnabled(false);
    
    186
    +  }
    
    187
    +  else
    
    188
    +  {
    
    189
    +    lcdFilterLabel_->setEnabled(true);
    
    190
    +    lcdFilterComboBox_->setEnabled(true);
    
    191
    +  }
    
    192
    +  emit repaintNeeded();
    
    193
    +}
    
    194
    +
    
    195
    +
    
    196
    +void
    
    197
    +SettingPanel::checkShowPoints()
    
    198
    +{
    
    199
    +  if (showPointsCheckBox_->isChecked())
    
    200
    +    showPointNumbersCheckBox_->setEnabled(true);
    
    201
    +  else
    
    202
    +    showPointNumbersCheckBox_->setEnabled(false);
    
    203
    +  emit repaintNeeded();
    
    204
    +}
    
    205
    +
    
    206
    +
    
    207
    +void
    
    208
    +SettingPanel::checkLCDFilter()
    
    209
    +{
    
    210
    +  emit repaintNeeded();
    
    211
    +}
    
    212
    +
    
    213
    +
    
    214
    +void
    
    215
    +SettingPanel::syncSettings()
    
    216
    +{
    
    217
    +  engine_->setLcdFilter(
    
    218
    +    static_cast<FT_LcdFilter>(lcdFilterComboboxModel_->indexToValue(
    
    219
    +      lcdFilterComboBox_->currentIndex())));
    
    220
    +  engine_->setAntiAliasingTarget(antiAliasingComboBoxModel_->indexToValue(
    
    221
    +    antiAliasingComboBox_->currentIndex()));
    
    222
    +  engine_->setHinting(hintingCheckBox_->isChecked());
    
    223
    +  engine_->setAutoHinting(autoHintingCheckBox_->isChecked());
    
    224
    +  engine_->setHorizontalHinting(horizontalHintingCheckBox_->isChecked());
    
    225
    +  engine_->setVerticalHinting(verticalHintingCheckBox_->isChecked());
    
    226
    +  engine_->setBlueZoneHinting(blueZoneHintingCheckBox_->isChecked());
    
    227
    +  engine_->setShowSegments(segmentDrawingCheckBox_->isChecked());
    
    228
    +
    
    229
    +  engine_->setGamma(gammaSlider_->value());
    
    230
    +}
    
    231
    +
    
    232
    +
    
    233
    +void
    
    234
    +SettingPanel::createConnections()
    
    235
    +{
    
    236
    +  connect(hintingCheckBox_, &QCheckBox::clicked,
    
    237
    +          this, &SettingPanel::checkHinting);
    
    238
    +
    
    239
    +  connect(hintingModeComboBox_, qOverload<int>(&QComboBox::activated),
    
    240
    +          this, &SettingPanel::checkHintingMode);
    
    241
    +  connect(antiAliasingComboBox_, qOverload<int>(&QComboBox::activated),
    
    242
    +          this, &SettingPanel::checkAntiAliasing);
    
    243
    +  connect(lcdFilterComboBox_, qOverload<int>(&QComboBox::activated),
    
    244
    +          this, &SettingPanel::checkLCDFilter);
    
    245
    +
    
    246
    +  connect(autoHintingCheckBox_, &QCheckBox::clicked,
    
    247
    +          this, &SettingPanel::checkAutoHinting);
    
    248
    +  connect(showBitmapCheckBox_, &QCheckBox::clicked,
    
    249
    +          this, &SettingPanel::repaintNeeded);
    
    250
    +  connect(showPointsCheckBox_, &QCheckBox::clicked, 
    
    251
    +          this, &SettingPanel::repaintNeeded);
    
    252
    +  connect(showPointNumbersCheckBox_, &QCheckBox::clicked,
    
    253
    +          this, &SettingPanel::repaintNeeded);
    
    254
    +  connect(showOutlinesCheckBox_, &QCheckBox::clicked,
    
    255
    +          this, &SettingPanel::repaintNeeded);
    
    256
    +}
    
    257
    +
    
    258
    +
    
    259
    +void
    
    260
    +SettingPanel::createLayout()
    
    261
    +{
    
    262
    +  hintingCheckBox_ = new QCheckBox(tr("Hinting"));
    
    263
    +
    
    264
    +  hintingModeLabel_ = new QLabel(tr("Hinting Mode"));
    
    265
    +  hintingModeLabel_->setAlignment(Qt::AlignRight);
    
    266
    +
    
    267
    +  hintingModeComboBoxModel_ = new HintingModeComboBoxModel;
    
    268
    +  hintingModeComboBox_ = new QComboBox;
    
    269
    +  hintingModeComboBox_->setModel(hintingModeComboBoxModel_);
    
    270
    +  hintingModeLabel_->setBuddy(hintingModeComboBox_);
    
    271
    +
    
    272
    +  autoHintingCheckBox_ = new QCheckBox(tr("Auto-Hinting"));
    
    273
    +  horizontalHintingCheckBox_ = new QCheckBox(tr("Horizontal Hinting"));
    
    274
    +  verticalHintingCheckBox_ = new QCheckBox(tr("Vertical Hinting"));
    
    275
    +  blueZoneHintingCheckBox_ = new QCheckBox(tr("Blue-Zone Hinting"));
    
    276
    +  segmentDrawingCheckBox_ = new QCheckBox(tr("Segment Drawing"));
    
    277
    +
    
    278
    +  antiAliasingLabel_ = new QLabel(tr("Anti-Aliasing"));
    
    279
    +  antiAliasingLabel_->setAlignment(Qt::AlignRight);
    
    280
    +
    
    281
    +  antiAliasingComboBoxModel_ = new AntiAliasingComboBoxModel;
    
    282
    +  antiAliasingComboBox_ = new QComboBox;
    
    283
    +  antiAliasingComboBox_->setModel(antiAliasingComboBoxModel_);
    
    284
    +  antiAliasingLabel_->setBuddy(antiAliasingComboBox_);
    
    285
    +
    
    286
    +  lcdFilterLabel_ = new QLabel(tr("LCD Filter"));
    
    287
    +  lcdFilterLabel_->setAlignment(Qt::AlignRight);
    
    288
    +
    
    289
    +  lcdFilterComboboxModel_ = new LCDFilterComboBoxModel;
    
    290
    +  lcdFilterComboBox_ = new QComboBox;
    
    291
    +  lcdFilterComboBox_->setModel(lcdFilterComboboxModel_);
    
    292
    +  lcdFilterLabel_->setBuddy(lcdFilterComboBox_);
    
    293
    +
    
    294
    +  int width;
    
    295
    +  // make all labels have the same width
    
    296
    +  width = hintingModeLabel_->minimumSizeHint().width();
    
    297
    +  width = qMax(antiAliasingLabel_->minimumSizeHint().width(), width);
    
    298
    +  width = qMax(lcdFilterLabel_->minimumSizeHint().width(), width);
    
    299
    +  hintingModeLabel_->setMinimumWidth(width);
    
    300
    +  antiAliasingLabel_->setMinimumWidth(width);
    
    301
    +  lcdFilterLabel_->setMinimumWidth(width);
    
    302
    +
    
    303
    +  // ensure that all items in combo boxes fit completely;
    
    304
    +  // also make all combo boxes have the same width
    
    305
    +  width = hintingModeComboBox_->minimumSizeHint().width();
    
    306
    +  width = qMax(antiAliasingComboBox_->minimumSizeHint().width(), width);
    
    307
    +  width = qMax(lcdFilterComboBox_->minimumSizeHint().width(), width);
    
    308
    +  hintingModeComboBox_->setMinimumWidth(width);
    
    309
    +  antiAliasingComboBox_->setMinimumWidth(width);
    
    310
    +  lcdFilterComboBox_->setMinimumWidth(width);
    
    311
    +
    
    312
    +  gammaLabel_ = new QLabel(tr("Gamma"));
    
    313
    +  gammaLabel_->setAlignment(Qt::AlignRight);
    
    314
    +  gammaSlider_ = new QSlider(Qt::Horizontal);
    
    315
    +  gammaSlider_->setRange(0, 30); // in 1/10th
    
    316
    +  gammaSlider_->setTickPosition(QSlider::TicksBelow);
    
    317
    +  gammaSlider_->setTickInterval(5);
    
    318
    +  gammaLabel_->setBuddy(gammaSlider_);
    
    319
    +
    
    320
    +  showBitmapCheckBox_ = new QCheckBox(tr("Show Bitmap"));
    
    321
    +  showPointsCheckBox_ = new QCheckBox(tr("Show Points"));
    
    322
    +  showPointNumbersCheckBox_ = new QCheckBox(tr("Show Point Numbers"));
    
    323
    +  showOutlinesCheckBox_ = new QCheckBox(tr("Show Outlines"));
    
    324
    +
    
    325
    +  hintingModeLayout_ = new QHBoxLayout;
    
    326
    +  hintingModeLayout_->addWidget(hintingModeLabel_);
    
    327
    +  hintingModeLayout_->addWidget(hintingModeComboBox_);
    
    328
    +
    
    329
    +  horizontalHintingLayout_ = new QHBoxLayout;
    
    330
    +  horizontalHintingLayout_->addSpacing(20); // XXX px
    
    331
    +  horizontalHintingLayout_->addWidget(horizontalHintingCheckBox_);
    
    332
    +
    
    333
    +  verticalHintingLayout_ = new QHBoxLayout;
    
    334
    +  verticalHintingLayout_->addSpacing(20); // XXX px
    
    335
    +  verticalHintingLayout_->addWidget(verticalHintingCheckBox_);
    
    336
    +
    
    337
    +  blueZoneHintingLayout_ = new QHBoxLayout;
    
    338
    +  blueZoneHintingLayout_->addSpacing(20); // XXX px
    
    339
    +  blueZoneHintingLayout_->addWidget(blueZoneHintingCheckBox_);
    
    340
    +
    
    341
    +  segmentDrawingLayout_ = new QHBoxLayout;
    
    342
    +  segmentDrawingLayout_->addSpacing(20); // XXX px
    
    343
    +  segmentDrawingLayout_->addWidget(segmentDrawingCheckBox_);
    
    344
    +
    
    345
    +  antiAliasingLayout_ = new QHBoxLayout;
    
    346
    +  antiAliasingLayout_->addWidget(antiAliasingLabel_);
    
    347
    +  antiAliasingLayout_->addWidget(antiAliasingComboBox_);
    
    348
    +
    
    349
    +  lcdFilterLayout_ = new QHBoxLayout;
    
    350
    +  lcdFilterLayout_->addWidget(lcdFilterLabel_);
    
    351
    +  lcdFilterLayout_->addWidget(lcdFilterComboBox_);
    
    352
    +
    
    353
    +  gammaLayout_ = new QHBoxLayout;
    
    354
    +  gammaLayout_->addWidget(gammaLabel_);
    
    355
    +  gammaLayout_->addWidget(gammaSlider_);
    
    356
    +
    
    357
    +  pointNumbersLayout_ = new QHBoxLayout;
    
    358
    +  pointNumbersLayout_->addSpacing(20); // XXX px
    
    359
    +  pointNumbersLayout_->addWidget(showPointNumbersCheckBox_);
    
    360
    +
    
    361
    +  generalTabLayout_ = new QVBoxLayout;
    
    362
    +  generalTabLayout_->addWidget(hintingCheckBox_);
    
    363
    +  generalTabLayout_->addLayout(hintingModeLayout_);
    
    364
    +  generalTabLayout_->addWidget(autoHintingCheckBox_);
    
    365
    +  generalTabLayout_->addLayout(horizontalHintingLayout_);
    
    366
    +  generalTabLayout_->addLayout(verticalHintingLayout_);
    
    367
    +  generalTabLayout_->addLayout(blueZoneHintingLayout_);
    
    368
    +  generalTabLayout_->addLayout(segmentDrawingLayout_);
    
    369
    +  generalTabLayout_->addSpacing(20); // XXX px
    
    370
    +  generalTabLayout_->addStretch(1);
    
    371
    +  generalTabLayout_->addLayout(antiAliasingLayout_);
    
    372
    +  generalTabLayout_->addLayout(lcdFilterLayout_);
    
    373
    +  generalTabLayout_->addSpacing(20); // XXX px
    
    374
    +  generalTabLayout_->addStretch(1);
    
    375
    +  generalTabLayout_->addLayout(gammaLayout_);
    
    376
    +  generalTabLayout_->addSpacing(20); // XXX px
    
    377
    +  generalTabLayout_->addStretch(1);
    
    378
    +  generalTabLayout_->addWidget(showBitmapCheckBox_);
    
    379
    +  generalTabLayout_->addWidget(showPointsCheckBox_);
    
    380
    +  generalTabLayout_->addLayout(pointNumbersLayout_);
    
    381
    +  generalTabLayout_->addWidget(showOutlinesCheckBox_);
    
    382
    +
    
    383
    +  generalTab_ = new QWidget;
    
    384
    +  generalTab_->setLayout(generalTabLayout_);
    
    385
    +
    
    386
    +  mmgxTab_ = new QWidget;
    
    387
    +
    
    388
    +  tab_ = new QTabWidget;
    
    389
    +  tab_->addTab(generalTab_, tr("General"));
    
    390
    +  tab_->addTab(mmgxTab_, tr("MM/GX"));
    
    391
    +
    
    392
    +  mainLayout_ = new QVBoxLayout;
    
    393
    +  mainLayout_->addWidget(tab_);
    
    394
    +  setLayout(mainLayout_);
    
    395
    +}
    
    396
    +
    
    397
    +
    
    398
    +void
    
    399
    +SettingPanel::setDefaults()
    
    400
    +{
    
    401
    +  Engine::EngineDefaultValues& defaults = engine_->engineDefaults();
    
    402
    +
    
    403
    +  hintingModeComboBoxModel_->setSupportedModes(
    
    404
    +    { defaults.ttInterpreterVersionDefault,
    
    405
    +      defaults.ttInterpreterVersionOther,
    
    406
    +      defaults.ttInterpreterVersionOther1 },
    
    407
    +    { defaults.cffHintingEngineDefault, 
    
    408
    +      defaults.cffHintingEngineOther });
    
    409
    +
    
    410
    +  currentCFFHintingMode_
    
    411
    +    = hintingModeComboBoxModel_->cffModeToIndex(
    
    412
    +    defaults.cffHintingEngineDefault);
    
    413
    +  currentTTInterpreterVersion_
    
    414
    +    = hintingModeComboBoxModel_->ttInterpreterVersionToIndex(
    
    415
    +        defaults.ttInterpreterVersionDefault);
    
    416
    +
    
    417
    +  hintingCheckBox_->setChecked(true);
    
    418
    +
    
    419
    +  antiAliasingComboBox_->setCurrentIndex(
    
    420
    +    AntiAliasingComboBoxModel::AntiAliasing_Normal);
    
    421
    +  lcdFilterComboBox_->setCurrentIndex(
    
    422
    +    LCDFilterComboBoxModel::LCDFilter_Light);
    
    423
    +
    
    424
    +  horizontalHintingCheckBox_->setChecked(true);
    
    425
    +  verticalHintingCheckBox_->setChecked(true);
    
    426
    +  blueZoneHintingCheckBox_->setChecked(true);
    
    427
    +
    
    428
    +  showBitmapCheckBox_->setChecked(true);
    
    429
    +  showOutlinesCheckBox_->setChecked(true);
    
    430
    +
    
    431
    +  gammaSlider_->setValue(18); // 1.8
    
    432
    +}
    
    433
    +
    
    434
    +
    
    435
    +// end of settingpanel.cpp

  • src/ftinspect/panels/settingpanel.hpp
    1
    +// settingpanel.hpp
    
    2
    +
    
    3
    +// Copyright (C) 2022 by Charlie Jiang.
    
    4
    +
    
    5
    +#pragma once
    
    6
    +
    
    7
    +#include "../engine/engine.hpp"
    
    8
    +#include "../models/ttsettingscomboboxmodel.hpp"
    
    9
    +
    
    10
    +#include <QWidget>
    
    11
    +#include <QTabWidget>
    
    12
    +#include <QLabel>
    
    13
    +#include <QComboBox>
    
    14
    +#include <QCheckBox>
    
    15
    +#include <QBoxLayout>
    
    16
    +
    
    17
    +class SettingPanel
    
    18
    +: public QWidget
    
    19
    +{
    
    20
    +  Q_OBJECT
    
    21
    +public:
    
    22
    +  SettingPanel(Engine* engine);
    
    23
    +  ~SettingPanel() = default;
    
    24
    +
    
    25
    +  //////// Getters/Setters
    
    26
    +
    
    27
    +  int antiAliasingModeIndex();
    
    28
    +
    
    29
    +  // TODO This would eventually go to separate panel for ftglyph (Singular View)
    
    30
    +  bool showBitmapChecked();
    
    31
    +  bool showOutLinesChecked();
    
    32
    +  bool showPointNumbersChecked();
    
    33
    +  bool showPointsChecked();
    
    34
    +  void syncSettings();
    
    35
    +
    
    36
    +signals:
    
    37
    +  void fontReloadNeeded();
    
    38
    +  void repaintNeeded();
    
    39
    +
    
    40
    +public slots:
    
    41
    +  void checkAllSettings();
    
    42
    +  void checkHinting();
    
    43
    +  void checkHintingMode();
    
    44
    +  void checkAutoHinting();
    
    45
    +  void checkAntiAliasing();
    
    46
    +  void checkShowPoints();
    
    47
    +  void checkLCDFilter();
    
    48
    +
    
    49
    +private:
    
    50
    +  Engine* engine_;
    
    51
    +
    
    52
    +  int currentCFFHintingMode_;
    
    53
    +  int currentTTInterpreterVersion_;
    
    54
    +
    
    55
    +  QTabWidget* tab_;
    
    56
    +
    
    57
    +  QWidget* generalTab_;
    
    58
    +  QWidget* mmgxTab_;
    
    59
    +
    
    60
    +  QLabel* gammaLabel_;
    
    61
    +  QLabel* antiAliasingLabel_;
    
    62
    +  QLabel* hintingModeLabel_;
    
    63
    +  QLabel* lcdFilterLabel_;
    
    64
    +
    
    65
    +  QCheckBox* hintingCheckBox_;
    
    66
    +  QCheckBox* horizontalHintingCheckBox_;
    
    67
    +  QCheckBox* verticalHintingCheckBox_;
    
    68
    +  QCheckBox* blueZoneHintingCheckBox_;
    
    69
    +  QCheckBox* segmentDrawingCheckBox_;
    
    70
    +  QCheckBox* autoHintingCheckBox_;
    
    71
    +  QCheckBox* showBitmapCheckBox_;
    
    72
    +  QCheckBox* showOutlinesCheckBox_;
    
    73
    +  QCheckBox* showPointNumbersCheckBox_;
    
    74
    +  QCheckBox* showPointsCheckBox_;
    
    75
    +
    
    76
    +  AntiAliasingComboBoxModel* antiAliasingComboBoxModel_;
    
    77
    +  HintingModeComboBoxModel* hintingModeComboBoxModel_;
    
    78
    +  LCDFilterComboBoxModel* lcdFilterComboboxModel_;
    
    79
    +
    
    80
    +  QComboBox* hintingModeComboBox_;
    
    81
    +  QComboBox* antiAliasingComboBox_;
    
    82
    +  QComboBox* lcdFilterComboBox_;
    
    83
    +
    
    84
    +  QSlider* gammaSlider_;
    
    85
    +
    
    86
    +  QVBoxLayout* mainLayout_;
    
    87
    +  QHBoxLayout* hintingModeLayout_;
    
    88
    +  QHBoxLayout* horizontalHintingLayout_;
    
    89
    +  QHBoxLayout* verticalHintingLayout_;
    
    90
    +  QHBoxLayout* blueZoneHintingLayout_;
    
    91
    +  QHBoxLayout* segmentDrawingLayout_;
    
    92
    +  QHBoxLayout* antiAliasingLayout_;
    
    93
    +  QHBoxLayout* lcdFilterLayout_;
    
    94
    +  QHBoxLayout* gammaLayout_;
    
    95
    +  QHBoxLayout* pointNumbersLayout_;
    
    96
    +
    
    97
    +  QVBoxLayout* generalTabLayout_;
    
    98
    +
    
    99
    +  void createConnections();
    
    100
    +  void createLayout();
    
    101
    +  void setDefaults();
    
    102
    +};
    
    103
    +
    
    104
    +
    
    105
    +// end of settingpanel.hpp


  • reply via email to

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