77import com .sun .javafx .sg .prism .NGNode ;
88import javafx .animation .FadeTransition ;
99import javafx .beans .binding .Bindings ;
10+ import javafx .beans .binding .DoubleBinding ;
1011import javafx .beans .property .DoubleProperty ;
12+ import javafx .beans .property .SimpleDoubleProperty ;
1113import javafx .geometry .Insets ;
1214import javafx .geometry .Pos ;
1315import javafx .scene .Node ;
1416import javafx .scene .control .*;
15- import javafx .scene .layout .Background ;
16- import javafx .scene .layout .BackgroundFill ;
17- import javafx .scene .layout .BorderPane ;
18- import javafx .scene .layout .HBox ;
17+ import javafx .scene .layout .*;
1918import javafx .scene .paint .Color ;
2019import javafx .scene .text .Font ;
2120import org .stt .model .TimeTrackingItem ;
2423import java .time .format .FormatStyle ;
2524import java .util .ResourceBundle ;
2625import java .util .function .Predicate ;
27- import java .util .stream .Stream ;
2826
2927import static java .util .Objects .requireNonNull ;
3028import static org .stt .gui .jfx .Glyph .GLYPH_SIZE_MEDIUM ;
@@ -44,7 +42,7 @@ class TimeTrackingItemCellWithActions extends ListCell<TimeTrackingItem> {
4442
4543 private final Node newDayNode ;
4644 private final TimeTrackingItemNodes itemNodes ;
47- private final int buttonIndex ;
45+ private final HBox actions ;
4846
4947 TimeTrackingItemCellWithActions (Font fontAwesome ,
5048 ResourceBundle localization ,
@@ -66,21 +64,18 @@ class TimeTrackingItemCellWithActions extends ListCell<TimeTrackingItem> {
6664 deleteButton .setOnAction (event -> actionsHandler .delete (getItem ()));
6765 stopButton .setOnAction (event -> actionsHandler .stop (getItem ()));
6866
69- itemNodes .appendNodesTo (cellPane .getChildren ());
67+ actions = new HBox (continueButton , editButton , deleteButton );
68+ StackPane .setAlignment (actions , Pos .CENTER );
69+ StackPane timeOrActions = new StackPaneWithoutResize ();
7070
71- buttonIndex = cellPane .getChildren ().size ();
71+ actions .opacityProperty ().bind (fadeOnHoverProperty ());
72+ SimpleDoubleProperty one = new SimpleDoubleProperty (1 );
73+ DoubleBinding timePaneOpacity = one .subtract (Bindings .min (one , fadeOnHoverProperty ().multiply (2 )));
74+ itemNodes .appendNodesTo (timeOrActions , timePaneOpacity , cellPane .getChildren ());
75+ timeOrActions .getChildren ().add (actions );
7276
73- cellPane .getChildren ().addAll (
74- continueButton ,
75- editButton ,
76- deleteButton );
7777 cellPane .setAlignment (Pos .CENTER_LEFT );
7878
79- DoubleProperty opacityProperty = fadeOnHoverProperty ();
80-
81- Stream .of (continueButton , editButton , deleteButton , stopButton )
82- .map (Node ::opacityProperty )
83- .forEach (p -> p .bind (opacityProperty ));
8479
8580 lastItemOnDayPane = new BorderPane ();
8681
@@ -137,7 +132,7 @@ protected void updateItem(TimeTrackingItem item, boolean empty) {
137132 if (empty ) {
138133 setGraphic (null );
139134 } else {
140- cellPane .getChildren ().set (buttonIndex , item .getEnd ().isPresent () ? continueButton : stopButton );
135+ actions .getChildren ().set (0 , item .getEnd ().isPresent () ? continueButton : stopButton );
141136 itemNodes .setItem (item );
142137 if (lastItemOfDay .test (item )) {
143138 setupLastItemOfDayPane ();
0 commit comments