Fire: Ignore mouse events outside the window (to the left)

This fixes a small issue where if you drag the cursor outside the
window on the left-hand side, the fire demo will still respond to
the mouse events, but wrapped around to the right of the window.
This commit is contained in:
MacDue 2022-05-08 15:55:00 +01:00 committed by Linus Groh
parent 934ea4faf1
commit 739d870091
Notes: sideshowbarker 2024-07-17 14:36:19 +09:00

View file

@ -174,9 +174,9 @@ void Fire::mousedown_event(GUI::MouseEvent& event)
void Fire::mousemove_event(GUI::MouseEvent& event)
{
if (dragging) {
if (event.y() >= 2 && event.y() < 398 && event.x() <= 638) {
int ypos = event.y() / 2;
int xpos = event.x() / 2;
int ypos = event.y() / 2;
int xpos = event.x() / 2;
if (bitmap->rect().shrunken(1, 1, 0, 0).contains(xpos, ypos)) {
bitmap->scanline_u8(ypos - 1)[xpos] = FIRE_MAX + 5;
bitmap->scanline_u8(ypos - 1)[xpos + 1] = FIRE_MAX + 5;
bitmap->scanline_u8(ypos)[xpos] = FIRE_MAX + 5;