From 5f9a8ccacf03e0d536519a5169321ad7683830b9 Mon Sep 17 00:00:00 2001 From: Nadim Khemir Date: Sat, 4 Nov 2023 18:22:05 +0100 Subject: [PATCH] ADDED: change arrow direction if box selected has one arrow --- Todo.txt | 3 --- lib/App/Asciio/Actions/Arrow.pm | 25 +++++++++++++++++-------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Todo.txt b/Todo.txt index 2a868f00..ed970dd6 100644 --- a/Todo.txt +++ b/Todo.txt @@ -1,6 +1,3 @@ -buildah run $c -- apt install libdata-compare-perl libdata-compare-perl libdirectory-scratch-structured-perl libeval-context-perl libextutils-pkgconfig-perl libfile-homedir-perl libgtk3-perl libio-prompter-perl libterm-size-any-perl libterm-termkey-perl libtest-block-perl libtermkey-dev libmodule-build-perl - -latest Data::TreeDumper constraints alignement diff --git a/lib/App/Asciio/Actions/Arrow.pm b/lib/App/Asciio/Actions/Arrow.pm index 609d2b14..584fede3 100644 --- a/lib/App/Asciio/Actions/Arrow.pm +++ b/lib/App/Asciio/Actions/Arrow.pm @@ -37,21 +37,30 @@ $self->update_display() if $changes_made ; sub change_arrow_direction { my ($self) = @_ ; -my $changes_made = 0 ; -for (grep {ref $_ eq 'App::Asciio::stripes::section_wirl_arrow'} $self->get_selected_elements(1)) +my @selection = $self->get_selected_elements(1) ; +my @arrows ; + +if (1 == @selection && ref $selection[0] eq 'App::Asciio::stripes::editable_box2') { - $self->create_undo_snapshot() unless $changes_made++ ; - $_->change_section_direction($self->{MOUSE_X} - $_->{X}, $self->{MOUSE_Y} - $_->{Y}) ; + my @connections = $self->get_connections_containing(@selection) ; + @arrows = $connections[0]{CONNECTED} if 1 == @connections ; } -for (grep {ref $_ eq 'App::Asciio::stripes::angled_arrow'} $self->get_selected_elements(1)) +push @arrows, grep {ref $_ eq 'App::Asciio::stripes::angled_arrow'} @selection ; +push @arrows, grep {ref $_ eq 'App::Asciio::stripes::section_wirl_arrow'} @selection ; + +for (@arrows) { - $self->create_undo_snapshot() unless $changes_made++ ; - $_->change_direction() ; + $self->create_undo_snapshot() ; + + $_->change_direction() if ref $_ eq 'App::Asciio::stripes::angled_arrow' ; + + $_->change_section_direction($self->{MOUSE_X} - $_->{X}, $self->{MOUSE_Y} - $_->{Y}) + if ref $_ eq 'App::Asciio::stripes::section_wirl_arrow' ; } -$self->update_display() if $changes_made ; +$self->update_display() if @arrows ; } #----------------------------------------------------------------------------------------------