diff options
author | Maarten Vanraes <alien@mageia.org> | 2016-04-24 21:18:59 +0200 |
---|---|---|
committer | Maarten Vanraes <alien@mageia.org> | 2016-04-24 23:21:55 +0200 |
commit | 7b79a6b21d9404cff72f2378d0eef9646dbceba9 (patch) | |
tree | 89cc3f53237fa86418aa4c0663f812722e167016 | |
parent | c7ea22b0e9c959e77a19e728ba738cb91bca103d (diff) | |
download | manatools-7b79a6b21d9404cff72f2378d0eef9646dbceba9.tar manatools-7b79a6b21d9404cff72f2378d0eef9646dbceba9.tar.gz manatools-7b79a6b21d9404cff72f2378d0eef9646dbceba9.tar.bz2 manatools-7b79a6b21d9404cff72f2378d0eef9646dbceba9.tar.xz manatools-7b79a6b21d9404cff72f2378d0eef9646dbceba9.zip |
Lock layout until after all waiting events are processed
-rw-r--r-- | lib/ManaTools/Shared/GUI/Dialog.pm | 66 | ||||
-rw-r--r-- | lib/ManaTools/Shared/GUI/ReplacePoint.pm | 13 |
2 files changed, 65 insertions, 14 deletions
diff --git a/lib/ManaTools/Shared/GUI/Dialog.pm b/lib/ManaTools/Shared/GUI/Dialog.pm index 240dce65..520fc30d 100644 --- a/lib/ManaTools/Shared/GUI/Dialog.pm +++ b/lib/ManaTools/Shared/GUI/Dialog.pm @@ -268,7 +268,6 @@ class_has 'TabField' => ( default => sub {return 3;}, ); - has 'optFields' => ( is => 'ro', isa => 'ArrayRef[Int]', @@ -278,6 +277,12 @@ has 'optFields' => ( }, ); +has 'layoutDirty' => ( + is => 'rw', + isa => 'Bool', + default => 0, +); + has 'info' => ( is => 'rw', isa => 'HashRef', @@ -433,6 +438,55 @@ sub addButtons { #============================================================= +=head2 multipleChanges + +=head3 INPUT + + $self: this object + +=head3 DESCRIPTION + + Start multiple changes (if required) + +=cut + +#============================================================= +sub multipleChanges { + my $self = shift; + my $ydialog = $self->dialog(); + return if ($self->layoutDirty()); + $ydialog->startMultipleChanges(); + $self->layoutDirty(1); +} + +#============================================================= + +=head2 recalcLayout + +=head3 INPUT + + $self: this object + $force: bool + +=head3 DESCRIPTION + + Recalculates the layout and ends multiple changes (if required or if forced) + +=cut + +#============================================================= +sub recalcLayout { + my $self = shift; + my $force = shift || 0; + my $ydialog = $self->dialog(); + return if (!$self->layoutDirty() || $force); + $ydialog->recalcLayout(); + $ydialog->doneMultipleChanges(); + $self->layoutDirty(0); +} + +#============================================================= + =head2 call =head3 INPUT @@ -485,13 +539,19 @@ sub call { ## build the whole layout my $layout = $self->layout->($self, $layoutstart); - ## add a cancelEvent ManaTools::Shared::GUI::Event->new(name => 'cancelEvent', eventHandler => $self, eventType => $yui::YEvent::CancelEvent, event => sub { return 0; }); # main loop while(1) { - my $yevent = $ydialog->waitForEvent($self->event_timeout); + my $yevent = $ydialog->pollEvent(); + if (!$yevent) { + # only recalc layout after all pending events have run + $self->recalcLayout(); + # wait for a new event + $yevent = $ydialog->waitForEvent($self->event_timeout); + } + # if we have an event, process it (and possibly exit) last if (!$self->processEvents($yevent)); } diff --git a/lib/ManaTools/Shared/GUI/ReplacePoint.pm b/lib/ManaTools/Shared/GUI/ReplacePoint.pm index c8db5856..10b38ff0 100644 --- a/lib/ManaTools/Shared/GUI/ReplacePoint.pm +++ b/lib/ManaTools/Shared/GUI/ReplacePoint.pm @@ -150,7 +150,6 @@ has 'container' => ( sub buildReplacePoint { my $self = shift; my $dialog = $self->parentDialog(); - my $ydialog = $dialog->dialog(); my $factory = $dialog->factory(); my $parentWidget = $self->parentWidget(); @@ -158,7 +157,7 @@ sub buildReplacePoint { my $replacepoint = $factory->createReplacePoint($parentWidget); # lock windows for multiple changes - $ydialog->startMultipleChanges(); + $dialog->multipleChanges(); return $replacepoint; } @@ -184,11 +183,11 @@ sub clear { my $dialog = $self->parentDialog(); my $ydialog = $dialog->dialog(); + $dialog->multipleChanges(); # clear out the events of the children $self->clearEvents(); # lock windows for multiple changes (this way it becomes ready for adding new children) - $ydialog->startMultipleChanges(); # clear out replacepoint $container->deleteChildren(); @@ -212,17 +211,9 @@ sub clear { sub finished { my $self = shift; my $container = $self->container(); - my $dialog = $self->parentDialog(); - my $ydialog = $dialog->dialog(); # trigger showChild on the container $container->showChild(); - - # recalulate layout - $ydialog->recalcLayout(); - - # unlock windows for multiple changes - $ydialog->doneMultipleChanges(); } #============================================================= |