freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype-demos][gsoc-2022-chariri-3] [ftinspect] Support


From: Charlie Jiang (@cqjjjzr)
Subject: [Git][freetype/freetype-demos][gsoc-2022-chariri-3] [ftinspect] Support MM/GX.
Date: Sun, 21 Aug 2022 15:19:53 +0000

Charlie Jiang pushed to branch gsoc-2022-chariri-3 at FreeType / FreeType Demo Programs

Commits:

  • 54761bec
    by Charlie Jiang at 2022-08-21T23:19:37+08:00
    [ftinspect] Support MM/GX.
    
    Currently the "Reset Default" is problematic due to rounding issue.
    
    * src/ftinspect/panels/settingpanelmmgx.cpp,
      src/ftinspect/panels/settingpanelmmgx.hpp:
      New file, containing the MM/GX setting tab.
    
    * src/ftinspect/panels/settingpanel.cpp,
      src/ftinspect/panels/settingpanel.hpp: Integrate the `SettingPanelMMGX`..
    
    * src/ftinspect/engine/engine.cpp, src/ftinspect/engine/engine.hpp:
      Add `applyMMGXDesignCoords` function, and move all cache resetting code
      to a new function `resetCache`.
    
    * src/ftinspect/engine/mmgx.cpp, src/ftinspect/engine/mmgx.hpp
      Add `isMM` field.
    
    * src/ftinspect/maingui.cpp: Force reset cache when reloading fonts.
    
    * src/ftinspect/CMakeLists.txt, src/ftinspect/meson.build: Updated.
    

11 changed files:

