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] 6 commits: * src/fti


From: Charlie Jiang (@cqjjjzr)
Subject: [Git][freetype/freetype-demos][gsoc-2022-chariri-3] 6 commits: * src/ftinspect/maingui.cpp: Set a larger initial size for the window.
Date: Sat, 27 Aug 2022 15:25:22 +0000

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

Commits:

  • e4b85d31
    by Charlie Jiang at 2022-08-27T22:20:30+08:00
    * src/ftinspect/maingui.cpp: Set a larger initial size for the window.
    
  • a093e489
    by Charlie Jiang at 2022-08-27T22:54:18+08:00
    * src/ftinspect/maingui.cpp: Don't shift the tab bar left when switching...
    
    to the comparator view.
    
    Now the tab bar don't jump left when switching to the comparator view which
    requires the left panel to be invisible.
    
  • 19bab0ba
    by Charlie Jiang at 2022-08-27T22:56:40+08:00
    [ftinspect] Line charmap label and combobox vertically in the comparator.
    
    * src/ftinspect/panels/comparator.cpp, src/ftinspect/panels/comparator.hpp:
      As described. The contents of the charmap combobox are always too wide,
      so don't place the label in the same line of the combobox.
    
  • c0512375
    by Charlie Jiang at 2022-08-27T23:05:37+08:00
    [ftinspect] Set better zoom factor for singular view.
    
    * src/ftinspect/panels/singular.cpp: The initial zoom factor is now based
      on the window size.
    
    * src/ftinspect/maingui.cpp: Force set main window size.
    
  • 0c79dfe4
    by Charlie Jiang at 2022-08-27T23:12:26+08:00
    [ftinspect] Flash the image inverted for highlighting.
    
    For better visibility, flash the image with inverted color.
    
    * src/ftinspect/glyphcomponents/glyphcontinuous.cpp,
      src/ftinspect/glyphcomponents/glyphcontinuous.hpp:
      As described.
    
  • 36191f72
    by Charlie Jiang at 2022-08-27T23:23:59+08:00
    [ftinspect] Alert user when files provided from commandline don't exist.
    
    * src/ftinspect/engine/fontfilemanager.cpp,
      src/ftinspect/engine/fontfilemanager.hpp: As described.
    
    * src/ftinspect/ftinspect.cpp, src/ftinspect/maingui.cpp: Move the `show`
      call before the `loadCommandLine` so the alert box isn't covered.
    

9 changed files:

