Charlie Jiang pushed to branch gsoc-2022-chariri at FreeType / FreeType Demo Programs
Commits:
-
e51718ed
by Charlie Jiang at 2022-07-08T01:38:07+08:00
13 changed files:
- src/ftinspect/CMakeLists.txt
- src/ftinspect/engine/engine.cpp
- src/ftinspect/engine/engine.hpp
- src/ftinspect/maingui.cpp
- src/ftinspect/maingui.hpp
- src/ftinspect/meson.build
- + src/ftinspect/panels/abstracttab.hpp
- src/ftinspect/panels/settingpanel.cpp
- src/ftinspect/panels/settingpanel.hpp
- + src/ftinspect/panels/singular.cpp
- + src/ftinspect/panels/singular.hpp
- src/ftinspect/widgets/customwidgets.cpp
- src/ftinspect/widgets/customwidgets.hpp
Changes:
... | ... | @@ -35,6 +35,7 @@ add_executable(ftinspect |
35 | 35 | "models/ttsettingscomboboxmodel.cpp"
|
36 | 36 | |
37 | 37 | "panels/settingpanel.cpp"
|
38 | + "panels/singular.cpp"
|
|
38 | 39 | )
|
39 | 40 | target_link_libraries(ftinspect
|
40 | 41 | Qt5::Core Qt5::Widgets
|
... | ... | @@ -298,6 +298,7 @@ Engine::loadFont(int fontIndex, |
298 | 298 | fontType_ = FontType_TrueType;
|
299 | 299 | }
|
300 | 300 | |
301 | + curNumGlyphs_ = numGlyphs;
|
|
301 | 302 | return numGlyphs;
|
302 | 303 | }
|
303 | 304 | |
... | ... | @@ -474,7 +475,7 @@ Engine::update() |
474 | 475 | {
|
475 | 476 | loadFlags_ |= FT_LOAD_NO_HINTING;
|
476 | 477 | |
477 | - if (antiAliasingTarget_ | FT_LOAD_TARGET_MONO) // XXX does this hold?
|
|
478 | + if (!antiAliasingEnabled_) // XXX does this hold?
|
|
478 | 479 | loadFlags_ |= FT_LOAD_MONOCHROME;
|
479 | 480 | }
|
480 | 481 |
... | ... | @@ -81,6 +81,7 @@ public: |
81 | 81 | int currentFontType() const { return fontType_; }
|
82 | 82 | const QString& currentFamilyName() { return curFamilyName_; }
|
83 | 83 | const QString& currentStyleName() { return curStyleName_; }
|
84 | + int currentFontNumberOfGlyphs() { return curNumGlyphs_; }
|
|
84 | 85 | int numberOfOpenedFonts();
|
85 | 86 | QString glyphName(int glyphIndex);
|
86 | 87 | long numberOfFaces(int fontIndex);
|
... | ... | @@ -92,6 +93,7 @@ public: |
92 | 93 | // getter named fontFileManager
|
93 | 94 | FontFileManager& fontFileManager() { return fontFileManager_; }
|
94 | 95 | EngineDefaultValues& engineDefaults() { return engineDefaults_; }
|
96 | + bool antiAliasingEnabled() { return antiAliasingEnabled_; }
|
|
95 | 97 | |
96 | 98 | //////// Setters (direct or indirect)
|
97 | 99 | |
... | ... | @@ -115,6 +117,7 @@ public: |
115 | 117 | void setShowSegments(bool showSegments) { showSegments_ = showSegments; }
|
116 | 118 | void setGamma(double gamma) { gamma_ = gamma; }
|
117 | 119 | void setAntiAliasingTarget(int target) { antiAliasingTarget_ = target; }
|
120 | + void setAntiAliasingEnabled(bool enabled) { antiAliasingEnabled_ = enabled; }
|
|
118 | 121 | |
119 | 122 | // Note: These 3 functions now takes actual mode/version from FreeType,
|
120 | 123 | // instead of values from enum in MainGUI!
|
... | ... | @@ -138,6 +141,7 @@ private: |
138 | 141 | |
139 | 142 | QString curFamilyName_;
|
140 | 143 | QString curStyleName_;
|
144 | + int curNumGlyphs_ = -1;
|
|
141 | 145 | |
142 | 146 | FT_Library library_;
|
143 | 147 | FTC_Manager cacheManager_;
|
... | ... | @@ -151,6 +155,7 @@ private: |
151 | 155 | |
152 | 156 | int fontType_;
|
153 | 157 | |
158 | + bool antiAliasingEnabled_ = true;
|
|
154 | 159 | bool usingPixelSize_ = false;
|
155 | 160 | double pointSize_;
|
156 | 161 | double pixelSize_;
|
... | ... | @@ -19,7 +19,6 @@ |
19 | 19 | MainGUI::MainGUI(Engine* engine)
|
20 | 20 | : engine_(engine)
|
21 | 21 | {
|
22 | - setGraphicsDefaults();
|
|
23 | 22 | createLayout();
|
24 | 23 | createConnections();
|
25 | 24 | createActions();
|
... | ... | @@ -35,8 +34,7 @@ MainGUI::MainGUI(Engine* engine) |
35 | 34 | |
36 | 35 | MainGUI::~MainGUI()
|
37 | 36 | {
|
38 | - delete gridItem_;
|
|
39 | - gridItem_ = NULL;
|
|
37 | + // empty
|
|
40 | 38 | }
|
41 | 39 | |
42 | 40 | |
... | ... | @@ -232,73 +230,38 @@ MainGUI::showFont() |
232 | 230 | auto state = settingPanel_->blockSignals(true);
|
233 | 231 | settingPanel_->checkHinting();
|
234 | 232 | settingPanel_->blockSignals(state);
|
235 | - indexSelector_->setMin(0);
|
|
236 | - indexSelector_->setMax(currentNumberOfGlyphs_ - 1);
|
|
237 | - indexSelector_->setCurrentIndex(indexSelector_->getCurrentIndex(), true);
|
|
233 | + reloadCurrentTabFont();
|
|
238 | 234 | }
|
239 | 235 | |
240 | 236 | |
241 | 237 | void
|
242 | -MainGUI::syncSettings()
|
|
238 | +MainGUI::repaintCurrentTab()
|
|
243 | 239 | {
|
244 | - // Spinbox value cannot become negative
|
|
245 | - engine_->setDPI(static_cast<unsigned int>(dpiSpinBox_->value()));
|
|
246 | - |
|
247 | - if (unitsComboBox_->currentIndex() == Units_px)
|
|
248 | - engine_->setSizeByPixel(sizeDoubleSpinBox_->value());
|
|
249 | - else
|
|
250 | - engine_->setSizeByPoint(sizeDoubleSpinBox_->value());
|
|
251 | - |
|
252 | - settingPanel_->syncSettings();
|
|
240 | + syncSettings();
|
|
241 | + tabs_[tabWidget_->currentIndex()]->repaint();
|
|
253 | 242 | }
|
254 | 243 | |
255 | 244 | |
256 | 245 | void
|
257 | -MainGUI::clearStatusBar()
|
|
246 | +MainGUI::reloadCurrentTabFont()
|
|
258 | 247 | {
|
259 | - statusBar()->clearMessage();
|
|
260 | - statusBar()->setStyleSheet("");
|
|
248 | + tabs_[tabWidget_->currentIndex()]->reloadFont();
|
|
261 | 249 | }
|
262 | 250 | |
263 | 251 | |
264 | 252 | void
|
265 | -MainGUI::checkUnits()
|
|
253 | +MainGUI::syncSettings()
|
|
266 | 254 | {
|
267 | - int index = unitsComboBox_->currentIndex();
|
|
268 | - |
|
269 | - if (index == Units_px)
|
|
270 | - {
|
|
271 | - dpiLabel_->setEnabled(false);
|
|
272 | - dpiSpinBox_->setEnabled(false);
|
|
273 | - sizeDoubleSpinBox_->setSingleStep(1);
|
|
274 | - sizeDoubleSpinBox_->setValue(qRound(sizeDoubleSpinBox_->value()));
|
|
275 | - }
|
|
276 | - else
|
|
277 | - {
|
|
278 | - dpiLabel_->setEnabled(true);
|
|
279 | - dpiSpinBox_->setEnabled(true);
|
|
280 | - sizeDoubleSpinBox_->setSingleStep(0.5);
|
|
281 | - }
|
|
282 | - |
|
283 | - drawGlyph();
|
|
255 | + settingPanel_->syncSettings();
|
|
256 | + tabs_[tabWidget_->currentIndex()]->syncSettings();
|
|
284 | 257 | }
|
285 | 258 | |
286 | 259 | |
287 | 260 | void
|
288 | -MainGUI::setGlyphIndex(int index)
|
|
261 | +MainGUI::clearStatusBar()
|
|
289 | 262 | {
|
290 | - // only adjust current glyph index if we have a valid font
|
|
291 | - if (currentNumberOfGlyphs_ > 0)
|
|
292 | - {
|
|
293 | - currentGlyphIndex_ = qBound(0, index, currentNumberOfGlyphs_ - 1);
|
|
294 | - }
|
|
295 | - |
|
296 | - QString upperHex = QString::number(currentGlyphIndex_, 16).toUpper();
|
|
297 | - glyphIndexLabel_->setText(
|
|
298 | - QString("%1 (0x%2)").arg(currentGlyphIndex_).arg(upperHex));
|
|
299 | - glyphNameLabel_->setText(engine_->glyphName(currentGlyphIndex_));
|
|
300 | - |
|
301 | - drawGlyph();
|
|
263 | + statusBar()->clearMessage();
|
|
264 | + statusBar()->setStyleSheet("");
|
|
302 | 265 | }
|
303 | 266 | |
304 | 267 | |
... | ... | @@ -452,184 +415,6 @@ MainGUI::nextNamedInstance() |
452 | 415 | }
|
453 | 416 | |
454 | 417 | |
455 | -void
|
|
456 | -MainGUI::zoom()
|
|
457 | -{
|
|
458 | - int scale = zoomSpinBox_->value();
|
|
459 | - |
|
460 | - QTransform transform;
|
|
461 | - transform.scale(scale, scale);
|
|
462 | - |
|
463 | - // we want horizontal and vertical 1px lines displayed with full pixels;
|
|
464 | - // we thus have to shift the coordinate system accordingly, using a value
|
|
465 | - // that represents 0.5px (i.e., half the 1px line width) after the scaling
|
|
466 | - qreal shift = 0.5 / scale;
|
|
467 | - transform.translate(shift, shift);
|
|
468 | - |
|
469 | - glyphView_->setTransform(transform);
|
|
470 | - updateGrid();
|
|
471 | -}
|
|
472 | - |
|
473 | - |
|
474 | -void
|
|
475 | -MainGUI::backToCenter()
|
|
476 | -{
|
|
477 | - glyphView_->centerOn(0, 0);
|
|
478 | - if (currentGlyphBitmapItem_)
|
|
479 | - glyphView_->ensureVisible(currentGlyphBitmapItem_);
|
|
480 | - else if (currentGlyphPointsItem_)
|
|
481 | - glyphView_->ensureVisible(currentGlyphPointsItem_);
|
|
482 | - |
|
483 | - updateGrid();
|
|
484 | -}
|
|
485 | - |
|
486 | - |
|
487 | -void
|
|
488 | -MainGUI::updateGrid()
|
|
489 | -{
|
|
490 | - if (gridItem_)
|
|
491 | - gridItem_->updateRect();
|
|
492 | -}
|
|
493 | - |
|
494 | - |
|
495 | -void
|
|
496 | -MainGUI::wheelZoom(QWheelEvent* event)
|
|
497 | -{
|
|
498 | - int numSteps = event->angleDelta().y() / 120;
|
|
499 | - int zoomAfter = zoomSpinBox_->value() + numSteps;
|
|
500 | - zoomAfter = std::max(zoomSpinBox_->minimum(),
|
|
501 | - std::min(zoomAfter, zoomSpinBox_->maximum()));
|
|
502 | - zoomSpinBox_->setValue(zoomAfter);
|
|
503 | - // TODO: Zoom relative to viewport left-bottom?
|
|
504 | -}
|
|
505 | - |
|
506 | - |
|
507 | -void
|
|
508 | -MainGUI::wheelResize(QWheelEvent* event)
|
|
509 | -{
|
|
510 | - int numSteps = event->angleDelta().y() / 120;
|
|
511 | - double sizeAfter = sizeDoubleSpinBox_->value() + numSteps * 0.5;
|
|
512 | - sizeAfter = std::max(sizeDoubleSpinBox_->minimum(),
|
|
513 | - std::min(sizeAfter, sizeDoubleSpinBox_->maximum()));
|
|
514 | - sizeDoubleSpinBox_->setValue(sizeAfter);
|
|
515 | -}
|
|
516 | - |
|
517 | - |
|
518 | -void
|
|
519 | -MainGUI::setGraphicsDefaults()
|
|
520 | -{
|
|
521 | - // color tables (with suitable opacity values) for converting
|
|
522 | - // FreeType's pixmaps to something Qt understands
|
|
523 | - monoColorTable_.append(QColor(Qt::transparent).rgba());
|
|
524 | - monoColorTable_.append(QColor(Qt::black).rgba());
|
|
525 | - |
|
526 | - for (int i = 0xFF; i >= 0; i--)
|
|
527 | - grayColorTable_.append(qRgba(i, i, i, 0xFF - i));
|
|
528 | - |
|
529 | - // XXX make this user-configurable
|
|
530 | - |
|
531 | - axisPen_.setColor(Qt::black);
|
|
532 | - axisPen_.setWidth(0);
|
|
533 | - blueZonePen_.setColor(QColor(64, 64, 255, 64)); // light blue
|
|
534 | - blueZonePen_.setWidth(0);
|
|
535 | - gridPen_.setColor(Qt::lightGray);
|
|
536 | - gridPen_.setWidth(0);
|
|
537 | - offPen_.setColor(Qt::darkGreen);
|
|
538 | - offPen_.setWidth(3);
|
|
539 | - onPen_.setColor(Qt::red);
|
|
540 | - onPen_.setWidth(3);
|
|
541 | - outlinePen_.setColor(Qt::red);
|
|
542 | - outlinePen_.setWidth(0);
|
|
543 | - segmentPen_.setColor(QColor(64, 255, 128, 64)); // light green
|
|
544 | - segmentPen_.setWidth(0);
|
|
545 | -}
|
|
546 | - |
|
547 | - |
|
548 | -void
|
|
549 | -MainGUI::drawGlyph()
|
|
550 | -{
|
|
551 | - // the call to `engine->loadOutline' updates FreeType's load flags
|
|
552 | - |
|
553 | - if (!engine_)
|
|
554 | - return;
|
|
555 | - |
|
556 | - if (currentGlyphBitmapItem_)
|
|
557 | - {
|
|
558 | - glyphScene_->removeItem(currentGlyphBitmapItem_);
|
|
559 | - delete currentGlyphBitmapItem_;
|
|
560 | - |
|
561 | - currentGlyphBitmapItem_ = NULL;
|
|
562 | - }
|
|
563 | - |
|
564 | - if (currentGlyphOutlineItem_)
|
|
565 | - {
|
|
566 | - glyphScene_->removeItem(currentGlyphOutlineItem_);
|
|
567 | - delete currentGlyphOutlineItem_;
|
|
568 | - |
|
569 | - currentGlyphOutlineItem_ = NULL;
|
|
570 | - }
|
|
571 | - |
|
572 | - if (currentGlyphPointsItem_)
|
|
573 | - {
|
|
574 | - glyphScene_->removeItem(currentGlyphPointsItem_);
|
|
575 | - delete currentGlyphPointsItem_;
|
|
576 | - |
|
577 | - currentGlyphPointsItem_ = NULL;
|
|
578 | - }
|
|
579 | - |
|
580 | - if (currentGlyphPointNumbersItem_)
|
|
581 | - {
|
|
582 | - glyphScene_->removeItem(currentGlyphPointNumbersItem_);
|
|
583 | - delete currentGlyphPointNumbersItem_;
|
|
584 | - |
|
585 | - currentGlyphPointNumbersItem_ = NULL;
|
|
586 | - }
|
|
587 | - |
|
588 | - syncSettings();
|
|
589 | - FT_Outline* outline = engine_->loadOutline(currentGlyphIndex_);
|
|
590 | - if (outline)
|
|
591 | - {
|
|
592 | - if (settingPanel_->showBitmapChecked())
|
|
593 | - {
|
|
594 | - // XXX support LCD
|
|
595 | - FT_Pixel_Mode pixelMode = FT_PIXEL_MODE_GRAY;
|
|
596 | - if (settingPanel_->antiAliasingModeIndex()
|
|
597 | - == AntiAliasingComboBoxModel::AntiAliasing_None)
|
|
598 | - pixelMode = FT_PIXEL_MODE_MONO;
|
|
599 | - |
|
600 | - currentGlyphBitmapItem_ = new GlyphBitmap(outline,
|
|
601 | - engine_->ftLibrary(),
|
|
602 | - pixelMode,
|
|
603 | - monoColorTable_,
|
|
604 | - grayColorTable_);
|
|
605 | - glyphScene_->addItem(currentGlyphBitmapItem_);
|
|
606 | - }
|
|
607 | - |
|
608 | - if (settingPanel_->showOutLinesChecked())
|
|
609 | - {
|
|
610 | - currentGlyphOutlineItem_ = new GlyphOutline(outlinePen_, outline);
|
|
611 | - glyphScene_->addItem(currentGlyphOutlineItem_);
|
|
612 | - }
|
|
613 | - |
|
614 | - if (settingPanel_->showPointsChecked())
|
|
615 | - {
|
|
616 | - currentGlyphPointsItem_ = new GlyphPoints(onPen_, offPen_, outline);
|
|
617 | - glyphScene_->addItem(currentGlyphPointsItem_);
|
|
618 | - |
|
619 | - if (settingPanel_->showPointNumbersChecked())
|
|
620 | - {
|
|
621 | - currentGlyphPointNumbersItem_ = new GlyphPointNumbers(onPen_,
|
|
622 | - offPen_,
|
|
623 | - outline);
|
|
624 | - glyphScene_->addItem(currentGlyphPointNumbersItem_);
|
|
625 | - }
|
|
626 | - }
|
|
627 | - }
|
|
628 | - |
|
629 | - glyphScene_->update();
|
|
630 | -}
|
|
631 | - |
|
632 | - |
|
633 | 418 | // XXX distances are specified in pixels,
|
634 | 419 | // making the layout dependent on the output device resolution
|
635 | 420 | void
|
... | ... | @@ -660,70 +445,15 @@ MainGUI::createLayout() |
660 | 445 | leftWidget_->setSizePolicy(leftWidgetPolicy);
|
661 | 446 | |
662 | 447 | // right side
|
663 | - glyphIndexLabel_ = new QLabel(this);
|
|
664 | - glyphNameLabel_ = new QLabel(this);
|
|
665 | 448 | fontNameLabel_ = new QLabel(this);
|
666 | 449 | |
667 | - glyphScene_ = new QGraphicsScene(this);
|
|
668 | - |
|
669 | - currentGlyphBitmapItem_ = NULL;
|
|
670 | - currentGlyphOutlineItem_ = NULL;
|
|
671 | - currentGlyphPointsItem_ = NULL;
|
|
672 | - currentGlyphPointNumbersItem_ = NULL;
|
|
673 | - |
|
674 | - glyphView_ = new QGraphicsViewx(this);
|
|
675 | - glyphView_->setRenderHint(QPainter::Antialiasing, true);
|
|
676 | - glyphView_->setDragMode(QGraphicsView::ScrollHandDrag);
|
|
677 | - glyphView_->setOptimizationFlags(QGraphicsView::DontSavePainterState);
|
|
678 | - glyphView_->setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
|
|
679 | - glyphView_->setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
|
|
680 | - glyphView_->setScene(glyphScene_);
|
|
681 | -
|
|
682 | - gridItem_ = new Grid(glyphView_, gridPen_, axisPen_);
|
|
683 | - glyphScene_->addItem(gridItem_);
|
|
684 | - |
|
685 | - // Don't use QGraphicsTextItem: We want this hint to be anchored at the
|
|
686 | - // top-left corner.
|
|
687 | - mouseUsageHint_ = new QLabel(tr("Scroll: Grid Up/Down\n"
|
|
688 | - "Alt + Scroll: Grid Left/Right\n"
|
|
689 | - "Ctrl + Scroll: Adjust Zoom (Relative to cursor)\n"
|
|
690 | - "Shift + Scroll: Adjust Font Size"), glyphView_);
|
|
691 | - mouseUsageHint_->setMargin(10);
|
|
692 | - auto hintFont = font();
|
|
693 | - hintFont.setPixelSize(24);
|
|
694 | - mouseUsageHint_->setFont(hintFont);
|
|
695 | - |
|
696 | - sizeLabel_ = new QLabel(tr("Size "), this);
|
|
697 | - sizeLabel_->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
|
698 | - sizeDoubleSpinBox_ = new QDoubleSpinBox;
|
|
699 | - sizeDoubleSpinBox_->setAlignment(Qt::AlignRight);
|
|
700 | - sizeDoubleSpinBox_->setDecimals(1);
|
|
701 | - sizeDoubleSpinBox_->setRange(1, 500);
|
|
702 | - sizeLabel_->setBuddy(sizeDoubleSpinBox_);
|
|
703 | - |
|
704 | - indexSelector_ = new GlyphIndexSelector(this);
|
|
705 | - indexSelector_->setSingleMode(true);
|
|
706 | - |
|
707 | - unitsComboBox_ = new QComboBox(this);
|
|
708 | - unitsComboBox_->insertItem(Units_px, "px");
|
|
709 | - unitsComboBox_->insertItem(Units_pt, "pt");
|
|
710 | - |
|
711 | - dpiLabel_ = new QLabel(tr("DPI "), this);
|
|
712 | - dpiLabel_->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
|
713 | - dpiSpinBox_ = new QSpinBox(this);
|
|
714 | - dpiSpinBox_->setAlignment(Qt::AlignRight);
|
|
715 | - dpiSpinBox_->setRange(10, 600);
|
|
716 | - dpiLabel_->setBuddy(dpiSpinBox_);
|
|
717 | - |
|
718 | - zoomLabel_ = new QLabel(tr("Zoom Factor"), this);
|
|
719 | - zoomLabel_->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
|
720 | - zoomSpinBox_ = new QSpinBoxx(this);
|
|
721 | - zoomSpinBox_->setAlignment(Qt::AlignRight);
|
|
722 | - zoomSpinBox_->setRange(1, 1000 - 1000 % 64);
|
|
723 | - zoomSpinBox_->setKeyboardTracking(false);
|
|
724 | - zoomLabel_->setBuddy(zoomSpinBox_);
|
|
725 | - |
|
726 | - centerGridButton_ = new QPushButton("Go Back to Grid Center", this);
|
|
450 | + singularTab_ = new SingularTab(this, engine_);
|
|
451 | + |
|
452 | + tabWidget_ = new QTabWidget(this);
|
|
453 | + |
|
454 | + // Note those two list must be in sync
|
|
455 | + tabs_.append(singularTab_);
|
|
456 | + tabWidget_->addTab(singularTab_, tr("Singular Grid View"));
|
|
727 | 457 | |
728 | 458 | previousFontButton_ = new QPushButton(tr("Previous Font"), this);
|
729 | 459 | nextFontButton_ = new QPushButton(tr("Next Font"), this);
|
... | ... | @@ -733,26 +463,6 @@ MainGUI::createLayout() |
733 | 463 | = new QPushButton(tr("Previous Named Instance"), this);
|
734 | 464 | nextNamedInstanceButton_ = new QPushButton(tr("Next Named Instance"), this);
|
735 | 465 | |
736 | - infoRightLayout = new QGridLayout;
|
|
737 | - infoRightLayout->addWidget(glyphIndexLabel_, 0, 0);
|
|
738 | - infoRightLayout->addWidget(glyphNameLabel_, 0, 1);
|
|
739 | - infoRightLayout->addWidget(fontNameLabel_, 0, 2);
|
|
740 | - |
|
741 | - sizeLayout_ = new QHBoxLayout;
|
|
742 | - sizeLayout_->addStretch(2);
|
|
743 | - sizeLayout_->addWidget(sizeLabel_);
|
|
744 | - sizeLayout_->addWidget(sizeDoubleSpinBox_);
|
|
745 | - sizeLayout_->addWidget(unitsComboBox_);
|
|
746 | - sizeLayout_->addStretch(1);
|
|
747 | - sizeLayout_->addWidget(dpiLabel_);
|
|
748 | - sizeLayout_->addWidget(dpiSpinBox_);
|
|
749 | - sizeLayout_->addStretch(1);
|
|
750 | - sizeLayout_->addWidget(zoomLabel_);
|
|
751 | - sizeLayout_->addWidget(zoomSpinBox_);
|
|
752 | - sizeLayout_->addStretch(1);
|
|
753 | - sizeLayout_->addWidget(centerGridButton_);
|
|
754 | - sizeLayout_->addStretch(2);
|
|
755 | - |
|
756 | 466 | fontLayout = new QGridLayout;
|
757 | 467 | fontLayout->setColumnStretch(0, 2);
|
758 | 468 | fontLayout->addWidget(nextFontButton_, 0, 1);
|
... | ... | @@ -766,12 +476,8 @@ MainGUI::createLayout() |
766 | 476 | fontLayout->setColumnStretch(6, 2);
|
767 | 477 | |
768 | 478 | rightLayout_ = new QVBoxLayout;
|
769 | - rightLayout_->addLayout(infoRightLayout);
|
|
770 | - rightLayout_->addWidget(glyphView_);
|
|
771 | - rightLayout_->addWidget(indexSelector_);
|
|
772 | - rightLayout_->addSpacing(10); // XXX px
|
|
773 | - rightLayout_->addLayout(sizeLayout_);
|
|
774 | - rightLayout_->addSpacing(10); // XXX px
|
|
479 | + rightLayout_->addWidget(fontNameLabel_);
|
|
480 | + rightLayout_->addWidget(tabWidget_);
|
|
775 | 481 | rightLayout_->addLayout(fontLayout);
|
776 | 482 | |
777 | 483 | // for symmetry with the left side use a widget also
|
... | ... | @@ -796,29 +502,7 @@ MainGUI::createConnections() |
796 | 502 | connect(settingPanel_, &SettingPanel::fontReloadNeeded,
|
797 | 503 | this, &MainGUI::showFont);
|
798 | 504 | connect(settingPanel_, &SettingPanel::repaintNeeded,
|
799 | - this, &MainGUI::drawGlyph);
|
|
800 | - connect(indexSelector_, &GlyphIndexSelector::currentIndexChanged,
|
|
801 | - this, &MainGUI::setGlyphIndex);
|
|
802 | - connect(sizeDoubleSpinBox_, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
|
|
803 | - this, &MainGUI::drawGlyph);
|
|
804 | - connect(unitsComboBox_, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
|
805 | - this, &MainGUI::checkUnits);
|
|
806 | - connect(dpiSpinBox_, QOverload<int>::of(&QSpinBox::valueChanged),
|
|
807 | - this, &MainGUI::drawGlyph);
|
|
808 | - |
|
809 | - connect(zoomSpinBox_, QOverload<int>::of(&QSpinBox::valueChanged),
|
|
810 | - this, &MainGUI::zoom);
|
|
811 | - connect(glyphView_, &QGraphicsViewx::shiftWheelEvent,
|
|
812 | - this, &MainGUI::wheelResize);
|
|
813 | - connect(glyphView_, &QGraphicsViewx::ctrlWheelEvent,
|
|
814 | - this, &MainGUI::wheelZoom);
|
|
815 | - connect(glyphView_->horizontalScrollBar(), &QScrollBar::valueChanged,
|
|
816 | - this, &MainGUI::updateGrid);
|
|
817 | - connect(glyphView_->verticalScrollBar(), &QScrollBar::valueChanged,
|
|
818 | - this, &MainGUI::updateGrid);
|
|
819 | - |
|
820 | - connect(centerGridButton_, &QPushButton::clicked,
|
|
821 | - this, &MainGUI::backToCenter);
|
|
505 | + this, &MainGUI::repaintCurrentTab);
|
|
822 | 506 | |
823 | 507 | connect(previousFontButton_, &QPushButton::clicked,
|
824 | 508 | this, &MainGUI::previousFont);
|
... | ... | @@ -886,7 +570,6 @@ void |
886 | 570 | MainGUI::setupDragDrop()
|
887 | 571 | {
|
888 | 572 | setAcceptDrops(true);
|
889 | - glyphView_->setAcceptDrops(false);
|
|
890 | 573 | }
|
891 | 574 | |
892 | 575 | |
... | ... | @@ -897,19 +580,12 @@ MainGUI::setDefaults() |
897 | 580 | currentFontIndex_ = 0;
|
898 | 581 | currentFaceIndex_ = 0;
|
899 | 582 | currentNamedInstanceIndex_ = 0;
|
900 | - currentGlyphIndex_ = 0;
|
|
901 | - |
|
902 | - sizeDoubleSpinBox_->setValue(20);
|
|
903 | - dpiSpinBox_->setValue(96);
|
|
904 | - zoomSpinBox_->setValue(20);
|
|
905 | 583 | |
906 | - // todo run check for settingpanel
|
|
907 | - checkUnits();
|
|
584 | + for (auto tab : tabs_)
|
|
585 | + tab->setDefaults();
|
|
908 | 586 | checkCurrentFontIndex();
|
909 | 587 | checkCurrentFaceIndex();
|
910 | 588 | checkCurrentNamedInstanceIndex();
|
911 | - indexSelector_->setCurrentIndex(indexSelector_->getCurrentIndex(), true);
|
|
912 | - zoom();
|
|
913 | 589 | }
|
914 | 590 | |
915 | 591 |
... | ... | @@ -6,15 +6,11 @@ |
6 | 6 | #pragma once
|
7 | 7 | |
8 | 8 | #include "engine/engine.hpp"
|
9 | -#include "rendering/glyphbitmap.hpp"
|
|
10 | -#include "rendering/glyphoutline.hpp"
|
|
11 | -#include "rendering/glyphpointnumbers.hpp"
|
|
12 | -#include "rendering/glyphpoints.hpp"
|
|
13 | -#include "rendering/grid.hpp"
|
|
14 | 9 | #include "widgets/customwidgets.hpp"
|
15 | 10 | #include "widgets/glyphindexselector.hpp"
|
16 | 11 | #include "models/ttsettingscomboboxmodel.hpp"
|
17 | 12 | #include "panels/settingpanel.hpp"
|
13 | +#include "panels/singular.hpp"
|
|
18 | 14 | |
19 | 15 | #include <QAction>
|
20 | 16 | #include <QCheckBox>
|
... | ... | @@ -72,14 +68,13 @@ protected: |
72 | 68 | private slots:
|
73 | 69 | void about();
|
74 | 70 | void aboutQt();
|
75 | - void setGlyphIndex(int);
|
|
76 | 71 | void checkCurrentFaceIndex();
|
77 | 72 | void checkCurrentFontIndex();
|
78 | 73 | void checkCurrentNamedInstanceIndex();
|
79 | - void checkUnits();
|
|
80 | 74 | void closeFont();
|
81 | 75 | void showFont();
|
82 | - void drawGlyph();
|
|
76 | + void repaintCurrentTab();
|
|
77 | + void reloadCurrentTabFont();
|
|
83 | 78 | void loadFonts();
|
84 | 79 | void nextFace();
|
85 | 80 | void nextFont();
|
... | ... | @@ -88,11 +83,6 @@ private slots: |
88 | 83 | void previousFont();
|
89 | 84 | void previousNamedInstance();
|
90 | 85 | void watchCurrentFont();
|
91 | - void zoom();
|
|
92 | - void backToCenter();
|
|
93 | - void updateGrid();
|
|
94 | - void wheelZoom(QWheelEvent* event);
|
|
95 | - void wheelResize(QWheelEvent* event);
|
|
96 | 86 | |
97 | 87 | private:
|
98 | 88 | Engine* engine_;
|
... | ... | @@ -106,86 +96,46 @@ private: |
106 | 96 | int currentNamedInstanceIndex_;
|
107 | 97 | |
108 | 98 | int currentNumberOfGlyphs_;
|
109 | - int currentGlyphIndex_;
|
|
110 | 99 | |
111 | 100 | // layout related stuff
|
112 | - GlyphOutline *currentGlyphOutlineItem_;
|
|
113 | - GlyphPoints *currentGlyphPointsItem_;
|
|
114 | - GlyphPointNumbers *currentGlyphPointNumbersItem_;
|
|
115 | - GlyphBitmap *currentGlyphBitmapItem_;
|
|
116 | - Grid *gridItem_ = NULL;
|
|
117 | - QLabel* mouseUsageHint_;
|
|
118 | - |
|
119 | 101 | QAction *aboutAct_;
|
120 | 102 | QAction *aboutQtAct_;
|
121 | 103 | QAction *closeFontAct_;
|
122 | 104 | QAction *exitAct_;
|
123 | 105 | QAction *loadFontsAct_;
|
124 | 106 | |
125 | - GlyphIndexSelector* indexSelector_;
|
|
126 | - QComboBox *unitsComboBox_;
|
|
127 | - |
|
128 | - QDoubleSpinBox *sizeDoubleSpinBox_;
|
|
129 | - |
|
130 | - QGraphicsScene *glyphScene_;
|
|
131 | - QGraphicsViewx *glyphView_;
|
|
132 | - |
|
133 | 107 | QGridLayout *fontLayout;
|
134 | - QGridLayout *infoRightLayout;
|
|
135 | 108 | |
136 | 109 | QHBoxLayout *ftinspectLayout_;
|
137 | 110 | QHBoxLayout *infoLeftLayout_;
|
138 | - QHBoxLayout *sizeLayout_;
|
|
139 | 111 | |
140 | - QLabel *dpiLabel_;
|
|
141 | 112 | QLabel *fontFilenameLabel_;
|
142 | 113 | QLabel *fontNameLabel_;
|
143 | - QLabel *glyphIndexLabel_;
|
|
144 | - QLabel *glyphNameLabel_;
|
|
145 | - QLabel *sizeLabel_;
|
|
146 | - QLabel *zoomLabel_;
|
|
147 | 114 | |
148 | 115 | QLocale *locale_;
|
149 | 116 | |
150 | 117 | QMenu *menuFile_;
|
151 | 118 | QMenu *menuHelp_;
|
152 | 119 | |
153 | - QPen axisPen_;
|
|
154 | - QPen blueZonePen_;
|
|
155 | - QPen gridPen_;
|
|
156 | - QPen offPen_;
|
|
157 | - QPen onPen_;
|
|
158 | - QPen outlinePen_;
|
|
159 | - QPen segmentPen_;
|
|
160 | - |
|
161 | - QPushButton *centerGridButton_;
|
|
162 | 120 | QPushButton *nextFaceButton_;
|
163 | 121 | QPushButton *nextFontButton_;
|
164 | 122 | QPushButton *nextNamedInstanceButton_;
|
165 | 123 | QPushButton *previousFaceButton_;
|
166 | 124 | QPushButton *previousFontButton_;
|
167 | 125 | QPushButton *previousNamedInstanceButton_;
|
168 | - |
|
169 | - QSpinBox *dpiSpinBox_;
|
|
170 | - QSpinBoxx *zoomSpinBox_;
|
|
171 | 126 |
|
172 | 127 | QVBoxLayout *leftLayout_;
|
173 | 128 | QVBoxLayout *rightLayout_;
|
174 | 129 | |
175 | - QVector<QRgb> grayColorTable_;
|
|
176 | - QVector<QRgb> monoColorTable_;
|
|
177 | - |
|
178 | 130 | QWidget *ftinspectWidget_;
|
179 | 131 | QWidget *leftWidget_;
|
180 | 132 | QWidget *rightWidget_;
|
181 | 133 | |
182 | 134 | SettingPanel* settingPanel_;
|
183 | 135 | |
184 | - enum Units
|
|
185 | - {
|
|
186 | - Units_px,
|
|
187 | - Units_pt
|
|
188 | - };
|
|
136 | + QTabWidget* tabWidget_;
|
|
137 | + QVector<AbstractTab*> tabs_;
|
|
138 | + SingularTab* singularTab_;
|
|
189 | 139 | |
190 | 140 | void openFonts(QStringList const& fileNames);
|
191 | 141 | |
... | ... | @@ -197,7 +147,6 @@ private: |
197 | 147 | void createLayout();
|
198 | 148 | void createMenus();
|
199 | 149 | void createStatusBar();
|
200 | - void setGraphicsDefaults();
|
|
201 | 150 | void setupDragDrop();
|
202 | 151 | |
203 | 152 | void readSettings();
|
... | ... | @@ -34,6 +34,7 @@ if qt5_dep.found() |
34 | 34 | 'models/ttsettingscomboboxmodel.cpp',
|
35 | 35 | |
36 | 36 | 'panels/settingpanel.cpp',
|
37 | + 'panels/singular.cpp',
|
|
37 | 38 | |
38 | 39 | 'ftinspect.cpp',
|
39 | 40 | 'maingui.cpp',
|
... | ... | @@ -47,6 +48,7 @@ if qt5_dep.found() |
47 | 48 | 'widgets/glyphindexselector.hpp',
|
48 | 49 | 'models/ttsettingscomboboxmodel.hpp',
|
49 | 50 | 'panels/settingpanel.hpp',
|
51 | + 'panels/singular.hpp',
|
|
50 | 52 | 'maingui.hpp',
|
51 | 53 | ],
|
52 | 54 | dependencies: qt5_dep)
|
1 | +// abstracttab.hpp
|
|
2 | + |
|
3 | +// Copyright (C) 2022 by Charlie Jiang.
|
|
4 | + |
|
5 | +#pragma once
|
|
6 | + |
|
7 | +// This is an pure abstract interface for a ftinspect "tab".
|
|
8 | +// The interface itself does not inherit from `QWidget`, but should be used as
|
|
9 | +// the second base class.
|
|
10 | +class AbstractTab
|
|
11 | +{
|
|
12 | +public:
|
|
13 | + virtual ~AbstractTab() = default; // must be `virtual` for `dynamic_cast`
|
|
14 | + |
|
15 | + virtual void syncSettings() = 0;
|
|
16 | + virtual void setDefaults() = 0;
|
|
17 | + virtual void repaint() = 0;
|
|
18 | + virtual void reloadFont() = 0;
|
|
19 | +};
|
|
20 | + |
|
21 | + |
|
22 | +// end of abstracttab.hpp |
... | ... | @@ -22,34 +22,6 @@ SettingPanel::antiAliasingModeIndex() |
22 | 22 | }
|
23 | 23 | |
24 | 24 | |
25 | -bool
|
|
26 | -SettingPanel::showBitmapChecked()
|
|
27 | -{
|
|
28 | - return showBitmapCheckBox_->isChecked();
|
|
29 | -}
|
|
30 | - |
|
31 | - |
|
32 | -bool
|
|
33 | -SettingPanel::showOutLinesChecked()
|
|
34 | -{
|
|
35 | - return showOutlinesCheckBox_->isChecked();
|
|
36 | -}
|
|
37 | - |
|
38 | - |
|
39 | -bool
|
|
40 | -SettingPanel::showPointNumbersChecked()
|
|
41 | -{
|
|
42 | - return showPointNumbersCheckBox_->isChecked();
|
|
43 | -}
|
|
44 | - |
|
45 | - |
|
46 | -bool
|
|
47 | -SettingPanel::showPointsChecked()
|
|
48 | -{
|
|
49 | - return showPointsCheckBox_->isChecked();
|
|
50 | -}
|
|
51 | - |
|
52 | - |
|
53 | 25 | void
|
54 | 26 | SettingPanel::checkAllSettings()
|
55 | 27 | {
|
... | ... | @@ -57,7 +29,6 @@ SettingPanel::checkAllSettings() |
57 | 29 | checkAutoHinting();
|
58 | 30 | checkAntiAliasing();
|
59 | 31 | checkLCDFilter();
|
60 | - checkShowPoints();
|
|
61 | 32 | }
|
62 | 33 | |
63 | 34 | |
... | ... | @@ -196,17 +167,6 @@ SettingPanel::checkAntiAliasing() |
196 | 167 | }
|
197 | 168 | |
198 | 169 | |
199 | -void
|
|
200 | -SettingPanel::checkShowPoints()
|
|
201 | -{
|
|
202 | - if (showPointsCheckBox_->isChecked())
|
|
203 | - showPointNumbersCheckBox_->setEnabled(true);
|
|
204 | - else
|
|
205 | - showPointNumbersCheckBox_->setEnabled(false);
|
|
206 | - emit repaintNeeded();
|
|
207 | -}
|
|
208 | - |
|
209 | - |
|
210 | 170 | void
|
211 | 171 | SettingPanel::checkLCDFilter()
|
212 | 172 | {
|
... | ... | @@ -222,6 +182,8 @@ SettingPanel::syncSettings() |
222 | 182 | lcdFilterComboBox_->currentIndex())));
|
223 | 183 | engine_->setAntiAliasingTarget(antiAliasingComboBoxModel_->indexToValue(
|
224 | 184 | antiAliasingComboBox_->currentIndex()));
|
185 | + engine_->setAntiAliasingEnabled(antiAliasingComboBox_->currentIndex()
|
|
186 | + != AntiAliasingComboBoxModel::AntiAliasing_None);
|
|
225 | 187 | engine_->setHinting(hintingCheckBox_->isChecked());
|
226 | 188 | engine_->setAutoHinting(autoHintingCheckBox_->isChecked());
|
227 | 189 | engine_->setHorizontalHinting(horizontalHintingCheckBox_->isChecked());
|
... | ... | @@ -264,14 +226,6 @@ SettingPanel::createConnections() |
264 | 226 | |
265 | 227 | connect(autoHintingCheckBox_, &QCheckBox::clicked,
|
266 | 228 | this, &SettingPanel::checkAutoHinting);
|
267 | - connect(showBitmapCheckBox_, &QCheckBox::clicked,
|
|
268 | - this, &SettingPanel::repaintNeeded);
|
|
269 | - connect(showPointsCheckBox_, &QCheckBox::clicked,
|
|
270 | - this, &SettingPanel::repaintNeeded);
|
|
271 | - connect(showPointNumbersCheckBox_, &QCheckBox::clicked,
|
|
272 | - this, &SettingPanel::repaintNeeded);
|
|
273 | - connect(showOutlinesCheckBox_, &QCheckBox::clicked,
|
|
274 | - this, &SettingPanel::repaintNeeded);
|
|
275 | 229 | }
|
276 | 230 | |
277 | 231 | |
... | ... | @@ -336,11 +290,6 @@ SettingPanel::createLayout() |
336 | 290 | gammaSlider_->setTickInterval(5);
|
337 | 291 | gammaLabel_->setBuddy(gammaSlider_);
|
338 | 292 | |
339 | - showBitmapCheckBox_ = new QCheckBox(tr("Show Bitmap"), this);
|
|
340 | - showPointsCheckBox_ = new QCheckBox(tr("Show Points"), this);
|
|
341 | - showPointNumbersCheckBox_ = new QCheckBox(tr("Show Point Numbers"), this);
|
|
342 | - showOutlinesCheckBox_ = new QCheckBox(tr("Show Outlines"), this);
|
|
343 | - |
|
344 | 293 | hintingModeLayout_ = new QHBoxLayout;
|
345 | 294 | hintingModeLayout_->addWidget(hintingModeLabel_);
|
346 | 295 | hintingModeLayout_->addWidget(hintingModeComboBox_);
|
... | ... | @@ -373,10 +322,6 @@ SettingPanel::createLayout() |
373 | 322 | gammaLayout_->addWidget(gammaLabel_);
|
374 | 323 | gammaLayout_->addWidget(gammaSlider_);
|
375 | 324 | |
376 | - pointNumbersLayout_ = new QHBoxLayout;
|
|
377 | - pointNumbersLayout_->addSpacing(20); // XXX px
|
|
378 | - pointNumbersLayout_->addWidget(showPointNumbersCheckBox_);
|
|
379 | - |
|
380 | 325 | generalTabLayout_ = new QVBoxLayout;
|
381 | 326 | generalTabLayout_->addWidget(hintingCheckBox_);
|
382 | 327 | generalTabLayout_->addLayout(hintingModeLayout_);
|
... | ... | @@ -394,10 +339,6 @@ SettingPanel::createLayout() |
394 | 339 | generalTabLayout_->addLayout(gammaLayout_);
|
395 | 340 | generalTabLayout_->addSpacing(20); // XXX px
|
396 | 341 | generalTabLayout_->addStretch(1);
|
397 | - generalTabLayout_->addWidget(showBitmapCheckBox_);
|
|
398 | - generalTabLayout_->addWidget(showPointsCheckBox_);
|
|
399 | - generalTabLayout_->addLayout(pointNumbersLayout_);
|
|
400 | - generalTabLayout_->addWidget(showOutlinesCheckBox_);
|
|
401 | 342 | |
402 | 343 | generalTab_ = new QWidget(this);
|
403 | 344 | generalTab_->setLayout(generalTabLayout_);
|
... | ... | @@ -444,9 +385,6 @@ SettingPanel::setDefaults() |
444 | 385 | verticalHintingCheckBox_->setChecked(true);
|
445 | 386 | blueZoneHintingCheckBox_->setChecked(true);
|
446 | 387 | |
447 | - showBitmapCheckBox_->setChecked(true);
|
|
448 | - showOutlinesCheckBox_->setChecked(true);
|
|
449 | - |
|
450 | 388 | gammaSlider_->setValue(18); // 1.8
|
451 | 389 | }
|
452 | 390 |
... | ... | @@ -28,12 +28,6 @@ public: |
28 | 28 | |
29 | 29 | int antiAliasingModeIndex();
|
30 | 30 | |
31 | - // TODO This would eventually go to separate panel for ftglyph (Singular View)
|
|
32 | - bool showBitmapChecked();
|
|
33 | - bool showOutLinesChecked();
|
|
34 | - bool showPointNumbersChecked();
|
|
35 | - bool showPointsChecked();
|
|
36 | - |
|
37 | 31 | signals:
|
38 | 32 | void fontReloadNeeded();
|
39 | 33 | void repaintNeeded();
|
... | ... | @@ -46,7 +40,6 @@ public slots: |
46 | 40 | void checkHintingMode();
|
47 | 41 | void checkAutoHinting();
|
48 | 42 | void checkAntiAliasing();
|
49 | - void checkShowPoints();
|
|
50 | 43 | void checkLCDFilter();
|
51 | 44 | |
52 | 45 | private:
|
... | ... | @@ -71,10 +64,6 @@ private: |
71 | 64 | QCheckBox* blueZoneHintingCheckBox_;
|
72 | 65 | QCheckBox* segmentDrawingCheckBox_;
|
73 | 66 | QCheckBox* autoHintingCheckBox_;
|
74 | - QCheckBox* showBitmapCheckBox_;
|
|
75 | - QCheckBox* showOutlinesCheckBox_;
|
|
76 | - QCheckBox* showPointNumbersCheckBox_;
|
|
77 | - QCheckBox* showPointsCheckBox_;
|
|
78 | 67 | |
79 | 68 | AntiAliasingComboBoxModel* antiAliasingComboBoxModel_;
|
80 | 69 | HintingModeComboBoxModel* hintingModeComboBoxModel_;
|
... | ... | @@ -95,7 +84,6 @@ private: |
95 | 84 | QHBoxLayout* antiAliasingLayout_;
|
96 | 85 | QHBoxLayout* lcdFilterLayout_;
|
97 | 86 | QHBoxLayout* gammaLayout_;
|
98 | - QHBoxLayout* pointNumbersLayout_;
|
|
99 | 87 | |
100 | 88 | QVBoxLayout* generalTabLayout_;
|
101 | 89 |
1 | +// singular.cpp
|
|
2 | + |
|
3 | +// Copyright (C) 2022 by Charlie Jiang.
|
|
4 | + |
|
5 | +#include "singular.hpp"
|
|
6 | + |
|
7 | +#include <QSizePolicy>
|
|
8 | +#include <QWheelEvent>
|
|
9 | + |
|
10 | + |
|
11 | +SingularTab::SingularTab(QWidget* parent, Engine* engine)
|
|
12 | +: QWidget(parent), engine_(engine)
|
|
13 | +{
|
|
14 | + setGraphicsDefaults();
|
|
15 | + createLayout();
|
|
16 | + createConnections();
|
|
17 | + |
|
18 | + currentGlyphIndex_ = 0;
|
|
19 | + checkShowPoints();
|
|
20 | + checkUnits();
|
|
21 | +}
|
|
22 | + |
|
23 | + |
|
24 | +SingularTab::~SingularTab()
|
|
25 | +{
|
|
26 | + delete gridItem_;
|
|
27 | + gridItem_ = NULL;
|
|
28 | +}
|
|
29 | + |
|
30 | + |
|
31 | +void
|
|
32 | +SingularTab::setGlyphIndex(int index)
|
|
33 | +{
|
|
34 | + // only adjust current glyph index if we have a valid font
|
|
35 | + if (currentGlyphCount_ > 0)
|
|
36 | + {
|
|
37 | + currentGlyphIndex_ = qBound(0, index, currentGlyphCount_ - 1);
|
|
38 | + }
|
|
39 | + |
|
40 | + QString upperHex = QString::number(currentGlyphIndex_, 16).toUpper();
|
|
41 | + glyphIndexLabel_->setText(
|
|
42 | + QString("%1 (0x%2)").arg(currentGlyphIndex_).arg(upperHex));
|
|
43 | + glyphNameLabel_->setText(engine_->glyphName(currentGlyphIndex_));
|
|
44 | + |
|
45 | + drawGlyph();
|
|
46 | +}
|
|
47 | + |
|
48 | + |
|
49 | +void
|
|
50 | +SingularTab::drawGlyph()
|
|
51 | +{
|
|
52 | + // the call to `engine->loadOutline' updates FreeType's load flags
|
|
53 | + |
|
54 | + if (!engine_)
|
|
55 | + return;
|
|
56 | + |
|
57 | + if (currentGlyphBitmapItem_)
|
|
58 | + {
|
|
59 | + glyphScene_->removeItem(currentGlyphBitmapItem_);
|
|
60 | + delete currentGlyphBitmapItem_;
|
|
61 | + |
|
62 | + currentGlyphBitmapItem_ = NULL;
|
|
63 | + }
|
|
64 | + |
|
65 | + if (currentGlyphOutlineItem_)
|
|
66 | + {
|
|
67 | + glyphScene_->removeItem(currentGlyphOutlineItem_);
|
|
68 | + delete currentGlyphOutlineItem_;
|
|
69 | + |
|
70 | + currentGlyphOutlineItem_ = NULL;
|
|
71 | + }
|
|
72 | + |
|
73 | + if (currentGlyphPointsItem_)
|
|
74 | + {
|
|
75 | + glyphScene_->removeItem(currentGlyphPointsItem_);
|
|
76 | + delete currentGlyphPointsItem_;
|
|
77 | + |
|
78 | + currentGlyphPointsItem_ = NULL;
|
|
79 | + }
|
|
80 | + |
|
81 | + if (currentGlyphPointNumbersItem_)
|
|
82 | + {
|
|
83 | + glyphScene_->removeItem(currentGlyphPointNumbersItem_);
|
|
84 | + delete currentGlyphPointNumbersItem_;
|
|
85 | + |
|
86 | + currentGlyphPointNumbersItem_ = NULL;
|
|
87 | + }
|
|
88 | + |
|
89 | + syncSettings();
|
|
90 | + FT_Outline* outline = engine_->loadOutline(currentGlyphIndex_);
|
|
91 | + if (outline)
|
|
92 | + {
|
|
93 | + if (showBitmapCheckBox_->isChecked())
|
|
94 | + {
|
|
95 | + // XXX support LCD
|
|
96 | + FT_Pixel_Mode pixelMode = FT_PIXEL_MODE_GRAY;
|
|
97 | + if (!engine_->antiAliasingEnabled())
|
|
98 | + pixelMode = FT_PIXEL_MODE_MONO;
|
|
99 | + |
|
100 | + currentGlyphBitmapItem_ = new GlyphBitmap(outline,
|
|
101 | + engine_->ftLibrary(),
|
|
102 | + pixelMode,
|
|
103 | + monoColorTable_,
|
|
104 | + grayColorTable_);
|
|
105 | + glyphScene_->addItem(currentGlyphBitmapItem_);
|
|
106 | + }
|
|
107 | + |
|
108 | + if (showOutlinesCheckBox_->isChecked())
|
|
109 | + {
|
|
110 | + currentGlyphOutlineItem_ = new GlyphOutline(outlinePen_, outline);
|
|
111 | + glyphScene_->addItem(currentGlyphOutlineItem_);
|
|
112 | + }
|
|
113 | + |
|
114 | + if (showPointsCheckBox_->isChecked())
|
|
115 | + {
|
|
116 | + currentGlyphPointsItem_ = new GlyphPoints(onPen_, offPen_, outline);
|
|
117 | + glyphScene_->addItem(currentGlyphPointsItem_);
|
|
118 | + |
|
119 | + if (showPointNumbersCheckBox_->isChecked())
|
|
120 | + {
|
|
121 | + currentGlyphPointNumbersItem_ = new GlyphPointNumbers(onPen_,
|
|
122 | + offPen_,
|
|
123 | + outline);
|
|
124 | + glyphScene_->addItem(currentGlyphPointNumbersItem_);
|
|
125 | + }
|
|
126 | + }
|
|
127 | + }
|
|
128 | + |
|
129 | + glyphScene_->update();
|
|
130 | +}
|
|
131 | + |
|
132 | + |
|
133 | +void
|
|
134 | +SingularTab::checkUnits()
|
|
135 | +{
|
|
136 | + int index = unitsComboBox_->currentIndex();
|
|
137 | + |
|
138 | + if (index == Units_px)
|
|
139 | + {
|
|
140 | + dpiLabel_->setEnabled(false);
|
|
141 | + dpiSpinBox_->setEnabled(false);
|
|
142 | + sizeDoubleSpinBox_->setSingleStep(1);
|
|
143 | + sizeDoubleSpinBox_->setValue(qRound(sizeDoubleSpinBox_->value()));
|
|
144 | + }
|
|
145 | + else
|
|
146 | + {
|
|
147 | + dpiLabel_->setEnabled(true);
|
|
148 | + dpiSpinBox_->setEnabled(true);
|
|
149 | + sizeDoubleSpinBox_->setSingleStep(0.5);
|
|
150 | + }
|
|
151 | + |
|
152 | + drawGlyph();
|
|
153 | +}
|
|
154 | + |
|
155 | + |
|
156 | +void
|
|
157 | +SingularTab::checkShowPoints()
|
|
158 | +{
|
|
159 | + if (showPointsCheckBox_->isChecked())
|
|
160 | + showPointNumbersCheckBox_->setEnabled(true);
|
|
161 | + else
|
|
162 | + showPointNumbersCheckBox_->setEnabled(false);
|
|
163 | + drawGlyph();
|
|
164 | +}
|
|
165 | + |
|
166 | + |
|
167 | +void
|
|
168 | +SingularTab::zoom()
|
|
169 | +{
|
|
170 | + int scale = zoomSpinBox_->value();
|
|
171 | + |
|
172 | + QTransform transform;
|
|
173 | + transform.scale(scale, scale);
|
|
174 | + |
|
175 | + // we want horizontal and vertical 1px lines displayed with full pixels;
|
|
176 | + // we thus have to shift the coordinate system accordingly, using a value
|
|
177 | + // that represents 0.5px (i.e., half the 1px line width) after the scaling
|
|
178 | + qreal shift = 0.5 / scale;
|
|
179 | + transform.translate(shift, shift);
|
|
180 | + |
|
181 | + glyphView_->setTransform(transform);
|
|
182 | + updateGrid();
|
|
183 | +}
|
|
184 | + |
|
185 | + |
|
186 | +void
|
|
187 | +SingularTab::backToCenter()
|
|
188 | +{
|
|
189 | + glyphView_->centerOn(0, 0);
|
|
190 | + if (currentGlyphBitmapItem_)
|
|
191 | + glyphView_->ensureVisible(currentGlyphBitmapItem_);
|
|
192 | + else if (currentGlyphPointsItem_)
|
|
193 | + glyphView_->ensureVisible(currentGlyphPointsItem_);
|
|
194 | + |
|
195 | + updateGrid();
|
|
196 | +}
|
|
197 | + |
|
198 | + |
|
199 | +void
|
|
200 | +SingularTab::updateGrid()
|
|
201 | +{
|
|
202 | + if (gridItem_)
|
|
203 | + gridItem_->updateRect();
|
|
204 | +}
|
|
205 | + |
|
206 | + |
|
207 | +void
|
|
208 | +SingularTab::wheelZoom(QWheelEvent* event)
|
|
209 | +{
|
|
210 | + int numSteps = event->angleDelta().y() / 120;
|
|
211 | + int zoomAfter = zoomSpinBox_->value() + numSteps;
|
|
212 | + zoomAfter = std::max(zoomSpinBox_->minimum(),
|
|
213 | + std::min(zoomAfter, zoomSpinBox_->maximum()));
|
|
214 | + zoomSpinBox_->setValue(zoomAfter);
|
|
215 | + // TODO: Zoom relative to viewport left-bottom?
|
|
216 | +}
|
|
217 | + |
|
218 | + |
|
219 | +void
|
|
220 | +SingularTab::wheelResize(QWheelEvent* event)
|
|
221 | +{
|
|
222 | + int numSteps = event->angleDelta().y() / 120;
|
|
223 | + double sizeAfter = sizeDoubleSpinBox_->value() + numSteps * 0.5;
|
|
224 | + sizeAfter = std::max(sizeDoubleSpinBox_->minimum(),
|
|
225 | + std::min(sizeAfter, sizeDoubleSpinBox_->maximum()));
|
|
226 | + sizeDoubleSpinBox_->setValue(sizeAfter);
|
|
227 | +}
|
|
228 | + |
|
229 | + |
|
230 | +void
|
|
231 | +SingularTab::createLayout()
|
|
232 | +{
|
|
233 | + glyphScene_ = new QGraphicsScene(this);
|
|
234 | + |
|
235 | + currentGlyphBitmapItem_ = NULL;
|
|
236 | + currentGlyphOutlineItem_ = NULL;
|
|
237 | + currentGlyphPointsItem_ = NULL;
|
|
238 | + currentGlyphPointNumbersItem_ = NULL;
|
|
239 | + |
|
240 | + glyphView_ = new QGraphicsViewx(this);
|
|
241 | + glyphView_->setRenderHint(QPainter::Antialiasing, true);
|
|
242 | + glyphView_->setAcceptDrops(false);
|
|
243 | + glyphView_->setDragMode(QGraphicsView::ScrollHandDrag);
|
|
244 | + glyphView_->setOptimizationFlags(QGraphicsView::DontSavePainterState);
|
|
245 | + glyphView_->setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
|
|
246 | + glyphView_->setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
|
|
247 | + glyphView_->setScene(glyphScene_);
|
|
248 | + |
|
249 | + gridItem_ = new Grid(glyphView_, gridPen_, axisPen_);
|
|
250 | + glyphScene_->addItem(gridItem_);
|
|
251 | + |
|
252 | + // Don't use QGraphicsTextItem: We want this hint to be anchored at the
|
|
253 | + // top-left corner.
|
|
254 | + mouseUsageHint_ = new QLabel(tr(
|
|
255 | + "Scroll: Grid Up/Down\n"
|
|
256 | + "Alt + Scroll: Grid Left/Right\n"
|
|
257 | + "Ctrl + Scroll: Adjust Zoom (Relative to cursor)\n"
|
|
258 | + "Shift + Scroll: Adjust Font Size"),
|
|
259 | + glyphView_);
|
|
260 | + auto hintFont = font();
|
|
261 | + hintFont.setPixelSize(24);
|
|
262 | + mouseUsageHint_->setFont(hintFont);
|
|
263 | + mouseUsageHint_->setAttribute(Qt::WA_TransparentForMouseEvents, true);
|
|
264 | + |
|
265 | + glyphIndexLabel_ = new QLabel(glyphView_);
|
|
266 | + glyphNameLabel_ = new QLabel(glyphView_);
|
|
267 | + glyphIndexLabel_->setFont(hintFont);
|
|
268 | + glyphNameLabel_->setFont(hintFont);
|
|
269 | + glyphIndexLabel_->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
|
270 | + glyphNameLabel_->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
|
271 | + glyphIndexLabel_->setAttribute(Qt::WA_TransparentForMouseEvents, true);
|
|
272 | + glyphNameLabel_->setAttribute(Qt::WA_TransparentForMouseEvents, true);
|
|
273 | + |
|
274 | + sizeLabel_ = new QLabel(tr("Size "), this);
|
|
275 | + sizeLabel_->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
|
276 | + sizeDoubleSpinBox_ = new QDoubleSpinBox;
|
|
277 | + sizeDoubleSpinBox_->setAlignment(Qt::AlignRight);
|
|
278 | + sizeDoubleSpinBox_->setDecimals(1);
|
|
279 | + sizeDoubleSpinBox_->setRange(1, 500);
|
|
280 | + sizeLabel_->setBuddy(sizeDoubleSpinBox_);
|
|
281 | + |
|
282 | + indexSelector_ = new GlyphIndexSelector(this);
|
|
283 | + indexSelector_->setSingleMode(true);
|
|
284 | + |
|
285 | + unitsComboBox_ = new QComboBox(this);
|
|
286 | + unitsComboBox_->insertItem(Units_px, "px");
|
|
287 | + unitsComboBox_->insertItem(Units_pt, "pt");
|
|
288 | + |
|
289 | + dpiLabel_ = new QLabel(tr("DPI "), this);
|
|
290 | + dpiLabel_->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
|
291 | + dpiSpinBox_ = new QSpinBox(this);
|
|
292 | + dpiSpinBox_->setAlignment(Qt::AlignRight);
|
|
293 | + dpiSpinBox_->setRange(10, 600);
|
|
294 | + dpiLabel_->setBuddy(dpiSpinBox_);
|
|
295 | + |
|
296 | + zoomLabel_ = new QLabel(tr("Zoom Factor"), this);
|
|
297 | + zoomLabel_->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
|
298 | + zoomSpinBox_ = new ZoomSpinBox(this);
|
|
299 | + zoomSpinBox_->setAlignment(Qt::AlignRight);
|
|
300 | + zoomSpinBox_->setRange(1, 1000 - 1000 % 64);
|
|
301 | + zoomSpinBox_->setKeyboardTracking(false);
|
|
302 | + zoomLabel_->setBuddy(zoomSpinBox_);
|
|
303 | + |
|
304 | + centerGridButton_ = new QPushButton("Go Back to Grid Center", this);
|
|
305 | + |
|
306 | + showBitmapCheckBox_ = new QCheckBox(tr("Show Bitmap"), this);
|
|
307 | + showPointsCheckBox_ = new QCheckBox(tr("Show Points"), this);
|
|
308 | + showPointNumbersCheckBox_ = new QCheckBox(tr("Show Point Numbers"), this);
|
|
309 | + showOutlinesCheckBox_ = new QCheckBox(tr("Show Outlines"), this);
|
|
310 | + |
|
311 | + sizeLayout_ = new QHBoxLayout;
|
|
312 | + sizeLayout_->addStretch(2);
|
|
313 | + sizeLayout_->addWidget(sizeLabel_);
|
|
314 | + sizeLayout_->addWidget(sizeDoubleSpinBox_);
|
|
315 | + sizeLayout_->addWidget(unitsComboBox_);
|
|
316 | + sizeLayout_->addStretch(1);
|
|
317 | + sizeLayout_->addWidget(dpiLabel_);
|
|
318 | + sizeLayout_->addWidget(dpiSpinBox_);
|
|
319 | + sizeLayout_->addStretch(1);
|
|
320 | + sizeLayout_->addWidget(zoomLabel_);
|
|
321 | + sizeLayout_->addWidget(zoomSpinBox_);
|
|
322 | + sizeLayout_->addStretch(1);
|
|
323 | + sizeLayout_->addWidget(centerGridButton_);
|
|
324 | + sizeLayout_->addStretch(2);
|
|
325 | + |
|
326 | + checkBoxesLayout_ = new QHBoxLayout;
|
|
327 | + checkBoxesLayout_->setSpacing(10);
|
|
328 | + checkBoxesLayout_->addWidget(showBitmapCheckBox_);
|
|
329 | + checkBoxesLayout_->addWidget(showPointsCheckBox_);
|
|
330 | + checkBoxesLayout_->addWidget(showPointNumbersCheckBox_);
|
|
331 | + checkBoxesLayout_->addWidget(showOutlinesCheckBox_);
|
|
332 | + |
|
333 | + glyphOverlayIndexLayout_ = new QHBoxLayout;
|
|
334 | + glyphOverlayIndexLayout_->addWidget(glyphIndexLabel_);
|
|
335 | + glyphOverlayIndexLayout_->addWidget(glyphNameLabel_);
|
|
336 | + glyphOverlayLayout_ = new QGridLayout;
|
|
337 | + glyphOverlayLayout_->addWidget(mouseUsageHint_, 0, 0,
|
|
338 | + Qt::AlignTop | Qt::AlignLeft);
|
|
339 | + glyphOverlayLayout_->addLayout(glyphOverlayIndexLayout_, 0, 1,
|
|
340 | + Qt::AlignTop | Qt::AlignRight);
|
|
341 | + glyphView_->setLayout(glyphOverlayLayout_);
|
|
342 | + |
|
343 | + mainLayout_ = new QVBoxLayout;
|
|
344 | + mainLayout_->addWidget(glyphView_);
|
|
345 | + mainLayout_->addWidget(indexSelector_);
|
|
346 | + mainLayout_->addSpacing(10); // XXX px
|
|
347 | + mainLayout_->addLayout(sizeLayout_);
|
|
348 | + mainLayout_->addLayout(checkBoxesLayout_);
|
|
349 | + mainLayout_->addSpacing(10); // XXX px
|
|
350 | + |
|
351 | + setLayout(mainLayout_);
|
|
352 | +}
|
|
353 | + |
|
354 | + |
|
355 | +void
|
|
356 | +SingularTab::createConnections()
|
|
357 | +{
|
|
358 | + connect(indexSelector_, &GlyphIndexSelector::currentIndexChanged,
|
|
359 | + this, &SingularTab::setGlyphIndex);
|
|
360 | + connect(sizeDoubleSpinBox_, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
|
|
361 | + this, &SingularTab::drawGlyph);
|
|
362 | + connect(unitsComboBox_, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
|
363 | + this, &SingularTab::checkUnits);
|
|
364 | + connect(dpiSpinBox_, QOverload<int>::of(&QSpinBox::valueChanged),
|
|
365 | + this, &SingularTab::drawGlyph);
|
|
366 | + |
|
367 | + connect(zoomSpinBox_, QOverload<int>::of(&QSpinBox::valueChanged),
|
|
368 | + this, &SingularTab::zoom);
|
|
369 | + connect(glyphView_, &QGraphicsViewx::shiftWheelEvent,
|
|
370 | + this, &SingularTab::wheelResize);
|
|
371 | + connect(glyphView_, &QGraphicsViewx::ctrlWheelEvent,
|
|
372 | + this, &SingularTab::wheelZoom);
|
|
373 | + connect(glyphView_->horizontalScrollBar(), &QScrollBar::valueChanged,
|
|
374 | + this, &SingularTab::updateGrid);
|
|
375 | + connect(glyphView_->verticalScrollBar(), &QScrollBar::valueChanged,
|
|
376 | + this, &SingularTab::updateGrid);
|
|
377 | + |
|
378 | + connect(centerGridButton_, &QPushButton::clicked,
|
|
379 | + this, &SingularTab::backToCenter);
|
|
380 | + |
|
381 | + connect(showBitmapCheckBox_, &QCheckBox::clicked,
|
|
382 | + this, &SingularTab::drawGlyph);
|
|
383 | + connect(showPointsCheckBox_, &QCheckBox::clicked,
|
|
384 | + this, &SingularTab::checkShowPoints);
|
|
385 | + connect(showPointNumbersCheckBox_, &QCheckBox::clicked,
|
|
386 | + this, &SingularTab::drawGlyph);
|
|
387 | + connect(showOutlinesCheckBox_, &QCheckBox::clicked,
|
|
388 | + this, &SingularTab::drawGlyph);
|
|
389 | +}
|
|
390 | + |
|
391 | + |
|
392 | +void
|
|
393 | +SingularTab::setGraphicsDefaults()
|
|
394 | +{
|
|
395 | + // color tables (with suitable opacity values) for converting
|
|
396 | + // FreeType's pixmaps to something Qt understands
|
|
397 | + monoColorTable_.append(QColor(Qt::transparent).rgba());
|
|
398 | + monoColorTable_.append(QColor(Qt::black).rgba());
|
|
399 | + |
|
400 | + for (int i = 0xFF; i >= 0; i--)
|
|
401 | + grayColorTable_.append(qRgba(i, i, i, 0xFF - i));
|
|
402 | + |
|
403 | + // XXX make this user-configurable
|
|
404 | + |
|
405 | + axisPen_.setColor(Qt::black);
|
|
406 | + axisPen_.setWidth(0);
|
|
407 | + blueZonePen_.setColor(QColor(64, 64, 255, 64)); // light blue
|
|
408 | + blueZonePen_.setWidth(0);
|
|
409 | + gridPen_.setColor(Qt::lightGray);
|
|
410 | + gridPen_.setWidth(0);
|
|
411 | + offPen_.setColor(Qt::darkGreen);
|
|
412 | + offPen_.setWidth(3);
|
|
413 | + onPen_.setColor(Qt::red);
|
|
414 | + onPen_.setWidth(3);
|
|
415 | + outlinePen_.setColor(Qt::red);
|
|
416 | + outlinePen_.setWidth(0);
|
|
417 | + segmentPen_.setColor(QColor(64, 255, 128, 64)); // light green
|
|
418 | + segmentPen_.setWidth(0);
|
|
419 | +}
|
|
420 | + |
|
421 | + |
|
422 | +void
|
|
423 | +SingularTab::repaint()
|
|
424 | +{
|
|
425 | + drawGlyph();
|
|
426 | +}
|
|
427 | + |
|
428 | + |
|
429 | +void
|
|
430 | +SingularTab::reloadFont()
|
|
431 | +{
|
|
432 | + currentGlyphCount_ = engine_->currentFontNumberOfGlyphs();
|
|
433 | + indexSelector_->setMin(0);
|
|
434 | + indexSelector_->setMax(currentGlyphCount_);
|
|
435 | + indexSelector_->setCurrentIndex(indexSelector_->getCurrentIndex(), true);
|
|
436 | + drawGlyph();
|
|
437 | +}
|
|
438 | + |
|
439 | + |
|
440 | +void
|
|
441 | +SingularTab::syncSettings()
|
|
442 | +{
|
|
443 | + // Spinbox value cannot become negative
|
|
444 | + engine_->setDPI(static_cast<unsigned int>(dpiSpinBox_->value()));
|
|
445 | + |
|
446 | + if (unitsComboBox_->currentIndex() == Units_px)
|
|
447 | + engine_->setSizeByPixel(sizeDoubleSpinBox_->value());
|
|
448 | + else
|
|
449 | + engine_->setSizeByPoint(sizeDoubleSpinBox_->value());
|
|
450 | +}
|
|
451 | + |
|
452 | + |
|
453 | +void
|
|
454 | +SingularTab::setDefaults()
|
|
455 | +{
|
|
456 | + currentGlyphIndex_ = 0;
|
|
457 | + |
|
458 | + sizeDoubleSpinBox_->setValue(20);
|
|
459 | + dpiSpinBox_->setValue(96);
|
|
460 | + zoomSpinBox_->setValue(20);
|
|
461 | + showBitmapCheckBox_->setChecked(true);
|
|
462 | + showOutlinesCheckBox_->setChecked(true);
|
|
463 | + |
|
464 | + checkUnits();
|
|
465 | + indexSelector_->setCurrentIndex(indexSelector_->getCurrentIndex(), true);
|
|
466 | + zoom();
|
|
467 | +}
|
|
468 | + |
|
469 | + |
|
470 | +// end of singular.cpp |
1 | +// singular.hpp
|
|
2 | + |
|
3 | +// Copyright (C) 2022 by Charlie Jiang.
|
|
4 | + |
|
5 | +#pragma once
|
|
6 | + |
|
7 | +#include "abstracttab.hpp"
|
|
8 | +#include "../widgets/customwidgets.hpp"
|
|
9 | +#include "../widgets/glyphindexselector.hpp"
|
|
10 | +#include "../rendering/glyphbitmap.hpp"
|
|
11 | +#include "../rendering/glyphoutline.hpp"
|
|
12 | +#include "../rendering/glyphpointnumbers.hpp"
|
|
13 | +#include "../rendering/glyphpoints.hpp"
|
|
14 | +#include "../rendering/grid.hpp"
|
|
15 | +#include "../engine/engine.hpp"
|
|
16 | +#include "../models/ttsettingscomboboxmodel.hpp"
|
|
17 | + |
|
18 | +#include <QWidget>
|
|
19 | +#include <QPushButton>
|
|
20 | +#include <QSpinBox>
|
|
21 | +#include <QGraphicsScene>
|
|
22 | +#include <QGraphicsView>
|
|
23 | +#include <QScrollBar>
|
|
24 | +#include <QLabel>
|
|
25 | +#include <QComboBox>
|
|
26 | +#include <QPen>
|
|
27 | +#include <QCheckBox>
|
|
28 | +#include <QVector>
|
|
29 | +#include <QGridLayout>
|
|
30 | +#include <QBoxLayout>
|
|
31 | + |
|
32 | +class SingularTab
|
|
33 | +: public QWidget, public AbstractTab
|
|
34 | +{
|
|
35 | + Q_OBJECT
|
|
36 | +public:
|
|
37 | + SingularTab(QWidget* parent, Engine* engine);
|
|
38 | + virtual ~SingularTab();
|
|
39 | + |
|
40 | + void repaint();
|
|
41 | + void reloadFont();
|
|
42 | + void syncSettings();
|
|
43 | + void setDefaults();
|
|
44 | + |
|
45 | +private slots:
|
|
46 | + void setGlyphIndex(int);
|
|
47 | + void drawGlyph();
|
|
48 | + |
|
49 | + void checkUnits();
|
|
50 | + void checkShowPoints();
|
|
51 | + |
|
52 | + void zoom();
|
|
53 | + void backToCenter();
|
|
54 | + void wheelZoom(QWheelEvent* event);
|
|
55 | + void wheelResize(QWheelEvent* event);
|
|
56 | + |
|
57 | +private:
|
|
58 | + int currentGlyphIndex_;
|
|
59 | + int currentGlyphCount_;
|
|
60 | + |
|
61 | + Engine* engine_;
|
|
62 | + |
|
63 | + QGraphicsScene* glyphScene_;
|
|
64 | + QGraphicsViewx* glyphView_;
|
|
65 | + |
|
66 | + GlyphOutline* currentGlyphOutlineItem_;
|
|
67 | + GlyphPoints* currentGlyphPointsItem_;
|
|
68 | + GlyphPointNumbers* currentGlyphPointNumbersItem_;
|
|
69 | + GlyphBitmap* currentGlyphBitmapItem_;
|
|
70 | + Grid* gridItem_ = NULL;
|
|
71 | + QLabel* mouseUsageHint_;
|
|
72 | + |
|
73 | + GlyphIndexSelector* indexSelector_;
|
|
74 | + QLabel* dpiLabel_;
|
|
75 | + QLabel* sizeLabel_;
|
|
76 | + QLabel* zoomLabel_;
|
|
77 | + QSpinBox* dpiSpinBox_;
|
|
78 | + ZoomSpinBox* zoomSpinBox_;
|
|
79 | + QComboBox* unitsComboBox_;
|
|
80 | + QDoubleSpinBox* sizeDoubleSpinBox_;
|
|
81 | + QPushButton* centerGridButton_;
|
|
82 | + |
|
83 | + QLabel* glyphIndexLabel_;
|
|
84 | + QLabel* glyphNameLabel_;
|
|
85 | + |
|
86 | + QCheckBox* showBitmapCheckBox_;
|
|
87 | + QCheckBox* showOutlinesCheckBox_;
|
|
88 | + QCheckBox* showPointNumbersCheckBox_;
|
|
89 | + QCheckBox* showPointsCheckBox_;
|
|
90 | + |
|
91 | + QVBoxLayout* mainLayout_;
|
|
92 | + QHBoxLayout* checkBoxesLayout_;
|
|
93 | + QHBoxLayout* sizeLayout_;
|
|
94 | + QGridLayout* glyphOverlayLayout_;
|
|
95 | + QHBoxLayout* glyphOverlayIndexLayout_;
|
|
96 | + |
|
97 | + QPen axisPen_;
|
|
98 | + QPen blueZonePen_;
|
|
99 | + QPen gridPen_;
|
|
100 | + QPen offPen_;
|
|
101 | + QPen onPen_;
|
|
102 | + QPen outlinePen_;
|
|
103 | + QPen segmentPen_;
|
|
104 | + |
|
105 | + QVector<QRgb> grayColorTable_;
|
|
106 | + QVector<QRgb> monoColorTable_;
|
|
107 | + |
|
108 | + enum Units
|
|
109 | + {
|
|
110 | + Units_px,
|
|
111 | + Units_pt
|
|
112 | + };
|
|
113 | + |
|
114 | + void createLayout();
|
|
115 | + void createConnections();
|
|
116 | + void setGraphicsDefaults();
|
|
117 | +
|
|
118 | + void updateGrid();
|
|
119 | +};
|
|
120 | + |
|
121 | +// end of singular.hpp |
... | ... | @@ -71,7 +71,7 @@ QGraphicsViewx::resizeEvent(QResizeEvent* event) |
71 | 71 | // so that we can do that symmetrically
|
72 | 72 | |
73 | 73 | int
|
74 | -QSpinBoxx::valueFromText(const QString& text) const
|
|
74 | +ZoomSpinBox::valueFromText(const QString& text) const
|
|
75 | 75 | {
|
76 | 76 | int val = QSpinBox::valueFromText(text);
|
77 | 77 | |
... | ... | @@ -92,14 +92,14 @@ QSpinBoxx::valueFromText(const QString& text) const |
92 | 92 | }
|
93 | 93 | |
94 | 94 | |
95 | -QSpinBoxx::QSpinBoxx(QWidget* parent)
|
|
95 | +ZoomSpinBox::ZoomSpinBox(QWidget* parent)
|
|
96 | 96 | : QSpinBox(parent)
|
97 | 97 | {
|
98 | 98 | }
|
99 | 99 | |
100 | 100 | |
101 | 101 | void
|
102 | -QSpinBoxx::stepBy(int steps)
|
|
102 | +ZoomSpinBox::stepBy(int steps)
|
|
103 | 103 | {
|
104 | 104 | int val = value();
|
105 | 105 |
... | ... | @@ -43,13 +43,13 @@ private: |
43 | 43 | |
44 | 44 | |
45 | 45 | // we want to have our own `stepBy' function for the zoom spin box
|
46 | -class QSpinBoxx
|
|
46 | +class ZoomSpinBox
|
|
47 | 47 | : public QSpinBox
|
48 | 48 | {
|
49 | 49 | Q_OBJECT
|
50 | 50 | |
51 | 51 | public:
|
52 | - QSpinBoxx(QWidget* parent);
|
|
52 | + ZoomSpinBox(QWidget* parent);
|
|
53 | 53 | void stepBy(int val);
|
54 | 54 | int valueFromText(const QString& text) const;
|
55 | 55 | };
|