freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype-demos][master] [ftinspect] Fix the glyph index s


From: Charlie Jiang (@cqjjjzr)
Subject: [Git][freetype/freetype-demos][master] [ftinspect] Fix the glyph index selector layout when the window resizes.
Date: Wed, 26 Jul 2023 12:45:26 +0000

Charlie Jiang pushed to branch master at FreeType / FreeType Demo Programs

Commits:

  • 2186a044
    by Charlie Jiang at 2023-07-26T12:29:07+00:00
    [ftinspect] Fix the glyph index selector layout when the window resizes.
    
    Fixes #26. When the window resizes, the invisible tabs don't get notified.
    Therefore, when the active tab changes, we need to trigger a manual
    relayouting of invisible tabs.
    
    * src/ftinspect/widgets/glyphindexselector.hpp,
      src/ftinspect/widgets/glyphindexselector.cpp:
      Extract public method `relayoutNavigation` from `resizeEvent`.
    
    * src/ftinspect/panels/abstracttab.hpp: Add `relayout` virtual method.
    
    * src/ftinspect/maingui.cpp: Call `AbstractTab::relayout` on the new tab
      when the active tab changes.
    
    * src/ftinspect/panels/singular.cpp, src/ftinspect/panels/singular.hpp,
      src/ftinspect/panels/continuous.cpp, src/ftinspect/panels/continuous.hpp:
      Implement `relayout` method and call `relayoutNavigation` of the glyph
      index selector in `relayout`.
    

8 changed files:

Changes:

  • src/ftinspect/maingui.cpp
    ... ... @@ -198,6 +198,8 @@ MainGUI::switchTab()
    198 198
       else
    
    199 199
         leftWidget_->setVisible(!isComparator);
    
    200 200
     
    
    201
    +  tabs_[tabWidget_->currentIndex()]->relayout();
    
    202
    +
    
    201 203
       reloadCurrentTabFont();
    
    202 204
     
    
    203 205
       if (current == continuousTab_
    

  • src/ftinspect/panels/abstracttab.hpp
    ... ... @@ -16,6 +16,7 @@ public:
    16 16
     
    
    17 17
       virtual void repaintGlyph() = 0;
    
    18 18
       virtual void reloadFont() = 0;
    
    19
    +  virtual void relayout() {}
    
    19 20
     };
    
    20 21
     
    
    21 22
     
    

  • src/ftinspect/panels/continuous.cpp
    ... ... @@ -65,6 +65,13 @@ ContinuousTab::reloadFont()
    65 65
     }
    
    66 66
     
    
    67 67
     
    
    68
    +void
    
    69
    +ContinuousTab::relayout()
    
    70
    +{
    
    71
    +  indexSelector_->relayoutNavigation();
    
    72
    +}
    
    73
    +
    
    74
    +
    
    68 75
     void
    
    69 76
     ContinuousTab::applySettings()
    
    70 77
     {
    

  • src/ftinspect/panels/continuous.hpp
    ... ... @@ -46,6 +46,7 @@ public:
    46 46
     
    
    47 47
       void repaintGlyph() override;
    
    48 48
       void reloadFont() override;
    
    49
    +  void relayout() override;
    
    49 50
       void highlightGlyph(int index);
    
    50 51
       void applySettings();
    
    51 52
     
    

  • src/ftinspect/panels/singular.cpp
    ... ... @@ -459,6 +459,13 @@ SingularTab::reloadFont()
    459 459
     }
    
    460 460
     
    
    461 461
     
    
    462
    +void
    
    463
    +SingularTab::relayout()
    
    464
    +{
    
    465
    +  indexSelector_->relayoutNavigation();
    
    466
    +}
    
    467
    +
    
    468
    +
    
    462 469
     void
    
    463 470
     SingularTab::setCurrentGlyphAndSize(int glyphIndex,
    
    464 471
                                         double sizePoint)
    

  • src/ftinspect/panels/singular.hpp
    ... ... @@ -46,6 +46,7 @@ public:
    46 46
     
    
    47 47
       void repaintGlyph() override;
    
    48 48
       void reloadFont() override;
    
    49
    +  void relayout() override;
    
    49 50
       // The size remains unchanged if `sizePoint` <= 0.
    
    50 51
       void setCurrentGlyphAndSize(int glyphIndex,
    
    51 52
                                   double sizePoint);
    

  • src/ftinspect/widgets/glyphindexselector.cpp
    ... ... @@ -20,6 +20,20 @@ GlyphIndexSelector::GlyphIndexSelector(QWidget* parent)
    20 20
     }
    
    21 21
     
    
    22 22
     
    
    23
    +void
    
    24
    +GlyphIndexSelector::relayoutNavigation()
    
    25
    +{
    
    26
    +  auto minimumWidth = minimumSizeHint().width();
    
    27
    +  if (toEndButton_->isVisible())
    
    28
    +  {
    
    29
    +    if (width() < minimumWidth)
    
    30
    +      navigationWidget_->setVisible(false);
    
    31
    +  }
    
    32
    +  else if (navigationWidget_->minimumSizeHint().width() + minimumWidth <= width())
    
    33
    +    navigationWidget_->setVisible(true);
    
    34
    +}
    
    35
    +
    
    36
    +
    
    23 37
     void
    
    24 38
     GlyphIndexSelector::setMinMax(int min,
    
    25 39
                                   int max)
    
    ... ... @@ -87,15 +101,7 @@ void
    87 101
     GlyphIndexSelector::resizeEvent(QResizeEvent* event)
    
    88 102
     {
    
    89 103
       QWidget::resizeEvent(event);
    
    90
    -  auto minimumWidth = minimumSizeHint().width();
    
    91
    -  if (toEndButton_->isVisible())
    
    92
    -  {
    
    93
    -    if (width() < minimumWidth)
    
    94
    -      navigationWidget_->setVisible(false);
    
    95
    -  }
    
    96
    -  else if (navigationWidget_->minimumSizeHint().width() + minimumWidth
    
    97
    -           <= width())
    
    98
    -    navigationWidget_->setVisible(true);
    
    104
    +  relayoutNavigation();
    
    99 105
     }
    
    100 106
     
    
    101 107
     
    

  • src/ftinspect/widgets/glyphindexselector.hpp
    ... ... @@ -24,6 +24,8 @@ public:
    24 24
       GlyphIndexSelector(QWidget* parent);
    
    25 25
       ~GlyphIndexSelector() override = default;
    
    26 26
     
    
    27
    +  void relayoutNavigation();
    
    28
    +
    
    27 29
       // Never triggers repaint!
    
    28 30
       void setMinMax(int min,
    
    29 31
                      int max);
    


  • reply via email to

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