Update iced

This commit is contained in:
Imbris 2020-10-31 04:52:38 -04:00
parent 90bfafc469
commit 469b048de9
22 changed files with 139 additions and 99 deletions

87
Cargo.lock generated
View File

@ -612,21 +612,6 @@ dependencies = [
"bitflags",
]
[[package]]
name = "cocoa"
version = "0.20.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c49e86fc36d5704151f5996b7b3795385f50ce09e3be0f47a0cfde869681cf8"
dependencies = [
"bitflags",
"block",
"core-foundation 0.7.0",
"core-graphics 0.19.2",
"foreign-types",
"libc",
"objc",
]
[[package]]
name = "cocoa"
version = "0.23.0"
@ -1869,14 +1854,14 @@ dependencies = [
[[package]]
name = "glutin"
version = "0.24.1"
source = "git+https://github.com/rust-windowing/glutin.git?rev=63a1ea7d6e64c5112418cab9f21cd409f0afd7c2#63a1ea7d6e64c5112418cab9f21cd409f0afd7c2"
version = "0.25.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8bae26a39a728b003e9fad473ea89527de0de050143b4df866f18bb154bc86e"
dependencies = [
"android_glue",
"cgl",
"cocoa 0.20.2",
"core-foundation 0.7.0",
"core-graphics 0.19.2",
"cocoa",
"core-foundation 0.9.1",
"glutin_egl_sys",
"glutin_emscripten_sys",
"glutin_gles2_sys",
@ -1887,8 +1872,8 @@ dependencies = [
"log",
"objc",
"osmesa-sys",
"parking_lot 0.10.2",
"wayland-client 0.27.0",
"parking_lot 0.11.0",
"wayland-client 0.28.1",
"wayland-egl",
"winapi 0.3.9",
"winit",
@ -1897,7 +1882,8 @@ dependencies = [
[[package]]
name = "glutin_egl_sys"
version = "0.1.5"
source = "git+https://github.com/rust-windowing/glutin.git?rev=63a1ea7d6e64c5112418cab9f21cd409f0afd7c2#63a1ea7d6e64c5112418cab9f21cd409f0afd7c2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2abb6aa55523480c4adc5a56bbaa249992e2dddb2fc63dc96e04a3355364c211"
dependencies = [
"gl_generator",
"winapi 0.3.9",
@ -1906,12 +1892,14 @@ dependencies = [
[[package]]
name = "glutin_emscripten_sys"
version = "0.1.1"
source = "git+https://github.com/rust-windowing/glutin.git?rev=63a1ea7d6e64c5112418cab9f21cd409f0afd7c2#63a1ea7d6e64c5112418cab9f21cd409f0afd7c2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80de4146df76e8a6c32b03007bc764ff3249dcaeb4f675d68a06caf1bac363f1"
[[package]]
name = "glutin_gles2_sys"
version = "0.1.5"
source = "git+https://github.com/rust-windowing/glutin.git?rev=63a1ea7d6e64c5112418cab9f21cd409f0afd7c2#63a1ea7d6e64c5112418cab9f21cd409f0afd7c2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8094e708b730a7c8a1954f4f8a31880af00eb8a1c5b5bf85d28a0a3c6d69103"
dependencies = [
"gl_generator",
"objc",
@ -1920,7 +1908,8 @@ dependencies = [
[[package]]
name = "glutin_glx_sys"
version = "0.1.7"
source = "git+https://github.com/rust-windowing/glutin.git?rev=63a1ea7d6e64c5112418cab9f21cd409f0afd7c2#63a1ea7d6e64c5112418cab9f21cd409f0afd7c2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e393c8fc02b807459410429150e9c4faffdb312d59b8c038566173c81991351"
dependencies = [
"gl_generator",
"x11-dl",
@ -1929,7 +1918,8 @@ dependencies = [
[[package]]
name = "glutin_wgl_sys"
version = "0.1.5"
source = "git+https://github.com/rust-windowing/glutin.git?rev=63a1ea7d6e64c5112418cab9f21cd409f0afd7c2#63a1ea7d6e64c5112418cab9f21cd409f0afd7c2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3da5951a1569dbab865c6f2a863efafff193a93caf05538d193e9e3816d21696"
dependencies = [
"gl_generator",
]
@ -2158,12 +2148,12 @@ dependencies = [
[[package]]
name = "iced_core"
version = "0.2.1"
source = "git+https://github.com/hecrj/iced?rev=4f2962d#4f2962d73f3bdeeca8a11817e404c45e91e2c2cc"
source = "git+https://github.com/hecrj/iced?rev=f464316#f46431600cb61d4e83e0ded1ca79525478436be3"
[[package]]
name = "iced_futures"
version = "0.1.2"
source = "git+https://github.com/hecrj/iced?rev=4f2962d#4f2962d73f3bdeeca8a11817e404c45e91e2c2cc"
source = "git+https://github.com/hecrj/iced?rev=f464316#f46431600cb61d4e83e0ded1ca79525478436be3"
dependencies = [
"futures 0.3.5",
"log",
@ -2173,7 +2163,7 @@ dependencies = [
[[package]]
name = "iced_graphics"
version = "0.1.0"
source = "git+https://github.com/hecrj/iced?rev=4f2962d#4f2962d73f3bdeeca8a11817e404c45e91e2c2cc"
source = "git+https://github.com/hecrj/iced?rev=f464316#f46431600cb61d4e83e0ded1ca79525478436be3"
dependencies = [
"bytemuck",
"glam",
@ -2186,7 +2176,7 @@ dependencies = [
[[package]]
name = "iced_native"
version = "0.2.2"
source = "git+https://github.com/hecrj/iced?rev=4f2962d#4f2962d73f3bdeeca8a11817e404c45e91e2c2cc"
source = "git+https://github.com/hecrj/iced?rev=f464316#f46431600cb61d4e83e0ded1ca79525478436be3"
dependencies = [
"iced_core",
"iced_futures",
@ -2198,7 +2188,7 @@ dependencies = [
[[package]]
name = "iced_style"
version = "0.1.0"
source = "git+https://github.com/hecrj/iced?rev=4f2962d#4f2962d73f3bdeeca8a11817e404c45e91e2c2cc"
source = "git+https://github.com/hecrj/iced?rev=f464316#f46431600cb61d4e83e0ded1ca79525478436be3"
dependencies = [
"iced_core",
]
@ -2206,7 +2196,7 @@ dependencies = [
[[package]]
name = "iced_winit"
version = "0.1.1"
source = "git+https://github.com/hecrj/iced?rev=4f2962d#4f2962d73f3bdeeca8a11817e404c45e91e2c2cc"
source = "git+https://github.com/hecrj/iced?rev=f464316#f46431600cb61d4e83e0ded1ca79525478436be3"
dependencies = [
"iced_futures",
"iced_graphics",
@ -3146,9 +3136,9 @@ dependencies = [
[[package]]
name = "old_school_gfx_glutin_ext"
version = "0.24.0"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0557cea37cc48d238c938ded2873a6cc772704ee1eb01e832b43c2dd99624bc"
checksum = "97d3bf7a77b32b947b6eaa3bc3671d50a74cd9aafdbbd4f9a4feb03ed3a0ee94"
dependencies = [
"gfx_core",
"gfx_device_gl",
@ -4246,10 +4236,8 @@ version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "562da6f2f0836e144f2e92118b35add58368280556af94f399666ebfd7d1e731"
dependencies = [
"andrew",
"bitflags",
"byteorder",
"calloop",
"dlib",
"lazy_static",
"log",
@ -4266,8 +4254,10 @@ version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ec5c077def8af49f9b5aeeb5fcf8079c638c6615c3a8f9305e2dea601de57f7"
dependencies = [
"andrew",
"bitflags",
"byteorder",
"calloop",
"dlib",
"lazy_static",
"log",
@ -5560,12 +5550,12 @@ dependencies = [
[[package]]
name = "wayland-egl"
version = "0.27.0"
version = "0.28.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "123b47be6f258fffd854f016e8e7397adb8c04d984fcf308dce13714ae2231ae"
checksum = "e7ca6190c84bcdc58beccc619bf4866709db32d653255e89da38867f97f90d61"
dependencies = [
"wayland-client 0.27.0",
"wayland-sys 0.27.0",
"wayland-client 0.28.1",
"wayland-sys 0.28.1",
]
[[package]]
@ -5743,11 +5733,11 @@ dependencies = [
[[package]]
name = "winit"
version = "0.22.2"
source = "git+https://gitlab.com/veloren/winit.git?branch=macos-test-rebased#5efbaa7e4644c627201a9c4d24217f448795ce0f"
version = "0.23.0"
source = "git+https://gitlab.com/veloren/winit.git?branch=macos-test-spiffed#7c8c5f21384c898f50d37298d229093549b08803"
dependencies = [
"bitflags",
"cocoa 0.23.0",
"cocoa",
"core-foundation 0.9.1",
"core-graphics 0.22.1",
"core-video-sys",
@ -5766,8 +5756,8 @@ dependencies = [
"percent-encoding 2.1.0",
"raw-window-handle",
"serde",
"smithay-client-toolkit 0.11.0",
"wayland-client 0.27.0",
"smithay-client-toolkit 0.12.0",
"wayland-client 0.28.1",
"winapi 0.3.9",
"x11-dl",
]
@ -5848,3 +5838,8 @@ name = "xml-rs"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b07db065a5cf61a7e4ba64f29e67db906fb1787316516c4e6e5ff0fea1efcd8a"
[[patch.unused]]
name = "glutin"
version = "0.24.1"
source = "git+https://github.com/rust-windowing/glutin.git?rev=63a1ea7d6e64c5112418cab9f21cd409f0afd7c2#63a1ea7d6e64c5112418cab9f21cd409f0afd7c2"

View File

@ -79,6 +79,6 @@ debug = 1
[patch.crates-io]
# cpal conflict fix isn't released yet
winit = { git = "https://gitlab.com/veloren/winit.git", branch = "macos-test-rebased" }
winit = { git = "https://gitlab.com/veloren/winit.git", branch = "macos-test-spiffed" }
glutin = {git = "https://github.com/rust-windowing/glutin.git", rev="63a1ea7d6e64c5112418cab9f21cd409f0afd7c2"}
vek = { git = "https://gitlab.com/veloren/vek.git", branch = "fix_intrinsics" }

View File

@ -27,16 +27,16 @@ anim = {package = "veloren-voxygen-anim", path = "src/anim", default-features =
gfx = "0.18.2"
gfx_device_gl = {version = "0.16.2", optional = true}
gfx_gl = {version = "0.6.1", optional = true}
glutin = {git = "https://github.com/rust-windowing/glutin.git", rev="63a1ea7d6e64c5112418cab9f21cd409f0afd7c2"}
old_school_gfx_glutin_ext = "0.24"
winit = {version = "0.22.2", features = ["serde"]}
glutin = "0.25.1"
old_school_gfx_glutin_ext = "0.25"
winit = {version = "0.23.0", features = ["serde"]}
# Ui
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 = "4f2962d"}
iced_winit = {git = "https://github.com/hecrj/iced", rev = "4f2962d"}
iced = {package = "iced_native", git = "https://github.com/hecrj/iced", rev = "f464316"}
iced_winit = {git = "https://github.com/hecrj/iced", rev = "f464316"}
window_clipboard = "0.1.1"
glyph_brush = "0.7.0"

View File

@ -15,11 +15,12 @@ impl aspect_ratio_container::Renderer for IcedRenderer {
defaults: &Self::Defaults,
_bounds: Rectangle,
cursor_position: Point,
viewport: &Rectangle,
//style: &Self::Style,
content: &Element<'_, M, Self>,
content_layout: Layout<'_>,
) -> Self::Output {
// TODO: stlying to add a background image and such
content.draw(self, defaults, content_layout, cursor_position)
content.draw(self, defaults, content_layout, cursor_position, viewport)
}
}

View File

@ -1,5 +1,5 @@
use super::super::{super::widget::background_container, IcedRenderer, Primitive};
use iced::{Element, Layout, Point};
use iced::{Element, Layout, Point, Rectangle};
impl background_container::Renderer for IcedRenderer {
fn draw<M, B>(
@ -7,6 +7,7 @@ impl background_container::Renderer for IcedRenderer {
defaults: &Self::Defaults,
background: &B,
background_layout: Layout<'_>,
viewport: &Rectangle,
content: &Element<'_, M, Self>,
content_layout: Layout<'_>,
cursor_position: Point,
@ -15,10 +16,10 @@ impl background_container::Renderer for IcedRenderer {
B: background_container::Background<Self>,
{
let back_primitive = background
.draw(self, defaults, background_layout, cursor_position)
.draw(self, defaults, background_layout, cursor_position, viewport)
.0;
let (content_primitive, mouse_interaction) =
content.draw(self, defaults, content_layout, cursor_position);
content.draw(self, defaults, content_layout, cursor_position, viewport);
(
Primitive::Group {
primitives: vec![back_primitive, content_primitive],

View File

@ -37,6 +37,7 @@ impl button::Renderer for IcedRenderer {
&Defaults { text_color },
content_layout,
cursor_position,
&bounds,
);
let primitive = if let Some((handle, color)) = maybe_image {

View File

@ -1,5 +1,5 @@
use super::super::{IcedRenderer, Primitive};
use iced::{column, mouse, Element, Layout, Point};
use iced::{column, mouse, Element, Layout, Point, Rectangle};
impl column::Renderer for IcedRenderer {
fn draw<M>(
@ -8,6 +8,7 @@ impl column::Renderer for IcedRenderer {
content: &[Element<'_, M, Self>],
layout: Layout<'_>,
cursor_position: Point,
viewport: &Rectangle,
) -> Self::Output {
let mut mouse_interaction = mouse::Interaction::default();
@ -18,7 +19,7 @@ impl column::Renderer for IcedRenderer {
.zip(layout.children())
.map(|(child, layout)| {
let (primitive, new_mouse_interaction) =
child.draw(self, defaults, layout, cursor_position);
child.draw(self, defaults, layout, cursor_position, viewport);
if new_mouse_interaction > mouse_interaction {
mouse_interaction = new_mouse_interaction;

View File

@ -15,12 +15,13 @@ impl container::Renderer for IcedRenderer {
defaults: &Self::Defaults,
bounds: Rectangle,
cursor_position: Point,
viewport: &Rectangle,
style_sheet: &Self::Style,
content: &Element<'_, M, Self>,
content_layout: Layout<'_>,
) -> Self::Output {
let (content, mouse_interaction) =
content.draw(self, defaults, content_layout, cursor_position);
content.draw(self, defaults, content_layout, cursor_position, viewport);
let prim = match style_sheet {
Self::Style::Image(handle, color) => {

View File

@ -7,16 +7,17 @@ impl overlay::Renderer for IcedRenderer {
defaults: &Self::Defaults,
_bounds: Rectangle,
cursor_position: Point,
viewport: &Rectangle,
over: &Element<'_, M, Self>,
over_layout: Layout<'_>,
under: &Element<'_, M, Self>,
under_layout: Layout<'_>,
) -> Self::Output {
let (under, under_mouse_interaction) =
under.draw(self, defaults, under_layout, cursor_position);
under.draw(self, defaults, under_layout, cursor_position, viewport);
let (over, over_mouse_interaction) =
over.draw(self, defaults, over_layout, cursor_position);
over.draw(self, defaults, over_layout, cursor_position, viewport);
// TODO: this isn't perfect but should be obselete when iced gets layer support
let mouse_interaction = if over_mouse_interaction == Interaction::Idle {

View File

@ -1,5 +1,5 @@
use super::super::{IcedRenderer, Primitive};
use iced::{mouse, row, Element, Layout, Point};
use iced::{mouse, row, Element, Layout, Point, Rectangle};
impl row::Renderer for IcedRenderer {
fn draw<M>(
@ -8,6 +8,7 @@ impl row::Renderer for IcedRenderer {
content: &[Element<'_, M, Self>],
layout: Layout<'_>,
cursor_position: Point,
viewport: &Rectangle,
) -> Self::Output {
let mut mouse_interaction = mouse::Interaction::default();
@ -18,7 +19,7 @@ impl row::Renderer for IcedRenderer {
.zip(layout.children())
.map(|(child, layout)| {
let (primitive, new_mouse_interaction) =
child.draw(self, defaults, layout, cursor_position);
child.draw(self, defaults, layout, cursor_position, viewport);
if new_mouse_interaction > mouse_interaction {
mouse_interaction = new_mouse_interaction;

View File

@ -3,9 +3,7 @@ use common::util::srgba_to_linear;
use iced::{mouse, scrollable, Rectangle};
use style::scrollable::{Scroller, Track};
const SCROLLBAR_WIDTH: u16 = 6;
const SCROLLBAR_MIN_HEIGHT: u16 = 6;
const SCROLLBAR_MARGIN: u16 = 1;
impl scrollable::Renderer for IcedRenderer {
type Style = style::scrollable::Style;
@ -18,32 +16,42 @@ impl scrollable::Renderer for IcedRenderer {
bounds: Rectangle,
content_bounds: Rectangle,
offset: u32,
scrollbar_width: u16,
scrollbar_margin: u16,
scroller_width: u16,
) -> Option<scrollable::Scrollbar> {
// TODO: might actually want to divide by p_scale here (same in text&ext_input)
// (or just not use it) (or at least only account for dpi but not any
// additional scaling)
let width = (SCROLLBAR_WIDTH + 2 * SCROLLBAR_MARGIN) as f32 * self.p_scale;
if content_bounds.height > bounds.height {
let scrollbar_bounds = Rectangle {
x: bounds.x + bounds.width - width,
width,
// Area containing both scrollbar and scroller
let outer_width = (scrollbar_width.max(scroller_width) + 2 * scrollbar_margin) as f32 /* * self.p_scale */;
let outer_bounds = Rectangle {
x: bounds.x + bounds.width - outer_width,
width: outer_width,
..bounds
};
// Background scrollbar (i.e. the track)
let scrollbar_bounds = Rectangle {
x: bounds.x + bounds.width - outer_width / 2.0 - (scrollbar_width / 2) as f32,
width: scrollbar_width as f32,
..bounds
};
// Interactive scroller
let visible_fraction = bounds.height / content_bounds.height;
let scrollbar_height = (bounds.height * visible_fraction)
.max((2 * SCROLLBAR_MIN_HEIGHT) as f32 * self.p_scale);
let scroller_height = (bounds.height * visible_fraction)
.max((2 * SCROLLBAR_MIN_HEIGHT) as f32/* * self.p_scale*/);
let y_offset = offset as f32 * visible_fraction;
let scroller_bounds = Rectangle {
x: scrollbar_bounds.x + SCROLLBAR_MARGIN as f32 * self.p_scale,
// TODO: check this behavior
x: bounds.x + bounds.width - outer_width / 2.0 - (scrollbar_width / 2) as f32, /* * self.p_scale*/
y: scrollbar_bounds.y + y_offset,
width: scrollbar_bounds.width - (2 * SCROLLBAR_MARGIN) as f32 * self.p_scale,
height: scrollbar_height,
width: scroller_width as f32, /* * self.p_scale*/
height: scroller_height,
};
Some(scrollable::Scrollbar {
outer_bounds,
bounds: scrollbar_bounds,
margin: scrollbar_margin,
scroller: scrollable::Scroller {
bounds: scroller_bounds,
},
@ -145,20 +153,14 @@ impl scrollable::Renderer for IcedRenderer {
}
if let Some(track) = style.track {
let bounds = Rectangle {
x: scrollbar.bounds.x + SCROLLBAR_MARGIN as f32 * self.p_scale,
width: scrollbar.bounds.width
- (2 * SCROLLBAR_MARGIN) as f32 * self.p_scale,
..scrollbar.bounds
};
primitives.push(match track {
Track::Color(color) => Primitive::Rectangle {
bounds,
bounds: scrollbar.bounds,
linear_color: srgba_to_linear(color.map(|e| e as f32 / 255.0)),
},
Track::Image(handle, color) => Primitive::Image {
handle: (handle, Rotation::None),
bounds,
bounds: scrollbar.bounds,
color,
},
});

View File

@ -1,5 +1,5 @@
use super::super::{super::widget::stack, IcedRenderer, Primitive};
use iced::{mouse, Element, Layout, Point};
use iced::{mouse, Element, Layout, Point, Rectangle};
impl stack::Renderer for IcedRenderer {
fn draw<M>(
@ -8,6 +8,7 @@ impl stack::Renderer for IcedRenderer {
content: &[Element<'_, M, Self>],
layout: Layout<'_>,
cursor_position: Point,
viewport: &Rectangle,
) -> Self::Output {
let mut mouse_interaction = mouse::Interaction::default();
@ -18,7 +19,7 @@ impl stack::Renderer for IcedRenderer {
.zip(layout.children())
.map(|(child, layout)| {
let (primitive, new_mouse_interaction) =
child.draw(self, defaults, layout, cursor_position);
child.draw(self, defaults, layout, cursor_position, viewport);
if new_mouse_interaction > mouse_interaction {
mouse_interaction = new_mouse_interaction;

View File

@ -1,5 +1,5 @@
use super::super::{super::widget::tooltip, IcedRenderer, Primitive};
use iced::{Element, Layout, Point};
use iced::{Element, Layout, Point, Rectangle};
impl tooltip::Renderer for IcedRenderer {
fn draw<M>(
@ -7,11 +7,12 @@ impl tooltip::Renderer for IcedRenderer {
alpha: f32,
defaults: &Self::Defaults,
cursor_position: Point,
viewport: &Rectangle,
content: &Element<'_, M, Self>,
content_layout: Layout<'_>,
) -> Self::Output {
let (primitive, cursor_interaction) =
content.draw(self, defaults, content_layout, cursor_position);
content.draw(self, defaults, content_layout, cursor_position, viewport);
(
Primitive::Opacity {
alpha,

View File

@ -139,11 +139,13 @@ where
defaults: &R::Defaults,
layout: Layout<'_>,
cursor_position: Point,
viewport: &Rectangle,
) -> R::Output {
renderer.draw(
defaults,
layout.bounds(),
cursor_position,
viewport,
&self.content,
layout.children().next().unwrap(),
)
@ -179,6 +181,7 @@ pub trait Renderer: iced::Renderer {
defaults: &Self::Defaults,
bounds: Rectangle,
cursor_position: Point,
viewport: &Rectangle,
//style: &Self::Style,
content: &Element<'_, M, Self>,
content_layout: Layout<'_>,

View File

@ -1,4 +1,6 @@
use iced::{layout, Clipboard, Element, Event, Hasher, Layout, Length, Point, Size, Widget};
use iced::{
layout, Clipboard, Element, Event, Hasher, Layout, Length, Point, Rectangle, Size, Widget,
};
use std::{hash::Hash, u32};
// TODO: decouple from image/compound graphic widgets (they could still use
@ -74,6 +76,7 @@ pub trait Background<R: iced::Renderer>: Sized {
defaults: &R::Defaults,
layout: Layout<'_>,
cursor_position: Point,
viewport: &Rectangle,
) -> R::Output;
}
@ -294,11 +297,13 @@ where
defaults: &R::Defaults,
layout: Layout<'_>,
cursor_position: Point,
viewport: &Rectangle,
) -> R::Output {
renderer.draw(
defaults,
&self.background,
layout,
viewport,
&self.content,
layout.children().next().unwrap(),
cursor_position,
@ -331,6 +336,7 @@ pub trait Renderer: iced::Renderer {
defaults: &Self::Defaults,
background: &B,
background_layout: Layout<'_>,
viewport: &Rectangle,
content: &Element<'_, M, Self>,
content_layout: Layout<'_>,
cursor_position: Point,

View File

@ -134,6 +134,8 @@ impl CompoundGraphic {
_defaults: &R::Defaults,
layout: Layout<'_>,
_cursor_position: Point,
// Note: could use to skip elements outside the viewport
_viewport: &Rectangle,
) -> R::Output {
let [pixel_w, pixel_h] = self.graphics_size;
let bounds = layout.bounds();
@ -195,8 +197,9 @@ where
defaults: &R::Defaults,
layout: Layout<'_>,
cursor_position: Point,
viewport: &Rectangle,
) -> R::Output {
Self::draw(self, renderer, defaults, layout, cursor_position)
Self::draw(self, renderer, defaults, layout, cursor_position, viewport)
}
fn hash_layout(&self, state: &mut Hasher) {
@ -251,7 +254,8 @@ where
defaults: &R::Defaults,
layout: Layout<'_>,
cursor_position: Point,
viewport: &Rectangle,
) -> R::Output {
Self::draw(self, renderer, defaults, layout, cursor_position)
Self::draw(self, renderer, defaults, layout, cursor_position, viewport)
}
}

View File

@ -1,4 +1,4 @@
use iced::{layout, Element, Hasher, Layout, Length, Point, Size, Widget};
use iced::{layout, Element, Hasher, Layout, Length, Point, Rectangle, Size, Widget};
use std::hash::Hash;
const DEFAULT_FILL_FRACTION: f32 = 1.0;
@ -94,6 +94,7 @@ where
defaults: &R::Defaults,
layout: Layout<'_>,
cursor_position: Point,
viewport: &Rectangle,
) -> R::Output {
// Note: this breaks if the parent widget adjusts the bounds height
let font_size = (layout.bounds().height * self.fill_fraction) as u16;
@ -103,6 +104,7 @@ where
defaults,
layout.children().next().unwrap(),
cursor_position,
viewport,
)
}

View File

@ -1,5 +1,5 @@
use super::super::graphic;
use iced::{layout, Element, Hasher, Layout, Length, Point, Widget};
use iced::{layout, Element, Hasher, Layout, Length, Point, Rectangle, Widget};
use std::hash::Hash;
use vek::Rgba;
@ -86,6 +86,7 @@ where
_defaults: &R::Defaults,
layout: Layout<'_>,
_cursor_position: Point,
_viewport: &Rectangle,
) -> R::Output {
renderer.draw(self.handle, self.color, layout)
}
@ -134,6 +135,7 @@ where
_defaults: &R::Defaults,
layout: Layout<'_>,
_cursor_position: Point,
_viewport: &Rectangle,
) -> R::Output {
renderer.draw(self.handle, self.color, layout)
}

View File

@ -86,6 +86,7 @@ where
_defaults: &R::Defaults,
layout: Layout<'_>,
_cursor_position: Point,
_viewport: &Rectangle,
) -> R::Output {
renderer.draw(layout.bounds())
}

View File

@ -169,12 +169,14 @@ where
defaults: &R::Defaults,
layout: Layout<'_>,
cursor_position: Point,
viewport: &Rectangle,
) -> R::Output {
let mut children = layout.children();
renderer.draw(
defaults,
layout.bounds(),
cursor_position,
viewport,
&self.over,
children.next().unwrap(),
&self.under,
@ -210,6 +212,7 @@ pub trait Renderer: iced::Renderer {
defaults: &Self::Defaults,
bounds: Rectangle,
cursor_position: Point,
viewport: &Rectangle,
//style: &self::Style,
over: &Element<'_, M, Self>,
over_layout: Layout<'_>,

View File

@ -1,4 +1,5 @@
use iced::{layout, Element, Hasher, Layout, Length, Point, Size, Widget};
// TODO: unused (I think?) consider slating for removal
use iced::{layout, Element, Hasher, Layout, Length, Point, Rectangle, Size, Widget};
use std::hash::Hash;
/// Stack up some widgets
@ -60,8 +61,9 @@ where
defaults: &R::Defaults,
layout: Layout<'_>,
cursor_position: Point,
viewport: &Rectangle,
) -> R::Output {
renderer.draw(defaults, &self.children, layout, cursor_position)
renderer.draw(defaults, &self.children, layout, cursor_position, viewport)
}
fn hash_layout(&self, state: &mut Hasher) {
@ -89,6 +91,7 @@ pub trait Renderer: iced::Renderer {
children: &[Element<'_, M, Self>],
layout: Layout<'_>,
cursor_position: Point,
viewport: &Rectangle,
) -> Self::Output;
}

View File

@ -209,6 +209,7 @@ where
defaults: &R::Defaults,
layout: Layout<'_>,
cursor_position: Point,
viewport: &Rectangle,
) -> R::Output {
let bounds = layout.bounds();
if bounds.contains(cursor_position) {
@ -224,7 +225,7 @@ where
}
self.content
.draw(renderer, defaults, layout, cursor_position)
.draw(renderer, defaults, layout, cursor_position, viewport)
}
fn overlay(&mut self, layout: Layout<'_>) -> Option<iced::overlay::Element<'_, M, R>> {
@ -355,7 +356,15 @@ where
layout: Layout<'_>,
cursor_position: Point,
) -> R::Output {
renderer.draw(self.alpha, defaults, cursor_position, &self.content, layout)
renderer.draw(
self.alpha,
defaults,
cursor_position,
// TODO: hopefully this works
&layout.bounds(),
&self.content,
layout,
)
}
}
@ -365,6 +374,7 @@ pub trait Renderer: iced::Renderer {
alpha: f32,
defaults: &Self::Defaults,
cursor_position: Point,
viewport: &Rectangle,
content: &Element<'_, M, Self>,
content_layout: Layout<'_>,
) -> Self::Output;