Skip to content

Commit

Permalink
Fixed animated tile overlay to look less odd in some cases
Browse files Browse the repository at this point in the history
Now it's also less intrusive, sitting just in one corner and being
slightly transparent.

Closes #1061
  • Loading branch information
bjorn committed Sep 7, 2015
1 parent 293b5ef commit 6d77198
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Keep the active brush when switching maps
* Python plugins can now add export-only map formats
* Fixed updating of current tile when changing map
* Fixed animated tile overlay to look less odd in some cases

0.13.1 (6 September 2015)
* Added Bulgarian translation (by Lyubomir Vasilev)
Expand Down
31 changes: 19 additions & 12 deletions src/tiled/tilesetview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,29 +233,36 @@ void TileDelegate::paint(QPainter *painter,

// Overlay with film strip when animated
if (mTilesetView->markAnimatedTiles() && tile->isAnimated()) {
QRectF strip(targetRect);
strip.setHeight(targetRect.height() / 5);
painter->fillRect(strip, Qt::black);
strip.moveBottom(targetRect.bottom() + 1);
painter->save();

qreal scale = qMin(tileImage.width() / 32.0,
tileImage.height() / 32.0);

painter->setClipRect(targetRect);
painter->translate(targetRect.right(),
targetRect.bottom());
painter->scale(scale * zoom, scale * zoom);
painter->translate(-18, 3);
painter->rotate(-45);
painter->setOpacity(0.8);

QRectF strip(0, 0, 32, 6);
painter->fillRect(strip, Qt::black);

painter->setRenderHint(QPainter::Antialiasing);
painter->setBrush(Qt::white);
painter->setPen(Qt::NoPen);

qreal step = qMax(strip.height(), qreal(3));
step = qMax(strip.width() / qFloor(strip.width() / step), qreal(3));
QRectF hole(0, 0, strip.height() * 0.6, strip.height() * 0.6);
qreal step = (strip.height() - hole.height()) + hole.width();
qreal margin = (strip.height() - hole.height()) / 2;

for (qreal x = strip.x() + (step - hole.width()) / 2;
x < strip.right();
x += step) {
hole.moveTo(x, targetRect.top() + margin);
painter->drawRoundedRect(hole, 25, 25, Qt::RelativeSize);
hole.moveTo(x, strip.top() + margin);
for (qreal x = (step - hole.width()) / 2; x < strip.right(); x += step) {
hole.moveTo(x, margin);
painter->drawRoundedRect(hole, 25, 25, Qt::RelativeSize);
}

painter->restore();
}

// Overlay with highlight color when selected
Expand Down

0 comments on commit 6d77198

Please sign in to comment.