Skip to content
Snippets Groups Projects
Commit 13700e0f authored by Jason Dittmer (jcd763)'s avatar Jason Dittmer (jcd763)
Browse files

Mouse sensitivity UI screen added. Not linked to backend.

parent e787b513
No related branches found
No related tags found
2 merge requests!65Prototype,!49Feature add to ui
......@@ -4,6 +4,11 @@ import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.Pane;
/**
* AddProfileScreen is the view screen for adding a profile to the database.
* A text field is used to get a name for a profile, and can be saved to the database
* by using the save button. If the user hits the back button, nothing is saved.
*/
public class AddProfileScreen extends Pane {
TextField nameTextBox = new TextField();
......@@ -23,6 +28,10 @@ public class AddProfileScreen extends Pane {
this.getChildren().addAll(nameTextBox, profileNameLabel);
}
/**
* Get method for the profile name in the text box.
* @return Contents of the profile name text box.
*/
public String getProfileName() {
return nameTextBox.getText();
}
......
package ui;
import com.sun.org.apache.xerces.internal.util.SynchronizedSymbolTable;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
......@@ -72,7 +73,7 @@ public class MainScreen extends Pane {
Button to send user to screen to change mouse sensitivity
*/
Button bMouseSens = new Button("Change Mouse Sensitivity");
bMouseSens.setOnAction(e -> System.out.println("Change Mouse Sensitivity"));
bMouseSens.setOnAction(e -> goToMouseSensitivity());
bMouseSens.setStyle("-fx-background-color: #2c2f33; -fx-text-fill: white; -fx-font-size: 30; -fx-vertical-align: middle; " +
"-fx-pref-width: 260px; -fx-pref-height: 150px; -fx-text-align: center;");
bMouseSens.setWrapText(true);
......@@ -208,5 +209,36 @@ public class MainScreen extends Pane {
profileScreen.getChildren().addAll(back, save);
}
/**
* Function called when user wishes to change mouse sensitivity. Reads in a slider value, save button saves changes,
* back button does nothing and goes back to main screen.
*/
private void goToMouseSensitivity() {
MouseSensitivityScreen mouseSensScreen = new MouseSensitivityScreen();
//Button to go back to main view
Button back = new Button("Back");
back.setLayoutX(510);
back.setLayoutY(700);
back.setStyle("-fx-background-color: #2c2f33; -fx-text-fill: white; -fx-font-size: 16; -fx-vertical-align: middle; " +
"-fx-pref-width: 100px; -fx-pref-height: 50px; -fx-text-align: center;");
back.setOnAction(e -> primaryStage.setScene(mainScreenScene));
//Button to save sensitivity and return to main screen
Button save = new Button("Save");
save.setLayoutX(640);
save.setLayoutY(700);
save.setStyle("-fx-background-color: #2c2f33; -fx-text-fill: white; -fx-font-size: 16; -fx-vertical-align: middle; " +
"-fx-pref-width: 100px; -fx-pref-height: 50px; -fx-text-align: center;");
save.setOnAction(e -> {
System.out.println(mouseSensScreen.getSensitivity());
primaryStage.setScene(mainScreenScene);
});
primaryStage.setTitle("Add New Profile");
Scene sensScene = new Scene(mouseSensScreen, 800, 800);
primaryStage.setScene(sensScene);
mouseSensScreen.getChildren().addAll(back, save);
}
}
package ui;
import javafx.scene.control.Label;
import javafx.scene.control.Slider;
import javafx.scene.layout.Pane;
/**
* MouseSensitivityScreen is the view screen for modifying mouse sensitivity.
* A slider is used to change the sensitivity and can be saved with the save button.
* Hitting the back button saves nothing.
*/
public class MouseSensitivityScreen extends Pane {
Slider slider = new Slider(1, 20, 10);
public MouseSensitivityScreen() {
this.setStyle("-fx-background-color: #99aab5;");
slider.setLayoutX(60);
slider.setLayoutY(375);
slider.setStyle("-fx-pref-width: 680px; -fx-pref-height: 50px; -fx-font-size: 24; -fx-control-inner-background: #2c2f33");
slider.setMajorTickUnit(1);
slider.setMinorTickCount(0);
slider.setShowTickMarks(true);
slider.setShowTickLabels(true);
slider.setSnapToTicks(true);
Label sliderLabel = new Label("Change Mouse Sensitivity:");
sliderLabel.setLayoutX(60);
sliderLabel.setLayoutY(285);
sliderLabel.setStyle("-fx-text-fill: #2c2f33; -fx-font-size: 30;");
this.getChildren().addAll(slider, sliderLabel);
}
/**
* Get method for the sensitivity value in the slider.
* @return Slider value for the mouse sensitivity bar.
*/
public double getSensitivity() {
return slider.getValue();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment