mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-26 12:59:00 +00:00
Merge pull request #319 from yodaldevoid/winit_22
Add support for winit 0.22
This commit is contained in:
commit
f579e063ce
10
.github/workflows/ci.yml
vendored
10
.github/workflows/ci.yml
vendored
@ -56,6 +56,11 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
command: check
|
command: check
|
||||||
args: --manifest-path imgui-winit-support/Cargo.toml --no-default-features --features winit-20
|
args: --manifest-path imgui-winit-support/Cargo.toml --no-default-features --features winit-20
|
||||||
|
- name: Run cargo check (imgui-winit-support with winit-22)
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: check
|
||||||
|
args: --manifest-path imgui-winit-support/Cargo.toml --no-default-features --features winit-22
|
||||||
- name: Run cargo fmt
|
- name: Run cargo fmt
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
@ -164,3 +169,8 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
command: test
|
command: test
|
||||||
args: --manifest-path imgui-winit-support/Cargo.toml --no-default-features --features winit-20
|
args: --manifest-path imgui-winit-support/Cargo.toml --no-default-features --features winit-20
|
||||||
|
- name: Run cargo test (imgui-winit-support with winit-22)
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: test
|
||||||
|
args: --manifest-path imgui-winit-support/Cargo.toml --no-default-features --features winit-22
|
||||||
|
|||||||
@ -16,7 +16,7 @@ exclude = [
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bitflags = "1.0"
|
bitflags = "1.0"
|
||||||
glium = { version = "0.26", default-features = false, optional = true }
|
glium = { version = "0.27", default-features = false, optional = true }
|
||||||
gfx = { version = "0.18", optional = true }
|
gfx = { version = "0.18", optional = true }
|
||||||
imgui-sys = { version = "0.4.0-pre", path = "imgui-sys" }
|
imgui-sys = { version = "0.4.0-pre", path = "imgui-sys" }
|
||||||
lazy_static = "1.1"
|
lazy_static = "1.1"
|
||||||
|
|||||||
24
imgui-examples/Cargo.lock
generated
24
imgui-examples/Cargo.lock
generated
@ -339,13 +339,13 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "glium"
|
name = "glium"
|
||||||
version = "0.26.0"
|
version = "0.27.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"backtrace 0.3.45 (registry+https://github.com/rust-lang/crates.io-index)",
|
"backtrace 0.3.45 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"gl_generator 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gl_generator 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"glutin 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"glutin 0.24.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"memoffset 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"memoffset 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"smallvec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"smallvec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -354,7 +354,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "glutin"
|
name = "glutin"
|
||||||
version = "0.23.0"
|
version = "0.24.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"android_glue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"android_glue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -375,7 +375,7 @@ dependencies = [
|
|||||||
"parking_lot 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"parking_lot 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"wayland-client 0.23.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"wayland-client 0.23.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"winit 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winit 0.22.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -448,7 +448,7 @@ name = "imgui"
|
|||||||
version = "0.4.0-pre"
|
version = "0.4.0-pre"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"glium 0.26.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"glium 0.27.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"imgui-sys 0.4.0-pre",
|
"imgui-sys 0.4.0-pre",
|
||||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"parking_lot 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"parking_lot 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -459,7 +459,7 @@ name = "imgui-examples"
|
|||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clipboard 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"clipboard 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"glium 0.26.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"glium 0.27.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"image 0.23.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"image 0.23.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"imgui 0.4.0-pre",
|
"imgui 0.4.0-pre",
|
||||||
"imgui-glium-renderer 0.4.0-pre",
|
"imgui-glium-renderer 0.4.0-pre",
|
||||||
@ -470,7 +470,7 @@ dependencies = [
|
|||||||
name = "imgui-glium-renderer"
|
name = "imgui-glium-renderer"
|
||||||
version = "0.4.0-pre"
|
version = "0.4.0-pre"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"glium 0.26.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"glium 0.27.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"imgui 0.4.0-pre",
|
"imgui 0.4.0-pre",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -486,7 +486,7 @@ name = "imgui-winit-support"
|
|||||||
version = "0.4.0-pre"
|
version = "0.4.0-pre"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"imgui 0.4.0-pre",
|
"imgui 0.4.0-pre",
|
||||||
"winit 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winit 0.22.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1102,7 +1102,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winit"
|
name = "winit"
|
||||||
version = "0.21.0"
|
version = "0.22.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"android_glue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"android_glue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -1219,8 +1219,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
"checksum gif 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)" = "471d90201b3b223f3451cd4ad53e34295f16a1df17b1edf3736d47761c3981af"
|
"checksum gif 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)" = "471d90201b3b223f3451cd4ad53e34295f16a1df17b1edf3736d47761c3981af"
|
||||||
"checksum gl_generator 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ca98bbde17256e02d17336a6bdb5a50f7d0ccacee502e191d3e3d0ec2f96f84a"
|
"checksum gl_generator 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ca98bbde17256e02d17336a6bdb5a50f7d0ccacee502e191d3e3d0ec2f96f84a"
|
||||||
"checksum gl_generator 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1a95dfc23a2b4a9a2f5ab41d194f8bfda3cabec42af4e39f08c339eb2a0c124d"
|
"checksum gl_generator 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1a95dfc23a2b4a9a2f5ab41d194f8bfda3cabec42af4e39f08c339eb2a0c124d"
|
||||||
"checksum glium 0.26.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a46e88b2c64cfa63d54ed54dc2a0d25136470eb1721e10be49d857ab583f8663"
|
"checksum glium 0.27.0 (registry+https://github.com/rust-lang/crates.io-index)" = "030bb23a12fac7e589b002c5e131e89348df88f91b56e3f3dbc4249527eeebf9"
|
||||||
"checksum glutin 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cf22d4e90c55d9be9f2ad52410e7a2c0d7e9c99d93a13df73a672e7ef4e8c7f7"
|
"checksum glutin 0.24.0 (registry+https://github.com/rust-lang/crates.io-index)" = "611023dea5047f3e9047aecb9e361852dcfd0881129daf5d110106ca2b14f3f3"
|
||||||
"checksum glutin_egl_sys 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "772edef3b28b8ad41e4ea202748e65eefe8e5ffd1f4535f1219793dbb20b3d4c"
|
"checksum glutin_egl_sys 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "772edef3b28b8ad41e4ea202748e65eefe8e5ffd1f4535f1219793dbb20b3d4c"
|
||||||
"checksum glutin_emscripten_sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "80de4146df76e8a6c32b03007bc764ff3249dcaeb4f675d68a06caf1bac363f1"
|
"checksum glutin_emscripten_sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "80de4146df76e8a6c32b03007bc764ff3249dcaeb4f675d68a06caf1bac363f1"
|
||||||
"checksum glutin_gles2_sys 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "07e853d96bebcb8e53e445225c3009758c6f5960d44f2543245f6f07b567dae0"
|
"checksum glutin_gles2_sys 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "07e853d96bebcb8e53e445225c3009758c6f5960d44f2543245f6f07b567dae0"
|
||||||
@ -1303,7 +1303,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||||
"checksum winapi-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4ccfbf554c6ad11084fb7517daca16cfdcaccbdadba4fc336f032a8b12c2ad80"
|
"checksum winapi-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4ccfbf554c6ad11084fb7517daca16cfdcaccbdadba4fc336f032a8b12c2ad80"
|
||||||
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||||
"checksum winit 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)" = "65a5c1a5ef76ac31cc97ad29489acdbed2178f3fc12ca00ee6cb11d60adb5a3a"
|
"checksum winit 0.22.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fc53342d3d1a3d57f3949e0692d93d5a8adb7814d8683cef4a09c2b550e94246"
|
||||||
"checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"
|
"checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"
|
||||||
"checksum x11-clipboard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "89bd49c06c9eb5d98e6ba6536cf64ac9f7ee3a009b2f53996d405b3944f6bcea"
|
"checksum x11-clipboard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "89bd49c06c9eb5d98e6ba6536cf64ac9f7ee3a009b2f53996d405b3944f6bcea"
|
||||||
"checksum x11-dl 2.18.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2bf981e3a5b3301209754218f962052d4d9ee97e478f4d26d4a6eced34c1fef8"
|
"checksum x11-dl 2.18.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2bf981e3a5b3301209754218f962052d4d9ee97e478f4d26d4a6eced34c1fef8"
|
||||||
|
|||||||
@ -11,7 +11,7 @@ publish = false
|
|||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
clipboard = "0.5"
|
clipboard = "0.5"
|
||||||
glium = { version = "0.26", default-features = true }
|
glium = { version = "0.27", default-features = true }
|
||||||
image = "0.23"
|
image = "0.23"
|
||||||
imgui = { path = "../" }
|
imgui = { path = "../" }
|
||||||
imgui-glium-renderer = { path = "../imgui-glium-renderer" }
|
imgui-glium-renderer = { path = "../imgui-glium-renderer" }
|
||||||
|
|||||||
@ -10,5 +10,5 @@ license = "MIT/Apache-2.0"
|
|||||||
categories = ["gui", "rendering"]
|
categories = ["gui", "rendering"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
glium = { version = "0.26", default-features = false }
|
glium = { version = "0.27", default-features = false }
|
||||||
imgui = { version = "0.4.0-pre", path = "../", features = ["glium"] }
|
imgui = { version = "0.4.0-pre", path = "../", features = ["glium"] }
|
||||||
|
|||||||
@ -13,6 +13,7 @@ categories = ["gui"]
|
|||||||
imgui = { version = "0.4.0-pre", path = "../" }
|
imgui = { version = "0.4.0-pre", path = "../" }
|
||||||
winit-19 = { version = ">= 0.16, <= 0.19", package = "winit", optional = true }
|
winit-19 = { version = ">= 0.16, <= 0.19", package = "winit", optional = true }
|
||||||
winit-20 = { version = ">= 0.20, <= 0.21", package = "winit", optional = true }
|
winit-20 = { version = ">= 0.20, <= 0.21", package = "winit", optional = true }
|
||||||
|
winit-22 = { version = "0.22", package = "winit", optional = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["winit-20"]
|
default = ["winit-22"]
|
||||||
|
|||||||
@ -77,6 +77,9 @@ use winit_19 as winit;
|
|||||||
#[cfg(feature = "winit-20")]
|
#[cfg(feature = "winit-20")]
|
||||||
use winit_20 as winit;
|
use winit_20 as winit;
|
||||||
|
|
||||||
|
#[cfg(feature = "winit-22")]
|
||||||
|
use winit_22 as winit;
|
||||||
|
|
||||||
use imgui::{self, BackendFlags, ConfigFlags, Context, ImString, Io, Key, Ui};
|
use imgui::{self, BackendFlags, ConfigFlags, Context, ImString, Io, Key, Ui};
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
use winit::dpi::{LogicalPosition, LogicalSize};
|
use winit::dpi::{LogicalPosition, LogicalSize};
|
||||||
@ -87,8 +90,8 @@ use winit::{
|
|||||||
TouchPhase, VirtualKeyCode, Window, WindowEvent,
|
TouchPhase, VirtualKeyCode, Window, WindowEvent,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "winit-20")]
|
#[cfg(any(feature = "winit-20", feature = "winit-22"))]
|
||||||
use winit_20::{
|
use winit::{
|
||||||
error::ExternalError,
|
error::ExternalError,
|
||||||
event::{
|
event::{
|
||||||
DeviceEvent, ElementState, Event, KeyboardInput, MouseButton, MouseScrollDelta, TouchPhase,
|
DeviceEvent, ElementState, Event, KeyboardInput, MouseButton, MouseScrollDelta, TouchPhase,
|
||||||
@ -210,7 +213,7 @@ impl WinitPlatform {
|
|||||||
///
|
///
|
||||||
/// * framebuffer scale (= DPI factor) is set
|
/// * framebuffer scale (= DPI factor) is set
|
||||||
/// * display size is set
|
/// * display size is set
|
||||||
#[cfg(feature = "winit-20")]
|
#[cfg(any(feature = "winit-20", feature = "winit-22"))]
|
||||||
pub fn attach_window(&mut self, io: &mut Io, window: &Window, hidpi_mode: HiDpiMode) {
|
pub fn attach_window(&mut self, io: &mut Io, window: &Window, hidpi_mode: HiDpiMode) {
|
||||||
let (hidpi_mode, hidpi_factor) = hidpi_mode.apply(window.scale_factor());
|
let (hidpi_mode, hidpi_factor) = hidpi_mode.apply(window.scale_factor());
|
||||||
self.hidpi_mode = hidpi_mode;
|
self.hidpi_mode = hidpi_mode;
|
||||||
@ -243,7 +246,7 @@ impl WinitPlatform {
|
|||||||
///
|
///
|
||||||
/// This utility function is useful if you are using a DPI mode other than default, and want
|
/// This utility function is useful if you are using a DPI mode other than default, and want
|
||||||
/// your application to use the same logical coordinates as imgui-rs.
|
/// your application to use the same logical coordinates as imgui-rs.
|
||||||
#[cfg(feature = "winit-20")]
|
#[cfg(any(feature = "winit-20", feature = "winit-22"))]
|
||||||
pub fn scale_size_from_winit(
|
pub fn scale_size_from_winit(
|
||||||
&self,
|
&self,
|
||||||
window: &Window,
|
window: &Window,
|
||||||
@ -277,7 +280,7 @@ impl WinitPlatform {
|
|||||||
///
|
///
|
||||||
/// This utility function is useful if you are using a DPI mode other than default, and want
|
/// This utility function is useful if you are using a DPI mode other than default, and want
|
||||||
/// your application to use the same logical coordinates as imgui-rs.
|
/// your application to use the same logical coordinates as imgui-rs.
|
||||||
#[cfg(feature = "winit-20")]
|
#[cfg(any(feature = "winit-20", feature = "winit-22"))]
|
||||||
pub fn scale_pos_from_winit(
|
pub fn scale_pos_from_winit(
|
||||||
&self,
|
&self,
|
||||||
window: &Window,
|
window: &Window,
|
||||||
@ -311,7 +314,7 @@ impl WinitPlatform {
|
|||||||
///
|
///
|
||||||
/// This utility function is useful if you are using a DPI mode other than default, and want
|
/// This utility function is useful if you are using a DPI mode other than default, and want
|
||||||
/// your application to use the same logical coordinates as imgui-rs.
|
/// your application to use the same logical coordinates as imgui-rs.
|
||||||
#[cfg(feature = "winit-20")]
|
#[cfg(any(feature = "winit-20", feature = "winit-22"))]
|
||||||
pub fn scale_pos_for_winit(
|
pub fn scale_pos_for_winit(
|
||||||
&self,
|
&self,
|
||||||
window: &Window,
|
window: &Window,
|
||||||
@ -408,6 +411,48 @@ impl WinitPlatform {
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// Handles a winit event.
|
||||||
|
///
|
||||||
|
/// This function performs the following actions (depends on the event):
|
||||||
|
///
|
||||||
|
/// * window size / dpi factor changes are applied
|
||||||
|
/// * keyboard state is updated
|
||||||
|
/// * mouse state is updated
|
||||||
|
#[cfg(any(feature = "winit-22"))]
|
||||||
|
pub fn handle_event<T>(&mut self, io: &mut Io, window: &Window, event: &Event<T>) {
|
||||||
|
match *event {
|
||||||
|
Event::WindowEvent {
|
||||||
|
window_id,
|
||||||
|
ref event,
|
||||||
|
} if window_id == window.id() => {
|
||||||
|
// We need to track modifiers separately because some system like macOS, will
|
||||||
|
// not reliably send modifier states during certain events like ScreenCapture.
|
||||||
|
// Gotta let the people show off their pretty imgui widgets!
|
||||||
|
if let WindowEvent::ModifiersChanged(modifiers) = event {
|
||||||
|
io.key_shift = modifiers.shift();
|
||||||
|
io.key_ctrl = modifiers.ctrl();
|
||||||
|
io.key_alt = modifiers.alt();
|
||||||
|
io.key_super = modifiers.logo();
|
||||||
|
}
|
||||||
|
|
||||||
|
self.handle_window_event(io, window, event);
|
||||||
|
}
|
||||||
|
// Track key release events outside our window. If we don't do this,
|
||||||
|
// we might never see the release event if some other window gets focus.
|
||||||
|
Event::DeviceEvent {
|
||||||
|
event:
|
||||||
|
DeviceEvent::Key(KeyboardInput {
|
||||||
|
state: ElementState::Released,
|
||||||
|
virtual_keycode: Some(key),
|
||||||
|
..
|
||||||
|
}),
|
||||||
|
..
|
||||||
|
} => {
|
||||||
|
io.keys_down[key as usize] = false;
|
||||||
|
}
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
|
}
|
||||||
#[cfg(feature = "winit-19")]
|
#[cfg(feature = "winit-19")]
|
||||||
fn handle_window_event(&mut self, io: &mut Io, window: &Window, event: &WindowEvent) {
|
fn handle_window_event(&mut self, io: &mut Io, window: &Window, event: &WindowEvent) {
|
||||||
match *event {
|
match *event {
|
||||||
@ -494,7 +539,7 @@ impl WinitPlatform {
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(feature = "winit-20")]
|
#[cfg(any(feature = "winit-20", feature = "winit-22"))]
|
||||||
fn handle_window_event(&mut self, io: &mut Io, window: &Window, event: &WindowEvent) {
|
fn handle_window_event(&mut self, io: &mut Io, window: &Window, event: &WindowEvent) {
|
||||||
match *event {
|
match *event {
|
||||||
WindowEvent::Resized(physical_size) => {
|
WindowEvent::Resized(physical_size) => {
|
||||||
@ -618,7 +663,7 @@ impl WinitPlatform {
|
|||||||
/// This function performs the following actions:
|
/// This function performs the following actions:
|
||||||
///
|
///
|
||||||
/// * mouse cursor is repositioned (if requested by imgui-rs)
|
/// * mouse cursor is repositioned (if requested by imgui-rs)
|
||||||
#[cfg(feature = "winit-20")]
|
#[cfg(any(feature = "winit-20", feature = "winit-22"))]
|
||||||
pub fn prepare_frame(&self, io: &mut Io, window: &Window) -> Result<(), ExternalError> {
|
pub fn prepare_frame(&self, io: &mut Io, window: &Window) -> Result<(), ExternalError> {
|
||||||
if io.want_set_mouse_pos {
|
if io.want_set_mouse_pos {
|
||||||
let logical_pos = self.scale_pos_for_winit(
|
let logical_pos = self.scale_pos_for_winit(
|
||||||
@ -668,7 +713,7 @@ impl WinitPlatform {
|
|||||||
/// This function performs the following actions:
|
/// This function performs the following actions:
|
||||||
///
|
///
|
||||||
/// * mouse cursor is changed and/or hidden (if requested by imgui-rs)
|
/// * mouse cursor is changed and/or hidden (if requested by imgui-rs)
|
||||||
#[cfg(feature = "winit-20")]
|
#[cfg(any(feature = "winit-20", feature = "winit-22"))]
|
||||||
pub fn prepare_render(&self, ui: &Ui, window: &Window) {
|
pub fn prepare_render(&self, ui: &Ui, window: &Window) {
|
||||||
let io = ui.io();
|
let io = ui.io();
|
||||||
if !io
|
if !io
|
||||||
|
|||||||
@ -72,6 +72,7 @@ pub(crate) unsafe extern "C" fn set_clipboard_text(user_data: *mut c_void, text:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// # Clipboard
|
/// # Clipboard
|
||||||
|
#[allow(clippy::fn_address_comparisons)] // This is allowed because although function addresses wont be unique, we just care if its OURS
|
||||||
impl<'ui> Ui<'ui> {
|
impl<'ui> Ui<'ui> {
|
||||||
/// Returns the current clipboard contents as text, or None if the clipboard is empty or cannot
|
/// Returns the current clipboard contents as text, or None if the clipboard is empty or cannot
|
||||||
/// be accessed
|
/// be accessed
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use sys;
|
|
||||||
|
|
||||||
use super::{ImStr, Ui};
|
use super::{ImStr, Ui};
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::os::raw::c_float;
|
use std::os::raw::c_float;
|
||||||
use std::{f32, mem, ptr};
|
use std::{f32, mem, ptr};
|
||||||
use sys;
|
|
||||||
|
|
||||||
use super::{ImStr, Ui};
|
use super::{ImStr, Ui};
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::os::raw::c_float;
|
use std::os::raw::c_float;
|
||||||
use std::{f32, mem, ptr};
|
use std::{f32, mem, ptr};
|
||||||
use sys;
|
|
||||||
|
|
||||||
use super::{ImStr, Ui};
|
use super::{ImStr, Ui};
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
use sys;
|
|
||||||
use sys::{ImDrawList, ImU32};
|
use sys::{ImDrawList, ImU32};
|
||||||
|
|
||||||
use super::Ui;
|
use super::Ui;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user