ui: graph toggle button number position

Improved the position of the small number in the graph node toggle button for windows.
This commit is contained in:
Manuel Dobusch
2015-12-30 00:21:38 +01:00
parent afc2d1e6b5
commit 5af8d0f03f
10 changed files with 381 additions and 159 deletions
@@ -10,6 +10,8 @@
#include "qt/utility/utilityQt.h"
#include "qt/view/graphElements/QtGraphNodeData.h"
#include <iostream>
QtGraphNodeExpandToggle::QtGraphNodeExpandToggle(bool expanded, int invisibleSubNodeCount)
: m_invisibleSubNodeCount(invisibleSubNodeCount)
, m_expanded(expanded)
@@ -63,10 +65,17 @@ void QtGraphNodeExpandToggle::updateStyle()
GraphViewStyle::NodeStyle style = GraphViewStyle::getStyleOfExpandToggleNode();
setStyle(style);
m_text->setPos(
(m_rect->rect().width() - QFontMetrics(m_text->font()).width(m_text->text())) / 2,
6
);
float textX = (m_rect->rect().width() / 2) - (QFontMetrics(m_text->font()).width(m_text->text()) / 2);
float textY = m_rect->rect().height() / 2 - QFontMetrics(m_text->font()).height() / 1.8f;
// move the text to the nearest integer x pos, instead of the next lower int pos
// improves results on windows systems
if (textX - (float)((int)textX) >= 0.5f)
{
textX += 0.5f;
}
m_text->setPos(textX, textY);
m_icon->setPos(
(m_rect->rect().width() - m_icon->pixmap().width() / QtDeviceScaledPixmap::devicePixelRatio()) / 2,
+37 -3
View File
@@ -20,6 +20,7 @@
#include "utility/messaging/type/MessageLoadProject.h"
#include "utility/messaging/type/MessageRedo.h"
#include "utility/messaging/type/MessageRefresh.h"
#include "utility/messaging/type/MessageResetZoom.h"
#include "utility/messaging/type/MessageSaveProject.h"
#include "utility/messaging/type/MessageSwitchColorScheme.h"
#include "utility/messaging/type/MessageUndo.h"
@@ -52,9 +53,6 @@ MouseReleaseFilter::MouseReleaseFilter(QObject* parent)
{
m_backButton = ApplicationSettings::getInstance()->getControlsMouseBackButton();
m_forwardButton = ApplicationSettings::getInstance()->getControlsMouseForwardButton();
std::cout << m_backButton << std::endl;
std::cout << m_forwardButton << std::endl;
}
bool MouseReleaseFilter::eventFilter(QObject* obj, QEvent* event)
@@ -63,6 +61,8 @@ bool MouseReleaseFilter::eventFilter(QObject* obj, QEvent* event)
{
QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(event);
if (mouseEvent->button() == m_backButton)
{
MessageUndo().dispatch();
@@ -78,6 +78,33 @@ bool MouseReleaseFilter::eventFilter(QObject* obj, QEvent* event)
return QObject::eventFilter(obj, event);
}
MouseWheelFilter::MouseWheelFilter(QObject* parent)
: QObject(parent)
{
}
bool MouseWheelFilter::eventFilter(QObject* obj, QEvent* event)
{
if (event->type() == QEvent::Wheel && QApplication::keyboardModifiers() == Qt::ControlModifier)
{
QWheelEvent* wheelEvent = dynamic_cast<QWheelEvent*>(event);
if (wheelEvent->delta() > 0.0f)
{
MessageZoom(true).dispatch();
return true;
}
else if (wheelEvent->delta() < 0.0f)
{
MessageZoom(false).dispatch();
return true;
}
}
return QObject::eventFilter(obj, event);
}
QtMainWindow::QtMainWindow()
: m_showDockWidgetTitleBars(true)
{
@@ -92,6 +119,7 @@ QtMainWindow::QtMainWindow()
QApplication* app = dynamic_cast<QApplication*>(QCoreApplication::instance());
app->installEventFilter(new MouseReleaseFilter(this));
app->installEventFilter(new MouseWheelFilter(this));
app->setStyleSheet(utility::getStyleSheet("data/gui/tooltip.css").c_str());
@@ -427,6 +455,11 @@ void QtMainWindow::zoomOut()
MessageZoom(false).dispatch();
}
void QtMainWindow::resetZoom()
{
MessageResetZoom().dispatch();
}
void QtMainWindow::switchColorScheme()
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "./data/color_schemes", "XML Files (*.xml)");
@@ -576,6 +609,7 @@ void QtMainWindow::setupViewMenu()
menu->addAction(tr("Larger font"), this, SLOT(zoomIn()), QKeySequence::ZoomIn);
menu->addAction(tr("Smaller font"), this, SLOT(zoomOut()), QKeySequence::ZoomOut);
menu->addAction(tr("Reset font size"), this, SLOT(resetZoom()));
menu->addAction(tr("Switch Color Scheme..."), this, SLOT(switchColorScheme()));
+12
View File
@@ -50,6 +50,17 @@ private:
size_t m_forwardButton;
};
class MouseWheelFilter
: public QObject
{
Q_OBJECT
public:
MouseWheelFilter(QObject* parent);
protected:
bool eventFilter(QObject* obj, QEvent* event);
};
class QtMainWindow
: public QMainWindow
@@ -103,6 +114,7 @@ public slots:
void redo();
void zoomIn();
void zoomOut();
void resetZoom();
void switchColorScheme();
void toggleView(View* view, bool fromMenu);