diff options
-rw-r--r-- | examples/integration_wgpu/src/main.rs | 2 | ||||
-rw-r--r-- | examples/todos/Cargo.toml | 2 | ||||
-rw-r--r-- | examples/todos/src/main.rs | 6 | ||||
-rw-r--r-- | examples/websocket/Cargo.toml | 2 | ||||
-rw-r--r-- | examples/websocket/src/main.rs | 5 | ||||
-rw-r--r-- | graphics/Cargo.toml | 2 | ||||
-rw-r--r-- | graphics/src/window/compositor.rs | 6 | ||||
-rw-r--r-- | native/src/widget/pane_grid.rs | 46 | ||||
-rw-r--r-- | native/src/widget/pane_grid/content.rs | 17 | ||||
-rw-r--r-- | native/src/widget/pick_list.rs | 6 | ||||
-rw-r--r-- | native/src/widget/text_input.rs | 6 | ||||
-rw-r--r-- | style/Cargo.toml | 4 | ||||
-rw-r--r-- | style/src/theme/palette.rs | 11 | ||||
-rw-r--r-- | wgpu/Cargo.toml | 6 | ||||
-rw-r--r-- | wgpu/src/window/compositor.rs | 9 |
15 files changed, 69 insertions, 61 deletions
diff --git a/examples/integration_wgpu/src/main.rs b/examples/integration_wgpu/src/main.rs index 69d46c3e..70f9a48b 100644 --- a/examples/integration_wgpu/src/main.rs +++ b/examples/integration_wgpu/src/main.rs @@ -119,6 +119,7 @@ pub fn main() { width: physical_size.width, height: physical_size.height, present_mode: wgpu::PresentMode::AutoVsync, + alpha_mode: wgpu::CompositeAlphaMode::Auto, }, ); @@ -213,6 +214,7 @@ pub fn main() { width: size.width, height: size.height, present_mode: wgpu::PresentMode::AutoVsync, + alpha_mode: wgpu::CompositeAlphaMode::Auto }, ); diff --git a/examples/todos/Cargo.toml b/examples/todos/Cargo.toml index 2326ffc6..7ad4d558 100644 --- a/examples/todos/Cargo.toml +++ b/examples/todos/Cargo.toml @@ -9,7 +9,7 @@ publish = false iced = { path = "../..", features = ["async-std", "debug"] } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -lazy_static = "1.4" +once_cell = "1.15" [target.'cfg(not(target_arch = "wasm32"))'.dependencies] async-std = "1.0" diff --git a/examples/todos/src/main.rs b/examples/todos/src/main.rs index bddc0e71..be48ae8c 100644 --- a/examples/todos/src/main.rs +++ b/examples/todos/src/main.rs @@ -11,12 +11,10 @@ use iced::window; use iced::{Application, Element}; use iced::{Color, Command, Font, Length, Settings, Subscription}; -use lazy_static::lazy_static; +use once_cell::sync::Lazy; use serde::{Deserialize, Serialize}; -lazy_static! { - static ref INPUT_ID: text_input::Id = text_input::Id::unique(); -} +static INPUT_ID: Lazy<text_input::Id> = Lazy::new(text_input::Id::unique); pub fn main() -> iced::Result { Todos::run(Settings { diff --git a/examples/websocket/Cargo.toml b/examples/websocket/Cargo.toml index 3981f699..c25f067b 100644 --- a/examples/websocket/Cargo.toml +++ b/examples/websocket/Cargo.toml @@ -9,7 +9,7 @@ publish = false iced = { path = "../..", features = ["tokio", "debug"] } iced_native = { path = "../../native" } iced_futures = { path = "../../futures" } -lazy_static = "1.4" +once_cell = "1.15" [dependencies.async-tungstenite] version = "0.16" diff --git a/examples/websocket/src/main.rs b/examples/websocket/src/main.rs index 3902e04c..ff2929da 100644 --- a/examples/websocket/src/main.rs +++ b/examples/websocket/src/main.rs @@ -8,6 +8,7 @@ use iced::widget::{ use iced::{ Application, Color, Command, Element, Length, Settings, Subscription, Theme, }; +use once_cell::sync::Lazy; pub fn main() -> iced::Result { WebSocket::run(Settings::default()) @@ -165,6 +166,4 @@ impl Default for State { } } -lazy_static::lazy_static! { - static ref MESSAGE_LOG: scrollable::Id = scrollable::Id::unique(); -} +static MESSAGE_LOG: Lazy<scrollable::Id> = Lazy::new(scrollable::Id::unique); diff --git a/graphics/Cargo.toml b/graphics/Cargo.toml index 49d4d9c6..18fef54f 100644 --- a/graphics/Cargo.toml +++ b/graphics/Cargo.toml @@ -20,7 +20,7 @@ opengl = [] [dependencies] glam = "0.10" -raw-window-handle = "0.4" +raw-window-handle = "0.5" thiserror = "1.0" [dependencies.bytemuck] diff --git a/graphics/src/window/compositor.rs b/graphics/src/window/compositor.rs index 0c4cadcd..52255666 100644 --- a/graphics/src/window/compositor.rs +++ b/graphics/src/window/compositor.rs @@ -2,7 +2,7 @@ //! surfaces. use crate::{Color, Error, Viewport}; -use raw_window_handle::HasRawWindowHandle; +use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle}; use thiserror::Error; /// A graphics compositor that can draw to windows. @@ -17,7 +17,7 @@ pub trait Compositor: Sized { type Surface; /// Creates a new [`Compositor`]. - fn new<W: HasRawWindowHandle>( + fn new<W: HasRawWindowHandle + HasRawDisplayHandle>( settings: Self::Settings, compatible_window: Option<&W>, ) -> Result<(Self, Self::Renderer), Error>; @@ -25,7 +25,7 @@ pub trait Compositor: Sized { /// Crates a new [`Surface`] for the given window. /// /// [`Surface`]: Self::Surface - fn create_surface<W: HasRawWindowHandle>( + fn create_surface<W: HasRawWindowHandle + HasRawDisplayHandle>( &mut self, window: &W, ) -> Self::Surface; diff --git a/native/src/widget/pane_grid.rs b/native/src/widget/pane_grid.rs index d84fb7a0..96cf78ef 100644 --- a/native/src/widget/pane_grid.rs +++ b/native/src/widget/pane_grid.rs @@ -341,6 +341,7 @@ where cursor_position, viewport, renderer, + self.on_drag.is_some(), ) }) .max() @@ -648,7 +649,7 @@ pub fn mouse_interaction( resize_leeway: Option<u16>, ) -> Option<mouse::Interaction> { if action.picked_pane().is_some() { - return Some(mouse::Interaction::Grab); + return Some(mouse::Interaction::Grabbing); } let resize_axis = @@ -756,27 +757,12 @@ pub fn draw<Renderer, T>( cursor_position }; + let mut render_picked_pane = None; + for ((id, pane), layout) in elements.zip(layout.children()) { match picked_pane { Some((dragging, origin)) if id == dragging => { - let bounds = layout.bounds(); - - renderer.with_translation( - cursor_position - - Point::new(bounds.x + origin.x, bounds.y + origin.y), - |renderer| { - renderer.with_layer(bounds, |renderer| { - draw_pane( - pane, - renderer, - default_style, - layout, - pane_cursor_position, - viewport, - ); - }); - }, - ); + render_picked_pane = Some((pane, origin, layout)); } _ => { draw_pane( @@ -791,6 +777,28 @@ pub fn draw<Renderer, T>( } } + // Render picked pane last + if let Some((pane, origin, layout)) = render_picked_pane { + let bounds = layout.bounds(); + + renderer.with_translation( + cursor_position + - Point::new(bounds.x + origin.x, bounds.y + origin.y), + |renderer| { + renderer.with_layer(bounds, |renderer| { + draw_pane( + pane, + renderer, + default_style, + layout, + pane_cursor_position, + viewport, + ); + }); + }, + ); + }; + if let Some((axis, split_region, is_picked)) = picked_split { let highlight = if is_picked { theme.picked_split(style) diff --git a/native/src/widget/pane_grid/content.rs b/native/src/widget/pane_grid/content.rs index 98ce2c4b..c236d820 100644 --- a/native/src/widget/pane_grid/content.rs +++ b/native/src/widget/pane_grid/content.rs @@ -115,25 +115,25 @@ where let show_controls = bounds.contains(cursor_position); - title_bar.draw( - &tree.children[1], + self.body.as_widget().draw( + &tree.children[0], renderer, theme, style, - title_bar_layout, + body_layout, cursor_position, viewport, - show_controls, ); - self.body.as_widget().draw( - &tree.children[0], + title_bar.draw( + &tree.children[1], renderer, theme, style, - body_layout, + title_bar_layout, cursor_position, viewport, + show_controls, ); } else { self.body.as_widget().draw( @@ -238,6 +238,7 @@ where cursor_position: Point, viewport: &Rectangle, renderer: &Renderer, + drag_enabled: bool, ) -> mouse::Interaction { let (body_layout, title_bar_interaction) = if let Some(title_bar) = &self.title_bar { @@ -247,7 +248,7 @@ where let is_over_pick_area = title_bar .is_over_pick_area(title_bar_layout, cursor_position); - if is_over_pick_area { + if is_over_pick_area && drag_enabled { return mouse::Interaction::Grab; } diff --git a/native/src/widget/pick_list.rs b/native/src/widget/pick_list.rs index c334804e..896f5b35 100644 --- a/native/src/widget/pick_list.rs +++ b/native/src/widget/pick_list.rs @@ -348,9 +348,9 @@ where let state = state(); let event_status = if state.is_open { - // TODO: Encode cursor availability in the type system - state.is_open = - cursor_position.x < 0.0 || cursor_position.y < 0.0; + // Event wasn't processed by overlay, so cursor was clicked either outside it's + // bounds or on the drop-down, either way we close the overlay. + state.is_open = false; event::Status::Captured } else if layout.bounds().contains(cursor_position) { diff --git a/native/src/widget/text_input.rs b/native/src/widget/text_input.rs index c2d25520..e5213cbe 100644 --- a/native/src/widget/text_input.rs +++ b/native/src/widget/text_input.rs @@ -712,14 +712,14 @@ where } return event::Status::Captured; + } else { + state.is_pasting = None; } } Event::Keyboard(keyboard::Event::ModifiersChanged(modifiers)) => { let state = state(); - if state.is_focused { - state.keyboard_modifiers = modifiers; - } + state.keyboard_modifiers = modifiers; } _ => {} } diff --git a/style/Cargo.toml b/style/Cargo.toml index cf9d328b..4a482a4f 100644 --- a/style/Cargo.toml +++ b/style/Cargo.toml @@ -18,5 +18,5 @@ features = ["palette"] [dependencies.palette] version = "0.6" -[dependencies.lazy_static] -version = "1.4" +[dependencies.once_cell] +version = "1.15" diff --git a/style/src/theme/palette.rs b/style/src/theme/palette.rs index 81aa9cc7..4fb5e4c8 100644 --- a/style/src/theme/palette.rs +++ b/style/src/theme/palette.rs @@ -1,6 +1,6 @@ use iced_core::Color; -use lazy_static::lazy_static; +use once_cell::sync::Lazy; use palette::{FromColor, Hsl, Mix, RelativeContrast, Srgb}; #[derive(Debug, Clone, Copy, PartialEq)] @@ -66,11 +66,10 @@ pub struct Extended { pub danger: Danger, } -lazy_static! { - pub static ref EXTENDED_LIGHT: Extended = - Extended::generate(Palette::LIGHT); - pub static ref EXTENDED_DARK: Extended = Extended::generate(Palette::DARK); -} +pub static EXTENDED_LIGHT: Lazy<Extended> = + Lazy::new(|| Extended::generate(Palette::LIGHT)); +pub static EXTENDED_DARK: Lazy<Extended> = + Lazy::new(|| Extended::generate(Palette::DARK)); impl Extended { pub fn generate(palette: Palette) -> Self { diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml index 586f97d3..55eec73f 100644 --- a/wgpu/Cargo.toml +++ b/wgpu/Cargo.toml @@ -28,10 +28,10 @@ spirv = ["wgpu/spirv"] webgl = ["wgpu/webgl"] [dependencies] -wgpu = "0.13" -wgpu_glyph = "0.17" +wgpu = "0.14" +wgpu_glyph = "0.18" glyph_brush = "0.7" -raw-window-handle = "0.4" +raw-window-handle = "0.5" log = "0.4" guillotiere = "0.6" futures = "0.3" diff --git a/wgpu/src/window/compositor.rs b/wgpu/src/window/compositor.rs index a36d2a87..6d0c36f6 100644 --- a/wgpu/src/window/compositor.rs +++ b/wgpu/src/window/compositor.rs @@ -4,7 +4,7 @@ use futures::stream::{self, StreamExt}; use iced_graphics::compositor; use iced_native::futures; -use raw_window_handle::HasRawWindowHandle; +use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle}; use std::marker::PhantomData; @@ -27,7 +27,7 @@ impl<Theme> Compositor<Theme> { /// Requests a new [`Compositor`] with the given [`Settings`]. /// /// Returns `None` if no compatible graphics adapter could be found. - pub async fn request<W: HasRawWindowHandle>( + pub async fn request<W: HasRawWindowHandle + HasRawDisplayHandle>( settings: Settings, compatible_window: Option<&W>, ) -> Option<Self> { @@ -123,7 +123,7 @@ impl<Theme> iced_graphics::window::Compositor for Compositor<Theme> { type Renderer = Renderer<Theme>; type Surface = wgpu::Surface; - fn new<W: HasRawWindowHandle>( + fn new<W: HasRawWindowHandle + HasRawDisplayHandle>( settings: Self::Settings, compatible_window: Option<&W>, ) -> Result<(Self, Self::Renderer), Error> { @@ -138,7 +138,7 @@ impl<Theme> iced_graphics::window::Compositor for Compositor<Theme> { Ok((compositor, Renderer::new(backend))) } - fn create_surface<W: HasRawWindowHandle>( + fn create_surface<W: HasRawWindowHandle + HasRawDisplayHandle>( &mut self, window: &W, ) -> wgpu::Surface { @@ -162,6 +162,7 @@ impl<Theme> iced_graphics::window::Compositor for Compositor<Theme> { present_mode: self.settings.present_mode, width, height, + alpha_mode: wgpu::CompositeAlphaMode::Auto, }, ); } |