Skip to content

Commit

Permalink
Fixes #167 Make noon line in ResourceCalendar optional
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemmermann committed Sep 12, 2022
1 parent 979e2de commit a732152
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public String getSampleName() {
@Override
public Node getPanel(Stage stage) {
ResourceCalendarView<String> resourceCalendarView = new ResourceCalendarView<>();

resourceCalendarView.setShowNoonMarker(false);
resourceCalendarView.setOverlapResolutionStrategy(OverlapResolutionStrategy.VISUAL_BOUNDS);
resourceCalendarView.setHeaderFactory(resource -> {
Label label1 = new Label("IG-TR");
Expand Down
22 changes: 22 additions & 0 deletions CalendarFXView/src/main/java/com/calendarfx/view/DateControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -1868,6 +1868,26 @@ public final void setShowToday(boolean show) {
showTodayProperty().set(show);
}

private final BooleanProperty showNoonMarker = new SimpleBooleanProperty(this, "showNoonMarker", true);

public final boolean isShowNoonMarker() {
return showNoonMarker.get();
}

/**
* A property used to indicate whether the day view should mark noon with a special
* marker.
*
* @return true if noon will be marked in a special way
*/
public final BooleanProperty showNoonMarkerProperty() {
return showNoonMarker;
}

public final void setShowNoonMarker(boolean showNoonMarker) {
this.showNoonMarker.set(showNoonMarker);
}

private final ObjectProperty<LocalDate> date = new SimpleObjectProperty<>(this, "date", LocalDate.now());

/**
Expand Down Expand Up @@ -2616,6 +2636,7 @@ public final void bind(DateControl otherControl, boolean bindDate) {
Bindings.bindBidirectional(otherControl.availableZoneIdsProperty(), availableZoneIdsProperty());
Bindings.bindBidirectional(otherControl.enableTimeZoneSupportProperty(), enableTimeZoneSupportProperty());
Bindings.bindBidirectional(otherControl.showDetailsUponCreationProperty(), showDetailsUponCreationProperty());
Bindings.bindBidirectional(otherControl.showNoonMarkerProperty(), showNoonMarkerProperty());

if (bindDate) {
Bindings.bindBidirectional(otherControl.dateProperty(), dateProperty());
Expand Down Expand Up @@ -2684,6 +2705,7 @@ public final void unbind(DateControl otherControl) {
Bindings.unbindBidirectional(otherControl.availabilityGridProperty(), availabilityGridProperty());
Bindings.unbindBidirectional(otherControl.availabilityFillProperty(), availabilityFillProperty());
Bindings.unbindBidirectional(otherControl.showDetailsUponCreationProperty(), showDetailsUponCreationProperty());
Bindings.unbindBidirectional(otherControl.showNoonMarkerProperty(), showNoonMarkerProperty());

// unbind callbacks
Bindings.unbindBidirectional(otherControl.entryDetailsCallbackProperty(), entryDetailsCallbackProperty());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,10 +458,12 @@ protected void layoutChildrenInfiniteScrolling(double contentX, double contentY,
line.getStyleClass().add(MIDNIGHT_LINE_STYLE_CLASS);
line.setStartX(snapPositionX(contentX));
line.setEndX(snapPositionX(contentX + contentWidth));
} else if (localTime.equals(LocalTime.NOON)) {
line.getStyleClass().add(NOON_LINE_STYLE_CLASS);
} else if (localTime.equals(LocalTime.NOON) ) {
line.setStartX(snapPositionX(contentX));
line.setEndX(snapPositionX(contentX + contentWidth));
if (view.isShowNoonMarker()) {
line.getStyleClass().add(NOON_LINE_STYLE_CLASS);
}
} else {
line.setStartX(snapPositionX(contentX + 4));
line.setEndX(snapPositionX(contentX + contentWidth - 4));
Expand Down

0 comments on commit a732152

Please sign in to comment.