RT-33074: [DatePicker] Fix issues in Modena CSS diff -r 5f0b44163796 modules/controls/src/main/java/com/sun/javafx/scene/control/skin/DatePickerSkin.java --- a/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/DatePickerSkin.java Mon Sep 23 14:03:18 2013 -0700 +++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/DatePickerSkin.java Mon Sep 23 15:37:37 2013 -0700 @@ -33,11 +33,14 @@ import java.time.format.DateTimeParseException; import javafx.application.Platform; +import javafx.beans.InvalidationListener; +import javafx.beans.Observable; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.css.PseudoClass; // import javafx.event.ActionEvent; import javafx.event.EventHandler; +import javafx.geometry.Insets; import javafx.scene.Node; import javafx.scene.control.DatePicker; import javafx.scene.control.TextField; @@ -75,6 +78,24 @@ }); } + // The "arrow" is actually a rectangular svg icon resembling a calendar. + // Round the size of the icon to whole integers to get sharp edges. + arrow.paddingProperty().addListener(new InvalidationListener() { + private boolean rounding = false; + @Override public void invalidated(Observable observable) { + if (!rounding) { + Insets padding = arrow.getPadding(); + Insets rounded = new Insets(Math.round(padding.getTop()), Math.round(padding.getRight()), + Math.round(padding.getBottom()), Math.round(padding.getLeft())); + if (!rounded.equals(padding)) { + rounding = true; + arrow.setPadding(rounded); + rounding = false; + } + } + } + }); + // Move fake focus in to the textfield. // Note: DatePicker uses TextField for both editable and non-editable modes datePicker.focusedProperty().addListener(new ChangeListener() { diff -r 5f0b44163796 modules/controls/src/main/resources/com/sun/javafx/scene/control/skin/caspian/caspian.css --- a/modules/controls/src/main/resources/com/sun/javafx/scene/control/skin/caspian/caspian.css Mon Sep 23 14:03:18 2013 -0700 +++ b/modules/controls/src/main/resources/com/sun/javafx/scene/control/skin/caspian/caspian.css Mon Sep 23 15:37:37 2013 -0700 @@ -3533,20 +3533,6 @@ * * ******************************************************************************/ -/* Merge the following rules with ComboBox rules whenever possible */ -/* Note that DatePicker uses same style for editable and non-editable text */ -/* This style is for non-editable ComboBox and does not apply to DatePicker - * .date-picker > .date-picker-display-node { - * -fx-padding: 0.25em 0 0.166667em 0.583333em; - * } - * .date-picker > .arrow-button { - * -fx-background-color: -fx-outer-border, -fx-inner-border, -fx-body-color; - * -fx-background-insets: 0, 1, 2; - * -fx-background-radius: 0 5 5 0, 0 4 4 0, 0 3 3 0; - * -fx-padding: 0 0.583em 0 0.667em; - * } - */ -/** END **/ /* Merge the following rules with Editable ComboBox rules */ /* Note that DatePicker uses same style for editable and non-editable text */ diff -r 5f0b44163796 modules/controls/src/main/resources/com/sun/javafx/scene/control/skin/modena/modena.css --- a/modules/controls/src/main/resources/com/sun/javafx/scene/control/skin/modena/modena.css Mon Sep 23 14:03:18 2013 -0700 +++ b/modules/controls/src/main/resources/com/sun/javafx/scene/control/skin/modena/modena.css Mon Sep 23 15:37:37 2013 -0700 @@ -1691,7 +1691,7 @@ -fx-text-fill: -fx-text-base-color; -fx-padding: 0.333333em 0.666667em 0.333333em 0.666667em; /* 4 8 4 8 */ } -.combo-box-base > .arrow-button { +.combo-box-base > .arrow-button { -fx-background-radius: 0 3 3 0, 0 2 2 0, 0 1 1 0; -fx-padding: 0.5em 0.667em 0.5em 0.833333em; /* 6 8 6 10 */ -fx-background-color: transparent; @@ -1707,23 +1707,28 @@ * * ******************************************************************************/ -.combo-box-base:editable > .arrow-button { +.combo-box-base:editable > .arrow-button, +.date-picker > .arrow-button { -fx-background-color: -fx-outer-border, -fx-inner-border, -fx-body-color; -fx-background-insets: 1 1 1 0, 1, 2; -fx-background-radius: 0 3 3 0, 0 2 2 0, 0 1 1 0; } -.combo-box-base:editable > .text-field { +.combo-box-base:editable > .text-field, +.date-picker > .text-field { -fx-background-color: -fx-control-inner-background; -fx-background-insets: 1 0 1 1; -fx-background-radius: 2 0 0 2; } -.combo-box-base:editable:contains-focus { +.combo-box-base:editable:contains-focus, +.date-picker:contains-focus { -fx-background-color: -fx-focus-color; -fx-background-insets: -0.2; -fx-background-radius: 3; } .combo-box-base:editable:focused > .text-field, -.combo-box-base:editable > .text-field:focused { +.combo-box-base:editable > .text-field:focused, +.date-picker:focused > .text-field, +.date-picker > .text-field:focused { -fx-background-color: -fx-control-inner-background, -fx-faint-focus-color, @@ -1731,7 +1736,8 @@ -fx-background-insets: 1 0 1 1, 1 0 1 1, 3 2 3 3; -fx-background-radius: 2 0 0 2, 1 0 0 1, 0; } -.combo-box-base:editable:contains-focus > .arrow-button { +.combo-box-base:editable:contains-focus > .arrow-button, +.date-picker:contains-focus > .arrow-button { -fx-background-color: -fx-inner-border, -fx-body-color, -fx-faint-focus-color, -fx-body-color; -fx-background-insets: 1, 2, 1, 2.6; -fx-background-radius: 0 2 2 0, 0 1 1 0, 0 1 1 0, 0 1 1 0; @@ -2931,32 +2937,12 @@ -fx-padding: 0.8em; } - - - /******************************************************************************* * * * DatePicker * * * ******************************************************************************/ -/* Merge the following rules with ComboBox rules whenever possible */ -/* Note that DatePicker uses same style for editable and non-editable text */ -/* This style is for non-editable ComboBox and does not apply to DatePicker - * .date-picker > .date-picker-display-node { - * -fx-background: transparent; - * -fx-background-color: transparent; - * -fx-text-fill: -fx-text-base-color; - * -fx-padding: 0.333333em 0.5em 0.333333em 0.75em; - * } - * .date-picker > .arrow-button { - * -fx-background-radius: 0 3 3 0, 0 2 2 0, 0 1 1 0; - * -fx-padding: 0.5em 0.583333em 0.5em 0.666667em; - * -fx-background-color: transparent; - * } - */ -/* END */ - .date-picker > .arrow-button > .arrow { -fx-shape: "M0,0v9h9V0H0z M2,8H1V7h1V8z M2,6H1V5h1V6z M2,4H1V3h1V4z M4,8H3V7h1V8z M4,6H3V5h1V6z M4,4H3V3h1V4z M6,8H5V7h1V8z M6,6H5 V5h1V6z M6,4H5V3h1V4z M8,8H7V7h1V8z M8,6H7V5h1V6z M8,4H7V3h1V4z"; -fx-background-color: -fx-mark-highlight-color, -fx-mark-color; @@ -2965,39 +2951,6 @@ -fx-scale-shape: true; } -/* Merge the following rules with Editable ComboBox rules */ -/* Note that DatePicker uses same style for editable and non-editable text */ -.date-picker > .arrow-button { - -fx-background-color: -fx-outer-border, -fx-inner-border, -fx-body-color; - -fx-background-insets: 1 1 1 0, 1, 2; - -fx-background-radius: 0 3 3 0, 0 2 2 0, 0 1 1 0; -} -.date-picker > .text-field { - -fx-background-color: -fx-control-inner-background; - -fx-background-insets: 1 0 1 1; - -fx-background-radius: 2 0 0 2; -} -.date-picker:contains-focus { - -fx-background-color: -fx-focus-color; - -fx-background-insets: -0.2; - -fx-background-radius: 3; -} -.date-picker:focused > .text-field, -.date-picker > .text-field:focused { - -fx-background-color: - -fx-control-inner-background, - -fx-faint-focus-color, - linear-gradient(from 0px 0px to 0px 5px, derive(-fx-control-inner-background, -9%), -fx-control-inner-background); - -fx-background-insets: 1 0 1 1, 1 0 1 1, 3 2 3 3; - -fx-background-radius: 2 0 0 2, 1 0 0 1, 0; -} -.date-picker:contains-focus > .arrow-button { - -fx-background-color: -fx-inner-border, -fx-body-color, -fx-faint-focus-color, -fx-body-color; - -fx-background-insets: 1, 2, 1, 2.6; - -fx-background-radius: 0 2 2 0, 0 1 1 0, 0 1 1 0, 0 1 1 0; -} -/* END */ - .date-picker-popup { -fx-background-color: linear-gradient(to bottom, @@ -3081,9 +3034,10 @@ .date-picker-popup > .calendar-grid { -fx-background-color: derive(-fx-selection-bar-non-focused, 60%); - -fx-background-insets: 1 0 0 0; -} -.date-picker-popup > * > .date-cell { + /*-fx-background-insets: 1 0 0 0;*/ + -fx-padding: 0; +} +.date-picker-popup > * > .date-cell { -fx-background-color: transparent; -fx-background-insets: 1, 2; -fx-padding: 0; @@ -3092,7 +3046,7 @@ } .date-picker-popup > * > .day-name-cell, .date-picker-popup > * > .week-number-cell { - -fx-font-size: 0.916667em; + -fx-font-size: 0.916667em; } .date-picker-popup > * > .week-number-cell { -fx-padding: 0.333333em 0.583333em 0.333333em 0.583333em; /* 4 7 4 7 */ @@ -3106,6 +3060,7 @@ -fx-padding: 0.333333em 0.583333em 0.333333em 0.583333em; /* 4 7 4 7 */ -fx-border-color: derive(-fx-selection-bar-non-focused, 60%); -fx-border-width: 1px; + -fx-font-size: 1em; -fx-background: -fx-control-inner-background; -fx-background-color: -fx-background; -fx-text-fill: -fx-text-background-color; @@ -3164,5 +3119,5 @@ .date-picker-popup > * > .previous-month.today:hover, .date-picker-popup > * > .next-month.today:hover { - -fx-background-color: lightgrey, derive(-fx-base, -10%), lightgrey; -} + -fx-background-color: -fx-selection-bar-non-focused, derive(-fx-selection-bar-non-focused, -20%), -fx-selection-bar-non-focused; +}