watch controls for edit mode
This commit is contained in:
@@ -34,10 +34,17 @@ use crate::{
|
||||
|
||||
mod lock;
|
||||
mod pos;
|
||||
mod tab;
|
||||
pub(crate) mod tab;
|
||||
|
||||
struct LongPressButtonState {
|
||||
pressed: Instant,
|
||||
pub(super) struct LongPressButtonState {
|
||||
pub(super) pressed: Instant,
|
||||
}
|
||||
impl Default for LongPressButtonState {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
pressed: Instant::now(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct EditModeState {
|
||||
@@ -264,7 +271,7 @@ fn make_edit_panel(app: &mut AppState) -> anyhow::Result<EditModeWrapPanel> {
|
||||
Ok(EventResult::Consumed)
|
||||
}),
|
||||
"::EditModeDeleteRelease" => Box::new(move |_common, _data, app, state| {
|
||||
if state.delete.pressed.elapsed() > Duration::from_secs(2) {
|
||||
if state.delete.pressed.elapsed() < Duration::from_secs(2) {
|
||||
return Ok(EventResult::Pass);
|
||||
}
|
||||
app.tasks.enqueue(TaskType::Overlay(
|
||||
@@ -296,7 +303,7 @@ fn make_edit_panel(app: &mut AppState) -> anyhow::Result<EditModeWrapPanel> {
|
||||
|
||||
panel.state.pos = PositioningHandler::new(&mut panel)?;
|
||||
panel.state.lock = InteractLockHandler::new(&mut panel)?;
|
||||
panel.state.tabs = ButtonPaneTabSwitcher::new(&mut panel)?;
|
||||
panel.state.tabs = ButtonPaneTabSwitcher::new(&mut panel, &["none", "pos", "alpha", "curve"])?;
|
||||
|
||||
set_up_checkbox(&mut panel, "additive_box", cb_assign_additive)?;
|
||||
set_up_slider(&mut panel, "alpha_slider", cb_assign_alpha)?;
|
||||
|
||||
@@ -5,9 +5,8 @@ use wgui::{
|
||||
parser::Fetchable, taffy,
|
||||
};
|
||||
|
||||
use crate::overlays::edit::EditModeWrapPanel;
|
||||
use crate::gui::panel::GuiPanel;
|
||||
|
||||
static TABS: [&str; 4] = ["none", "pos", "alpha", "curve"];
|
||||
static BUTTON_PREFIX: &str = "top_";
|
||||
static PANE_PREFIX: &str = "tab_";
|
||||
|
||||
@@ -19,16 +18,16 @@ struct TabData {
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub(super) struct ButtonPaneTabSwitcher {
|
||||
pub struct ButtonPaneTabSwitcher {
|
||||
tabs: HashMap<&'static str, Rc<TabData>>,
|
||||
active_tab: Option<Rc<TabData>>,
|
||||
}
|
||||
|
||||
impl ButtonPaneTabSwitcher {
|
||||
pub fn new(panel: &mut EditModeWrapPanel) -> anyhow::Result<Self> {
|
||||
pub fn new<S>(panel: &mut GuiPanel<S>, tab_names: &[&'static str]) -> anyhow::Result<Self> {
|
||||
let mut tabs = HashMap::new();
|
||||
|
||||
for tab_name in &TABS {
|
||||
for tab_name in tab_names {
|
||||
let name = format!("{BUTTON_PREFIX}{tab_name}");
|
||||
let button = panel.parser_state.fetch_component_as(&name).ok();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user