ui: Display count circle of bundle node as rounded rect
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
QtCountCircleItem::QtCountCircleItem(QGraphicsItem* parent)
|
||||
: QtRoundedRectItem(parent)
|
||||
{
|
||||
this->setRadius(100);
|
||||
this->setRadius(10);
|
||||
this->setAcceptHoverEvents(true);
|
||||
|
||||
QFont font;
|
||||
@@ -27,13 +27,15 @@ QtCountCircleItem::~QtCountCircleItem()
|
||||
|
||||
void QtCountCircleItem::setPosition(const Vec2f& pos)
|
||||
{
|
||||
qreal radius = getRadius();
|
||||
this->setRect(pos.x - radius, pos.y - radius, 2 * radius, 2 * radius);
|
||||
qreal width = QFontMetrics(m_number->font()).width(m_number->text());
|
||||
qreal height = QFontMetrics(m_number->font()).height();
|
||||
|
||||
m_number->setPos(
|
||||
pos.x - radius + 5,
|
||||
pos.y - QFontMetrics(m_number->font()).height() / 2
|
||||
this->setRadius(height / 2 + 1);
|
||||
this->setRect(
|
||||
pos.x - std::max(width / 2 + 4, height / 2 + 1), pos.y - height / 2 - 1,
|
||||
std::max(width + 8, height + 2), height + 2
|
||||
);
|
||||
m_number->setPos(pos.x - width / 2, pos.y - height / 2);
|
||||
}
|
||||
|
||||
void QtCountCircleItem::setNumber(size_t number)
|
||||
@@ -41,9 +43,6 @@ void QtCountCircleItem::setNumber(size_t number)
|
||||
QString numberStr = QString::number(number);
|
||||
m_number->setText(numberStr);
|
||||
|
||||
qreal radius = QFontMetrics(m_number->font()).width(numberStr) / 2 + 5;
|
||||
this->setRadius(radius);
|
||||
|
||||
QPointF center = this->rect().center();
|
||||
this->setPosition(Vec2f(center.x(), center.y()));
|
||||
}
|
||||
|
||||
@@ -59,8 +59,12 @@ void QtGraphNodeBundle::updateStyle()
|
||||
}
|
||||
setStyle(style);
|
||||
|
||||
m_circle->setPosition(
|
||||
Vec2f(m_rect->rect().right() - 3 + m_circle->getRadius() / 2, m_rect->rect().top() + 3 - m_circle->getRadius() / 4));
|
||||
Vec2f pos(m_rect->rect().right(), m_rect->rect().top() - 2);
|
||||
if (m_type.getNodeStyle() == NodeType::STYLE_BIG_NODE)
|
||||
{
|
||||
pos += Vec2f(-2, 2);
|
||||
}
|
||||
m_circle->setPosition(pos);
|
||||
|
||||
GraphViewStyle::NodeStyle accessStyle = GraphViewStyle::getStyleOfCountCircle();
|
||||
m_circle->setStyle(
|
||||
|
||||
Reference in New Issue
Block a user