Commit 524de469 authored by ryoii's avatar ryoii

play with ui any way

parent 899c2b7d
package net.mamoe.mirai.console.graphical.styleSheet
import javafx.scene.Cursor
import javafx.scene.effect.BlurType
import javafx.scene.effect.DropShadow
import javafx.scene.paint.Color
import javafx.scene.text.FontWeight
import tornadofx.*
class LoginViewStyleSheet : Stylesheet() {
companion object {
val vBox by csselement("VBox")
}
init {
vBox {
maxWidth = 500.px
maxHeight = 500.px
backgroundColor += c("39c5BB", 0.3)
backgroundRadius += box(15.px)
padding = box(50.px, 100.px)
spacing = 25.px
borderRadius += box(15.px)
effect = DropShadow(BlurType.THREE_PASS_BOX, Color.GRAY, 10.0, 0.0, 15.0, 15.0)
}
textField {
prefHeight = 30.px
textFill = Color.BLACK
fontWeight = FontWeight.BOLD
}
button {
backgroundColor += c("00BCD4", 0.8)
padding = box(10.px, 0.px)
prefWidth = 500.px
textFill = Color.WHITE
fontWeight = FontWeight.BOLD
cursor = Cursor.HAND
}
}
}
\ No newline at end of file
...@@ -17,20 +17,20 @@ internal fun EventTarget.jfxButton(text: String = "", graphic: Node? = null, op: ...@@ -17,20 +17,20 @@ internal fun EventTarget.jfxButton(text: String = "", graphic: Node? = null, op:
if (graphic != null) it.graphic = graphic if (graphic != null) it.graphic = graphic
} }
fun EventTarget.jfxTextfield(value: String? = null, op: TextField.() -> Unit = {}) = JFXTextField().attachTo(this, op) { fun EventTarget.jfxTextfield(value: String? = null, op: JFXTextField.() -> Unit = {}) = JFXTextField().attachTo(this, op) {
if (value != null) it.text = value if (value != null) it.text = value
} }
fun EventTarget.jfxTextfield(property: ObservableValue<String>, op: TextField.() -> Unit = {}) = jfxTextfield().apply { fun EventTarget.jfxTextfield(property: ObservableValue<String>, op: JFXTextField.() -> Unit = {}) = jfxTextfield().apply {
bind(property) bind(property)
op(this) op(this)
} }
fun EventTarget.jfxPasswordfield(value: String? = null, op: TextField.() -> Unit = {}) = JFXPasswordField().attachTo(this, op) { fun EventTarget.jfxPasswordfield(value: String? = null, op: JFXPasswordField.() -> Unit = {}) = JFXPasswordField().attachTo(this, op) {
if (value != null) it.text = value if (value != null) it.text = value
} }
fun EventTarget.jfxPasswordfield(property: ObservableValue<String>, op: TextField.() -> Unit = {}) = jfxPasswordfield().apply { fun EventTarget.jfxPasswordfield(property: ObservableValue<String>, op: JFXPasswordField.() -> Unit = {}) = jfxPasswordfield().apply {
bind(property) bind(property)
op(this) op(this)
} }
......
package net.mamoe.mirai.console.graphical.view package net.mamoe.mirai.console.graphical.view
import com.jfoenix.controls.JFXAlert
import com.jfoenix.controls.JFXPopup
import javafx.beans.property.SimpleStringProperty import javafx.beans.property.SimpleStringProperty
import javafx.scene.control.Label import javafx.geometry.Pos
import javafx.scene.image.Image
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import net.mamoe.mirai.console.graphical.controller.MiraiGraphicalUIController import net.mamoe.mirai.console.graphical.controller.MiraiGraphicalUIController
import net.mamoe.mirai.console.graphical.styleSheet.LoginViewStyleSheet
import net.mamoe.mirai.console.graphical.util.jfxButton import net.mamoe.mirai.console.graphical.util.jfxButton
import net.mamoe.mirai.console.graphical.util.jfxPasswordfield import net.mamoe.mirai.console.graphical.util.jfxPasswordfield
import net.mamoe.mirai.console.graphical.util.jfxTextfield import net.mamoe.mirai.console.graphical.util.jfxTextfield
import tornadofx.* import tornadofx.*
class LoginView : View() { class LoginView : View("CNM") {
private val controller = find<MiraiGraphicalUIController>() private val controller = find<MiraiGraphicalUIController>()
private val qq = SimpleStringProperty("") private val qq = SimpleStringProperty("")
private val psd = SimpleStringProperty("") private val psd = SimpleStringProperty("")
override val root = pane { override val root = borderpane {
form {
fieldset("登录") { addStylesheet(LoginViewStyleSheet::class)
field("QQ") {
jfxTextfield(qq) center = vbox {
}
field("密码") { imageview(Image(LoginView::class.java.classLoader.getResourceAsStream("character.png"))) {
jfxPasswordfield(psd) alignment = Pos.CENTER
}
} }
jfxButton("登录").action {
jfxTextfield(qq) {
promptText = "QQ"
isLabelFloat = true
}
jfxPasswordfield(psd) {
promptText = "Password"
isLabelFloat = true
}
jfxButton("Login").action {
runAsync { runAsync {
runBlocking { runBlocking { controller.login(qq.value, psd.value) }
controller.login(qq.value, psd.value)
}
}.ui { }.ui {
// show dialog qq.value = ""
psd.value = ""
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment