From 9458a1b05e375fced731cd596325ec9690c79092 Mon Sep 17 00:00:00 2001 From: Daniel Collin Date: Fri, 29 Jan 2016 20:56:26 +0100 Subject: [PATCH] MouseMode::Clamp now clamps to [(0,0) (w-1,h-1)] --- CHANGELOG.md | 4 ++++ Cargo.toml | 2 +- README.md | 2 +- src/mouse_handler.rs | 4 ++-- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c20ac48..2926eb3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ This project follows semantic versioning. +### v0.3.1 (2016-01-29) + +- [fixed] get_mouse_pos(MouseMode::Clamp) now is in the region [(0, 0) - (width - 1, height - 1)] instead of (width, height) + ### v0.3.0 (2016-01-29) - [added] get_mouse_pos diff --git a/Cargo.toml b/Cargo.toml index cb0f1e53..0f4effb4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "minifb" -version = "0.3.0" +version = "0.3.1" license = "MIT/Apache-2.0" authors = ["Daniel Collin "] description = "Cross-platform window setup for bitmap rendering" diff --git a/README.md b/README.md index adcfc574..1fec9350 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Usage ```toml # Cargo.toml [dependencies] -minifb = "0.3.0" +minifb = "0.3.1" ``` Example diff --git a/src/mouse_handler.rs b/src/mouse_handler.rs index f401379c..23ec8864 100644 --- a/src/mouse_handler.rs +++ b/src/mouse_handler.rs @@ -14,8 +14,8 @@ pub fn get_pos(mode: MouseMode, mx: f32, my: f32, scale: f32, width: f32, height match mode { MouseMode::Pass => Some((x, y)), MouseMode::Clamp => { - Some((clamp(x, 0.0, window_width), - clamp(y, 0.0, window_height))) + Some((clamp(x, 0.0, window_width - 1.0), + clamp(y, 0.0, window_height - 1.0))) }, MouseMode::Discard => { if x < 0.0 || y < 0.0 || x >= window_width || y >= window_height {