Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update iced f2c9b6b2ffc50d67d9789e77cb55eeb2a0ebe470 #687

Merged
merged 3 commits into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
258 changes: 109 additions & 149 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ iced = { version = "0.14.0-dev", default-features = false, features = [
"lazy",
"advanced",
"image",
"multi-window",
] }
log = "0.4.16"
once_cell = "1.18"
Expand Down Expand Up @@ -68,5 +67,5 @@ windows_exe_info = "0.4"
members = ["data", "ipc", "irc", "irc/proto"]

[patch.crates-io]
iced = { git = "https://github.com/iced-rs/iced", rev = "d660fad33d97cf78507c6797b5fe45b3daf47454" }
iced_core = { git = "https://github.com/iced-rs/iced", rev = "d660fad33d97cf78507c6797b5fe45b3daf47454" }
iced = { git = "https://github.com/iced-rs/iced", rev = "f2c9b6b2ffc50d67d9789e77cb55eeb2a0ebe470" }
iced_core = { git = "https://github.com/iced-rs/iced", rev = "f2c9b6b2ffc50d67d9789e77cb55eeb2a0ebe470" }
8 changes: 3 additions & 5 deletions src/appearance/theme.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use iced::application;

use crate::widget::combo_box;

pub use data::appearance::theme::{
Expand Down Expand Up @@ -71,9 +69,9 @@ impl Default for Theme {
}
}

