Browse Source
implement mint conversions (#352)
* Implement mint conversions
Implement conversions for [mint](https://docs.rs/mint) (math interoperability standard types).
- `impl {From, Into}<mint::Point2> for Pos2`
- `impl {From, Into}<mint::Vector2> for Vec2`
* Forward `mint` feature: egui -> epaint -> emath
fix-scrolling
Luis Wirth
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with
47 additions and
1 deletions
-
Cargo.lock
-
egui/Cargo.toml
-
emath/Cargo.toml
-
emath/src/pos2.rs
-
emath/src/vec2.rs
-
epaint/Cargo.toml
|
@ -823,6 +823,7 @@ checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" |
|
|
name = "emath" |
|
|
name = "emath" |
|
|
version = "0.11.0" |
|
|
version = "0.11.0" |
|
|
dependencies = [ |
|
|
dependencies = [ |
|
|
|
|
|
"mint", |
|
|
"serde", |
|
|
"serde", |
|
|
] |
|
|
] |
|
|
|
|
|
|
|
@ -1362,6 +1363,12 @@ dependencies = [ |
|
|
"autocfg", |
|
|
"autocfg", |
|
|
] |
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
[[package]] |
|
|
|
|
|
name = "mint" |
|
|
|
|
|
version = "0.5.6" |
|
|
|
|
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
|
|
|
|
|
checksum = "519df8d6856dcd4b40519947737b408f81be051fc032590659cae5d77d664185" |
|
|
|
|
|
|
|
|
[[package]] |
|
|
[[package]] |
|
|
name = "mio" |
|
|
name = "mio" |
|
|
version = "0.6.23" |
|
|
version = "0.6.23" |
|
|
|
@ -37,5 +37,7 @@ persistence = ["serde", "epaint/persistence", "ron"] |
|
|
single_threaded = ["epaint/single_threaded"] |
|
|
single_threaded = ["epaint/single_threaded"] |
|
|
multi_threaded = ["epaint/multi_threaded"] |
|
|
multi_threaded = ["epaint/multi_threaded"] |
|
|
|
|
|
|
|
|
|
|
|
mint = ["epaint/mint"] |
|
|
|
|
|
|
|
|
[dev-dependencies] |
|
|
[dev-dependencies] |
|
|
serde_json = "1" |
|
|
serde_json = "1" |
|
|
|
@ -20,6 +20,7 @@ include = [ |
|
|
[lib] |
|
|
[lib] |
|
|
|
|
|
|
|
|
[dependencies] |
|
|
[dependencies] |
|
|
|
|
|
mint = { version = "0.5.6", optional = true } |
|
|
serde = { version = "1", features = ["derive"], optional = true } |
|
|
serde = { version = "1", features = ["derive"], optional = true } |
|
|
|
|
|
|
|
|
[features] |
|
|
[features] |
|
|
|
@ -84,6 +84,23 @@ impl From<&Pos2> for (f32, f32) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
// Mint compatibility and convenience conversions
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "mint")] |
|
|
|
|
|
impl From<mint::Point2<f32>> for Pos2 { |
|
|
|
|
|
fn from(v: mint::Point2<f32>) -> Self { |
|
|
|
|
|
Self::new(v.x, v.y) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "mint")] |
|
|
|
|
|
impl From<Pos2> for mint::Point2<f32> { |
|
|
|
|
|
fn from(v: Pos2) -> Self { |
|
|
|
|
|
Self { x: v.x, y: v.y } |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
impl Pos2 { |
|
|
impl Pos2 { |
|
|
|
@ -81,6 +81,23 @@ impl From<&Vec2> for (f32, f32) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
// Mint compatibility and convenience conversions
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "mint")] |
|
|
|
|
|
impl From<mint::Vector2<f32>> for Vec2 { |
|
|
|
|
|
fn from(v: mint::Vector2<f32>) -> Self { |
|
|
|
|
|
Self::new(v.x, v.y) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[cfg(feature = "mint")] |
|
|
|
|
|
impl From<Vec2> for mint::Vector2<f32> { |
|
|
|
|
|
fn from(v: Vec2) -> Self { |
|
|
|
|
|
Self { x: v.x, y: v.y } |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
impl Vec2 { |
|
|
impl Vec2 { |
|
|
|
@ -43,3 +43,5 @@ single_threaded = ["atomic_refcell"] |
|
|
|
|
|
|
|
|
# Only needed if you plan to use the same fonts from multiple threads. |
|
|
# Only needed if you plan to use the same fonts from multiple threads. |
|
|
multi_threaded = ["parking_lot"] |
|
|
multi_threaded = ["parking_lot"] |
|
|
|
|
|
|
|
|
|
|
|
mint = ["emath/mint"] |
|
|