changeset 2133:b0a03ab44363

Automated merge with ssh://jfxsrc.us.oracle.com//javafx/8.0/scrum/controls/jfx/rt
author jgiles
date Fri, 04 Jan 2013 15:21:29 +1300
parents 02985c07385e 0eb2889dede0
children 42eb515e4bfb
files javafx-ui-controls/src/com/sun/javafx/scene/control/skin/PopupControlSkin.java
diffstat 5 files changed, 38 insertions(+), 280 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/PopupControlSkin.java	Thu Jan 03 15:56:03 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,186 +0,0 @@
-/*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.javafx.scene.control.skin;
-
-import javafx.event.Event;
-import javafx.event.EventHandler;
-import javafx.scene.Node;
-import javafx.scene.Parent;
-import javafx.scene.Scene;
-import javafx.scene.control.PopupControl;
-import javafx.scene.control.Skin;
-import javafx.stage.Popup;
-import javafx.stage.Window;
-
-/**
- * PoppedUp Controls are different from other controls in that some, or all, of
- * their visuals are hosted in a Popup. Because the Popup is not itself a member
- * of the scenegraph, we need to manage sending certain messages such as
- * processing of CSS and layout between the "base" or "anchor" scenegraph and
- * the popup scenegraph. This class manages these details.
- * <p>
- * Subclasses of PopupControlSkin may want to provide a Region which represents
- * the Control in the base scenegraph, and must provide a Region which
- * represents this control in the popup. These regions will be mapped in
- * as appropriate by this class.
- * <p>
- * The popup associated with this skin is defined as a protected variable. By
- * default a new Popup instance is created for each PopupControlSkin instance,
- * though subclasses may reuse popups (c.f. TooltipSkin).
- * <p>
- * The popup is shown or hidden based on the {@code showing} variable. It is
- * the responsibility of the subclass to make sure this variable is updated
- * as appropriate based on state on the Control or on other state.
- * <p>
- * When {@code showing} changes to true, the showPopup() function will be
- * called. The implementation of that function relies on the {@code screenX} and
- * {@code screenY} variables for positioning of the popup. Subclasses should
- * ensure that these variables are setup correctly.
- * <p>
- * When {@code showing) changes to false, then the hidePopup() function will
- * be called.
- */
-public class PopupControlSkin<C extends PopupControl> implements Skin<C>{
-
-    /**
-    * This var keeps a count of visible Popup controls other than the tooltip
-    * There should only be at most one visible popup control at any given time
-    */
-    private static int visiblePopupControlCount=0;
-
-    /**
-     * The visual representation for the Control in the "base" scenegraph. This
-     * may be null if there is no base representation (such as with a Tooltip).
-     */
-    protected Node content;
-
-    /**
-     * The visual representation for the Control in the popup. This must be
-     * specified.
-     */
-    protected Node popupContent;
-
-    /**
-     * Indicates whether the popup should be showing or hidden. It is the
-     * responsibility of subclasses to bind this showing variable to the
-     * appropriate var on the control
-     */
-    protected boolean showing = false;
-
-    protected void setShowing(boolean value) {
-       boolean oldValue = showing;
-       showing = value;
-       showHidePopup(oldValue);
-    }
-
-    protected void showHidePopup(boolean oldValue) {
-        if (showing) {
-            visiblePopupControlCount++;
-            showPopup();
-        } else if (oldValue) {
-            visiblePopupControlCount--;
-            hidePopup();
-        }
-    }
-
-    /**
-     * The popup menu which will be used. The subclass generally doesn't need
-     * to access this variable, except for Tooltip, which does so to make sure
-     * that the shared popup is used.
-     */
-    protected Popup popup;
-
-    /**
-     * The screenX position at which to show the popup.
-     */
-    protected double screenX;
-
-    /**
-     * The screenY position at which to show the popup.
-     */
-    protected double screenY;
-
-    protected void onAutoHide() {
-        // do nothing subclasses can override. 
-    }
-    protected void showPopup() {
-        if (popup == null) {
-            popup = new Popup();
-            popup.setAutoHide(true);
-            popup.setAutoFix(true);
-            popup.setOnAutoHide(new EventHandler<Event>() {
-                @Override public void handle(Event evt) {
-                    onAutoHide();
-                }
-            });
-        }
-
-        // Call show before setting the content. In order for popupContent
-        // to be styled, the popupContent must be in a Scene and the Scene
-        // must be in a Window.
-        final Scene scene = content == null ? null : content.getScene();
-        final Window win = scene == null ? null : scene.getWindow();
-        // TODO: do we need this test?
-        if (win == null) return;
-        popup.show(content, screenX, screenY);
-
-        // Adding content here triggers Popup.invokeDimensions()
-        popup.getContent().setAll(popupContent);
-
-        if (popupContent instanceof Parent) {
-            ((Parent) popupContent).requestLayout();
-        }
-//        getSkinnable().autosize();
-        popupContent.autosize();
-    }
-
-    protected void hidePopup() {
-        if (popup != null) {
-            popup.hide();
-            // null the popup to reclaim memory
-            popup.getContent().clear();
-            popup = null;
-        }
-    }
-
-    /* ************************************************************************
-     *                    Skin Implementation                                 *
-     **************************************************************************/
-
-    @Override public Node getNode() {
-        // subclasses should override
-        return null;
-    }
-
-    @Override public void dispose() {
-       // do nothing subclasses should override
-    }
-
-    @Override public C getSkinnable() {
-        // subclasses should override
-        return null;
-    }
-}
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableColumnHeader.java	Thu Jan 03 15:56:03 2013 -0800
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableColumnHeader.java	Fri Jan 04 15:21:29 2013 +1300
@@ -404,7 +404,12 @@
         if (! isSortingEnabled()) return;
         
         isSortColumn = sortPos != -1;
