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] WIP: Ena


From: Charlie Jiang (@cqjjjzr)
Subject: [Git][freetype/freetype-demos][gsoc-2022-chariri-3] [ftinspect] WIP: Enable a narrower layout.
Date: Fri, 26 Aug 2022 14:56:29 +0000

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

Commits:

  • 651a2128
    by Charlie Jiang at 2022-08-26T22:52:55+08:00
    [ftinspect] WIP: Enable a narrower layout.
    
    By disabling size constraint, we can force resize the window to a smaller
    width. For a better effect, the index selector will hide its navigation
    buttons if the horizontal spaces is not enough.
    
    * src/ftinspect/maingui.cpp: Disable constraint. Set a max width instead of
      fixed size for the settings panel.
    
    * src/ftinspect/widgets/glyphindexselector.cpp,
      src/ftinspect/widgets/glyphindexselector.hpp: Show/hide the navi buttons
      depending on the available size.
    

3 changed files:

Changes:

  • src/ftinspect/maingui.cpp
    ... ... @@ -250,7 +250,7 @@ MainGUI::createLayout()
    250 250
       // to change the policy we have to use a widget wrapper
    
    251 251
       leftWidget_ = new QWidget(this);
    
    252 252
       leftWidget_->setLayout(leftLayout_);
    
    253
    -  leftWidget_->setFixedWidth(400);
    
    253
    +  leftWidget_->setMaximumWidth(400);
    
    254 254
     
    
    255 255
       // right side
    
    256 256
       singularTab_ = new SingularTab(this, engine_);
    
    ... ... @@ -303,9 +303,11 @@ MainGUI::createLayout()
    303 303
       ftinspectLayout_->addLayout(mainPartLayout_);
    
    304 304
       ftinspectLayout_->addWidget(tripletSelector_);
    
    305 305
       ftinspectLayout_->setContentsMargins(0, 0, 0, 0);
    
    306
    +  ftinspectLayout_->setSizeConstraint(QLayout::SetNoConstraint);
    
    306 307
     
    
    307 308
       ftinspectWidget_ = new QWidget(this);
    
    308 309
       ftinspectWidget_->setLayout(ftinspectLayout_);
    
    310
    +  layout()->setSizeConstraint(QLayout::SetNoConstraint);
    
    309 311
     
    
    310 312
       statusBar()->hide(); // remove the extra space
    
    311 313
       setCentralWidget(ftinspectWidget_);
    

  • src/ftinspect/widgets/glyphindexselector.cpp
    ... ... @@ -81,6 +81,22 @@ GlyphIndexSelector::setNumberRenderer(std::function<QString(int)> renderer)
    81 81
     }
    
    82 82
     
    
    83 83
     
    
    84
    +void
    
    85
    +GlyphIndexSelector::resizeEvent(QResizeEvent* event)
    
    86
    +{
    
    87
    +  QWidget::resizeEvent(event);
    
    88
    +  auto minimumWidth = minimumSizeHint().width();
    
    89
    +  if (toEndButton_->isVisible())
    
    90
    +  {
    
    91
    +    if (width() < minimumWidth)
    
    92
    +      navigationWidget_->setVisible(false);
    
    93
    +  }
    
    94
    +  else if (navigationWidget_->minimumSizeHint().width() + minimumWidth 
    
    95
    +           <= width())
    
    96
    +    navigationWidget_->setVisible(true);
    
    97
    +}
    
    98
    +
    
    99
    +
    
    84 100
     void
    
    85 101
     GlyphIndexSelector::adjustIndex(int delta)
    
    86 102
     {
    
    ... ... @@ -123,6 +139,7 @@ GlyphIndexSelector::updateLabel()
    123 139
     void
    
    124 140
     GlyphIndexSelector::createLayout()
    
    125 141
     {
    
    142
    +  navigationWidget_ = new QWidget(this);
    
    126 143
       toStartButton_ = new QPushButton("|<", this);
    
    127 144
       toM1000Button_ = new QPushButton("-1000", this);
    
    128 145
       toM100Button_ = new QPushButton("-100", this);
    
    ... ... @@ -162,7 +179,6 @@ GlyphIndexSelector::createLayout()
    162 179
       // Layouting
    
    163 180
       navigationLayout_ = new QHBoxLayout;
    
    164 181
       navigationLayout_->setSpacing(0);
    
    165
    -  navigationLayout_->addStretch(3);
    
    166 182
       navigationLayout_->addWidget(toStartButton_);
    
    167 183
       navigationLayout_->addWidget(toM1000Button_);
    
    168 184
       navigationLayout_->addWidget(toM100Button_);
    
    ... ... @@ -173,14 +189,20 @@ GlyphIndexSelector::createLayout()
    173 189
       navigationLayout_->addWidget(toP100Button_);
    
    174 190
       navigationLayout_->addWidget(toP1000Button_);
    
    175 191
       navigationLayout_->addWidget(toEndButton_);
    
    176
    -  navigationLayout_->addStretch(1);
    
    177
    -  navigationLayout_->addWidget(indexSpinBox_);
    
    178
    -  navigationLayout_->addStretch(1);
    
    179
    -  navigationLayout_->addWidget(indexLabel_);
    
    180
    -  navigationLayout_->addStretch(3);
    
    192
    +  navigationWidget_->setLayout(navigationLayout_);
    
    193
    +
    
    194
    +  layout_ = new QHBoxLayout;
    
    195
    +  layout_->setSpacing(0);
    
    196
    +  layout_->addStretch(3);
    
    197
    +  layout_->addWidget(navigationWidget_);
    
    198
    +  layout_->addStretch(1);
    
    199
    +  layout_->addWidget(indexSpinBox_);
    
    200
    +  layout_->addStretch(1);
    
    201
    +  layout_->addWidget(indexLabel_);
    
    202
    +  layout_->addStretch(3);
    
    181 203
     
    
    182 204
       setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
    
    183
    -  setLayout(navigationLayout_);
    
    205
    +  setLayout(layout_);
    
    184 206
     }
    
    185 207
     
    
    186 208
     void
    

  • src/ftinspect/widgets/glyphindexselector.hpp
    ... ... @@ -33,6 +33,9 @@ public:
    33 33
     signals:
    
    34 34
       void currentIndexChanged(int index);
    
    35 35
     
    
    36
    +protected:
    
    37
    +  void resizeEvent(QResizeEvent* event) override;
    
    38
    +
    
    36 39
     private slots:
    
    37 40
       void adjustIndex(int delta);
    
    38 41
       void emitValueChanged();
    
    ... ... @@ -44,7 +47,7 @@ private:
    44 47
       std::function<QString(int)> numberRenderer_;
    
    45 48
     
    
    46 49
       // min, max and current status are held by `indexSpinBox_`
    
    47
    -
    
    50
    +  QWidget* navigationWidget_;
    
    48 51
       QPushButton* toEndButton_;
    
    49 52
       QPushButton* toM1000Button_;
    
    50 53
       QPushButton* toM100Button_;
    
    ... ... @@ -60,6 +63,7 @@ private:
    60 63
       QSpinBox* indexSpinBox_;
    
    61 64
     
    
    62 65
       QHBoxLayout* navigationLayout_;
    
    66
    +  QHBoxLayout* layout_;
    
    63 67
     
    
    64 68
       QSignalMapper* glyphNavigationMapper_;
    
    65 69
     
    


  • reply via email to

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