Fix tools drawing rectangles with tools not doing anything in some cases

Namely, when those rectangles are not drawn in a top left to bottom right corner order. Broken by a26544ba955f, which neglected to port the rectangle normalization logic from Simulation::ToolBox.
This commit is contained in:
Tamás Bálint Misius 2024-10-08 22:07:50 +02:00
parent 0c048a9d6e
commit 2cc5d9bbbb
No known key found for this signature in database
GPG Key ID: 5B472A12F6ECA9F2

View File

@ -87,7 +87,9 @@ static void defaultPerformDrawRect(SimTool *tool, Simulation *sim, const Brush &
{
int brushX = ((position1.X + position2.X) / 2);
int brushY = ((position1.Y + position2.Y) / 2);
for (auto p : RectBetween(position1, position2))
auto tl = ui::Point{ std::min(position1.X, position2.X), std::min(position1.Y, position2.Y) };
auto br = ui::Point{ std::max(position1.X, position2.X), std::max(position1.Y, position2.Y) };
for (auto p : RectBetween(tl, br))
{
tool->CallPerform(sim, p, { brushX, brushY });
}