Skip to content

Commit ee19e4b

Browse files
qindapaonkh
authored andcommitted
CHANGED: optimized GUI re-draw
Only draw elements and grid section that the user can see. ADDED: Cross-mode drawing cache ADDED: GTK_MEMORY_OVER_SPEED Configuration parameter GTK_MEMORY_OVER_SPEED Let the user decide whether the background and grid are drawn to the entire screen or to the viewport.
1 parent 819504d commit ee19e4b

File tree

19 files changed

+610
-418
lines changed

19 files changed

+610
-418
lines changed

examples/pcie_ltssm.asciio

16.3 KB
Binary file not shown.

lib/App/Asciio.pm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,6 @@ Please report errors at https://github.com/nkh/P5-App-Asciio/issues.
999999
10001000
Qin Qing
10011001
northisland2017@gmail.com
1002-
unicode support, scroll bar, and rhombus object
10031002
10041003
=head1 LICENSE AND COPYRIGHT
10051004

lib/App/Asciio/Actions.pm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,17 @@ for my $action (@actions)
100100
$self->{CURRENT_ACTIONS}{$action}{ORIGIN}
101101
)
102102
) if $self->{ACTION_VERBOSE} && $self->{CURRENT_ACTIONS}{$action}{NAME} ne 'Mouse motion' ;
103+
103104

104105
# Note: action sub is what changes $self->{CURRENT_ACTIONS} to a new action group
105106
my $start_actions = $self->{CURRENT_ACTIONS} ;
106107

