Upgrade to winit 0.25

This commit is contained in:
Imbris 2021-06-15 04:01:57 -04:00
parent 9d9c0a045d
commit b7162ac15c
14 changed files with 102 additions and 155 deletions

168
Cargo.lock generated
View File

@ -613,15 +613,6 @@ dependencies = [
"objc_id", "objc_id",
] ]
[[package]]
name = "clipboard_wayland"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61bcb8cde0387fde807b9b7af66ce8bd1665ef736e46e6e47fda82ea003e6ade"
dependencies = [
"smithay-clipboard",
]
[[package]] [[package]]
name = "clipboard_wayland" name = "clipboard_wayland"
version = "0.2.0" version = "0.2.0"
@ -631,16 +622,6 @@ dependencies = [
"smithay-clipboard", "smithay-clipboard",
] ]
[[package]]
name = "clipboard_x11"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40403aa5220e5cd303d32dc4248cac8aa92bf47e3ae31e0e2481081755a63ff1"
dependencies = [
"thiserror",
"x11rb",
]
[[package]] [[package]]
name = "clipboard_x11" name = "clipboard_x11"
version = "0.3.1" version = "0.3.1"
@ -931,8 +912,8 @@ dependencies = [
"lazy_static", "lazy_static",
"libc", "libc",
"mach 0.3.2", "mach 0.3.2",
"ndk 0.3.0", "ndk",
"ndk-glue 0.3.0", "ndk-glue",
"nix 0.20.0", "nix 0.20.0",
"oboe", "oboe",
"parking_lot 0.11.1", "parking_lot 0.11.1",
@ -1054,6 +1035,20 @@ dependencies = [
"itertools 0.9.0", "itertools 0.9.0",
] ]
[[package]]
name = "crossbeam"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ae5588f6b3c3cb05239e90bd110f257254aecd01e4635400391aeae07497845"
dependencies = [
"cfg-if 1.0.0",
"crossbeam-channel",
"crossbeam-deque 0.8.0",
"crossbeam-epoch 0.9.5",
"crossbeam-queue",
"crossbeam-utils 0.8.5",
]
[[package]] [[package]]
name = "crossbeam-channel" name = "crossbeam-channel"
version = "0.5.1" version = "0.5.1"
@ -2386,13 +2381,13 @@ dependencies = [
[[package]] [[package]]
name = "iced_core" name = "iced_core"
version = "0.3.0" version = "0.4.0"
source = "git+https://github.com/hecrj/iced?rev=8d882d787e6b7fd7c2435f42f82933e2ed904edf#8d882d787e6b7fd7c2435f42f82933e2ed904edf" source = "git+https://github.com/Imberflur/iced?tag=winit-0.25#18a48a5eeefd2aa6e50f5dd0751ac2e94c88a9eb"
[[package]] [[package]]
name = "iced_futures" name = "iced_futures"
version = "0.2.0" version = "0.3.0"
source = "git+https://github.com/hecrj/iced?rev=8d882d787e6b7fd7c2435f42f82933e2ed904edf#8d882d787e6b7fd7c2435f42f82933e2ed904edf" source = "git+https://github.com/Imberflur/iced?tag=winit-0.25#18a48a5eeefd2aa6e50f5dd0751ac2e94c88a9eb"
dependencies = [ dependencies = [
"futures", "futures",
"log", "log",
@ -2401,8 +2396,8 @@ dependencies = [
[[package]] [[package]]
name = "iced_graphics" name = "iced_graphics"
version = "0.1.0" version = "0.2.0"
source = "git+https://github.com/hecrj/iced?rev=8d882d787e6b7fd7c2435f42f82933e2ed904edf#8d882d787e6b7fd7c2435f42f82933e2ed904edf" source = "git+https://github.com/Imberflur/iced?tag=winit-0.25#18a48a5eeefd2aa6e50f5dd0751ac2e94c88a9eb"
dependencies = [ dependencies = [
"bytemuck", "bytemuck",
"glam", "glam",
@ -2414,8 +2409,8 @@ dependencies = [
[[package]] [[package]]
name = "iced_native" name = "iced_native"
version = "0.3.0" version = "0.4.0"
source = "git+https://github.com/hecrj/iced?rev=8d882d787e6b7fd7c2435f42f82933e2ed904edf#8d882d787e6b7fd7c2435f42f82933e2ed904edf" source = "git+https://github.com/Imberflur/iced?tag=winit-0.25#18a48a5eeefd2aa6e50f5dd0751ac2e94c88a9eb"
dependencies = [ dependencies = [
"iced_core", "iced_core",
"iced_futures", "iced_futures",
@ -2426,16 +2421,16 @@ dependencies = [
[[package]] [[package]]
name = "iced_style" name = "iced_style"
version = "0.2.0" version = "0.3.0"
source = "git+https://github.com/hecrj/iced?rev=8d882d787e6b7fd7c2435f42f82933e2ed904edf#8d882d787e6b7fd7c2435f42f82933e2ed904edf" source = "git+https://github.com/Imberflur/iced?tag=winit-0.25#18a48a5eeefd2aa6e50f5dd0751ac2e94c88a9eb"
dependencies = [ dependencies = [
"iced_core", "iced_core",
] ]
[[package]] [[package]]
name = "iced_winit" name = "iced_winit"
version = "0.2.0" version = "0.3.0"
source = "git+https://github.com/hecrj/iced?rev=8d882d787e6b7fd7c2435f42f82933e2ed904edf#8d882d787e6b7fd7c2435f42f82933e2ed904edf" source = "git+https://github.com/Imberflur/iced?tag=winit-0.25#18a48a5eeefd2aa6e50f5dd0751ac2e94c88a9eb"
dependencies = [ dependencies = [
"iced_futures", "iced_futures",
"iced_graphics", "iced_graphics",
@ -2443,7 +2438,7 @@ dependencies = [
"log", "log",
"thiserror", "thiserror",
"winapi 0.3.9", "winapi 0.3.9",
"window_clipboard 0.1.4", "window_clipboard",
"winit", "winit",
] ]
@ -2637,7 +2632,7 @@ dependencies = [
[[package]] [[package]]
name = "keyboard-keynames" name = "keyboard-keynames"
version = "0.1.0" version = "0.1.0"
source = "git+https://gitlab.com/Frinksy/keyboard-keynames.git?rev=a97ae509cdb9dc70cf1bf0af762d2d1d3a0d6e0c#a97ae509cdb9dc70cf1bf0af762d2d1d3a0d6e0c" source = "git+https://gitlab.com/Frinksy/keyboard-keynames.git?rev=9ae8f89014d0b0c5b61d0e821c5aeb6140c5c0dc#9ae8f89014d0b0c5b61d0e821c5aeb6140c5c0dc"
dependencies = [ dependencies = [
"libc", "libc",
"memmap", "memmap",
@ -3028,6 +3023,18 @@ dependencies = [
"slab", "slab",
] ]
[[package]]
name = "mio-misc"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ddf05411bb159cdb5801bb10002afb66cb4572be656044315e363460ce69dc2"
dependencies = [
"crossbeam",
"crossbeam-queue",
"log",
"mio 0.7.11",
]
[[package]] [[package]]
name = "miow" name = "miow"
version = "0.2.2" version = "0.2.2"
@ -3097,18 +3104,6 @@ dependencies = [
"winapi 0.3.9", "winapi 0.3.9",
] ]
[[package]]
name = "ndk"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5eb167c1febed0a496639034d0c76b3b74263636045db5489eee52143c246e73"
dependencies = [
"jni-sys",
"ndk-sys",
"num_enum 0.4.3",
"thiserror",
]
[[package]] [[package]]
name = "ndk" name = "ndk"
version = "0.3.0" version = "0.3.0"
@ -3117,24 +3112,10 @@ checksum = "8794322172319b972f528bf90c6b467be0079f1fa82780ffb431088e741a73ab"
dependencies = [ dependencies = [
"jni-sys", "jni-sys",
"ndk-sys", "ndk-sys",
"num_enum 0.5.1", "num_enum",
"thiserror", "thiserror",
] ]
[[package]]
name = "ndk-glue"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bdf399b8b7a39c6fb153c4ec32c72fd5fe789df24a647f229c239aa7adb15241"
dependencies = [
"lazy_static",
"libc",
"log",
"ndk 0.2.1",
"ndk-macro",
"ndk-sys",
]
[[package]] [[package]]
name = "ndk-glue" name = "ndk-glue"
version = "0.3.0" version = "0.3.0"
@ -3144,7 +3125,7 @@ dependencies = [
"lazy_static", "lazy_static",
"libc", "libc",
"log", "log",
"ndk 0.3.0", "ndk",
"ndk-macro", "ndk-macro",
"ndk-sys", "ndk-sys",
] ]
@ -3465,16 +3446,6 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "num_enum"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca565a7df06f3d4b485494f25ba05da1435950f4dc263440eda7a6fa9b8e36e4"
dependencies = [
"derivative",
"num_enum_derive 0.4.3",
]
[[package]] [[package]]
name = "num_enum" name = "num_enum"
version = "0.5.1" version = "0.5.1"
@ -3482,19 +3453,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "226b45a5c2ac4dd696ed30fa6b94b057ad909c7b7fc2e0d0808192bced894066" checksum = "226b45a5c2ac4dd696ed30fa6b94b057ad909c7b7fc2e0d0808192bced894066"
dependencies = [ dependencies = [
"derivative", "derivative",
"num_enum_derive 0.5.1", "num_enum_derive",
]
[[package]]
name = "num_enum_derive"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffa5a33ddddfee04c0283a7653987d634e880347e96b5b2ed64de07efb59db9d"
dependencies = [
"proc-macro-crate",
"proc-macro2 1.0.27",
"quote 1.0.9",
"syn 1.0.72",
] ]
[[package]] [[package]]
@ -3574,8 +3533,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dfa187b38ae20374617b7ad418034ed3dc90ac980181d211518bd03537ae8f8d" checksum = "dfa187b38ae20374617b7ad418034ed3dc90ac980181d211518bd03537ae8f8d"
dependencies = [ dependencies = [
"jni", "jni",
"ndk 0.3.0", "ndk",
"ndk-glue 0.3.0", "ndk-glue",
"num-derive", "num-derive",
"num-traits", "num-traits",
"oboe-sys", "oboe-sys",
@ -6147,7 +6106,7 @@ dependencies = [
"veloren-world", "veloren-world",
"wgpu", "wgpu",
"wgpu-profiler", "wgpu-profiler",
"window_clipboard 0.2.1", "window_clipboard",
"winit", "winit",
"winres", "winres",
] ]
@ -6850,19 +6809,6 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "window_clipboard"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37cf16659e398a96f4ab8deff2b9db2ca0c3c5d6c1b59b1d577b7f888f0f03c6"
dependencies = [
"clipboard-win 4.2.1",
"clipboard_macos",
"clipboard_wayland 0.1.2",
"clipboard_x11 0.2.0",
"raw-window-handle",
]
[[package]] [[package]]
name = "window_clipboard" name = "window_clipboard"
version = "0.2.1" version = "0.2.1"
@ -6871,15 +6817,16 @@ checksum = "33a4518b538a45ad39d138a8c3bea8f6b4452174aeb38143d1dd643a3a838ccc"
dependencies = [ dependencies = [
"clipboard-win 4.2.1", "clipboard-win 4.2.1",
"clipboard_macos", "clipboard_macos",
"clipboard_wayland 0.2.0", "clipboard_wayland",
"clipboard_x11 0.3.1", "clipboard_x11",
"raw-window-handle", "raw-window-handle",
] ]
[[package]] [[package]]
name = "winit" name = "winit"
version = "0.24.0" version = "0.25.0"
source = "git+https://gitlab.com/veloren/winit.git?branch=macos-test-spiffed#488c511802dfd95ca54f6f76a38547c93c7b02c9" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79610794594d5e86be473ef7763f604f2159cbac8c94debd00df8fb41e86c2f8"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"cocoa", "cocoa",
@ -6891,15 +6838,16 @@ dependencies = [
"lazy_static", "lazy_static",
"libc", "libc",
"log", "log",
"mio 0.6.23", "mio 0.7.11",
"mio-extras", "mio-misc",
"ndk 0.2.1", "ndk",
"ndk-glue 0.2.1", "ndk-glue",
"ndk-sys", "ndk-sys",
"objc", "objc",
"parking_lot 0.11.1", "parking_lot 0.11.1",
"percent-encoding", "percent-encoding",
"raw-window-handle", "raw-window-handle",
"scopeguard",
"serde", "serde",
"smithay-client-toolkit", "smithay-client-toolkit",
"wayland-client 0.28.5", "wayland-client 0.28.5",

View File

@ -111,8 +111,6 @@ buildInputs = ["openssl"]
nativeBuildInputs = ["pkg-config"] nativeBuildInputs = ["pkg-config"]
[patch.crates-io] [patch.crates-io]
# macos CI fix isn't released yet
winit = { git = "https://gitlab.com/veloren/winit.git", branch = "macos-test-spiffed" }
vek = { git = "https://gitlab.com/veloren/vek.git", branch = "fix_intrinsics2" } vek = { git = "https://gitlab.com/veloren/vek.git", branch = "fix_intrinsics2" }
# patch wgpu so we can use wgpu-profiler crate # patch wgpu so we can use wgpu-profiler crate
wgpu = { git = "https://github.com/gfx-rs/wgpu.git", rev = "a92b8549a8e2cb9dac781bafc5ed32828f3caf46" } wgpu = { git = "https://github.com/gfx-rs/wgpu.git", rev = "a92b8549a8e2cb9dac781bafc5ed32828f3caf46" }

View File

@ -44,7 +44,7 @@ anim = {package = "veloren-voxygen-anim", path = "anim"}
i18n = {package = "veloren-i18n", path = "i18n"} i18n = {package = "veloren-i18n", path = "i18n"}
# Graphics # Graphics
winit = {version = "0.24.0", features = ["serde"]} winit = {version = "0.25.0", features = ["serde"]}
wgpu = { version = "=0.8.0", features = ["trace", "cross"] } wgpu = { version = "=0.8.0", features = ["trace", "cross"] }
wgpu-profiler = { git = "https://github.com/Imberflur/wgpu-profiler", tag = "wgpu-0.8" } wgpu-profiler = { git = "https://github.com/Imberflur/wgpu-profiler", tag = "wgpu-0.8" }
bytemuck = { version="1.4", features=["derive"] } bytemuck = { version="1.4", features=["derive"] }
@ -54,11 +54,11 @@ shaderc = "0.6.2"
conrod_core = {git = "https://gitlab.com/veloren/conrod.git", branch="copypasta_0.7"} conrod_core = {git = "https://gitlab.com/veloren/conrod.git", branch="copypasta_0.7"}
conrod_winit = {git = "https://gitlab.com/veloren/conrod.git", branch="copypasta_0.7"} conrod_winit = {git = "https://gitlab.com/veloren/conrod.git", branch="copypasta_0.7"}
euc = "0.5.0" euc = "0.5.0"
iced = {package = "iced_native", git = "https://github.com/hecrj/iced", rev = "8d882d787e6b7fd7c2435f42f82933e2ed904edf"} iced = {package = "iced_native", git = "https://github.com/Imberflur/iced", tag = "winit-0.25"}
iced_winit = {git = "https://github.com/hecrj/iced", rev = "8d882d787e6b7fd7c2435f42f82933e2ed904edf"} iced_winit = {git = "https://github.com/Imberflur/iced", tag = "winit-0.25"}
window_clipboard = "0.2" window_clipboard = "0.2"
glyph_brush = "0.7.0" glyph_brush = "0.7.0"
keyboard-keynames = { git = "https://gitlab.com/Frinksy/keyboard-keynames.git", rev = "a97ae509cdb9dc70cf1bf0af762d2d1d3a0d6e0c" } keyboard-keynames = { git = "https://gitlab.com/Frinksy/keyboard-keynames.git", rev = "9ae8f89014d0b0c5b61d0e821c5aeb6140c5c0dc" }
# ECS # ECS
specs = {git = "https://github.com/amethyst/specs.git", rev = "f985bec5d456f7b0dd8aae99848f9473c2cd9d46"} specs = {git = "https://github.com/amethyst/specs.git", rev = "f985bec5d456f7b0dd8aae99848f9473c2cd9d46"}

View File

@ -62,7 +62,7 @@ pub struct GlobalState {
pub singleplayer: Option<Singleplayer>, pub singleplayer: Option<Singleplayer>,
// TODO: redo this so that the watcher doesn't have to exist for reloading to occur // TODO: redo this so that the watcher doesn't have to exist for reloading to occur
pub i18n: LocalizationHandle, pub i18n: LocalizationHandle,
pub clipboard: Option<iced_winit::Clipboard>, pub clipboard: iced_winit::Clipboard,
// NOTE: This can be removed from GlobalState if client state behavior is refactored to not // NOTE: This can be removed from GlobalState if client state behavior is refactored to not
// enter the game before confirmation of successful character load // enter the game before confirmation of successful character load
/// An error returned by Client that needs to be displayed by the UI /// An error returned by Client that needs to be displayed by the UI

View File

@ -181,7 +181,7 @@ fn main() {
// Create window // Create window
let (mut window, event_loop) = Window::new(&settings).expect("Failed to create window!"); let (mut window, event_loop) = Window::new(&settings).expect("Failed to create window!");
let clipboard = iced_winit::Clipboard::new(window.window()); let clipboard = iced_winit::Clipboard::connect(window.window());
let lazy_init = SpriteRenderContext::new(window.renderer_mut()); let lazy_init = SpriteRenderContext::new(window.renderer_mut());

View File

@ -1564,7 +1564,7 @@ impl CharSelectionUi {
.view(&global_state.settings, &client, &self.error, &i18n), .view(&global_state.settings, &client, &self.error, &i18n),
global_state.window.renderer_mut(), global_state.window.renderer_mut(),
None, None,
global_state.clipboard.as_ref(), &mut global_state.clipboard,
); );
if self.enter_pressed { if self.enter_pressed {

View File

@ -569,7 +569,7 @@ impl MainMenuUi {
self.controls.view(&global_state.settings, dt.as_secs_f32()), self.controls.view(&global_state.settings, dt.as_secs_f32()),
global_state.window.renderer_mut(), global_state.window.renderer_mut(),
None, None,
global_state.clipboard.as_ref(), &mut global_state.clipboard,
); );
messages.into_iter().for_each(|message| { messages.into_iter().for_each(|message| {

View File

@ -148,7 +148,7 @@ impl IcedUi {
root: E, root: E,
renderer: &mut Renderer, renderer: &mut Renderer,
pool: Option<&SlowJobPool>, pool: Option<&SlowJobPool>,
clipboard: Option<&Clipboard>, clipboard: &mut Clipboard,
) -> (Vec<M>, mouse::Interaction) { ) -> (Vec<M>, mouse::Interaction) {
span!(_guard, "maintain", "IcedUi::maintain"); span!(_guard, "maintain", "IcedUi::maintain");
// Handle window resizing, dpi factor change, and scale mode changing // Handle window resizing, dpi factor change, and scale mode changing
@ -194,11 +194,8 @@ impl IcedUi {
let _event_status_list = user_interface.update( let _event_status_list = user_interface.update(
&self.events, &self.events,
cursor_position, cursor_position,
match clipboard {
Some(c) => Some(c),
None => None,
},
&self.renderer, &self.renderer,
clipboard,
&mut messages, &mut messages,
); );
messages messages

View File

@ -5,7 +5,7 @@ impl button::Renderer for IcedRenderer {
// TODO: what if this gets large enough to not be copied around? // TODO: what if this gets large enough to not be copied around?
type Style = style::button::Style; type Style = style::button::Style;
const DEFAULT_PADDING: u16 = 0; const DEFAULT_PADDING: iced::Padding = iced::Padding::ZERO;
fn draw<M>( fn draw<M>(
&mut self, &mut self,

View File

@ -119,17 +119,17 @@ where
event: Event, event: Event,
layout: Layout<'_>, layout: Layout<'_>,
cursor_position: Point, cursor_position: Point,
messages: &mut Vec<M>,
renderer: &R, renderer: &R,
clipboard: Option<&dyn Clipboard>, clipboard: &mut dyn Clipboard,
messages: &mut Vec<M>,
) -> iced::event::Status { ) -> iced::event::Status {
self.content.on_event( self.content.on_event(
event, event,
layout.children().next().unwrap(), layout.children().next().unwrap(),
cursor_position, cursor_position,
messages,
renderer, renderer,
clipboard, clipboard,
messages,
) )
} }

View File

@ -255,17 +255,17 @@ where
event: Event, event: Event,
layout: Layout<'_>, layout: Layout<'_>,
cursor_position: Point, cursor_position: Point,
messages: &mut Vec<M>,
renderer: &R, renderer: &R,
clipboard: Option<&dyn Clipboard>, clipboard: &mut dyn Clipboard,
messages: &mut Vec<M>,
) -> iced::event::Status { ) -> iced::event::Status {
self.content.on_event( self.content.on_event(
event, event,
layout.children().next().unwrap(), layout.children().next().unwrap(),
cursor_position, cursor_position,
messages,
renderer, renderer,
clipboard, clipboard,
messages,
) )
} }

View File

@ -48,9 +48,9 @@ where
event: Event, event: Event,
layout: Layout<'_>, layout: Layout<'_>,
_cursor_position: Point, _cursor_position: Point,
_messages: &mut Vec<M>,
_renderer: &R, _renderer: &R,
_clipboard: Option<&dyn Clipboard>, _clipboard: &mut dyn Clipboard,
_messages: &mut Vec<M>,
) -> iced::event::Status { ) -> iced::event::Status {
if let Event::Mouse(mouse::Event::CursorMoved { if let Event::Mouse(mouse::Event::CursorMoved {
position: Point { x, y }, position: Point { x, y },

View File

@ -1,6 +1,6 @@
use iced::{ use iced::{
layout, mouse, Align, Clipboard, Element, Event, Hasher, Layout, Length, Point, Rectangle, layout, mouse, Align, Clipboard, Element, Event, Hasher, Layout, Length, Padding, Point,
Size, Widget, Rectangle, Size, Widget,
}; };
use std::hash::Hash; use std::hash::Hash;
@ -10,7 +10,7 @@ use std::hash::Hash;
/// the front widget /// the front widget
/// Alignment and padding is used for the front widget /// Alignment and padding is used for the front widget
pub struct Overlay<'a, M, R: self::Renderer> { pub struct Overlay<'a, M, R: self::Renderer> {
padding: u16, padding: Padding,
width: Length, width: Length,
height: Length, height: Length,
max_width: u32, max_width: u32,
@ -32,7 +32,7 @@ where
U: Into<Element<'a, M, R>>, U: Into<Element<'a, M, R>>,
{ {
Self { Self {
padding: 0, padding: Padding::ZERO,
width: Length::Shrink, width: Length::Shrink,
height: Length::Shrink, height: Length::Shrink,
max_width: u32::MAX, max_width: u32::MAX,
@ -44,8 +44,8 @@ where
} }
} }
pub fn padding(mut self, pad: u16) -> Self { pub fn padding<P: Into<Padding>>(mut self, pad: P) -> Self {
self.padding = pad; self.padding = pad.into();
self self
} }
@ -99,8 +99,6 @@ where
fn height(&self) -> Length { self.height } fn height(&self) -> Length { self.height }
fn layout(&self, renderer: &R, limits: &layout::Limits) -> layout::Node { fn layout(&self, renderer: &R, limits: &layout::Limits) -> layout::Node {
let padding = self.padding as f32;
let limits = limits let limits = limits
.loose() .loose()
.max_width(self.max_width) .max_width(self.max_width)
@ -111,16 +109,22 @@ where
let under = self.under.layout(renderer, &limits.loose()); let under = self.under.layout(renderer, &limits.loose());
let under_size = under.size(); let under_size = under.size();
let limits = limits.pad(padding); let limits = limits.pad(self.padding);
let mut over = self.over.layout(renderer, &limits.loose()); let mut over = self.over.layout(renderer, &limits.loose());
let over_size = over.size(); let over_size = over.size();
let size = limits.resolve(Size { let size = limits.resolve(
width: under_size.width.max(over_size.width + padding * 2.0), Size {
height: under_size.height.max(over_size.height + padding * 2.0), width: under_size.width.max(over_size.width),
}); height: under_size.height.max(over_size.height),
}
.pad(self.padding),
);
over.move_to(Point::new(padding, padding)); over.move_to(Point::new(
self.padding.left.into(),
self.padding.top.into(),
));
over.align(self.horizontal_alignment, self.vertical_alignment, size); over.align(self.horizontal_alignment, self.vertical_alignment, size);
layout::Node::with_children(size, vec![over, under]) layout::Node::with_children(size, vec![over, under])
@ -131,9 +135,9 @@ where
event: Event, event: Event,
layout: Layout<'_>, layout: Layout<'_>,
cursor_position: Point, cursor_position: Point,
messages: &mut Vec<M>,
renderer: &R, renderer: &R,
clipboard: Option<&dyn Clipboard>, clipboard: &mut dyn Clipboard,
messages: &mut Vec<M>,
) -> iced::event::Status { ) -> iced::event::Status {
let mut children = layout.children(); let mut children = layout.children();
let over_layout = children.next().unwrap(); let over_layout = children.next().unwrap();
@ -143,9 +147,9 @@ where
event.clone(), event.clone(),
over_layout, over_layout,
cursor_position, cursor_position,
messages,
renderer, renderer,
clipboard, clipboard,
messages,
); );
// If mouse press check if over the overlay widget before sending to under // If mouse press check if over the overlay widget before sending to under
@ -158,9 +162,9 @@ where
event, event,
children.next().unwrap(), children.next().unwrap(),
cursor_position, cursor_position,
messages,
renderer, renderer,
clipboard, clipboard,
messages,
) )
.merge(status) .merge(status)
} else { } else {

View File

@ -189,17 +189,17 @@ where
event: Event, event: Event,
layout: Layout<'_>, layout: Layout<'_>,
cursor_position: Point, cursor_position: Point,
messages: &mut Vec<M>,
renderer: &R, renderer: &R,
clipboard: Option<&dyn Clipboard>, clipboard: &mut dyn Clipboard,
messages: &mut Vec<M>,
) -> iced::event::Status { ) -> iced::event::Status {
self.content.on_event( self.content.on_event(
event, event,
layout, layout,
cursor_position, cursor_position,
messages,
renderer, renderer,
clipboard, clipboard,
messages,
) )
} }