[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2-demos] gsoc-2022-chariri-3 469443c 13/36: [ftinspect] Rework
From: |
Werner Lemberg |
Subject: |
[freetype2-demos] gsoc-2022-chariri-3 469443c 13/36: [ftinspect] Rework on scroll tooltip of "Singular View" |
Date: |
Wed, 27 Jul 2022 06:32:44 -0400 (EDT) |
branch: gsoc-2022-chariri-3
commit 469443c41178455ef1786c4cae642701db596f2f
Author: Charlie Jiang <w@chariri.moe>
Commit: Charlie Jiang <w@chariri.moe>
[ftinspect] Rework on scroll tooltip of "Singular View"
The overlay tooltip explaining scroll operations in the singular view is
annoying and ugly. Move it into a small button on the right-bottom corner.
Only show the tooltip when clicking the button.
* src/ftinspect/panels/singular.cpp, src/ftinspect/panels/singular.hpp:
As described.
---
src/ftinspect/panels/singular.cpp | 42 ++++++++++++++++++++++++---------------
src/ftinspect/panels/singular.hpp | 4 +++-
2 files changed, 29 insertions(+), 17 deletions(-)
diff --git a/src/ftinspect/panels/singular.cpp
b/src/ftinspect/panels/singular.cpp
index 726c105..878654a 100644
--- a/src/ftinspect/panels/singular.cpp
+++ b/src/ftinspect/panels/singular.cpp
@@ -5,6 +5,7 @@
#include "singular.hpp"
#include <QSizePolicy>
+#include <QToolTip>
#include <QWheelEvent>
@@ -204,6 +205,18 @@ SingularTab::setGridVisible()
}
+void
+SingularTab::showToolTip()
+{
+ QToolTip::showText(helpButton_->pos(),
+ tr("Scroll: Grid Up/Down\n"
+ "Alt + Scroll: Grid Left/Right\n"
+ "Ctrl + Scroll: Adjust Zoom (Relative to cursor)\n"
+ "Shift + Scroll: Adjust Font Size"),
+ helpButton_);
+}
+
+
void
SingularTab::createLayout()
{
@@ -230,22 +243,13 @@ SingularTab::createLayout()
// Don't use QGraphicsTextItem: We want this hint to be anchored at the
// top-left corner.
- mouseUsageHint_ = new QLabel(tr(
- "Scroll: Grid Up/Down\n"
- "Alt + Scroll: Grid Left/Right\n"
- "Ctrl + Scroll: Adjust Zoom (Relative to cursor)\n"
- "Shift + Scroll: Adjust Font Size"),
- glyphView_);
- auto hintFont = font();
- hintFont.setPixelSize(24);
- mouseUsageHint_->setFont(hintFont);
- mouseUsageHint_->setAttribute(Qt::WA_TransparentForMouseEvents, true);
- mouseUsageHint_->setStyleSheet("QLabel { color : black; }");
+ auto overlayFont = font();
+ overlayFont.setPixelSize(24);
glyphIndexLabel_ = new QLabel(glyphView_);
glyphNameLabel_ = new QLabel(glyphView_);
- glyphIndexLabel_->setFont(hintFont);
- glyphNameLabel_->setFont(hintFont);
+ glyphIndexLabel_->setFont(overlayFont);
+ glyphNameLabel_->setFont(overlayFont);
glyphIndexLabel_->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
glyphNameLabel_->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
glyphIndexLabel_->setAttribute(Qt::WA_TransparentForMouseEvents, true);
@@ -268,6 +272,8 @@ SingularTab::createLayout()
zoomLabel_->setBuddy(zoomSpinBox_);
centerGridButton_ = new QPushButton("Go Back to Grid Center", this);
+ helpButton_ = new QPushButton("?", this);
+ helpButton_->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
showBitmapCheckBox_ = new QCheckBox(tr("Show Bitmap"), this);
showPointsCheckBox_ = new QCheckBox(tr("Show Points"), this);
@@ -275,6 +281,10 @@ SingularTab::createLayout()
showOutlinesCheckBox_ = new QCheckBox(tr("Show Outlines"), this);
showGridCheckBox_ = new QCheckBox(tr("Show Grid"), this);
+ indexHelpLayout_ = new QHBoxLayout;
+ indexHelpLayout_->addWidget(indexSelector_, 1);
+ indexHelpLayout_->addWidget(helpButton_);
+
sizeLayout_ = new QHBoxLayout;
sizeLayout_->addStretch(2);
sizeLayout_->addWidget(sizeSelector_, 3);
@@ -297,15 +307,13 @@ SingularTab::createLayout()
glyphOverlayIndexLayout_->addWidget(glyphIndexLabel_);
glyphOverlayIndexLayout_->addWidget(glyphNameLabel_);
glyphOverlayLayout_ = new QGridLayout;
- glyphOverlayLayout_->addWidget(mouseUsageHint_, 0, 0,
- Qt::AlignTop | Qt::AlignLeft);
glyphOverlayLayout_->addLayout(glyphOverlayIndexLayout_, 0, 1,
Qt::AlignTop | Qt::AlignRight);
glyphView_->setLayout(glyphOverlayLayout_);
mainLayout_ = new QVBoxLayout;
mainLayout_->addWidget(glyphView_);
- mainLayout_->addWidget(indexSelector_);
+ mainLayout_->addLayout(indexHelpLayout_);
mainLayout_->addSpacing(10); // XXX px
mainLayout_->addLayout(sizeLayout_);
mainLayout_->addLayout(checkBoxesLayout_);
@@ -336,6 +344,8 @@ SingularTab::createConnections()
connect(centerGridButton_, &QPushButton::clicked,
this, &SingularTab::backToCenter);
+ connect(helpButton_, &QPushButton::clicked,
+ this, &SingularTab::showToolTip);
connect(showBitmapCheckBox_, &QCheckBox::clicked,
this, &SingularTab::drawGlyph);
diff --git a/src/ftinspect/panels/singular.hpp
b/src/ftinspect/panels/singular.hpp
index 6c83535..ccfc6ae 100644
--- a/src/ftinspect/panels/singular.hpp
+++ b/src/ftinspect/panels/singular.hpp
@@ -53,6 +53,7 @@ private slots:
void wheelZoom(QWheelEvent* event);
void wheelResize(QWheelEvent* event);
void setGridVisible();
+ void showToolTip();
private:
int currentGlyphIndex_;
@@ -68,13 +69,13 @@ private:
GlyphPointNumbers* currentGlyphPointNumbersItem_;
GlyphBitmap* currentGlyphBitmapItem_;
Grid* gridItem_ = NULL;
- QLabel* mouseUsageHint_;
GlyphIndexSelector* indexSelector_;
FontSizeSelector* sizeSelector_;
QLabel* zoomLabel_;
ZoomSpinBox* zoomSpinBox_;
QPushButton* centerGridButton_;
+ QPushButton* helpButton_;
QLabel* glyphIndexLabel_;
QLabel* glyphNameLabel_;
@@ -87,6 +88,7 @@ private:
QVBoxLayout* mainLayout_;
QHBoxLayout* checkBoxesLayout_;
+ QHBoxLayout* indexHelpLayout_;
QHBoxLayout* sizeLayout_;
QGridLayout* glyphOverlayLayout_;
QHBoxLayout* glyphOverlayIndexLayout_;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2-demos] gsoc-2022-chariri-3 469443c 13/36: [ftinspect] Rework on scroll tooltip of "Singular View",
Werner Lemberg <=