remove button exec; add reset button
This commit is contained in:
parent
c0042d7680
commit
76986010ba
3 changed files with 38 additions and 23 deletions
|
|
@ -1,21 +1,20 @@
|
|||
use sfml::{graphics::{CircleShape, Drawable, Font, Shape, Text, Transformable}, system::Vector2f};
|
||||
|
||||
use crate::constants::button::{DEFAULT_BG_COLOR, DEFAULT_TXT_COLOR, FONT_SIZE, PRECISION, RADIUS};
|
||||
use crate::constants::button::{DEFAULT_BG_COLOR, DEFAULT_TXT_COLOR, PRECISION};
|
||||
|
||||
pub struct Button<'a> {
|
||||
background: CircleShape<'a>,
|
||||
text: Text<'a>,
|
||||
pub exec: Box<dyn Fn(u32) -> u32>
|
||||
text: Text<'a>
|
||||
}
|
||||
|
||||
impl<'a> Button<'a> {
|
||||
pub fn new(text: String, font: &'a Font, pos: impl Into<Vector2f>, exec: Box<dyn Fn(u32) -> u32>) -> Self {
|
||||
let mut background = CircleShape::new(RADIUS, PRECISION);
|
||||
background.set_origin((RADIUS, RADIUS));
|
||||
pub fn new(text: String, font: &'a Font, font_size: u32, pos: impl Into<Vector2f>, radius: f32) -> Self {
|
||||
let mut background = CircleShape::new(radius, PRECISION);
|
||||
background.set_origin((radius, radius));
|
||||
background.set_position(pos);
|
||||
background.set_fill_color(DEFAULT_BG_COLOR);
|
||||
|
||||
let mut text = Text::new(&text, font, FONT_SIZE);
|
||||
let mut text = Text::new(&text, font, font_size);
|
||||
text.set_position(background.position());
|
||||
text.set_fill_color(DEFAULT_TXT_COLOR);
|
||||
|
||||
|
|
@ -27,8 +26,7 @@ impl<'a> Button<'a> {
|
|||
|
||||
Button {
|
||||
background,
|
||||
text,
|
||||
exec
|
||||
text
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue