From c2472632582bc428b4c6cfac308be25221be56bd Mon Sep 17 00:00:00 2001 From: Imbris Date: Mon, 14 Sep 2020 00:58:43 -0400 Subject: [PATCH] Update to the latest git iced --- Cargo.lock | 19 ++++++++------- voxygen/Cargo.toml | 4 ++-- voxygen/src/ui/ice/mod.rs | 4 +++- voxygen/src/ui/ice/renderer/mod.rs | 23 +++++++++++++++++++ voxygen/src/ui/ice/renderer/widget/slider.rs | 13 ++++++----- .../src/ui/ice/renderer/widget/text_input.rs | 6 ----- 6 files changed, 46 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9dd0bbee7d..2316f712f2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1847,9 +1847,9 @@ dependencies = [ [[package]] name = "glam" -version = "0.8.7" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00572b5b10070ac495be20a25b4c8d379d20bcdec8ea0c870022b620ec79b20" +checksum = "8637c7ec4fd0776c51eeab3e0d5d1aa7e440ece3fc2ee7d674e13c957287bfc1" [[package]] name = "glob" @@ -2158,12 +2158,12 @@ dependencies = [ [[package]] name = "iced_core" version = "0.2.1" -source = "git+https://github.com/hecrj/iced?rev=b5d842f#b5d842f877145c78f5d595a87cc1927bb6f5b86a" +source = "git+https://github.com/hecrj/iced?rev=4f2962d#4f2962d73f3bdeeca8a11817e404c45e91e2c2cc" [[package]] name = "iced_futures" version = "0.1.2" -source = "git+https://github.com/hecrj/iced?rev=b5d842f#b5d842f877145c78f5d595a87cc1927bb6f5b86a" +source = "git+https://github.com/hecrj/iced?rev=4f2962d#4f2962d73f3bdeeca8a11817e404c45e91e2c2cc" dependencies = [ "futures 0.3.5", "log", @@ -2173,19 +2173,20 @@ dependencies = [ [[package]] name = "iced_graphics" version = "0.1.0" -source = "git+https://github.com/hecrj/iced?rev=b5d842f#b5d842f877145c78f5d595a87cc1927bb6f5b86a" +source = "git+https://github.com/hecrj/iced?rev=4f2962d#4f2962d73f3bdeeca8a11817e404c45e91e2c2cc" dependencies = [ "bytemuck", "glam", "iced_native", "iced_style", "raw-window-handle", + "thiserror", ] [[package]] name = "iced_native" version = "0.2.2" -source = "git+https://github.com/hecrj/iced?rev=b5d842f#b5d842f877145c78f5d595a87cc1927bb6f5b86a" +source = "git+https://github.com/hecrj/iced?rev=4f2962d#4f2962d73f3bdeeca8a11817e404c45e91e2c2cc" dependencies = [ "iced_core", "iced_futures", @@ -2197,7 +2198,7 @@ dependencies = [ [[package]] name = "iced_style" version = "0.1.0" -source = "git+https://github.com/hecrj/iced?rev=b5d842f#b5d842f877145c78f5d595a87cc1927bb6f5b86a" +source = "git+https://github.com/hecrj/iced?rev=4f2962d#4f2962d73f3bdeeca8a11817e404c45e91e2c2cc" dependencies = [ "iced_core", ] @@ -2205,11 +2206,13 @@ dependencies = [ [[package]] name = "iced_winit" version = "0.1.1" -source = "git+https://github.com/hecrj/iced?rev=b5d842f#b5d842f877145c78f5d595a87cc1927bb6f5b86a" +source = "git+https://github.com/hecrj/iced?rev=4f2962d#4f2962d73f3bdeeca8a11817e404c45e91e2c2cc" dependencies = [ + "iced_futures", "iced_graphics", "iced_native", "log", + "thiserror", "winapi 0.3.9", "window_clipboard", "winit", diff --git a/voxygen/Cargo.toml b/voxygen/Cargo.toml index 21fd6d0e76..3a0bf5d634 100644 --- a/voxygen/Cargo.toml +++ b/voxygen/Cargo.toml @@ -35,8 +35,8 @@ winit = {version = "0.22.2", features = ["serde"]} 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"} euc = {git = "https://github.com/zesterer/euc.git"} -iced = {package = "iced_native", git = "https://github.com/hecrj/iced", rev = "b5d842f"} -iced_winit = {git = "https://github.com/hecrj/iced", rev = "b5d842f"} +iced = {package = "iced_native", git = "https://github.com/hecrj/iced", rev = "4f2962d"} +iced_winit = {git = "https://github.com/hecrj/iced", rev = "4f2962d"} window_clipboard = "0.1.1" glyph_brush = "0.7.0" diff --git a/voxygen/src/ui/ice/mod.rs b/voxygen/src/ui/ice/mod.rs index b5464d432d..6538cef61a 100644 --- a/voxygen/src/ui/ice/mod.rs +++ b/voxygen/src/ui/ice/mod.rs @@ -152,11 +152,13 @@ impl IcedUi { ); let messages = user_interface.update( - self.events.drain(..), + &self.events, cursor_position, Some(&self.clipboard), &mut self.renderer, ); + // Clear events + self.events.clear(); let (primitive, mouse_interaction) = user_interface.draw(&mut self.renderer, cursor_position); diff --git a/voxygen/src/ui/ice/renderer/mod.rs b/voxygen/src/ui/ice/renderer/mod.rs index 092a5e5c5d..b1f200aa45 100644 --- a/voxygen/src/ui/ice/renderer/mod.rs +++ b/voxygen/src/ui/ice/renderer/mod.rs @@ -781,6 +781,29 @@ impl iced::Renderer for IcedRenderer { node } + + fn overlay( + &mut self, + (base_primitive, base_interaction): Self::Output, + (overlay_primitive, overlay_interaction): Self::Output, + overlay_bounds: iced::Rectangle, + ) -> Self::Output { + ( + Primitive::Group { + primitives: vec![base_primitive, Primitive::Clip { + bounds: iced::Rectangle { + // TODO: do we need this + 0.5? + width: overlay_bounds.width + 0.5, + height: overlay_bounds.height + 0.5, + ..overlay_bounds + }, + offset: Vec2::new(0, 0), + content: Box::new(overlay_primitive), + }], + }, + base_interaction.max(overlay_interaction), + ) + } } // TODO: impl Debugger diff --git a/voxygen/src/ui/ice/renderer/widget/slider.rs b/voxygen/src/ui/ice/renderer/widget/slider.rs index 056c60b423..e58c6acc80 100644 --- a/voxygen/src/ui/ice/renderer/widget/slider.rs +++ b/voxygen/src/ui/ice/renderer/widget/slider.rs @@ -1,7 +1,7 @@ use super::super::{super::Rotation, style, IcedRenderer, Primitive}; use common::util::srgba_to_linear; -use iced::{slider, mouse, Rectangle, Point}; use core::ops::RangeInclusive; +use iced::{mouse, slider, Point, Rectangle}; use style::slider::{Bar, Cursor, Style}; const CURSOR_WIDTH: f32 = 10.0; @@ -10,7 +10,9 @@ const BAR_HEIGHT: f32 = 18.0; impl slider::Renderer for IcedRenderer { type Style = Style; - fn height(&self) -> u32 { 20 } + + const DEFAULT_HEIGHT: u16 = 20; + fn draw( &mut self, bounds: Rectangle, @@ -18,9 +20,8 @@ impl slider::Renderer for IcedRenderer { range: RangeInclusive, value: f32, is_dragging: bool, - style: &Self::Style + style: &Self::Style, ) -> Self::Output { - let bar_bounds = Rectangle { height: BAR_HEIGHT, ..bounds @@ -38,7 +39,7 @@ impl slider::Renderer for IcedRenderer { }; let (max, min) = range.into_inner(); - let offset = bounds.width as f32 * (max - min ) / (value - min); + let offset = bounds.width as f32 * (max - min) / (value - min); let cursor_bounds = Rectangle { x: bounds.x + offset - CURSOR_WIDTH / 2.0, y: bounds.y + if is_dragging { 2.0 } else { 0.0 }, @@ -74,6 +75,6 @@ impl slider::Renderer for IcedRenderer { // TODO Cursor text label vec![bar, cursor] }; - (Primitive::Group{primitives}, interaction) + (Primitive::Group { primitives }, interaction) } } diff --git a/voxygen/src/ui/ice/renderer/widget/text_input.rs b/voxygen/src/ui/ice/renderer/widget/text_input.rs index ce62bf7277..ec833214b3 100644 --- a/voxygen/src/ui/ice/renderer/widget/text_input.rs +++ b/voxygen/src/ui/ice/renderer/widget/text_input.rs @@ -11,14 +11,8 @@ const CURSOR_WIDTH: f32 = 2.0; const EXTRA_OFFSET: f32 = 10.0; impl text_input::Renderer for IcedRenderer { - type Font = FontId; type Style = (); - fn default_size(&self) -> u16 { - // TODO: make configurable - 20 - } - fn measure_value(&self, value: &str, size: u16, font: Self::Font) -> f32 { // Using the physical scale might make this cached info usable below? // Although we also have a position of the screen there so this could be useless