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,