summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/src/element.rs4
-rw-r--r--core/src/image.rs85
-rw-r--r--core/src/layout/node.rs13
-rw-r--r--core/src/lib.rs2
-rw-r--r--core/src/overlay.rs2
-rw-r--r--core/src/overlay/element.rs4
-rw-r--r--core/src/overlay/group.rs2
-rw-r--r--core/src/rectangle.rs56
-rw-r--r--core/src/renderer/null.rs27
-rw-r--r--core/src/svg.rs69
-rw-r--r--core/src/widget.rs2
-rw-r--r--core/src/widget/operation.rs191
-rw-r--r--core/src/widget/operation/focusable.rs30
13 files changed, 406 insertions, 81 deletions
diff --git a/core/src/element.rs b/core/src/element.rs
index 385d8295..6ebb8a15 100644
--- a/core/src/element.rs
+++ b/core/src/element.rs
@@ -304,7 +304,7 @@ where
tree: &mut Tree,
layout: Layout<'_>,
renderer: &Renderer,
- operation: &mut dyn widget::Operation<()>,
+ operation: &mut dyn widget::Operation,
) {
self.widget.operate(tree, layout, renderer, operation);
}
@@ -440,7 +440,7 @@ where
state: &mut Tree,
layout: Layout<'_>,
renderer: &Renderer,
- operation: &mut dyn widget::Operation<()>,
+ operation: &mut dyn widget::Operation,
) {
self.element
.widget
diff --git a/core/src/image.rs b/core/src/image.rs
index 82ecdd0f..f985636a 100644
--- a/core/src/image.rs
+++ b/core/src/image.rs
@@ -7,6 +7,73 @@ use rustc_hash::FxHasher;
use std::hash::{Hash, Hasher};
use std::path::{Path, PathBuf};
+/// A raster image that can be drawn.
+#[derive(Debug, Clone, PartialEq)]
+pub struct Image<H = Handle> {
+ /// The handle of the image.
+ pub handle: H,
+
+ /// The filter method of the image.
+ pub filter_method: FilterMethod,
+
+ /// The rotation to be applied to the image; on its center.
+ pub rotation: Radians,
+
+ /// The opacity of the image.
+ ///
+ /// 0 means transparent. 1 means opaque.
+ pub opacity: f32,
+
+ /// If set to `true`, the image will be snapped to the pixel grid.
+ ///
+ /// This can avoid graphical glitches, specially when using
+ /// [`FilterMethod::Nearest`].
+ pub snap: bool,
+}
+
+impl Image<Handle> {
+ /// Creates a new [`Image`] with the given handle.
+ pub fn new(handle: impl Into<Handle>) -> Self {
+ Self {
+ handle: handle.into(),
+ filter_method: FilterMethod::default(),
+ rotation: Radians(0.0),
+ opacity: 1.0,
+ snap: false,
+ }
+ }
+
+ /// Sets the filter method of the [`Image`].
+ pub fn filter_method(mut self, filter_method: FilterMethod) -> Self {
+ self.filter_method = filter_method;
+ self
+ }
+
+ /// Sets the rotation of the [`Image`].
+ pub fn rotation(mut self, rotation: impl Into<Radians>) -> Self {
+ self.rotation = rotation.into();
+ self
+ }
+
+ /// Sets the opacity of the [`Image`].
+ pub fn opacity(mut self, opacity: impl Into<f32>) -> Self {
+ self.opacity = opacity.into();
+ self
+ }
+
+ /// Sets whether the [`Image`] should be snapped to the pixel grid.
+ pub fn snap(mut self, snap: bool) -> Self {
+ self.snap = snap;
+ self
+ }
+}
+
+impl From<&Handle> for Image {
+ fn from(handle: &Handle) -> Self {
+ Image::new(handle.clone())
+ }
+}
+
/// A handle of some image data.
#[derive(Clone, PartialEq, Eq)]
pub enum Handle {
@@ -101,6 +168,12 @@ where
}
}
+impl From<&Handle> for Handle {
+ fn from(value: &Handle) -> Self {
+ value.clone()
+ }
+}
+
impl std::fmt::Debug for Handle {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
@@ -166,14 +239,6 @@ pub trait Renderer: crate::Renderer {
/// Returns the dimensions of an image for the given [`Handle`].
fn measure_image(&self, handle: &Self::Handle) -> Size<u32>;
- /// Draws an image with the given [`Handle`] and inside the provided
- /// `bounds`.
- fn draw_image(
- &mut self,
- handle: Self::Handle,
- filter_method: FilterMethod,
- bounds: Rectangle,
- rotation: Radians,
- opacity: f32,
- );
+ /// Draws an [`Image`] inside the provided `bounds`.
+ fn draw_image(&mut self, image: Image<Self::Handle>, bounds: Rectangle);
}
diff --git a/core/src/layout/node.rs b/core/src/layout/node.rs
index 5743a9bd..0c0f90fb 100644
--- a/core/src/layout/node.rs
+++ b/core/src/layout/node.rs
@@ -103,12 +103,13 @@ impl Node {
}
/// Translates the [`Node`] by the given translation.
- pub fn translate(self, translation: impl Into<Vector>) -> Self {
- let translation = translation.into();
+ pub fn translate(mut self, translation: impl Into<Vector>) -> Self {
+ self.translate_mut(translation);
+ self
+ }
- Self {
- bounds: self.bounds + translation,
- ..self
- }
+ /// Translates the [`Node`] by the given translation.
+ pub fn translate_mut(&mut self, translation: impl Into<Vector>) {
+ self.bounds = self.bounds + translation.into();
}
}
diff --git a/core/src/lib.rs b/core/src/lib.rs
index 40a288e5..df599f45 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -57,6 +57,7 @@ pub use element::Element;
pub use event::Event;
pub use font::Font;
pub use gradient::Gradient;
+pub use image::Image;
pub use layout::Layout;
pub use length::Length;
pub use overlay::Overlay;
@@ -69,6 +70,7 @@ pub use rotation::Rotation;
pub use shadow::Shadow;
pub use shell::Shell;
pub use size::Size;
+pub use svg::Svg;
pub use text::Text;
pub use theme::Theme;
pub use transformation::Transformation;
diff --git a/core/src/overlay.rs b/core/src/overlay.rs
index 3b79970e..f09de831 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<()>,
+ _operation: &mut dyn widget::Operation,
) {
}
diff --git a/core/src/overlay/element.rs b/core/src/overlay/element.rs
index 61e75e8a..32e987a3 100644
--- a/core/src/overlay/element.rs
+++ b/core/src/overlay/element.rs
@@ -92,7 +92,7 @@ where
&mut self,
layout: Layout<'_>,
renderer: &Renderer,
- operation: &mut dyn widget::Operation<()>,
+ operation: &mut dyn widget::Operation,
) {
self.overlay.operate(layout, renderer, operation);
}
@@ -144,7 +144,7 @@ where
&mut self,
layout: Layout<'_>,
renderer: &Renderer,
- operation: &mut dyn widget::Operation<()>,
+ operation: &mut dyn widget::Operation,
) {
self.content.operate(layout, renderer, operation);
}
diff --git a/core/src/overlay/group.rs b/core/src/overlay/group.rs
index cd12eac9..6541d311 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<()>,
+ 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/rectangle.rs b/core/src/rectangle.rs
index 155cfcbf..cff33991 100644
--- a/core/src/rectangle.rs
+++ b/core/src/rectangle.rs
@@ -47,6 +47,62 @@ impl Rectangle<f32> {
}
}
+ /// Creates a new square [`Rectangle`] with the center at the origin and
+ /// with the given radius.
+ pub fn with_radius(radius: f32) -> Self {
+ Self {
+ x: -radius,
+ y: -radius,
+ width: radius * 2.0,
+ height: radius * 2.0,
+ }
+ }
+
+ /// Creates a new axis-aligned [`Rectangle`] from the given vertices; returning the
+ /// rotation in [`Radians`] that must be applied to the axis-aligned [`Rectangle`]
+ /// to obtain the desired result.
+ pub fn with_vertices(
+ top_left: Point,
+ top_right: Point,
+ bottom_left: Point,
+ ) -> (Rectangle, Radians) {
+ let width = (top_right.x - top_left.x).hypot(top_right.y - top_left.y);
+
+ let height =
+ (bottom_left.x - top_left.x).hypot(bottom_left.y - top_left.y);
+
+ let rotation =
+ (top_right.y - top_left.y).atan2(top_right.x - top_left.x);
+
+ let rotation = if rotation < 0.0 {
+ 2.0 * std::f32::consts::PI + rotation
+ } else {
+ rotation
+ };
+
+ let position = {
+ let center = Point::new(
+ (top_right.x + bottom_left.x) / 2.0,
+ (top_right.y + bottom_left.y) / 2.0,
+ );
+
+ let rotation = -rotation - std::f32::consts::PI * 2.0;
+
+ Point::new(
+ center.x + (top_left.x - center.x) * rotation.cos()
+ - (top_left.y - center.y) * rotation.sin(),
+ center.y
+ + (top_left.x - center.x) * rotation.sin()
+ + (top_left.y - center.y) * rotation.cos(),
+ )
+ };
+
+ (
+ Rectangle::new(position, Size::new(width, height)),
+ Radians(rotation),
+ )
+ }
+
/// Returns the [`Point`] at the center of the [`Rectangle`].
pub fn center(&self) -> Point {
Point::new(self.center_x(), self.center_y())
diff --git a/core/src/renderer/null.rs b/core/src/renderer/null.rs
index 5c7513c6..e3a07280 100644
--- a/core/src/renderer/null.rs
+++ b/core/src/renderer/null.rs
@@ -1,11 +1,10 @@
use crate::alignment;
-use crate::image;
+use crate::image::{self, Image};
use crate::renderer::{self, Renderer};
use crate::svg;
use crate::text::{self, Text};
use crate::{
- Background, Color, Font, Pixels, Point, Radians, Rectangle, Size,
- Transformation,
+ Background, Color, Font, Pixels, Point, Rectangle, Size, Transformation,
};
impl Renderer for () {
@@ -178,21 +177,13 @@ impl text::Editor for () {
}
impl image::Renderer for () {
- type Handle = ();
+ type Handle = image::Handle;
fn measure_image(&self, _handle: &Self::Handle) -> Size<u32> {
Size::default()
}
- fn draw_image(
- &mut self,
- _handle: Self::Handle,
- _filter_method: image::FilterMethod,
- _bounds: Rectangle,
- _rotation: Radians,
- _opacity: f32,
- ) {
- }
+ fn draw_image(&mut self, _image: Image, _bounds: Rectangle) {}
}
impl svg::Renderer for () {
@@ -200,13 +191,5 @@ impl svg::Renderer for () {
Size::default()
}
- fn draw_svg(
- &mut self,
- _handle: svg::Handle,
- _color: Option<Color>,
- _bounds: Rectangle,
- _rotation: Radians,
- _opacity: f32,
- ) {
- }
+ fn draw_svg(&mut self, _svg: svg::Svg, _bounds: Rectangle) {}
}
diff --git a/core/src/svg.rs b/core/src/svg.rs
index 946b8156..ac19b223 100644
--- a/core/src/svg.rs
+++ b/core/src/svg.rs
@@ -7,6 +7,66 @@ use std::hash::{Hash, Hasher as _};
use std::path::PathBuf;
use std::sync::Arc;
+/// A raster image that can be drawn.
+#[derive(Debug, Clone, PartialEq)]
+pub struct Svg<H = Handle> {
+ /// The handle of the [`Svg`].
+ pub handle: H,
+
+ /// The [`Color`] filter to be applied to the [`Svg`].
+ ///
+ /// If some [`Color`] is set, the whole [`Svg`] will be
+ /// painted with it—ignoring any intrinsic colors.
+ ///
+ /// This can be useful for coloring icons programmatically
+ /// (e.g. with a theme).
+ pub color: Option<Color>,
+
+ /// The rotation to be applied to the image; on its center.
+ pub rotation: Radians,
+
+ /// The opacity of the [`Svg`].
+ ///
+ /// 0 means transparent. 1 means opaque.
+ pub opacity: f32,
+}
+
+impl Svg<Handle> {
+ /// Creates a new [`Svg`] with the given handle.
+ pub fn new(handle: impl Into<Handle>) -> Self {
+ Self {
+ handle: handle.into(),
+ color: None,
+ rotation: Radians(0.0),
+ opacity: 1.0,
+ }
+ }
+
+ /// Sets the [`Color`] filter of the [`Svg`].
+ pub fn color(mut self, color: impl Into<Color>) -> Self {
+ self.color = Some(color.into());
+ self
+ }
+
+ /// Sets the rotation of the [`Svg`].
+ pub fn rotation(mut self, rotation: impl Into<Radians>) -> Self {
+ self.rotation = rotation.into();
+ self
+ }
+
+ /// Sets the opacity of the [`Svg`].
+ pub fn opacity(mut self, opacity: impl Into<f32>) -> Self {
+ self.opacity = opacity.into();
+ self
+ }
+}
+
+impl From<&Handle> for Svg {
+ fn from(handle: &Handle) -> Self {
+ Svg::new(handle.clone())
+ }
+}
+
/// A handle of Svg data.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Handle {
@@ -95,12 +155,5 @@ pub trait Renderer: crate::Renderer {
fn measure_svg(&self, handle: &Handle) -> Size<u32>;
/// Draws an SVG with the given [`Handle`], an optional [`Color`] filter, and inside the provided `bounds`.
- fn draw_svg(
- &mut self,
- handle: Handle,
- color: Option<Color>,
- bounds: Rectangle,
- rotation: Radians,
- opacity: f32,
- );
+ fn draw_svg(&mut self, svg: Svg, bounds: Rectangle);
}
diff --git a/core/src/widget.rs b/core/src/widget.rs
index 08cfa55b..c5beea54 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<()>,
+ _operation: &mut dyn Operation,
) {
}
diff --git a/core/src/widget/operation.rs b/core/src/widget/operation.rs
index 3e4ed618..741e1a5f 100644
--- a/core/src/widget/operation.rs
+++ b/core/src/widget/operation.rs
@@ -12,11 +12,12 @@ use crate::{Rectangle, Vector};
use std::any::Any;
use std::fmt;
+use std::marker::PhantomData;
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>: Send {
+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
@@ -53,6 +54,46 @@ pub trait Operation<T>: Send {
}
}
+impl<T, O> Operation<O> for Box<T>
+where
+ T: Operation<O> + ?Sized,
+{
+ fn container(
+ &mut self,
+ id: Option<&Id>,
+ bounds: Rectangle,
+ operate_on_children: &mut dyn FnMut(&mut dyn Operation<O>),
+ ) {
+ self.as_mut().container(id, bounds, operate_on_children);
+ }
+
+ fn focusable(&mut self, state: &mut dyn Focusable, id: Option<&Id>) {
+ self.as_mut().focusable(state, id);
+ }
+
+ fn scrollable(
+ &mut self,
+ state: &mut dyn Scrollable,
+ id: Option<&Id>,
+ bounds: Rectangle,
+ translation: Vector,
+ ) {
+ self.as_mut().scrollable(state, id, bounds, translation);
+ }
+
+ fn text_input(&mut self, state: &mut dyn TextInput, id: Option<&Id>) {
+ self.as_mut().text_input(state, id);
+ }
+
+ fn custom(&mut self, state: &mut dyn Any, id: Option<&Id>) {
+ self.as_mut().custom(state, id);
+ }
+
+ fn finish(&self) -> Outcome<O> {
+ self.as_ref().finish()
+ }
+}
+
/// The result of an [`Operation`].
pub enum Outcome<T> {
/// The [`Operation`] produced no result.
@@ -78,9 +119,62 @@ where
}
}
+/// Wraps the [`Operation`] in a black box, erasing its returning type.
+pub fn black_box<'a, T, O>(
+ operation: &'a mut dyn Operation<T>,
+) -> impl Operation<O> + 'a
+where
+ T: 'a,
+{
+ struct BlackBox<'a, T> {
+ operation: &'a mut dyn Operation<T>,
+ }
+
+ impl<'a, T, O> Operation<O> for BlackBox<'a, T> {
+ fn container(
+ &mut self,
+ id: Option<&Id>,
+ bounds: Rectangle,
+ operate_on_children: &mut dyn FnMut(&mut dyn Operation<O>),
+ ) {
+ self.operation.container(id, bounds, &mut |operation| {
+ operate_on_children(&mut BlackBox { operation });
+ });
+ }
+
+ fn focusable(&mut self, state: &mut dyn Focusable, id: Option<&Id>) {
+ self.operation.focusable(state, id);
+ }
+
+ fn scrollable(
+ &mut self,
+ state: &mut dyn Scrollable,
+ id: Option<&Id>,
+ bounds: Rectangle,
+ translation: Vector,
+ ) {
+ self.operation.scrollable(state, id, bounds, translation);
+ }
+
+ fn text_input(&mut self, state: &mut dyn TextInput, id: Option<&Id>) {
+ self.operation.text_input(state, id);
+ }
+
+ fn custom(&mut self, state: &mut dyn Any, id: Option<&Id>) {
+ self.operation.custom(state, id);
+ }
+
+ fn finish(&self) -> Outcome<O> {
+ Outcome::None
+ }
+ }
+
+ BlackBox { operation }
+}
+
/// Maps the output of an [`Operation`] using the given function.
pub fn map<A, B>(
- operation: Box<dyn Operation<A>>,
+ operation: impl Operation<A>,
f: impl Fn(A) -> B + Send + Sync + 'static,
) -> impl Operation<B>
where
@@ -88,13 +182,14 @@ where
B: 'static,
{
#[allow(missing_debug_implementations)]
- struct Map<A, B> {
- operation: Box<dyn Operation<A>>,
+ struct Map<O, A, B> {
+ operation: O,
f: Arc<dyn Fn(A) -> B + Send + Sync>,
}
- impl<A, B> Operation<B> for Map<A, B>
+ impl<O, A, B> Operation<B> for Map<O, A, B>
where
+ O: Operation<A>,
A: 'static,
B: 'static,
{
@@ -155,10 +250,7 @@ where
let Self { operation, .. } = self;
- MapRef {
- operation: operation.as_mut(),
- }
- .container(id, bounds, operate_on_children);
+ MapRef { operation }.container(id, bounds, operate_on_children);
}
fn focusable(&mut self, state: &mut dyn Focusable, id: Option<&Id>) {
@@ -201,6 +293,87 @@ where
}
}
+/// Chains the output of an [`Operation`] with the provided function to
+/// build a new [`Operation`].
+pub fn chain<A, B, O>(
+ operation: impl Operation<A> + 'static,
+ f: fn(A) -> O,
+) -> impl Operation<B>
+where
+ A: 'static,
+ B: Send + 'static,
+ O: Operation<B> + 'static,
+{
+ struct Chain<T, O, A, B>
+ where
+ T: Operation<A>,
+ O: Operation<B>,
+ {
+ operation: T,
+ next: fn(A) -> O,
+ _result: PhantomData<B>,
+ }
+
+ impl<T, O, A, B> Operation<B> for Chain<T, O, A, B>
+ where
+ T: Operation<A> + 'static,
+ O: Operation<B> + 'static,
+ A: 'static,
+ B: Send + 'static,
+ {
+ fn container(
+ &mut self,
+ id: Option<&Id>,
+ bounds: Rectangle,
+ operate_on_children: &mut dyn FnMut(&mut dyn Operation<B>),
+ ) {
+ self.operation.container(id, bounds, &mut |operation| {
+ operate_on_children(&mut black_box(operation));
+ });
+ }
+
+ fn focusable(&mut self, state: &mut dyn Focusable, id: Option<&Id>) {
+ self.operation.focusable(state, id);
+ }
+
+ fn scrollable(
+ &mut self,
+ state: &mut dyn Scrollable,
+ id: Option<&Id>,
+ bounds: Rectangle,
+ translation: crate::Vector,
+ ) {
+ self.operation.scrollable(state, id, bounds, translation);
+ }
+
+ fn text_input(&mut self, state: &mut dyn TextInput, id: Option<&Id>) {
+ self.operation.text_input(state, id);
+ }
+
+ fn custom(&mut self, state: &mut dyn std::any::Any, id: Option<&Id>) {
+ self.operation.custom(state, id);
+ }
+
+ fn finish(&self) -> Outcome<B> {
+ match self.operation.finish() {
+ Outcome::None => Outcome::None,
+ Outcome::Some(value) => {
+ Outcome::Chain(Box::new((self.next)(value)))
+ }
+ Outcome::Chain(operation) => {
+ Outcome::Chain(Box::new(chain(operation, self.next)))
+ }
+ }
+ }
+ }
+
+ Chain {
+ operation,
+ next: f,
+ _result: PhantomData,
+ }
+}
+
/// Produces an [`Operation`] that applies the given [`Operation`] to the
/// children of a container with the given [`Id`].
pub fn scope<T: 'static>(
diff --git a/core/src/widget/operation/focusable.rs b/core/src/widget/operation/focusable.rs
index 68c22faa..0a6f2e96 100644
--- a/core/src/widget/operation/focusable.rs
+++ b/core/src/widget/operation/focusable.rs
@@ -1,5 +1,5 @@
//! Operate on widgets that can be focused.
-use crate::widget::operation::{Operation, Outcome};
+use crate::widget::operation::{self, Operation, Outcome};
use crate::widget::Id;
use crate::Rectangle;
@@ -58,19 +58,12 @@ pub fn focus<T>(target: Id) -> impl Operation<T> {
/// Produces an [`Operation`] that generates a [`Count`] and chains it with the
/// provided function to build a new [`Operation`].
-pub fn count<T, O>(f: fn(Count) -> O) -> impl Operation<T>
-where
- O: Operation<T> + 'static,
-{
- struct CountFocusable<O> {
+pub fn count() -> impl Operation<Count> {
+ struct CountFocusable {
count: Count,
- next: fn(Count) -> O,
}
- impl<T, O> Operation<T> for CountFocusable<O>
- where
- O: Operation<T> + 'static,
- {
+ impl Operation<Count> for CountFocusable {
fn focusable(&mut self, state: &mut dyn Focusable, _id: Option<&Id>) {
if state.is_focused() {
self.count.focused = Some(self.count.total);
@@ -83,26 +76,25 @@ where
&mut self,
_id: Option<&Id>,
_bounds: Rectangle,
- operate_on_children: &mut dyn FnMut(&mut dyn Operation<T>),
+ operate_on_children: &mut dyn FnMut(&mut dyn Operation<Count>),
) {
operate_on_children(self);
}
- fn finish(&self) -> Outcome<T> {
- Outcome::Chain(Box::new((self.next)(self.count)))
+ fn finish(&self) -> Outcome<Count> {
+ Outcome::Some(self.count)
}
}
CountFocusable {
count: Count::default(),
- next: f,
}
}
/// Produces an [`Operation`] that searches for the current focused widget, and
/// - if found, focuses the previous focusable widget.
/// - if not found, focuses the last focusable widget.
-pub fn focus_previous<T>() -> impl Operation<T> {
+pub fn focus_previous() -> impl Operation {
struct FocusPrevious {
count: Count,
current: usize,
@@ -136,13 +128,13 @@ pub fn focus_previous<T>() -> impl Operation<T> {
}
}
- count(|count| FocusPrevious { count, current: 0 })
+ operation::chain(count(), |count| FocusPrevious { count, current: 0 })
}
/// Produces an [`Operation`] that searches for the current focused widget, and
/// - if found, focuses the next focusable widget.
/// - if not found, focuses the first focusable widget.
-pub fn focus_next<T>() -> impl Operation<T> {
+pub fn focus_next() -> impl Operation {
struct FocusNext {
count: Count,
current: usize,
@@ -170,7 +162,7 @@ pub fn focus_next<T>() -> impl Operation<T> {
}
}
- count(|count| FocusNext { count, current: 0 })
+ operation::chain(count(), |count| FocusNext { count, current: 0 })
}
/// Produces an [`Operation`] that searches for the current focused widget