Skip to content

Commit

Permalink
[prmr#538] Apply dark theme.
Browse files Browse the repository at this point in the history
  • Loading branch information
jkcoding7 committed May 24, 2024
1 parent 472e74f commit 810a08e
Show file tree
Hide file tree
Showing 12 changed files with 248 additions and 90 deletions.
Binary file added icons/16x16/dark-mode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion src/org/jetuml/JetUML.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

.welcome-tab-panel
{
-fx-padding: 20px;
Expand Down
21 changes: 10 additions & 11 deletions src/org/jetuml/gui/AboutDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.Border;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import javafx.stage.Modality;
Expand All @@ -45,30 +46,28 @@
*/
public class AboutDialog
{
private final Stage aStage = new Stage();
private final Stage aStage;

/**
* Creates a new dialog.
*
* @param pOwner The stage that owns this stage.
*/
public AboutDialog( Stage pOwner )
public AboutDialog( Stage pDialogStage )
{
prepareStage(pOwner);
aStage.setScene(createScene());
aStage = pDialogStage;
prepareStage();
aStage.getScene().setRoot(createRoot());
}

private void prepareStage(Stage pOwner)
private void prepareStage()
{
aStage.setResizable(false);
aStage.initModality(Modality.WINDOW_MODAL);
aStage.initOwner(pOwner);
aStage.setTitle(String.format("%s %s", RESOURCES.getString("dialog.about.title"),
RESOURCES.getString("application.name")));
aStage.getIcons().add(new Image(RESOURCES.getString("application.icon")));
}

private Scene createScene()
private Pane createRoot()
{
final int verticalSpacing = 5;

Expand Down Expand Up @@ -96,7 +95,7 @@ private Scene createScene()

final int padding = 15;
HBox layout = new HBox(padding);
layout.setStyle("-fx-background-color: gainsboro;");
//layout.setStyle("-fx-background-color: gainsboro;");
layout.setPadding(new Insets(padding));
layout.setAlignment(Pos.CENTER_LEFT);

Expand All @@ -114,7 +113,7 @@ private Scene createScene()
}
});

return new Scene(layout);
return layout;
}

/**
Expand Down
35 changes: 35 additions & 0 deletions src/org/jetuml/gui/AbstractDialog.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.jetuml.gui;

import javafx.scene.Scene;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.GridPane;
import javafx.stage.Modality;
import javafx.stage.Stage;

/**
*
*/
public class AbstractDialog extends Stage
{
/**
* s.
* @param pOwner d
*/
public AbstractDialog(Stage pOwner)
{
Scene scenex = new Scene(new GridPane());
setScene(scenex);
setResizable(false);
initModality(Modality.WINDOW_MODAL);
initOwner(pOwner);
addEventHandler(KeyEvent.KEY_PRESSED, pEvent ->
{
if( pEvent.getCode() == KeyCode.ESCAPE )
{
close();
}
});
getScene().getStylesheets().add(getClass().getResource("DarkMode.css").toExternalForm());
}
}
104 changes: 104 additions & 0 deletions src/org/jetuml/gui/DarkMode.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
.root {
-fx-accent: #1e74c6;
-fx-focus-color: -fx-accent;
-fx-base: #373e43;
-fx-control-inner-background: derive(-fx-base, 35%);
-fx-control-inner-background-alt: -fx-control-inner-background ;
}

.label{
-fx-text-fill: lightgray;
}

.text-field {
-fx-prompt-text-fill: gray;
}

.titulo{
-fx-font-weight: bold;
-fx-font-size: 18px;
}

.button{
-fx-focus-traversable: false;
}

.button:hover{
-fx-text-fill: white;
}

.separator *.line {
-fx-background-color: #3C3C3C;
-fx-border-style: solid;
-fx-border-width: 1px;
}

.scroll-bar{
-fx-background-color: derive(-fx-base,45%)
}

.button:default {
-fx-base: -fx-accent ;
}

.table-view{
/*-fx-background-color: derive(-fx-base, 10%);*/
-fx-selection-bar-non-focused: derive(-fx-base, 50%);
}

.table-view .column-header .label{
-fx-alignment: CENTER_LEFT;
-fx-font-weight: none;
}

.list-cell:even,
.list-cell:odd,
.table-row-cell:even,
.table-row-cell:odd{
-fx-control-inner-background: derive(-fx-base, 15%);
}

.list-cell:empty,
.table-row-cell:empty {
-fx-background-color: transparent;
}

.list-cell,
.table-row-cell{
-fx-border-color: transparent;
-fx-table-cell-border-color:transparent;
}


.welcome-tab-panel
{
-fx-padding: 20px;
}

