App-Asciio
view release on metacpan or search on metacpan
setup/actions/elements_manipulation.pl view on Meta::CPAN
#----------------------------------------------------------------------------------------------
register_action_handlers
(
'Select next element' => ['000-Tab', \&select_next_element],
'Select previous element' => ['00S-ISO_Left_Tab', \&select_previous_element],
'Select all elements' => ['C00-a', \&select_all_elements],
'Delete selected elements' => ['000-Delete', \&delete_selected_elements],
'Group selected elements' => ['C00-g', \&group_selected_elements],
'Ungroup selected elements' => ['C00-u', \&ungroup_selected_elements],
'Move selected elements to the front' => ['C00-f', \&move_selected_elements_to_front],
'Move selected elements to the back' => ['C00-b', \&move_selected_elements_to_back],
'Temporary move selected element to the front' => ['0A0-f', \&temporary_move_selected_element_to_front],
'Edit selected element' => ['000-Return', \&edit_selected_element],
'Move selected elements left' => ['000-Left', \&move_selection_left],
'Move selected elements right' => ['000-Right', \&move_selection_right],
'Move selected elements up' => ['000-Up', \&move_selection_up],
'Move selected elements down' => ['000-Down', \&move_selection_down],
'Change arrow direction' => ['000-d', \&change_arrow_direction],
'Flip arrow start and end' => ['000-f', \&flip_arrow_ends],
) ;
#----------------------------------------------------------------------------------------------
sub edit_selected_element
{
my ($self) = @_ ;
my @selected_elements = $self->get_selected_elements(1) ;
if(@selected_elements == 1)
{
$self->create_undo_snapshot() ;
$self->edit_element($selected_elements[0]) ;
$self->update_display();
}
}
#----------------------------------------------------------------------------------------------
sub change_arrow_direction
{
my ($self) = @_ ;
$self->create_undo_snapshot() ;
my $changes_made = 0 ;
# App::Asciio::stripes::section_wirl_arrow
my @elements_to_redirect = grep {ref $_ eq 'App::Asciio::stripes::section_wirl_arrow'} $self->get_selected_elements(1) ;
if(@elements_to_redirect)
{
$changes_made++ ;
for (@elements_to_redirect)
{
$_->change_section_direction($self->{MOUSE_X} - $_->{X}, $self->{MOUSE_Y} - $_->{Y}) ;
}
}
# App::Asciio::stripes::angled_arrow
@elements_to_redirect = grep {ref $_ eq 'App::Asciio::stripes::angled_arrow'} $self->get_selected_elements(1) ;
if(@elements_to_redirect)
{
$changes_made++ ;
for (@elements_to_redirect)
{
$_->change_direction() ;
}
}
# all
if($changes_made)
{
$self->update_display() ;
}
else
{
$self->pop_undo_buffer(1) ;
}
}
#----------------------------------------------------------------------------------------------
sub flip_arrow_ends
{
my ($self) = @_ ;
my @elements_to_flip =
grep
{
my @connectors = $_->get_connector_points() ;
( run in 0.966 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )