diff --git a/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java b/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java index 20ff975..93833dd 100644 --- a/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java +++ b/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java @@ -1,12 +1,9 @@ package greenify.client.controller; +import com.sun.javafx.scene.control.skin.ButtonSkin; import greenify.client.Application; import greenify.client.rest.UserService; -import javafx.animation.Interpolator; -import javafx.animation.KeyFrame; -import javafx.animation.KeyValue; -import javafx.animation.Timeline; -import javafx.animation.TranslateTransition; +import javafx.animation.*; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.event.ActionEvent; @@ -180,6 +177,7 @@ public class RegisterWindowController { addSlideAnimation(1100, passwordField, 300); TimeUnit.MILLISECONDS.sleep(300); addSlideAnimation(1100, passwordField2, -420); + signUpButton.setSkin(new SignUpButtonSkin(signUpButton)); } /** @@ -605,4 +603,31 @@ public class RegisterWindowController { carTravelElectricLabel.getText().replace(" mpge", "")); } } + + @SuppressWarnings("Duplicates") + private class SignUpButtonSkin extends ButtonSkin { + /** + * button skin for the 'add activity' buttons. + * adds scale animations on entering, clicking and extiting the button + * @param button the button to set the skin of + */ + private SignUpButtonSkin(Button button) { + super(button); + + //transition to scale up on hover + final ScaleTransition scaleUp = new ScaleTransition(Duration.millis(85)); + //add the node and the position to scale to + scaleUp.setNode(button); + scaleUp.setToX(1.1); + scaleUp.setToY(1.1); + //play the transition when hovered over the button + button.setOnMouseEntered(e -> scaleUp.playFromStart()); + + final ScaleTransition scaleDown = new ScaleTransition(Duration.millis(85)); + scaleDown.setNode(button); + scaleDown.setToX(1.0); + scaleDown.setToY(1.0); + button.setOnMouseExited(e -> scaleDown.playFromStart()); + } + } } diff --git a/src/Client/src/main/java/greenify/client/controller/UserController.java b/src/Client/src/main/java/greenify/client/controller/UserController.java index e732740..c808c15 100644 --- a/src/Client/src/main/java/greenify/client/controller/UserController.java +++ b/src/Client/src/main/java/greenify/client/controller/UserController.java @@ -1,7 +1,10 @@ package greenify.client.controller; +import com.sun.javafx.scene.control.skin.ButtonSkin; import greenify.client.Application; import greenify.client.rest.UserService; +import javafx.animation.FillTransition; +import javafx.animation.ScaleTransition; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.Parent; @@ -10,8 +13,10 @@ import javafx.scene.control.Alert; import javafx.scene.control.Button; import javafx.scene.control.PasswordField; import javafx.scene.control.TextField; +import javafx.scene.paint.Color; import javafx.stage.Stage; import javafx.stage.Window; +import javafx.util.Duration; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -35,6 +40,11 @@ public class UserController { @FXML private Button signUpButton; + public void initialize() { + loginButton.setSkin(new LoginButtonSkin(loginButton)); + signUpButton.setSkin(new LoginButtonSkin(signUpButton)); + } + /** * Handles when the user clicks on the login button. * it checks if the username and password fields are filled @@ -135,10 +145,39 @@ public class UserController { Parent registerWindow = Application.load(this.getClass().getClassLoader() .getResource("fxml/RegisterWindow.fxml")); Scene registerScene = new Scene(registerWindow); + registerScene.getStylesheets().add(Application.class.getClassLoader() + .getResource("stylesheets/registerWindowStyle.css").toExternalForm()); Stage registerStage = new Stage(); registerStage.setScene(registerScene); registerStage.setTitle("Enter register credentials"); registerStage.show(); } + @SuppressWarnings("Duplicates") + private class LoginButtonSkin extends ButtonSkin { + /** + * button skin for the 'add activity' buttons. + * adds scale animations on entering, clicking and extiting the button + * @param button the button to set the skin of + */ + private LoginButtonSkin(Button button) { + super(button); + + //transition to scale up on hover + final ScaleTransition scaleUp = new ScaleTransition(Duration.millis(85)); + //add the node and the position to scale to + scaleUp.setNode(button); + scaleUp.setToX(1.1); + scaleUp.setToY(1.1); + //play the transition when hovered over the button + button.setOnMouseEntered(e -> scaleUp.playFromStart()); + + final ScaleTransition scaleDown = new ScaleTransition(Duration.millis(85)); + scaleDown.setNode(button); + scaleDown.setToX(1.0); + scaleDown.setToY(1.0); + button.setOnMouseExited(e -> scaleDown.playFromStart()); + } + } + } diff --git a/src/Client/src/main/resources/fxml/RegisterWindow.fxml b/src/Client/src/main/resources/fxml/RegisterWindow.fxml index 5764438..6c82691 100644 --- a/src/Client/src/main/resources/fxml/RegisterWindow.fxml +++ b/src/Client/src/main/resources/fxml/RegisterWindow.fxml @@ -1,5 +1,6 @@ + @@ -24,7 +25,7 @@ - -