changeset 2356:2a30c171d69d

Modena: fix Color Picker styling issues.
author "Jasper Potts"
date Wed, 23 Jan 2013 00:43:36 -0800
parents 61ec4e8030af
children cad0acc0359c
files javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ColorPalette.java javafx-ui-controls/src/com/sun/javafx/scene/control/skin/caspian/caspian.css javafx-ui-controls/src/com/sun/javafx/scene/control/skin/modena/modena.css
diffstat 3 files changed, 54 insertions(+), 47 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ColorPalette.java	Wed Jan 23 00:17:38 2013 -0800
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ColorPalette.java	Wed Jan 23 00:43:36 2013 -0800
@@ -25,15 +25,15 @@
 import javafx.scene.input.MouseEvent;
 import javafx.scene.layout.GridPane;
 import javafx.scene.layout.StackPane;
+import javafx.scene.layout.VBox;
 import javafx.scene.paint.Color;
 import javafx.scene.shape.Rectangle;
 import javafx.scene.shape.StrokeType;
 import javafx.stage.Window;
 
 
-public class ColorPalette extends StackPane {
-    
-    private static final int GAP = 15;
+public class ColorPalette extends VBox {
+
     private static final int SQUARE_SIZE = 15;
     private static final int NUM_OF_COLUMNS = 12;
     private static final int NUM_OF_ROWS = 10;
@@ -133,18 +133,19 @@
         int customRowIndex = 0;
         int remainingSquares = customSquares.size()%NUM_OF_COLUMNS;
         int numEmpty = (remainingSquares == 0) ? 0 : NUM_OF_COLUMNS - remainingSquares;
-        
+
         customColorGrid.getChildren().clear();
         if (customSquares.isEmpty()) {
-            customColorAdded = false;
             customColorLabel.setVisible(false);
+            customColorLabel.setManaged(false);
             customColorGrid.setVisible(false);
+            customColorGrid.setManaged(false);
             return;
-        }
-        if (!customColorAdded) {
-            customColorAdded = true;
+        } else {
             customColorLabel.setVisible(true);
+            customColorLabel.setManaged(true);
             customColorGrid.setVisible(true);
+            customColorGrid.setManaged(true);
             if (contextMenu == null) {
                 MenuItem item = new MenuItem("Remove Color");
                 item.setOnAction(new EventHandler<ActionEvent>() {
@@ -357,39 +358,39 @@
     public ColorPickerGrid getColorGrid() {
         return colorPickerGrid;
     }
-    
-    @Override protected void layoutChildren() {
-        double x = getInsets().getLeft();
-        double y = getInsets().getTop();
-//        double popupWidth = cpg.prefWidth(-1) + paddingX+getInsets().getRight();
-//        double popupHeight = cpg.prefHeight(-1) + getInsets().getTop() + getInsets().getBottom();
-        colorPickerGrid.relocate(x, y);
-        y = y+colorPickerGrid.prefHeight(-1)+GAP;
-        if (customColorAdded) {
-            if (customColorLabel.isVisible()) {
-                customColorLabel.resizeRelocate(x, y, colorPickerGrid.prefWidth(-1), customColorLabel.prefHeight(y));
-                y = y+customColorLabel.prefHeight(-1)+LABEL_GAP; 
-            }
-            customColorGrid.relocate(x, y);
-            y = y+customColorGrid.prefHeight(-1)+GAP;
-        }
-        separator.resizeRelocate(x, y, colorPickerGrid.prefWidth(-1), separator.prefHeight(-1));
-        y = y+separator.prefHeight(-1)+GAP;
-        customColorLink.resizeRelocate(x, y, colorPickerGrid.prefWidth(-1), customColorLink.prefHeight(-1));
-    }
-    
-    @Override protected double computePrefWidth(double height) {
-        return getInsets().getLeft() + colorPickerGrid.prefWidth(-1) + getInsets().getRight();
-    }
-    
-    @Override protected double computePrefHeight(double width) {
-        double totalHeight = colorPickerGrid.prefHeight(-1) + GAP + 
-                ((customColorAdded) ? 
-                (customColorGrid.prefHeight(-1)+customColorLabel.prefHeight(-1))+LABEL_GAP+GAP : 0) +
-                separator.prefHeight(-1) + GAP + customColorLink.prefHeight(-1);
-        return getInsets().getTop() + totalHeight + getInsets().getBottom();
-    }
-   
+//
+//    @Override protected void layoutChildren() {
+//        double x = getInsets().getLeft();
+//        double y = getInsets().getTop();
+////        double popupWidth = cpg.prefWidth(-1) + paddingX+getInsets().getRight();
+////        double popupHeight = cpg.prefHeight(-1) + getInsets().getTop() + getInsets().getBottom();
+//        colorPickerGrid.relocate(x, y);
+//        y = y+colorPickerGrid.prefHeight(-1)+GAP;
+//        if (customColorAdded) {
+//            if (customColorLabel.isVisible()) {
+//                customColorLabel.resizeRelocate(x, y, colorPickerGrid.prefWidth(-1), customColorLabel.prefHeight(y));
+//                y = y+customColorLabel.prefHeight(-1)+LABEL_GAP;
+//            }
+//            customColorGrid.relocate(x, y);
+//            y = y+customColorGrid.prefHeight(-1)+GAP;
+//        }
+//        separator.resizeRelocate(x, y, colorPickerGrid.prefWidth(-1), separator.prefHeight(-1));
+//        y = y+separator.prefHeight(-1)+GAP;
+//        customColorLink.resizeRelocate(x, y, colorPickerGrid.prefWidth(-1), customColorLink.prefHeight(-1));
+//    }
+//
+//    @Override protected double computePrefWidth(double height) {
+//        return getInsets().getLeft() + colorPickerGrid.prefWidth(-1) + getInsets().getRight();
+//    }
+//
+//    @Override protected double computePrefHeight(double width) {
+//        double totalHeight = colorPickerGrid.prefHeight(-1) + GAP +
+//                ((customColorAdded) ?
+//                (customColorGrid.prefHeight(-1)+customColorLabel.prefHeight(-1))+LABEL_GAP+GAP : 0) +
+//                separator.prefHeight(-1) + GAP + customColorLink.prefHeight(-1);
+//        return getInsets().getTop() + totalHeight + getInsets().getBottom();
+//    }
+//
     public boolean isCustomColorDialogShowing() {
         if (customColorDialog != null) return customColorDialog.isVisible();
         return false;
@@ -425,7 +426,12 @@
             Tooltip.install(this, new Tooltip((tooltipStr == null) ? "" : tooltipStr));
           
             rectangle.getStyleClass().add("color-rect");
-            
+
+            addEventHandler(MouseEvent.MOUSE_ENTERED, new EventHandler<MouseEvent>() {
+                @Override public void handle(MouseEvent event) {
+                    toFront();
+                }
+            });
             addEventHandler(MouseEvent.MOUSE_RELEASED, new EventHandler<MouseEvent>() {
                 @Override public void handle(MouseEvent event) {
                     if (!dragDetected && event.getButton() == MouseButton.PRIMARY && event.getClickCount() == 1) {
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/caspian/caspian.css	Wed Jan 23 00:17:38 2013 -0800
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/caspian/caspian.css	Wed Jan 23 00:43:36 2013 -0800
@@ -529,7 +529,7 @@
 
 .button:show-mnemonics > .mnemonic-underline {
     -fx-stroke: -fx-text-fill;
-} 
+}
 /*******************************************************************************
  *                                                                             *
  * ToggleButton                                                                *
@@ -3262,6 +3262,7 @@
 }
 
 .color-palette {
+    -fx-spacing: 15px;
      -fx-background-color:
         derive(-fx-color,-40%),
         derive(-fx-color,100%),
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/modena/modena.css	Wed Jan 23 00:17:38 2013 -0800
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/modena/modena.css	Wed Jan 23 00:43:36 2013 -0800
@@ -1690,14 +1690,14 @@
  ******************************************************************************/
 
 .color-picker > .arrow-button {
-    -fx-background-color: null;
+    -fx-background-color: null !important;
     -fx-padding: 0.5em 0.833333em 0.5em 0; /* 6 10 6 0 */
 }
-.color-picker.split-button {
-    -fx-background-color: null;
+.color-picker.split-button > .color-picker-label{
+    -fx-background-color: null !important;
 }
 .color-picker.split-button > .arrow-button {
-    -fx-background-color: -fx-outer-border, -fx-inner-border, -fx-body-color; 
+    -fx-background-color: -fx-outer-border, -fx-inner-border, -fx-body-color !important;
     -fx-padding: 0.5em 0.833333em 0.5em 0.833333em; /* 6 10 6 10 */
 }
 .color-picker > .color-picker-label > .picker-color > .picker-color-rect {