Changes:

  • src/ftinspect/CMakeLists.txt
    ... ... @@ -48,6 +48,7 @@ add_executable(ftinspect
    48 48
       "models/fontinfomodels.cpp"
    
    49 49
     
    
    50 50
       "panels/settingpanel.cpp"
    
    51
    +  "panels/settingpanelmmgx.cpp"
    
    51 52
       "panels/singular.cpp"
    
    52 53
       "panels/continuous.cpp"
    
    53 54
       "panels/comparator.cpp"
    

  • src/ftinspect/engine/engine.cpp
    ... ... @@ -16,6 +16,7 @@
    16 16
     #include <freetype/ftdriver.h>
    
    17 17
     #include <freetype/ftlcdfil.h>
    
    18 18
     #include <freetype/ftbitmap.h>
    
    19
    +#include <freetype/ftmm.h>
    
    19 20
     
    
    20 21
     
    
    21 22
     /////////////////////////////////////////////////////////////////////////////
    
    ... ... @@ -743,12 +744,7 @@ Engine::setCFFHintingMode(int mode)
    743 744
                                        "hinting-engine",
    
    744 745
                                        &mode);
    
    745 746
       if (!error)
    
    746
    -  {
    
    747
    -    // reset the cache
    
    748
    -    FTC_Manager_Reset(cacheManager_);
    
    749
    -    ftFallbackFace_ = NULL;
    
    750
    -    ftSize_ = NULL;
    
    751
    -  }
    
    747
    +    resetCache();
    
    752 748
     }
    
    753 749
     
    
    754 750
     
    
    ... ... @@ -760,19 +756,13 @@ Engine::setTTInterpreterVersion(int version)
    760 756
                                        "interpreter-version",
    
    761 757
                                        &version);
    
    762 758
       if (!error)
    
    763
    -  {
    
    764
    -    // reset the cache
    
    765
    -    FTC_Manager_Reset(cacheManager_);
    
    766
    -    ftFallbackFace_ = NULL;
    
    767
    -    ftSize_ = NULL;
    
    768
    -  }
    
    759
    +    resetCache();
    
    769 760
     }
    
    770 761
     
    
    771 762
     
    
    772 763
     void
    
    773 764
     Engine::setStemDarkening(bool darkening)
    
    774 765
     {
    
    775
    -  // TODO not working
    
    776 766
       FT_Bool noDarkening = !darkening;
    
    777 767
       FT_Property_Set(library_,
    
    778 768
                       "cff",
    
    ... ... @@ -790,10 +780,20 @@ Engine::setStemDarkening(bool darkening)
    790 780
                       "t1cid",
    
    791 781
                       "no-stem-darkening",
    
    792 782
                       &noDarkening);
    
    793
    -  // reset the cache
    
    794
    -  FTC_Manager_Reset(cacheManager_);
    
    795
    -  ftFallbackFace_ = NULL;
    
    796
    -  ftSize_ = NULL;
    
    783
    +  resetCache();
    
    784
    +}
    
    785
    +
    
    786
    +
    
    787
    +void
    
    788
    +Engine::applyMMGXDesignCoords(FT_Fixed* coords,
    
    789
    +                              size_t count)
    
    790
    +{
    
    791
    +  if (!ftSize_)
    
    792
    +    return;
    
    793
    +  if (count >= UINT_MAX)
    
    794
    +    count = UINT_MAX - 1;
    
    795
    +  FT_Set_Var_Design_Coordinates(ftSize_->face,
    
    796
    +                                static_cast<unsigned>(count), coords);
    
    797 797
     }
    
    798 798
     
    
    799 799
     
    
    ... ... @@ -866,6 +866,16 @@ Engine::update()
    866 866
     }
    
    867 867
     
    
    868 868
     
    
    869
    +void
    
    870
    +Engine::resetCache()
    
    871
    +{
    
    872
    +  // reset the cache
    
    873
    +  FTC_Manager_Reset(cacheManager_);
    
    874
    +  ftFallbackFace_ = NULL;
    
    875
    +  ftSize_ = NULL;
    
    876
    +}
    
    877
    +
    
    878
    +
    
    869 879
     void
    
    870 880
     Engine::queryEngine()
    
    871 881
     {
    

  • src/ftinspect/engine/engine.hpp
    ... ... @@ -122,6 +122,7 @@ public:
    122 122
       void removeFont(int fontIndex, bool closeFile = true);
    
    123 123
       
    
    124 124
       void update();
    
    125
    +  void resetCache();
    
    125 126
     
    
    126 127
       //////// Getters
    
    127 128
     
    
    ... ... @@ -210,7 +211,9 @@ public:
    210 211
       void setLcdFilter(FT_LcdFilter filter);
    
    211 212
       void setCFFHintingMode(int mode);
    
    212 213
       void setTTInterpreterVersion(int version);
    
    214
    +
    
    213 215
       void setStemDarkening(bool darkening);
    
    216
    +  void applyMMGXDesignCoords(FT_Fixed* coords, size_t count);
    
    214 217
     
    
    215 218
       void setForeground(QRgb foreground);
    
    216 219
       void setBackground(QRgb background);
    

  • src/ftinspect/engine/mmgx.cpp
    ... ... @@ -48,6 +48,7 @@ MMGXAxisInfo::get(Engine* engine,
    48 48
         info.minimum = axis.minimum / 65536.0;
    
    49 49
         info.def = axis.def / 65536.0;
    
    50 50
         info.tag = axis.tag;
    
    51
    +    info.isMM = state == MMGXState::MM;
    
    51 52
     
    
    52 53
         unsigned int flags = 0;
    
    53 54
         FT_Get_Var_Axis_Flags(mm, i, &flags);
    
    ... ... @@ -78,5 +79,5 @@ MMGXAxisInfo::get(Engine* engine,
    78 79
       return state;
    
    79 80
     }
    
    80 81
     
    
    81
    -// end of mmgx.cpp
    
    82 82
     
    
    83
    +// end of mmgx.cpp

  • src/ftinspect/engine/mmgx.hpp
    ... ... @@ -26,6 +26,7 @@ struct MMGXAxisInfo
    26 26
       double def;
    
    27 27
     
    
    28 28
       bool hidden;
    
    29
    +  bool isMM;
    
    29 30
     
    
    30 31
       static MMGXState get(Engine* engine, std::vector<MMGXAxisInfo>& infos);
    
    31 32
     
    
    ... ... @@ -39,7 +40,8 @@ struct MMGXAxisInfo
    39 40
           && lhs.minimum == rhs.minimum
    
    40 41
           && lhs.maximum == rhs.maximum
    
    41 42
           && lhs.def == rhs.def
    
    42
    -      && lhs.hidden == rhs.hidden;
    
    43
    +      && lhs.hidden == rhs.hidden
    
    44
    +      && lhs.isMM == rhs.isMM;
    
    43 45
       }
    
    44 46
     
    
    45 47
     
    

  • src/ftinspect/maingui.cpp
    ... ... @@ -206,6 +206,7 @@ MainGUI::repaintCurrentTab()
    206 206
     void
    
    207 207
     MainGUI::reloadCurrentTabFont()
    
    208 208
     {
    
    209
    +  engine_->resetCache();
    
    209 210
       syncSettings();
    
    210 211
       tabs_[tabWidget_->currentIndex()]->reloadFont();
    
    211 212
     }
    

  • src/ftinspect/meson.build
    ... ... @@ -48,6 +48,7 @@ if qt5_dep.found()
    48 48
         'models/fontinfomodels.cpp',
    
    49 49
     
    
    50 50
         'panels/settingpanel.cpp',
    
    51
    +    'panels/settingpanelmmgx.cpp',
    
    51 52
         'panels/singular.cpp',
    
    52 53
         'panels/continuous.cpp',
    
    53 54
         'panels/comparator.cpp',
    
    ... ... @@ -72,6 +73,7 @@ if qt5_dep.found()
    72 73
           'models/customcomboboxmodels.hpp',
    
    73 74
           'models/fontinfomodels.hpp',
    
    74 75
           'panels/settingpanel.hpp',
    
    76
    +      'panels/settingpanelmmgx.hpp',
    
    75 77
           'panels/singular.hpp',
    
    76 78
           'panels/continuous.hpp',
    
    77 79
           'panels/comparator.hpp',
    

  • src/ftinspect/panels/settingpanel.cpp
    ... ... @@ -111,6 +111,7 @@ SettingPanel::onFontChanged()
    111 111
       }
    
    112 112
     
    
    113 113
       populatePalettes();
    
    114
    +  mmgxPanel_->reloadFont();
    
    114 115
       blockSignals(blockState);
    
    115 116
     }
    
    116 117
     
    
    ... ... @@ -364,6 +365,7 @@ SettingPanel::syncSettings()
    364 365
     
    
    365 366
       engine_->setForeground(foregroundColor_.rgba());
    
    366 367
       engine_->setBackground(backgroundColor_.rgba());
    
    368
    +  mmgxPanel_->syncSettings();
    
    367 369
     }
    
    368 370
     
    
    369 371
     
    
    ... ... @@ -426,6 +428,9 @@ SettingPanel::createConnections()
    426 428
         connect(foregroundButton_, &QPushButton::clicked,
    
    427 429
                 this, &SettingPanel::openForegroundPicker);
    
    428 430
       }
    
    431
    +
    
    432
    +  connect(mmgxPanel_, &SettingPanelMMGX::mmgxCoordsChanged,
    
    433
    +          this, &SettingPanel::fontReloadNeeded);
    
    429 434
     }
    
    430 435
     
    
    431 436
     
    
    ... ... @@ -510,6 +515,8 @@ SettingPanel::createLayout()
    510 515
       gammaLabel_->setBuddy(gammaSlider_);
    
    511 516
       gammaValueLabel_ = new QLabel(this);
    
    512 517
     
    
    518
    +  mmgxPanel_ = new SettingPanelMMGX(this, engine_);
    
    519
    +
    
    513 520
       if (!comparatorMode_)
    
    514 521
       {
    
    515 522
         backgroundButton_ = new QPushButton(tr("Background"), this);
    
    ... ... @@ -517,7 +524,6 @@ SettingPanel::createLayout()
    517 524
       }
    
    518 525
     
    
    519 526
       generalTab_ = new QWidget(this);
    
    520
    -  mmgxTab_ = new QWidget(this);
    
    521 527
     
    
    522 528
       generalTab_->setSizePolicy(QSizePolicy::MinimumExpanding,
    
    523 529
                                  QSizePolicy::MinimumExpanding);
    
    ... ... @@ -602,7 +608,7 @@ SettingPanel::createLayoutNormal()
    602 608
       generalTab_->setLayout(generalTabLayout_);
    
    603 609
     
    
    604 610
       tab_->addTab(generalTab_, tr("General"));
    
    605
    -  tab_->addTab(mmgxTab_, tr("MM/GX"));
    
    611
    +  tab_->addTab(mmgxPanel_, tr("MM/GX"));
    
    606 612
     }
    
    607 613
     
    
    608 614
     
    
    ... ... @@ -647,7 +653,7 @@ SettingPanel::createLayoutComperator()
    647 653
     
    
    648 654
       tab_->addTab(hintingRenderingTab_, tr("Hinting && Rendering"));
    
    649 655
       tab_->addTab(generalTab_, tr("General"));
    
    650
    -  tab_->addTab(mmgxTab_, tr("MM/GX"));
    
    656
    +  tab_->addTab(mmgxPanel_, tr("MM/GX"));
    
    651 657
       setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum);
    
    652 658
     }
    
    653 659
     
    

  • src/ftinspect/panels/settingpanel.hpp
    ... ... @@ -4,6 +4,7 @@
    4 4
     
    
    5 5
     #pragma once
    
    6 6
     
    
    7
    +#include "settingpanelmmgx.hpp"
    
    7 8
     #include "../engine/engine.hpp"
    
    8 9
     #include "../models/customcomboboxmodels.hpp"
    
    9 10
     
    
    ... ... @@ -76,7 +77,7 @@ private:
    76 77
     
    
    77 78
       QWidget* generalTab_;
    
    78 79
       QWidget* hintingRenderingTab_;
    
    79
    -  QWidget* mmgxTab_;
    
    80
    +  SettingPanelMMGX* mmgxPanel_;
    
    80 81
     
    
    81 82
       QLabel* gammaLabel_;
    
    82 83
       QLabel* gammaValueLabel_;
    

  • src/ftinspect/panels/settingpanelmmgx.cpp
    1
    +// settingpanelmmgx.cpp
    
    2
    +
    
    3
    +// Copyright (C) 2022 by Charlie Jiang.
    
    4
    +
    
    5
    +#include "settingpanelmmgx.hpp"
    
    6
    +
    
    7
    +#include <QScrollBar>
    
    8
    +
    
    9
    +#include "../engine/engine.hpp"
    
    10
    +
    
    11
    +SettingPanelMMGX::SettingPanelMMGX(QWidget* parent,
    
    12
    +                                   Engine* engine)
    
    13
    +: QWidget(parent),
    
    14
    +  engine_(engine)
    
    15
    +{
    
    16
    +  createLayout();
    
    17
    +  createConnections();
    
    18
    +}
    
    19
    +
    
    20
    +
    
    21
    +void
    
    22
    +SettingPanelMMGX::reloadFont()
    
    23
    +{
    
    24
    +  setEnabled(engine_->currentFontMMGXState() != MMGXState::NoMMGX);
    
    25
    +  if (currentAxes_ == engine_->currentFontMMGXAxes())
    
    26
    +    return;
    
    27
    +
    
    28
    +  currentAxes_ = engine_->currentFontMMGXAxes();
    
    29
    +
    
    30
    +  auto newSize = currentAxes_.size();
    
    31
    +  auto oldSize = itemWidgets_.size();
    
    32
    +  auto minSize = std::min(newSize, oldSize);
    
    33
    +
    
    34
    +  // This won't trigger unexpected updating since signals are blocked
    
    35
    +  for (size_t i = 0; i < minSize; ++i)
    
    36
    +    itemWidgets_[i]->updateInfo(currentAxes_[i]);
    
    37
    +
    
    38
    +  if (newSize < oldSize)
    
    39
    +  {
    
    40
    +    for (size_t i = oldSize; i < newSize; ++i)
    
    41
    +    {
    
    42
    +      auto w = itemWidgets_[i];
    
    43
    +      disconnect(w);
    
    44
    +      listLayout_->removeWidget(w);
    
    45
    +      delete w;
    
    46
    +    }
    
    47
    +    itemWidgets_.resize(newSize);
    
    48
    +  }
    
    49
    +  else if (newSize > oldSize)
    
    50
    +  {
    
    51
    +    itemWidgets_.resize(newSize);
    
    52
    +    for (size_t i = oldSize; i < newSize; ++i)
    
    53
    +    {
    
    54
    +      auto w = new MMGXSettingItem(this);
    
    55
    +      itemWidgets_[i] = w;
    
    56
    +      w->updateInfo(currentAxes_[i]);
    
    57
    +      listLayout_->addWidget(w);
    
    58
    +      connect(w, &MMGXSettingItem::valueChanged,
    
    59
    +              this, &SettingPanelMMGX::itemChanged);
    
    60
    +    }
    
    61
    +  }
    
    62
    +  checkHidden();
    
    63
    +}
    
    64
    +
    
    65
    +
    
    66
    +void
    
    67
    +SettingPanelMMGX::syncSettings()
    
    68
    +{
    
    69
    +  engine_->reloadFont();
    
    70
    +  engine_->applyMMGXDesignCoords(currentValues_.data(),
    
    71
    +                                 currentValues_.size());
    
    72
    +}
    
    73
    +
    
    74
    +
    
    75
    +void
    
    76
    +SettingPanelMMGX::checkHidden()
    
    77
    +{
    
    78
    +  if (itemWidgets_.size() < currentAxes_.size())
    
    79
    +    return; // This should never happen!
    
    80
    +  for (int i = 0; static_cast<size_t>(i) < currentAxes_.size(); ++i)
    
    81
    +    itemWidgets_[i]->setVisible(showHiddenCheckBox_->isChecked()
    
    82
    +                                || !currentAxes_[i].hidden);
    
    83
    +}
    
    84
    +
    
    85
    +
    
    86
    +void
    
    87
    +SettingPanelMMGX::createLayout()
    
    88
    +{
    
    89
    +  showHiddenCheckBox_ = new QCheckBox(tr("Show Hidden"), this);
    
    90
    +  resetDefaultButton_ = new QPushButton(tr("Reset Default"), this);
    
    91
    +  itemsListWidget_ = new QWidget(this);
    
    92
    +  scrollArea_ = new UnboundScrollArea(this);
    
    93
    +
    
    94
    +  scrollArea_->setWidget(itemsListWidget_);
    
    95
    +  scrollArea_->setWidgetResizable(true);
    
    96
    +  scrollArea_->setStyleSheet("QScrollArea {background-color:transparent;}");
    
    97
    +  itemsListWidget_->setStyleSheet("background-color:transparent;");
    
    98
    +
    
    99
    +  mainLayout_ = new QVBoxLayout;
    
    100
    +  listLayout_ = new QVBoxLayout;
    
    101
    +  listWrapperLayout_ = new QVBoxLayout;
    
    102
    +
    
    103
    +  listLayout_->setContentsMargins(0, 0, 0, 0);
    
    104
    +  itemsListWidget_->setContentsMargins(0, 0, 0, 0);
    
    105
    +
    
    106
    +  itemsListWidget_->setLayout(listWrapperLayout_);
    
    107
    +
    
    108
    +  listWrapperLayout_->addLayout(listLayout_);
    
    109
    +  listWrapperLayout_->addStretch(1);
    
    110
    +
    
    111
    +  mainLayout_->addWidget(showHiddenCheckBox_);
    
    112
    +  mainLayout_->addWidget(resetDefaultButton_);
    
    113
    +  mainLayout_->addWidget(scrollArea_, 1);
    
    114
    +
    
    115
    +  setLayout(mainLayout_);
    
    116
    +}
    
    117
    +
    
    118
    +
    
    119
    +void
    
    120
    +SettingPanelMMGX::createConnections()
    
    121
    +{
    
    122
    +  connect(showHiddenCheckBox_, &QCheckBox::clicked,
    
    123
    +          this, &SettingPanelMMGX::checkHidden);
    
    124
    +  connect(resetDefaultButton_, &QCheckBox::clicked,
    
    125
    +          this, &SettingPanelMMGX::resetDefaultClicked);
    
    126
    +}
    
    127
    +
    
    128
    +
    
    129
    +void
    
    130
    +SettingPanelMMGX::itemChanged()
    
    131
    +{
    
    132
    +  currentValues_.resize(currentAxes_.size());
    
    133
    +  for (unsigned i = 0; i < currentAxes_.size(); ++i)
    
    134
    +    currentValues_[i] = itemWidgets_[i]->value();
    
    135
    +
    
    136
    +  emit mmgxCoordsChanged();
    
    137
    +}
    
    138
    +
    
    139
    +
    
    140
    +void
    
    141
    +SettingPanelMMGX::resetDefaultClicked()
    
    142
    +{
    
    143
    +  for (auto w : itemWidgets_)
    
    144
    +    w->resetDefault();
    
    145
    +  itemChanged();
    
    146
    +}
    
    147
    +
    
    148
    +
    
    149
    +MMGXSettingItem::MMGXSettingItem(QWidget* parent)
    
    150
    +: QFrame(parent)
    
    151
    +{
    
    152
    +  createLayout();
    
    153
    +  createConnections();
    
    154
    +}
    
    155
    +
    
    156
    +
    
    157
    +void
    
    158
    +MMGXSettingItem::updateInfo(MMGXAxisInfo& info)
    
    159
    +{
    
    160
    +  axisInfo_ = info;
    
    161
    +  if (info.hidden)
    
    162
    +    nameLabel_->setText("<i>" + info.name + "</i>");
    
    163
    +  else
    
    164
    +    nameLabel_->setText(info.name);
    
    165
    +
    
    166
    +  // To keep things simple, we will use 1/1024 of the span between the min and
    
    167
    +  // max as one step on the slider.
    
    168
    +
    
    169
    +  slider_->setMinimum(0);
    
    170
    +  slider_->setTickInterval(1);
    
    171
    +  slider_->setMaximum(1024);
    
    172
    +
    
    173
    +  resetDefault();
    
    174
    +}
    
    175
    +
    
    176
    +
    
    177
    +void
    
    178
    +MMGXSettingItem::resetDefault()
    
    179
    +{
    
    180
    +  QSignalBlocker blocker(this);
    
    181
    +  slider_->setValue(static_cast<int>((axisInfo_.def - axisInfo_.minimum)
    
    182
    +                                     / (axisInfo_.maximum - axisInfo_.minimum)
    
    183
    +                                     * 1024));
    
    184
    +}
    
    185
    +
    
    186
    +
    
    187
    +void
    
    188
    +MMGXSettingItem::createLayout()
    
    189
    +{
    
    190
    +  nameLabel_ = new QLabel(this);
    
    191
    +  valueLabel_ = new QLabel(this);
    
    192
    +  slider_ = new QSlider(this);
    
    193
    +  slider_->setOrientation(Qt::Horizontal);
    
    194
    +
    
    195
    +  mainLayout_ = new QGridLayout();
    
    196
    +
    
    197
    +  mainLayout_->addWidget(nameLabel_, 0, 0);
    
    198
    +  mainLayout_->addWidget(valueLabel_, 0, 1, 1, 1, Qt::AlignRight);
    
    199
    +  mainLayout_->addWidget(slider_, 1, 0, 1, 2);
    
    200
    +
    
    201
    +  mainLayout_->setContentsMargins(4, 4, 4, 4);
    
    202
    +  setContentsMargins(4, 4, 4, 4);
    
    203
    +  setLayout(mainLayout_);
    
    204
    +  setFrameShape(StyledPanel);
    
    205
    +}
    
    206
    +
    
    207
    +
    
    208
    +void
    
    209
    +MMGXSettingItem::createConnections()
    
    210
    +{
    
    211
    +  connect(slider_, &QSlider::valueChanged,
    
    212
    +          this, &MMGXSettingItem::sliderValueChanged);
    
    213
    +}
    
    214
    +
    
    215
    +
    
    216
    +void
    
    217
    +MMGXSettingItem::sliderValueChanged()
    
    218
    +{
    
    219
    +  auto value = slider_->value() / 1024.0
    
    220
    +               * (axisInfo_.maximum - axisInfo_.minimum)
    
    221
    +               + axisInfo_.minimum;
    
    222
    +  actualValue_ = static_cast<FT_Fixed>(value * 65536.0);
    
    223
    +
    
    224
    +  if (axisInfo_.isMM)
    
    225
    +    actualValue_ = FT_RoundFix(actualValue_);
    
    226
    +  else
    
    227
    +  {
    
    228
    +    double x = actualValue_ / 65536.0 * 100.0;
    
    229
    +    x += x < 0.0 ? -0.5 : 0.5;
    
    230
    +    x = static_cast<int>(x);
    
    231
    +    x = x / 100.0 * 65536.0;
    
    232
    +    x += x < 0.0 ? -0.5 : 0.5;
    
    233
    +
    
    234
    +    actualValue_ = static_cast<FT_Fixed>(x);
    
    235
    +  }
    
    236
    +
    
    237
    +  valueLabel_->setText(QString::number(actualValue_ / 65536.0));
    
    238
    +
    
    239
    +  emit valueChanged();
    
    240
    +}
    
    241
    +
    
    242
    +
    
    243
    +// end of settingpanelmmgx.cpp

  • src/ftinspect/panels/settingpanelmmgx.hpp
    1
    +// settingpanelmmgx.hpp
    
    2
    +
    
    3
    +// Copyright (C) 2022 by Charlie Jiang.
    
    4
    +
    
    5
    +#pragma once
    
    6
    +
    
    7
    +#include "../engine/mmgx.hpp"
    
    8
    +#include "../widgets/customwidgets.hpp"
    
    9
    +
    
    10
    +#include <QWidget>
    
    11
    +#include <QGridLayout>
    
    12
    +#include <QBoxLayout>
    
    13
    +#include <QCheckBox>
    
    14
    +#include <QScrollArea>
    
    15
    +#include <QSlider>
    
    16
    +#include <QFrame>
    
    17
    +#include <QLabel>
    
    18
    +
    
    19
    +#include <freetype/fttypes.h>
    
    20
    +
    
    21
    +class Engine;
    
    22
    +
    
    23
    +class MMGXSettingItem;
    
    24
    +class SettingPanelMMGX
    
    25
    +: public QWidget
    
    26
    +{
    
    27
    +  Q_OBJECT
    
    28
    +public:
    
    29
    +  SettingPanelMMGX(QWidget* parent, Engine* engine);
    
    30
    +  ~SettingPanelMMGX() override = default;
    
    31
    +
    
    32
    +  void reloadFont();
    
    33
    +  void syncSettings();
    
    34
    +  void checkHidden();
    
    35
    +  std::vector<FT_Fixed>& mmgxCoords() { return currentValues_; }
    
    36
    +
    
    37
    +signals:
    
    38
    +  void mmgxCoordsChanged();
    
    39
    +
    
    40
    +private:
    
    41
    +  Engine* engine_;
    
    42
    +
    
    43
    +  QCheckBox* showHiddenCheckBox_;
    
    44
    +  QPushButton* resetDefaultButton_;
    
    45
    +  QWidget* itemsListWidget_;
    
    46
    +  UnboundScrollArea* scrollArea_;
    
    47
    +  std::vector<MMGXSettingItem*> itemWidgets_;
    
    48
    +
    
    49
    +  QVBoxLayout* mainLayout_;
    
    50
    +  QVBoxLayout* listLayout_;
    
    51
    +  QVBoxLayout* listWrapperLayout_;
    
    52
    +
    
    53
    +  std::vector<FT_Fixed> currentValues_;
    
    54
    +  std::vector<MMGXAxisInfo> currentAxes_;
    
    55
    +
    
    56
    +  void createLayout();
    
    57
    +  void createConnections();
    
    58
    +
    
    59
    +  void itemChanged();
    
    60
    +  void resetDefaultClicked();
    
    61
    +};
    
    62
    +
    
    63
    +
    
    64
    +class MMGXSettingItem
    
    65
    +: public QFrame
    
    66
    +{
    
    67
    +  Q_OBJECT
    
    68
    +public:
    
    69
    +  MMGXSettingItem(QWidget* parent);
    
    70
    +  ~MMGXSettingItem() override = default;
    
    71
    +
    
    72
    +  void updateInfo(MMGXAxisInfo& info);
    
    73
    +  FT_Fixed value() { return actualValue_; }
    
    74
    +  void resetDefault();
    
    75
    +
    
    76
    +signals:
    
    77
    +  void valueChanged();
    
    78
    +
    
    79
    +private:
    
    80
    +  QLabel* nameLabel_;
    
    81
    +  QLabel* valueLabel_;
    
    82
    +  QSlider* slider_;
    
    83
    +
    
    84
    +  QGridLayout* mainLayout_;
    
    85
    +
    
    86
    +  FT_Fixed actualValue_;
    
    87
    +  MMGXAxisInfo axisInfo_;
    
    88
    +
    
    89
    +  void createLayout();
    
    90
    +  void createConnections();
    
    91
    +  void sliderValueChanged();
    
    92
    +};
    
    93
    +
    
    94
    +
    
    95
    +// end of settingpanelmmgx.hpp


  • reply via email to

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