feat(rectangle_tracker): functions for widget and subscription

This commit is contained in:
Michael Aaron Murphy 2023-10-12 13:16:12 +02:00 committed by Michael Murphy
parent 436a5825d7
commit 8c86dae449
2 changed files with 22 additions and 0 deletions

View file

@ -16,6 +16,27 @@ use std::{fmt::Debug, hash::Hash};
pub use iced_style::container::{Appearance, StyleSheet};
pub fn rectangle_tracker<'a, Message, I, T>(
content: T,
id: I,
tx: UnboundedSender<(I, Rectangle)>,
) -> RectangleTrackingContainer<'a, Message, crate::Renderer, I>
where
I: Hash + Copy + Send + Sync + Debug + 'a,
T: Into<Element<'a, Message, crate::Renderer>>,
{
RectangleTrackingContainer::new(content, id, tx)
}
pub fn subscription<
I: 'static + Hash + Copy + Send + Sync + Debug,
R: 'static + Hash + Copy + Send + Sync + Debug + Eq,
>(
id: I,
) -> iced::Subscription<(I, RectangleUpdate<R>)> {
subscription::rectangle_tracker_subscription(id)
}
#[derive(Clone, Debug)]
pub struct RectangleTracker<I> {
tx: UnboundedSender<(I, Rectangle)>,