ui: only single class expand button next to class name

This change reduces the size of collapsed classes in the GraphView by removing the condensed view of the class access
nodes and using a single button next to the class name for collapsing and expanding instead.
This commit is contained in:
Eberhard Graether
2015-04-28 20:08:05 +02:00
parent a0340d9438
commit 791189c3c3
16 changed files with 296 additions and 208 deletions
@@ -0,0 +1,71 @@
#include "qt/view/graphElements/QtGraphNodeExpandToggle.h"
#include "utility/messaging/type/MessageGraphNodeExpand.h"
#include "qt/graphics/QtRoundedRectItem.h"
#include "qt/utility/QtDeviceScaledPixmap.h"
QtGraphNodeExpandToggle::QtGraphNodeExpandToggle(bool expanded, int invisibleSubNodeCount)
: m_allVisible(invisibleSubNodeCount == 0)
{
const int iconHeight = 4;
m_icon = new QGraphicsPixmapItem(this);
if (!expanded && !invisibleSubNodeCount)
{
this->hide();
return;
}
else
{
QtDeviceScaledPixmap pixmap("data/gui/graph_view/images/arrow.png");
pixmap.scaleToHeight(iconHeight);
if (invisibleSubNodeCount)
{
QString numberStr = QString::number(invisibleSubNodeCount);
m_text->setText(numberStr);
}
else
{
pixmap.mirror();
}
m_icon->setPixmap(pixmap.pixmap());
}
}
QtGraphNodeExpandToggle::~QtGraphNodeExpandToggle()
{
}
bool QtGraphNodeExpandToggle::isExpandToggleNode() const
{
return true;
}
void QtGraphNodeExpandToggle::onClick()
{
QtGraphNode* parent = getParent();
if (parent && parent->getData())
{
MessageGraphNodeExpand(parent->getData()->getId()).dispatch();
}
}
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,
5
);
m_icon->setPos(
(m_rect->rect().width() - m_icon->pixmap().width() / QtDeviceScaledPixmap::devicePixelRatio()) / 2,
(m_allVisible ? 9 : 14)
);
}