diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenView.java b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenView.java index c3a16606..5b2b3e26 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenView.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/modules/stock_screen/StockScreenView.java @@ -13,6 +13,7 @@ import javafx.beans.property.SimpleDoubleProperty; import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleStringProperty; import javafx.beans.value.ObservableValue; +import javafx.css.PseudoClass; import javafx.scene.Node; import javafx.scene.control.*; import javafx.scene.input.KeyCode; @@ -68,10 +69,24 @@ class StockScreenView implements IFXComponent { HBox.setHgrow(separator, Priority.ALWAYS); mainPaneContent.setTop(mainPaneTopContent); + PseudoClass outOfStockPseudoClass = PseudoClass.getPseudoClass("stock-out"); + PseudoClass lowStockPseudoClass = PseudoClass.getPseudoClass("stock-low"); + PseudoClass highStockPseudoClass = PseudoClass.getPseudoClass("stock-high"); stockTableView = new TableView<>(); stockTableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); stockTableView.setRowFactory(tableView->{ TableRow row = new TableRow<>(); + row.itemProperty().addListener((obs, oldVal, newVal)->{ + if(newVal!=null){ + row.pseudoClassStateChanged(outOfStockPseudoClass, newVal.getAmountRemaining()<=0); + row.pseudoClassStateChanged(lowStockPseudoClass, newVal.getAmountRemaining()>0 && newVal.getAmountRemaining()<30); + row.pseudoClassStateChanged(highStockPseudoClass, newVal.getAmountRemaining()>=30); + }else{ + row.pseudoClassStateChanged(outOfStockPseudoClass, false); + row.pseudoClassStateChanged(lowStockPseudoClass, false); + row.pseudoClassStateChanged(highStockPseudoClass, false); + } + }); row.setOnMouseClicked(event -> { if (event.getButton().equals(MouseButton.PRIMARY) && event.getClickCount() == 2) ctrl.getProductActivationListener().onProductActivated(row.getItem()); diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/javafx_override/HighlightListCell.java b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/javafx_override/HighlightListCell.java index 7bab5db3..985b058c 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/javafx_override/HighlightListCell.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/ressources/components/generics/javafx_override/HighlightListCell.java @@ -1,18 +1,25 @@ package com.pqt.client.gui.ressources.components.generics.javafx_override; +import javafx.css.PseudoClass; import javafx.scene.control.ListCell; public class HighlightListCell extends ListCell { + + private PseudoClass highlightPC; + private boolean highlighted; + + public HighlightListCell() { + super(); + highlighted = false; + highlightPC = PseudoClass.getPseudoClass("highlighted"); + } + public void setHighLight(boolean highLight){ - if(highLight){ - if(!getStyleClass().contains("list-cell-highlighted")) - getStyleClass().add("list-cell-highlighted"); - } - else - getStyleClass().remove("list-cell-highlighted"); + highlighted = highLight; + this.pseudoClassStateChanged(highlightPC, highLight); } public boolean isHightlighted(){ - return getStyleClass().contains("list-cell-highlighted"); + return highlighted; } } diff --git a/Workspace/client/src/main/resources/dark-theme.css b/Workspace/client/src/main/resources/dark-theme.css index e8db18a7..4d001188 100644 --- a/Workspace/client/src/main/resources/dark-theme.css +++ b/Workspace/client/src/main/resources/dark-theme.css @@ -51,6 +51,7 @@ .list-view { -fx-base: #1d1d1d; -fx-control-inner-background: #1d1d1d; + -fx-control-inner-background-alt: #333333; -fx-background-color: #1d1d1d; -fx-table-cell-border-color: transparent; -fx-table-header-border-color: transparent; @@ -71,8 +72,10 @@ .list-view:focused .list-cell:filled:focused:selected { -fx-background-color: -fx-focus-color; } -.list-cell-highlighted{ - -fx-background-color: #4d4d4d; +.list-cell:highlighted{ + -fx-text-fill: #cc7a00; + -fx-border-width: 1px; + -fx-border-color: white; } .table-view { @@ -108,6 +111,26 @@ -fx-opacity: 1; } +.table-view .table-row-cell { + -fx-control-inner-background: #1d1d1d; + -fx-control-inner-background-alt: #333333; +} + +.table-view .table-row-cell:stock-out { + -fx-control-inner-background: #4d0000; + -fx-control-inner-background-alt: #4d0000; +} + +.table-view .table-row-cell:stock-low { + -fx-control-inner-background: #4d2e00; + -fx-control-inner-background-alt: #4d2e00; +} + +.table-view .table-row-cell:stock-high { + -fx-control-inner-background: #1a3300; + -fx-control-inner-background-alt: #1a3300; +} + .table-view:focused .table-row-cell:filled:focused:selected { -fx-background-color: -fx-focus-color; } @@ -247,7 +270,7 @@ .validator .button{ -fx-pref-width: 150; -fx-pref-height: 50; - } +} .sidebar { -fx-background-color: #2e2e2e;