-        if (! isSortColumn) return;
+        if (! isSortColumn) {
+            if (sortArrow != null) {
+                sortArrow.setVisible(false);
+            }
+            return;
+        }
         
         final int sortColumnCount = getTableViewSkin().getSortOrder().size();
         boolean showSortOrderDots = sortPos <= 3 && sortColumnCount > 1;
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TooltipSkin.java	Thu Jan 03 15:56:03 2013 -0800
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TooltipSkin.java	Fri Jan 04 15:21:29 2013 +1300
@@ -22,35 +22,27 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
 package com.sun.javafx.scene.control.skin;
 
 import javafx.scene.Node;
 import javafx.scene.control.Label;
 import javafx.scene.control.Skin;
 import javafx.scene.control.Tooltip;
-import javafx.scene.layout.StackPane;
 
 /**
- * Region/css based skin for Tooltip. It deals mostly with show hide logic for
+ * CSS based skin for Tooltip. It deals mostly with show hide logic for
  * Popup based controls, and specifically in this case for tooltip. It also
  * implements some of the Skin interface methods.
  *
  * TooltipContent class is the actual skin implementation of the tooltip.
  */
-public class TooltipSkin implements Skin<Tooltip> { //extends PopupControlSkin<Tooltip> {
-    private StackPane root;
+public class TooltipSkin implements Skin<Tooltip> { 
     private Label tipLabel;
-    private StackPane pageCorner;
 
     private Tooltip tooltip;
 
     public TooltipSkin(Tooltip t) {
         this.tooltip = t;
-//        setEffect(t.getEffect());
         tipLabel = new Label();
         tipLabel.contentDisplayProperty().bind(t.contentDisplayProperty());
         tipLabel.fontProperty().bind(t.fontProperty());
@@ -59,75 +51,31 @@
         tipLabel.textOverrunProperty().bind(t.textOverrunProperty());
         tipLabel.textProperty().bind(t.textProperty());
         tipLabel.wrapTextProperty().bind(t.wrapTextProperty());
-        pageCorner = new StackPane();
-        pageCorner.getStyleClass().setAll("page-corner");
-      
-        root = new StackPane() {
-            @Override protected void layoutChildren() {
-                tipLabel.resizeRelocate(getInsets().getLeft(), getInsets().getTop(),
-                        getWidth() - getInsets().getLeft() - getInsets().getRight(),
-                        getHeight() - getInsets().getTop() - getInsets().getBottom());
-                double pw = pageCorner.prefWidth(-1);
-                double ph = pageCorner.prefHeight(-1);
-                pageCorner.resizeRelocate((getWidth() - pw), (getHeight() - ph), pw, ph);
-            }
+        tipLabel.minWidthProperty().bind(t.minWidthProperty());
+        tipLabel.prefWidthProperty().bind(t.prefWidthProperty());
+        tipLabel.maxWidthProperty().bind(t.maxWidthProperty());
+        tipLabel.minHeightProperty().bind(t.minHeightProperty());
+        tipLabel.prefHeightProperty().bind(t.prefHeightProperty());
+        tipLabel.maxHeightProperty().bind(t.maxHeightProperty());
 
-            @Override protected double computeMinWidth(double width) {
-                return (tooltip.getMinWidth() != -1) ? tooltip.getMinWidth() : computePrefWidth(width);
-            }
-
-             @Override protected double computeMinHeight(double height) {
-                return (tooltip.getMinHeight() != -1) ? tooltip.getMinHeight() : computePrefHeight(height);
-            }
-
-            @Override protected double computePrefWidth(double width) {
-                 if(tooltip.getPrefWidth() != -1 ) {
-                    return tooltip.getPrefWidth();
-                } else {
-                     return (tooltip.isWrapText()) ? tipLabel.prefWidth(width) :
-                         getInsets().getLeft() + tipLabel.prefWidth(-1) + getInsets().getRight();
-                }
-            }
-
-            @Override protected double computePrefHeight(double height) {
-                 if (tooltip.getPrefWidth() != -1) {
-                     return getInsets().getTop() +
-                         tipLabel.prefHeight(tooltip.getPrefWidth() - getInsets().getLeft() - getInsets().getRight()) +
-                         getInsets().getBottom();
-                 } else {
-                    return getInsets().getTop() + tipLabel.prefHeight(-1) + getInsets().getBottom();
-                 }
-
-            }
-            @Override protected double computeMaxWidth(double width) {
-                return (tooltip.getMaxWidth() != -1) ? tooltip.getMaxWidth() : computePrefWidth(width);
-            }
-
-            @Override protected double computeMaxHeight(double height) {
-               return (tooltip.getMaxHeight() != -1) ? tooltip.getMaxHeight() : computePrefHeight(height);
-             }
-
-        };
-
-        root.getChildren().addAll(tipLabel, pageCorner);
         // RT-7512 - skin needs to have styleClass of the control
         // TODO - This needs to be bound together, not just set! Probably should
         // do the same for id and style as well.
-        root.getStyleClass().setAll(t.getStyleClass());
-        root.setStyle(t.getStyle());
-        root.setId(t.getId());
+        tipLabel.getStyleClass().setAll(t.getStyleClass());
+        tipLabel.setStyle(t.getStyle());
+        tipLabel.setId(t.getId());
     }
     
-    
     @Override public Tooltip getSkinnable() {
         return tooltip;
     }
 
     @Override public Node getNode() {
-        return root;
+        return tipLabel;
     }
 
     @Override public void dispose() {
         tooltip = null;
+        tipLabel = null;
     }
 }
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/caspian/caspian.css	Thu Jan 03 15:56:03 2013 -0800
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/caspian/caspian.css	Fri Jan 04 15:21:29 2013 +1300
@@ -1864,18 +1864,10 @@
         linear-gradient(#fefefc, #e6dd71),
         linear-gradient(#fef592, #e5d848);
     -fx-background-insets: 0,1,2;
-    -fx-background-radius: 0 0 13 0;
     -fx-padding: 0.333333em 0.666667em 0.333333em 0.666667em; /* 4 8 4 8 */
     -fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 8, 0.0 , 0 , 0 );
 }
 
-.page-corner {
-    -fx-padding: 4.5 4.5 4.5 4.5;
-    -fx-background-color: linear-gradient( from 0% 0% to 50% 50%, #fcf7b6, #a59c31);
-    -fx-shape: "M0,0H9L0,9Z";
-    -fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 4 , 0.0 , 0 , 0 );
-}
-
 /*******************************************************************************
  *                                                                             *
  * Toolbar                                                                     *
--- a/javafx-ui-controls/src/javafx/scene/control/PopupControl.java	Thu Jan 03 15:56:03 2013 -0800
+++ b/javafx-ui-controls/src/javafx/scene/control/PopupControl.java	Fri Jan 04 15:21:29 2013 +1300
@@ -866,24 +866,6 @@
 //    public double getBaselineOffset() { return getSkinNode() == null? 0 : getSkinNode().getBaselineOffset(); }
 
     /**
-     * Called from several places whenever the children of the Control
-     * may need to be updated (principally, when the tool tip changes,
-     * the skin changes, or the skin.node changes).
-     */
-    private void updateChildren() {
-        prefWidthCache = -1;
-        prefHeightCache = -1;
-        minWidthCache = -1;
-        minHeightCache = -1;
-        maxWidthCache = -1;
-        maxHeightCache = -1;
-        skinSizeComputed = false;
-        final Node n = getSkinNode();
-        if (n != null) bridge.getChildren().setAll(n);
-        else bridge.getChildren().clear();
-    }
-
-    /**
      * Create a new instance of the default skin for this control. This is called to create a skin for the control if
      * no skin is provided via CSS {@code -fx-skin} or set explicitly in a sub-class with {@code  setSkin(...)}.
      *
@@ -1095,8 +1077,25 @@
                 if (oldValue != null) oldValue.dispose();
                 // Get the new value, and save it off as the new oldValue
                 oldValue = getValue();
-                // Update the children list with the new skin node
-                updateChildren();
+                
+                prefWidthCache = -1;
+                prefHeightCache = -1;
+                minWidthCache = -1;
+                minHeightCache = -1;
+                maxWidthCache = -1;
+                maxHeightCache = -1;
+                skinSizeComputed = false;
+                final Node n = getSkinNode();
+                if (n != null) bridge.getChildren().setAll(n);
+                else bridge.getChildren().clear();
+
+                // calling impl_reapplyCSS() as the styleable properties may now
+                // be different, as we will now be able to return styleable properties 
+                // belonging to the skin. If impl_reapplyCSS() is not called, the 
+                // getCssMetaData() method is never called, so the 
+                // skin properties are never exposed.
+                impl_reapplyCSS();
+                
                 // DEBUG: Log that we've changed the skin
                 final PlatformLogger logger = Logging.getControlsLogger();
                 if (logger.isLoggable(PlatformLogger.FINEST)) {