Rename pop widget to sensor 📡
This commit is contained in:
parent
c46600a69a
commit
57c628839a
5 changed files with 31 additions and 28 deletions
|
|
@ -10,7 +10,7 @@ use iced::animation;
|
||||||
use iced::time::{Instant, milliseconds};
|
use iced::time::{Instant, milliseconds};
|
||||||
use iced::widget::{
|
use iced::widget::{
|
||||||
button, container, float, grid, horizontal_space, image, mouse_area,
|
button, container, float, grid, horizontal_space, image, mouse_area,
|
||||||
opaque, pop, scrollable, stack,
|
opaque, scrollable, sensor, stack,
|
||||||
};
|
};
|
||||||
use iced::window;
|
use iced::window;
|
||||||
use iced::{
|
use iced::{
|
||||||
|
|
@ -257,7 +257,7 @@ fn card<'a>(
|
||||||
.style(button::text)
|
.style(button::text)
|
||||||
.into()
|
.into()
|
||||||
} else {
|
} else {
|
||||||
pop(card)
|
sensor(card)
|
||||||
.on_show(|_| Message::ImagePoppedIn(metadata.id))
|
.on_show(|_| Message::ImagePoppedIn(metadata.id))
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use iced::highlighter;
|
||||||
use iced::time::{self, Instant, milliseconds};
|
use iced::time::{self, Instant, milliseconds};
|
||||||
use iced::widget::{
|
use iced::widget::{
|
||||||
self, button, center_x, container, horizontal_space, hover, image,
|
self, button, center_x, container, horizontal_space, hover, image,
|
||||||
markdown, pop, right, row, scrollable, text_editor, toggler,
|
markdown, right, row, scrollable, sensor, text_editor, toggler,
|
||||||
};
|
};
|
||||||
use iced::window;
|
use iced::window;
|
||||||
use iced::{
|
use iced::{
|
||||||
|
|
@ -267,7 +267,7 @@ impl<'a> markdown::Viewer<'a, Message> for CustomViewer<'a> {
|
||||||
)
|
)
|
||||||
.into()
|
.into()
|
||||||
} else {
|
} else {
|
||||||
pop(horizontal_space())
|
sensor(horizontal_space())
|
||||||
.key_ref(url.as_str())
|
.key_ref(url.as_str())
|
||||||
.delay(milliseconds(500))
|
.delay(milliseconds(500))
|
||||||
.on_show(|_size| Message::ImageShown(url.clone()))
|
.on_show(|_size| Message::ImageShown(url.clone()))
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ use crate::text_input::{self, TextInput};
|
||||||
use crate::toggler::{self, Toggler};
|
use crate::toggler::{self, Toggler};
|
||||||
use crate::tooltip::{self, Tooltip};
|
use crate::tooltip::{self, Tooltip};
|
||||||
use crate::vertical_slider::{self, VerticalSlider};
|
use crate::vertical_slider::{self, VerticalSlider};
|
||||||
use crate::{Column, Grid, MouseArea, Pin, Pop, Row, Space, Stack, Themer};
|
use crate::{Column, Grid, MouseArea, Pin, Row, Sensor, Space, Stack, Themer};
|
||||||
|
|
||||||
use std::borrow::Borrow;
|
use std::borrow::Borrow;
|
||||||
use std::ops::RangeInclusive;
|
use std::ops::RangeInclusive;
|
||||||
|
|
@ -990,18 +990,20 @@ where
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new [`Pop`] widget.
|
/// Creates a new [`Sensor`] widget.
|
||||||
|
///
|
||||||
|
/// A [`Sensor`] widget can generate messages when its contents are shown,
|
||||||
|
/// hidden, or resized.
|
||||||
///
|
///
|
||||||
/// A [`Pop`] widget can generate messages when it pops in and out of view.
|
|
||||||
/// It can even notify you with anticipation at a given distance!
|
/// It can even notify you with anticipation at a given distance!
|
||||||
pub fn pop<'a, Message, Theme, Renderer>(
|
pub fn sensor<'a, Message, Theme, Renderer>(
|
||||||
content: impl Into<Element<'a, Message, Theme, Renderer>>,
|
content: impl Into<Element<'a, Message, Theme, Renderer>>,
|
||||||
) -> Pop<'a, (), Message, Theme, Renderer>
|
) -> Sensor<'a, (), Message, Theme, Renderer>
|
||||||
where
|
where
|
||||||
Renderer: core::Renderer,
|
Renderer: core::Renderer,
|
||||||
Message: Clone,
|
Message: Clone,
|
||||||
{
|
{
|
||||||
Pop::new(content)
|
Sensor::new(content)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new [`Scrollable`] with the provided content.
|
/// Creates a new [`Scrollable`] with the provided content.
|
||||||
|
|
|
||||||
|
|
@ -26,12 +26,12 @@ pub mod keyed;
|
||||||
pub mod overlay;
|
pub mod overlay;
|
||||||
pub mod pane_grid;
|
pub mod pane_grid;
|
||||||
pub mod pick_list;
|
pub mod pick_list;
|
||||||
pub mod pop;
|
|
||||||
pub mod progress_bar;
|
pub mod progress_bar;
|
||||||
pub mod radio;
|
pub mod radio;
|
||||||
pub mod row;
|
pub mod row;
|
||||||
pub mod rule;
|
pub mod rule;
|
||||||
pub mod scrollable;
|
pub mod scrollable;
|
||||||
|
pub mod sensor;
|
||||||
pub mod slider;
|
pub mod slider;
|
||||||
pub mod table;
|
pub mod table;
|
||||||
pub mod text;
|
pub mod text;
|
||||||
|
|
@ -74,8 +74,6 @@ pub use pick_list::PickList;
|
||||||
#[doc(no_inline)]
|
#[doc(no_inline)]
|
||||||
pub use pin::Pin;
|
pub use pin::Pin;
|
||||||
#[doc(no_inline)]
|
#[doc(no_inline)]
|
||||||
pub use pop::Pop;
|
|
||||||
#[doc(no_inline)]
|
|
||||||
pub use progress_bar::ProgressBar;
|
pub use progress_bar::ProgressBar;
|
||||||
#[doc(no_inline)]
|
#[doc(no_inline)]
|
||||||
pub use radio::Radio;
|
pub use radio::Radio;
|
||||||
|
|
@ -86,6 +84,8 @@ pub use rule::Rule;
|
||||||
#[doc(no_inline)]
|
#[doc(no_inline)]
|
||||||
pub use scrollable::Scrollable;
|
pub use scrollable::Scrollable;
|
||||||
#[doc(no_inline)]
|
#[doc(no_inline)]
|
||||||
|
pub use sensor::Sensor;
|
||||||
|
#[doc(no_inline)]
|
||||||
pub use slider::Slider;
|
pub use slider::Slider;
|
||||||
#[doc(no_inline)]
|
#[doc(no_inline)]
|
||||||
pub use space::Space;
|
pub use space::Space;
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ use crate::core::{
|
||||||
///
|
///
|
||||||
/// It can even notify you with anticipation at a given distance!
|
/// It can even notify you with anticipation at a given distance!
|
||||||
#[allow(missing_debug_implementations)]
|
#[allow(missing_debug_implementations)]
|
||||||
pub struct Pop<
|
pub struct Sensor<
|
||||||
'a,
|
'a,
|
||||||
Key,
|
Key,
|
||||||
Message,
|
Message,
|
||||||
|
|
@ -32,12 +32,12 @@ pub struct Pop<
|
||||||
delay: Duration,
|
delay: Duration,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, Message, Theme, Renderer> Pop<'a, (), Message, Theme, Renderer>
|
impl<'a, Message, Theme, Renderer> Sensor<'a, (), Message, Theme, Renderer>
|
||||||
where
|
where
|
||||||
Message: Clone,
|
Message: Clone,
|
||||||
Renderer: core::Renderer,
|
Renderer: core::Renderer,
|
||||||
{
|
{
|
||||||
/// Creates a new [`Pop`] widget with the given content.
|
/// Creates a new [`Sensor`] widget with the given content.
|
||||||
pub fn new(
|
pub fn new(
|
||||||
content: impl Into<Element<'a, Message, Theme, Renderer>>,
|
content: impl Into<Element<'a, Message, Theme, Renderer>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
|
@ -53,7 +53,8 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, Key, Message, Theme, Renderer> Pop<'a, Key, Message, Theme, Renderer>
|
impl<'a, Key, Message, Theme, Renderer>
|
||||||
|
Sensor<'a, Key, Message, Theme, Renderer>
|
||||||
where
|
where
|
||||||
Message: Clone,
|
Message: Clone,
|
||||||
Key: self::Key,
|
Key: self::Key,
|
||||||
|
|
@ -84,17 +85,17 @@ where
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the key of the [`Pop`] widget, for continuity.
|
/// Sets the key of the [`Sensor`] widget, for continuity.
|
||||||
///
|
///
|
||||||
/// If the key changes, the [`Pop`] widget will trigger again.
|
/// If the key changes, the [`Sensor`] widget will trigger again.
|
||||||
pub fn key<K>(
|
pub fn key<K>(
|
||||||
self,
|
self,
|
||||||
key: K,
|
key: K,
|
||||||
) -> Pop<'a, impl self::Key, Message, Theme, Renderer>
|
) -> Sensor<'a, impl self::Key, Message, Theme, Renderer>
|
||||||
where
|
where
|
||||||
K: Clone + PartialEq + 'static,
|
K: Clone + PartialEq + 'static,
|
||||||
{
|
{
|
||||||
Pop {
|
Sensor {
|
||||||
content: self.content,
|
content: self.content,
|
||||||
key: OwnedKey(key),
|
key: OwnedKey(key),
|
||||||
on_show: self.on_show,
|
on_show: self.on_show,
|
||||||
|
|
@ -105,18 +106,18 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the key of the [`Pop`] widget, for continuity; using a reference.
|
/// Sets the key of the [`Sensor`], for continuity; using a reference.
|
||||||
///
|
///
|
||||||
/// If the key changes, the [`Pop`] widget will trigger again.
|
/// If the key changes, the [`Sensor`] will trigger again.
|
||||||
pub fn key_ref<K>(
|
pub fn key_ref<K>(
|
||||||
self,
|
self,
|
||||||
key: &'a K,
|
key: &'a K,
|
||||||
) -> Pop<'a, &'a K, Message, Theme, Renderer>
|
) -> Sensor<'a, &'a K, Message, Theme, Renderer>
|
||||||
where
|
where
|
||||||
K: ToOwned + PartialEq<K::Owned> + ?Sized,
|
K: ToOwned + PartialEq<K::Owned> + ?Sized,
|
||||||
K::Owned: 'static,
|
K::Owned: 'static,
|
||||||
{
|
{
|
||||||
Pop {
|
Sensor {
|
||||||
content: self.content,
|
content: self.content,
|
||||||
key,
|
key,
|
||||||
on_show: self.on_show,
|
on_show: self.on_show,
|
||||||
|
|
@ -160,7 +161,7 @@ struct State<Key> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Key, Message, Theme, Renderer> Widget<Message, Theme, Renderer>
|
impl<Key, Message, Theme, Renderer> Widget<Message, Theme, Renderer>
|
||||||
for Pop<'_, Key, Message, Theme, Renderer>
|
for Sensor<'_, Key, Message, Theme, Renderer>
|
||||||
where
|
where
|
||||||
Key: self::Key,
|
Key: self::Key,
|
||||||
Message: Clone,
|
Message: Clone,
|
||||||
|
|
@ -368,7 +369,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, Key, Message, Theme, Renderer>
|
impl<'a, Key, Message, Theme, Renderer>
|
||||||
From<Pop<'a, Key, Message, Theme, Renderer>>
|
From<Sensor<'a, Key, Message, Theme, Renderer>>
|
||||||
for Element<'a, Message, Theme, Renderer>
|
for Element<'a, Message, Theme, Renderer>
|
||||||
where
|
where
|
||||||
Message: Clone + 'a,
|
Message: Clone + 'a,
|
||||||
|
|
@ -376,7 +377,7 @@ where
|
||||||
Renderer: core::Renderer + 'a,
|
Renderer: core::Renderer + 'a,
|
||||||
Theme: 'a,
|
Theme: 'a,
|
||||||
{
|
{
|
||||||
fn from(pop: Pop<'a, Key, Message, Theme, Renderer>) -> Self {
|
fn from(pop: Sensor<'a, Key, Message, Theme, Renderer>) -> Self {
|
||||||
Element::new(pop)
|
Element::new(pop)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue