You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2009/05/24 22:13:42 UTC
svn commit: r778222 - in /incubator/pivot/trunk/wtk/src/pivot/wtk:
ApplicationContext.java Display.java skin/terra/TerraTabPaneSkin.java
Author: gbrown
Date: Sun May 24 20:13:41 2009
New Revision: 778222
URL: http://svn.apache.org/viewvc?rev=778222&view=rev
Log:
Fix layout issue in TerraTabPaneSkin; don't block relayouts when a paint is pending - instead, drop mouse motion event if processing the event would starve paint processing.
Modified:
incubator/pivot/trunk/wtk/src/pivot/wtk/ApplicationContext.java
incubator/pivot/trunk/wtk/src/pivot/wtk/Display.java
incubator/pivot/trunk/wtk/src/pivot/wtk/skin/terra/TerraTabPaneSkin.java
Modified: incubator/pivot/trunk/wtk/src/pivot/wtk/ApplicationContext.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/ApplicationContext.java?rev=778222&r1=778221&r2=778222&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/ApplicationContext.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/ApplicationContext.java Sun May 24 20:13:41 2009
@@ -83,14 +83,14 @@
private Point dragLocation = null;
private Component dragDescendant = null;
-
private Manifest dragManifest = null;
-
private DropAction userDropAction = null;
private Component dropDescendant = null;
private double scale = 1;
+ private boolean paintPending = false;
+
private boolean debugRepaint = false;
private DropTargetListener dropTargetListener = new DropTargetListener() {
@@ -358,6 +358,8 @@
(int)Math.ceil(width * scale) + 1, (int)Math.ceil(height * scale) + 1);
}
}
+
+ paintPending = true;
}
@Override
@@ -386,6 +388,8 @@
throw exception;
}
}
+
+ paintPending = false;
}
@Override
@@ -808,135 +812,137 @@
protected void processMouseMotionEvent(MouseEvent event) {
super.processMouseMotionEvent(event);
- int x = (int)Math.round(event.getX() / scale);
- int y = (int)Math.round(event.getY() / scale);
-
- // Set the mouse location
- mouseLocation = new Point(x, y);
+ if (!paintPending) {
+ int x = (int)Math.round(event.getX() / scale);
+ int y = (int)Math.round(event.getY() / scale);
- // Process the event
- switch (event.getID()) {
- case MouseEvent.MOUSE_MOVED:
- case MouseEvent.MOUSE_DRAGGED: {
- if (dragDescendant == null) {
- // A drag is not active
- Component mouseCapturer = Mouse.getCapturer();
+ // Set the mouse location
+ mouseLocation = new Point(x, y);
- if (mouseCapturer == null) {
- // The mouse is not captured, so propagate the event to the display
- display.mouseMove(x, y);
-
- int dragThreshold = Platform.getDragThreshold();
+ // Process the event
+ switch (event.getID()) {
+ case MouseEvent.MOUSE_MOVED:
+ case MouseEvent.MOUSE_DRAGGED: {
+ if (dragDescendant == null) {
+ // A drag is not active
+ Component mouseCapturer = Mouse.getCapturer();
- if (dragLocation != null
- && (Math.abs(x - dragLocation.x) > dragThreshold
- || Math.abs(y - dragLocation.y) > dragThreshold)) {
- // The user has dragged the mouse past the drag threshold; try
- // to find a drag source
- dragDescendant = display.getDescendantAt(dragLocation.x,
- dragLocation.y);
-
- while (dragDescendant != null
- && dragDescendant.getDragSource() == null) {
- dragDescendant = dragDescendant.getParent();
- }
+ if (mouseCapturer == null) {
+ // The mouse is not captured, so propagate the event to the display
+ display.mouseMove(x, y);
+
+ int dragThreshold = Platform.getDragThreshold();
+
+ if (dragLocation != null
+ && (Math.abs(x - dragLocation.x) > dragThreshold
+ || Math.abs(y - dragLocation.y) > dragThreshold)) {
+ // The user has dragged the mouse past the drag threshold; try
+ // to find a drag source
+ dragDescendant = display.getDescendantAt(dragLocation.x,
+ dragLocation.y);
+
+ while (dragDescendant != null
+ && dragDescendant.getDragSource() == null) {
+ dragDescendant = dragDescendant.getParent();
+ }
- if (dragDescendant == null
- || dragDescendant.isBlocked()) {
- // There was nothing to drag, so clear the drag location
- dragDescendant = null;
- dragLocation = null;
- } else {
- DragSource dragSource = dragDescendant.getDragSource();
- dragLocation = dragDescendant.mapPointFromAncestor(display, x, y);
+ if (dragDescendant == null
+ || dragDescendant.isBlocked()) {
+ // There was nothing to drag, so clear the drag location
+ dragDescendant = null;
+ dragLocation = null;
+ } else {
+ DragSource dragSource = dragDescendant.getDragSource();
+ dragLocation = dragDescendant.mapPointFromAncestor(display, x, y);
- if (dragSource.beginDrag(dragDescendant, dragLocation.x, dragLocation.y)) {
- // A drag has started
- if (dragSource.isNative()) {
- // Clear the drag state since it is not used for
- // native drags
+ if (dragSource.beginDrag(dragDescendant, dragLocation.x, dragLocation.y)) {
+ // A drag has started
+ if (dragSource.isNative()) {
+ // Clear the drag state since it is not used for
+ // native drags
+ dragDescendant = null;
+ dragLocation = null;
+
+ startNativeDrag(dragSource, event);
+ } else {
+ if (dragSource.getRepresentation() != null
+ && dragSource.getOffset() == null) {
+ throw new IllegalStateException("Drag offset is required when a "
+ + " respresentation is specified.");
+ }
+
+ if (display.isMouseOver()) {
+ display.mouseOut();
+ }
+
+ // Get the drag content
+ dragManifest = dragSource.getContent();
+
+ // Get the initial user drop action
+ userDropAction = getUserDropAction(event);
+
+ // Repaint the drag visual
+ dragLocation = new Point(x, y);
+ repaintDragRepresentation();
+ }
+ } else {
+ // Clear the drag state
dragDescendant = null;
dragLocation = null;
-
- startNativeDrag(dragSource, event);
- } else {
- if (dragSource.getRepresentation() != null
- && dragSource.getOffset() == null) {
- throw new IllegalStateException("Drag offset is required when a "
- + " respresentation is specified.");
- }
-
- if (display.isMouseOver()) {
- display.mouseOut();
- }
-
- // Get the drag content
- dragManifest = dragSource.getContent();
-
- // Get the initial user drop action
- userDropAction = getUserDropAction(event);
-
- // Repaint the drag visual
- dragLocation = new Point(x, y);
- repaintDragRepresentation();
}
- } else {
- // Clear the drag state
- dragDescendant = null;
- dragLocation = null;
}
}
+ } else {
+ // Delegate the event to the capturer
+ Point location = mouseCapturer.mapPointFromAncestor(display, x, y);
+ mouseCapturer.mouseMove(location.x, location.y);
}
} else {
- // Delegate the event to the capturer
- Point location = mouseCapturer.mapPointFromAncestor(display, x, y);
- mouseCapturer.mouseMove(location.x, location.y);
- }
- } else {
- if (dragLocation != null) {
- DragSource dragSource = dragDescendant.getDragSource();
+ if (dragLocation != null) {
+ DragSource dragSource = dragDescendant.getDragSource();
- // Get the previous and current drop descendant and call
- // move or exit/enter as appropriate
- Component previousDropDescendant = dropDescendant;
- dropDescendant = getDropDescendant(x, y);
-
- DropAction dropAction = null;
-
- if (previousDropDescendant == dropDescendant) {
- if (dropDescendant != null) {
- DropTarget dropTarget = dropDescendant.getDropTarget();
-
- Point dropLocation = dropDescendant.mapPointFromAncestor(display, x, y);
- dropAction = dropTarget.dragMove(dropDescendant, dragManifest,
- dragSource.getSupportedDropActions(),
- dropLocation.x, dropLocation.y, userDropAction);
- }
- } else {
- if (previousDropDescendant != null) {
- DropTarget previousDropTarget = previousDropDescendant.getDropTarget();
- previousDropTarget.dragExit(previousDropDescendant);
- }
+ // Get the previous and current drop descendant and call
+ // move or exit/enter as appropriate
+ Component previousDropDescendant = dropDescendant;
+ dropDescendant = getDropDescendant(x, y);
+
+ DropAction dropAction = null;
+
+ if (previousDropDescendant == dropDescendant) {
+ if (dropDescendant != null) {
+ DropTarget dropTarget = dropDescendant.getDropTarget();
+
+ Point dropLocation = dropDescendant.mapPointFromAncestor(display, x, y);
+ dropAction = dropTarget.dragMove(dropDescendant, dragManifest,
+ dragSource.getSupportedDropActions(),
+ dropLocation.x, dropLocation.y, userDropAction);
+ }
+ } else {
+ if (previousDropDescendant != null) {
+ DropTarget previousDropTarget = previousDropDescendant.getDropTarget();
+ previousDropTarget.dragExit(previousDropDescendant);
+ }
- if (dropDescendant != null) {
- DropTarget dropTarget = dropDescendant.getDropTarget();
- dropAction = dropTarget.dragEnter(dropDescendant, dragManifest,
- dragSource.getSupportedDropActions(), userDropAction);
+ if (dropDescendant != null) {
+ DropTarget dropTarget = dropDescendant.getDropTarget();
+ dropAction = dropTarget.dragEnter(dropDescendant, dragManifest,
+ dragSource.getSupportedDropActions(), userDropAction);
+ }
}
- }
- // Update cursor
- setCursor(getDropCursor(dropAction));
+ // Update cursor
+ setCursor(getDropCursor(dropAction));
- // Repaint the drag visual
- repaintDragRepresentation();
+ // Repaint the drag visual
+ repaintDragRepresentation();
- dragLocation = new Point(x, y);
- repaintDragRepresentation();
+ dragLocation = new Point(x, y);
+ repaintDragRepresentation();
+ }
}
- }
- break;
+ break;
+ }
}
}
}
@@ -1236,8 +1242,8 @@
* @param location
*/
public static void open(URL location) {
- // TODO Remove dynamic invocation when Java 6 is supported on the Mac
-
+ // TODO Remove dynamic invocation when Java 6 is fully supported on
+ // Mac OS X
try {
Class<?> desktopClass = Class.forName("java.awt.Desktop");
Method getDesktopMethod = desktopClass.getMethod("getDesktop", new Class<?>[] {});
Modified: incubator/pivot/trunk/wtk/src/pivot/wtk/Display.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/Display.java?rev=778222&r1=778221&r2=778222&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/Display.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/Display.java Sun May 24 20:13:41 2009
@@ -28,15 +28,12 @@
private class ValidateCallback implements Runnable {
public void run() {
validate();
- if (!paintPending) {
- validateCallback = null;
- }
+ validateCallback = null;
}
}
private ApplicationContext.DisplayHost displayHost;
private ValidateCallback validateCallback = null;
- private boolean paintPending = false;
protected Display(ApplicationContext.DisplayHost displayHost) {
this.displayHost = displayHost;
@@ -58,7 +55,7 @@
@Override
protected void setParent(Container parent) {
- throw new UnsupportedOperationException();
+ throw new UnsupportedOperationException("Display can't have a parent.");
}
@Override
@@ -82,7 +79,7 @@
Graphics2D graphics = (Graphics2D)displayHost.getGraphics();
// If the display host has been made non-displayable (as will
- // happen when the native peer closes), graphics will be null.
+ // happen when the native peer closes), graphics will be null
if (graphics != null) {
double scale = displayHost.getScale();
if (scale == 1) {
@@ -97,17 +94,6 @@
}
} else {
displayHost.repaint(x, y, width, height);
- paintPending = true;
- }
- }
-
- @Override
- public void paint(Graphics2D graphics) {
- super.paint(graphics);
- paintPending = false;
-
- if (validateCallback != null) {
- ApplicationContext.queueCallback(validateCallback);
}
}
Modified: incubator/pivot/trunk/wtk/src/pivot/wtk/skin/terra/TerraTabPaneSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/skin/terra/TerraTabPaneSkin.java?rev=778222&r1=778221&r2=778222&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/skin/terra/TerraTabPaneSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/skin/terra/TerraTabPaneSkin.java Sun May 24 20:13:41 2009
@@ -1046,6 +1046,11 @@
this.tabOrientation = tabOrientation;
+ // Invalidate the tab buttons since their preferred sizes have changed
+ for (Component tabButton : buttonFlowPane) {
+ tabButton.invalidate();
+ }
+
buttonFlowPane.setOrientation(tabOrientation);
switch (tabOrientation) {