From b4f505853b5ee2576486bc51b912e66999d846f9 Mon Sep 17 00:00:00 2001 From: Lily Hopkins Date: Wed, 1 May 2024 16:15:08 +0100 Subject: [PATCH] fix: resolve problematic moves fixes #143 --- testangel/src/ui/flows/action_component.rs | 2 +- testangel/src/ui/flows/mod.rs | 15 ++++++++++++++- testangel/src/ui/mod.rs | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/testangel/src/ui/flows/action_component.rs b/testangel/src/ui/flows/action_component.rs index 2955bf8..6e1b807 100644 --- a/testangel/src/ui/flows/action_component.rs +++ b/testangel/src/ui/flows/action_component.rs @@ -191,7 +191,7 @@ impl FactoryComponent for ActionComponent { 1 }; sender.output(ActionComponentOutput::MoveStep(*from, to, offset)).unwrap(); - sender.input(ActionComponentInput::ProposedDrop { above: false, below: false, }); + sender.input(ActionComponentInput::ProposedDrop { above: false, below: false }); return true; } false diff --git a/testangel/src/ui/flows/mod.rs b/testangel/src/ui/flows/mod.rs index 532d161..02d9ce5 100644 --- a/testangel/src/ui/flows/mod.rs +++ b/testangel/src/ui/flows/mod.rs @@ -712,9 +712,19 @@ impl Component for FlowsModel { self.needs_saving = true; } - FlowInputs::PasteStep(idx, config) => { + FlowInputs::PasteStep(idx, mut config) => { let flow = self.open_flow.as_mut().unwrap(); let idx = idx.max(0).min(flow.actions.len()); + + // Adjust step just about to paste + for (_param_idx, source) in config.parameter_sources.iter_mut() { + if let ActionParameterSource::FromOutput(from_step, _output_idx) = source { + if *from_step <= idx { + *source = ActionParameterSource::Literal; + } + } + } + log::info!("Pasting step to {}", idx + 1); flow.actions.insert(idx, config); @@ -747,10 +757,13 @@ impl Component for FlowsModel { let current_from = from.current_index(); let step = self.open_flow.as_ref().unwrap().actions[current_from].clone(); sender.input(FlowInputs::CutStep(from)); + + // Establish new position let mut to = (to.current_index() as isize + offset).max(0) as usize; if to > current_from && to > 0 { to -= 1; } + sender.input(FlowInputs::PasteStep(to, step)); } } diff --git a/testangel/src/ui/mod.rs b/testangel/src/ui/mod.rs index e16905d..ed1a45f 100644 --- a/testangel/src/ui/mod.rs +++ b/testangel/src/ui/mod.rs @@ -77,7 +77,7 @@ impl Component for AppModel { set_title: Some(&lang::lookup("app-name")), set_default_width: 800, set_default_height: 600, - set_icon_name: Some("testangel"), + set_icon_name: Some(relm4_icons::icon_names::TESTANGEL), gtk::Box { set_orientation: gtk::Orientation::Vertical,