fix sticky state on Lock Interaction
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
use std::rc::Rc;
|
||||
|
||||
use anyhow::Context;
|
||||
use glam::FloatExt;
|
||||
use wgui::{
|
||||
animation::{Animation, AnimationEasing},
|
||||
components::button::ComponentButton,
|
||||
event::CallbackDataCommon,
|
||||
layout::WidgetID,
|
||||
parser::Fetchable,
|
||||
@@ -15,6 +18,7 @@ pub(super) struct InteractLockHandler {
|
||||
id: WidgetID,
|
||||
color: wgui::drawing::Color,
|
||||
interactable: bool,
|
||||
button: Option<Rc<ComponentButton>>,
|
||||
}
|
||||
|
||||
impl InteractLockHandler {
|
||||
@@ -27,10 +31,13 @@ impl InteractLockHandler {
|
||||
.get_as::<WidgetRectangle>(id)
|
||||
.context("Element with id=\"shadow\" must be a <rectangle>")?;
|
||||
|
||||
let button = panel.parser_state.fetch_component_as("top_lock")?;
|
||||
|
||||
Ok(Self {
|
||||
id,
|
||||
color: shadow_rect.params.color,
|
||||
interactable: true,
|
||||
button: Some(button),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -42,6 +49,10 @@ impl InteractLockHandler {
|
||||
.get_as::<WidgetRectangle>(self.id)
|
||||
.unwrap(); // can only fail if set_up_rect has issues
|
||||
|
||||
if let Some(button) = self.button.as_ref() {
|
||||
button.set_sticky_state(common, !interactable);
|
||||
}
|
||||
|
||||
let globals = common.state.globals.get();
|
||||
if interactable {
|
||||
set_anim_color(&mut rect, 0.0, self.color, globals.defaults.danger_color);
|
||||
@@ -60,6 +71,9 @@ impl InteractLockHandler {
|
||||
let rect_color = self.color;
|
||||
|
||||
self.interactable = !self.interactable;
|
||||
if let Some(button) = self.button.as_ref() {
|
||||
button.set_sticky_state(common, !self.interactable);
|
||||
}
|
||||
|
||||
let anim = if self.interactable {
|
||||
Animation::new(
|
||||
|
||||
Reference in New Issue
Block a user