... |
... |
@@ -432,6 +432,40 @@ MainGUI::zoom() |
432
|
432
|
}
|
433
|
433
|
|
434
|
434
|
|
|
435
|
+void
|
|
436
|
+MainGUI::backToCenter()
|
|
437
|
+{
|
|
438
|
+ glyphView_->centerOn(0, 0);
|
|
439
|
+ if (currentGlyphBitmapItem_)
|
|
440
|
+ glyphView_->ensureVisible(currentGlyphBitmapItem_);
|
|
441
|
+ else if (currentGlyphPointsItem_)
|
|
442
|
+ glyphView_->ensureVisible(currentGlyphPointsItem_);
|
|
443
|
+}
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+void
|
|
447
|
+MainGUI::wheelZoom(QWheelEvent* event)
|
|
448
|
+{
|
|
449
|
+ int numSteps = event->angleDelta().y() / 120;
|
|
450
|
+ int zoomAfter = zoomSpinBox_->value() + numSteps;
|
|
451
|
+ zoomAfter = std::max(zoomSpinBox_->minimum(),
|
|
452
|
+ std::min(zoomAfter, zoomSpinBox_->maximum()));
|
|
453
|
+ zoomSpinBox_->setValue(zoomAfter);
|
|
454
|
+ // TODO: Zoom relative to viewport left-bottom?
|
|
455
|
+}
|
|
456
|
+
|
|
457
|
+
|
|
458
|
+void
|
|
459
|
+MainGUI::wheelResize(QWheelEvent* event)
|
|
460
|
+{
|
|
461
|
+ int numSteps = event->angleDelta().y() / 120;
|
|
462
|
+ double sizeAfter = sizeDoubleSpinBox_->value() + numSteps * 0.5;
|
|
463
|
+ sizeAfter = std::max(sizeDoubleSpinBox_->minimum(),
|
|
464
|
+ std::min(sizeAfter, sizeDoubleSpinBox_->maximum()));
|
|
465
|
+ sizeDoubleSpinBox_->setValue(sizeAfter);
|
|
466
|
+}
|
|
467
|
+
|
|
468
|
+
|
435
|
469
|
void
|
436
|
470
|
MainGUI::setGraphicsDefaults()
|
437
|
471
|
{
|
... |
... |
@@ -597,8 +631,19 @@ MainGUI::createLayout() |
597
|
631
|
glyphView_->setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
|
598
|
632
|
glyphView_->setScene(glyphScene_);
|
599
|
633
|
|
|
634
|
+ // Don't use QGraphicsTextItem: We want this hint to be anchored at the
|
|
635
|
+ // top-left corner.
|
|
636
|
+ mouseUsageHint_ = new QLabel(tr("Scroll: Grid Up/Down\n"
|
|
637
|
+ "Alt + Scroll: Grid Left/Right\n"
|
|
638
|
+ "Ctrl + Scroll: Adjust Zoom (Relative to cursor)\n"
|
|
639
|
+ "Shift + Scroll: Adjust Font Size"), glyphView_);
|
|
640
|
+ mouseUsageHint_->setMargin(10);
|
|
641
|
+ auto hintFont = font();
|
|
642
|
+ hintFont.setPixelSize(24);
|
|
643
|
+ mouseUsageHint_->setFont(hintFont);
|
|
644
|
+
|
600
|
645
|
sizeLabel_ = new QLabel(tr("Size "), this);
|
601
|
|
- sizeLabel_->setAlignment(Qt::AlignRight);
|
|
646
|
+ sizeLabel_->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
602
|
647
|
sizeDoubleSpinBox_ = new QDoubleSpinBox;
|
603
|
648
|
sizeDoubleSpinBox_->setAlignment(Qt::AlignRight);
|
604
|
649
|
sizeDoubleSpinBox_->setDecimals(1);
|
... |
... |
@@ -610,7 +655,7 @@ MainGUI::createLayout() |
610
|
655
|
unitsComboBox_->insertItem(Units_pt, "pt");
|
611
|
656
|
|
612
|
657
|
dpiLabel_ = new QLabel(tr("DPI "), this);
|
613
|
|
- dpiLabel_->setAlignment(Qt::AlignRight);
|
|
658
|
+ dpiLabel_->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
614
|
659
|
dpiSpinBox_ = new QSpinBox(this);
|
615
|
660
|
dpiSpinBox_->setAlignment(Qt::AlignRight);
|
616
|
661
|
dpiSpinBox_->setRange(10, 600);
|
... |
... |
@@ -628,13 +673,15 @@ MainGUI::createLayout() |
628
|
673
|
toEndButtonx_ = new QPushButtonx(">|", this);
|
629
|
674
|
|
630
|
675
|
zoomLabel_ = new QLabel(tr("Zoom Factor"), this);
|
631
|
|
- zoomLabel_->setAlignment(Qt::AlignRight);
|
|
676
|
+ zoomLabel_->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
632
|
677
|
zoomSpinBox_ = new QSpinBoxx(this);
|
633
|
678
|
zoomSpinBox_->setAlignment(Qt::AlignRight);
|
634
|
679
|
zoomSpinBox_->setRange(1, 1000 - 1000 % 64);
|
635
|
680
|
zoomSpinBox_->setKeyboardTracking(false);
|
636
|
681
|
zoomLabel_->setBuddy(zoomSpinBox_);
|
637
|
682
|
|
|
683
|
+ centerGridButton_ = new QPushButton("Go Back to Grid Center", this);
|
|
684
|
+
|
638
|
685
|
previousFontButton_ = new QPushButton(tr("Previous Font"), this);
|
639
|
686
|
nextFontButton_ = new QPushButton(tr("Next Font"), this);
|
640
|
687
|
previousFaceButton_ = new QPushButton(tr("Previous Face"), this);
|
... |
... |
@@ -674,6 +721,8 @@ MainGUI::createLayout() |
674
|
721
|
sizeLayout_->addStretch(1);
|
675
|
722
|
sizeLayout_->addWidget(zoomLabel_);
|
676
|
723
|
sizeLayout_->addWidget(zoomSpinBox_);
|
|
724
|
+ sizeLayout_->addStretch(1);
|
|
725
|
+ sizeLayout_->addWidget(centerGridButton_);
|
677
|
726
|
sizeLayout_->addStretch(2);
|
678
|
727
|
|
679
|
728
|
fontLayout = new QGridLayout;
|
... |
... |
@@ -729,6 +778,13 @@ MainGUI::createConnections() |
729
|
778
|
|
730
|
779
|
connect(zoomSpinBox_, SIGNAL(valueChanged(int)),
|
731
|
780
|
SLOT(zoom()));
|
|
781
|
+ connect(glyphView_, SIGNAL(shiftWheelEvent(QWheelEvent*)),
|
|
782
|
+ SLOT(wheelResize(QWheelEvent*)));
|
|
783
|
+ connect(glyphView_, SIGNAL(ctrlWheelEvent(QWheelEvent*)),
|
|
784
|
+ SLOT(wheelZoom(QWheelEvent*)));
|
|
785
|
+
|
|
786
|
+ connect(centerGridButton_, SIGNAL(clicked()),
|
|
787
|
+ SLOT(backToCenter()));
|
732
|
788
|
|
733
|
789
|
connect(previousFontButton_, SIGNAL(clicked()),
|
734
|
790
|
SLOT(previousFont()));
|