Can set stroke and fill on text and shapes (#551)

* Can set stroke and fill on text and shapes

* resend layout on failed update

* text input properly resets on bad input

* support modifying gradients

* can modify gradients in the properties panel

* updated labels

* remove heap allocation in favor of RC

* removed redundent line

* oops
This commit is contained in:
mfish33
2022-02-15 09:04:11 -08:00
committed by Keavon Chambers
parent 2aba0fc06b
commit ee0718ef5d
17 changed files with 286 additions and 33 deletions
+6 -4
View File
@@ -1,3 +1,5 @@
use std::rc::Rc;
use super::layout_message::LayoutTarget;
use crate::message_prelude::*;
@@ -130,18 +132,18 @@ impl WidgetHolder {
#[derive(Clone)]
pub struct WidgetCallback<T> {
pub callback: fn(&T) -> Message,
pub callback: Rc<dyn Fn(&T) -> Message + 'static>,
}
impl<T> WidgetCallback<T> {
pub fn new(callback: fn(&T) -> Message) -> Self {
Self { callback }
pub fn new(callback: impl Fn(&T) -> Message + 'static) -> Self {
Self { callback: Rc::new(callback) }
}
}
impl<T> Default for WidgetCallback<T> {
fn default() -> Self {
Self { callback: |_| Message::NoOp }
Self::new(|_| Message::NoOp)
}
}