fix sticky state on Lock Interaction
This commit is contained in:
@@ -39,7 +39,7 @@
|
||||
<rectangle padding="16" gap="8" round="32" color="~color_bg" border="2" border_color="~color_accent" justify_content="center">
|
||||
<div flex_direction="column" gap="8">
|
||||
<div flex_direction="row" gap="4">
|
||||
<TopButton sticky="1" id="top_lock" src="edit/lock_open.svg" tooltip="EDIT_MODE.LOCK_INTERACTION" press="::EditModeToggleLock" />
|
||||
<TopButton sticky="0" id="top_lock" src="edit/lock_open.svg" tooltip="EDIT_MODE.LOCK_INTERACTION" press="::EditModeToggleLock" />
|
||||
<TopButton sticky="1" id="top_grab" src="edit/disable-grab.svg" tooltip="EDIT_MODE.DISABLE_GRAB" press="::EditModeToggleGrab" />
|
||||
<TopButton sticky="0" id="top_pos" src="edit/anchor.svg" tooltip="EDIT_MODE.POSITIONING" press="::EditModeTab pos" />
|
||||
<TopButton sticky="0" id="top_alpha" src="edit/fade.svg" tooltip="EDIT_MODE.OPACITY" press="::EditModeTab alpha" />
|
||||
|
||||
@@ -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