impl application::DefaultStyle for Theme {
fn default_style(&self) -> application::Appearance {
application::Appearance {
impl iced::theme::Base for Theme {
fn base(&self) -> iced::theme::Style {
iced::theme::Style {
background_color: self.colors().general.background,
text_color: self.colors().text.primary,
}
Expand Down
4 changes: 2 additions & 2 deletions src/appearance/theme/text_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub fn primary(theme: &Theme, status: Status) -> Style {
};

match status {
Status::Active | Status::Hovered | Status::Focused => active,
Status::Active | Status::Hovered | Status::Focused { .. } => active,
Status::Disabled => Style {
background: Background::Color(theme.colors().buffer.background_text_input),
placeholder: Color {
Expand All @@ -55,7 +55,7 @@ pub fn error(theme: &Theme, status: Status) -> Style {
let primary = primary(theme, status);

match status {
Status::Active | Status::Hovered | Status::Focused => Style {
Status::Active | Status::Hovered | Status::Focused { .. } => Style {
border: Border {
radius: 4.0.into(),
width: 1.0,
Expand Down
23 changes: 13 additions & 10 deletions src/buffer/scroll_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,18 +574,16 @@ mod keyed {
key: Key,
inner: impl Into<Element<'a, Message>>,
) -> Element<'a, Message> {
#[derive(Default)]
struct State;

decorate(inner)
.operate(
move |_state: &mut State,
move |_state: &mut (),
inner: &Element<'a, Message>,
tree: &mut advanced::widget::Tree,
layout: advanced::Layout<'_>,
renderer: &Renderer,
operation: &mut dyn advanced::widget::Operation<()>| {
operation.custom(&mut (key, layout.bounds()), None);
let mut key = key;
operation.custom(None, layout.bounds(), &mut key);
inner.as_widget().operate(tree, layout, renderer, operation);
},
)
Expand Down Expand Up @@ -619,11 +617,11 @@ mod keyed {
impl Operation<State> for State {
fn scrollable(
&mut self,
_state: &mut dyn widget::operation::Scrollable,
id: Option<&widget::Id>,
bounds: Rectangle,
content_bounds: Rectangle,
_translation: Vector,
_state: &mut dyn widget::operation::Scrollable,
) {
if id == Some(&self.scrollable.clone().into()) {
self.scrollable_bounds = Some(ScrollableBounds {
Expand All @@ -645,13 +643,18 @@ mod keyed {
operate_on_children(self)
}

fn custom(&mut self, state: &mut dyn std::any::Any, _id: Option<&widget::Id>) {
fn custom(
&mut self,
_id: Option<&widget::Id>,
bounds: Rectangle,
state: &mut dyn std::any::Any,
) {
if self.active {
if let Some((key, bounds)) = state.downcast_ref::<(Key, Rectangle)>() {
if let Some(key) = state.downcast_ref::<Key>() {
if self.key == *key {
self.hit_bounds = Some(*bounds);
self.hit_bounds = Some(bounds);
} else if self.hit_bounds.is_none() {
self.prev_bounds = Some(*bounds);
self.prev_bounds = Some(bounds);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub fn setup(is_debug: bool) -> Result<ReceiverStream<Vec<Record>>, Error> {
))
});

if is_debug {
if is_debug || cfg!(feature = "dev") {
io_sink = io_sink.chain(std::io::stdout());
} else {
let log_file = data::log::file()?;
Expand Down
18 changes: 9 additions & 9 deletions src/widget/anchored_overlay.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use iced::advanced::{layout, overlay, renderer, widget, Clipboard, Layout, Shell, Widget};
use iced::{event, mouse, Event, Length, Point, Rectangle, Size, Vector};
use iced::{mouse, Event, Length, Point, Rectangle, Size, Vector};

use super::{Element, Renderer};
use crate::Theme;
Expand Down Expand Up @@ -96,7 +96,7 @@ impl<Message> Widget<Message, Theme, Renderer> for AnchoredOverlay<'_, Message>
.operate(&mut tree.children[0], layout, renderer, operation);
}

fn on_event(
fn update(
&mut self,
tree: &mut widget::Tree,
event: Event,
Expand All @@ -106,8 +106,8 @@ impl<Message> Widget<Message, Theme, Renderer> for AnchoredOverlay<'_, Message>
clipboard: &mut dyn Clipboard,
shell: &mut Shell<'_, Message>,
viewport: &Rectangle,
) -> event::Status {
self.base.as_widget_mut().on_event(
) {
self.base.as_widget_mut().update(
&mut tree.children[0],
event,
layout,
Expand All @@ -116,7 +116,7 @@ impl<Message> Widget<Message, Theme, Renderer> for AnchoredOverlay<'_, Message>
clipboard,
shell,
viewport,
)
);
}

fn mouse_interaction(
Expand Down Expand Up @@ -251,16 +251,16 @@ impl<Message> overlay::Overlay<Message, Theme, Renderer> for Overlay<'_, '_, Mes
.operate(self.tree, layout, renderer, operation);
}

fn on_event(
fn update(
&mut self,
event: Event,
layout: Layout<'_>,
cursor: mouse::Cursor,
renderer: &Renderer,
clipboard: &mut dyn Clipboard,
shell: &mut Shell<'_, Message>,
) -> event::Status {
self.content.as_widget_mut().on_event(
) {
self.content.as_widget_mut().update(
self.tree,
event,
layout,
Expand All @@ -269,7 +269,7 @@ impl<Message> overlay::Overlay<Message, Theme, Renderer> for Overlay<'_, '_, Mes
clipboard,
shell,
&layout.bounds(),
)
);
}

fn mouse_interaction(
Expand Down
6 changes: 2 additions & 4 deletions src/widget/color_picker.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use iced::advanced::renderer::{Quad, Renderer as _};
use iced::widget::{column, container, row};
use iced::{
advanced, border, event, mouse, touch, Color,
advanced, border, mouse, touch, Color,
Length::{self, *},
Point, Rectangle,
};
Expand Down Expand Up @@ -302,7 +302,7 @@ fn picker<'a, Message: 'a>(
let color = data::appearance::theme::to_hsva(color);

decorate(Space::new(width, height))
.on_event(
.update(
move |state: &mut Option<Rectangle>,
_inner: &mut Element<'a, Message>,
_tree: &mut advanced::widget::Tree,
Expand Down Expand Up @@ -371,8 +371,6 @@ fn picker<'a, Message: 'a>(
}
_ => {}
}

event::Status::Ignored
},
)
.draw(
Expand Down
38 changes: 27 additions & 11 deletions src/widget/combo_box.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use iced::advanced::{
use iced::overlay::menu;
use iced::widget::text::LineHeight;
use iced::widget::{text_input, TextInput};
use iced::{event, keyboard, Event, Length, Padding, Rectangle, Vector};
use iced::{keyboard, window, Event, Length, Padding, Rectangle, Vector};

use std::cell::RefCell;
use std::fmt::Display;
Expand Down Expand Up @@ -403,7 +403,7 @@ where
})
}

fn on_event(
fn update(
&mut self,
tree: &mut widget::Tree,
event: Event,
Expand All @@ -413,7 +413,7 @@ where
clipboard: &mut dyn Clipboard,
shell: &mut Shell<'_, Message>,
viewport: &Rectangle,
) -> event::Status {
) {
let menu = tree.state.downcast_mut::<Menu<T>>();

let started_focused = self.state.is_focused();
Expand All @@ -427,7 +427,7 @@ where

// Provide it to the widget
let mut tree = self.state.text_input_tree();
let mut event_status = self.text_input.on_event(
self.text_input.update(
&mut tree,
event.clone(),
layout,
Expand All @@ -439,13 +439,27 @@ where
);
self.state.update_text_input(tree);

if local_shell.is_event_captured() {
shell.capture_event();
}

if let Some(redraw_request) = local_shell.redraw_request() {
match redraw_request {
window::RedrawRequest::NextFrame => {
shell.request_redraw();
}
window::RedrawRequest::At(at) => {
shell.request_redraw_at(at);
}
}
}

// Then finally react to them here
for message in local_messages {
let TextInputEvent::TextChanged(new_value) = message;

if let Some(on_input) = &self.on_input {
shell.publish((on_input)(new_value.clone()));
published_message_to_shell = true;
}

// Couple the filtered options with the `ComboBox`
Expand All @@ -462,6 +476,7 @@ where
);
});
shell.invalidate_layout();
shell.request_redraw();
}

if self.state.is_focused() {
Expand All @@ -488,7 +503,8 @@ where
}
}

event_status = event::Status::Captured;
shell.capture_event();
shell.request_redraw();
}
(keyboard::Key::Named(keyboard::key::Named::ArrowUp), _)
| (keyboard::Key::Named(keyboard::key::Named::Tab), true) => {
Expand All @@ -513,7 +529,8 @@ where
}
}

event_status = event::Status::Captured;
shell.capture_event();
shell.request_redraw();
}
(keyboard::Key::Named(keyboard::key::Named::ArrowDown), _)
| (keyboard::Key::Named(keyboard::key::Named::Tab), false) => {
Expand Down Expand Up @@ -541,7 +558,8 @@ where
}
}

event_status = event::Status::Captured;
shell.capture_event();
shell.request_redraw();
}
_ => {}
}
Expand All @@ -563,7 +581,7 @@ where

// Unfocus the input
let mut tree = state.text_input_tree();
let _ = self.text_input.on_event(
self.text_input.update(
&mut tree,
Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left)),
layout,
Expand All @@ -587,8 +605,6 @@ where
if started_focused != self.state.is_focused() {
shell.invalidate_widgets();
}

event_status
}

fn mouse_interaction(
Expand Down
Loading
Loading