App-Asciio
view release on metacpan or search on metacpan
setup/actions/context_menu_box.pl view on Meta::CPAN
#----------------------------------------------------------------------------------------------
register_action_handlers
(
'box_context_menu' => ['box_context_menu', undef, undef, \&box_context_menu],
) ;
#----------------------------------------------------------------------------------------------
use Readonly ;
Readonly my $TOP => 0 ;
Readonly my $TITLE_SEPARATOR => 1 ;
Readonly my $BODY_SEPARATOR => 2 ;
Readonly my $BOTTOM => 3;
Readonly my $DISPLAY => 0 ;
Readonly my $NAME => 1 ;
Readonly my $LEFT => 2 ;
Readonly my $BODY => 3 ;
Readonly my $RIGHT => 4 ;
my %box_types =
(
dash =>
[
[1, 'top', '.', '-', '.', 1, ],
[0, 'title separator', '|', '-', '|', 1, ],
[1, 'body separator', '| ', '|', ' |', 1, ],
[1, 'bottom', '\'', '-', '\'', 1, ],
],
dot =>
[
[1, 'top', '.', '.', '.', 1, ],
[0, 'title separator', '.', '.', '.', 1, ],
[1, 'body separator', '. ', '.', ' .', 1, ],
[1, 'bottom', '.', '.', '.', 1, ],
],
star =>
[
[1, 'top', '*', '*', '*', 1, ],
[0, 'title separator', '*', '*', '*', 1, ],
[1, 'body separator', '* ', '*', ' *', 1, ],
[1, 'bottom', '*', '*', '*', 1, ],
],
) ;
#----------------------------------------------------------------------------------------------
sub box_context_menu
{
my ($self, $popup_x, $popup_y) = @_ ;
my @context_menu_entries ;
my ($character_width, $character_height) = $self->get_character_size() ;
my @selected_elements = $self->get_selected_elements(1) ;
if(@selected_elements == 1 && 'App::Asciio::stripes::editable_box2' eq ref $selected_elements[0])
{
my $element = $selected_elements[0] ;
my ($x, $y) = $self->closest_character($popup_x - ($element->{X} * $character_width) , $popup_y - ($element->{Y} * $character_height)) ;
push @context_menu_entries,
[
'/Rotate text',
sub {$element->rotate_text() ;},
] ;
push @context_menu_entries,
[
'/box selected element',
\&box_selected_element,
{ ELEMENT => $element},
] ;
push @context_menu_entries,
[
'/Box type/dash',
\&change_box_type,
{
ELEMENT => $element,
TYPE => 'dash',
}
],
[
'/Box type/dot',
\&change_box_type,
{
ELEMENT => $element,
TYPE => 'dot',
}
],
[
'/Box type/star',
\&change_box_type,
{
ELEMENT => $element,
TYPE => 'star',
}
] ;
push @context_menu_entries,
[
$element->is_autoconnect_enabled() ? '/disable autoconnection' : '/enable autoconnection',
sub
{
$self->create_undo_snapshot() ;
$element->enable_autoconnect(! $element->is_autoconnect_enabled()) ;
$self->update_display() ;
}
] ;
if($element->is_border_connection_allowed())
{
push @context_menu_entries, ["/Disable border connection", sub {$element->allow_border_connection(0) ;}] ;
}
( run in 0.514 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )