Skip to content

Commit

Permalink
Multi window update
Browse files Browse the repository at this point in the history
  • Loading branch information
PolyMeilex committed Dec 5, 2023
1 parent 501f0d2 commit 0c1213a
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 33 deletions.
19 changes: 10 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions neothesia/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ oxisynth = { version = "0.0.3", optional = true }
midi-file = { workspace = true }
midi-io = { path = "../midi-io" }

iced_style = {git = "https://github.com/iced-rs/iced.git", rev="8727b3fc50ec251d9c117c51ca1289be5ba9b117"}
iced_graphics = {git = "https://github.com/iced-rs/iced.git", rev="8727b3fc50ec251d9c117c51ca1289be5ba9b117"}
iced_core = {git = "https://github.com/iced-rs/iced.git", rev="8727b3fc50ec251d9c117c51ca1289be5ba9b117"}
iced_runtime = {git = "https://github.com/iced-rs/iced.git", rev="8727b3fc50ec251d9c117c51ca1289be5ba9b117"}
iced_wgpu = { git = "https://github.com/iced-rs/iced.git", rev="8727b3fc50ec251d9c117c51ca1289be5ba9b117", features = ["image"] }
iced_widget = { git = "https://github.com/iced-rs/iced.git", rev="8727b3fc50ec251d9c117c51ca1289be5ba9b117", features = ["image"] }
iced_style = {git = "https://github.com/iced-rs/iced.git", rev="fc285d3e461626408c56bbc1605fcf0c974b2f69"}
iced_graphics = {git = "https://github.com/iced-rs/iced.git", rev="fc285d3e461626408c56bbc1605fcf0c974b2f69"}
iced_core = {git = "https://github.com/iced-rs/iced.git", rev="fc285d3e461626408c56bbc1605fcf0c974b2f69"}
iced_runtime = {git = "https://github.com/iced-rs/iced.git", rev="fc285d3e461626408c56bbc1605fcf0c974b2f69"}
iced_wgpu = { git = "https://github.com/iced-rs/iced.git", rev="fc285d3e461626408c56bbc1605fcf0c974b2f69", features = ["image"] }
iced_widget = { git = "https://github.com/iced-rs/iced.git", rev="fc285d3e461626408c56bbc1605fcf0c974b2f69", features = ["image"] }

[[bin]]
name = "neothesia"
49 changes: 31 additions & 18 deletions neothesia/src/iced_utils/iced_conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,32 @@ pub fn window_event(
) -> Option<Event> {
use winit::event::WindowEvent;

let id = iced_core::window::Id::MAIN;

match event {
WindowEvent::Resized(new_size) => {
let logical_size = new_size.to_logical(scale_factor);

Some(Event::Window(window::Event::Resized {
width: logical_size.width,
height: logical_size.height,
}))
Some(Event::Window(
id,
window::Event::Resized {
width: logical_size.width,
height: logical_size.height,
},
))
}
WindowEvent::ScaleFactorChanged { new_inner_size, .. } => {
let logical_size = new_inner_size.to_logical(scale_factor);

Some(Event::Window(window::Event::Resized {
width: logical_size.width,
height: logical_size.height,
}))
Some(Event::Window(
id,
window::Event::Resized {
width: logical_size.width,
height: logical_size.height,
},
))
}
WindowEvent::CloseRequested => Some(Event::Window(window::Event::CloseRequested)),
WindowEvent::CloseRequested => Some(Event::Window(id, window::Event::CloseRequested)),
WindowEvent::CursorMoved { position, .. } => {
let position = position.to_logical::<f64>(scale_factor);

Expand Down Expand Up @@ -132,23 +140,28 @@ pub fn window_event(
WindowEvent::ModifiersChanged(new_modifiers) => Some(Event::Keyboard(
keyboard::Event::ModifiersChanged(self::modifiers(*new_modifiers)),
)),
WindowEvent::Focused(focused) => Some(Event::Window(if *focused {
window::Event::Focused
} else {
window::Event::Unfocused
})),
WindowEvent::Focused(focused) => Some(Event::Window(
id,
if *focused {
window::Event::Focused
} else {
window::Event::Unfocused
},
)),
WindowEvent::HoveredFile(path) => {
Some(Event::Window(window::Event::FileHovered(path.clone())))
Some(Event::Window(id, window::Event::FileHovered(path.clone())))
}
WindowEvent::DroppedFile(path) => {
Some(Event::Window(window::Event::FileDropped(path.clone())))
Some(Event::Window(id, window::Event::FileDropped(path.clone())))
}
WindowEvent::HoveredFileCancelled => {
Some(Event::Window(id, window::Event::FilesHoveredLeft))
}
WindowEvent::HoveredFileCancelled => Some(Event::Window(window::Event::FilesHoveredLeft)),
WindowEvent::Touch(touch) => Some(Event::Touch(touch_event(*touch, scale_factor))),
WindowEvent::Moved(position) => {
let winit::dpi::LogicalPosition { x, y } = position.to_logical(scale_factor);

Some(Event::Window(window::Event::Moved { x, y }))
Some(Event::Window(id, window::Event::Moved { x, y }))
}
_ => None,
}
Expand Down

0 comments on commit 0c1213a

Please sign in to comment.