Overlay style fixes [release]

This commit is contained in:
crschnick 2024-03-24 07:19:54 +00:00
parent ce8c97dce6
commit e90c6f36d3
4 changed files with 20 additions and 23 deletions

View file

@ -7,8 +7,11 @@ import javafx.beans.property.Property;
import javafx.beans.property.SimpleObjectProperty; import javafx.beans.property.SimpleObjectProperty;
import javafx.scene.control.TextArea; import javafx.scene.control.TextArea;
import javafx.scene.layout.Region; import javafx.scene.layout.Region;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.experimental.FieldDefaults; import lombok.experimental.FieldDefaults;
import org.kordamp.ikonli.javafx.FontIcon;
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
public class ErrorOverlayComp extends SimpleComp { public class ErrorOverlayComp extends SimpleComp {
@ -34,7 +37,11 @@ public class ErrorOverlayComp extends SimpleComp {
l.setEditable(false); l.setEditable(false);
return l; return l;
}); });
content.set(new ModalOverlayComp.OverlayContent("error", comp, null, () -> {})); content.set(new ModalOverlayComp.OverlayContent("error", comp, Comp.of(() -> {
var graphic = new FontIcon("mdomz-warning");
graphic.setIconColor(Color.RED);
return new StackPane(graphic);
}), null, () -> {}));
}); });
}); });
content.addListener((observable, oldValue, newValue) -> { content.addListener((observable, oldValue, newValue) -> {

View file

@ -2,7 +2,6 @@ package io.xpipe.app.comp.base;
import atlantafx.base.controls.ModalPane; import atlantafx.base.controls.ModalPane;
import atlantafx.base.layout.ModalBox; import atlantafx.base.layout.ModalBox;
import atlantafx.base.theme.Styles;
import io.xpipe.app.core.AppFont; import io.xpipe.app.core.AppFont;
import io.xpipe.app.core.AppI18n; import io.xpipe.app.core.AppI18n;
import io.xpipe.app.fxcomps.Comp; import io.xpipe.app.fxcomps.Comp;
@ -17,9 +16,7 @@ import javafx.scene.control.Label;
import javafx.scene.layout.Region; import javafx.scene.layout.Region;
import javafx.scene.layout.StackPane; import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox; import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import lombok.Value; import lombok.Value;
import org.kordamp.ikonli.javafx.FontIcon;
public class ModalOverlayComp extends SimpleComp { public class ModalOverlayComp extends SimpleComp {
@ -35,6 +32,7 @@ public class ModalOverlayComp extends SimpleComp {
protected Region createSimple() { protected Region createSimple() {
var bgRegion = background.createRegion(); var bgRegion = background.createRegion();
var modal = new ModalPane(); var modal = new ModalPane();
AppFont.small(modal);
modal.getStyleClass().add("modal-overlay-comp"); modal.getStyleClass().add("modal-overlay-comp");
var pane = new StackPane(bgRegion, modal); var pane = new StackPane(bgRegion, modal);
pane.setPickOnBounds(false); pane.setPickOnBounds(false);
@ -45,9 +43,7 @@ public class ModalOverlayComp extends SimpleComp {
} }
if (newValue != null) { if (newValue != null) {
var graphic = new FontIcon("mdomz-warning"); var l = new Label(AppI18n.get(newValue.titleKey), newValue.graphic != null ? newValue.graphic.createRegion() : null);
graphic.setIconColor(Color.RED);
var l = new Label(AppI18n.get(newValue.titleKey), graphic);
l.setGraphicTextGap(6); l.setGraphicTextGap(6);
AppFont.normal(l); AppFont.normal(l);
var r = newValue.content.createRegion(); var r = newValue.content.createRegion();
@ -58,7 +54,6 @@ public class ModalOverlayComp extends SimpleComp {
if (newValue.finishKey != null) { if (newValue.finishKey != null) {
var finishButton = new Button(AppI18n.get(newValue.finishKey)); var finishButton = new Button(AppI18n.get(newValue.finishKey));
finishButton.setDefaultButton(true); finishButton.setDefaultButton(true);
Styles.toggleStyleClass(finishButton, Styles.FLAT);
finishButton.setOnAction(event -> { finishButton.setOnAction(event -> {
newValue.onFinish.run(); newValue.onFinish.run();
overlayContent.setValue(null); overlayContent.setValue(null);
@ -97,6 +92,7 @@ public class ModalOverlayComp extends SimpleComp {
String titleKey; String titleKey;
Comp<?> content; Comp<?> content;
Comp<?> graphic;
String finishKey; String finishKey;
Runnable onFinish; Runnable onFinish;
} }

View file

@ -3,16 +3,10 @@
-fx-background-radius: 6; -fx-background-radius: 6;
} }
.modal-overlay-comp { .modal-overlay-comp .modal-box .button {
-fx-border-radius: 0; -fx-padding: 6 12 6 12;
-fx-background-radius: 0; -fx-border-width: 1px;
} -fx-border-radius: 2px;
-fx-background-radius: 2px;
.modal-overlay-comp .titled-pane > * {
-fx-border-radius: 0;
}
.modal-overlay-comp .titled-pane > * {
-fx-background-radius: 0;
} }

View file

@ -63,6 +63,7 @@ public class NewItemAction implements BrowserAction, BranchAction {
creationName.textProperty().bindBidirectional(name); creationName.textProperty().bindBidirectional(name);
return creationName; return creationName;
}), }),
null,
"finish", "finish",
() -> { () -> {
model.createFileAsync(name.getValue()); model.createFileAsync(name.getValue());
@ -91,6 +92,7 @@ public class NewItemAction implements BrowserAction, BranchAction {
creationName.textProperty().bindBidirectional(name); creationName.textProperty().bindBidirectional(name);
return creationName; return creationName;
}), }),
null,
"finish", "finish",
() -> { () -> {
model.createDirectoryAsync(name.getValue()); model.createDirectoryAsync(name.getValue());
@ -116,15 +118,13 @@ public class NewItemAction implements BrowserAction, BranchAction {
.setValue(new ModalOverlayComp.OverlayContent( .setValue(new ModalOverlayComp.OverlayContent(
"base.newLink", "base.newLink",
new OptionsBuilder() new OptionsBuilder()
.spacer(10)
.name("linkName") .name("linkName")
.addString(linkName) .addString(linkName)
.spacer(10)
.name("targetPath") .name("targetPath")
.addString(target) .addString(target)
.buildComp() .buildComp()
.prefWidth(400) .prefWidth(350),
.prefHeight(130), null,
"finish", "finish",
() -> { () -> {
model.createLinkAsync(linkName.getValue(), target.getValue()); model.createLinkAsync(linkName.getValue(), target.getValue());