Skip to content

Commit

Permalink
fix: resolve problematic moves
Browse files Browse the repository at this point in the history
fixes #143
  • Loading branch information
lilopkins committed May 1, 2024
1 parent d6dd1fb commit b4f5058
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion testangel/src/ui/flows/action_component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 14 additions & 1 deletion testangel/src/ui/flows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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));
}
}
Expand Down
2 changes: 1 addition & 1 deletion testangel/src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit b4f5058

Please sign in to comment.