Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented light theme #84

Merged
merged 1 commit into from Oct 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/main/java/seedu/address/model/appsettings/ThemeEnum.java
Expand Up @@ -4,12 +4,17 @@
* Enums for either a light theme or a dark theme.
*/
public enum ThemeEnum {
DARK("DarkTheme.css"), LIGHT("LightTheme.css");
DARK(ThemeEnum.class.getClassLoader().getResource("view/DarkTheme.css").toExternalForm(),
ThemeEnum.class.getClassLoader().getResource("view/Extensions.css").toExternalForm()),
LIGHT(ThemeEnum.class.getClassLoader().getResource("view/LightTheme.css").toExternalForm(),
ThemeEnum.class.getClassLoader().getResource("view/ExtensionsLight.css").toExternalForm());

private String themeUrl;
private String extensionUrl;

ThemeEnum(String s) {
ThemeEnum(String s, String e) {
themeUrl = s;
extensionUrl = e;
}

/**
Expand All @@ -20,4 +25,8 @@ public enum ThemeEnum {
public String getThemeUrl() {
return themeUrl;
}

public String getExtensionUrl() {
return extensionUrl;
}
}
14 changes: 10 additions & 4 deletions src/main/java/seedu/address/ui/MainWindow.java
Expand Up @@ -5,6 +5,7 @@
import javafx.event.ActionEvent;

import javafx.fxml.FXML;
import javafx.scene.Scene;
import javafx.scene.control.MenuItem;
import javafx.scene.control.TextInputControl;
import javafx.scene.input.KeyCombination;
Expand Down Expand Up @@ -48,6 +49,9 @@ public class MainWindow extends UiPart<Stage> {
private HelpWindow helpWindow;
private CommandBox commandBox;

@FXML
private Scene scene;

@FXML
private StackPane commandBoxPlaceholder;

Expand Down Expand Up @@ -83,8 +87,6 @@ public MainWindow(Stage primaryStage, AppManager appManager) {

this.uiLogicHelper = appManager.getLogic();

this.updateUi = new UpdateUi(modularDisplay, currentModeFooter);

// Configure the UI
setWindowDefaultSize(appManager.getGuiSettings());

Expand Down Expand Up @@ -163,8 +165,11 @@ void fillInnerParts() {

//Assigns only after initialisation.
this.updateUi = new UpdateUi(modularDisplay, currentModeFooter);
updateUi.setTheme(appManager.getAppSettings().getDefaultTheme(), scene);
}



/**
* Sets the default size based on {@code guiSettings}.
*/
Expand Down Expand Up @@ -233,8 +238,9 @@ private CommandResult executeCommand(String commandText) throws CommandException
resultDisplay.setFeedbackToUser(commandResult.getFeedbackToUser());

//Updates the Ui.
updateUi.updateMode(commandText);
updateUi.updateModularDisplay(commandText, modularDisplayPlaceholder);
updateUi.updateModularDisplay(commandText, uiLogicHelper.getMode(), modularDisplayPlaceholder);

updateUi.setTheme(appManager.getAppSettings().getDefaultTheme(), scene);

if (commandResult.isShowHelp()) {
handleHelp();
Expand Down
38 changes: 19 additions & 19 deletions src/main/java/seedu/address/ui/UpdateUi.java
@@ -1,6 +1,9 @@
package seedu.address.ui;

import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import seedu.address.logic.util.ModeEnum;
import seedu.address.model.appsettings.ThemeEnum;


/**
Expand All @@ -16,30 +19,13 @@ public UpdateUi(ModularDisplay modularDisplay, CurrentModeFooter currentModeFoot
this.currentModeFooter = currentModeFooter;
}

//Use string for now, eventually use mode.
/**
* Updates the mode in {@code MainWindow}.
*
* @param mode The mode to update to.
*/
public void updateMode(String mode) {
String firstArg = mode.split(" ")[0];
if (firstArg.equals("home")) {
currentModeFooter.changeMode("home");
} else if (firstArg.equals("start")) {
currentModeFooter.changeMode("game");
} else if (firstArg.equals("load")) {
currentModeFooter.changeMode("load");
}
}

/**
* Updates the {@code ModularDisplay} in {@code MainWindow}.
*
* @param command The command that triggers the update.
* @param modularDisplayPlaceholder {@code modularDisplayPlaceholder} in {@code MainWindow} that gets updated.
*/
public void updateModularDisplay(String command, StackPane modularDisplayPlaceholder) {
public void updateModularDisplay(String command, ModeEnum modeEnum, StackPane modularDisplayPlaceholder) {
String firstArg = command.split(" ")[0];
if (firstArg.equals("load")) {
modularDisplay.swapToBanks(modularDisplayPlaceholder);
Expand All @@ -49,11 +35,25 @@ public void updateModularDisplay(String command, StackPane modularDisplayPlaceho
modularDisplay.swapToList(modularDisplayPlaceholder);
} else if (firstArg.equals("help")) {
//modularDisplay.swapToBanks(modularDisplayPlaceholder);
} else if (firstArg.equals("settings")) {
} else if (modeEnum.equals(ModeEnum.SETTINGS)) {
modularDisplay.swapToSettings(modularDisplayPlaceholder);
} else {
modularDisplay.swapToLoadDisplay(modularDisplayPlaceholder);
}
}

public void setTheme(ThemeEnum theme, Scene scene) {
if (theme.equals(ThemeEnum.DARK)) {
scene.getStylesheets().remove(ThemeEnum.LIGHT.getThemeUrl());
scene.getStylesheets().remove(ThemeEnum.LIGHT.getExtensionUrl());
scene.getStylesheets().add(theme.getThemeUrl());
scene.getStylesheets().add(theme.getExtensionUrl());
} else {
scene.getStylesheets().remove(ThemeEnum.DARK.getThemeUrl());
scene.getStylesheets().remove(ThemeEnum.DARK.getExtensionUrl());
scene.getStylesheets().add(theme.getThemeUrl());
scene.getStylesheets().add(theme.getExtensionUrl());
}
}

}
19 changes: 8 additions & 11 deletions src/main/java/seedu/address/ui/modules/SettingsPanel.java
Expand Up @@ -15,13 +15,8 @@
*/
public class SettingsPanel extends UiPart<Region> {
private static final String FXML = "SettingsPanel.fxml";
private static final String LABEL_STYLE = "-fx-font-size: 11pt;"
+ "-fx-font-family: \"Segoe UI SemiBold\";"
+ "-fx-opacity: 0.5;"
+ "-fx-padding: 20 20 20 0;"
+ "-fx-text-fill: rgba(255, 255, 255, 100);";
private static final String HIGHLIGHTED = LABEL_STYLE + "-fx-text-fill: rgba(85, 255, 68, 100);"
+ "-fx-opacity: 0.9";
private static final String LABEL_STYLE = "label-unhighlighted";
private static final String HIGHLIGHTED = "label-highlighted";
private AppSettings appSettings;


Expand Down Expand Up @@ -53,7 +48,7 @@ private void addOptions(HBox field, String... names) {
List<Label> options = new ArrayList<>();
for (String labelTitle: names) {
Label option = new Label(labelTitle);
option.setStyle(LABEL_STYLE);
option.getStyleClass().add(LABEL_STYLE);
options.add(option);
}
field.getChildren().addAll(options);
Expand All @@ -69,7 +64,7 @@ public void highlightChoice(HBox field, String option) {
int sizeOfList = field.getChildren().size();
for (int i = 0; i < sizeOfList; i++) {
Label child = (Label) field.getChildren().get(i);
if (child.getStyle().equals(HIGHLIGHTED)) {
if (child.getStyleClass().contains(HIGHLIGHTED)) {
unhighlightText(child);
break;
}
Expand All @@ -84,11 +79,13 @@ public void highlightChoice(HBox field, String option) {
}

private void highlightText(Label label) {
label.setStyle(HIGHLIGHTED);
label.getStyleClass().remove(LABEL_STYLE);
label.getStyleClass().add(HIGHLIGHTED);
}

private void unhighlightText(Label label) {
label.setStyle(LABEL_STYLE);
label.getStyleClass().remove(HIGHLIGHTED);
label.getStyleClass().add(LABEL_STYLE);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/view/BankLabelPanel.fxml
Expand Up @@ -3,7 +3,7 @@
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.StackPane?>

<StackPane prefHeight="150.0" prefWidth="200.0" stylesheets="@DarkTheme.css" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
<StackPane prefHeight="150.0" prefWidth="200.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
<children>
<Label fx:id="bankName" alignment="TOP_LEFT" styleClass="label-header" text="BankName" StackPane.alignment="CENTER" />
</children>
Expand Down
13 changes: 8 additions & 5 deletions src/main/resources/view/CommandBox.fxml
@@ -1,12 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.Menu?>
<?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.layout.VBox?>

<StackPane prefHeight="0.0" prefWidth="1077.0" styleClass="stack-pane" stylesheets="@DarkTheme.css" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<StackPane prefHeight="0.0" prefWidth="1077.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
<children>
<VBox prefHeight="0.0" prefWidth="1077.0">
<children>
Expand All @@ -15,7 +18,7 @@
<VBox prefHeight="100.0" prefWidth="234.0">
<children>
<Label text="Mode" textFill="WHITE" />
<ComboBox fx:id="commandComboField" prefWidth="150.0" promptText="load" stylesheets="@DarkTheme.css" />
<ComboBox fx:id="commandComboField" prefWidth="150.0" promptText="load" />
</children>
</VBox>
<TextField fx:id="commandTextField" onAction="#handleCommandEntered" prefHeight="40.0" prefWidth="1017.0" promptText="Enter command here..." text="" HBox.hgrow="ALWAYS" />
Expand Down
16 changes: 16 additions & 0 deletions src/main/resources/view/DarkTheme.css
Expand Up @@ -31,6 +31,22 @@
-fx-opacity: 1;
}

.label-unhighlighted {
-fx-font-size: 11pt;
-fx-font-family: "Segoe UI SemiBold";
-fx-opacity: 0.5;
-fx-padding: 20 20 20 0;
-fx-text-fill: rgba(255, 255, 255, 100);
}

.label-highlighted {
-fx-font-size: 11pt;
-fx-font-family: "Segoe UI SemiBold";
-fx-opacity: 0.9;
-fx-padding: 20 20 20 0;
-fx-text-fill: rgba(85, 255, 68, 100);
}

.text-field {
-fx-font-size: 12pt;
-fx-font-family: "Segoe UI Semibold";
Expand Down
20 changes: 20 additions & 0 deletions src/main/resources/view/ExtensionsLight.css
@@ -0,0 +1,20 @@

.error {
-fx-text-fill: #d06651 !important; /* The error class should always override the default text-fill style */
}

.list-cell:empty {
/* Empty cells will not have alternating colours */
-fx-background: #c7c7c7;
}

.tag-selector {
-fx-border-width: 1;
-fx-border-color: #000000;
-fx-border-radius: 3;
-fx-background-radius: 3;
}

.tooltip-text {
-fx-text-fill: #000000;
}
10 changes: 5 additions & 5 deletions src/main/resources/view/GameResultPanel.fxml
Expand Up @@ -9,15 +9,15 @@
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.layout.VBox?>

<ScrollPane fitToHeight="true" fitToWidth="true" stylesheets="@DarkTheme.css" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
<ScrollPane fitToHeight="true" fitToWidth="true" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
<content>
<VBox maxHeight="-Infinity" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefWidth="600.0" stylesheets="@DarkTheme.css">
<VBox maxHeight="-Infinity" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefWidth="600.0">
<children>
<Label fx:id="title" alignment="CENTER" maxHeight="-Infinity" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" styleClass="label-header" text="Title" textAlignment="CENTER" />
<Label fx:id="title" alignment="CENTER" maxHeight="-Infinity" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" text="Title" textAlignment="CENTER" />
<StackPane fx:id="badgesRowPlaceholder" />
<Region prefHeight="20.0" />
<Label fx:id="title1" alignment="CENTER" maxHeight="-Infinity" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" styleClass="label-bright" text="Score:" textAlignment="CENTER" />
<Label fx:id="scoreText" alignment="CENTER" maxHeight="-Infinity" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" styleClass="label-header" text="XX" textAlignment="CENTER" />
<Label fx:id="title1" alignment="CENTER" maxHeight="-Infinity" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" text="Score:" textAlignment="CENTER" />
<Label fx:id="scoreText" alignment="CENTER" maxHeight="-Infinity" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" text="XX" textAlignment="CENTER" />
<HBox minWidth="0.0" prefHeight="30.0" prefWidth="0.0">
<children>
<Region prefHeight="200.0" HBox.hgrow="ALWAYS" />
Expand Down