theme: Use boxed functions instead fn pointers (#99)
This is more general, and necessary if the custom theming is dynamically generated. Iced's builtin theme also uses `Box`ed `Fn`, or `Rc` where clone is required, so this seems reasonable. Only `Text` is left using `fn`, since it needs to be `Copy`. Hopefully that can be changed in Iced at some point. `::custom` methods are added to make these variants a little more convenient to construct. This replaces a couple `From` implementations, which are potentially problematic with a generic.
This commit is contained in:
parent
c878e24465
commit
b85c504d72
11 changed files with 65 additions and 63 deletions
|
|
@ -207,7 +207,7 @@ impl<'a> Icon<'a> {
|
|||
|
||||
fn svg_element<Message: 'static>(&self, handle: svg::Handle) -> Element<'static, Message> {
|
||||
svg::Svg::<Renderer>::new(handle)
|
||||
.style(self.style)
|
||||
.style(self.style.clone())
|
||||
.width(self.width.unwrap_or(Length::Units(self.size)))
|
||||
.height(self.height.unwrap_or(Length::Units(self.size)))
|
||||
.content_fit(self.content_fit)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue