summaryrefslogtreecommitdiffstats
path: root/widget/src/button.rs
diff options
context:
space:
mode:
Diffstat (limited to 'widget/src/button.rs')
-rw-r--r--widget/src/button.rs35
1 files changed, 17 insertions, 18 deletions
diff --git a/widget/src/button.rs b/widget/src/button.rs
index 8ebc9657..384a3156 100644
--- a/widget/src/button.rs
+++ b/widget/src/button.rs
@@ -119,9 +119,9 @@ where
/// Sets the style variant of this [`Button`].
pub fn style(
mut self,
- style: <Renderer::Theme as StyleSheet>::Style,
+ style: impl Into<<Renderer::Theme as StyleSheet>::Style>,
) -> Self {
- self.style = style;
+ self.style = style.into();
self
}
}
@@ -146,7 +146,7 @@ where
}
fn diff(&self, tree: &mut Tree) {
- tree.diff_children(std::slice::from_ref(&self.content))
+ tree.diff_children(std::slice::from_ref(&self.content));
}
fn width(&self) -> Length {
@@ -159,19 +159,17 @@ where
fn layout(
&self,
+ tree: &mut Tree,
renderer: &Renderer,
limits: &layout::Limits,
) -> layout::Node {
- layout(
- renderer,
- limits,
- self.width,
- self.height,
- self.padding,
- |renderer, limits| {
- self.content.as_widget().layout(renderer, limits)
- },
- )
+ layout(limits, self.width, self.height, self.padding, |limits| {
+ self.content.as_widget().layout(
+ &mut tree.children[0],
+ renderer,
+ limits,
+ )
+ })
}
fn operate(
@@ -181,7 +179,7 @@ where
renderer: &Renderer,
operation: &mut dyn Operation<Message>,
) {
- operation.container(None, &mut |operation| {
+ operation.container(None, layout.bounds(), &mut |operation| {
self.content.as_widget().operate(
&mut tree.children[0],
layout.children().next().unwrap(),
@@ -200,6 +198,7 @@ where
renderer: &Renderer,
clipboard: &mut dyn Clipboard,
shell: &mut Shell<'_, Message>,
+ viewport: &Rectangle,
) -> event::Status {
if let event::Status::Captured = self.content.as_widget_mut().on_event(
&mut tree.children[0],
@@ -209,6 +208,7 @@ where
renderer,
clipboard,
shell,
+ viewport,
) {
return event::Status::Captured;
}
@@ -424,17 +424,16 @@ where
}
/// Computes the layout of a [`Button`].
-pub fn layout<Renderer>(
- renderer: &Renderer,
+pub fn layout(
limits: &layout::Limits,
width: Length,
height: Length,
padding: Padding,
- layout_content: impl FnOnce(&Renderer, &layout::Limits) -> layout::Node,
+ layout_content: impl FnOnce(&layout::Limits) -> layout::Node,
) -> layout::Node {
let limits = limits.width(width).height(height);
- let mut content = layout_content(renderer, &limits.pad(padding));
+ let mut content = layout_content(&limits.pad(padding));
let padding = padding.fit(content.size(), limits.max());
let size = limits.pad(padding).resolve(content.size()).pad(padding);