Changes:

  • src/ftinspect/engine/fontfilemanager.cpp
    ... ... @@ -6,6 +6,7 @@
    6 6
     #include "fontfilemanager.hpp"
    
    7 7
     
    
    8 8
     #include <QCoreApplication>
    
    9
    +#include <QMessageBox>
    
    9 10
     
    
    10 11
     
    
    11 12
     FontFileManager::FontFileManager()
    
    ... ... @@ -30,8 +31,9 @@ FontFileManager::size()
    30 31
     
    
    31 32
     
    
    32 33
     void
    
    33
    -FontFileManager::append(QStringList newFileNames)
    
    34
    +FontFileManager::append(QStringList newFileNames, bool alertNotExist)
    
    34 35
     {
    
    36
    +  QStringList failedFiles;
    
    35 37
       for (auto& name : newFileNames)
    
    36 38
       {
    
    37 39
         auto info = QFileInfo(name);
    
    ... ... @@ -39,7 +41,14 @@ FontFileManager::append(QStringList newFileNames)
    39 41
     
    
    40 42
         // Filter non-file elements
    
    41 43
         if (!info.isFile())
    
    44
    +    {
    
    45
    +      if (alertNotExist)
    
    46
    +        failedFiles.append(name);
    
    42 47
           continue;
    
    48
    +    }
    
    49
    +
    
    50
    +    if (!info.exists() && alertNotExist)
    
    51
    +      failedFiles.append(name);
    
    43 52
     
    
    44 53
         // Uniquify elements
    
    45 54
         auto absPath = info.absoluteFilePath();
    
    ... ... @@ -57,6 +66,18 @@ FontFileManager::append(QStringList newFileNames)
    57 66
           return; // Prevent overflowing
    
    58 67
         fontFileNameList_.append(info);
    
    59 68
       }
    
    69
    +
    
    70
    +  if (alertNotExist && !failedFiles.empty())
    
    71
    +  {
    
    72
    +    auto msg = new QMessageBox;
    
    73
    +    msg->setAttribute(Qt::WA_DeleteOnClose);
    
    74
    +    msg->setStandardButtons(QMessageBox::Ok);
    
    75
    +    msg->setWindowTitle(tr("Failed to load some files"));
    
    76
    +    msg->setText(tr("Files failed to load:\n%1").arg(failedFiles.join("\n")));
    
    77
    +    msg->setIcon(QMessageBox::Warning);
    
    78
    +    msg->setModal(false);
    
    79
    +    msg->open();
    
    80
    +  }
    
    60 81
     }
    
    61 82
     
    
    62 83
     
    
    ... ... @@ -111,7 +132,7 @@ FontFileManager::loadFromCommandLine()
    111 132
       auto args = QCoreApplication::arguments();
    
    112 133
       if (!args.empty())
    
    113 134
         args.removeFirst();
    
    114
    -  append(args);
    
    135
    +  append(args, true);
    
    115 136
     }
    
    116 137
     
    
    117 138
     
    

  • src/ftinspect/engine/fontfilemanager.hpp
    ... ... @@ -23,7 +23,7 @@ public:
    23 23
       ~FontFileManager() override = default;
    
    24 24
     
    
    25 25
       int size();
    
    26
    -  void append(QStringList newFileNames);
    
    26
    +  void append(QStringList newFileNames, bool alertNotExist = false);
    
    27 27
       void remove(int index);
    
    28 28
     
    
    29 29
       QFileInfo& operator[](int index);
    

  • src/ftinspect/ftinspect.cpp
    ... ... @@ -24,8 +24,6 @@ main(int argc,
    24 24
       Engine engine;
    
    25 25
       MainGUI gui(&engine);
    
    26 26
     
    
    27
    -  gui.show();
    
    28
    -
    
    29 27
       return app.exec();
    
    30 28
     }
    
    31 29
     
    

  • src/ftinspect/glyphcomponents/glyphcontinuous.cpp
    ... ... @@ -350,8 +350,9 @@ GlyphContinuous::paintCache(QPainter* painter)
    350 350
         for (auto& glyph : line.entries)
    
    351 351
         {
    
    352 352
           if (glyph.glyphIndex == flashGlyphIndex_ && flashFlipFlop)
    
    353
    -        continue; // flash
    
    354
    -      drawCacheGlyph(painter, glyph);
    
    353
    +        drawCacheGlyph(painter, glyph, true);
    
    354
    +      else
    
    355
    +        drawCacheGlyph(painter, glyph);
    
    355 356
         }
    
    356 357
       }
    
    357 358
     }
    
    ... ... @@ -528,7 +529,8 @@ GlyphContinuous::beginDrawCacheLine(QPainter* painter,
    528 529
     
    
    529 530
     void
    
    530 531
     GlyphContinuous::drawCacheGlyph(QPainter* painter,
    
    531
    -                                const GlyphCacheEntry& entry)
    
    532
    +                                const GlyphCacheEntry& entry,
    
    533
    +                                bool colorInverted)
    
    532 534
     {
    
    533 535
       // ftview.c:557
    
    534 536
       // Well, metrics is also part of the cache...
    
    ... ... @@ -547,7 +549,14 @@ GlyphContinuous::drawCacheGlyph(QPainter* painter,
    547 549
       rect.moveLeft(rect.x() + sizeIndicatorOffset_);
    
    548 550
       rect.translate(positionDelta_);
    
    549 551
     
    
    550
    -  painter->drawImage(rect.topLeft(), *entry.image);
    
    552
    +  if (colorInverted)
    
    553
    +  {
    
    554
    +    auto inverted = entry.image->copy();
    
    555
    +    inverted.invertPixels();
    
    556
    +    painter->drawImage(rect.topLeft(), inverted);
    
    557
    +  }
    
    558
    +  else
    
    559
    +    painter->drawImage(rect.topLeft(), *entry.image);
    
    551 560
     }
    
    552 561
     
    
    553 562
     
    

  • src/ftinspect/glyphcomponents/glyphcontinuous.hpp
    ... ... @@ -173,7 +173,8 @@ private:
    173 173
       void beginDrawCacheLine(QPainter* painter,
    
    174 174
                               GlyphCacheLine& line);
    
    175 175
       void drawCacheGlyph(QPainter* painter,
    
    176
    -                      const GlyphCacheEntry& entry);
    
    176
    +                      const GlyphCacheEntry& entry,
    
    177
    +                      bool colorInverted = false);
    
    177 178
     
    
    178 179
       GlyphCacheEntry* findGlyphByMouse(QPoint position,
    
    179 180
                                         double* outSizePoint);
    

  • src/ftinspect/maingui.cpp
    ... ... @@ -28,9 +28,11 @@ MainGUI::MainGUI(Engine* engine)
    28 28
       setupDragDrop();
    
    29 29
     
    
    30 30
       readSettings();
    
    31
    -  loadCommandLine();
    
    32
    -
    
    33 31
       setUnifiedTitleAndToolBarOnMac(true);
    
    32
    +
    
    33
    +  show(); // place this before `loadCommandLine` so alerts from loading
    
    34
    +          // won't be covered.
    
    35
    +  loadCommandLine();
    
    34 36
     }
    
    35 37
     
    
    36 38
     
    
    ... ... @@ -166,6 +168,14 @@ MainGUI::switchTab()
    166 168
     {
    
    167 169
       auto current = tabWidget_->currentWidget();
    
    168 170
       auto isComparator = current == comparatorTab_;
    
    171
    +
    
    172
    +  if (isComparator)
    
    173
    +    tabWidget_->setStyleSheet(QString("QTabWidget::tab-bar {left: %1 px;}")
    
    174
    +                              .arg(leftWidget_->width()));
    
    175
    +  else
    
    176
    +    tabWidget_->setStyleSheet("");
    
    177
    +  
    
    178
    +
    
    169 179
       if (!leftWidget_->isVisible() && !isComparator)
    
    170 180
       {
    
    171 181
         // Dirty approach here: When setting the left panel as visible, the main
    
    ... ... @@ -303,11 +313,14 @@ MainGUI::createLayout()
    303 313
       ftinspectLayout_->addLayout(mainPartLayout_);
    
    304 314
       ftinspectLayout_->addWidget(tripletSelector_);
    
    305 315
       ftinspectLayout_->setContentsMargins(0, 0, 0, 0);
    
    306
    -  ftinspectLayout_->setSizeConstraint(QLayout::SetNoConstraint);
    
    307 316
     
    
    308 317
       ftinspectWidget_ = new QWidget(this);
    
    309 318
       ftinspectWidget_->setLayout(ftinspectLayout_);
    
    319
    +
    
    320
    +  ftinspectLayout_->setSizeConstraint(QLayout::SetNoConstraint);
    
    310 321
       layout()->setSizeConstraint(QLayout::SetNoConstraint);
    
    322
    +  ftinspectWidget_->resize(1400, 900);
    
    323
    +  resize(1400, 900);
    
    311 324
     
    
    312 325
       statusBar()->hide(); // remove the extra space
    
    313 326
       setCentralWidget(ftinspectWidget_);
    

  • src/ftinspect/panels/comparator.cpp
    ... ... @@ -125,13 +125,10 @@ ComperatorTab::createLayout()
    125 125
       // Layouting
    
    126 126
       layout_ = new QGridLayout;
    
    127 127
     
    
    128
    -  charMapLayout_ = new QHBoxLayout;
    
    129
    -  charMapLayout_->addWidget(charMapLabel_);
    
    130
    -  charMapLayout_->addWidget(charMapSelector_);
    
    131
    -
    
    132 128
       sourceLayout_ = new QVBoxLayout;
    
    133 129
       sourceLayout_->addWidget(sizeSelector_);
    
    134
    -  sourceLayout_->addLayout(charMapLayout_);
    
    130
    +  sourceLayout_->addWidget(charMapLabel_);
    
    131
    +  sourceLayout_->addWidget(charMapSelector_);
    
    135 132
       sourceLayout_->addWidget(sourceTextEdit_, 1);
    
    136 133
       sourceWidget_->setLayout(sourceLayout_);
    
    137 134
     
    

  • src/ftinspect/panels/comparator.hpp
    ... ... @@ -53,7 +53,6 @@ private:
    53 53
       QWidget* sourceWidget_;
    
    54 54
     
    
    55 55
       QVBoxLayout* sourceLayout_;
    
    56
    -  QHBoxLayout* charMapLayout_;
    
    57 56
       QGridLayout* layout_;
    
    58 57
     
    
    59 58
       void createLayout();
    

  • src/ftinspect/panels/singular.cpp
    ... ... @@ -270,12 +270,13 @@ SingularTab::resizeEvent(QResizeEvent* event)
    270 270
       {
    
    271 271
         sizeSelector_->applyToEngine(engine_);
    
    272 272
         auto dpi = engine_->dpi();
    
    273
    -    auto val = size * dpi / 72.0 / 2;
    
    274
    -    glyphView_->centerOn(val, -val);
    
    273
    +    size = size * dpi / 72.0;
    
    275 274
       }
    
    276
    -  else
    
    277
    -    glyphView_->centerOn(size / 2, -size / 2);
    
    275
    +  glyphView_->centerOn(size / 2, -size / 2);
    
    278 276
     
    
    277
    +  auto viewSize = glyphView_->size();
    
    278
    +  auto minViewSide = std::min(viewSize.height(), viewSize.width());
    
    279
    +  zoomSpinBox_->setValue(static_cast<int>(minViewSide / size * 0.9));
    
    279 280
     }
    
    280 281
     
    
    281 282
     
    


  • reply via email to

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