.welcome-tab-panel .panel-title
{
-fx-padding: 0px 0px 3px 0px;
-fx-font-size: 20pt;
-fx-border-width: 0 0 3 0;
-fx-border-color: black;
-fx-border-insets: 0 0 15px 15px;
}

.welcome-tab-panel .button
{
-fx-background-color: transparent;
-fx-font-size: 17pt;
-fx-text-fill: white;
}

.welcome-tab-panel .button:hover
{
-fx-text-fill: black;
-fx-font-size: 17pt;
}

.welcome-tab-footer
{
-fx-alignment: center;
-fx-padding: 0 0 10px 0;
}
23 changes: 20 additions & 3 deletions src/org/jetuml/gui/DiagramCanvas.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ public class DiagramCanvas extends Canvas implements SelectionObserver, BooleanP
* preferred size. */
private static final int DIMENSION_BUFFER = 20;
private static final int GRID_SIZE = 10;
private static final Color REGULAR_GRID_COLOR = Color.rgb(220, 220, 220);
private static final Color DARK_MODE_GRID_COLOR = Color.web("#5e6468");
private static final Color DARK_MODE_CANVAS_COLOR = Color.web("#373e43");
private static final int DIAGRAM_PADDING = 4;
private static final int CONNECT_THRESHOLD = 8;

Expand Down Expand Up @@ -240,11 +243,25 @@ public Diagram diagram()
public void paintPanel()
{
GraphicsContext context = getGraphicsContext2D();
context.setFill(Color.WHITE);
if( UserPreferences.instance().getBoolean(BooleanPreference.darkMode) )
{
context.setFill(DARK_MODE_CANVAS_COLOR);
}
else
{
context.setFill(Color.WHITE);
}
context.fillRect(0, 0, getWidth(), getHeight());
if(UserPreferences.instance().getBoolean(BooleanPreference.showGrid))
{
Grid.draw(context, new Rectangle(0, 0, (int) getWidth(), (int) getHeight()));
if( UserPreferences.instance().getBoolean(BooleanPreference.darkMode) )
{
Grid.draw(context, new Rectangle(0, 0, (int) getWidth(), (int) getHeight()), DARK_MODE_GRID_COLOR);
}
else
{
Grid.draw(context, new Rectangle(0, 0, (int) getWidth(), (int) getHeight()), REGULAR_GRID_COLOR);
}
}
aDiagramBuilder.renderer().draw(context);
synchronizeSelectionModel();
Expand Down Expand Up @@ -353,7 +370,7 @@ else if(((ClassDiagramBuilder)aDiagramBuilder).canUnlinkFromPackage(selectedNode
@Override
public void booleanPreferenceChanged(BooleanPreference pPreference)
{
if( pPreference == BooleanPreference.showGrid )
if( pPreference == BooleanPreference.showGrid || pPreference == BooleanPreference.darkMode )
{
paintPanel();
}
Expand Down
22 changes: 10 additions & 12 deletions src/org/jetuml/gui/DiagramSizeDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,31 +54,29 @@ public class DiagramSizeDialog
private static final int MAX_SIZE = 4000;
private static final int MIN_SIZE = 250;

private final Stage aStage = new Stage();
private final Stage aStage;
private final TextField aWidthField = new TextField();
private final TextField aHeightField = new TextField();

/**
* Creates a new dialog.
*
* @param pOwner The stage that owns this stage.
* @param pDialogStage The stage that owns this stage.
*/
public DiagramSizeDialog( Stage pOwner )
public DiagramSizeDialog( Stage pDialogStage )
{
prepareStage(pOwner);
aStage.setScene(createScene());
aStage = pDialogStage;
prepareStage();
aStage.getScene().setRoot(createRoot());
}

private void prepareStage(Stage pOwner)
private void prepareStage()
{
aStage.setResizable(false);
aStage.initModality(Modality.WINDOW_MODAL);
aStage.initOwner(pOwner);
aStage.setTitle(RESOURCES.getString("dialog.diagram_size.title"));
aStage.getIcons().add(new Image(RESOURCES.getString("application.icon")));
}

private Scene createScene()
private Pane createRoot()
{
BorderPane layout = new BorderPane();
layout.setPadding( new Insets(SPACING));
Expand All @@ -87,13 +85,13 @@ private Scene createScene()
message = message.replace("#1", Integer.toString(MIN_SIZE));
message = message.replace("#2", Integer.toString(MAX_SIZE));

HBox top = new HBox(new Text(message));
HBox top = new HBox(new Label(message));
top.setAlignment(Pos.CENTER);
layout.setTop(top);
layout.setCenter(createForm());
layout.setBottom(createButtons());

return new Scene(layout);
return layout;
}

private Pane createForm()
Expand Down
Loading

0 comments on commit 810a08e

Please sign in to comment.