use std::sync::Arc; use glam::Vec2; use taffy::{AlignItems, JustifyContent, prelude::length}; use crate::{ animation::{Animation, AnimationEasing}, drawing::{self, Color}, event::{EventListener, WidgetCallback}, layout::{Layout, WidgetID}, renderer_vk::text::{FontWeight, TextStyle}, widget::{ rectangle::{Rectangle, RectangleParams}, text::{TextLabel, TextParams}, util::WLength, }, }; pub struct Params<'a> { pub text: &'a str, pub color: drawing::Color, pub size: Vec2, pub text_style: TextStyle, } impl Default for Params<'_> { fn default() -> Self { Self { text: "Text", color: drawing::Color::new(1.0, 1.0, 1.0, 1.0), size: Vec2::new(128.0, 32.0), text_style: TextStyle::default(), } } } pub struct Button { color: drawing::Color, pub body: WidgetID, // Rectangle pub text_id: WidgetID, // Text text_node: taffy::NodeId, } impl Button { pub fn set_text<'a, C>(&self, callback_data: &mut C, text: &str) where C: WidgetCallback<'a>, { callback_data.call_on_widget(self.text_id, |label: &mut TextLabel| { label.set_text(text); }); callback_data.mark_redraw(); callback_data.mark_dirty(self.text_node); } } fn anim_hover_in(button: Arc