summaryrefslogtreecommitdiffstats
path: root/widget/src/pane_grid
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--widget/src/pane_grid.rs22
-rw-r--r--widget/src/pane_grid/content.rs12
-rw-r--r--widget/src/pane_grid/title_bar.rs10
3 files changed, 22 insertions, 22 deletions
diff --git a/widget/src/pane_grid.rs b/widget/src/pane_grid.rs
index bdeb4250..beac0bd8 100644
--- a/widget/src/pane_grid.rs
+++ b/widget/src/pane_grid.rs
@@ -110,7 +110,7 @@ pub struct PaneGrid<
on_click: Option<Box<dyn Fn(Pane) -> Message + 'a>>,
on_drag: Option<Box<dyn Fn(DragEvent) -> Message + 'a>>,
on_resize: Option<(f32, Box<dyn Fn(ResizeEvent) -> Message + 'a>)>,
- style: Style<Theme>,
+ style: Style<'a, Theme>,
}
impl<'a, Message, Theme, Renderer> PaneGrid<'a, Message, Theme, Renderer>
@@ -126,7 +126,7 @@ where
view: impl Fn(Pane, &'a T, bool) -> Content<'a, Message, Theme, Renderer>,
) -> Self
where
- Theme: DefaultStyle,
+ Theme: DefaultStyle + 'a,
{
let contents = if let Some((pane, pane_state)) =
state.maximized.and_then(|pane| {
@@ -158,7 +158,7 @@ where
on_click: None,
on_drag: None,
on_resize: None,
- style: Theme::default_style(),
+ style: Box::new(Theme::default_style),
}
}
@@ -218,8 +218,8 @@ where
}
/// Sets the style of the [`PaneGrid`].
- pub fn style(mut self, style: fn(&Theme) -> Appearance) -> Self {
- self.style = style;
+ pub fn style(mut self, style: impl Fn(&Theme) -> Appearance + 'a) -> Self {
+ self.style = Box::new(style);
self
}
@@ -1146,23 +1146,23 @@ pub struct Line {
}
/// The style of a [`PaneGrid`].
-pub type Style<Theme> = fn(&Theme) -> Appearance;
+pub type Style<'a, Theme> = Box<dyn Fn(&Theme) -> Appearance + 'a>;
/// The default style of a [`PaneGrid`].
pub trait DefaultStyle {
/// Returns the default style of a [`PaneGrid`].
- fn default_style() -> Style<Self>;
+ fn default_style(&self) -> Appearance;
}
impl DefaultStyle for Theme {
- fn default_style() -> Style<Self> {
- default
+ fn default_style(&self) -> Appearance {
+ default(self)
}
}
impl DefaultStyle for Appearance {
- fn default_style() -> Style<Self> {
- |appearance| *appearance
+ fn default_style(&self) -> Appearance {
+ *self
}
}
diff --git a/widget/src/pane_grid/content.rs b/widget/src/pane_grid/content.rs
index aecec777..98f4f99a 100644
--- a/widget/src/pane_grid/content.rs
+++ b/widget/src/pane_grid/content.rs
@@ -24,7 +24,7 @@ pub struct Content<
{
title_bar: Option<TitleBar<'a, Message, Theme, Renderer>>,
body: Element<'a, Message, Theme, Renderer>,
- style: container::Style<Theme>,
+ style: container::Style<'a, Theme>,
}
impl<'a, Message, Theme, Renderer> Content<'a, Message, Theme, Renderer>
@@ -34,12 +34,12 @@ where
/// Creates a new [`Content`] with the provided body.
pub fn new(body: impl Into<Element<'a, Message, Theme, Renderer>>) -> Self
where
- Theme: container::DefaultStyle,
+ Theme: container::DefaultStyle + 'a,
{
Self {
title_bar: None,
body: body.into(),
- style: Theme::default_style(),
+ style: Box::new(Theme::default_style),
}
}
@@ -55,9 +55,9 @@ where
/// Sets the style of the [`Content`].
pub fn style(
mut self,
- style: fn(&Theme, container::Status) -> container::Appearance,
+ style: impl Fn(&Theme, container::Status) -> container::Appearance + 'a,
) -> Self {
- self.style = style.into();
+ self.style = Box::new(style);
self
}
}
@@ -403,7 +403,7 @@ impl<'a, T, Message, Theme, Renderer> From<T>
for Content<'a, Message, Theme, Renderer>
where
T: Into<Element<'a, Message, Theme, Renderer>>,
- Theme: container::DefaultStyle,
+ Theme: container::DefaultStyle + 'a,
Renderer: crate::core::Renderer,
{
fn from(element: T) -> Self {
diff --git a/widget/src/pane_grid/title_bar.rs b/widget/src/pane_grid/title_bar.rs
index 37f0f160..8dfea6e3 100644
--- a/widget/src/pane_grid/title_bar.rs
+++ b/widget/src/pane_grid/title_bar.rs
@@ -25,7 +25,7 @@ pub struct TitleBar<
controls: Option<Element<'a, Message, Theme, Renderer>>,
padding: Padding,
always_show_controls: bool,
- style: container::Style<Theme>,
+ style: container::Style<'a, Theme>,
}
impl<'a, Message, Theme, Renderer> TitleBar<'a, Message, Theme, Renderer>
@@ -37,14 +37,14 @@ where
content: impl Into<Element<'a, Message, Theme, Renderer>>,
) -> Self
where
- Theme: container::DefaultStyle,
+ Theme: container::DefaultStyle + 'a,
{
Self {
content: content.into(),
controls: None,
padding: Padding::ZERO,
always_show_controls: false,
- style: Theme::default_style(),
+ style: Box::new(Theme::default_style),
}
}
@@ -66,9 +66,9 @@ where
/// Sets the style of the [`TitleBar`].
pub fn style(
mut self,
- style: fn(&Theme, container::Status) -> container::Appearance,
+ style: impl Fn(&Theme, container::Status) -> container::Appearance + 'a,
) -> Self {
- self.style = style.into();
+ self.style = Box::new(style);
self
}