mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 15:10:44 +01:00
Add padding for text area
This commit is contained in:
parent
16fe990424
commit
f122a4579f
11 changed files with 163 additions and 11 deletions
|
@ -523,12 +523,21 @@ bg color of non edit textFields: fafafa
|
|||
-jfx-focus-color: -bs-rd-green;
|
||||
-jfx-unfocus-color: -bs-rd-grey-line;
|
||||
-fx-background-color: -bs-rd-white;
|
||||
-fx-padding: 0.333333em 0.333333em 0.333333em 0.333333em;
|
||||
}
|
||||
|
||||
.jfx-text-area:readonly {
|
||||
-fx-background-color: transparent;
|
||||
}
|
||||
|
||||
.jfx-text-area > .input-line {
|
||||
-fx-translate-x: -0.333333em;
|
||||
}
|
||||
|
||||
.jfx-text-area > .input-focused-line {
|
||||
-fx-translate-x: -0.333333em;
|
||||
}
|
||||
|
||||
.wallet-seed-words {
|
||||
-fx-font-family: "IBM Plex Mono";
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
package bisq.desktop.components;
|
||||
|
||||
import com.jfoenix.controls.JFXTextArea;
|
||||
|
||||
import javafx.scene.control.Skin;
|
||||
|
||||
public class BisqTextArea extends JFXTextArea {
|
||||
@Override
|
||||
protected Skin<?> createDefaultSkin() {
|
||||
return new JFXTextAreaSkinBisqStyle(this);
|
||||
}
|
||||
}
|
|
@ -41,6 +41,10 @@ import javafx.geometry.VPos;
|
|||
|
||||
import javafx.util.Duration;
|
||||
|
||||
/**
|
||||
* Code copied and adapted from com.jfoenix.skins.JFXRadioButtonSkin
|
||||
*/
|
||||
|
||||
public class JFXRadioButtonSkinBisqStyle extends RadioButtonSkin {
|
||||
private final JFXRippler rippler;
|
||||
private double padding = 12;
|
||||
|
|
|
@ -0,0 +1,121 @@
|
|||
package bisq.desktop.components;
|
||||
|
||||
import com.jfoenix.adapters.ReflectionHelper;
|
||||
import com.jfoenix.controls.JFXTextArea;
|
||||
import com.jfoenix.skins.PromptLinesWrapper;
|
||||
import com.jfoenix.skins.ValidationPane;
|
||||
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.ScrollPane;
|
||||
import javafx.scene.control.skin.TextAreaSkin;
|
||||
import javafx.scene.layout.Background;
|
||||
import javafx.scene.layout.BackgroundFill;
|
||||
import javafx.scene.layout.CornerRadii;
|
||||
import javafx.scene.layout.Region;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.text.Text;
|
||||
|
||||
import javafx.geometry.Insets;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/**
|
||||
* Code copied and adapted from com.jfoenix.skins.JFXTextAreaSkin
|
||||
*/
|
||||
|
||||
public class JFXTextAreaSkinBisqStyle extends TextAreaSkin {
|
||||
|
||||
private boolean invalid = true;
|
||||
|
||||
private ScrollPane scrollPane;
|
||||
private Text promptText;
|
||||
|
||||
private ValidationPane<JFXTextArea> errorContainer;
|
||||
private PromptLinesWrapper<JFXTextArea> linesWrapper;
|
||||
|
||||
public JFXTextAreaSkinBisqStyle(JFXTextArea textArea) {
|
||||
super(textArea);
|
||||
// init text area properties
|
||||
scrollPane = (ScrollPane) getChildren().get(0);
|
||||
textArea.setWrapText(true);
|
||||
|
||||
linesWrapper = new PromptLinesWrapper<>(
|
||||
textArea,
|
||||
promptTextFillProperty(),
|
||||
textArea.textProperty(),
|
||||
textArea.promptTextProperty(),
|
||||
() -> promptText);
|
||||
|
||||
linesWrapper.init(() -> createPromptNode(), scrollPane);
|
||||
errorContainer = new ValidationPane<>(textArea);
|
||||
getChildren().addAll(linesWrapper.line, linesWrapper.focusedLine, linesWrapper.promptContainer, errorContainer);
|
||||
|
||||
registerChangeListener(textArea.disableProperty(), obs -> linesWrapper.updateDisabled());
|
||||
registerChangeListener(textArea.focusColorProperty(), obs -> linesWrapper.updateFocusColor());
|
||||
registerChangeListener(textArea.unFocusColorProperty(), obs -> linesWrapper.updateUnfocusColor());
|
||||
registerChangeListener(textArea.disableAnimationProperty(), obs -> errorContainer.updateClip());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void layoutChildren(final double x, final double y, final double w, final double h) {
|
||||
super.layoutChildren(x, y, w, h);
|
||||
|
||||
final double height = getSkinnable().getHeight();
|
||||
final double width = getSkinnable().getWidth();
|
||||
linesWrapper.layoutLines(x, y, width, h, height, promptText == null ? 0 : promptText.getLayoutBounds().getHeight() + 3);
|
||||
errorContainer.layoutPane(x, height + linesWrapper.focusedLine.getHeight(), width, h);
|
||||
linesWrapper.updateLabelFloatLayout();
|
||||
|
||||
if (invalid) {
|
||||
invalid = false;
|
||||
// set the default background of text area viewport to white
|
||||
Region viewPort = (Region) scrollPane.getChildrenUnmodifiable().get(0);
|
||||
viewPort.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT,
|
||||
CornerRadii.EMPTY,
|
||||
Insets.EMPTY)));
|
||||
// reapply css of scroll pane in case set by the user
|
||||
viewPort.applyCss();
|
||||
errorContainer.invalid(w);
|
||||
// focus
|
||||
linesWrapper.invalid();
|
||||
}
|
||||
}
|
||||
|
||||
private void createPromptNode() {
|
||||
if (promptText != null || !linesWrapper.usePromptText.get()) {
|
||||
return;
|
||||
}
|
||||
promptText = new Text();
|
||||
promptText.setManaged(false);
|
||||
promptText.getStyleClass().add("text");
|
||||
promptText.setTranslateX(-getSkinnable().getPadding().getLeft() + 1);
|
||||
promptText.visibleProperty().bind(linesWrapper.usePromptText);
|
||||
promptText.fontProperty().bind(getSkinnable().fontProperty());
|
||||
promptText.textProperty().bind(getSkinnable().promptTextProperty());
|
||||
promptText.fillProperty().bind(linesWrapper.animatedPromptTextFill);
|
||||
promptText.setLayoutX(1);
|
||||
promptText.getTransforms().add(linesWrapper.promptTextScale);
|
||||
linesWrapper.promptContainer.getChildren().add(promptText);
|
||||
if (getSkinnable().isFocused() && ((JFXTextArea) getSkinnable()).isLabelFloat()) {
|
||||
promptText.setTranslateY(-Math.floor(scrollPane.getHeight()));
|
||||
linesWrapper.promptTextScale.setX(0.85);
|
||||
linesWrapper.promptTextScale.setY(0.85);
|
||||
}
|
||||
|
||||
try {
|
||||
Field field = ReflectionHelper.getField(TextAreaSkin.class, "promptNode");
|
||||
Object oldValue = field.get(this);
|
||||
if (oldValue != null) {
|
||||
removeHighlight(Arrays.asList(((Node) oldValue)));
|
||||
}
|
||||
field.set(this, promptText);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -16,6 +16,10 @@ import javafx.beans.value.ObservableDoubleValue;
|
|||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/**
|
||||
* Code copied and adapted from com.jfoenix.skins.JFXTextFieldSkin
|
||||
*/
|
||||
|
||||
public class JFXTextFieldSkinBisqStyle<T extends TextField & IFXLabelFloatControl> extends TextFieldSkin {
|
||||
|
||||
private double inputLineExtension;
|
||||
|
|
|
@ -22,6 +22,7 @@ import bisq.desktop.common.view.FxmlView;
|
|||
import bisq.desktop.components.AutoTooltipButton;
|
||||
import bisq.desktop.components.AutoTooltipLabel;
|
||||
import bisq.desktop.components.AutoTooltipTableColumn;
|
||||
import bisq.desktop.components.BisqTextArea;
|
||||
import bisq.desktop.components.BusyAnimation;
|
||||
import bisq.desktop.components.HyperlinkWithIcon;
|
||||
import bisq.desktop.components.InputTextField;
|
||||
|
@ -67,8 +68,6 @@ import com.google.common.io.ByteStreams;
|
|||
import de.jensd.fx.fontawesome.AwesomeDude;
|
||||
import de.jensd.fx.fontawesome.AwesomeIcon;
|
||||
|
||||
import com.jfoenix.controls.JFXTextArea;
|
||||
|
||||
import javafx.stage.FileChooser;
|
||||
|
||||
import javafx.scene.Scene;
|
||||
|
@ -691,7 +690,7 @@ public class TraderDisputeView extends ActivatableView<VBox, Void> {
|
|||
messagesAnchorPane = new AnchorPane();
|
||||
VBox.setVgrow(messagesAnchorPane, Priority.ALWAYS);
|
||||
|
||||
inputTextArea = new JFXTextArea();
|
||||
inputTextArea = new BisqTextArea();
|
||||
inputTextArea.setPrefHeight(70);
|
||||
inputTextArea.setWrapText(true);
|
||||
if (!(this instanceof ArbitratorDisputeView))
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package bisq.desktop.main.overlays.windows;
|
||||
|
||||
import bisq.desktop.components.BisqTextArea;
|
||||
import bisq.desktop.main.MainView;
|
||||
import bisq.desktop.main.overlays.Overlay;
|
||||
import bisq.desktop.util.Layout;
|
||||
|
@ -194,7 +195,7 @@ public class ContractWindow extends Overlay<ContractWindow> {
|
|||
Res.get("shared.viewContractAsJson"), 0).second;
|
||||
viewContractButton.setDefaultButton(false);
|
||||
viewContractButton.setOnAction(e -> {
|
||||
TextArea textArea = new TextArea();
|
||||
TextArea textArea = new BisqTextArea();
|
||||
String contractAsJson = dispute.getContractAsJson();
|
||||
contractAsJson += "\n\nBuyerMultiSigPubKeyHex: " + Utils.HEX.encode(contract.getBuyerMultiSigPubKey());
|
||||
contractAsJson += "\nSellerMultiSigPubKeyHex: " + Utils.HEX.encode(contract.getSellerMultiSigPubKey());
|
||||
|
|
|
@ -19,6 +19,7 @@ package bisq.desktop.main.overlays.windows;
|
|||
|
||||
import bisq.desktop.components.AutoTooltipCheckBox;
|
||||
import bisq.desktop.components.AutoTooltipRadioButton;
|
||||
import bisq.desktop.components.BisqTextArea;
|
||||
import bisq.desktop.components.InputTextField;
|
||||
import bisq.desktop.main.overlays.Overlay;
|
||||
import bisq.desktop.main.overlays.popups.Popup;
|
||||
|
@ -45,8 +46,6 @@ import org.bitcoinj.core.Coin;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import com.jfoenix.controls.JFXTextArea;
|
||||
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.CheckBox;
|
||||
|
@ -485,7 +484,7 @@ public class DisputeSummaryWindow extends Overlay<DisputeSummaryWindow> {
|
|||
|
||||
private void addSummaryNotes() {
|
||||
|
||||
summaryNotesTextArea = new JFXTextArea();
|
||||
summaryNotesTextArea = new BisqTextArea();
|
||||
summaryNotesTextArea.setPromptText(Res.get("disputeSummaryWindow.addSummaryNotes"));
|
||||
summaryNotesTextArea.setWrapText(true);
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package bisq.desktop.main.overlays.windows;
|
||||
|
||||
import bisq.desktop.components.BisqTextArea;
|
||||
import bisq.desktop.components.TextFieldWithCopyIcon;
|
||||
import bisq.desktop.main.MainView;
|
||||
import bisq.desktop.main.overlays.Overlay;
|
||||
|
@ -247,7 +248,7 @@ public class TradeDetailsWindow extends Overlay<TradeDetailsWindow> {
|
|||
Res.get("shared.viewContractAsJson"), 0).second;
|
||||
viewContractButton.setDefaultButton(false);
|
||||
viewContractButton.setOnAction(e -> {
|
||||
TextArea textArea = new TextArea();
|
||||
TextArea textArea = new BisqTextArea();
|
||||
textArea.setText(trade.getContractAsJson());
|
||||
String contractAsJson = trade.getContractAsJson();
|
||||
contractAsJson += "\n\nBuyerMultiSigPubKeyHex: " + Utils.HEX.encode(contract.getBuyerMultiSigPubKey());
|
||||
|
|
|
@ -24,6 +24,7 @@ import bisq.desktop.components.AutoTooltipLabel;
|
|||
import bisq.desktop.components.AutoTooltipRadioButton;
|
||||
import bisq.desktop.components.AutoTooltipSlideToggleButton;
|
||||
import bisq.desktop.components.BalanceTextField;
|
||||
import bisq.desktop.components.BisqTextArea;
|
||||
import bisq.desktop.components.BsqAddressTextField;
|
||||
import bisq.desktop.components.BusyAnimation;
|
||||
import bisq.desktop.components.FundsTextField;
|
||||
|
@ -417,7 +418,7 @@ public class FormBuilder {
|
|||
|
||||
public static TextArea addTextArea(GridPane gridPane, int rowIndex, String prompt, double top) {
|
||||
|
||||
TextArea textArea = new JFXTextArea();
|
||||
TextArea textArea = new BisqTextArea();
|
||||
textArea.setPromptText(prompt);
|
||||
((JFXTextArea) textArea).setLabelFloat(true);
|
||||
textArea.setWrapText(true);
|
||||
|
@ -454,7 +455,7 @@ public class FormBuilder {
|
|||
public static Tuple2<Label, TextArea> addTopLabelTextArea(GridPane gridPane, int rowIndex, int colIndex,
|
||||
String title, String prompt, double top) {
|
||||
|
||||
TextArea textArea = new JFXTextArea();
|
||||
TextArea textArea = new BisqTextArea();
|
||||
textArea.setPromptText(prompt);
|
||||
textArea.setWrapText(true);
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ package bisq.desktop.util;
|
|||
|
||||
import bisq.desktop.app.BisqApp;
|
||||
import bisq.desktop.components.AutoTooltipLabel;
|
||||
import bisq.desktop.components.BisqTextArea;
|
||||
import bisq.desktop.components.indicator.TxConfidenceIndicator;
|
||||
import bisq.desktop.main.overlays.popups.Popup;
|
||||
|
||||
|
@ -740,7 +741,7 @@ public class GUIUtil {
|
|||
}
|
||||
|
||||
public static void showSelectableTextModal(String title, String text) {
|
||||
TextArea textArea = new TextArea();
|
||||
TextArea textArea = new BisqTextArea();
|
||||
textArea.setText(text);
|
||||
textArea.setEditable(false);
|
||||
textArea.setWrapText(true);
|
||||
|
|
Loading…
Add table
Reference in a new issue