This repository has been archived by the owner on Sep 29, 2022. It is now read-only.
forked from AY1920S1-CS2103T-F12-3/main
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update AboutUs.adoc for team members to commit * Add a newline in AboutUs.adoc * Add more use cases to Developer Guide * Fix missing endline * Update GUI to include chat pane * Add newlines for FXML files * Update various docs to display TagLine * Add placeholder image * Fix minor typo in user guide * Update Tagline to TagLine * Update team name * Fix some typos in user guide and developer guide * Change chat pane layout * Clean up UI code * Add icon for response messages
- Loading branch information
Showing
11 changed files
with
291 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package tagline.ui; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
import javafx.fxml.FXML; | ||
import javafx.scene.control.ScrollPane; | ||
import javafx.scene.image.Image; | ||
import javafx.scene.layout.GridPane; | ||
import javafx.scene.layout.StackPane; | ||
import javafx.scene.layout.VBox; | ||
import tagline.ui.CommandBox.CommandExecutor; | ||
|
||
/** | ||
* The UI component that stores the chat window. | ||
*/ | ||
public class ChatPane extends UiPart<GridPane> { | ||
|
||
private static final String FXML = "ChatPane.fxml"; | ||
private static final String TAGLINE_RESPONSE_IMAGE = "/images/tagline_icon.png"; | ||
|
||
private CommandBox commandBox; | ||
|
||
@FXML | ||
private StackPane commandBoxPlaceholder; | ||
|
||
@FXML | ||
private ScrollPane dialogScrollPane; | ||
|
||
@FXML | ||
private VBox dialogContainer; | ||
|
||
private Image image = new Image(getClass().getResourceAsStream(TAGLINE_RESPONSE_IMAGE)); | ||
|
||
public ChatPane(CommandExecutor commandExecutor) { | ||
super(FXML); | ||
|
||
commandBox = new CommandBox(commandExecutor); | ||
commandBox.getRoot().prefWidthProperty().bind(getRoot().widthProperty()); | ||
commandBoxPlaceholder.getChildren().add(commandBox.getRoot()); | ||
|
||
//setting vvalue to 1.0 doesn't work | ||
dialogScrollPane.vvalueProperty().bind(dialogContainer.heightProperty()); | ||
} | ||
|
||
/** | ||
* Displays a new command from the user in the chat window. | ||
* @param commandFromUser Command entered by user | ||
*/ | ||
public void setCommandFromUser(String commandFromUser) { | ||
requireNonNull(commandFromUser); | ||
|
||
//Don't display empty messages | ||
if (commandFromUser.isEmpty()) { | ||
return; | ||
} | ||
|
||
dialogContainer.getChildren().add(DialogBox.getCommandDialog(commandFromUser).getRoot()); | ||
} | ||
|
||
/** | ||
* Displays the feedback returned by TagLine in the chat window. | ||
* @param feedbackToUser Feedback to user | ||
*/ | ||
public void setFeedbackToUser(String feedbackToUser) { | ||
requireNonNull(feedbackToUser); | ||
dialogContainer.getChildren().add(DialogBox.getResponseDialog(feedbackToUser, image).getRoot()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package tagline.ui; | ||
|
||
import javafx.animation.FadeTransition; | ||
import javafx.fxml.FXML; | ||
import javafx.geometry.Pos; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.image.Image; | ||
import javafx.scene.image.ImageView; | ||
import javafx.scene.layout.HBox; | ||
import javafx.scene.shape.Circle; | ||
import javafx.util.Duration; | ||
|
||
/** | ||
* A dialog box to display chat messages. | ||
*/ | ||
class DialogBox extends UiPart<HBox> { | ||
|
||
private static final String FXML = "DialogBox.fxml"; | ||
|
||
private static final String COMMAND_DIALOG = "command-dialog"; | ||
private static final String RESPONSE_DIALOG = "response-dialog"; | ||
|
||
private static final double TRANSITION_DURATION = 0.5; | ||
private static final double TRANSITION_OPACITY_FROM = 0.5; | ||
private static final double TRANSITION_OPACITY_TO = 1.0; | ||
|
||
@FXML | ||
private Label dialog; | ||
|
||
@FXML | ||
private ImageView displayPicture; | ||
|
||
private FadeTransition fadeTransition; | ||
|
||
/** | ||
* Creates a new DialogBox. | ||
* | ||
* @param text Text to place in the dialog box | ||
*/ | ||
private DialogBox(String text) { | ||
super(FXML); | ||
|
||
dialog.setText(text); | ||
prepareAnimation(); | ||
|
||
double radius = displayPicture.getFitHeight() / 2; | ||
displayPicture.setClip(new Circle(radius, radius, radius)); | ||
} | ||
|
||
/** | ||
* Prepares the fade-in transition of the dialog box. | ||
*/ | ||
private void prepareAnimation() { | ||
fadeTransition = new FadeTransition(); | ||
fadeTransition.setDuration(Duration.seconds(TRANSITION_DURATION)); | ||
fadeTransition.setFromValue(TRANSITION_OPACITY_FROM); | ||
fadeTransition.setToValue(TRANSITION_OPACITY_TO); | ||
|
||
fadeTransition.setNode(dialog); | ||
} | ||
|
||
/** | ||
* Flips the dialog box so that the text is aligned on the left. | ||
*/ | ||
private void flip() { | ||
getRoot().setAlignment(Pos.TOP_LEFT); | ||
} | ||
|
||
/** | ||
* Creates a dialog box for commands from the user. | ||
* The text box is aligned to the right. | ||
* | ||
* @param text Text to place in the dialog box | ||
* @return A DialogBox object for the message | ||
*/ | ||
public static DialogBox getCommandDialog(String text) { | ||
DialogBox db = new DialogBox(text); | ||
|
||
db.dialog.getStyleClass().add(COMMAND_DIALOG); | ||
db.fadeTransition.play(); | ||
return db; | ||
} | ||
|
||
/** | ||
* Creates a dialog box for response messages. | ||
* The text box is aligned to the left. | ||
* | ||
* @param text Text to place in the dialog box | ||
* @param image Image to place as the icon | ||
* @return A DialogBox object for the message | ||
*/ | ||
public static DialogBox getResponseDialog(String text, Image image) { | ||
DialogBox db = new DialogBox(text); | ||
db.flip(); | ||
|
||
db.displayPicture.setImage(image); | ||
db.dialog.getStyleClass().add(RESPONSE_DIALOG); | ||
db.fadeTransition.play(); | ||
return db; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import javafx.geometry.Insets?> | ||
<?import javafx.scene.control.ScrollPane?> | ||
<?import javafx.scene.layout.GridPane?> | ||
<?import javafx.scene.layout.StackPane?> | ||
<?import javafx.scene.layout.VBox?> | ||
<?import javafx.scene.layout.RowConstraints?> | ||
|
||
<GridPane xmlns="http://javafx.com/javafx/8" | ||
xmlns:fx="http://javafx.com/fxml/1" VBox.vgrow="ALWAYS"> | ||
<rowConstraints> | ||
<RowConstraints vgrow="ALWAYS" valignment="TOP"/> | ||
<RowConstraints vgrow="NEVER" valignment="BOTTOM"/> | ||
</rowConstraints> | ||
<children> | ||
<StackPane VBox.vgrow="ALWAYS" styleClass="stack-pane" GridPane.rowIndex="0"> | ||
<ScrollPane fx:id="dialogScrollPane" hbarPolicy="NEVER" fitToWidth="true"> | ||
<content> | ||
<VBox fx:id="dialogContainer" /> | ||
</content> | ||
</ScrollPane> | ||
</StackPane> | ||
|
||
<StackPane VBox.vgrow="NEVER" fx:id="commandBoxPlaceholder" styleClass="stack-pane" | ||
GridPane.rowIndex="1"> | ||
<padding> | ||
<Insets top="5" right="10" bottom="5" left="10" /> | ||
</padding> | ||
</StackPane> | ||
</children> | ||
</GridPane> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import javafx.scene.control.Button?> | ||
<?import javafx.scene.control.TextField?> | ||
<?import javafx.scene.layout.StackPane?> | ||
|
||
<StackPane styleClass="stack-pane" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"> | ||
<TextField fx:id="commandTextField" onAction="#handleCommandEntered" promptText="Enter command here..."/> | ||
</StackPane> | ||
<?import javafx.scene.layout.ColumnConstraints?> | ||
<?import javafx.scene.layout.GridPane?> | ||
|
||
<GridPane styleClass="stack-pane" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"> | ||
<columnConstraints> | ||
<ColumnConstraints hgrow="ALWAYS" halignment="LEFT"/> | ||
<ColumnConstraints hgrow="NEVER" prefWidth="5.0" minWidth="5.0"/> | ||
<ColumnConstraints hgrow="NEVER" minWidth="60.0"/> | ||
</columnConstraints> | ||
<children> | ||
<TextField fx:id="commandTextField" onAction="#handleCommandEntered" promptText="Enter command here..." | ||
GridPane.columnIndex="0"/> | ||
<Button onAction="#handleCommandEntered" text="Send" GridPane.columnIndex="2"/> | ||
</children> | ||
</GridPane> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.