mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-13 14:38:36 +00:00
Replace imgui-glutin-support with imgui-winit-support
This commit is contained in:
parent
0b459cf104
commit
eb5aaf1c2a
@ -11,6 +11,7 @@
|
||||
- Upgrade to cimgui 1.66.2+ / imgui 1.66b. **This is a very big update, so there
|
||||
are a lot of breaking changes**
|
||||
- Bump minimum Rust version to 1.28 (required by the glutin crate)
|
||||
- Replaced `imgui-glutin-support` with `imgui-winit-support`
|
||||
|
||||
## [0.0.21] - 2018-10-11
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@ members = [
|
||||
"imgui-sys",
|
||||
"imgui-gfx-renderer",
|
||||
"imgui-glium-renderer",
|
||||
"imgui-glutin-support"
|
||||
"imgui-winit-support"
|
||||
]
|
||||
exclude = [
|
||||
"imgui-examples",
|
||||
|
||||
18
imgui-examples/Cargo.lock
generated
18
imgui-examples/Cargo.lock
generated
@ -287,7 +287,7 @@ dependencies = [
|
||||
"glutin 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"imgui 0.0.22-pre",
|
||||
"imgui-gfx-renderer 0.0.22-pre",
|
||||
"imgui-glutin-support 0.0.22-pre",
|
||||
"imgui-winit-support 0.0.22-pre",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -299,14 +299,6 @@ dependencies = [
|
||||
"imgui-sys 0.0.22-pre",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "imgui-glutin-support"
|
||||
version = "0.0.22-pre"
|
||||
dependencies = [
|
||||
"glutin 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"imgui 0.0.22-pre",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "imgui-sys"
|
||||
version = "0.0.22-pre"
|
||||
@ -317,6 +309,14 @@ dependencies = [
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "imgui-winit-support"
|
||||
version = "0.0.22-pre"
|
||||
dependencies = [
|
||||
"imgui 0.0.22-pre",
|
||||
"winit 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "khronos_api"
|
||||
version = "2.2.0"
|
||||
|
||||
@ -14,4 +14,4 @@ gfx_window_glutin = "0.27"
|
||||
glutin = "0.19"
|
||||
imgui = { version = "0.0.22-pre", path = "../" }
|
||||
imgui-gfx-renderer = { version = "0.0.22-pre", path = "../imgui-gfx-renderer" }
|
||||
imgui-glutin-support = { version = "0.0.22-pre", path = "../imgui-glutin-support" }
|
||||
imgui-winit-support = { version = "0.0.22-pre", path = "../imgui-winit-support" }
|
||||
|
||||
@ -4,7 +4,7 @@ extern crate glutin;
|
||||
#[macro_use]
|
||||
extern crate imgui;
|
||||
extern crate imgui_gfx_renderer;
|
||||
extern crate imgui_glutin_support;
|
||||
extern crate imgui_winit_support;
|
||||
|
||||
use imgui::*;
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use imgui::{FontGlyphRange, ImFontConfig, ImGui, ImVec4, Ui};
|
||||
use imgui_gfx_renderer::{Renderer, Shaders};
|
||||
use imgui_glutin_support;
|
||||
use imgui_winit_support;
|
||||
use std::time::Instant;
|
||||
|
||||
pub fn run<F: FnMut(&Ui) -> bool>(title: String, clear_color: [f32; 4], mut run_ui: F) {
|
||||
@ -87,7 +87,7 @@ pub fn run<F: FnMut(&Ui) -> bool>(title: String, clear_color: [f32; 4], mut run_
|
||||
let mut renderer = Renderer::init(&mut imgui, &mut factory, shaders, main_color.clone())
|
||||
.expect("Failed to initialize renderer");
|
||||
|
||||
imgui_glutin_support::configure_keys(&mut imgui);
|
||||
imgui_winit_support::configure_keys(&mut imgui);
|
||||
|
||||
let mut last_frame = Instant::now();
|
||||
let mut quit = false;
|
||||
@ -99,7 +99,7 @@ pub fn run<F: FnMut(&Ui) -> bool>(title: String, clear_color: [f32; 4], mut run_
|
||||
WindowEvent::{CloseRequested, Resized},
|
||||
};
|
||||
|
||||
imgui_glutin_support::handle_event(
|
||||
imgui_winit_support::handle_event(
|
||||
&mut imgui,
|
||||
&event,
|
||||
window.get_hidpi_factor(),
|
||||
@ -126,9 +126,9 @@ pub fn run<F: FnMut(&Ui) -> bool>(title: String, clear_color: [f32; 4], mut run_
|
||||
let delta_s = delta.as_secs() as f32 + delta.subsec_nanos() as f32 / 1_000_000_000.0;
|
||||
last_frame = now;
|
||||
|
||||
imgui_glutin_support::update_mouse_cursor(&imgui, &window);
|
||||
imgui_winit_support::update_mouse_cursor(&imgui, &window);
|
||||
|
||||
let frame_size = imgui_glutin_support::get_frame_size(&window, hidpi_factor).unwrap();
|
||||
let frame_size = imgui_winit_support::get_frame_size(&window, hidpi_factor).unwrap();
|
||||
|
||||
let ui = imgui.frame(frame_size, delta_s);
|
||||
if !run_ui(&ui) {
|
||||
|
||||
18
imgui-glium-examples/Cargo.lock
generated
18
imgui-glium-examples/Cargo.lock
generated
@ -305,7 +305,7 @@ dependencies = [
|
||||
"image 0.20.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"imgui 0.0.22-pre",
|
||||
"imgui-glium-renderer 0.0.22-pre",
|
||||
"imgui-glutin-support 0.0.22-pre",
|
||||
"imgui-winit-support 0.0.22-pre",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -317,14 +317,6 @@ dependencies = [
|
||||
"imgui-sys 0.0.22-pre",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "imgui-glutin-support"
|
||||
version = "0.0.22-pre"
|
||||
dependencies = [
|
||||
"glutin 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"imgui 0.0.22-pre",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "imgui-sys"
|
||||
version = "0.0.22-pre"
|
||||
@ -335,6 +327,14 @@ dependencies = [
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "imgui-winit-support"
|
||||
version = "0.0.22-pre"
|
||||
dependencies = [
|
||||
"imgui 0.0.22-pre",
|
||||
"winit 0.16.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "inflate"
|
||||
version = "0.4.3"
|
||||
|
||||
@ -12,5 +12,5 @@ publish = false
|
||||
glium = { version = "0.22", default-features = true }
|
||||
imgui = { version = "0.0.22-pre", path = "../" }
|
||||
imgui-glium-renderer = { version = "0.0.22-pre", path = "../imgui-glium-renderer" }
|
||||
imgui-glutin-support = { version = "0.0.22-pre", path = "../imgui-glutin-support" }
|
||||
imgui-winit-support = { version = "0.0.22-pre", path = "../imgui-winit-support" }
|
||||
image = "0.20"
|
||||
|
||||
@ -2,7 +2,7 @@ extern crate glium;
|
||||
#[macro_use]
|
||||
extern crate imgui;
|
||||
extern crate imgui_glium_renderer;
|
||||
extern crate imgui_glutin_support;
|
||||
extern crate imgui_winit_support;
|
||||
|
||||
use imgui::*;
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@ extern crate glium;
|
||||
extern crate image;
|
||||
extern crate imgui;
|
||||
extern crate imgui_glium_renderer;
|
||||
extern crate imgui_glutin_support;
|
||||
extern crate imgui_winit_support;
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::error::Error;
|
||||
|
||||
@ -2,7 +2,7 @@ extern crate glium;
|
||||
#[macro_use]
|
||||
extern crate imgui;
|
||||
extern crate imgui_glium_renderer;
|
||||
extern crate imgui_glutin_support;
|
||||
extern crate imgui_winit_support;
|
||||
|
||||
use imgui::*;
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ use glium::{
|
||||
Texture2d,
|
||||
};
|
||||
use imgui::{FontGlyphRange, ImFontConfig, ImGui, Ui};
|
||||
use imgui_glutin_support;
|
||||
use imgui_winit_support;
|
||||
use std::rc::Rc;
|
||||
use std::time::Instant;
|
||||
|
||||
@ -56,7 +56,7 @@ where
|
||||
|
||||
let mut renderer = Renderer::init(&mut imgui, &display).expect("Failed to initialize renderer");
|
||||
|
||||
imgui_glutin_support::configure_keys(&mut imgui);
|
||||
imgui_winit_support::configure_keys(&mut imgui);
|
||||
|
||||
let mut last_frame = Instant::now();
|
||||
let mut quit = false;
|
||||
@ -65,7 +65,7 @@ where
|
||||
events_loop.poll_events(|event| {
|
||||
use glium::glutin::{Event, WindowEvent::CloseRequested};
|
||||
|
||||
imgui_glutin_support::handle_event(
|
||||
imgui_winit_support::handle_event(
|
||||
&mut imgui,
|
||||
&event,
|
||||
window.get_hidpi_factor(),
|
||||
@ -85,9 +85,9 @@ where
|
||||
let delta_s = delta.as_secs() as f32 + delta.subsec_nanos() as f32 / 1_000_000_000.0;
|
||||
last_frame = now;
|
||||
|
||||
imgui_glutin_support::update_mouse_cursor(&imgui, &window);
|
||||
imgui_winit_support::update_mouse_cursor(&imgui, &window);
|
||||
|
||||
let frame_size = imgui_glutin_support::get_frame_size(&window, hidpi_factor).unwrap();
|
||||
let frame_size = imgui_winit_support::get_frame_size(&window, hidpi_factor).unwrap();
|
||||
|
||||
let ui = imgui.frame(frame_size, delta_s);
|
||||
if !run_ui(&ui, display.get_context(), renderer.textures()) {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
extern crate glium;
|
||||
extern crate imgui;
|
||||
extern crate imgui_glium_renderer;
|
||||
extern crate imgui_glutin_support;
|
||||
extern crate imgui_winit_support;
|
||||
|
||||
mod support;
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
extern crate glium;
|
||||
extern crate imgui;
|
||||
extern crate imgui_glium_renderer;
|
||||
extern crate imgui_glutin_support;
|
||||
extern crate imgui_winit_support;
|
||||
|
||||
mod support;
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@ extern crate glium;
|
||||
#[macro_use]
|
||||
extern crate imgui;
|
||||
extern crate imgui_glium_renderer;
|
||||
extern crate imgui_glutin_support;
|
||||
extern crate imgui_winit_support;
|
||||
|
||||
use imgui::*;
|
||||
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
[package]
|
||||
name = "imgui-glutin-support"
|
||||
name = "imgui-winit-support"
|
||||
version = "0.0.22-pre"
|
||||
authors = ["Joonas Javanainen <joonas.javanainen@gmail.com>", "imgui-rs contributors"]
|
||||
description = "glutin support code for the imgui crate"
|
||||
description = "winit support code for the imgui crate"
|
||||
homepage = "https://github.com/Gekkio/imgui-rs"
|
||||
repository = "https://github.com/Gekkio/imgui-rs"
|
||||
license = "MIT/Apache-2.0"
|
||||
@ -12,5 +12,5 @@ categories = ["gui"]
|
||||
travis-ci = { repository = "Gekkio/imgui-rs" }
|
||||
|
||||
[dependencies]
|
||||
glutin = ">= 0.17, <= 0.19"
|
||||
imgui = { version = "0.0.22-pre", path = "../" }
|
||||
winit = ">= 0.16, <= 0.18"
|
||||
@ -1,4 +1,4 @@
|
||||
//! This crate provides support functions to simplify integrating imgui-rs with glutin.
|
||||
//! This crate provides support functions to simplify integrating imgui-rs with winit.
|
||||
//!
|
||||
//! # Using the library
|
||||
//!
|
||||
@ -6,24 +6,24 @@
|
||||
//!
|
||||
//! ```rust,no_run
|
||||
//! # extern crate imgui;
|
||||
//! # extern crate imgui_glutin_support;
|
||||
//! # extern crate imgui_winit_support;
|
||||
//! use imgui::ImGui;
|
||||
//!
|
||||
//! # fn main() {
|
||||
//! let mut imgui = ImGui::init();
|
||||
//! imgui_glutin_support::configure_keys(&mut imgui);
|
||||
//! imgui_winit_support::configure_keys(&mut imgui);
|
||||
//! # }
|
||||
//! ```
|
||||
//!
|
||||
//! In your main loop you should already be retrieving events from glutin and handling them. All
|
||||
//! you need to do is pass each event to `imgui_glutin_support` as well:
|
||||
//! In your main loop you should already be retrieving events from winit and handling them. All
|
||||
//! you need to do is pass each event to `imgui_winit_support` as well:
|
||||
//!
|
||||
//! ```rust,no_run
|
||||
//! # extern crate glutin;
|
||||
//! # extern crate imgui;
|
||||
//! # extern crate imgui_glutin_support;
|
||||
//! # use glutin::EventsLoop;
|
||||
//! # extern crate imgui_winit_support;
|
||||
//! # extern crate winit;
|
||||
//! # use imgui::ImGui;
|
||||
//! # use winit::EventsLoop;
|
||||
//! # fn main() {
|
||||
//! # let mut events_loop = EventsLoop::new();
|
||||
//! # let mut imgui = ImGui::init();
|
||||
@ -32,7 +32,7 @@
|
||||
//! events_loop.poll_events(|event| {
|
||||
//! // do application-specific stuff with event
|
||||
//!
|
||||
//! imgui_glutin_support::handle_event(
|
||||
//! imgui_winit_support::handle_event(
|
||||
//! &mut imgui,
|
||||
//! &event,
|
||||
//! window_hidpi_factor,
|
||||
@ -50,11 +50,11 @@
|
||||
//! For example, you might want to customize mouse wheel line scrolling amount:
|
||||
//!
|
||||
//! ```rust,no_run
|
||||
//! # extern crate glutin;
|
||||
//! # extern crate imgui;
|
||||
//! # extern crate imgui_glutin_support;
|
||||
//! # use glutin::{EventsLoop, Event, WindowEvent, MouseScrollDelta, TouchPhase};
|
||||
//! # extern crate imgui_winit_support;
|
||||
//! # extern crate winit;
|
||||
//! # use imgui::ImGui;
|
||||
//! # use winit::{EventsLoop, Event, WindowEvent, MouseScrollDelta, TouchPhase};
|
||||
//! # fn main() {
|
||||
//! # let mut events_loop = EventsLoop::new();
|
||||
//! # let mut imgui = ImGui::init();
|
||||
@ -64,7 +64,7 @@
|
||||
//! // do application-specific stuff with event
|
||||
//!
|
||||
//! // default handling for events
|
||||
//! imgui_glutin_support::handle_event(
|
||||
//! imgui_winit_support::handle_event(
|
||||
//! &mut imgui,
|
||||
//! &event,
|
||||
//! window_hidpi_factor,
|
||||
@ -89,16 +89,16 @@
|
||||
//! # }
|
||||
//! ```
|
||||
|
||||
extern crate glutin;
|
||||
extern crate imgui;
|
||||
extern crate winit;
|
||||
|
||||
use glutin::{
|
||||
use imgui::{FrameSize, ImGui, ImGuiKey, ImGuiMouseCursor};
|
||||
use winit::{
|
||||
ElementState, Event, KeyboardInput, ModifiersState, MouseButton, MouseCursor, MouseScrollDelta,
|
||||
TouchPhase, VirtualKeyCode, Window, WindowEvent,
|
||||
};
|
||||
use imgui::{FrameSize, ImGui, ImGuiKey, ImGuiMouseCursor};
|
||||
|
||||
/// Configure imgui key map with glutin `VirtualKeyCode` values
|
||||
/// Configure imgui key map with winit `VirtualKeyCode` values
|
||||
pub fn configure_keys(imgui: &mut ImGui) {
|
||||
imgui.set_imgui_key(ImGuiKey::Tab, VirtualKeyCode::Tab as _);
|
||||
imgui.set_imgui_key(ImGuiKey::LeftArrow, VirtualKeyCode::Left as _);
|
||||
@ -177,7 +177,7 @@ pub fn handle_mouse_button_state(imgui: &mut ImGui, button: MouseButton, state:
|
||||
imgui.set_mouse_down(states);
|
||||
}
|
||||
|
||||
/// Update imgui state from glutin event
|
||||
/// Update imgui state from winit event
|
||||
pub fn handle_event(
|
||||
imgui: &mut ImGui,
|
||||
event: &Event,
|
||||
@ -192,7 +192,7 @@ pub fn handle_event(
|
||||
}
|
||||
}
|
||||
|
||||
/// Update imgui state from glutin window event
|
||||
/// Update imgui state from winit window event
|
||||
pub fn handle_window_event(
|
||||
imgui: &mut ImGui,
|
||||
event: &WindowEvent,
|
||||
@ -236,7 +236,7 @@ pub fn handle_window_event(
|
||||
}
|
||||
}
|
||||
|
||||
/// Update glutin window mouse cursor state
|
||||
/// Update winit window mouse cursor state
|
||||
pub fn update_mouse_cursor(imgui: &ImGui, window: &Window) {
|
||||
let mouse_cursor = imgui.mouse_cursor();
|
||||
if imgui.mouse_draw_cursor() || mouse_cursor == ImGuiMouseCursor::None {
|
||||
Loading…
x
Reference in New Issue
Block a user