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/09/02 19:58:09 UTC

svn commit: r810633 - in /incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk: Window.java skin/WindowSkin.java skin/terra/TerraFrameSkin.java skin/terra/TerraPaletteSkin.java skin/terra/TerraSheetSkin.java skin/terra/TerraTooltipSkin.java

Author: gbrown
Date: Wed Sep  2 17:58:09 2009
New Revision: 810633

URL: http://svn.apache.org/viewvc?rev=810633&view=rev
Log:
Resolve issues PIVOT-265 and PIVOT-266.

Modified:
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Window.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/WindowSkin.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFrameSkin.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraPaletteSkin.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraSheetSkin.java
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTooltipSkin.java

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Window.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Window.java?rev=810633&r1=810632&r2=810633&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Window.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Window.java Wed Sep  2 17:58:09 2009
@@ -33,6 +33,13 @@
  */
 public class Window extends Container {
     /**
+     * Window skin interface.
+     */
+    public interface Skin extends org.apache.pivot.wtk.Skin {
+        public Bounds getClientArea();
+    }
+
+    /**
      * Class representing a mapping from keystrokes to actions.
      */
     public static class ActionMapping {
@@ -785,6 +792,14 @@
     }
 
     /**
+     * Returns the bounds of the window's client area.
+     */
+    public Bounds getClientArea() {
+        Window.Skin windowSkin = (Window.Skin)getSkin();
+        return windowSkin.getClientArea();
+    }
+
+    /**
      * Returns the window's auxilliary flag. Auxilliary windows can't become
      * active and can only own other auxilliary windows.
      *
@@ -914,16 +929,13 @@
     }
 
     /**
-     * Moves the window to the top of the window stack. The window is removed
-     * from its current position in the display's component sequence and
-     * appended to the end. It is also moved to the top of its owner's owned
-     * window list so it becomes top-most of all windows owned by its owner.
+     * Moves the window to the top of the window stack. If it is not an
+     * auxilliary window, it is made active, and focus is restored to the
+     * most recently focused decendant.
      * <p>
      * All windows owned by this window are subsequently moved to the front,
      * ensuring that this window's owned windows remain on top of it.
      * <p>
-     * Finally, the window is made active and focus is restored to the most
-     * recently focused decendant component.
      */
     public void moveToFront() {
         if (!isOpen()) {

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/WindowSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/WindowSkin.java?rev=810633&r1=810632&r2=810633&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/WindowSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/WindowSkin.java Wed Sep  2 17:58:09 2009
@@ -19,6 +19,7 @@
 import java.awt.Color;
 
 import org.apache.pivot.util.Vote;
+import org.apache.pivot.wtk.Bounds;
 import org.apache.pivot.wtk.Component;
 import org.apache.pivot.wtk.Container;
 import org.apache.pivot.wtk.Dimensions;
@@ -34,8 +35,8 @@
 /**
  * Window skin.
  */
-public class WindowSkin extends ContainerSkin
-    implements WindowListener, WindowStateListener {
+public class WindowSkin extends ContainerSkin implements Window.Skin,
+    WindowListener, WindowStateListener {
     /**
      * Focus traversal policy that always returns the window's content. This
      * ensures that focus does not traverse out of the window.
@@ -120,6 +121,11 @@
     }
 
     @Override
+    public Bounds getClientArea() {
+        return new Bounds(0, 0, getWidth(), getHeight());
+    }
+
+    @Override
     public boolean mouseDown(Component component, Mouse.Button button, int x, int y) {
         boolean consumed = super.mouseDown(component, button, x, y);
 

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFrameSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFrameSkin.java?rev=810633&r1=810632&r2=810633&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFrameSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFrameSkin.java Wed Sep  2 17:58:09 2009
@@ -63,7 +63,6 @@
     public static class FrameButton extends PushButton {
         public FrameButton(Object buttonData) {
             super(buttonData);
-
             installSkin(FrameButton.class);
         }
     }
@@ -462,6 +461,7 @@
 
         return new Dimensions(preferredWidth, preferredHeight);
     }
+
     public void layout() {
         Frame frame = (Frame)getComponent();
 
@@ -585,6 +585,26 @@
     }
 
     @Override
+    public Bounds getClientArea() {
+        int width = getWidth();
+        int height = getHeight();
+        int titleBarHeight = titleBarTablePane.getHeight();
+
+        Frame frame = (Frame)getComponent();
+        boolean maximized = frame.isMaximized();
+
+        Bounds clientArea;
+        if (maximized
+            && !getShowWindowControls()) {
+            clientArea = new Bounds(0, 0, width, height);
+        } else {
+            clientArea = new Bounds(1, titleBarHeight + 2, width - 2, height - (titleBarHeight + 2));
+        }
+
+        return clientArea;
+    }
+
+    @Override
     public void setBackgroundColor(Color backgroundColor) {
         super.setBackgroundColor(backgroundColor);
         contentBevelColor = TerraTheme.brighten(backgroundColor);

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraPaletteSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraPaletteSkin.java?rev=810633&r1=810632&r2=810633&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraPaletteSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraPaletteSkin.java Wed Sep  2 17:58:09 2009
@@ -278,7 +278,7 @@
         // Size/position title bar
         titleBarTablePane.setLocation(1, 1);
         titleBarTablePane.setSize(Math.max(width - 2, 0),
-            Math.max(titleBarTablePane.getPreferredHeight(width - 2), 0));
+            titleBarTablePane.getPreferredHeight());
 
         // Size/position content
         Component content = palette.getContent();
@@ -327,6 +327,15 @@
     }
 
     @Override
+    public Bounds getClientArea() {
+        int width = getWidth();
+        int height = getHeight();
+        int titleBarHeight = titleBarTablePane.getHeight();
+
+        return new Bounds(1, titleBarHeight + 2, width - 2, height - (titleBarHeight + 2));
+    }
+
+    @Override
     public void setBackgroundColor(Color backgroundColor) {
         super.setBackgroundColor(backgroundColor);
         contentBevelColor = TerraTheme.brighten(backgroundColor);

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraSheetSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraSheetSkin.java?rev=810633&r1=810632&r2=810633&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraSheetSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraSheetSkin.java Wed Sep  2 17:58:09 2009
@@ -22,6 +22,7 @@
 import org.apache.pivot.collections.Dictionary;
 import org.apache.pivot.util.Vote;
 import org.apache.pivot.wtk.ApplicationContext;
+import org.apache.pivot.wtk.Bounds;
 import org.apache.pivot.wtk.Component;
 import org.apache.pivot.wtk.ComponentListener;
 import org.apache.pivot.wtk.Container;
@@ -69,16 +70,13 @@
     private OpenTransition openTransition = null;
     private Quadratic easing = new Quadratic();
 
-    // TODO Eliminate these and replace with a window component listener
-    private ComponentListener ownerComponentListener = new ComponentListener.Adapter() {
+    private ComponentListener ownerListener = new ComponentListener.Adapter() {
         public void locationChanged(Component component, int previousX, int previousY) {
-            alignToOwnerContent();
+            alignToOwner();
         }
-    };
 
-    private ComponentListener ownerContentComponentListener = new ComponentListener.Adapter() {
         public void sizeChanged(Component component, int previousWidth, int previousHeight) {
-            alignToOwnerContent();
+            alignToOwner();
         }
     };
 
@@ -95,12 +93,14 @@
                 Window window = descendant.getWindow();
 
                 if (window.isOwner(sheet)) {
-                    // TODO Block for mouse over the client area only
-
-                    ApplicationContext.beep();
-                    window.moveToFront();
+                    Point location = window.mapPointFromAncestor(display, x, y);
 
-                    consumed = true;
+                    Bounds clientArea = window.getClientArea();
+                    if (clientArea.contains(location)) {
+                        ApplicationContext.beep();
+                        window.moveToFront();
+                        consumed = true;
+                    }
                 }
             }
 
@@ -270,7 +270,7 @@
     public void sizeChanged(Component component, int previousWidth, int previousHeight) {
         super.sizeChanged(component, previousWidth, previousHeight);
 
-        alignToOwnerContent();
+        alignToOwner();
     }
 
     @Override
@@ -379,10 +379,7 @@
         dropShadowDecorator.setShadowOpacity(DropShadowDecorator.DEFAULT_SHADOW_OPACITY);
 
         Window owner = window.getOwner();
-        owner.getComponentListeners().add(ownerComponentListener);
-
-        Component ownerContent = owner.getContent();
-        ownerContent.getComponentListeners().add(ownerContentComponentListener);
+        owner.getComponentListeners().add(ownerListener);
 
         openTransition = new OpenTransition(false);
         openTransition.start(new TransitionListener() {
@@ -444,19 +441,16 @@
 
     public void sheetClosed(Sheet sheet) {
         Window owner = sheet.getOwner();
-        owner.getComponentListeners().remove(ownerComponentListener);
-
-        Component ownerContent = owner.getContent();
-        ownerContent.getComponentListeners().remove(ownerContentComponentListener);
+        owner.getComponentListeners().remove(ownerListener);
     }
 
-    public void alignToOwnerContent() {
+    public void alignToOwner() {
         Sheet sheet = (Sheet)getComponent();
 
         Window owner = sheet.getOwner();
-        Component content = owner.getContent();
-        Point contentLocation = content.mapPointToAncestor(owner.getDisplay(), 0, 0);
-        sheet.setLocation(contentLocation.x + (content.getWidth() - getWidth()) / 2,
-            contentLocation.y);
+        Bounds clientArea = owner.getClientArea();
+
+        Point location = owner.mapPointToAncestor(owner.getDisplay(), clientArea.x, clientArea.y);
+        sheet.setLocation(location.x + (clientArea.width - getWidth()) / 2, location.y);
     }
 }

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTooltipSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTooltipSkin.java?rev=810633&r1=810632&r2=810633&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTooltipSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraTooltipSkin.java Wed Sep  2 17:58:09 2009
@@ -47,7 +47,7 @@
 
     private boolean fade = true;
 
-    private ContainerMouseListener displayContainerMouseListener = new ContainerMouseListener() {
+    private ContainerMouseListener displayMouseListener = new ContainerMouseListener() {
         public boolean mouseMove(Container container, int x, int y) {
             Tooltip tooltip = (Tooltip)getComponent();
             tooltip.close();
@@ -142,7 +142,7 @@
 
         // Add this as a display mouse and key listener
         Display display = window.getDisplay();
-        display.getContainerMouseListeners().add(displayContainerMouseListener);
+        display.getContainerMouseListeners().add(displayMouseListener);
         display.getComponentKeyListeners().add(displayKeyListener);
     }
 
@@ -186,7 +186,7 @@
         super.windowClosed(window, display);
 
         // Remove this as a display mouse and key listener
-        display.getContainerMouseListeners().remove(displayContainerMouseListener);
+        display.getContainerMouseListeners().remove(displayMouseListener);
         display.getComponentKeyListeners().remove(displayKeyListener);
 
         closeTransition = null;