Update to the latest git iced

This commit is contained in:
Imbris 2020-09-14 00:58:43 -04:00
parent 42c6550a0b
commit c247263258
6 changed files with 46 additions and 23 deletions

19
Cargo.lock generated
View File

@ -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",

View File

@ -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"

View File

@ -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);

View File

@ -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

View File

@ -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<f32>,
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)
}
}

View File

@ -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