Skip to content

Commit

Permalink
CSSTUDIO-2482 If default colors are available for headers, use those …
Browse files Browse the repository at this point in the history
…for the toolbar in the navigator.
  • Loading branch information
abrahamwolk committed Jul 16, 2024
1 parent 6f0762e commit c613494
Showing 1 changed file with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ public class NavigatorController implements Initializable {
private static final String NAVIGATOR_SELECTOR_MENU_ITEMS_CSS = "-fx-font-weight: normal; -fx-font-size: 13; ";
private static String NAVIGATOR_ROOT;
protected static String OPI_ROOT;
static private String TOP_BAR_CSS_STYLE;
static private String NAVIGATOR_LABEL_CSS_STYLE;
static private Color TREE_WIDGET_BACKGROUND_COLOR;
static private DataFormat navigationTreeDataFormat = new DataFormat("application/navigation-tree-data-format");
@FXML
Expand All @@ -119,6 +121,36 @@ public void initialize(URL location, ResourceBundle resources) {

VBox.setVgrow(treeView, Priority.ALWAYS);

{
Optional<NamedWidgetColor> maybeBackgroundColor = WidgetColorService.getColors().getColor("PRIMARY-HEADER-BACKGROUND");
Optional<NamedWidgetColor> maybeForegroundColor = WidgetColorService.getColors().getColor("HEADER-TEXT");
if (maybeBackgroundColor.isPresent() && maybeForegroundColor.isPresent()) {
String backgroundColor_string;
String foregroundColor_string;

{
NamedWidgetColor namedBackgroundColor = maybeBackgroundColor.get();
Color backgroundColor = new Color(namedBackgroundColor.getRed()/255.0, namedBackgroundColor.getGreen()/255.0, namedBackgroundColor.getBlue()/255.0, namedBackgroundColor.getAlpha()/255.0);
backgroundColor_string = "#" + backgroundColor.toString().substring(2, 8);
}

{
NamedWidgetColor namedForegroundColor = maybeForegroundColor.get();
Color foregroundColor = new Color(namedForegroundColor.getRed()/255.0, namedForegroundColor.getGreen()/255.0, namedForegroundColor.getBlue()/255.0, namedForegroundColor.getAlpha()/255.0);
foregroundColor_string = "#" + foregroundColor.toString().substring(2, 8);
}
TOP_BAR_CSS_STYLE = "-fx-alignment: center; -fx-background-color: " + backgroundColor_string + ";";
NAVIGATOR_LABEL_CSS_STYLE = "-fx-font-weight: bold; -fx-text-fill: " + foregroundColor_string + ";";
}
else {
TOP_BAR_CSS_STYLE = "-fx-alignment: center; -fx-background-color: #483d8b;";
NAVIGATOR_LABEL_CSS_STYLE = "-fx-font-weight: bold; -fx-text-fill: white;";
}

topBar.setStyle(TOP_BAR_CSS_STYLE);
navigatorLabel.setStyle(NAVIGATOR_LABEL_CSS_STYLE);
}

{
Optional<NamedWidgetColor> maybeNamedWidgetColor = WidgetColorService.getColors().getColor(NamedWidgetColors.BACKGROUND);
if (maybeNamedWidgetColor.isPresent()) {
Expand Down Expand Up @@ -260,6 +292,7 @@ private void loadTopMostNavigator() {
void enterEditModeAction(ActionEvent actionEvent) {
editModeEnabledProperty.set(true);
topBar.setStyle("-fx-alignment: center; -fx-background-color: fuchsia; ");
navigatorLabel.setStyle("-fx-font-weight: bold; -fx-text-fill: white; ");
enableDragNDropToTopBar();
leaveEditModeMenuItem.setDisable(true);
saveChangesMenuItem.setDisable(true);
Expand Down Expand Up @@ -292,7 +325,9 @@ protected void saveNavigatorAction(ActionEvent actionEvent) {
@FXML
void leaveEditModeAction(ActionEvent actionEvent) {
editModeEnabledProperty.set(false);
topBar.setStyle("-fx-alignment: center; -fx-background-color: #483d8b; ");

topBar.setStyle(TOP_BAR_CSS_STYLE);
navigatorLabel.setStyle(NAVIGATOR_LABEL_CSS_STYLE);
disableDragNDropToTopBar();
leaveEditModeMenuItem.setDisable(false);
saveChangesMenuItem.setDisable(true);
Expand Down

0 comments on commit c613494

Please sign in to comment.