« blib/lib/App/Asciio/GTK/Asciio/stripes/ellipse.pm
↑ Summary
blib/lib/App/Asciio/setup/import_export/svg.pl »
| 1 | |||
| 2 | package App::Asciio::Actions::Clone ; | ||
| 3 | |||
| 4 | use App::Asciio::Actions::Elements ; | ||
| 5 | |||
| 6 | use strict ; use warnings ; | ||
| 7 | |||
| 8 | my $clone_element_to_insert ; | ||
| 9 | my $clone_element_overlay ; | ||
| 10 | |||
| 11 | sub clone_set_overlay | ||
| 12 | { | ||
| 13 | my ($asciio, $element_definition) = @_ ; | ||
| 14 | |||
| 15 | my $element_name = $element_definition->[0] ; | ||
| 16 | my $element_index = $asciio->{ELEMENT_TYPES_BY_NAME}{$element_name} ; | ||
| 17 | |||
| 18 | if(defined $element_index) | ||
| 19 | { | ||
| 20 | $clone_element_to_insert = $element_definition ; | ||
| 21 | |||
| 22 | $clone_element_overlay = Clone::clone($asciio->{ELEMENT_TYPES}[$element_index]) ; | ||
| 23 | $asciio->set_element_position($clone_element_overlay, $asciio->{MOUSE_X}, $asciio->{MOUSE_Y}) ; | ||
| 24 | |||
| 25 | $asciio->update_display ; | ||
| 26 | } | ||
| 27 | } | ||
| 28 | |||
| 29 | sub clone_get_overlay | ||
| 30 | { | ||
| 31 | my ($asciio, $UI_type, $gc, $widget_width, $widget_height, $character_width, $character_height) = @_ ; | ||
| 32 | |||
| 33 | # # we can draw directly | ||
| 34 | # if($UI_type eq 'GUI') | ||
| 35 | # { | ||
| 36 | # my $surface = Cairo::ImageSurface->create('argb32', 50, 50) ; | ||
| 37 | # my $gco = Cairo::Context->create($surface) ; | ||
| 38 | |||
| 39 | # my $background_color = $asciio->get_color('cross_filler_background') ; | ||
| 40 | # $gco->set_source_rgb(@$background_color) ; | ||
| 41 | |||
| 42 | # $gco->rectangle(0, 0, $character_width, $character_height) ; | ||
| 43 | # $gco->fill() ; | ||
| 44 | |||
| 45 | # $gc->set_source_surface($surface, ($asciio->{MOUSE_X} - 1 ) * $character_width, ($asciio->{MOUSE_Y} - 1) * $character_height); | ||
| 46 | # $gc->paint() ; | ||
| 47 | # } | ||
| 48 | |||
| 49 | $asciio->set_element_position($clone_element_overlay, $asciio->{MOUSE_X}, $asciio->{MOUSE_Y}) ; | ||
| 50 | $clone_element_overlay | ||
| 51 | } | ||
| 52 | |||
| 53 | sub clone_enter | ||
| 54 | { | ||
| 55 | my ($asciio) = @_ ; | ||
| 56 | |||
| 57 | my $stripes_group = App::Asciio::Actions::ElementsManipulation::create_stripes_group_from_selected_elements($asciio, 0, 1) ; | ||
| 58 | |||
| 59 | if($stripes_group) | ||
| 60 | { | ||
| 61 | App::Asciio::Actions::Clipboard::copy_to_clipboard($asciio) ; | ||
| 62 | |||
| 63 | $clone_element_to_insert = 'SELECTION' ; | ||
| 64 | $clone_element_overlay = $stripes_group ; | ||
| 65 | |||
| 66 | $asciio->set_element_position($stripes_group, $asciio->{MOUSE_X}, $asciio->{MOUSE_Y}) ; | ||
| 67 | } | ||
| 68 | else | ||
| 69 | { | ||
| 70 | clone_set_overlay($asciio, ['Asciio/box', 0]) ; | ||
| 71 | } | ||
| 72 | |||
| 73 | $asciio->hide_pointer ; | ||
| 74 | |||
| 75 | $asciio->set_overlays_sub(\&clone_get_overlay) ; | ||
| 76 | |||
| 77 | $asciio->update_display ; | ||
| 78 | } | ||
| 79 | |||
| 80 | sub clone_escape { my ($asciio) = @_ ; $asciio->set_overlays_sub(undef) ; $asciio->show_pointer ; $asciio->update_display ; } | ||
| 81 | sub clone_mouse_motion { my ($asciio, $event) = @_ ; App::Asciio::Actions::Mouse::mouse_motion($asciio, $event) ; $asciio->update_display() ; } | ||
| 82 | |||
| 83 | sub clone_add_element | ||
| 84 | { | ||
| 85 | my ($asciio) = @_ ; | ||
| 86 | |||
| 87 | if($clone_element_to_insert eq 'SELECTION') | ||
| 88 | { | ||
| 89 | App::Asciio::Actions::Clipboard::insert_from_clipboard($asciio) ; | ||
| 90 | } | ||
| 91 | else | ||
| 92 | { | ||
| 93 | App::Asciio::Actions::Elements::add_element($asciio, $clone_element_to_insert) ; | ||
| 94 | } | ||
| 95 | } | ||
| 96 | |||
| 97 | #---------------------------------------------------------------------------------------------- | ||
| 98 | |||
| 99 | 1 ; | ||
| 100 |