diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2009-03-29 16:18:02 -0400 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2009-03-29 16:18:02 -0400 |
| commit | c9f9b0cc3c4b282e3c3f894c09f5e7d16c19b784 (patch) | |
| tree | 5d02827996850ff7a4146baf1b0f43fc24a4d370 | |
| parent | ecd75133f03d93767d39e6e97836ec896cf2dd77 (diff) | |
| download | sigen-c9f9b0cc3c4b282e3c3f894c09f5e7d16c19b784.tar.gz sigen-c9f9b0cc3c4b282e3c3f894c09f5e7d16c19b784.tar.xz sigen-c9f9b0cc3c4b282e3c3f894c09f5e7d16c19b784.zip | |
If the PainterPath is empty, draw a placeholder square instead so something can be clicked
| -rw-r--r-- | sigmodr/widgets/mapeditor/EffectItem.cpp | 11 | ||||
| -rw-r--r-- | sigmodr/widgets/mapeditor/WarpItem.cpp | 11 |
2 files changed, 18 insertions, 4 deletions
diff --git a/sigmodr/widgets/mapeditor/EffectItem.cpp b/sigmodr/widgets/mapeditor/EffectItem.cpp index 17a09ed8..d1b946aa 100644 --- a/sigmodr/widgets/mapeditor/EffectItem.cpp +++ b/sigmodr/widgets/mapeditor/EffectItem.cpp @@ -44,6 +44,9 @@ EffectItem::EffectItem(Sigmod::Map* map, MapEffect* effect, QGraphicsScene* pare QRectF EffectItem::boundingRect() const { + QPainterPath path = m_effect->area(); + if (path.isEmpty()) + return QRect(0, 0, 32, 32); return m_effect->area().boundingRect(); } @@ -51,7 +54,11 @@ void EffectItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option { painter->setBrush(QBrush(Qt::red)); painter->setPen(QPen(Qt::black, 2)); - painter->drawPath(m_effect->area()); + QPainterPath path = m_effect->area(); + if (path.isEmpty()) + painter->drawRect(0, 0, 32, 32); + else + painter->drawPath(path); MapItem::paint(painter, option, widget); } @@ -70,6 +77,6 @@ void EffectItem::effectChanged() void EffectItem::resetLabel() { m_label->setText(m_effect->name()); - QSizeF size = m_label->boundingRect().size() / 2 - m_effect->area().boundingRect().size() / 2; + QSizeF size = m_label->boundingRect().size() / 2 - boundingRect().size() / 2; m_label->setPos(-size.width(), -size.height()); } diff --git a/sigmodr/widgets/mapeditor/WarpItem.cpp b/sigmodr/widgets/mapeditor/WarpItem.cpp index 4be27568..1cc53388 100644 --- a/sigmodr/widgets/mapeditor/WarpItem.cpp +++ b/sigmodr/widgets/mapeditor/WarpItem.cpp @@ -44,6 +44,9 @@ WarpItem::WarpItem(Sigmod::Map* map, MapWarp* warp, QGraphicsScene* parent) : QRectF WarpItem::boundingRect() const { + QPainterPath path = m_warp->area(); + if (path.isEmpty()) + return QRect(0, 0, 32, 32); return m_warp->area().boundingRect(); } @@ -51,7 +54,11 @@ void WarpItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, { painter->setBrush(QBrush(Qt::green)); painter->setPen(QPen(Qt::black, 2)); - painter->drawPath(m_warp->area()); + QPainterPath path = m_warp->area(); + if (path.isEmpty()) + painter->drawRect(0, 0, 32, 32); + else + painter->drawPath(path); MapItem::paint(painter, option, widget); } @@ -70,6 +77,6 @@ void WarpItem::warpChanged() void WarpItem::resetLabel() { m_label->setText(m_warp->name()); - QSizeF size = m_label->boundingRect().size() / 2 - m_warp->area().boundingRect().size() / 2; + QSizeF size = m_label->boundingRect().size() / 2 - boundingRect().size() / 2; m_label->setPos(-size.width(), -size.height()); } |
