mirror of
https://github.com/mamoe/mirai.git
synced 2024-12-28 17:40:09 +08:00
play with ui any way
This commit is contained in:
parent
899c2b7dda
commit
524de46954
@ -0,0 +1,47 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
@ -17,20 +17,20 @@ internal fun EventTarget.jfxButton(text: String = "", graphic: Node? = null, op:
|
||||
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
|
||||
}
|
||||
|
||||
fun EventTarget.jfxTextfield(property: ObservableValue<String>, op: TextField.() -> Unit = {}) = jfxTextfield().apply {
|
||||
fun EventTarget.jfxTextfield(property: ObservableValue<String>, op: JFXTextField.() -> Unit = {}) = jfxTextfield().apply {
|
||||
bind(property)
|
||||
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
|
||||
}
|
||||
|
||||
fun EventTarget.jfxPasswordfield(property: ObservableValue<String>, op: TextField.() -> Unit = {}) = jfxPasswordfield().apply {
|
||||
fun EventTarget.jfxPasswordfield(property: ObservableValue<String>, op: JFXPasswordField.() -> Unit = {}) = jfxPasswordfield().apply {
|
||||
bind(property)
|
||||
op(this)
|
||||
}
|
||||
|
@ -1,41 +0,0 @@
|
||||
package net.mamoe.mirai.console.graphical.view
|
||||
|
||||
import com.jfoenix.controls.JFXAlert
|
||||
import com.jfoenix.controls.JFXPopup
|
||||
import javafx.beans.property.SimpleStringProperty
|
||||
import javafx.scene.control.Label
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import net.mamoe.mirai.console.graphical.controller.MiraiGraphicalUIController
|
||||
import net.mamoe.mirai.console.graphical.util.jfxButton
|
||||
import net.mamoe.mirai.console.graphical.util.jfxPasswordfield
|
||||
import net.mamoe.mirai.console.graphical.util.jfxTextfield
|
||||
import tornadofx.*
|
||||
|
||||
class LoginView : View() {
|
||||
|
||||
private val controller = find<MiraiGraphicalUIController>()
|
||||
private val qq = SimpleStringProperty("")
|
||||
private val psd = SimpleStringProperty("")
|
||||
|
||||
override val root = pane {
|
||||
form {
|
||||
fieldset("登录") {
|
||||
field("QQ") {
|
||||
jfxTextfield(qq)
|
||||
}
|
||||
field("密码") {
|
||||
jfxPasswordfield(psd)
|
||||
}
|
||||
}
|
||||
jfxButton("登录").action {
|
||||
runAsync {
|
||||
runBlocking {
|
||||
controller.login(qq.value, psd.value)
|
||||
}
|
||||
}.ui {
|
||||
// show dialog
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package net.mamoe.mirai.console.graphical.view
|
||||
|
||||
import javafx.beans.property.SimpleStringProperty
|
||||
import javafx.geometry.Pos
|
||||
import javafx.scene.image.Image
|
||||
import kotlinx.coroutines.runBlocking
|
||||
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.jfxPasswordfield
|
||||
import net.mamoe.mirai.console.graphical.util.jfxTextfield
|
||||
import tornadofx.*
|
||||
|
||||
class LoginView : View("CNM") {
|
||||
|
||||
private val controller = find<MiraiGraphicalUIController>()
|
||||
private val qq = SimpleStringProperty("")
|
||||
private val psd = SimpleStringProperty("")
|
||||
|
||||
override val root = borderpane {
|
||||
|
||||
addStylesheet(LoginViewStyleSheet::class)
|
||||
|
||||
center = vbox {
|
||||
|
||||
imageview(Image(LoginView::class.java.classLoader.getResourceAsStream("character.png"))) {
|
||||
alignment = Pos.CENTER
|
||||
}
|
||||
|
||||
jfxTextfield(qq) {
|
||||
promptText = "QQ"
|
||||
isLabelFloat = true
|
||||
}
|
||||
|
||||
jfxPasswordfield(psd) {
|
||||
promptText = "Password"
|
||||
isLabelFloat = true
|
||||
}
|
||||
|
||||
jfxButton("Login").action {
|
||||
runAsync {
|
||||
runBlocking { controller.login(qq.value, psd.value) }
|
||||
}.ui {
|
||||
qq.value = ""
|
||||
psd.value = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
BIN
mirai-console-graphical/src/main/resources/character.png
Normal file
BIN
mirai-console-graphical/src/main/resources/character.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
Loading…
Reference in New Issue
Block a user