freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype-demos][reorg-maingui] 2 commits: [ftinspect] Dir


From: Charlie Jiang (@cqjjjzr)
Subject: [Git][freetype/freetype-demos][reorg-maingui] 2 commits: [ftinspect] Directly pass `Engine` object to constructor of `MainGUI`
Date: Fri, 01 Jul 2022 16:11:21 +0000

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

Commits:

  • 96390184
    by Charlie Jiang at 2022-07-01T20:27:52+08:00
    [ftinspect] Directly pass `Engine` object to constructor of `MainGUI`
    
    Because there's no bidirectional dependency between `Engine` and `MainGUI`,
    we no longer need `MainGUI::update` func and can directly pass the `Engine`
    object to `MainGUI`. This also make `engine_` variable available immediately
    in the constructor of `MainGUI`.
    
    * src/ftinspect/maingui.cpp, src/ftinspect/maingui.hpp: As described.
    
  • 16523dec
    by Charlie Jiang at 2022-07-02T00:03:55+08:00
    [ftinspect] WIP: Move settings panel to
    
    WARNING: Buggy, crashing.
    
    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.
    
    Currently crashes randomly on `engine.cpp:341` due to corrupted (deallocated)
    memory at `ftSize_`.
    
    (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/ftinspect.cpp
    ... ... @@ -21,10 +21,9 @@ main(int argc,
    21 21
       app.setOrganizationName("FreeType");
    
    22 22
       app.setOrganizationDomain("freetype.org");
    
    23 23
     
    
    24
    -  MainGUI gui;
    
    25 24
       Engine engine;
    
    25
    +  MainGUI gui(&engine);
    
    26 26
     
    
    27
    -  gui.update(&engine);
    
    28 27
       gui.setDefaults();
    
    29 28
     
    
    30 29
       gui.show();
    

  • src/ftinspect/maingui.cpp
    ... ... @@ -14,10 +14,9 @@
    14 14
     #include <freetype/ftdriver.h>
    
    15 15
     
    
    16 16
     
    
    17
    -MainGUI::MainGUI()
    
    17
    +MainGUI::MainGUI(Engine* engine)
    
    18
    +: engine_(engine)
    
    18 19
     {
    
    19
    -  engine_ = NULL;
    
    20
    -
    
    21 20
       setGraphicsDefaults();
    
    22 21
       createLayout();
    
    23 22
       createConnections();
    
    ... ... @@ -37,19 +36,6 @@ MainGUI::~MainGUI()
    37 36
     }
    
    38 37
     
    
    39 38
     
    
    40
    -void
    
    41
    -MainGUI::update(Engine* e)
    
    42
    -{
    
    43
    -  if (engine_)
    
    44
    -    disconnect(&engine_->fontFileManager(), &FontFileManager::currentFileChanged,
    
    45
    -        this, &MainGUI::watchCurrentFont);
    
    46
    -
    
    47
    -  engine_ = e;
    
    48
    -  connect(&engine_->fontFileManager(), &FontFileManager::currentFileChanged,
    
    49
    -          this, &MainGUI::watchCurrentFont);
    
    50
    -}
    
    51
    -
    
    52
    -
    
    53 39
     // overloading
    
    54 40
     
    
    55 41
     void
    
    ... ... @@ -203,7 +189,7 @@ MainGUI::showFont()
    203 189
       checkCurrentFontIndex();
    
    204 190
       checkCurrentFaceIndex();
    
    205 191
       checkCurrentNamedInstanceIndex();
    
    206
    -  checkHinting();
    
    192
    +  settingPanel_->checkHinting();
    
    207 193
       adjustGlyphIndex(0);
    
    208 194
     
    
    209 195
       drawGlyph();
    
    ... ... @@ -221,17 +207,7 @@ MainGUI::syncSettings()
    221 207
       else
    
    222 208
         engine_->setSizeByPoint(sizeDoubleSpinBox_->value());
    
    223 209
     
    
    224
    -  engine_->setHinting(hintingCheckBox_->isChecked());
    
    225
    -  engine_->setAutoHinting(autoHintingCheckBox_->isChecked());
    
    226
    -  engine_->setHorizontalHinting(horizontalHintingCheckBox_->isChecked());
    
    227
    -  engine_->setVerticalHinting(verticalHintingCheckBox_->isChecked());
    
    228
    -  engine_->setBlueZoneHinting(blueZoneHintingCheckBox_->isChecked());
    
    229
    -  engine_->setShowSegments(segmentDrawingCheckBox_->isChecked());
    
    230
    -
    
    231
    -  engine_->setGamma(gammaSlider_->value());
    
    232
    -
    
    233
    -  engine_->setAntiAliasingTarget(antiAliasingComboBoxModel_->indexToValue(
    
    234
    -    antiAliasingComboBox_->currentIndex()));
    
    210
    +  settingPanel_->syncSettings();
    
    235 211
     }
    
    236 212
     
    
    237 213
     
    
    ... ... @@ -243,161 +219,6 @@ MainGUI::clearStatusBar()
    243 219
     }
    
    244 220
     
    
    245 221
     
    
    246
    -void
    
    247
    -MainGUI::checkHinting()
    
    248
    -{
    
    249
    -  if (hintingCheckBox_->isChecked())
    
    250
    -  {
    
    251
    -    if (engine_->currentFontType() == Engine::FontType_CFF)
    
    252
    -    {
    
    253
    -      hintingModeComboBoxModel_->setCurrentEngineType(
    
    254
    -        HintingModeComboBoxModel::HintingEngineType_CFF);
    
    255
    -      hintingModeComboBox_->setCurrentIndex(currentCFFHintingMode_);
    
    256
    -    }
    
    257
    -    else if (engine_->currentFontType() == Engine::FontType_TrueType)
    
    258
    -    {
    
    259
    -      hintingModeComboBoxModel_->setCurrentEngineType(
    
    260
    -        HintingModeComboBoxModel::HintingEngineType_TrueType);
    
    261
    -      hintingModeComboBox_->setCurrentIndex(currentTTInterpreterVersion_);
    
    262
    -    }
    
    263
    -    else
    
    264
    -    {
    
    265
    -      hintingModeLabel_->setEnabled(false);
    
    266
    -      hintingModeComboBox_->setEnabled(false);
    
    267
    -    }
    
    268
    -
    
    269
    -    autoHintingCheckBox_->setEnabled(true);
    
    270
    -    checkAutoHinting();
    
    271
    -  }
    
    272
    -  else
    
    273
    -  {
    
    274
    -    hintingModeLabel_->setEnabled(false);
    
    275
    -    hintingModeComboBox_->setEnabled(false);
    
    276
    -
    
    277
    -    autoHintingCheckBox_->setEnabled(false);
    
    278
    -    horizontalHintingCheckBox_->setEnabled(false);
    
    279
    -    verticalHintingCheckBox_->setEnabled(false);
    
    280
    -    blueZoneHintingCheckBox_->setEnabled(false);
    
    281
    -    segmentDrawingCheckBox_->setEnabled(false);
    
    282
    -
    
    283
    -    antiAliasingComboBoxModel_->setLightAntiAliasingEnabled(false);
    
    284
    -    if (antiAliasingComboBox_->currentIndex()
    
    285
    -      == AntiAliasingComboBoxModel::AntiAliasing_Light)
    
    286
    -      antiAliasingComboBox_->setCurrentIndex(
    
    287
    -        AntiAliasingComboBoxModel::AntiAliasing_Normal);
    
    288
    -  }
    
    289
    -
    
    290
    -  drawGlyph();
    
    291
    -}
    
    292
    -
    
    293
    -
    
    294
    -void
    
    295
    -MainGUI::checkHintingMode()
    
    296
    -{
    
    297
    -  int index = hintingModeComboBox_->currentIndex();
    
    298
    -
    
    299
    -  if (engine_->currentFontType() == Engine::FontType_CFF)
    
    300
    -  {
    
    301
    -    engine_->setCFFHintingMode(
    
    302
    -      hintingModeComboBoxModel_->indexToCFFMode(index));
    
    303
    -    currentCFFHintingMode_ = index;
    
    304
    -  }
    
    305
    -  else if (engine_->currentFontType() == Engine::FontType_TrueType)
    
    306
    -  {
    
    307
    -    engine_->setTTInterpreterVersion(
    
    308
    -      hintingModeComboBoxModel_->indexToTTInterpreterVersion(index));
    
    309
    -    currentTTInterpreterVersion_ = index;
    
    310
    -  }
    
    311
    -
    
    312
    -  // this enforces reloading of the font
    
    313
    -  showFont();
    
    314
    -}
    
    315
    -
    
    316
    -
    
    317
    -void
    
    318
    -MainGUI::checkAutoHinting()
    
    319
    -{
    
    320
    -  if (autoHintingCheckBox_->isChecked())
    
    321
    -  {
    
    322
    -    hintingModeLabel_->setEnabled(false);
    
    323
    -    hintingModeComboBox_->setEnabled(false);
    
    324
    -
    
    325
    -    horizontalHintingCheckBox_->setEnabled(true);
    
    326
    -    verticalHintingCheckBox_->setEnabled(true);
    
    327
    -    blueZoneHintingCheckBox_->setEnabled(true);
    
    328
    -    segmentDrawingCheckBox_->setEnabled(true);
    
    329
    -
    
    330
    -    antiAliasingComboBoxModel_->setLightAntiAliasingEnabled(true);
    
    331
    -  }
    
    332
    -  else
    
    333
    -  {
    
    334
    -    if (engine_->currentFontType() == Engine::FontType_CFF
    
    335
    -        || engine_->currentFontType() == Engine::FontType_TrueType)
    
    336
    -    {
    
    337
    -      hintingModeLabel_->setEnabled(true);
    
    338
    -      hintingModeComboBox_->setEnabled(true);
    
    339
    -    }
    
    340
    -
    
    341
    -    horizontalHintingCheckBox_->setEnabled(false);
    
    342
    -    verticalHintingCheckBox_->setEnabled(false);
    
    343
    -    blueZoneHintingCheckBox_->setEnabled(false);
    
    344
    -    segmentDrawingCheckBox_->setEnabled(false);
    
    345
    -
    
    346
    -    antiAliasingComboBoxModel_->setLightAntiAliasingEnabled(false);
    
    347
    -
    
    348
    -    if (antiAliasingComboBox_->currentIndex()
    
    349
    -        == AntiAliasingComboBoxModel::AntiAliasing_Light)
    
    350
    -      antiAliasingComboBox_->setCurrentIndex(
    
    351
    -          AntiAliasingComboBoxModel::AntiAliasing_Normal);
    
    352
    -  }
    
    353
    -
    
    354
    -  drawGlyph();
    
    355
    -}
    
    356
    -
    
    357
    -
    
    358
    -void
    
    359
    -MainGUI::checkAntiAliasing()
    
    360
    -{
    
    361
    -  int index = antiAliasingComboBox_->currentIndex();
    
    362
    -
    
    363
    -  if (index == AntiAliasingComboBoxModel::AntiAliasing_None
    
    364
    -      || index == AntiAliasingComboBoxModel::AntiAliasing::AntiAliasing_Normal
    
    365
    -      || index == AntiAliasingComboBoxModel::AntiAliasing_Light)
    
    366
    -  {
    
    367
    -    lcdFilterLabel_->setEnabled(false);
    
    368
    -    lcdFilterComboBox_->setEnabled(false);
    
    369
    -  }
    
    370
    -  else
    
    371
    -  {
    
    372
    -    lcdFilterLabel_->setEnabled(true);
    
    373
    -    lcdFilterComboBox_->setEnabled(true);
    
    374
    -  }
    
    375
    -
    
    376
    -  drawGlyph();
    
    377
    -}
    
    378
    -
    
    379
    -
    
    380
    -void
    
    381
    -MainGUI::checkLcdFilter()
    
    382
    -{
    
    383
    -  int index = lcdFilterComboBox_->currentIndex();
    
    384
    -  engine_->setLcdFilter(static_cast<FT_LcdFilter>(
    
    385
    -    lcdFilterComboboxModel_->indexToValue(index)));
    
    386
    -}
    
    387
    -
    
    388
    -
    
    389
    -void
    
    390
    -MainGUI::checkShowPoints()
    
    391
    -{
    
    392
    -  if (showPointsCheckBox_->isChecked())
    
    393
    -    showPointNumbersCheckBox_->setEnabled(true);
    
    394
    -  else
    
    395
    -    showPointNumbersCheckBox_->setEnabled(false);
    
    396
    -
    
    397
    -  drawGlyph();
    
    398
    -}
    
    399
    -
    
    400
    -
    
    401 222
     void
    
    402 223
     MainGUI::checkUnits()
    
    403 224
     {
    
    ... ... @@ -685,11 +506,11 @@ MainGUI::drawGlyph()
    685 506
       FT_Outline* outline = engine_->loadOutline(currentGlyphIndex_);
    
    686 507
       if (outline)
    
    687 508
       {
    
    688
    -    if (showBitmapCheckBox_->isChecked())
    
    509
    +    if (settingPanel_->showBitmapChecked())
    
    689 510
         {
    
    690 511
           // XXX support LCD
    
    691 512
           FT_Pixel_Mode pixelMode = FT_PIXEL_MODE_GRAY;
    
    692
    -      if (antiAliasingComboBox_->currentIndex()
    
    513
    +      if (settingPanel_->antiAliasingModeIndex()
    
    693 514
               == AntiAliasingComboBoxModel::AntiAliasing_None)
    
    694 515
             pixelMode = FT_PIXEL_MODE_MONO;
    
    695 516
     
    
    ... ... @@ -701,18 +522,18 @@ MainGUI::drawGlyph()
    701 522
           glyphScene_->addItem(currentGlyphBitmapItem_);
    
    702 523
         }
    
    703 524
     
    
    704
    -    if (showOutlinesCheckBox_->isChecked())
    
    525
    +    if (settingPanel_->showOutLinesChecked())
    
    705 526
         {
    
    706 527
           currentGlyphOutlineItem_ = new GlyphOutline(outlinePen_, outline);
    
    707 528
           glyphScene_->addItem(currentGlyphOutlineItem_);
    
    708 529
         }
    
    709 530
     
    
    710
    -    if (showPointsCheckBox_->isChecked())
    
    531
    +    if (settingPanel_->showPointsChecked())
    
    711 532
         {
    
    712 533
           currentGlyphPointsItem_ = new GlyphPoints(onPen_, offPen_, outline);
    
    713 534
           glyphScene_->addItem(currentGlyphPointsItem_);
    
    714 535
     
    
    715
    -      if (showPointNumbersCheckBox_->isChecked())
    
    536
    +      if (settingPanel_->showPointNumbersChecked())
    
    716 537
           {
    
    717 538
             currentGlyphPointNumbersItem_ = new GlyphPointNumbers(onPen_,
    
    718 539
                                                                  offPen_,
    
    ... ... @@ -734,142 +555,14 @@ MainGUI::createLayout()
    734 555
       // left side
    
    735 556
       fontFilenameLabel_ = new QLabel;
    
    736 557
     
    
    737
    -  hintingCheckBox_ = new QCheckBox(tr("Hinting"));
    
    738
    -
    
    739
    -  hintingModeLabel_ = new QLabel(tr("Hinting Mode"));
    
    740
    -  hintingModeLabel_->setAlignment(Qt::AlignRight);
    
    741
    -
    
    742
    -  hintingModeComboBoxModel_ = new HintingModeComboBoxModel;
    
    743
    -  hintingModeComboBox_ = new QComboBox;
    
    744
    -  hintingModeComboBox_->setModel(hintingModeComboBoxModel_);
    
    745
    -  hintingModeLabel_->setBuddy(hintingModeComboBox_);
    
    746
    -
    
    747
    -  autoHintingCheckBox_ = new QCheckBox(tr("Auto-Hinting"));
    
    748
    -  horizontalHintingCheckBox_ = new QCheckBox(tr("Horizontal Hinting"));
    
    749
    -  verticalHintingCheckBox_ = new QCheckBox(tr("Vertical Hinting"));
    
    750
    -  blueZoneHintingCheckBox_ = new QCheckBox(tr("Blue-Zone Hinting"));
    
    751
    -  segmentDrawingCheckBox_ = new QCheckBox(tr("Segment Drawing"));
    
    752
    -
    
    753
    -  antiAliasingLabel_ = new QLabel(tr("Anti-Aliasing"));
    
    754
    -  antiAliasingLabel_->setAlignment(Qt::AlignRight);
    
    755
    -
    
    756
    -  antiAliasingComboBoxModel_ = new AntiAliasingComboBoxModel;
    
    757
    -  antiAliasingComboBox_ = new QComboBox;
    
    758
    -  antiAliasingComboBox_->setModel(antiAliasingComboBoxModel_);
    
    759
    -  antiAliasingLabel_->setBuddy(antiAliasingComboBox_);
    
    760
    -
    
    761
    -  lcdFilterLabel_ = new QLabel(tr("LCD Filter"));
    
    762
    -  lcdFilterLabel_->setAlignment(Qt::AlignRight);
    
    763
    -
    
    764
    -  lcdFilterComboboxModel_ = new LCDFilterComboBoxModel;
    
    765
    -  lcdFilterComboBox_ = new QComboBox;
    
    766
    -  lcdFilterComboBox_->setModel(lcdFilterComboboxModel_);
    
    767
    -  lcdFilterLabel_->setBuddy(lcdFilterComboBox_);
    
    768
    -
    
    769
    -  int width;
    
    770
    -  // make all labels have the same width
    
    771
    -  width = hintingModeLabel_->minimumSizeHint().width();
    
    772
    -  width = qMax(antiAliasingLabel_->minimumSizeHint().width(), width);
    
    773
    -  width = qMax(lcdFilterLabel_->minimumSizeHint().width(), width);
    
    774
    -  hintingModeLabel_->setMinimumWidth(width);
    
    775
    -  antiAliasingLabel_->setMinimumWidth(width);
    
    776
    -  lcdFilterLabel_->setMinimumWidth(width);
    
    777
    -
    
    778
    -  // ensure that all items in combo boxes fit completely;
    
    779
    -  // also make all combo boxes have the same width
    
    780
    -  width = hintingModeComboBox_->minimumSizeHint().width();
    
    781
    -  width = qMax(antiAliasingComboBox_->minimumSizeHint().width(), width);
    
    782
    -  width = qMax(lcdFilterComboBox_->minimumSizeHint().width(), width);
    
    783
    -  hintingModeComboBox_->setMinimumWidth(width);
    
    784
    -  antiAliasingComboBox_->setMinimumWidth(width);
    
    785
    -  lcdFilterComboBox_->setMinimumWidth(width);
    
    786
    -
    
    787
    -  gammaLabel_ = new QLabel(tr("Gamma"));
    
    788
    -  gammaLabel_->setAlignment(Qt::AlignRight);
    
    789
    -  gammaSlider_ = new QSlider(Qt::Horizontal);
    
    790
    -  gammaSlider_->setRange(0, 30); // in 1/10th
    
    791
    -  gammaSlider_->setTickPosition(QSlider::TicksBelow);
    
    792
    -  gammaSlider_->setTickInterval(5);
    
    793
    -  gammaLabel_->setBuddy(gammaSlider_);
    
    794
    -
    
    795
    -  showBitmapCheckBox_ = new QCheckBox(tr("Show Bitmap"));
    
    796
    -  showPointsCheckBox_ = new QCheckBox(tr("Show Points"));
    
    797
    -  showPointNumbersCheckBox_ = new QCheckBox(tr("Show Point Numbers"));
    
    798
    -  showOutlinesCheckBox_ = new QCheckBox(tr("Show Outlines"));
    
    799
    -
    
    800 558
       infoLeftLayout_ = new QHBoxLayout;
    
    801 559
       infoLeftLayout_->addWidget(fontFilenameLabel_);
    
    802 560
     
    
    803
    -  hintingModeLayout_ = new QHBoxLayout;
    
    804
    -  hintingModeLayout_->addWidget(hintingModeLabel_);
    
    805
    -  hintingModeLayout_->addWidget(hintingModeComboBox_);
    
    806
    -
    
    807
    -  horizontalHintingLayout_ = new QHBoxLayout;
    
    808
    -  horizontalHintingLayout_->addSpacing(20); // XXX px
    
    809
    -  horizontalHintingLayout_->addWidget(horizontalHintingCheckBox_);
    
    810
    -
    
    811
    -  verticalHintingLayout_ = new QHBoxLayout;
    
    812
    -  verticalHintingLayout_->addSpacing(20); // XXX px
    
    813
    -  verticalHintingLayout_->addWidget(verticalHintingCheckBox_);
    
    814
    -
    
    815
    -  blueZoneHintingLayout_ = new QHBoxLayout;
    
    816
    -  blueZoneHintingLayout_->addSpacing(20); // XXX px
    
    817
    -  blueZoneHintingLayout_->addWidget(blueZoneHintingCheckBox_);
    
    818
    -
    
    819
    -  segmentDrawingLayout_ = new QHBoxLayout;
    
    820
    -  segmentDrawingLayout_->addSpacing(20); // XXX px
    
    821
    -  segmentDrawingLayout_->addWidget(segmentDrawingCheckBox_);
    
    822
    -
    
    823
    -  antiAliasingLayout_ = new QHBoxLayout;
    
    824
    -  antiAliasingLayout_->addWidget(antiAliasingLabel_);
    
    825
    -  antiAliasingLayout_->addWidget(antiAliasingComboBox_);
    
    826
    -
    
    827
    -  lcdFilterLayout_ = new QHBoxLayout;
    
    828
    -  lcdFilterLayout_->addWidget(lcdFilterLabel_);
    
    829
    -  lcdFilterLayout_->addWidget(lcdFilterComboBox_);
    
    830
    -
    
    831
    -  gammaLayout_ = new QHBoxLayout;
    
    832
    -  gammaLayout_->addWidget(gammaLabel_);
    
    833
    -  gammaLayout_->addWidget(gammaSlider_);
    
    834
    -
    
    835
    -  pointNumbersLayout_ = new QHBoxLayout;
    
    836
    -  pointNumbersLayout_->addSpacing(20); // XXX px
    
    837
    -  pointNumbersLayout_->addWidget(showPointNumbersCheckBox_);
    
    838
    -
    
    839
    -  generalTabLayout_ = new QVBoxLayout;
    
    840
    -  generalTabLayout_->addWidget(hintingCheckBox_);
    
    841
    -  generalTabLayout_->addLayout(hintingModeLayout_);
    
    842
    -  generalTabLayout_->addWidget(autoHintingCheckBox_);
    
    843
    -  generalTabLayout_->addLayout(horizontalHintingLayout_);
    
    844
    -  generalTabLayout_->addLayout(verticalHintingLayout_);
    
    845
    -  generalTabLayout_->addLayout(blueZoneHintingLayout_);
    
    846
    -  generalTabLayout_->addLayout(segmentDrawingLayout_);
    
    847
    -  generalTabLayout_->addSpacing(20); // XXX px
    
    848
    -  generalTabLayout_->addStretch(1);
    
    849
    -  generalTabLayout_->addLayout(antiAliasingLayout_);
    
    850
    -  generalTabLayout_->addLayout(lcdFilterLayout_);
    
    851
    -  generalTabLayout_->addSpacing(20); // XXX px
    
    852
    -  generalTabLayout_->addStretch(1);
    
    853
    -  generalTabLayout_->addLayout(gammaLayout_);
    
    854
    -  generalTabLayout_->addSpacing(20); // XXX px
    
    855
    -  generalTabLayout_->addStretch(1);
    
    856
    -  generalTabLayout_->addWidget(showBitmapCheckBox_);
    
    857
    -  generalTabLayout_->addWidget(showPointsCheckBox_);
    
    858
    -  generalTabLayout_->addLayout(pointNumbersLayout_);
    
    859
    -  generalTabLayout_->addWidget(showOutlinesCheckBox_);
    
    860
    -
    
    861
    -  generalTabWidget_ = new QWidget;
    
    862
    -  generalTabWidget_->setLayout(generalTabLayout_);
    
    863
    -
    
    864
    -  mmgxTabWidget_ = new QWidget;
    
    865
    -
    
    866
    -  tabWidget_ = new QTabWidget;
    
    867
    -  tabWidget_->addTab(generalTabWidget_, tr("General"));
    
    868
    -  tabWidget_->addTab(mmgxTabWidget_, tr("MM/GX"));
    
    561
    +  settingPanel_ = new SettingPanel(engine_);
    
    869 562
     
    
    870 563
       leftLayout_ = new QVBoxLayout;
    
    871 564
       leftLayout_->addLayout(infoLeftLayout_);
    
    872
    -  leftLayout_->addWidget(tabWidget_);
    
    565
    +  leftLayout_->addWidget(settingPanel_);
    
    873 566
     
    
    874 567
       // we don't want to expand the left side horizontally;
    
    875 568
       // to change the policy we have to use a widget wrapper
    
    ... ... @@ -895,7 +588,6 @@ MainGUI::createLayout()
    895 588
       currentGlyphOutlineItem_ = NULL;
    
    896 589
       currentGlyphPointsItem_ = NULL;
    
    897 590
       currentGlyphPointNumbersItem_ = NULL;
    
    898
    -  drawGlyph();
    
    899 591
     
    
    900 592
       glyphView_ = new QGraphicsViewx;
    
    901 593
       glyphView_->setRenderHint(QPainter::Antialiasing, true);
    
    ... ... @@ -1023,27 +715,10 @@ MainGUI::createLayout()
    1023 715
     void
    
    1024 716
     MainGUI::createConnections()
    
    1025 717
     {
    
    1026
    -  connect(hintingCheckBox_, SIGNAL(clicked()),
    
    1027
    -          SLOT(checkHinting()));
    
    1028
    -
    
    1029
    -  connect(hintingModeComboBox_, SIGNAL(currentIndexChanged(int)),
    
    1030
    -          SLOT(checkHintingMode()));
    
    1031
    -  connect(antiAliasingComboBox_, SIGNAL(currentIndexChanged(int)),
    
    1032
    -          SLOT(checkAntiAliasing()));
    
    1033
    -  connect(lcdFilterComboBox_, SIGNAL(currentIndexChanged(int)),
    
    1034
    -          SLOT(checkLcdFilter()));
    
    1035
    -
    
    1036
    -  connect(autoHintingCheckBox_, SIGNAL(clicked()),
    
    1037
    -          SLOT(checkAutoHinting()));
    
    1038
    -  connect(showBitmapCheckBox_, SIGNAL(clicked()),
    
    1039
    -          SLOT(drawGlyph()));
    
    1040
    -  connect(showPointsCheckBox_, SIGNAL(clicked()),
    
    1041
    -          SLOT(checkShowPoints()));
    
    1042
    -  connect(showPointNumbersCheckBox_, SIGNAL(clicked()),
    
    718
    +  connect(settingPanel_, SIGNAL(fontReloadNeeded()),
    
    719
    +          SLOT(showFont()));
    
    720
    +  connect(settingPanel_, SIGNAL(repaintNeeded()),
    
    1043 721
               SLOT(drawGlyph()));
    
    1044
    -  connect(showOutlinesCheckBox_, SIGNAL(clicked()),
    
    1045
    -          SLOT(drawGlyph()));
    
    1046
    -
    
    1047 722
       connect(sizeDoubleSpinBox_, SIGNAL(valueChanged(double)),
    
    1048 723
               SLOT(drawGlyph()));
    
    1049 724
       connect(unitsComboBox_, SIGNAL(currentIndexChanged(int)),
    
    ... ... @@ -1102,6 +777,9 @@ MainGUI::createConnections()
    1102 777
       glyphNavigationMapper_->setMapping(toP100Buttonx_, 100);
    
    1103 778
       glyphNavigationMapper_->setMapping(toP1000Buttonx_, 1000);
    
    1104 779
       glyphNavigationMapper_->setMapping(toEndButtonx_, 0x10000);
    
    780
    +
    
    781
    +  connect(&engine_->fontFileManager(), &FontFileManager::currentFileChanged,
    
    782
    +          this, &MainGUI::watchCurrentFont);
    
    1105 783
     }
    
    1106 784
     
    
    1107 785
     
    
    ... ... @@ -1152,53 +830,17 @@ MainGUI::createStatusBar()
    1152 830
     void
    
    1153 831
     MainGUI::setDefaults()
    
    1154 832
     {
    
    1155
    -  Engine::EngineDefaultValues& defaults = engine_->engineDefaults();
    
    1156
    -
    
    1157
    -  hintingModeComboBoxModel_->setSupportedModes(
    
    1158
    -    { defaults.ttInterpreterVersionDefault,
    
    1159
    -      defaults.ttInterpreterVersionOther,
    
    1160
    -      defaults.ttInterpreterVersionOther1 },
    
    1161
    -    { defaults.cffHintingEngineDefault, 
    
    1162
    -      defaults.cffHintingEngineOther });
    
    1163
    -
    
    1164 833
       // the next four values always non-negative
    
    1165 834
       currentFontIndex_ = 0;
    
    1166 835
       currentFaceIndex_ = 0;
    
    1167 836
       currentNamedInstanceIndex_ = 0;
    
    1168 837
       currentGlyphIndex_ = 0;
    
    1169 838
     
    
    1170
    -  currentCFFHintingMode_
    
    1171
    -    = hintingModeComboBoxModel_->cffModeToIndex(
    
    1172
    -    defaults.cffHintingEngineDefault);
    
    1173
    -  currentTTInterpreterVersion_
    
    1174
    -    = hintingModeComboBoxModel_->ttInterpreterVersionToIndex(
    
    1175
    -        defaults.ttInterpreterVersionDefault);
    
    1176
    -
    
    1177
    -  hintingCheckBox_->setChecked(true);
    
    1178
    -
    
    1179
    -  antiAliasingComboBox_->setCurrentIndex(
    
    1180
    -    AntiAliasingComboBoxModel::AntiAliasing_Normal);
    
    1181
    -  lcdFilterComboBox_->setCurrentIndex(
    
    1182
    -    LCDFilterComboBoxModel::LCDFilter_Light);
    
    1183
    -
    
    1184
    -  horizontalHintingCheckBox_->setChecked(true);
    
    1185
    -  verticalHintingCheckBox_->setChecked(true);
    
    1186
    -  blueZoneHintingCheckBox_->setChecked(true);
    
    1187
    -
    
    1188
    -  showBitmapCheckBox_->setChecked(true);
    
    1189
    -  showOutlinesCheckBox_->setChecked(true);
    
    1190
    -
    
    1191
    -  gammaSlider_->setValue(18); // 1.8
    
    1192 839
       sizeDoubleSpinBox_->setValue(20);
    
    1193 840
       dpiSpinBox_->setValue(96);
    
    1194 841
       zoomSpinBox_->setValue(20);
    
    1195 842
     
    
    1196
    -  checkHinting();
    
    1197
    -  checkHintingMode();
    
    1198
    -  checkAutoHinting();
    
    1199
    -  checkAntiAliasing();
    
    1200
    -  checkLcdFilter();
    
    1201
    -  checkShowPoints();
    
    843
    +  // todo run check for settingpanel
    
    1202 844
       checkUnits();
    
    1203 845
       checkCurrentFontIndex();
    
    1204 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>
    
    ... ... @@ -53,11 +54,10 @@ class MainGUI
    53 54
       Q_OBJECT
    
    54 55
     
    
    55 56
     public:
    
    56
    -  MainGUI();
    
    57
    +  MainGUI(Engine* engine);
    
    57 58
       ~MainGUI();
    
    58 59
     
    
    59 60
       void setDefaults();
    
    60
    -  void update(Engine*);
    
    61 61
     
    
    62 62
       friend class Engine;
    
    63 63
       friend FT_Error faceRequester(FTC_FaceID,
    
    ... ... @@ -72,17 +72,12 @@ private slots:
    72 72
       void about();
    
    73 73
       void aboutQt();
    
    74 74
       void adjustGlyphIndex(int);
    
    75
    -  void checkAntiAliasing();
    
    76
    -  void checkAutoHinting();
    
    77 75
       void checkCurrentFaceIndex();
    
    78 76
       void checkCurrentFontIndex();
    
    79 77
       void checkCurrentNamedInstanceIndex();
    
    80
    -  void checkHinting();
    
    81
    -  void checkHintingMode();
    
    82
    -  void checkLcdFilter();
    
    83
    -  void checkShowPoints();
    
    84 78
       void checkUnits();
    
    85 79
       void closeFont();
    
    80
    +  void showFont();
    
    86 81
       void drawGlyph();
    
    87 82
       void loadFonts();
    
    88 83
       void nextFace();
    
    ... ... @@ -108,9 +103,6 @@ private:
    108 103
       int currentNumberOfGlyphs_;
    
    109 104
       int currentGlyphIndex_;
    
    110 105
     
    
    111
    -  int currentCFFHintingMode_;
    
    112
    -  int currentTTInterpreterVersion_;
    
    113
    -
    
    114 106
       // layout related stuff
    
    115 107
       GlyphOutline *currentGlyphOutlineItem_;
    
    116 108
       GlyphPoints *currentGlyphPointsItem_;
    
    ... ... @@ -123,24 +115,6 @@ private:
    123 115
       QAction *exitAct_;
    
    124 116
       QAction *loadFontsAct_;
    
    125 117
     
    
    126
    -  QCheckBox *autoHintingCheckBox_;
    
    127
    -  QCheckBox *blueZoneHintingCheckBox_;
    
    128
    -  QCheckBox *hintingCheckBox_;
    
    129
    -  QCheckBox *horizontalHintingCheckBox_;
    
    130
    -  QCheckBox *segmentDrawingCheckBox_;
    
    131
    -  QCheckBox *showBitmapCheckBox_;
    
    132
    -  QCheckBox *showOutlinesCheckBox_;
    
    133
    -  QCheckBox *showPointNumbersCheckBox_;
    
    134
    -  QCheckBox *showPointsCheckBox_;
    
    135
    -  QCheckBox *verticalHintingCheckBox_;
    
    136
    -
    
    137
    -  AntiAliasingComboBoxModel* antiAliasingComboBoxModel_;
    
    138
    -  HintingModeComboBoxModel* hintingModeComboBoxModel_;
    
    139
    -  LCDFilterComboBoxModel* lcdFilterComboboxModel_;
    
    140
    -
    
    141
    -  QComboBox *antiAliasingComboBox_;
    
    142
    -  QComboBox *hintingModeComboBox_;
    
    143
    -  QComboBox *lcdFilterComboBox_;
    
    144 118
       QComboBox *unitsComboBox_;
    
    145 119
     
    
    146 120
       QDoubleSpinBox *sizeDoubleSpinBox_;
    
    ... ... @@ -151,29 +125,16 @@ private:
    151 125
       QGridLayout *fontLayout;
    
    152 126
       QGridLayout *infoRightLayout;
    
    153 127
     
    
    154
    -  QHBoxLayout *antiAliasingLayout_;
    
    155
    -  QHBoxLayout *blueZoneHintingLayout_;
    
    156 128
       QHBoxLayout *ftinspectLayout_;
    
    157
    -  QHBoxLayout *gammaLayout_;
    
    158
    -  QHBoxLayout *hintingModeLayout_;
    
    159
    -  QHBoxLayout *horizontalHintingLayout_;
    
    160 129
       QHBoxLayout *infoLeftLayout_;
    
    161
    -  QHBoxLayout *lcdFilterLayout_;
    
    162 130
       QHBoxLayout *navigationLayout_;
    
    163
    -  QHBoxLayout *pointNumbersLayout_;
    
    164
    -  QHBoxLayout *segmentDrawingLayout_;
    
    165 131
       QHBoxLayout *sizeLayout_;
    
    166
    -  QHBoxLayout *verticalHintingLayout_;
    
    167 132
     
    
    168
    -  QLabel *antiAliasingLabel_;
    
    169 133
       QLabel *dpiLabel_;
    
    170 134
       QLabel *fontFilenameLabel_;
    
    171 135
       QLabel *fontNameLabel_;
    
    172
    -  QLabel *gammaLabel_;
    
    173 136
       QLabel *glyphIndexLabel_;
    
    174 137
       QLabel *glyphNameLabel_;
    
    175
    -  QLabel *hintingModeLabel_;
    
    176
    -  QLabel *lcdFilterLabel_;
    
    177 138
       QLabel *sizeLabel_;
    
    178 139
       QLabel *zoomLabel_;
    
    179 140
     
    
    ... ... @@ -210,14 +171,9 @@ private:
    210 171
     
    
    211 172
       QSignalMapper *glyphNavigationMapper_;
    
    212 173
     
    
    213
    -  QSlider *gammaSlider_;
    
    214
    -
    
    215 174
       QSpinBox *dpiSpinBox_;
    
    216 175
       QSpinBoxx *zoomSpinBox_;
    
    217
    -
    
    218
    -  QTabWidget *tabWidget_;
    
    219
    -
    
    220
    -  QVBoxLayout *generalTabLayout_;
    
    176
    +  
    
    221 177
       QVBoxLayout *leftLayout_;
    
    222 178
       QVBoxLayout *rightLayout_;
    
    223 179
     
    
    ... ... @@ -225,10 +181,10 @@ private:
    225 181
       QVector<QRgb> monoColorTable_;
    
    226 182
     
    
    227 183
       QWidget *ftinspectWidget_;
    
    228
    -  QWidget *generalTabWidget_;
    
    229 184
       QWidget *leftWidget_;
    
    230 185
       QWidget *rightWidget_;
    
    231
    -  QWidget *mmgxTabWidget_;
    
    186
    +
    
    187
    +  SettingPanel* settingPanel_;
    
    232 188
     
    
    233 189
       enum Units
    
    234 190
       {
    
    ... ... @@ -236,7 +192,6 @@ private:
    236 192
         Units_pt
    
    237 193
       };
    
    238 194
     
    
    239
    -  void showFont();
    
    240 195
       void syncSettings();
    
    241 196
       void clearStatusBar();
    
    242 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::checkAutoHinting()
    
    113
    +{
    
    114
    +  if (autoHintingCheckBox_->isChecked())
    
    115
    +  {
    
    116
    +    hintingModeLabel_->setEnabled(false);
    
    117
    +    hintingModeComboBox_->setEnabled(false);
    
    118
    +
    
    119
    +    horizontalHintingCheckBox_->setEnabled(true);
    
    120
    +    verticalHintingCheckBox_->setEnabled(true);
    
    121
    +    blueZoneHintingCheckBox_->setEnabled(true);
    
    122
    +    segmentDrawingCheckBox_->setEnabled(true);
    
    123
    +
    
    124
    +    antiAliasingComboBoxModel_->setLightAntiAliasingEnabled(true);
    
    125
    +  }
    
    126
    +  else
    
    127
    +  {
    
    128
    +    if (engine_->currentFontType() == Engine::FontType_CFF
    
    129
    +        || engine_->currentFontType() == Engine::FontType_TrueType)
    
    130
    +    {
    
    131
    +      hintingModeLabel_->setEnabled(true);
    
    132
    +      hintingModeComboBox_->setEnabled(true);
    
    133
    +    }
    
    134
    +
    
    135
    +    horizontalHintingCheckBox_->setEnabled(false);
    
    136
    +    verticalHintingCheckBox_->setEnabled(false);
    
    137
    +    blueZoneHintingCheckBox_->setEnabled(false);
    
    138
    +    segmentDrawingCheckBox_->setEnabled(false);
    
    139
    +
    
    140
    +    antiAliasingComboBoxModel_->setLightAntiAliasingEnabled(false);
    
    141
    +
    
    142
    +    if (antiAliasingComboBox_->currentIndex()
    
    143
    +        == AntiAliasingComboBoxModel::AntiAliasing_Light)
    
    144
    +      antiAliasingComboBox_->setCurrentIndex(
    
    145
    +          AntiAliasingComboBoxModel::AntiAliasing_Normal);
    
    146
    +  }
    
    147
    +  emit repaintNeeded();
    
    148
    +}
    
    149
    +
    
    150
    +
    
    151
    +void
    
    152
    +SettingPanel::checkAntiAliasing()
    
    153
    +{
    
    154
    +  int index = antiAliasingComboBox_->currentIndex();
    
    155
    +
    
    156
    +  if (index == AntiAliasingComboBoxModel::AntiAliasing_None
    
    157
    +      || index == AntiAliasingComboBoxModel::AntiAliasing::AntiAliasing_Normal
    
    158
    +      || index == AntiAliasingComboBoxModel::AntiAliasing_Light)
    
    159
    +  {
    
    160
    +    lcdFilterLabel_->setEnabled(false);
    
    161
    +    lcdFilterComboBox_->setEnabled(false);
    
    162
    +  }
    
    163
    +  else
    
    164
    +  {
    
    165
    +    lcdFilterLabel_->setEnabled(true);
    
    166
    +    lcdFilterComboBox_->setEnabled(true);
    
    167
    +  }
    
    168
    +  emit repaintNeeded();
    
    169
    +}
    
    170
    +
    
    171
    +
    
    172
    +void
    
    173
    +SettingPanel::checkShowPoints()
    
    174
    +{
    
    175
    +  if (showPointsCheckBox_->isChecked())
    
    176
    +    showPointNumbersCheckBox_->setEnabled(true);
    
    177
    +  else
    
    178
    +    showPointNumbersCheckBox_->setEnabled(false);
    
    179
    +  emit repaintNeeded();
    
    180
    +}
    
    181
    +
    
    182
    +
    
    183
    +void
    
    184
    +SettingPanel::checkLCDFilter()
    
    185
    +{
    
    186
    +  emit repaintNeeded();
    
    187
    +}
    
    188
    +
    
    189
    +
    
    190
    +void
    
    191
    +SettingPanel::syncSettings()
    
    192
    +{
    
    193
    +  int index = hintingModeComboBox_->currentIndex();
    
    194
    +
    
    195
    +  if (engine_->currentFontType() == Engine::FontType_CFF)
    
    196
    +  {
    
    197
    +    engine_->setCFFHintingMode(
    
    198
    +        hintingModeComboBoxModel_->indexToCFFMode(index));
    
    199
    +    currentCFFHintingMode_ = index;
    
    200
    +  }
    
    201
    +  else if (engine_->currentFontType() == Engine::FontType_TrueType)
    
    202
    +  {
    
    203
    +    engine_->setTTInterpreterVersion(
    
    204
    +        hintingModeComboBoxModel_->indexToTTInterpreterVersion(index));
    
    205
    +    currentTTInterpreterVersion_ = index;
    
    206
    +  }
    
    207
    +
    
    208
    +  engine_->setLcdFilter(
    
    209
    +    static_cast<FT_LcdFilter>(lcdFilterComboboxModel_->indexToValue(
    
    210
    +      lcdFilterComboBox_->currentIndex())));
    
    211
    +  engine_->setAntiAliasingTarget(antiAliasingComboBoxModel_->indexToValue(
    
    212
    +    antiAliasingComboBox_->currentIndex()));
    
    213
    +  engine_->setHinting(hintingCheckBox_->isChecked());
    
    214
    +  engine_->setAutoHinting(autoHintingCheckBox_->isChecked());
    
    215
    +  engine_->setHorizontalHinting(horizontalHintingCheckBox_->isChecked());
    
    216
    +  engine_->setVerticalHinting(verticalHintingCheckBox_->isChecked());
    
    217
    +  engine_->setBlueZoneHinting(blueZoneHintingCheckBox_->isChecked());
    
    218
    +  engine_->setShowSegments(segmentDrawingCheckBox_->isChecked());
    
    219
    +
    
    220
    +  engine_->setGamma(gammaSlider_->value());
    
    221
    +}
    
    222
    +
    
    223
    +
    
    224
    +void
    
    225
    +SettingPanel::createConnections()
    
    226
    +{
    
    227
    +  connect(hintingCheckBox_, &QCheckBox::clicked,
    
    228
    +          this, &SettingPanel::checkHinting);
    
    229
    +
    
    230
    +  connect(hintingModeComboBox_, qOverload<int>(&QComboBox::activated),
    
    231
    +          this, &SettingPanel::fontReloadNeeded);
    
    232
    +  connect(antiAliasingComboBox_, qOverload<int>(&QComboBox::activated),
    
    233
    +          this, &SettingPanel::checkAntiAliasing);
    
    234
    +  connect(lcdFilterComboBox_, qOverload<int>(&QComboBox::activated),
    
    235
    +          this, &SettingPanel::checkLCDFilter);
    
    236
    +
    
    237
    +  connect(autoHintingCheckBox_, &QCheckBox::clicked,
    
    238
    +          this, &SettingPanel::checkAutoHinting);
    
    239
    +  connect(showBitmapCheckBox_, &QCheckBox::clicked,
    
    240
    +          this, &SettingPanel::repaintNeeded);
    
    241
    +  connect(showPointsCheckBox_, &QCheckBox::clicked, 
    
    242
    +          this, &SettingPanel::repaintNeeded);
    
    243
    +  connect(showPointNumbersCheckBox_, &QCheckBox::clicked,
    
    244
    +          this, &SettingPanel::repaintNeeded);
    
    245
    +  connect(showOutlinesCheckBox_, &QCheckBox::clicked,
    
    246
    +          this, &SettingPanel::repaintNeeded);
    
    247
    +}
    
    248
    +
    
    249
    +
    
    250
    +void
    
    251
    +SettingPanel::createLayout()
    
    252
    +{
    
    253
    +  hintingCheckBox_ = new QCheckBox(tr("Hinting"));
    
    254
    +
    
    255
    +  hintingModeLabel_ = new QLabel(tr("Hinting Mode"));
    
    256
    +  hintingModeLabel_->setAlignment(Qt::AlignRight);
    
    257
    +
    
    258
    +  hintingModeComboBoxModel_ = new HintingModeComboBoxModel;
    
    259
    +  hintingModeComboBox_ = new QComboBox;
    
    260
    +  hintingModeComboBox_->setModel(hintingModeComboBoxModel_);
    
    261
    +  hintingModeLabel_->setBuddy(hintingModeComboBox_);
    
    262
    +
    
    263
    +  autoHintingCheckBox_ = new QCheckBox(tr("Auto-Hinting"));
    
    264
    +  horizontalHintingCheckBox_ = new QCheckBox(tr("Horizontal Hinting"));
    
    265
    +  verticalHintingCheckBox_ = new QCheckBox(tr("Vertical Hinting"));
    
    266
    +  blueZoneHintingCheckBox_ = new QCheckBox(tr("Blue-Zone Hinting"));
    
    267
    +  segmentDrawingCheckBox_ = new QCheckBox(tr("Segment Drawing"));
    
    268
    +
    
    269
    +  antiAliasingLabel_ = new QLabel(tr("Anti-Aliasing"));
    
    270
    +  antiAliasingLabel_->setAlignment(Qt::AlignRight);
    
    271
    +
    
    272
    +  antiAliasingComboBoxModel_ = new AntiAliasingComboBoxModel;
    
    273
    +  antiAliasingComboBox_ = new QComboBox;
    
    274
    +  antiAliasingComboBox_->setModel(antiAliasingComboBoxModel_);
    
    275
    +  antiAliasingLabel_->setBuddy(antiAliasingComboBox_);
    
    276
    +
    
    277
    +  lcdFilterLabel_ = new QLabel(tr("LCD Filter"));
    
    278
    +  lcdFilterLabel_->setAlignment(Qt::AlignRight);
    
    279
    +
    
    280
    +  lcdFilterComboboxModel_ = new LCDFilterComboBoxModel;
    
    281
    +  lcdFilterComboBox_ = new QComboBox;
    
    282
    +  lcdFilterComboBox_->setModel(lcdFilterComboboxModel_);
    
    283
    +  lcdFilterLabel_->setBuddy(lcdFilterComboBox_);
    
    284
    +
    
    285
    +  int width;
    
    286
    +  // make all labels have the same width
    
    287
    +  width = hintingModeLabel_->minimumSizeHint().width();
    
    288
    +  width = qMax(antiAliasingLabel_->minimumSizeHint().width(), width);
    
    289
    +  width = qMax(lcdFilterLabel_->minimumSizeHint().width(), width);
    
    290
    +  hintingModeLabel_->setMinimumWidth(width);
    
    291
    +  antiAliasingLabel_->setMinimumWidth(width);
    
    292
    +  lcdFilterLabel_->setMinimumWidth(width);
    
    293
    +
    
    294
    +  // ensure that all items in combo boxes fit completely;
    
    295
    +  // also make all combo boxes have the same width
    
    296
    +  width = hintingModeComboBox_->minimumSizeHint().width();
    
    297
    +  width = qMax(antiAliasingComboBox_->minimumSizeHint().width(), width);
    
    298
    +  width = qMax(lcdFilterComboBox_->minimumSizeHint().width(), width);
    
    299
    +  hintingModeComboBox_->setMinimumWidth(width);
    
    300
    +  antiAliasingComboBox_->setMinimumWidth(width);
    
    301
    +  lcdFilterComboBox_->setMinimumWidth(width);
    
    302
    +
    
    303
    +  gammaLabel_ = new QLabel(tr("Gamma"));
    
    304
    +  gammaLabel_->setAlignment(Qt::AlignRight);
    
    305
    +  gammaSlider_ = new QSlider(Qt::Horizontal);
    
    306
    +  gammaSlider_->setRange(0, 30); // in 1/10th
    
    307
    +  gammaSlider_->setTickPosition(QSlider::TicksBelow);
    
    308
    +  gammaSlider_->setTickInterval(5);
    
    309
    +  gammaLabel_->setBuddy(gammaSlider_);
    
    310
    +
    
    311
    +  showBitmapCheckBox_ = new QCheckBox(tr("Show Bitmap"));
    
    312
    +  showPointsCheckBox_ = new QCheckBox(tr("Show Points"));
    
    313
    +  showPointNumbersCheckBox_ = new QCheckBox(tr("Show Point Numbers"));
    
    314
    +  showOutlinesCheckBox_ = new QCheckBox(tr("Show Outlines"));
    
    315
    +
    
    316
    +  hintingModeLayout_ = new QHBoxLayout;
    
    317
    +  hintingModeLayout_->addWidget(hintingModeLabel_);
    
    318
    +  hintingModeLayout_->addWidget(hintingModeComboBox_);
    
    319
    +
    
    320
    +  horizontalHintingLayout_ = new QHBoxLayout;
    
    321
    +  horizontalHintingLayout_->addSpacing(20); // XXX px
    
    322
    +  horizontalHintingLayout_->addWidget(horizontalHintingCheckBox_);
    
    323
    +
    
    324
    +  verticalHintingLayout_ = new QHBoxLayout;
    
    325
    +  verticalHintingLayout_->addSpacing(20); // XXX px
    
    326
    +  verticalHintingLayout_->addWidget(verticalHintingCheckBox_);
    
    327
    +
    
    328
    +  blueZoneHintingLayout_ = new QHBoxLayout;
    
    329
    +  blueZoneHintingLayout_->addSpacing(20); // XXX px
    
    330
    +  blueZoneHintingLayout_->addWidget(blueZoneHintingCheckBox_);
    
    331
    +
    
    332
    +  segmentDrawingLayout_ = new QHBoxLayout;
    
    333
    +  segmentDrawingLayout_->addSpacing(20); // XXX px
    
    334
    +  segmentDrawingLayout_->addWidget(segmentDrawingCheckBox_);
    
    335
    +
    
    336
    +  antiAliasingLayout_ = new QHBoxLayout;
    
    337
    +  antiAliasingLayout_->addWidget(antiAliasingLabel_);
    
    338
    +  antiAliasingLayout_->addWidget(antiAliasingComboBox_);
    
    339
    +
    
    340
    +  lcdFilterLayout_ = new QHBoxLayout;
    
    341
    +  lcdFilterLayout_->addWidget(lcdFilterLabel_);
    
    342
    +  lcdFilterLayout_->addWidget(lcdFilterComboBox_);
    
    343
    +
    
    344
    +  gammaLayout_ = new QHBoxLayout;
    
    345
    +  gammaLayout_->addWidget(gammaLabel_);
    
    346
    +  gammaLayout_->addWidget(gammaSlider_);
    
    347
    +
    
    348
    +  pointNumbersLayout_ = new QHBoxLayout;
    
    349
    +  pointNumbersLayout_->addSpacing(20); // XXX px
    
    350
    +  pointNumbersLayout_->addWidget(showPointNumbersCheckBox_);
    
    351
    +
    
    352
    +  generalTabLayout_ = new QVBoxLayout;
    
    353
    +  generalTabLayout_->addWidget(hintingCheckBox_);
    
    354
    +  generalTabLayout_->addLayout(hintingModeLayout_);
    
    355
    +  generalTabLayout_->addWidget(autoHintingCheckBox_);
    
    356
    +  generalTabLayout_->addLayout(horizontalHintingLayout_);
    
    357
    +  generalTabLayout_->addLayout(verticalHintingLayout_);
    
    358
    +  generalTabLayout_->addLayout(blueZoneHintingLayout_);
    
    359
    +  generalTabLayout_->addLayout(segmentDrawingLayout_);
    
    360
    +  generalTabLayout_->addSpacing(20); // XXX px
    
    361
    +  generalTabLayout_->addStretch(1);
    
    362
    +  generalTabLayout_->addLayout(antiAliasingLayout_);
    
    363
    +  generalTabLayout_->addLayout(lcdFilterLayout_);
    
    364
    +  generalTabLayout_->addSpacing(20); // XXX px
    
    365
    +  generalTabLayout_->addStretch(1);
    
    366
    +  generalTabLayout_->addLayout(gammaLayout_);
    
    367
    +  generalTabLayout_->addSpacing(20); // XXX px
    
    368
    +  generalTabLayout_->addStretch(1);
    
    369
    +  generalTabLayout_->addWidget(showBitmapCheckBox_);
    
    370
    +  generalTabLayout_->addWidget(showPointsCheckBox_);
    
    371
    +  generalTabLayout_->addLayout(pointNumbersLayout_);
    
    372
    +  generalTabLayout_->addWidget(showOutlinesCheckBox_);
    
    373
    +
    
    374
    +  generalTab_ = new QWidget;
    
    375
    +  generalTab_->setLayout(generalTabLayout_);
    
    376
    +
    
    377
    +  mmgxTab_ = new QWidget;
    
    378
    +
    
    379
    +  tab_ = new QTabWidget;
    
    380
    +  tab_->addTab(generalTab_, tr("General"));
    
    381
    +  tab_->addTab(mmgxTab_, tr("MM/GX"));
    
    382
    +
    
    383
    +  mainLayout_ = new QVBoxLayout;
    
    384
    +  mainLayout_->addWidget(tab_);
    
    385
    +  setLayout(mainLayout_);
    
    386
    +}
    
    387
    +
    
    388
    +
    
    389
    +void
    
    390
    +SettingPanel::setDefaults()
    
    391
    +{
    
    392
    +  Engine::EngineDefaultValues& defaults = engine_->engineDefaults();
    
    393
    +
    
    394
    +  hintingModeComboBoxModel_->setSupportedModes(
    
    395
    +    { defaults.ttInterpreterVersionDefault,
    
    396
    +      defaults.ttInterpreterVersionOther,
    
    397
    +      defaults.ttInterpreterVersionOther1 },
    
    398
    +    { defaults.cffHintingEngineDefault, 
    
    399
    +      defaults.cffHintingEngineOther });
    
    400
    +
    
    401
    +  currentCFFHintingMode_
    
    402
    +    = hintingModeComboBoxModel_->cffModeToIndex(
    
    403
    +    defaults.cffHintingEngineDefault);
    
    404
    +  currentTTInterpreterVersion_
    
    405
    +    = hintingModeComboBoxModel_->ttInterpreterVersionToIndex(
    
    406
    +        defaults.ttInterpreterVersionDefault);
    
    407
    +
    
    408
    +  hintingCheckBox_->setChecked(true);
    
    409
    +
    
    410
    +  antiAliasingComboBox_->setCurrentIndex(
    
    411
    +    AntiAliasingComboBoxModel::AntiAliasing_Normal);
    
    412
    +  lcdFilterComboBox_->setCurrentIndex(
    
    413
    +    LCDFilterComboBoxModel::LCDFilter_Light);
    
    414
    +
    
    415
    +  horizontalHintingCheckBox_->setChecked(true);
    
    416
    +  verticalHintingCheckBox_->setChecked(true);
    
    417
    +  blueZoneHintingCheckBox_->setChecked(true);
    
    418
    +
    
    419
    +  showBitmapCheckBox_->setChecked(true);
    
    420
    +  showOutlinesCheckBox_->setChecked(true);
    
    421
    +
    
    422
    +  gammaSlider_->setValue(18); // 1.8
    
    423
    +}
    
    424
    +
    
    425
    +
    
    426
    +// 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 checkAutoHinting();
    
    44
    +  void checkAntiAliasing();
    
    45
    +  void checkShowPoints();
    
    46
    +  void checkLCDFilter();
    
    47
    +
    
    48
    +private:
    
    49
    +  Engine* engine_;
    
    50
    +
    
    51
    +  int currentCFFHintingMode_;
    
    52
    +  int currentTTInterpreterVersion_;
    
    53
    +
    
    54
    +  QTabWidget* tab_;
    
    55
    +
    
    56
    +  QWidget* generalTab_;
    
    57
    +  QWidget* mmgxTab_;
    
    58
    +
    
    59
    +  QLabel* gammaLabel_;
    
    60
    +  QLabel* antiAliasingLabel_;
    
    61
    +  QLabel* hintingModeLabel_;
    
    62
    +  QLabel* lcdFilterLabel_;
    
    63
    +
    
    64
    +  QCheckBox* hintingCheckBox_;
    
    65
    +  QCheckBox* horizontalHintingCheckBox_;
    
    66
    +  QCheckBox* verticalHintingCheckBox_;
    
    67
    +  QCheckBox* blueZoneHintingCheckBox_;
    
    68
    +  QCheckBox* segmentDrawingCheckBox_;
    
    69
    +  QCheckBox* autoHintingCheckBox_;
    
    70
    +  QCheckBox* showBitmapCheckBox_;
    
    71
    +  QCheckBox* showOutlinesCheckBox_;
    
    72
    +  QCheckBox* showPointNumbersCheckBox_;
    
    73
    +  QCheckBox* showPointsCheckBox_;
    
    74
    +
    
    75
    +  AntiAliasingComboBoxModel* antiAliasingComboBoxModel_;
    
    76
    +  HintingModeComboBoxModel* hintingModeComboBoxModel_;
    
    77
    +  LCDFilterComboBoxModel* lcdFilterComboboxModel_;
    
    78
    +
    
    79
    +  QComboBox* hintingModeComboBox_;
    
    80
    +  QComboBox* antiAliasingComboBox_;
    
    81
    +  QComboBox* lcdFilterComboBox_;
    
    82
    +
    
    83
    +  QSlider* gammaSlider_;
    
    84
    +
    
    85
    +  QVBoxLayout* mainLayout_;
    
    86
    +  QHBoxLayout* hintingModeLayout_;
    
    87
    +  QHBoxLayout* horizontalHintingLayout_;
    
    88
    +  QHBoxLayout* verticalHintingLayout_;
    
    89
    +  QHBoxLayout* blueZoneHintingLayout_;
    
    90
    +  QHBoxLayout* segmentDrawingLayout_;
    
    91
    +  QHBoxLayout* antiAliasingLayout_;
    
    92
    +  QHBoxLayout* lcdFilterLayout_;
    
    93
    +  QHBoxLayout* gammaLayout_;
    
    94
    +  QHBoxLayout* pointNumbersLayout_;
    
    95
    +
    
    96
    +  QVBoxLayout* generalTabLayout_;
    
    97
    +
    
    98
    +  void createConnections();
    
    99
    +  void createLayout();
    
    100
    +  void setDefaults();
    
    101
    +};
    
    102
    +
    
    103
    +
    
    104
    +// end of settingpanel.hpp


  • reply via email to

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