App-Guiio
view release on metacpan or search on metacpan
lib/App/Guiio.pm view on Meta::CPAN
This gtk2-perl application allows you to draw ASCII diagrams in a modern (but simple) graphical
application. The ASCII graphs can be saved as ASCII or in a format that allows you to modify them later.
Thanks to all the Perl-QA hackathon 2008 in Oslo for pushing me to do an early release.
Special thanks go to the Muppet and the gtk-perl group, Gábor Szabó for his help and advices.
Adam Kennedy coined the cool name.
Sometimes a diagram is worth a lot of text in a source code file. It has always been painfull to do
ASCII diagrams by hand.
=head1 DOCUMENTATION
=head2 Guiio user interface
.-----------------------------------------------------------------.
| Guiio |
|-----------------------------------------------------------------|
| ............................................................... |
| ..............-------------..------------..--------------...... |
| .............| stencils > || guiio > || box |..... |
| .............| Rulers > || computer > || text |..... |
| .............| File > || people > || wirl_arrow |..... |
grid---------->.......'-------------'| divers > || axis |..... |
| ............................'------------'| boxes > |..... |
| ......................^...................| rulers > |..... |
| ......................|...................'--------------'..... |
| ......................|........................................ |
| ......................|........................................ |
| ......................|........................................ |
| ......................|........................................ |
'-----------------------|-----------------------------------------'
|
|
context menu
=head2 context menu
The context menu allows to access to B<guiio> commands. B<ASCII> is used to insert ASCII elements.
=head2 keyboard shortcuts
All the keyboad commands definitions can be found under I<guiio/setup/actions/>. Among the commands
implemented are:
=over 2
=item * select all
=item * delete
=item * undo
=item * group/ungroup
=item * open / save
=item * local clipboard operations
=back
A window displaying the currently available commands is displayed if you press B<K>.
=head2 elements
There but a few elements implemented at the moment.
=head3 wirl arrow
An arrow that tries to do what you want. Try rotating the end clockwise then counter clockwise to see how it acts
^
|
| --------.
| |
'------- |
|
O-------------X / |
/ |
/ |
/ v
/
/
v
=head3 box and text
Both are implemented within the same code. Try double clicking on a box to see what you can do with it.
.----------.
| title |
.----------. |----------| ************
| | | body 1 | * *
'----------' | body 2 | ************
'----------'
anything in a box
(\_/) |
edit_me (O.o) <------------'
(> <)
=head3 your own stencils
Take a look at I<setup/stencils/computer> for a stencil example. Stencils lites in I<setup/setup.ini> will
be loaded when B<Guiio> starts.
=head3 your own element type
For simple elemnts, put your design in a box. that should cover 90% of anyone's needs. You can look in
I<lib/stripes> for element implementation examples.
=head2 exporting to ASCII
You can export to a file in ASCII format but using the B<.txt> extension.
Exporting to the clipboard is done with B<ctl + e>.
=head1 EXAMPLES
User code ^ ^ OS code
\ /
\ /
\ /
User code <----Mode----->OS code
/ \
/ \
/ \
User code v v OS code
.---. .---. .---. .---. .---. .---.
OS API '---' '---' '---' '---' '---' '---'
| | | | | |
v v | v | v
.------------. | .-----------. | .-----.
| Filesystem | | | Scheduler | | | MMU |
'------------' | '-----------' | '-----'
| | | |
v | | v
.----. | | .---------.
| IO |<----' | | Network |
'----' | '---------'
| | |
v v v
.---------------------------------------.
| HAL |
'---------------------------------------'
.---------. .---------.
| State 1 | | State 2 |
'---------' '---------'
^ \ ^ \
/ \ / \
/ \ / \
/ \ / \
/ \ / \
/ v v
****** ****** ******
* T1 * * T2 * * T3 *
****** ****** ******
^ ^ /
\ \ /
\ \ /
\ \ / stimuli
\ \ /
\ \ v
\ .---------.
'--------| State 3 |
'---------'
lib/App/Guiio.pm view on Meta::CPAN
$self->run_actions(["${modifiers}-button_release", $event]) ;
return TRUE ;
}
if(defined $self->{MODIFIED_INDEX} && defined $self->{MODIFIED} && $self->{MODIFIED_INDEX} == $self->{MODIFIED})
{
$self->pop_undo_buffer(1) ; # no changes
}
$self->update_display();
}
#-----------------------------------------------------------------------------
sub button_press_event
{
#~ print "button_press_event\n" ;
my ($widget, $event, $self) = @_ ;
$self->{DRAGGING} = '' ;
delete $self->{RESIZE_CONNECTOR_NAME} ;
$self->create_undo_snapshot() ;
$self->{MODIFIED_INDEX} = $self->{MODIFIED} ;
my $modifiers = get_key_modifiers($event) ;
my $button = ${event}->button() ;
if($self->exists_action("${modifiers}-button_press-$button"))
{
$self->run_actions(["${modifiers}-button_press-$button", $event]) ;
return TRUE ;
}
if($event->type eq '2button-press')
{
my($x, $y) = $self->closest_character($event->coords()) ;
my @element_over = grep { $self->is_over_element($_, $x, $y) } reverse @{$self->{ELEMENTS}} ;
if(@element_over)
{
my $selected_element = $element_over[0] ;
$self->edit_element($selected_element) ;
$self->update_display();
}
return TRUE ;
}
if($event->button == 1)
{
my $modifiers = get_key_modifiers($event) ;
my ($x, $y) = $self->closest_character($event->coords()) ;
my ($first_element) = first_value {$self->is_over_element($_, $x, $y)} reverse @{$self->{ELEMENTS}} ;
if ($modifiers eq 'C00')
{
if(defined $first_element)
{
$self->run_actions_by_name('Copy to clipboard', ['Insert from clipboard', 0, 0]) ;
}
}
else
{
if(defined $first_element)
{
if ($modifiers eq '00S')
{
$self->select_elements_flip($first_element) ;
}
else
{
unless($self->is_element_selected($first_element))
{
$self->select_elements(0, @{$self->{ELEMENTS}}) ;
$self->select_elements(1, $first_element) ;
}
}
}
else
{
$self->select_elements(0, @{$self->{ELEMENTS}}) if ($modifiers eq '000') ;
}
}
$self->{SELECTION_RECTANGLE} = {START_X => $x , START_Y => $y} ;
$self->update_display();
}
if($event->button == 2)
{
my ($x, $y) = $self->closest_character($event->coords()) ;
$self->{SELECTION_RECTANGLE} = {START_X => $x , START_Y => $y} ;
$self->update_display();
}
# handle right button mouse click, disabled with GUIIO as context
#if($event->button == 3)
# {
# $self->display_popup_menu($event) ;
# }
return TRUE;
}
#-----------------------------------------------------------------------------
sub motion_notify_event
{
my ($widget, $event, $self) = @_ ;
my ($x, $y) = $self->closest_character($event->coords()) ;
my $modifiers = get_key_modifiers($event) ;
if($self->exists_action("${modifiers}motion_notify"))
{
$self->run_actions(["${modifiers}-motion_notify", $event]) ;
return TRUE ;
}
( run in 1.777 second using v1.01-cache-2.11-cpan-2398b32b56e )