Skip to content

Commit 823ecd5

Browse files
authored
Expand the status bar info for the Eraser (#4261)
When erasing a rectangle, now shows "Erase area (<width> x <height>)". Related to issue #4201
1 parent e6a03b3 commit 823ecd5

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Added support for SVG 1.2 / CSS blending modes to layers (#3932)
66
* Added button to toggle Terrain Brush to full tile mode (by Finlay Pearson, #3407)
77
* Added square selection and expand-from-center to Rectangular Select tool (#4201)
8-
* Added status bar info for various Stamp and Terrain Brush modes (#3092, #4201)
8+
* Added status info for various Stamp Brush, Terrain Brush and Eraser modes (#3092, #4201)
99
* Added export plugin for Remixed Dungeon (by Mikhael Danilov, #4158)
1010
* Added "World > World Properties" menu action (with dogboydog, #4190)
1111
* Scripting: Added API for custom property types (with dogboydog, #3971)

src/tiled/eraser.cpp

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,14 @@ void Eraser::mousePressed(QGraphicsSceneMouseEvent *event)
5757
if (event->button() == Qt::LeftButton) {
5858
mMode = Erase;
5959
doErase(false);
60+
updateStatusInfo();
6061
return;
61-
} else if (event->button() == Qt::RightButton && !(event->modifiers() & Qt::ControlModifier)) {
62+
}
63+
64+
if (event->button() == Qt::RightButton && !(event->modifiers() & Qt::ControlModifier)) {
6265
mStart = tilePosition();
6366
mMode = RectangleErase;
67+
updateStatusInfo();
6468
return;
6569
}
6670
}
@@ -82,6 +86,7 @@ void Eraser::mouseReleased(QGraphicsSceneMouseEvent *event)
8286
doErase(false);
8387
mMode = Nothing;
8488
brushItem()->setTileRegion(eraseArea());
89+
updateStatusInfo();
8590
}
8691
break;
8792
}
@@ -130,4 +135,25 @@ QRect Eraser::eraseArea() const
130135
return QRect(tilePosition(), QSize(1, 1));
131136
}
132137

138+
void Eraser::updateStatusInfo()
139+
{
140+
if (!isBrushVisible()) {
141+
AbstractTileTool::updateStatusInfo();
142+
return;
143+
}
144+
145+
if (mMode == RectangleErase) {
146+
const QPoint pos = tilePosition();
147+
const QRect rect = eraseArea();
148+
setStatusInfo(tr("%1, %2 - Erase area (%4 x %5)")
149+
.arg(pos.x())
150+
.arg(pos.y())
151+
.arg(rect.width())
152+
.arg(rect.height()));
153+
return;
154+
}
155+
156+
AbstractTileTool::updateStatusInfo();
157+
}
158+
133159
#include "moc_eraser.cpp"

src/tiled/eraser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class Eraser : public AbstractTileTool
4343

4444
protected:
4545
void tilePositionChanged(QPoint tilePos) override;
46+
void updateStatusInfo() override;
4647

4748
private:
4849
void doErase(bool continuation);

0 commit comments

Comments
 (0)