108+
if($self->{BINDINGS_COMPLETION})
109+
{
110+
delete $self->{BINDINGS_COMPLETION} ;
111+
$self->update_display() ;
112+
}
113+
107114
if(defined $self->{CURRENT_ACTIONS}{$action}{ARGUMENTS})
108115
{
109116
push @results,

lib/App/Asciio/Actions/Colors.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ my ($color) = $self->get_color_from_user([0, 0, 0]) ;
4040

4141
$self->create_undo_snapshot() ;
4242

43-
delete $self->{CACHE}{GRID} ;
43+
delete $self->{CACHE}{BACKGROUND_AND_GRID} ;
4444
$self->{COLORS}{background} = $color ;
4545

4646
$self->update_display() ;
@@ -56,7 +56,7 @@ my ($color) = $self->get_color_from_user([0, 0, 0]) ;
5656

5757
$self->create_undo_snapshot() ;
5858

59-
delete $self->{CACHE}{GRID} ;
59+
delete $self->{CACHE}{BACKGROUND_AND_GRID} ;
6060
$self->{COLORS}{grid} = $color ;
6161

6262
$self->update_display() ;

lib/App/Asciio/Actions/Elements.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ my $element = $self->add_new_element_named($name, $x // $self->{MOUSE_X}, $y //
5454
if($edit)
5555
{
5656
$element->edit($self);
57-
$self->{EDIT_SEMAPHORE} = 3 if((defined $self->{EDIT_TEXT_INLINE}) && ($self->{EDIT_TEXT_INLINE} != 0)) ;
57+
$self->{EDIT_SEMAPHORE} = 3 if defined $self->{EDIT_TEXT_INLINE} && $self->{EDIT_TEXT_INLINE} != 0 ;
5858
}
5959

6060
use App::Asciio::Actions::Mouse ;

lib/App/Asciio/Actions/Mouse.pm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,15 +379,15 @@ if($event->{STATE} eq 'dragging-button1' && ($self->{PREVIOUS_X} != $x || $self-
379379
{
380380
my ($character_width, $character_height) = $self->get_character_size() ;
381381

382-
my $h_value = $self->{sc_window}->get_hadjustment()->get_value() ;
383-
my $v_value = $self->{sc_window}->get_vadjustment()->get_value() ;
382+
my $h_value = $self->{SC_WINDOW}->get_hadjustment()->get_value() ;
383+
my $v_value = $self->{SC_WINDOW}->get_vadjustment()->get_value() ;
384384

385385
my $new_h_value = $h_value - (($x - $self->{PREVIOUS_X}) * $character_width) ;
386386
my $new_v_value = $v_value - (($y - $self->{PREVIOUS_Y}) * $character_height) ;
387387

388388
if($new_h_value >= 0)
389389
{
390-
$self->{sc_window}->get_hadjustment()->set_value($new_h_value) ;
390+
$self->{SC_WINDOW}->get_hadjustment()->set_value($new_h_value) ;
391391
}
392392
else
393393
{
@@ -396,7 +396,7 @@ if($event->{STATE} eq 'dragging-button1' && ($self->{PREVIOUS_X} != $x || $self-
396396

397397
if($new_v_value >= 0)
398398
{
399-
$self->{sc_window}->get_vadjustment()->set_value($new_v_value) ;
399+
$self->{SC_WINDOW}->get_vadjustment()->set_value($new_v_value) ;
400400
}
401401
else
402402
{

lib/App/Asciio/Actions/Unsorted.pm

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ $self->set_font($family, $size);
123123
# resize canvas
124124
if($self->{UI} eq 'GUI')
125125
{
126-
my $h_value = $self->{sc_window}->get_hadjustment()->get_value() ;
127-
my $v_value = $self->{sc_window}->get_vadjustment()->get_value() ;
126+
my $h_value = $self->{SC_WINDOW}->get_hadjustment()->get_value() ;
127+
my $v_value = $self->{SC_WINDOW}->get_vadjustment()->get_value() ;
128128

129129
$self->invalidate_rendering_cache() ;
130130

@@ -143,8 +143,8 @@ if($self->{UI} eq 'GUI')
143143
$new_h_value = max(0, min($canvas_width, $new_h_value)) ;
144144
$new_v_value = max(0, min($canvas_height, $new_v_value)) ;
145145

146-
$self->{sc_window}->get_hadjustment()->set_value($new_h_value) ;
147-
$self->{sc_window}->get_vadjustment()->set_value($new_v_value) ;
146+
$self->{SC_WINDOW}->get_hadjustment()->set_value($new_h_value) ;
147+
$self->{SC_WINDOW}->get_vadjustment()->set_value($new_v_value) ;
148148

149149
}
150150

@@ -400,7 +400,7 @@ sub flip_grid_display
400400
{
401401
my ($self) = @_ ;
402402
$self->{DISPLAY_GRID} ^=1 ;
403-
delete $self->{CACHE}{GRID} ;
403+
delete $self->{CACHE}{BACKGROUND_AND_GRID} ;
404404
$self->update_display() ;
405405
}
406406

@@ -457,5 +457,13 @@ $self->update_display() ;
457457

458458
#----------------------------------------------------------------------------------------------
459459

460+
sub toggle_edit_inline
461+
{
462+
my ($self) = @_ ;
463+
$self->{EDIT_TEXT_INLINE} ^= 1 ;
464+
}
465+
466+
#----------------------------------------------------------------------------------------------
467+
460468
1 ;
461469

lib/App/Asciio/Cross.pm

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ my @diagonal_char_func = (
202202

203203
sub get_cross_mode_overlays
204204
{
205-
my ($zbuffer, $start_x, $end_x, $start_y, $end_y) = @_;
205+
my ($zbuffer) = @_;
206206

207207
my @overlays ;
208208

@@ -233,12 +233,6 @@ while (my ($coordinate, $char_stacks) = each %{ $cross_zbuffer->{intersecting_el
233233
while( my($coordinate, $elements) = each $cross_zbuffer->{intersecting_elements}->%*)
234234
{
235235
my ($Y, $X) = split ';', $coordinate ;
236-
237-
if(defined $start_x)
238-
{
239-
next if(($Y>$end_y) || ($Y<$start_y) || ($X>$end_x) || ($X<$start_x)) ;
240-
}
241-
242236
my $neighbors_stack = $cross_zbuffer->get_neighbors_stack($coordinate) ;
243237

244238
my ($char_315, $up, $char_45, $right, $char_135, $down, $char_225, $left) =
@@ -290,17 +284,24 @@ return @overlays ;
290284
}
291285

292286
#-----------------------------------------------------------------------------
293-
# +
294-
sub scene_cross
287+
288+
sub scene_cross
295289
{
296290
my ($up, $down, $left, $right, $char_category_indexs) = @_;
297291

298-
return 0 unless defined $up && defined $down && defined $left && defined $right ;
292+
return 0 unless defined $up && defined $down && defined $left && defined $right;
293+
294+
my %valid_chars = (
295+
up => { map { $_ => 1 } qw(| . ' + ^) },
296+
down => { map { $_ => 1 } qw(| . ' + v) },
297+
left => { map { $_ => 1 } qw(- . ' + <) },
298+
right => { map { $_ => 1 } qw(- . ' + >) },
299+
);
299300

300-
return ((any {$_ eq '|'} @{$up}) || (any {$_ eq '.'} @{$up}) || (any {$_ eq '\''} @{$up}) || (any {$_ eq '+'} @{$up}) || (any {$_ eq '^'} @{$up}))
301-
&& ((any {$_ eq '|'} @{$down}) || (any {$_ eq '.'} @{$down}) || (any {$_ eq '\''} @{$down}) || (any {$_ eq '+'} @{$down}) || (any {$_ eq 'v'} @{$down}))
302-
&& ((any {$_ eq '-'} @{$left}) || (any {$_ eq '.'} @{$left}) || (any {$_ eq '\''} @{$left}) || (any {$_ eq '+'} @{$left}) || (any {$_ eq '<'} @{$left}))
303-
&& ((any {$_ eq '-'} @{$right}) || (any {$_ eq '.'} @{$right}) || (any {$_ eq '\''} @{$right}) || (any {$_ eq '+'} @{$right}) || (any {$_ eq '>'} @{$right})) ;
301+
return (any { $valid_chars{up}{$_} } @$up)
302+
&& (any { $valid_chars{down}{$_} } @$down)
303+
&& (any { $valid_chars{left}{$_} } @$left)
304+
&& (any { $valid_chars{right}{$_} } @$right);
304305
}
305306

306307
#-----------------------------------------------------------------------------

lib/App/Asciio/Elements.pm

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,20 @@ use Readonly ;
1717

1818
use App::Asciio::Connections ;
1919

20+
use App::Asciio::GTK::Asciio::stripes::editable_exec_box ;
21+
use App::Asciio::GTK::Asciio::stripes::editable_box2 ;
22+
use App::Asciio::GTK::Asciio::stripes::rhombus ;
23+
use App::Asciio::GTK::Asciio::stripes::ellipse ;
24+
25+
use App::Asciio::GTK::Asciio::stripes::editable_arrow2 ;
26+
use App::Asciio::GTK::Asciio::stripes::wirl_arrow ;
27+
use App::Asciio::GTK::Asciio::stripes::angled_arrow ;
28+
use App::Asciio::GTK::Asciio::stripes::section_wirl_arrow ;
29+
30+
use App::Asciio::GTK::Asciio::Dialogs ;
31+
use App::Asciio::GTK::Asciio::DnD ;
32+
use App::Asciio::GTK::Asciio::Menues ;
33+
2034
#-----------------------------------------------------------------------------
2135

2236
sub set_modified_state { my ($self, $state) = @_ ; $self->{MODIFIED} = $state ; }
@@ -299,7 +313,7 @@ for my $element (@elements)
299313
}
300314

301315
$self->{MODIFIED }++ ;
302-
delete $element->{CACHE}{COORDINATES} ;
316+
delete $element->{CACHE}{SELECTION_COORDINATES} ;
303317
}
304318
}
305319

@@ -755,23 +769,25 @@ return($is_within) ;
755769

756770
#-----------------------------------------------------------------------------
757771

758-
sub get_extent_box
772+
sub get_selected_elements_extents
759773
{
760774
my ($self, @elements) = @_ ;
761775

762776
@elements = $self->get_selected_elements(1) unless @elements ;
763777

764-
my ($xs, $ys, $xe, $ye) = (10_000, 10_000, 0, 0) ;
778+
my ($xs, $ys, $xe, $ye, $has_extents) = (10_000, 10_000, 0, 0, 0) ;
765779

766780
for (grep { ref($_) !~ /arrow/ } @elements)
767781
{
782+
$has_extents++ ;
783+
768784
$xs = min($xs//10_000, $_->{X} + $_->{EXTENTS}[0]) ;
769785
$ys = min($ys//10_000, $_->{Y} + $_->{EXTENTS}[1]) ;
770786
$xe = max($xe//0, $_->{X} + $_->{EXTENTS}[2]) ;
771787
$ye = max($ye//0, $_->{Y} + $_->{EXTENTS}[3]) ;
772788
}
773789

774-
($xs // 0, $ys // 0, $xe // 0, $ye // 0) ;
790+
($xs // 0, $ys // 0, $xe // 0, $ye // 0, $has_extents) ;
775791
}
776792

777793
#-----------------------------------------------------------------------------

0 commit comments

Comments
 (0)