changeset 295:c06a484e652e

fix RT-18356 MenuBar : incorrect selection. RT-18960 MenuBar default foreground, background - bad contrast. - includes Jasper's caspian patch.
author Paru Somashekar <paru.somashekar@oracle.com>
date Fri, 20 Jan 2012 15:32:00 -0800
parents 0d061c4a6c44
children 55346b3feef9
files javafx-ui-controls/src/com/sun/javafx/scene/control/skin/MenuBarSkin.java javafx-ui-controls/src/com/sun/javafx/scene/control/skin/caspian/caspian.css
diffstat 2 files changed, 31 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/MenuBarSkin.java	Sat Jan 21 10:38:22 2012 +1300
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/MenuBarSkin.java	Fri Jan 20 15:32:00 2012 -0800
@@ -287,6 +287,16 @@
         return false;
     }
 
+    private int getMenuBarButtonIndex(MenuBarButton m) {
+        for (int i= 0; i < container.getChildren().size(); i++) {
+            MenuBarButton menuButton = (MenuBarButton)container.getChildren().get(i);
+            if (m == menuButton) {
+                return i;
+            }
+        }
+        return -1;
+    }
+    
     private void rebuildUI() {
         for(Node n : container.getChildren()) {
             //Stop observing menu's showing & disable property for changes.
@@ -418,6 +428,8 @@
                         } else {
                             openMenu = null;
                         }
+                        // update FocusedIndex
+                        focusedMenuIndex = getMenuBarButtonIndex(menuButton);
                     }
                 }
             });
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/caspian/caspian.css	Sat Jan 21 10:38:22 2012 +1300
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/caspian/caspian.css	Fri Jan 20 15:32:00 2012 -0800
@@ -898,38 +898,24 @@
     -fx-skin: "com.sun.javafx.scene.control.skin.MenuBarSkin";
     -fx-padding: 0.0em 0.666667em 0.0em 0.666667em; /* 0 8 0 8 */
     -fx-spacing: 0.166667em; /* 2 */
-    -fx-text-fill: -fx-mid-text-color, white;
-    -fx-background-color:
-/*         bottom shape: */
-        linear-gradient(to bottom, derive(-fx-base,-30%), black),
-/*         top shape: */
-        linear-gradient(to bottom, derive(-fx-base,-50%), derive(-fx-base,-70%));
+    -fx-base: derive(#d0d0d0,-70%);
+    -fx-background-color: linear-gradient(to bottom, derive(-fx-color,50%), derive(-fx-color,-30%)), -fx-body-color;
     -fx-background-insets: 0, 1 0 1 0;
     -fx-background-radius: 0, 0 ;
 }
 
-.menu-bar Text {
-    -fx-font-smoothing-type: lcd;
-}
-
-.menu-bar .menu .label {
+/* Show nothing for background of normal menu button in a menu bar */
+.menu-bar .menu-button {
+    -fx-background-radius: 0;
+    -fx-background-color: transparent;
+    -fx-background-insets: 0; 
+}
+/* Change padding of menu buttons when in menu bar */
+.menu-bar .menu-button .label {
     -fx-padding: 0.333em 0.5em 0.333em 0.5em; /* 4 6 4 6*/
-/*    -fx-effect: dropshadow(two-pass-box , rgba(0, 0, 0, 0.6), 1, 0.0 , 0, 1);*/
-}
-
-.menu-bar .menu-button:disabled .label {
-    -fx-opacity: -fx-disabled-opacity;
-}
-
-.menu-bar .menu {
-    -fx-background-color: null;
-    -fx-text-fill: white;
-    -fx-background-insets: 0;
-    -fx-background-radius: 0;
-    -fx-padding: 0.0em;
-}
-
-.menu-bar .menu .showing {
+}
+
+.menu-bar .menu-button:hover, .menu-bar .menu-button:focused, .menu-bar .menu-button.showing {
     -fx-background: -fx-accent;
     -fx-background-color: -fx-selection-bar;
     -fx-text-fill: -fx-selection-bar-text;
@@ -950,8 +936,7 @@
 
 .menu-bar:show-mnemonics .mnemonic-underline {
     -fx-stroke: -fx-text-fill;
-} 
-
+}
 
 /*******************************************************************************
  *                                                                             *
@@ -1990,7 +1975,11 @@
     -fx-background-insets: 0 0 -1 0, 0, 1, 2;
     -fx-background-radius: 5, 5, 4, 3;
     -fx-padding: 0.0em; /* 0 */
-}
+    -fx-text-fill: -fx-text-base-color;
+}
+
+/* TODO workaround for RT-19062 */
+.menu-button .label { -fx-text-fill: -fx-text-base-color; }
 
 .menu-button Text {
     -fx-font-smoothing-type: lcd;