Permalink
Browse files

This change delays the closing transition of a Sheet until all the

listeners have weighed in on the closing vote.  That way, if the
first listener (the skin) is okay with closing, but a later listener
is not, the transition will not start and have to be reversed
(causing a visible flash).


git-svn-id: https://svn.apache.org/repos/asf/pivot/trunk@1409081 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent 95fc67d commit a2c7d17c2ff728c5fbc9325d03422c98f2678a1b Roger Lee Whitcomb committed Nov 14, 2012
Showing with 28 additions and 18 deletions.
  1. +28 −18 wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraSheetSkin.java
@@ -181,6 +181,9 @@ public void paint(Graphics2D graphics) {
private Quadratic easing = new Quadratic();
private TranslationDecorator translationDecorator = new TranslationDecorator(true);
+ private boolean closingResult;
+ private boolean doingFinalClose = false;
+
private ComponentListener ownerListener = new ComponentListener.Adapter() {
@Override
public void locationChanged(Component component, int previousX, int previousY) {
@@ -653,46 +656,53 @@ public void windowClosed(Window window, Display display, Window owner) {
}
@Override
- public Vote previewSheetClose(final Sheet sheet, final boolean result) {
- // Start a close transition, return false, and close the window
- // when the transition is complete
+ public Vote previewSheetClose(Sheet sheet, boolean result) {
Vote vote = Vote.APPROVE;
// Don't start the transition if the sheet is being closed as a result
// of the owner closing
Window owner = sheet.getOwner();
if (!(owner.isClosing()
- || owner.isClosed())) {
- TransitionListener transitionListener = new TransitionListener() {
- @Override
- public void transitionCompleted(Transition transition) {
- sheet.close(result);
- openTransition = null;
- }
- };
-
+ || owner.isClosed()
+ || doingFinalClose)) {
if (openTransition == null) {
- // Start the close transition
+ // Setup for the close transition
+ // Don't start it until we know that everyone
+ // else is okay with it
openTransition = new OpenTransition(true);
- openTransition.start(transitionListener);
+ closingResult = result;
} else {
// Reverse the open transition
- openTransition.reverse();
+ if (openTransition.isRunning()) {
+ openTransition.reverse();
+ }
}
- vote = (openTransition != null
- && openTransition.isRunning()) ? Vote.DEFER : Vote.APPROVE;
+ vote = (openTransition != null) ? Vote.DEFER : Vote.APPROVE;
}
return vote;
}
@Override
- public void sheetCloseVetoed(Sheet sheet, Vote reason) {
+ public void sheetCloseVetoed(final Sheet sheet, Vote reason) {
if (reason == Vote.DENY
&& openTransition != null) {
openTransition.stop();
openTransition = null;
+ } else
+ if (reason == Vote.DEFER
+ && openTransition != null
+ && !openTransition.isRunning()) {
+ openTransition.start(new TransitionListener() {
+ @Override
+ public void transitionCompleted(Transition transition) {
+ openTransition = null;
+ doingFinalClose = true;
+ sheet.close(closingResult);
+ doingFinalClose = false;
+ }
+ });
}
}

0 comments on commit a2c7d17

Please sign in to comment.