From 50fb11a7396554a989513bd94077c6ecb92397a1 Mon Sep 17 00:00:00 2001 From: leewyatt Date: Fri, 12 Apr 2024 00:22:25 +0900 Subject: [PATCH 1/2] Implement styling for selected days from adjacent months. --- .../com/dlsc/gemsfx/skins/CalendarViewSkin.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/gemsfx/src/main/java/com/dlsc/gemsfx/skins/CalendarViewSkin.java b/gemsfx/src/main/java/com/dlsc/gemsfx/skins/CalendarViewSkin.java index 26e1a7fd..a2158275 100644 --- a/gemsfx/src/main/java/com/dlsc/gemsfx/skins/CalendarViewSkin.java +++ b/gemsfx/src/main/java/com/dlsc/gemsfx/skins/CalendarViewSkin.java @@ -411,7 +411,7 @@ private void updateBodyConstraints() { * depending on whether the week number column is shown or not. * * @param numberOfColumns the number of total columns (either 7 or 8) - * @param columnIndex the index of the column for which to create the constraints, -1 indicates the column used for showing the "week of year" numbers + * @param columnIndex the index of the column for which to create the constraints, -1 indicates the column used for showing the "week of year" numbers * @return the column constraints for the given column */ protected ColumnConstraints createColumnConstraints(int numberOfColumns, int columnIndex) { @@ -508,7 +508,7 @@ private void buildView() { return dateFilter != null && !dateFilter.call(cellDate); } return false; - }, view.earliestDateProperty(), view.latestDateProperty(), view.dateFilterProperty() , cell.itemProperty())); + }, view.earliestDateProperty(), view.latestDateProperty(), view.dateFilterProperty(), cell.itemProperty())); bodyGridPane.add(cell, showWeekNumbers ? col + 1 : col, row); @@ -632,9 +632,10 @@ private void updateView() { cell.getStyleClass().add(TODAY); } - if (YearMonth.from(date).isBefore(yearMonth)) { + YearMonth cellYearMonth = YearMonth.from(date); + if (cellYearMonth.isBefore(yearMonth)) { cell.getStyleClass().add(PREVIOUS_MONTH); - } else if (YearMonth.from(date).isAfter(yearMonth)) { + } else if (cellYearMonth.isAfter(yearMonth)) { cell.getStyleClass().add(NEXT_MONTH); } @@ -642,8 +643,10 @@ private void updateView() { cell.getStyleClass().add(WEEKEND_DAY); } - if (view.getSelectionModel().isSelected(localDate) && YearMonth.from(localDate).equals(displayedYearMonth)) { - cell.getStyleClass().add(SELECTED); + if (view.getSelectionModel().isSelected(localDate)) { + if (cellYearMonth.equals(yearMonth) || view.isMarkSelectedDaysOfPreviousOrNextMonth()) { + cell.getStyleClass().add(SELECTED); + } if (Objects.equals(view.getSelectionModel().getSelectionMode(), SelectionModel.SelectionMode.DATE_RANGE)) { From 2262eb537bea39e727219eca63b9068392142bd1 Mon Sep 17 00:00:00 2001 From: leewyatt Date: Fri, 12 Apr 2024 02:14:06 +0900 Subject: [PATCH 2/2] Fix immediate visibility of Month Dropdown Button on property change. --- .../main/java/com/dlsc/gemsfx/skins/CalendarViewSkin.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gemsfx/src/main/java/com/dlsc/gemsfx/skins/CalendarViewSkin.java b/gemsfx/src/main/java/com/dlsc/gemsfx/skins/CalendarViewSkin.java index a2158275..9966c71c 100644 --- a/gemsfx/src/main/java/com/dlsc/gemsfx/skins/CalendarViewSkin.java +++ b/gemsfx/src/main/java/com/dlsc/gemsfx/skins/CalendarViewSkin.java @@ -211,7 +211,13 @@ public CalendarViewSkin(CalendarView view) { monthDropdownArrowButton.visibleProperty().bind(view.monthSelectionViewEnabledProperty().and(view.showMonthDropdownProperty().and(view.showMonthProperty()))); monthDropdownArrowButton.managedProperty().bind(monthDropdownArrowButton.visibleProperty()); monthDropdownArrowButton.disableProperty().bind(view.disableMonthDropdownButtonProperty()); - monthLabel.setGraphic(monthDropdownArrowButton); + monthLabel.graphicProperty().bind(Bindings.createObjectBinding(() -> { + if (view.isMonthSelectionViewEnabled() && view.isShowMonthDropdown()) { + return monthDropdownArrowButton; + } + return null; + }, + view.showMonthDropdownProperty(), view.monthSelectionViewEnabledProperty())); StackPane yearDropdownArrow = new StackPane(); yearDropdownArrow.getStyleClass().add("arrow");