diff --git a/bgw-gui/src/main/kotlin/tools/aqua/bgw/builder/NodeBuilder.kt b/bgw-gui/src/main/kotlin/tools/aqua/bgw/builder/NodeBuilder.kt index 7aaa3e5e6f..204ffc63f9 100644 --- a/bgw-gui/src/main/kotlin/tools/aqua/bgw/builder/NodeBuilder.kt +++ b/bgw-gui/src/main/kotlin/tools/aqua/bgw/builder/NodeBuilder.kt @@ -34,6 +34,7 @@ import tools.aqua.bgw.components.gamecomponentviews.HexagonView import tools.aqua.bgw.components.layoutviews.CameraPane import tools.aqua.bgw.components.layoutviews.LayoutView import tools.aqua.bgw.components.layoutviews.Pane +import tools.aqua.bgw.components.uicomponents.TextInputUIComponent import tools.aqua.bgw.components.uicomponents.UIComponent import tools.aqua.bgw.core.BoardGameScene import tools.aqua.bgw.core.Scene @@ -172,6 +173,11 @@ object NodeBuilder { if (nV.isNotEmpty()) background?.style = nV } + if (this is TextInputUIComponent) { + this.internalCSS = + "-fx-control-inner-background: transparent; -fx-highlight-fill: dodgerblue; -fx-background-color: transparent; " + } + fontProperty.guiListener = { _, _ -> updateStyle(node) } internalCSSProperty.guiListener = { _, _ -> updateStyle(node) } componentStyleProperty.setGUIListenerAndInvoke(componentStyle) { _, _ -> updateStyle(node) } diff --git a/bgw-gui/src/main/kotlin/tools/aqua/bgw/builder/UINodeBuilder.kt b/bgw-gui/src/main/kotlin/tools/aqua/bgw/builder/UINodeBuilder.kt index f168247cd1..d9f819c09a 100644 --- a/bgw-gui/src/main/kotlin/tools/aqua/bgw/builder/UINodeBuilder.kt +++ b/bgw-gui/src/main/kotlin/tools/aqua/bgw/builder/UINodeBuilder.kt @@ -19,6 +19,7 @@ package tools.aqua.bgw.builder import com.jfoenix.controls.* import java.awt.Color +import java.io.FileNotFoundException import javafx.beans.property.BooleanProperty as FXBooleanProperty import javafx.beans.property.ObjectProperty as FXObjectProperty import javafx.beans.property.StringProperty as FXStringProperty @@ -84,6 +85,8 @@ object UINodeBuilder { textProperty().bindTextProperty(textArea) promptTextProperty().bindPromptProperty(textArea) disableUndo() + val resource = this::class.java.getResource("/style.css") ?: throw FileNotFoundException() + stylesheets.add(resource.toExternalForm()) } /** Builds [TextField]. */ diff --git a/bgw-gui/src/main/kotlin/tools/aqua/bgw/components/uicomponents/PasswordField.kt b/bgw-gui/src/main/kotlin/tools/aqua/bgw/components/uicomponents/PasswordField.kt index 415f437d1d..ac25552cc7 100644 --- a/bgw-gui/src/main/kotlin/tools/aqua/bgw/components/uicomponents/PasswordField.kt +++ b/bgw-gui/src/main/kotlin/tools/aqua/bgw/components/uicomponents/PasswordField.kt @@ -17,9 +17,12 @@ package tools.aqua.bgw.components.uicomponents +import java.awt.Color import tools.aqua.bgw.core.DEFAULT_TEXT_FIELD_HEIGHT import tools.aqua.bgw.core.DEFAULT_TEXT_FIELD_WIDTH import tools.aqua.bgw.util.Font +import tools.aqua.bgw.visual.ColorVisual +import tools.aqua.bgw.visual.Visual /** * A [PasswordField] is a single line input field that shows stars instead of typed text. @@ -36,6 +39,7 @@ import tools.aqua.bgw.util.Font * @param prompt Prompt for this [PasswordField]. This gets displayed as a prompt to the user * whenever the label is an empty string. Default: empty string. * @param font [Font] to be used to display [text]. + * @param visual [Visual] to be used as a background. Defaults to a Light-gray [ColorVisual]. * * @see TextField * @see TextArea @@ -47,7 +51,8 @@ open class PasswordField( height: Number = DEFAULT_TEXT_FIELD_HEIGHT, text: String = "", prompt: String = "", - font: Font = Font() + font: Font = Font(), + visual: Visual = ColorVisual(Color(240, 240, 240)) ) : TextInputUIComponent( posX = posX, @@ -56,4 +61,5 @@ open class PasswordField( height = height, text = text, prompt = prompt, - font = font) + font = font, + visual = visual) diff --git a/bgw-gui/src/main/kotlin/tools/aqua/bgw/components/uicomponents/TextArea.kt b/bgw-gui/src/main/kotlin/tools/aqua/bgw/components/uicomponents/TextArea.kt index 021a2d04a4..7de62a0b3c 100644 --- a/bgw-gui/src/main/kotlin/tools/aqua/bgw/components/uicomponents/TextArea.kt +++ b/bgw-gui/src/main/kotlin/tools/aqua/bgw/components/uicomponents/TextArea.kt @@ -19,9 +19,12 @@ package tools.aqua.bgw.components.uicomponents +import java.awt.Color import tools.aqua.bgw.core.DEFAULT_TEXT_AREA_HEIGHT import tools.aqua.bgw.core.DEFAULT_TEXT_AREA_WIDTH import tools.aqua.bgw.util.Font +import tools.aqua.bgw.visual.ColorVisual +import tools.aqua.bgw.visual.Visual /** * A [TextArea] is a multi line input field. @@ -38,6 +41,7 @@ import tools.aqua.bgw.util.Font * @param prompt Prompt for this [TextArea]. This gets displayed as a prompt to the user whenever * the label is an empty string. Default: empty string. * @param font [Font] to be used to display [text]. + * @param visual [Visual] to be used as a background. Defaults to a Light-gray [ColorVisual]. * * @see TextField * @see PasswordField @@ -49,7 +53,8 @@ open class TextArea( height: Number = DEFAULT_TEXT_AREA_HEIGHT, text: String = "", prompt: String = "", - font: Font = Font() + font: Font = Font(), + visual: Visual = ColorVisual(Color(240, 240, 240)) ) : TextInputUIComponent( posX = posX, @@ -58,4 +63,5 @@ open class TextArea( height = height, text = text, prompt = prompt, - font = font) + font = font, + visual = visual) diff --git a/bgw-gui/src/main/kotlin/tools/aqua/bgw/components/uicomponents/TextField.kt b/bgw-gui/src/main/kotlin/tools/aqua/bgw/components/uicomponents/TextField.kt index 07daee789f..419b6832a2 100644 --- a/bgw-gui/src/main/kotlin/tools/aqua/bgw/components/uicomponents/TextField.kt +++ b/bgw-gui/src/main/kotlin/tools/aqua/bgw/components/uicomponents/TextField.kt @@ -17,9 +17,12 @@ package tools.aqua.bgw.components.uicomponents +import java.awt.Color import tools.aqua.bgw.core.DEFAULT_TEXT_FIELD_HEIGHT import tools.aqua.bgw.core.DEFAULT_TEXT_FIELD_WIDTH import tools.aqua.bgw.util.Font +import tools.aqua.bgw.visual.ColorVisual +import tools.aqua.bgw.visual.Visual /** * A [TextField] is a single line input field. @@ -36,6 +39,7 @@ import tools.aqua.bgw.util.Font * @param prompt Prompt for this [TextField]. This gets displayed as a prompt to the user whenever * the label is an empty string. Default: empty string. * @param font [Font] to be used to display [text]. + * @param visual [Visual] to be used as a background. Defaults to a Light-gray [ColorVisual]. * * @see PasswordField * @see TextArea @@ -47,7 +51,8 @@ open class TextField( height: Number = DEFAULT_TEXT_FIELD_HEIGHT, text: String = "", prompt: String = "", - font: Font = Font() + font: Font = Font(), + visual: Visual = ColorVisual(Color(240, 240, 240)) ) : TextInputUIComponent( posX = posX, @@ -56,4 +61,5 @@ open class TextField( height = height, text = text, prompt = prompt, - font = font) + font = font, + visual = visual) diff --git a/bgw-gui/src/main/kotlin/tools/aqua/bgw/components/uicomponents/TextInputUIComponent.kt b/bgw-gui/src/main/kotlin/tools/aqua/bgw/components/uicomponents/TextInputUIComponent.kt index bd7fe9d3cb..8c81e4e98e 100644 --- a/bgw-gui/src/main/kotlin/tools/aqua/bgw/components/uicomponents/TextInputUIComponent.kt +++ b/bgw-gui/src/main/kotlin/tools/aqua/bgw/components/uicomponents/TextInputUIComponent.kt @@ -19,9 +19,11 @@ package tools.aqua.bgw.components.uicomponents +import java.awt.Color import tools.aqua.bgw.observable.properties.Property import tools.aqua.bgw.observable.properties.StringProperty import tools.aqua.bgw.util.Font +import tools.aqua.bgw.visual.ColorVisual import tools.aqua.bgw.visual.Visual /** @@ -34,6 +36,7 @@ import tools.aqua.bgw.visual.Visual * @param text Text for this [TextInputUIComponent]. * @param prompt Prompt for this [TextInputUIComponent]. * @param font Font to be used for the [text]. + * @param visual [Visual] to be used as a background. Defaults to a Light-gray [ColorVisual]. */ sealed class TextInputUIComponent( posX: Number, @@ -43,14 +46,10 @@ sealed class TextInputUIComponent( text: String, prompt: String, font: Font, + visual: Visual = ColorVisual(Color(240, 240, 240)) ) : UIComponent( - posX = posX, - posY = posY, - width = width, - height = height, - font = font, - visual = Visual.EMPTY) { + posX = posX, posY = posY, width = width, height = height, font = font, visual = visual) { /** * [Property] for the text of this [TextInputUIComponent].