mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
visual improvements: card hover effect, independent scaling of ZoneViewWidget
This commit is contained in:
parent
6b7c5eefd3
commit
46fdae43cd
8 changed files with 127 additions and 34 deletions
|
|
@ -82,9 +82,8 @@ void AbstractCardItem::transformPainter(QPainter *painter, const QSizeF &transla
|
|||
painter->setFont(f);
|
||||
}
|
||||
|
||||
void AbstractCardItem::paintPicture(QPainter *painter, int angle)
|
||||
void AbstractCardItem::paintPicture(QPainter *painter, const QSizeF &translatedSize, int angle)
|
||||
{
|
||||
QSizeF translatedSize = getTranslatedSize(painter);
|
||||
QRectF totalBoundingRect = painter->combinedTransform().mapRect(boundingRect());
|
||||
qreal scaleFactor = translatedSize.width() / boundingRect().width();
|
||||
|
||||
|
|
@ -143,15 +142,20 @@ void AbstractCardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *
|
|||
{
|
||||
painter->save();
|
||||
|
||||
paintPicture(painter, tapAngle);
|
||||
QSizeF translatedSize = getTranslatedSize(painter);
|
||||
paintPicture(painter, translatedSize, tapAngle);
|
||||
|
||||
painter->save();
|
||||
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||
transformPainter(painter, translatedSize, tapAngle);
|
||||
if (isSelected()) {
|
||||
painter->setPen(Qt::red);
|
||||
painter->drawRect(QRectF(0.5, 0.5, CARD_WIDTH - 1, CARD_HEIGHT - 1));
|
||||
painter->drawRect(QRectF(0.5, 0.5, translatedSize.width() - 1, translatedSize.height() - 1));
|
||||
} else if (isHovered) {
|
||||
painter->setPen(Qt::yellow);
|
||||
painter->drawRect(QRectF(0.5, 0.5, CARD_WIDTH - 1, CARD_HEIGHT - 1));
|
||||
painter->drawRect(QRectF(0.5, 0.5, translatedSize.width() - 1, translatedSize.height() - 1));
|
||||
}
|
||||
painter->restore();
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue