From df04250ad2a8d97d3c4c992cce63fe308222b55a Mon Sep 17 00:00:00 2001 From: Cory Forsstrom Date: Sun, 14 Jul 2024 12:41:18 -0700 Subject: [PATCH] Update iced --- Cargo.lock | 21 ++++----- Cargo.toml | 4 +- data/src/stream.rs | 2 +- src/buffer/channel.rs | 17 ++++--- src/buffer/channel/topic.rs | 11 ++--- src/buffer/empty.rs | 2 +- src/buffer/file_transfers.rs | 25 +++++------ src/buffer/input_view/completion.rs | 2 +- src/buffer/scroll_view.rs | 59 ++++++++++++------------- src/buffer/user_context.rs | 12 ++--- src/event.rs | 6 +-- src/main.rs | 55 ++++++++++------------- src/modal/connect_to_server.rs | 2 +- src/modal/reload_configuration_error.rs | 2 +- src/screen/dashboard.rs | 14 +++--- src/screen/dashboard/sidebar.rs | 29 ++++++------ src/screen/help.rs | 2 +- src/screen/migration.rs | 2 +- src/screen/welcome.rs | 2 +- src/stream.rs | 4 +- src/theme.rs | 8 ++-- src/theme/container.rs | 4 +- src/theme/scrollable.rs | 14 +++--- src/url.rs | 4 +- src/widget/context_menu.rs | 4 +- src/widget/selectable_text.rs | 2 +- src/window.rs | 16 +++---- 27 files changed, 159 insertions(+), 166 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b49b2e5b4..c06cc7708 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1955,7 +1955,7 @@ dependencies = [ [[package]] name = "iced" version = "0.13.0-dev" -source = "git+https://github.com/iced-rs/iced?rev=19db068bbbebcda1756720525da247f35bd3a5e0#19db068bbbebcda1756720525da247f35bd3a5e0" +source = "git+https://github.com/iced-rs/iced?rev=bdf0430880f5c29443f5f0a0ae4895866dfef4c6#bdf0430880f5c29443f5f0a0ae4895866dfef4c6" dependencies = [ "iced_core", "iced_futures", @@ -1969,7 +1969,7 @@ dependencies = [ [[package]] name = "iced_core" version = "0.13.0-dev" -source = "git+https://github.com/iced-rs/iced?rev=19db068bbbebcda1756720525da247f35bd3a5e0#19db068bbbebcda1756720525da247f35bd3a5e0" +source = "git+https://github.com/iced-rs/iced?rev=bdf0430880f5c29443f5f0a0ae4895866dfef4c6#bdf0430880f5c29443f5f0a0ae4895866dfef4c6" dependencies = [ "bitflags 2.5.0", "bytes", @@ -1988,7 +1988,7 @@ dependencies = [ [[package]] name = "iced_futures" version = "0.13.0-dev" -source = "git+https://github.com/iced-rs/iced?rev=19db068bbbebcda1756720525da247f35bd3a5e0#19db068bbbebcda1756720525da247f35bd3a5e0" +source = "git+https://github.com/iced-rs/iced?rev=bdf0430880f5c29443f5f0a0ae4895866dfef4c6#bdf0430880f5c29443f5f0a0ae4895866dfef4c6" dependencies = [ "futures", "iced_core", @@ -2002,7 +2002,7 @@ dependencies = [ [[package]] name = "iced_graphics" version = "0.13.0-dev" -source = "git+https://github.com/iced-rs/iced?rev=19db068bbbebcda1756720525da247f35bd3a5e0#19db068bbbebcda1756720525da247f35bd3a5e0" +source = "git+https://github.com/iced-rs/iced?rev=bdf0430880f5c29443f5f0a0ae4895866dfef4c6#bdf0430880f5c29443f5f0a0ae4895866dfef4c6" dependencies = [ "bitflags 2.5.0", "bytemuck", @@ -2023,7 +2023,7 @@ dependencies = [ [[package]] name = "iced_renderer" version = "0.13.0-dev" -source = "git+https://github.com/iced-rs/iced?rev=19db068bbbebcda1756720525da247f35bd3a5e0#19db068bbbebcda1756720525da247f35bd3a5e0" +source = "git+https://github.com/iced-rs/iced?rev=bdf0430880f5c29443f5f0a0ae4895866dfef4c6#bdf0430880f5c29443f5f0a0ae4895866dfef4c6" dependencies = [ "iced_graphics", "iced_tiny_skia", @@ -2035,7 +2035,7 @@ dependencies = [ [[package]] name = "iced_runtime" version = "0.13.0-dev" -source = "git+https://github.com/iced-rs/iced?rev=19db068bbbebcda1756720525da247f35bd3a5e0#19db068bbbebcda1756720525da247f35bd3a5e0" +source = "git+https://github.com/iced-rs/iced?rev=bdf0430880f5c29443f5f0a0ae4895866dfef4c6#bdf0430880f5c29443f5f0a0ae4895866dfef4c6" dependencies = [ "bytes", "iced_core", @@ -2047,7 +2047,7 @@ dependencies = [ [[package]] name = "iced_tiny_skia" version = "0.13.0-dev" -source = "git+https://github.com/iced-rs/iced?rev=19db068bbbebcda1756720525da247f35bd3a5e0#19db068bbbebcda1756720525da247f35bd3a5e0" +source = "git+https://github.com/iced-rs/iced?rev=bdf0430880f5c29443f5f0a0ae4895866dfef4c6#bdf0430880f5c29443f5f0a0ae4895866dfef4c6" dependencies = [ "bytemuck", "cosmic-text", @@ -2062,7 +2062,7 @@ dependencies = [ [[package]] name = "iced_wgpu" version = "0.13.0-dev" -source = "git+https://github.com/iced-rs/iced?rev=19db068bbbebcda1756720525da247f35bd3a5e0#19db068bbbebcda1756720525da247f35bd3a5e0" +source = "git+https://github.com/iced-rs/iced?rev=bdf0430880f5c29443f5f0a0ae4895866dfef4c6#bdf0430880f5c29443f5f0a0ae4895866dfef4c6" dependencies = [ "bitflags 2.5.0", "bytemuck", @@ -2081,11 +2081,12 @@ dependencies = [ [[package]] name = "iced_widget" version = "0.13.0-dev" -source = "git+https://github.com/iced-rs/iced?rev=19db068bbbebcda1756720525da247f35bd3a5e0#19db068bbbebcda1756720525da247f35bd3a5e0" +source = "git+https://github.com/iced-rs/iced?rev=bdf0430880f5c29443f5f0a0ae4895866dfef4c6#bdf0430880f5c29443f5f0a0ae4895866dfef4c6" dependencies = [ "iced_renderer", "iced_runtime", "num-traits", + "once_cell", "ouroboros", "rustc-hash", "thiserror", @@ -2095,7 +2096,7 @@ dependencies = [ [[package]] name = "iced_winit" version = "0.13.0-dev" -source = "git+https://github.com/iced-rs/iced?rev=19db068bbbebcda1756720525da247f35bd3a5e0#19db068bbbebcda1756720525da247f35bd3a5e0" +source = "git+https://github.com/iced-rs/iced?rev=bdf0430880f5c29443f5f0a0ae4895866dfef4c6#bdf0430880f5c29443f5f0a0ae4895866dfef4c6" dependencies = [ "iced_futures", "iced_graphics", diff --git a/Cargo.toml b/Cargo.toml index 2c8bf9745..7f8164aef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,5 +52,5 @@ embed-resource = "2.1.1" members = ["data", "ipc", "irc", "irc/proto"] [patch.crates-io] -iced = { git = "https://github.com/iced-rs/iced", rev = "19db068bbbebcda1756720525da247f35bd3a5e0" } -iced_core = { git = "https://github.com/iced-rs/iced", rev = "19db068bbbebcda1756720525da247f35bd3a5e0" } +iced = { git = "https://github.com/iced-rs/iced", rev = "bdf0430880f5c29443f5f0a0ae4895866dfef4c6" } +iced_core = { git = "https://github.com/iced-rs/iced", rev = "bdf0430880f5c29443f5f0a0ae4895866dfef4c6" } diff --git a/data/src/stream.rs b/data/src/stream.rs index 2ea797c25..0f3a56030 100644 --- a/data/src/stream.rs +++ b/data/src/stream.rs @@ -1,8 +1,8 @@ use chrono::{DateTime, Utc}; +use futures::never::Never; use std::time::Duration; use futures::channel::mpsc; -use futures::never::Never; use futures::{future, stream, FutureExt, SinkExt, StreamExt}; use irc::proto::{self, command, Command}; use irc::{codec, connection, Connection}; diff --git a/src/buffer/channel.rs b/src/buffer/channel.rs index d058d7892..eb2cd1139 100644 --- a/src/buffer/channel.rs +++ b/src/buffer/channel.rs @@ -3,7 +3,7 @@ use data::user::Nick; use data::User; use data::{channel, history, message, Config}; use iced::widget::{column, container, row}; -use iced::{Length, Task}; +use iced::{padding, Length, Task}; use super::{input_view, scroll_view, user_context}; use crate::theme; @@ -189,7 +189,7 @@ pub fn view<'a>( container(body) .width(Length::Fill) .height(Length::Fill) - .padding([4, 8, 8, 8]) + .padding(padding::all(8).top(4)) .into() } @@ -326,13 +326,12 @@ mod nick_list { .spacing(1); container( - Scrollable::with_direction( - column, - scrollable::Direction::Vertical( - scrollable::Properties::new().width(1).scroller_width(1), - ), - ) - .style(theme::scrollable::hidden), + Scrollable::new(column) + .direction(scrollable::Direction::Vertical { + scrollbar: scrollable::Scrollbar::new().width(1).scroller_width(1), + spacing: None, + }) + .style(theme::scrollable::hidden), ) .width(Length::Shrink) .max_width(120) diff --git a/src/buffer/channel/topic.rs b/src/buffer/channel/topic.rs index 38f15567c..460efd2ae 100644 --- a/src/buffer/channel/topic.rs +++ b/src/buffer/channel/topic.rs @@ -52,11 +52,12 @@ pub fn view<'a>( let content = column![selectable_text(text).style(theme::selectable_text::transparent)] .push_maybe(set_by); - let scrollable = Scrollable::with_direction( - container(content).width(Length::Fill).padding(padding()), - scrollable::Direction::Vertical(scrollable::Properties::new().width(1).scroller_width(1)), - ) - .style(theme::scrollable::hidden); + let scrollable = Scrollable::new(container(content).width(Length::Fill).padding(padding())) + .direction(scrollable::Direction::Vertical { + scrollbar: scrollable::Scrollbar::new().width(1).scroller_width(1), + spacing: None, + }) + .style(theme::scrollable::hidden); // Use double pass to limit layout to `max_lines` of text column![ diff --git a/src/buffer/empty.rs b/src/buffer/empty.rs index 9affac37a..6bf5c5568 100644 --- a/src/buffer/empty.rs +++ b/src/buffer/empty.rs @@ -8,7 +8,7 @@ pub fn view<'a, Message: 'a>() -> Element<'a, Message> { let content = column![] .push(text("⟵ select buffer").shaping(text::Shaping::Advanced)) - .align_items(iced::Alignment::Center); + .align_x(iced::Alignment::Center); container(content) .align_x(alignment::Horizontal::Center) diff --git a/src/buffer/file_transfers.rs b/src/buffer/file_transfers.rs index b12a9927c..e81403bc3 100644 --- a/src/buffer/file_transfers.rs +++ b/src/buffer/file_transfers.rs @@ -27,7 +27,7 @@ pub fn view<'a>( text("No transfers found").style(theme::text::transparent) ] .spacing(8) - .align_items(iced::Alignment::Center), + .align_x(iced::Alignment::Center), )) .into(); } @@ -42,13 +42,12 @@ pub fn view<'a>( .padding([0, 2]); container( - Scrollable::with_direction( - column, - scrollable::Direction::Vertical( - scrollable::Properties::new().width(1).scroller_width(1), - ), - ) - .style(theme::scrollable::hidden), + Scrollable::new(column) + .direction(scrollable::Direction::Vertical { + scrollbar: scrollable::Scrollbar::new().width(1).scroller_width(1), + spacing: None, + }) + .style(theme::scrollable::hidden), ) .width(Length::Fill) .height(Length::Fill) @@ -105,7 +104,7 @@ mod transfer_row { use bytesize::ByteSize; use data::file_transfer::{self, FileTransfer}; use iced::widget::{column, container, progress_bar, row, text}; - use iced::{alignment, Length}; + use iced::{alignment, padding, Length}; use crate::buffer::file_transfers::row_button; use crate::widget::Element; @@ -216,11 +215,11 @@ mod transfer_row { let file_size = ByteSize::b(transfer.size); let filename = container(text(format!("{} ({file_size})", transfer.filename))); - let mut buttons = row![].align_items(iced::Alignment::Center).spacing(2); + let mut buttons = row![].align_y(iced::Alignment::Center).spacing(2); let content = column![filename, status] // Add 1 padding to make container odd sized // for proper icon centering - .padding([1, 0, 0, 0]) + .padding(padding::top(1)) .width(Length::Fill) .spacing(0); @@ -245,10 +244,10 @@ mod transfer_row { let row = row![content, buttons] .spacing(6) - .align_items(iced::Alignment::Center); + .align_y(iced::Alignment::Center); container(row) - .padding([6, 4, 6, 8]) + .padding(padding::top(6).bottom(6).right(4).left(8)) .width(Length::Fill) .align_y(alignment::Vertical::Center) .style(move |theme| theme::container::table_row(theme, idx)) diff --git a/src/buffer/input_view/completion.rs b/src/buffer/input_view/completion.rs index 33a35010f..1e29c5d7c 100644 --- a/src/buffer/input_view/completion.rs +++ b/src/buffer/input_view/completion.rs @@ -415,7 +415,7 @@ impl Command { Element::from(row![ text(" "), tooltip( - row![content, tooltip_indicator].align_items(iced::Alignment::Start), + row![content, tooltip_indicator].align_y(iced::Alignment::Start), container(text(arg_tooltip.clone()).style(move |theme| { if index == active_arg { theme::text::transparent_accent(theme) diff --git a/src/buffer/scroll_view.rs b/src/buffer/scroll_view.rs index 540dfd8e2..d2d50341a 100644 --- a/src/buffer/scroll_view.rs +++ b/src/buffer/scroll_view.rs @@ -3,7 +3,7 @@ use data::server::Server; use data::user::Nick; use data::{history, time, Config}; use iced::widget::{column, container, horizontal_rule, row, scrollable, text, Scrollable}; -use iced::{Length, Task}; +use iced::{padding, Length, Task}; use super::user_context; use crate::theme; @@ -86,40 +86,39 @@ pub fn view<'a>( let divider = row![ container(horizontal_rule(1)) .width(Length::Fill) - .padding([0, 6, 0, 0]), + .padding(padding::right(6)), text("backlog") .size(font_size) .style(theme::text::transparent), container(horizontal_rule(1)) .width(Length::Fill) - .padding([0, 0, 0, 6]) + .padding(padding::left(6)) ] .padding(2) - .align_items(iced::Alignment::Center); + .align_y(iced::Alignment::Center); column![column(old), divider, column(new)] } else { column![column(old), column(new)] }; - Scrollable::with_direction( - container(content).width(Length::Fill).padding([0, 8]), - scrollable::Direction::Vertical( - scrollable::Properties::default() - .alignment(status.alignment()) + Scrollable::new(container(content).width(Length::Fill).padding([0, 8])) + .direction(scrollable::Direction::Vertical { + scrollbar: scrollable::Scrollbar::default() + .anchor(status.alignment()) .width(5) .scroller_width(5), - ), - ) - .on_scroll(move |viewport| Message::Scrolled { - count, - remaining, - oldest, - status, - viewport, - }) - .id(state.scrollable.clone()) - .into() + spacing: None, + }) + .on_scroll(move |viewport| Message::Scrolled { + count, + remaining, + oldest, + status, + viewport, + }) + .id(state.scrollable.clone()) + .into() } #[derive(Debug, Clone)] @@ -263,16 +262,16 @@ impl Status { } } - fn alignment(self) -> scrollable::Alignment { + fn alignment(self) -> scrollable::Anchor { match self { Status::Idle(anchor) => match anchor { - Anchor::Top => scrollable::Alignment::Start, - Anchor::Bottom => scrollable::Alignment::End, + Anchor::Top => scrollable::Anchor::Start, + Anchor::Bottom => scrollable::Anchor::End, }, - Status::Unlocked(_) => scrollable::Alignment::Start, + Status::Unlocked(_) => scrollable::Anchor::Start, Status::Loading(anchor) => match anchor { - Anchor::Top => scrollable::Alignment::Start, - Anchor::Bottom => scrollable::Alignment::End, + Anchor::Top => scrollable::Anchor::Start, + Anchor::Bottom => scrollable::Anchor::End, }, } } @@ -293,15 +292,15 @@ impl Status { fn is_top(self, relative_offset: f32) -> bool { match self.alignment() { - scrollable::Alignment::Start => relative_offset == 0.0, - scrollable::Alignment::End => relative_offset == 1.0, + scrollable::Anchor::Start => relative_offset == 0.0, + scrollable::Anchor::End => relative_offset == 1.0, } } fn is_bottom(self, relative_offset: f32) -> bool { match self.alignment() { - scrollable::Alignment::Start => relative_offset == 1.0, - scrollable::Alignment::End => relative_offset == 0.0, + scrollable::Anchor::Start => relative_offset == 1.0, + scrollable::Anchor::End => relative_offset == 0.0, } } diff --git a/src/buffer/user_context.rs b/src/buffer/user_context.rs index b6afe191b..1c273e089 100644 --- a/src/buffer/user_context.rs +++ b/src/buffer/user_context.rs @@ -1,7 +1,7 @@ use data::user::Nick; use data::{Buffer, User}; use iced::widget::{button, container, horizontal_rule, row, text, Space}; -use iced::Length; +use iced::{padding, Length, Padding}; use crate::widget::{context_menu, double_pass, Element}; use crate::{icon, theme}; @@ -143,8 +143,8 @@ fn menu_button(content: &str, message: Message, length: Length) -> Element<'_, M .into() } -fn right_justified_padding() -> [f32; 4] { - [5.0, 5.0 + double_pass::horizontal_expansion(), 5.0, 5.0] +fn right_justified_padding() -> Padding { + padding::all(5).right(5.0 + double_pass::horizontal_expansion()) } fn user_info(current_user: Option<&User>, length: Length) -> Element<'_, Message> { @@ -159,7 +159,7 @@ fn user_info(current_user: Option<&User>, length: Length) -> Element<'_, Message .shaping(text::Shaping::Advanced), ) .padding(right_justified_padding()) - .align_items(iced::Alignment::Center) + .align_y(iced::Alignment::Center) .into() } else { row![] @@ -171,7 +171,7 @@ fn user_info(current_user: Option<&User>, length: Length) -> Element<'_, Message .shaping(text::Shaping::Advanced), ) .padding(right_justified_padding()) - .align_items(iced::Alignment::Center) + .align_y(iced::Alignment::Center) .into() } } else { @@ -188,7 +188,7 @@ fn user_info(current_user: Option<&User>, length: Length) -> Element<'_, Message .shaping(text::Shaping::Advanced), ) .padding(right_justified_padding()) - .align_items(iced::Alignment::Center) + .align_y(iced::Alignment::Center) .into() } } diff --git a/src/event.rs b/src/event.rs index dc561966c..ba8c84eae 100644 --- a/src/event.rs +++ b/src/event.rs @@ -2,7 +2,7 @@ use iced::{event, keyboard, window, Subscription}; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Event { - CloseRequested, + CloseRequested(window::Id), Copy, Escape, Home, @@ -16,7 +16,7 @@ pub fn events() -> Subscription { fn filtered_events( event: iced::Event, status: iced::event::Status, - _id: iced::window::Id, + window: window::Id, ) -> Option { let ignored = |status| matches!(status, iced::event::Status::Ignored); @@ -38,7 +38,7 @@ fn filtered_events( key: keyboard::Key::Named(keyboard::key::Named::End), .. }) if ignored(status) => Some(Event::End), - iced::Event::Window(window::Event::CloseRequested) => Some(Event::CloseRequested), + iced::Event::Window(window::Event::CloseRequested) => Some(Event::CloseRequested(window)), _ => None, } } diff --git a/src/main.rs b/src/main.rs index 2bfd78503..5dbca1194 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,9 +24,8 @@ use data::config::{self, Config}; use data::version::Version; use data::window::Window; use data::{environment, server, version, User}; -use iced::advanced::Application; use iced::widget::{column, container}; -use iced::{executor, Length, Renderer, Subscription, Task}; +use iced::{Length, Subscription, Task}; use screen::{dashboard, help, migration, welcome}; use self::event::{events, Event}; @@ -78,7 +77,21 @@ pub fn main() -> iced::Result { } } - if let Err(error) = Halloy::run(settings(config_load, destination)) { + let window_load = Window::load().unwrap_or_default(); + + if let Err(error) = iced::application("Halloy", Halloy::update, Halloy::view) + .theme(Halloy::theme) + .scale_factor(Halloy::scale_factor) + .subscription(Halloy::subscription) + .settings(settings(&config_load)) + .window(window::Settings { + size: window_load.size.into(), + position: window_load.position.map(From::from).unwrap_or_default(), + exit_on_close_request: false, + ..window::settings() + }) + .run_with(move || Halloy::new(config_load.clone(), destination.clone())) + { log::error!("{}", error.to_string()); Err(error) } else { @@ -86,11 +99,7 @@ pub fn main() -> iced::Result { } } -fn settings( - config_load: Result, - route_received: Option, -) -> iced::Settings<(Result, Option)> { - let window_load = Window::load().unwrap_or_default(); +fn settings(config_load: &Result) -> iced::Settings { let default_text_size = config_load .as_ref() .ok() @@ -101,13 +110,6 @@ fn settings( iced::Settings { default_font: font::MONO.clone().into(), default_text_size: default_text_size.into(), - window: window::Settings { - size: window_load.size.into(), - position: window_load.position.map(From::from).unwrap_or_default(), - exit_on_close_request: false, - ..window::settings() - }, - flags: (config_load, route_received), id: None, antialiasing: false, fonts: font::load(), @@ -214,16 +216,11 @@ pub enum Message { WindowSettingsSaved(Result<(), data::window::Error>), } -impl Application for Halloy { - type Renderer = Renderer; - type Executor = executor::Default; - type Message = Message; - type Theme = Theme; - type Flags = (Result, Option); - - fn new(flags: Self::Flags) -> (Halloy, Task) { - let (config_load, url_received) = flags; - +impl Halloy { + fn new( + config_load: Result, + url_received: Option, + ) -> (Halloy, Task) { let (mut halloy, command) = Halloy::load_from_state(config_load); let latest_remote_version = Task::perform(version::latest_remote_version(), Message::Version); @@ -237,10 +234,6 @@ impl Application for Halloy { (halloy, command) } - fn title(&self) -> String { - String::from("Halloy") - } - fn update(&mut self, message: Message) -> Task { match message { Message::Dashboard(message) => { @@ -608,8 +601,8 @@ impl Application for Halloy { &mut self.theme, ) .map(Message::Dashboard) - } else if let event::Event::CloseRequested = event { - window::close(window::Id::MAIN) + } else if let event::Event::CloseRequested(window) = event { + window::close(window) } else { Task::none() } diff --git a/src/modal/connect_to_server.rs b/src/modal/connect_to_server.rs index 22a0b58d7..22532d7e7 100644 --- a/src/modal/connect_to_server.rs +++ b/src/modal/connect_to_server.rs @@ -45,7 +45,7 @@ pub fn view<'a>(raw: &'a str, config: &config::Server) -> Element<'a, Message> { .spacing(4), ) .spacing(20) - .align_items(iced::Alignment::Center), + .align_x(iced::Alignment::Center), ) .width(Length::Shrink) .style(theme::container::default_banner) diff --git a/src/modal/reload_configuration_error.rs b/src/modal/reload_configuration_error.rs index 45be2a411..1459c9a37 100644 --- a/src/modal/reload_configuration_error.rs +++ b/src/modal/reload_configuration_error.rs @@ -24,7 +24,7 @@ pub fn view<'a>(error: &config::Error) -> Element<'a, Message> { .on_press(Message::Cancel) ] .spacing(20) - .align_items(iced::Alignment::Center), + .align_x(iced::Alignment::Center), ) .width(Length::Shrink) .style(theme::container::error_modal) diff --git a/src/screen/dashboard.rs b/src/screen/dashboard.rs index c7d794f38..e635ac2c9 100644 --- a/src/screen/dashboard.rs +++ b/src/screen/dashboard.rs @@ -13,7 +13,7 @@ use data::user::Nick; use data::{client, environment, history, Config, Server, User, Version}; use iced::widget::pane_grid::{self, PaneGrid}; use iced::widget::{column, container, row, Space}; -use iced::{clipboard, window, Length, Task}; +use iced::{clipboard, padding, window, Length, Task}; use self::command_bar::CommandBar; use self::pane::Pane; @@ -41,7 +41,7 @@ pub enum Message { Sidebar(sidebar::Message), SelectedText(Vec<(f32, String)>), History(history::manager::Message), - Close, + Close(window::Id), DashboardSaved(Result<(), data::dashboard::Error>), CloseHistory, Task(command_bar::Message), @@ -331,8 +331,8 @@ impl Dashboard { Message::History(message) => { self.history.update(message); } - Message::Close => { - return (window::close(window::Id::MAIN), None); + Message::Close(window) => { + return (window::close(window), None); } Message::DashboardSaved(Ok(_)) => { log::info!("dashboard saved"); @@ -637,7 +637,7 @@ impl Dashboard { .push(pane_grid) .width(Length::Fill) .height(Length::Fill) - .padding([height_margin, 0, 0, 0]); + .padding(padding::top(height_margin)); let base = if let Some(command_bar) = self.command_bar.as_ref() { let background = anchored_overlay( @@ -717,7 +717,7 @@ impl Dashboard { .map(move |message| Message::Pane(pane::Message::Buffer(pane, message))) }) .unwrap_or_else(Task::none), - CloseRequested => { + CloseRequested(window) => { let history = self.history.close_all(); let last_changed = self.last_changed; let dashboard = data::Dashboard::from(&*self); @@ -737,7 +737,7 @@ impl Dashboard { } }; - Task::perform(task, |_| Message::Close) + Task::perform(task, move |_| Message::Close(window)) } } } diff --git a/src/screen/dashboard/sidebar.rs b/src/screen/dashboard/sidebar.rs index 10cc4bcdf..2ed6468ff 100644 --- a/src/screen/dashboard/sidebar.rs +++ b/src/screen/dashboard/sidebar.rs @@ -4,7 +4,7 @@ use iced::widget::{ button, center, column, container, horizontal_space, pane_grid, row, scrollable, text, vertical_space, Scrollable, }; -use iced::Length; +use iced::{padding, Length}; use super::pane::Pane; use crate::widget::{context_menu, tooltip, Element}; @@ -137,7 +137,7 @@ impl Sidebar { } } - let mut menu_buttons = row![].spacing(1).padding([0, 0, 4, 0]); + let mut menu_buttons = row![].spacing(1).padding(padding::bottom(4)); if config.buttons.command_bar { let button = button(center(icon::search())) @@ -187,22 +187,23 @@ impl Sidebar { menu_buttons = menu_buttons.push(button_with_tooltip); } - let content = column![Scrollable::with_direction( - column, - scrollable::Direction::Vertical( - iced::widget::scrollable::Properties::default() - .width(0) - .scroller_width(0), - ), - ),]; + let content = + column![ + Scrollable::new(column,).direction(scrollable::Direction::Vertical { + scrollbar: iced::widget::scrollable::Scrollbar::default() + .width(0) + .scroller_width(0), + spacing: None + },), + ]; let body = column![container(content).height(Length::Fill), menu_buttons]; Some( container(body) .height(Length::Fill) - .padding([8, 0, 6, 6]) .center_x(Length::Shrink) + .padding(padding::top(8).bottom(6).left(6)) .max_width(config.width) .into(), ) @@ -266,7 +267,7 @@ fn buffer_button<'a>( .shaping(text::Shaping::Advanced) ] .spacing(8) - .align_items(iced::Alignment::Center), + .align_y(iced::Alignment::Center), Buffer::Channel(_, channel) => row![] .push(horizontal_space().width(3)) .push_maybe(has_unread.then_some(icon::dot().size(6).style(theme::text::info))) @@ -276,7 +277,7 @@ fn buffer_button<'a>( .style(theme::text::primary) .shaping(text::Shaping::Advanced), ) - .align_items(iced::Alignment::Center), + .align_y(iced::Alignment::Center), Buffer::Query(_, nick) => row![] .push(horizontal_space().width(3)) .push_maybe(has_unread.then_some(icon::dot().size(6).style(theme::text::info))) @@ -286,7 +287,7 @@ fn buffer_button<'a>( .style(theme::text::primary) .shaping(text::Shaping::Advanced), ) - .align_items(iced::Alignment::Center), + .align_y(iced::Alignment::Center), }; let base = button(row) diff --git a/src/screen/help.rs b/src/screen/help.rs index 9652ccdbe..ec842baa2 100644 --- a/src/screen/help.rs +++ b/src/screen/help.rs @@ -90,7 +90,7 @@ impl Help { .push(wiki_button) .push(refresh_button), ) - .align_items(iced::Alignment::Center); + .align_x(iced::Alignment::Center); container(content) .align_x(alignment::Horizontal::Center) diff --git a/src/screen/migration.rs b/src/screen/migration.rs index 100ebe433..a0af4a710 100644 --- a/src/screen/migration.rs +++ b/src/screen/migration.rs @@ -96,7 +96,7 @@ impl Migration { .push(refresh_button), ) .width(350) - .align_items(iced::Alignment::Center); + .align_x(iced::Alignment::Center); container(content) .align_x(alignment::Horizontal::Center) diff --git a/src/screen/welcome.rs b/src/screen/welcome.rs index cf46ebb33..4488f3ff5 100644 --- a/src/screen/welcome.rs +++ b/src/screen/welcome.rs @@ -103,7 +103,7 @@ impl Welcome { .push(documentation_button) .push(reload_button), ) - .align_items(iced::Alignment::Center); + .align_x(iced::Alignment::Center); container(content) .align_x(alignment::Horizontal::Center) diff --git a/src/stream.rs b/src/stream.rs index 7934a5597..9c6eeeca9 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -1,7 +1,7 @@ pub use data::stream::{self, *}; use data::{config, server}; -use iced::{subscription, Subscription}; +use iced::Subscription; pub fn run(entry: server::Entry, proxy: Option) -> Subscription { - subscription::run_with_id(entry.server.clone(), stream::run(entry, proxy)) + Subscription::run_with_id(entry.server.clone(), stream::run(entry, proxy)) } diff --git a/src/theme.rs b/src/theme.rs index 975995664..332df4cab 100644 --- a/src/theme.rs +++ b/src/theme.rs @@ -1,5 +1,5 @@ use data::theme::Colors; -use iced::program; +use iced::application; use crate::widget::combo_box; @@ -67,9 +67,9 @@ impl Default for Theme { } } -impl program::DefaultStyle for Theme { - fn default_style(&self) -> program::Appearance { - program::Appearance { +impl application::DefaultStyle for Theme { + fn default_style(&self) -> application::Appearance { + application::Appearance { background_color: self.colors().background.base, text_color: self.colors().text.base, } diff --git a/src/theme/container.rs b/src/theme/container.rs index 7e9c5726a..2a00d4ba3 100644 --- a/src/theme/container.rs +++ b/src/theme/container.rs @@ -1,5 +1,5 @@ use iced::widget::container::{transparent, Catalog, Style, StyleFn}; -use iced::{Background, Border, Color}; +use iced::{border, Background, Border, Color}; use super::Theme; @@ -65,7 +65,7 @@ pub fn pane_header(theme: &Theme) -> Style { Style { background: Some(Background::Color(theme.colors().background.darker)), border: Border { - radius: [4.0, 4.0, 0.0, 0.0].into(), + radius: border::top_left(4).top_right(4), width: 1.0, color: Color::TRANSPARENT, }, diff --git a/src/theme/scrollable.rs b/src/theme/scrollable.rs index 34ebc7110..6d0365a81 100644 --- a/src/theme/scrollable.rs +++ b/src/theme/scrollable.rs @@ -1,7 +1,7 @@ use iced::{ widget::{ container, - scrollable::{Catalog, Scrollbar, Scroller, Status, Style, StyleFn}, + scrollable::{Catalog, Rail, Scroller, Status, Style, StyleFn}, }, Background, Border, Color, Shadow, }; @@ -21,7 +21,7 @@ impl Catalog for Theme { } pub fn primary(theme: &Theme, status: Status) -> Style { - let scrollbar = Scrollbar { + let rail = Rail { background: None, border: Border::default(), scroller: Scroller { @@ -46,15 +46,15 @@ pub fn primary(theme: &Theme, status: Status) -> Style { }, shadow: Shadow::default(), }, - vertical_scrollbar: scrollbar, - horizontal_scrollbar: scrollbar, + vertical_rail: rail, + horizontal_rail: rail, gap: None, }, } } pub fn hidden(_theme: &Theme, status: Status) -> Style { - let scrollbar = Scrollbar { + let rail = Rail { background: None, border: Border::default(), scroller: Scroller { @@ -79,8 +79,8 @@ pub fn hidden(_theme: &Theme, status: Status) -> Style { }, shadow: Shadow::default(), }, - vertical_scrollbar: scrollbar, - horizontal_scrollbar: scrollbar, + vertical_rail: rail, + horizontal_rail: rail, gap: None, }, } diff --git a/src/url.rs b/src/url.rs index 23a9a3677..346af96b2 100644 --- a/src/url.rs +++ b/src/url.rs @@ -46,7 +46,7 @@ pub fn listen() -> Subscription { } } - Subscription::from_recipe(OnUrl) + subscription::from_recipe(OnUrl) } #[cfg(not(target_os = "macos"))] @@ -71,5 +71,5 @@ pub fn listen() -> Subscription { } } - Subscription::from_recipe(Listener) + subscription::from_recipe(Listener) } diff --git a/src/widget/context_menu.rs b/src/widget/context_menu.rs index b476f752b..fe886ee43 100644 --- a/src/widget/context_menu.rs +++ b/src/widget/context_menu.rs @@ -15,7 +15,7 @@ where Message: 'a, T: 'a + Copy, { - let build_menu = |length, view: &dyn Fn(T, Length) -> Element<'a, Message>| { + let build_menu = |length, view: &(dyn Fn(T, Length) -> Element<'a, Message> + 'a)| { container(column( entries.iter().copied().map(|entry| view(entry, length)), )) @@ -232,7 +232,7 @@ pub fn close(f: fn(bool) -> Message) -> Task { } } - Task::widget(Close { + widget::operate(Close { any_closed: false, f, }) diff --git a/src/widget/selectable_text.rs b/src/widget/selectable_text.rs index 92b2af864..80f46a09a 100644 --- a/src/widget/selectable_text.rs +++ b/src/widget/selectable_text.rs @@ -506,7 +506,7 @@ pub fn selected(f: fn(Vec<(f32, String)>) -> Message) - } } - Task::widget(Selected { + widget::operate(Selected { contents: vec![], f, }) diff --git a/src/window.rs b/src/window.rs index fb269bd58..f8cfb2841 100644 --- a/src/window.rs +++ b/src/window.rs @@ -1,6 +1,6 @@ use futures::{stream::BoxStream, Stream, StreamExt}; -pub use iced::window::{close, Id, Settings}; -use iced::{advanced::graphics::futures::subscription, Subscription}; +pub use iced::window::{close, Settings}; +use iced::{advanced::graphics::futures::subscription, Point, Size, Subscription}; use data::window::{self, Event}; @@ -65,7 +65,7 @@ pub fn settings() -> Settings { } pub fn events() -> Subscription { - Subscription::from_recipe(Events) + subscription::from_recipe(Events) } enum State> { @@ -112,12 +112,12 @@ impl subscription::Recipe for Events { event: iced::Event::Window(window_event), status: _, } => match window_event { - iced::window::Event::Moved { x, y } => { - Some(Event::Moved(window::Position::new(x as f32, y as f32))) + iced::window::Event::Moved(Point { x, y }) => { + Some(Event::Moved(window::Position::new(x, y))) + } + iced::window::Event::Resized(Size { width, height }) => { + Some(Event::Resized(window::Size::new(width, height))) } - iced::window::Event::Resized { width, height } => Some(Event::Resized( - window::Size::new(width as f32, height as f32), - )), _ => None, }, _ => None,