Fix undo problem with paint bucket tool: don't paint outside visible bounds
Fix #473: Now paint bucket-like tools stop at grid bounds