refactor: add optional parameter for layout offset and bounds for button handlers

Buttons are often used for toggling popups, so something allowing more straightforward positioning is important.
This commit is contained in:
Ashley Wulber 2025-05-23 12:40:10 -04:00 committed by Michael Murphy
parent b61a7ebd5f
commit 1fce5df160
7 changed files with 165 additions and 70 deletions

View file

@ -44,12 +44,14 @@ use iced_core::{Length, Padding};
use std::borrow::Cow;
/// A button with a custom element for its content.
pub fn custom<'a, Message>(content: impl Into<crate::Element<'a, Message>>) -> Button<'a, Message> {
pub fn custom<'a, Message: Clone + 'a>(
content: impl Into<crate::Element<'a, Message>>,
) -> Button<'a, Message> {
Button::new(content.into())
}
/// An image button which may contain any widget as its content.
pub fn custom_image_button<'a, Message>(
pub fn custom_image_button<'a, Message: Clone + 'a>(
content: impl Into<crate::Element<'a, Message>>,
on_remove: Option<Message>,
) -> Button<'a, Message> {