summaryrefslogtreecommitdiffstats
path: root/core/src
diff options
context:
space:
mode:
Diffstat (limited to 'core/src')
-rw-r--r--core/src/element.rs61
-rw-r--r--core/src/overlay.rs2
-rw-r--r--core/src/overlay/element.rs60
-rw-r--r--core/src/overlay/group.rs2
-rw-r--r--core/src/widget.rs2
-rw-r--r--core/src/widget/operation.rs10
-rw-r--r--core/src/window/settings/windows.rs5
7 files changed, 15 insertions, 127 deletions
diff --git a/core/src/element.rs b/core/src/element.rs
index 7d918a2e..385d8295 100644
--- a/core/src/element.rs
+++ b/core/src/element.rs
@@ -10,7 +10,6 @@ use crate::{
Widget,
};
-use std::any::Any;
use std::borrow::Borrow;
/// A generic [`Widget`].
@@ -305,63 +304,9 @@ where
tree: &mut Tree,
layout: Layout<'_>,
renderer: &Renderer,
- operation: &mut dyn widget::Operation<B>,
+ operation: &mut dyn widget::Operation<()>,
) {
- struct MapOperation<'a, B> {
- operation: &'a mut dyn widget::Operation<B>,
- }
-
- impl<'a, T, B> widget::Operation<T> for MapOperation<'a, B> {
- fn container(
- &mut self,
- id: Option<&widget::Id>,
- bounds: Rectangle,
- operate_on_children: &mut dyn FnMut(
- &mut dyn widget::Operation<T>,
- ),
- ) {
- self.operation.container(id, bounds, &mut |operation| {
- operate_on_children(&mut MapOperation { operation });
- });
- }
-
- fn focusable(
- &mut self,
- state: &mut dyn widget::operation::Focusable,
- id: Option<&widget::Id>,
- ) {
- self.operation.focusable(state, id);
- }
-
- fn scrollable(
- &mut self,
- state: &mut dyn widget::operation::Scrollable,
- id: Option<&widget::Id>,
- bounds: Rectangle,
- translation: Vector,
- ) {
- self.operation.scrollable(state, id, bounds, translation);
- }
-
- fn text_input(
- &mut self,
- state: &mut dyn widget::operation::TextInput,
- id: Option<&widget::Id>,
- ) {
- self.operation.text_input(state, id);
- }
-
- fn custom(&mut self, state: &mut dyn Any, id: Option<&widget::Id>) {
- self.operation.custom(state, id);
- }
- }
-
- self.widget.operate(
- tree,
- layout,
- renderer,
- &mut MapOperation { operation },
- );
+ self.widget.operate(tree, layout, renderer, operation);
}
fn on_event(
@@ -495,7 +440,7 @@ where
state: &mut Tree,
layout: Layout<'_>,
renderer: &Renderer,
- operation: &mut dyn widget::Operation<Message>,
+ operation: &mut dyn widget::Operation<()>,
) {
self.element
.widget
diff --git a/core/src/overlay.rs b/core/src/overlay.rs
index 3a57fe16..16f867da 100644
--- a/core/src/overlay.rs
+++ b/core/src/overlay.rs
@@ -41,7 +41,7 @@ where
&mut self,
_layout: Layout<'_>,
_renderer: &Renderer,
- _operation: &mut dyn widget::Operation<Message>,
+ _operation: &mut dyn widget::Operation<()>,
) {
}
diff --git a/core/src/overlay/element.rs b/core/src/overlay/element.rs
index 695b88b3..61e75e8a 100644
--- a/core/src/overlay/element.rs
+++ b/core/src/overlay/element.rs
@@ -5,9 +5,7 @@ use crate::layout;
use crate::mouse;
use crate::renderer;
use crate::widget;
-use crate::{Clipboard, Layout, Point, Rectangle, Shell, Size, Vector};
-
-use std::any::Any;
+use crate::{Clipboard, Layout, Point, Rectangle, Shell, Size};
/// A generic [`Overlay`].
#[allow(missing_debug_implementations)]
@@ -94,7 +92,7 @@ where
&mut self,
layout: Layout<'_>,
renderer: &Renderer,
- operation: &mut dyn widget::Operation<Message>,
+ operation: &mut dyn widget::Operation<()>,
) {
self.overlay.operate(layout, renderer, operation);
}
@@ -146,59 +144,9 @@ where
&mut self,
layout: Layout<'_>,
renderer: &Renderer,
- operation: &mut dyn widget::Operation<B>,
+ operation: &mut dyn widget::Operation<()>,
) {
- struct MapOperation<'a, B> {
- operation: &'a mut dyn widget::Operation<B>,
- }
-
- impl<'a, T, B> widget::Operation<T> for MapOperation<'a, B> {
- fn container(
- &mut self,
- id: Option<&widget::Id>,
- bounds: Rectangle,
- operate_on_children: &mut dyn FnMut(
- &mut dyn widget::Operation<T>,
- ),
- ) {
- self.operation.container(id, bounds, &mut |operation| {
- operate_on_children(&mut MapOperation { operation });
- });
- }
-
- fn focusable(
- &mut self,
- state: &mut dyn widget::operation::Focusable,
- id: Option<&widget::Id>,
- ) {
- self.operation.focusable(state, id);
- }
-
- fn scrollable(
- &mut self,
- state: &mut dyn widget::operation::Scrollable,
- id: Option<&widget::Id>,
- bounds: Rectangle,
- translation: Vector,
- ) {
- self.operation.scrollable(state, id, bounds, translation);
- }
-
- fn text_input(
- &mut self,
- state: &mut dyn widget::operation::TextInput,
- id: Option<&widget::Id>,
- ) {
- self.operation.text_input(state, id);
- }
-
- fn custom(&mut self, state: &mut dyn Any, id: Option<&widget::Id>) {
- self.operation.custom(state, id);
- }
- }
-
- self.content
- .operate(layout, renderer, &mut MapOperation { operation });
+ self.content.operate(layout, renderer, operation);
}
fn on_event(
diff --git a/core/src/overlay/group.rs b/core/src/overlay/group.rs
index 7e4bebd0..cd12eac9 100644
--- a/core/src/overlay/group.rs
+++ b/core/src/overlay/group.rs
@@ -132,7 +132,7 @@ where
&mut self,
layout: Layout<'_>,
renderer: &Renderer,
- operation: &mut dyn widget::Operation<Message>,
+ operation: &mut dyn widget::Operation<()>,
) {
operation.container(None, layout.bounds(), &mut |operation| {
self.children.iter_mut().zip(layout.children()).for_each(
diff --git a/core/src/widget.rs b/core/src/widget.rs
index b02e3a4f..0d12deba 100644
--- a/core/src/widget.rs
+++ b/core/src/widget.rs
@@ -105,7 +105,7 @@ where
_state: &mut Tree,
_layout: Layout<'_>,
_renderer: &Renderer,
- _operation: &mut dyn Operation<Message>,
+ _operation: &mut dyn Operation<()>,
) {
}
diff --git a/core/src/widget/operation.rs b/core/src/widget/operation.rs
index b91cf9ac..3e4ed618 100644
--- a/core/src/widget/operation.rs
+++ b/core/src/widget/operation.rs
@@ -12,11 +12,11 @@ use crate::{Rectangle, Vector};
use std::any::Any;
use std::fmt;
-use std::rc::Rc;
+use std::sync::Arc;
/// A piece of logic that can traverse the widget tree of an application in
/// order to query or update some widget state.
-pub trait Operation<T> {
+pub trait Operation<T>: Send {
/// Operates on a widget that contains other widgets.
///
/// The `operate_on_children` function can be called to return control to
@@ -81,7 +81,7 @@ where
/// Maps the output of an [`Operation`] using the given function.
pub fn map<A, B>(
operation: Box<dyn Operation<A>>,
- f: impl Fn(A) -> B + 'static,
+ f: impl Fn(A) -> B + Send + Sync + 'static,
) -> impl Operation<B>
where
A: 'static,
@@ -90,7 +90,7 @@ where
#[allow(missing_debug_implementations)]
struct Map<A, B> {
operation: Box<dyn Operation<A>>,
- f: Rc<dyn Fn(A) -> B>,
+ f: Arc<dyn Fn(A) -> B + Send + Sync>,
}
impl<A, B> Operation<B> for Map<A, B>
@@ -197,7 +197,7 @@ where
Map {
operation,
- f: Rc::new(f),
+ f: Arc::new(f),
}
}
diff --git a/core/src/window/settings/windows.rs b/core/src/window/settings/windows.rs
index d3bda259..88fe2fbd 100644
--- a/core/src/window/settings/windows.rs
+++ b/core/src/window/settings/windows.rs
@@ -1,12 +1,8 @@
//! Platform specific settings for Windows.
-use raw_window_handle::RawWindowHandle;
/// The platform specific window settings of an application.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct PlatformSpecific {
- /// Parent window
- pub parent: Option<RawWindowHandle>,
-
/// Drag and drop support
pub drag_and_drop: bool,
@@ -17,7 +13,6 @@ pub struct PlatformSpecific {
impl Default for PlatformSpecific {
fn default() -> Self {
Self {
- parent: None,
drag_and_drop: true,
skip_taskbar: false,
}