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] Relayout


From: Charlie Jiang (@cqjjjzr)
Subject: [Git][freetype/freetype-demos][gsoc-2022-chariri-3] [ftinspect] Relayout setting panes in the comparator view.
Date: Mon, 08 Aug 2022 13:27:39 +0000

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

Commits:

  • 2a306c98
    by Charlie Jiang at 2022-08-08T21:25:57+08:00
    [ftinspect] Relayout setting panes in the comparator view.
    
    * src/ftinspect/panels/comparator.cpp, src/ftinspect/panels/comparator.hpp:
      Remove the scroll areas and directly add the setting panels to the layout.
    
    * src/ftinspect/panels/settingpanel.cpp,
      src/ftinspect/panels/settingpanel.hpp:
      Add `createLayoutNormal` and `createLayoutComperator` functions.
      Move some options to a new tab under comparator mode.
    

6 changed files:

Changes:

  • src/ftinspect/panels/comparator.cpp
    ... ... @@ -93,17 +93,11 @@ ComperatorTab::createLayout()
    93 93
         auto frame = new QFrame(this);
    
    94 94
         auto canvas = new GlyphContinuous(frame, engine_);
    
    95 95
         auto settingPanel = new SettingPanel(this, engine_, true);
    
    96
    -    auto area = new UnboundScrollArea(this);
    
    97
    -
    
    98
    -    area->setWidget(settingPanel);
    
    99
    -    area->setWidgetResizable(true);
    
    100
    -    area->horizontalScrollBar()->setEnabled(false);
    
    101 96
         
    
    102 97
         canvas->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
    
    103
    -    area->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
    
    98
    +    settingPanel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
    
    104 99
     
    
    105 100
         canvas_.emplace_back(canvas);
    
    106
    -    settingPanelAreas_.emplace_back(area);
    
    107 101
         settingPanels_.emplace_back(settingPanel);
    
    108 102
         frames_.emplace_back(frame);
    
    109 103
     
    
    ... ... @@ -133,8 +127,8 @@ ComperatorTab::createLayout()
    133 127
       layout_->addWidget(sourceWidget_, 0, 0, 2, 1);
    
    134 128
       for (int i = 0; static_cast<unsigned>(i) < frames_.size(); ++i)
    
    135 129
         layout_->addWidget(frames_[i], 0, i + 1);
    
    136
    -  for (int i = 0; static_cast<unsigned>(i) < settingPanelAreas_.size(); ++i)
    
    137
    -    layout_->addWidget(settingPanelAreas_[i], 1, i + 1);
    
    130
    +  for (int i = 0; static_cast<unsigned>(i) < settingPanels_.size(); ++i)
    
    131
    +    layout_->addWidget(settingPanels_[i], 1, i + 1);
    
    138 132
     
    
    139 133
       layout_->setRowStretch(0, 3);
    
    140 134
       layout_->setRowStretch(1, 2);
    

  • src/ftinspect/panels/comparator.hpp
    ... ... @@ -49,7 +49,6 @@ private:
    49 49
       std::vector<GlyphContinuous*> canvas_;
    
    50 50
       std::vector<SettingPanel*> settingPanels_;
    
    51 51
       std::vector<QFrame*> frames_;
    
    52
    -  std::vector<UnboundScrollArea*> settingPanelAreas_;
    
    53 52
     
    
    54 53
       QWidget* sourceWidget_;
    
    55 54
     
    

  • src/ftinspect/panels/settingpanel.cpp
    ... ... @@ -492,6 +492,17 @@ SettingPanel::createLayout()
    492 492
         foregroundButton_ = new QPushButton(tr("Foreground"), this);
    
    493 493
       }
    
    494 494
     
    
    495
    +  generalTab_ = new QWidget(this);
    
    496
    +  mmgxTab_ = new QWidget(this);
    
    497
    +
    
    498
    +  generalTab_->setSizePolicy(QSizePolicy::MinimumExpanding,
    
    499
    +                             QSizePolicy::MinimumExpanding);
    
    500
    +
    
    501
    +  tab_ = new QTabWidget(this);
    
    502
    +  tab_->setSizePolicy(QSizePolicy::MinimumExpanding,
    
    503
    +                      QSizePolicy::MinimumExpanding);
    
    504
    +
    
    505
    +
    
    495 506
       if (debugMode_)
    
    496 507
       {
    
    497 508
         debugLayout_ = new QVBoxLayout;
    
    ... ... @@ -507,6 +518,23 @@ SettingPanel::createLayout()
    507 518
       gammaLayout_->addWidget(gammaSlider_);
    
    508 519
       gammaLayout_->addWidget(gammaValueLabel_);
    
    509 520
     
    
    521
    +  if (comparatorMode_)
    
    522
    +    createLayoutComperator();
    
    523
    +  else
    
    524
    +    createLayoutNormal();
    
    525
    +
    
    526
    +  mainLayout_ = new QVBoxLayout;
    
    527
    +  mainLayout_->addWidget(tab_);
    
    528
    +  setLayout(mainLayout_);
    
    529
    +  mainLayout_->setContentsMargins(0, 0, 0, 0);
    
    530
    +  setContentsMargins(0, 0, 0, 0);
    
    531
    +  
    
    532
    +}
    
    533
    +
    
    534
    +
    
    535
    +void
    
    536
    +SettingPanel::createLayoutNormal()
    
    537
    +{
    
    510 538
       generalTabLayout_ = new QGridLayout;
    
    511 539
     
    
    512 540
       gridLayout2ColAddWidget(generalTabLayout_, hintingCheckBox_);
    
    ... ... @@ -516,72 +544,86 @@ SettingPanel::createLayout()
    516 544
     
    
    517 545
       if (debugMode_)
    
    518 546
         gridLayout2ColAddLayout(generalTabLayout_, debugLayout_);
    
    519
    -
    
    520
    -  if (!comparatorMode_)
    
    521
    -    gridLayout2ColAddItem(generalTabLayout_,
    
    522
    -                          new QSpacerItem(0, 20, QSizePolicy::Minimum,
    
    523
    -                                          QSizePolicy::MinimumExpanding));
    
    547
    +  
    
    548
    +  gridLayout2ColAddItem(generalTabLayout_,
    
    549
    +                        new QSpacerItem(0, 20, QSizePolicy::Minimum,
    
    550
    +                                        QSizePolicy::MinimumExpanding));
    
    524 551
     
    
    525 552
       gridLayout2ColAddWidget(generalTabLayout_, 
    
    526 553
                               antiAliasingLabel_, antiAliasingComboBox_);
    
    527 554
       gridLayout2ColAddWidget(generalTabLayout_, 
    
    528 555
                               lcdFilterLabel_, lcdFilterComboBox_);
    
    556
    +  
    
    557
    +  gridLayout2ColAddItem(generalTabLayout_,
    
    558
    +                        new QSpacerItem(0, 20, QSizePolicy::Minimum,
    
    559
    +                                        QSizePolicy::MinimumExpanding));
    
    529 560
     
    
    530
    -  if (!comparatorMode_)
    
    531
    -    gridLayout2ColAddItem(generalTabLayout_,
    
    532
    -                          new QSpacerItem(0, 20, QSizePolicy::Minimum,
    
    533
    -                                          QSizePolicy::MinimumExpanding));
    
    534
    -
    
    535
    -  if (!comparatorMode_)
    
    536
    -  {
    
    537
    -    colorPickerLayout_ = new QHBoxLayout;
    
    538
    -    colorPickerLayout_->addWidget(backgroundButton_, 1);
    
    539
    -    colorPickerLayout_->addWidget(foregroundButton_, 1);
    
    540
    -    generalTabLayout_->addLayout(colorPickerLayout_,
    
    541
    -                                 generalTabLayout_->rowCount(), 
    
    542
    -                                 0, 1, 2);
    
    543
    -  }
    
    561
    +  colorPickerLayout_ = new QHBoxLayout;
    
    562
    +  colorPickerLayout_->addWidget(backgroundButton_, 1);
    
    563
    +  colorPickerLayout_->addWidget(foregroundButton_, 1);
    
    564
    +  generalTabLayout_->addLayout(colorPickerLayout_,
    
    565
    +                               generalTabLayout_->rowCount(), 0, 1, 2);
    
    544 566
     
    
    545 567
       gridLayout2ColAddLayout(generalTabLayout_, gammaLayout_);
    
    546 568
       gridLayout2ColAddWidget(generalTabLayout_, embeddedBitmapCheckBox_);
    
    547 569
       gridLayout2ColAddWidget(generalTabLayout_, colorLayerCheckBox_);
    
    548 570
       gridLayout2ColAddWidget(generalTabLayout_, 
    
    549 571
                               paletteLabel_, paletteComboBox_);
    
    550
    -
    
    551
    -  if (comparatorMode_)
    
    552
    -  {
    
    553
    -    gridLayout2ColAddWidget(generalTabLayout_, kerningCheckBox_);
    
    554
    -    gridLayout2ColAddWidget(generalTabLayout_, lsbRsbDeltaCheckBox_);
    
    555
    -  }
    
    556
    -
    
    557
    -  if (!comparatorMode_)
    
    558
    -    gridLayout2ColAddItem(generalTabLayout_,
    
    559
    -                          new QSpacerItem(0, 20, QSizePolicy::Minimum,
    
    560
    -                                          QSizePolicy::MinimumExpanding));
    
    572
    +  
    
    573
    +  gridLayout2ColAddItem(generalTabLayout_,
    
    574
    +                        new QSpacerItem(0, 20, QSizePolicy::Minimum,
    
    575
    +                                        QSizePolicy::MinimumExpanding));
    
    561 576
     
    
    562 577
       generalTabLayout_->setColumnStretch(1, 1);
    
    563
    -
    
    564
    -  generalTab_ = new QWidget(this);
    
    565 578
       generalTab_->setLayout(generalTabLayout_);
    
    566
    -  generalTab_->setSizePolicy(QSizePolicy::MinimumExpanding,
    
    567
    -                             QSizePolicy::MinimumExpanding);
    
    568
    -
    
    569
    -  mmgxTab_ = new QWidget(this);
    
    570 579
     
    
    571
    -  tab_ = new QTabWidget(this);
    
    572 580
       tab_->addTab(generalTab_, tr("General"));
    
    573 581
       tab_->addTab(mmgxTab_, tr("MM/GX"));
    
    574
    -  tab_->setSizePolicy(QSizePolicy::MinimumExpanding,
    
    575
    -                      QSizePolicy::MinimumExpanding);
    
    582
    +}
    
    576 583
     
    
    577
    -  mainLayout_ = new QVBoxLayout;
    
    578
    -  mainLayout_->addWidget(tab_);
    
    579
    -  setLayout(mainLayout_);
    
    580
    -  mainLayout_->setContentsMargins(0, 0, 0, 0);
    
    581
    -  setContentsMargins(0, 0, 0, 0);
    
    582 584
     
    
    583
    -  if (comparatorMode_)
    
    584
    -    setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum);
    
    585
    +void
    
    586
    +SettingPanel::createLayoutComperator()
    
    587
    +{
    
    588
    +  hintingRenderingTab_ = new QWidget(this);
    
    589
    +
    
    590
    +  generalTabLayout_ = new QGridLayout;
    
    591
    +  hintingRenderingTabLayout_ = new QGridLayout;
    
    592
    +
    
    593
    +  // Hinting & Rendering
    
    594
    +  gridLayout2ColAddWidget(hintingRenderingTabLayout_, hintingCheckBox_);
    
    595
    +  gridLayout2ColAddWidget(hintingRenderingTabLayout_, 
    
    596
    +                          hintingModeLabel_, hintingModeComboBox_);
    
    597
    +  gridLayout2ColAddWidget(hintingRenderingTabLayout_, autoHintingCheckBox_);
    
    598
    +
    
    599
    +  if (debugMode_)
    
    600
    +    gridLayout2ColAddLayout(hintingRenderingTabLayout_, debugLayout_);
    
    601
    +
    
    602
    +  gridLayout2ColAddWidget(hintingRenderingTabLayout_, 
    
    603
    +                          antiAliasingLabel_, antiAliasingComboBox_);
    
    604
    +  gridLayout2ColAddWidget(hintingRenderingTabLayout_, 
    
    605
    +                          lcdFilterLabel_, lcdFilterComboBox_);
    
    606
    +
    
    607
    +  gridLayout2ColAddLayout(hintingRenderingTabLayout_, gammaLayout_);
    
    608
    +
    
    609
    +  // General
    
    610
    +  gridLayout2ColAddWidget(generalTabLayout_, embeddedBitmapCheckBox_);
    
    611
    +  gridLayout2ColAddWidget(generalTabLayout_, colorLayerCheckBox_);
    
    612
    +  gridLayout2ColAddWidget(generalTabLayout_, 
    
    613
    +                          paletteLabel_, paletteComboBox_);
    
    614
    +
    
    615
    +  gridLayout2ColAddWidget(generalTabLayout_, kerningCheckBox_);
    
    616
    +  gridLayout2ColAddWidget(generalTabLayout_, lsbRsbDeltaCheckBox_);
    
    617
    +
    
    618
    +  generalTabLayout_->setColumnStretch(1, 1);
    
    619
    +  hintingRenderingTabLayout_->setColumnStretch(1, 1);
    
    620
    +  generalTab_->setLayout(generalTabLayout_);
    
    621
    +  hintingRenderingTab_->setLayout(hintingRenderingTabLayout_);
    
    622
    +
    
    623
    +  tab_->addTab(hintingRenderingTab_, tr("Hinting && Rendering"));
    
    624
    +  tab_->addTab(generalTab_, tr("General"));
    
    625
    +  tab_->addTab(mmgxTab_, tr("MM/GX"));
    
    626
    +  setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum);
    
    585 627
     }
    
    586 628
     
    
    587 629
     
    

  • src/ftinspect/panels/settingpanel.hpp
    ... ... @@ -74,6 +74,7 @@ private:
    74 74
       QTabWidget* tab_;
    
    75 75
     
    
    76 76
       QWidget* generalTab_;
    
    77
    +  QWidget* hintingRenderingTab_;
    
    77 78
       QWidget* mmgxTab_;
    
    78 79
     
    
    79 80
       QLabel* gammaLabel_;
    
    ... ... @@ -110,6 +111,7 @@ private:
    110 111
     
    
    111 112
       QVBoxLayout* mainLayout_;
    
    112 113
       QGridLayout* generalTabLayout_;
    
    114
    +  QGridLayout* hintingRenderingTabLayout_;
    
    113 115
       QVBoxLayout* debugLayout_;
    
    114 116
       QHBoxLayout* gammaLayout_;
    
    115 117
       QHBoxLayout* colorPickerLayout_;
    
    ... ... @@ -121,6 +123,8 @@ private:
    121 123
     
    
    122 124
       void createConnections();
    
    123 125
       void createLayout();
    
    126
    +  void createLayoutNormal();
    
    127
    +  void createLayoutComperator();
    
    124 128
       void setDefaults();
    
    125 129
     
    
    126 130
       void populatePalettes();
    

  • src/ftinspect/widgets/customwidgets.cpp
    ... ... @@ -148,32 +148,4 @@ ZoomSpinBox::stepBy(int steps)
    148 148
     }
    
    149 149
     
    
    150 150
     
    
    151
    -UnboundScrollArea::UnboundScrollArea(QWidget* parent)
    
    152
    -: QScrollArea(parent)
    
    153
    -{
    
    154
    -}
    
    155
    -
    
    156
    -
    
    157
    -QSize
    
    158
    -UnboundScrollArea::sizeHint() const
    
    159
    -{
    
    160
    -  int fw = 2 * frameWidth();
    
    161
    -  QSize sz(fw, fw);
    
    162
    -
    
    163
    -  int h = fontMetrics().height();
    
    164
    -
    
    165
    -  auto w = widget();
    
    166
    -  if (w)
    
    167
    -    sz += widgetResizable() ? w->sizeHint() : w->size();
    
    168
    -  else
    
    169
    -    sz += QSize(12 * h, 8 * h);
    
    170
    -
    
    171
    -  if (verticalScrollBarPolicy() == Qt::ScrollBarAlwaysOn)
    
    172
    -    sz.setWidth(sz.width() + verticalScrollBar()->sizeHint().width());
    
    173
    -  if (horizontalScrollBarPolicy() == Qt::ScrollBarAlwaysOn)
    
    174
    -    sz.setHeight(sz.height() + horizontalScrollBar()->sizeHint().height());
    
    175
    -  return sz;
    
    176
    -}
    
    177
    -
    
    178
    -
    
    179 151
     // end of custom_widgets.cpp

  • src/ftinspect/widgets/customwidgets.hpp
    ... ... @@ -56,17 +56,4 @@ public:
    56 56
     };
    
    57 57
     
    
    58 58
     
    
    59
    -// https://bugreports.qt.io/browse/QTBUG-10459
    
    60
    -// https://phabricator.kde.org/D14692
    
    61
    -class UnboundScrollArea
    
    62
    -: public QScrollArea
    
    63
    -{
    
    64
    -  Q_OBJECT
    
    65
    -
    
    66
    -public:
    
    67
    -  UnboundScrollArea(QWidget* parent);
    
    68
    -  QSize sizeHint() const override;
    
    69
    -};
    
    70
    -
    
    71
    -
    
    72 59
     // end of custom_widgets.hpp


  • reply via email to

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