|
|
|
@@ -8,10 +8,13 @@ import javafx.beans.property.SimpleIntegerProperty; |
|
|
|
import javafx.geometry.Pos; |
|
|
|
import javafx.scene.control.Button; |
|
|
|
import javafx.scene.control.Label; |
|
|
|
import javafx.scene.effect.DropShadow; |
|
|
|
import javafx.scene.image.Image; |
|
|
|
import javafx.scene.image.ImageView; |
|
|
|
import javafx.scene.layout.StackPane; |
|
|
|
import javafx.scene.paint.Color; |
|
|
|
import javafx.scene.text.Font; |
|
|
|
import javafx.scene.text.FontWeight; |
|
|
|
import javafx.util.Duration; |
|
|
|
|
|
|
|
/** |
|
|
|
@@ -33,25 +36,36 @@ public class MessageIcon extends Button { |
|
|
|
imageView.setFitWidth(30); |
|
|
|
/* imageView.opacityProperty().bind(Bindings.createDoubleBinding( |
|
|
|
()->messageCount.get()>0? 1.0 : 0.5, messageCount));*/ |
|
|
|
DropShadow ds1 = new DropShadow(); |
|
|
|
ds1.setOffsetY(0.0f); |
|
|
|
ds1.setOffsetX(0.0f); |
|
|
|
ds1.setColor(Color.valueOf("#e38217")); |
|
|
|
imageView.effectProperty().bind(Bindings.createObjectBinding( |
|
|
|
()->messageCount.get() > 0 ? ds1:null, messageCount |
|
|
|
)); |
|
|
|
|
|
|
|
|
|
|
|
messageCountLabel = new Label(); |
|
|
|
messageCountLabel.textProperty().bind(messageCount.asString()); |
|
|
|
StackPane.setAlignment(messageCountLabel, Pos.BOTTOM_RIGHT); |
|
|
|
messageCountLabel.setTextFill(Color.BLACK); |
|
|
|
messageCountLabel.setFont(Font.font("", FontWeight.BOLD, 20)); |
|
|
|
StackPane.setAlignment(messageCountLabel, Pos.CENTER); |
|
|
|
messageCountLabel.textFillProperty().bind(Bindings.createObjectBinding( |
|
|
|
() -> (messageCount.get() > 0? Color.DARKRED: Color.BLACK), messageCount)); |
|
|
|
|
|
|
|
|
|
|
|
this.disableProperty().bind(messageCount.lessThanOrEqualTo(0)); |
|
|
|
|
|
|
|
StackPane graphic = new StackPane(imageView, messageCountLabel); |
|
|
|
this.setGraphic(graphic); |
|
|
|
|
|
|
|
|
|
|
|
initTransition(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private void initTransition(){ |
|
|
|
transition = new FadeTransition(Duration.millis(500), imageView); |
|
|
|
transition.setFromValue(0.5); |
|
|
|
transition.setFromValue(0.2); |
|
|
|
transition.setToValue(1.0); |
|
|
|
transition.setCycleCount(Timeline.INDEFINITE); |
|
|
|
transition.setAutoReverse(true); |
|
|
|
|