@@ -21,7 +21,6 @@ use App::Asciio::GTK::Asciio::stripes::editable_exec_box ;
2121use App::Asciio::GTK::Asciio::stripes::editable_box2 ;
2222use App::Asciio::GTK::Asciio::stripes::rhombus ;
2323use App::Asciio::GTK::Asciio::stripes::ellipse ;
24-
2524use App::Asciio::GTK::Asciio::stripes::editable_arrow2 ;
2625use App::Asciio::GTK::Asciio::stripes::wirl_arrow ;
2726use App::Asciio::GTK::Asciio::stripes::angled_arrow ;
@@ -264,11 +263,11 @@ for my $element (@elements)
264263 ! exists $selected_elements {$_ -> {CONNECTEE }}
265264 }
266265 $self -> get_possible_connections($element ) ;
267-
266+
268267 $self -> add_connections(@new_connections ) ;
269268
270269 # handle box element
271- for my $connection ($self -> get_connected ($element ))
270+ for my $connection ($self -> get_connections_with_connectee ($element ))
272271 {
273272 # move connected with connectees
274273 if (exists $selected_elements {$connection -> {CONNECTED }})
@@ -297,10 +296,9 @@ for my $element (@elements)
297296 # move them relatively to their previous position
298297 if ($connection -> {CONNECTED } == $other_connection -> {CONNECTED })
299298 {
300- my ($new_connector ) = # in characters relative to element origin
301- $other_connection -> {CONNECTED }-> get_named_connection($other_connection -> {CONNECTOR }{NAME }) ;
299+ my ($named_connection ) = $other_connection -> {CONNECTED }-> get_named_connection($other_connection -> {CONNECTOR }{NAME }) ;
302300
303- $other_connection -> {CONNECTOR } = $new_connector ;
301+ $other_connection -> {CONNECTOR } = $named_connection ;
304302 $other_connection -> {FIXED }++ ;
305303 }
306304 }
@@ -329,64 +327,65 @@ my ($x_offset, $y_offset, undef, undef, $resized_connector_name) =
329327$selected_element -> {X } += $x_offset ;
330328$selected_element -> {Y } += $y_offset ;
331329
332- # handle connections
333330if ($self -> is_connected($selected_element ))
334331 {
332+ # handle connections for arrows
333+
335334 # disconnect current connections
336335 $self -> delete_connections_containing($selected_element ) ;
336+ $self -> connect_elements($selected_element ) ; # connect to new elements if any
337337 }
338-
339- $self -> connect_elements($selected_element ) ; # connect to new elements if any
340-
341- for my $connection ($self -> get_connected($selected_element ))
338+ else
342339 {
343- # all connection where the selected element is the connectee
344-
345- my ($new_connection ) = # in characters relative to element origin
346- $selected_element -> get_named_connection($connection -> {CONNECTION }{NAME }) ;
347-
348- if (defined $new_connection )
340+ # handle connections for non arrows
341+ for my $connection ($self -> get_connections_with_connectee($selected_element ))
349342 {
350- my ($x_offset , $y_offset , $width , $height , $new_connector ) =
351- $connection -> {CONNECTED }-> move_connector
352- (
353- $connection -> {CONNECTOR }{NAME },
354- $new_connection -> {X } - $connection -> {CONNECTION }{X },
355- $new_connection -> {Y }- $connection -> {CONNECTION }{Y }
356- ) ;
357-
358- $connection -> {CONNECTED }{X } += $x_offset ;
359- $connection -> {CONNECTED }{Y } += $y_offset ;
360-
361- # the connection point has also changed
362- $connection -> {CONNECTOR } = $new_connector ;
363- $connection -> {CONNECTION } = $new_connection ;
364-
365- $connection -> {FIXED }++ ;
343+ my ($named_connection ) = $selected_element -> get_named_connection($connection -> {CONNECTION }{NAME }) ;
344+ # {X => ..., Y => ..., NAME => same_as_apssed as argumnent} ;
366345
367- # find the other connectors belonging to this connected
368- for my $other_connection (grep { ! $_ -> {FIXED }} @{$self -> {CONNECTIONS }})
346+ if (defined $named_connection )
369347 {
370- # move them relatively to their previous position
371- if ($connection -> {CONNECTED } == $other_connection -> {CONNECTED })
348+ # move arrow connector to match the element connection
349+ my ($x_offset , $y_offset , $width , $height , $new_connector ) =
350+ $connection -> {CONNECTED }-> move_connector
351+ (
352+ $connection -> {CONNECTOR }{NAME },
353+ $named_connection -> {X } - $connection -> {CONNECTION }{X },
354+ $named_connection -> {Y }- $connection -> {CONNECTION }{Y }
355+ ) ;
356+
357+ $connection -> {CONNECTED }{X } += $x_offset ;
358+ $connection -> {CONNECTED }{Y } += $y_offset ;
359+
360+ # the connection point has also changed
361+ $connection -> {CONNECTOR } = $new_connector ;
362+ $connection -> {CONNECTION } = $named_connection ;
363+
364+ $connection -> {FIXED }++ ;
365+
366+ # find the other connectors belonging to this arrow
367+ for my $other_connection (grep { ! $_ -> {FIXED }} @{$self -> {CONNECTIONS }})
372368 {
373- my ($new_connector ) = # in characters relative to element origin
374- $other_connection -> {CONNECTED }-> get_named_connection($other_connection -> {CONNECTOR }{NAME }) ;
369+ # move them relatively to their previous position
370+ if ($connection -> {CONNECTED } == $other_connection -> {CONNECTED })
371+ {
372+ my ($named_connection ) = $other_connection -> {CONNECTED }-> get_named_connection($other_connection -> {CONNECTOR }{NAME }) ;
373+
374+ $other_connection -> {CONNECTOR } = $named_connection ;
375+ $other_connection -> {FIXED }++ ;
376+ }
377+ }
375378
376- $other_connection -> {CONNECTOR } = $new_connector ;
377- $other_connection -> {FIXED }++ ;
379+ for my $connection (@{$self -> {CONNECTIONS }})
380+ {
381+ delete $connection -> {FIXED } ;
378382 }
379383 }
380-
381- for my $connection (@{$self -> {CONNECTIONS }})
384+ else
382385 {
383- delete $connection -> { FIXED } ;
386+ $self -> delete_connections( $connection ) ;
384387 }
385388 }
386- else
387- {
388- $self -> delete_connections($connection ) ;
389- }
390389 }
391390
392391return ($x_offset , $y_offset , $resized_connector_name ) ;
@@ -487,29 +486,28 @@ if($self->is_connected($selected_element))
487486
488487$self -> connect_elements($selected_element ) ; # connect to new elements if any
489488
490- for my $connection ($self -> get_connected ($selected_element ))
489+ for my $connection ($self -> get_connectons ($selected_element ))
491490 {
492491 # all connection where the selected element is the connectee
493492
494- my ($new_connection ) = # in characters relative to element origin
495- $selected_element -> get_named_connection($connection -> {CONNECTION }{NAME }) ;
493+ my ($named_connection ) = $selected_element -> get_named_connection($connection -> {CONNECTION }{NAME }) ;
496494
497- if (defined $new_connection )
495+ if (defined $named_connection )
498496 {
499497 my ($x_offset , $y_offset , $width , $height , $new_connector ) =
500498 $connection -> {CONNECTED }-> move_connector
501499 (
502500 $connection -> {CONNECTOR }{NAME },
503- $new_connection -> {X } - $connection -> {CONNECTION }{X },
504- $new_connection -> {Y }- $connection -> {CONNECTION }{Y }
501+ $named_connection -> {X } - $connection -> {CONNECTION }{X },
502+ $named_connection -> {Y }- $connection -> {CONNECTION }{Y }
505503 ) ;
506504
507505 $connection -> {CONNECTED }{X } += $x_offset ;
508506 $connection -> {CONNECTED }{Y } += $y_offset ;
509507
510508 # the connection point has also changed
511509 $connection -> {CONNECTOR } = $new_connector ;
512- $connection -> {CONNECTION } = $new_connection ;
510+ $connection -> {CONNECTION } = $named_connection ;
513511
514512 $connection -> {FIXED }++ ;
515513
@@ -519,18 +517,14 @@ for my $connection ($self->get_connected($selected_element))
519517 # move them relatively to their previous position
520518 if ($connection -> {CONNECTED } == $other_connection -> {CONNECTED })
521519 {
522- my ($new_connector ) = # in characters relative to element origin
523- $other_connection -> {CONNECTED }-> get_named_connection($other_connection -> {CONNECTOR }{NAME }) ;
520+ my ($named_connection ) = $other_connection -> {CONNECTED }-> get_named_connection($other_connection -> {CONNECTOR }{NAME }) ;
524521
525- $other_connection -> {CONNECTOR } = $new_connector ;
522+ $other_connection -> {CONNECTOR } = $named_connection ;
526523 $other_connection -> {FIXED }++ ;
527524 }
528525 }
529-
530- for my $connection (@{$self -> {CONNECTIONS }})
531- {
532- delete $connection -> {FIXED } ;
533- }
526+
527+ delete $_ -> {FIXED } for @{$self -> {CONNECTIONS }} ;
534528 }
535529 else
536530 {
0 commit comments