mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-24 06:11:30 +11:00
implement mint conversions (#1930)
Implement conversions for [mint](https://docs.rs/mint) (math interoperability standard types). - `impl From<mint::Point2> for {Physical, Logical}Position` - `impl From<{Physical, Logical}Position> for mint::Point2` - `impl From<mint::Vector2> for {Physical, Logical}Size` - `impl From<{Physical, Logical}Size> for mint::Vector2`
This commit is contained in:
parent
41d9826ee9
commit
078b9719cc
|
@ -28,6 +28,7 @@
|
||||||
- Implement `Default`, `Hash`, and `Eq` for `LogicalPosition`, `PhysicalPosition`, `LogicalSize`, and `PhysicalSize`.
|
- Implement `Default`, `Hash`, and `Eq` for `LogicalPosition`, `PhysicalPosition`, `LogicalSize`, and `PhysicalSize`.
|
||||||
- On macOS, initialize the Menu Bar with minimal defaults. (Can be prevented using `enable_default_menu_creation`)
|
- On macOS, initialize the Menu Bar with minimal defaults. (Can be prevented using `enable_default_menu_creation`)
|
||||||
- On macOS, change the default behavior for first click when the window was unfocused. Now the window becomes focused and then emits a `MouseInput` event on a "first mouse click".
|
- On macOS, change the default behavior for first click when the window was unfocused. Now the window becomes focused and then emits a `MouseInput` event on a "first mouse click".
|
||||||
|
- Implement mint (math interoperability standard types) conversions (under feature flag `mint`).
|
||||||
|
|
||||||
# 0.24.0 (2020-12-09)
|
# 0.24.0 (2020-12-09)
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ log = "0.4"
|
||||||
serde = { version = "1", optional = true, features = ["serde_derive"] }
|
serde = { version = "1", optional = true, features = ["serde_derive"] }
|
||||||
raw-window-handle = "0.3"
|
raw-window-handle = "0.3"
|
||||||
bitflags = "1"
|
bitflags = "1"
|
||||||
|
mint = { version = "0.5.6", optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
image = "0.23.12"
|
image = "0.23.12"
|
||||||
|
|
|
@ -66,6 +66,7 @@ Winit provides the following features, which can be enabled in your `Cargo.toml`
|
||||||
* `serde`: Enables serialization/deserialization of certain types with [Serde](https://crates.io/crates/serde).
|
* `serde`: Enables serialization/deserialization of certain types with [Serde](https://crates.io/crates/serde).
|
||||||
* `x11` (enabled by default): On Unix platform, compiles with the X11 backend
|
* `x11` (enabled by default): On Unix platform, compiles with the X11 backend
|
||||||
* `wayland` (enabled by default): On Unix platform, compiles with the Wayland backend
|
* `wayland` (enabled by default): On Unix platform, compiles with the Wayland backend
|
||||||
|
* `mint`: Enables mint (math interoperability standard types) conversions.
|
||||||
|
|
||||||
### Platform-specific usage
|
### Platform-specific usage
|
||||||
|
|
||||||
|
|
68
src/dpi.rs
68
src/dpi.rs
|
@ -228,6 +228,23 @@ impl<P: Pixel, X: Pixel> Into<[X; 2]> for LogicalPosition<P> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "mint")]
|
||||||
|
impl<P: Pixel> From<mint::Point2<P>> for LogicalPosition<P> {
|
||||||
|
fn from(mint: mint::Point2<P>) -> Self {
|
||||||
|
Self::new(mint.x, mint.y)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "mint")]
|
||||||
|
impl<P: Pixel> From<LogicalPosition<P>> for mint::Point2<P> {
|
||||||
|
fn from(winit: LogicalPosition<P>) -> Self {
|
||||||
|
mint::Point2 {
|
||||||
|
x: winit.x,
|
||||||
|
y: winit.y,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// A position represented in physical pixels.
|
/// A position represented in physical pixels.
|
||||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Default, Hash)]
|
#[derive(Debug, Copy, Clone, Eq, PartialEq, Default, Hash)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
|
@ -293,6 +310,23 @@ impl<P: Pixel, X: Pixel> Into<[X; 2]> for PhysicalPosition<P> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "mint")]
|
||||||
|
impl<P: Pixel> From<mint::Point2<P>> for PhysicalPosition<P> {
|
||||||
|
fn from(mint: mint::Point2<P>) -> Self {
|
||||||
|
Self::new(mint.x, mint.y)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "mint")]
|
||||||
|
impl<P: Pixel> From<PhysicalPosition<P>> for mint::Point2<P> {
|
||||||
|
fn from(winit: PhysicalPosition<P>) -> Self {
|
||||||
|
mint::Point2 {
|
||||||
|
x: winit.x,
|
||||||
|
y: winit.y,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// A size represented in logical pixels.
|
/// A size represented in logical pixels.
|
||||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Default, Hash)]
|
#[derive(Debug, Copy, Clone, Eq, PartialEq, Default, Hash)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
|
@ -358,6 +392,23 @@ impl<P: Pixel, X: Pixel> Into<[X; 2]> for LogicalSize<P> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "mint")]
|
||||||
|
impl<P: Pixel> From<mint::Vector2<P>> for LogicalSize<P> {
|
||||||
|
fn from(mint: mint::Vector2<P>) -> Self {
|
||||||
|
Self::new(mint.x, mint.y)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "mint")]
|
||||||
|
impl<P: Pixel> From<LogicalSize<P>> for mint::Vector2<P> {
|
||||||
|
fn from(winit: LogicalSize<P>) -> Self {
|
||||||
|
mint::Vector2 {
|
||||||
|
x: winit.width,
|
||||||
|
y: winit.height,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// A size represented in physical pixels.
|
/// A size represented in physical pixels.
|
||||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Default, Hash)]
|
#[derive(Debug, Copy, Clone, Eq, PartialEq, Default, Hash)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
|
@ -420,6 +471,23 @@ impl<P: Pixel, X: Pixel> Into<[X; 2]> for PhysicalSize<P> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "mint")]
|
||||||
|
impl<P: Pixel> From<mint::Vector2<P>> for PhysicalSize<P> {
|
||||||
|
fn from(mint: mint::Vector2<P>) -> Self {
|
||||||
|
Self::new(mint.x, mint.y)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "mint")]
|
||||||
|
impl<P: Pixel> From<PhysicalSize<P>> for mint::Vector2<P> {
|
||||||
|
fn from(winit: PhysicalSize<P>) -> Self {
|
||||||
|
mint::Vector2 {
|
||||||
|
x: winit.width,
|
||||||
|
y: winit.height,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// A size that's either physical or logical.
|
/// A size that's either physical or logical.
|
||||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
|
|
Loading…
Reference in a new issue