mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-10 20:20:08 +08:00
f*ck JFoenix
This commit is contained in:
parent
24eaa15c0d
commit
8985c20c0c
@ -0,0 +1,28 @@
|
||||
package net.mamoe.mirai.console.graphical.util
|
||||
|
||||
import com.jfoenix.controls.JFXButton
|
||||
import com.jfoenix.controls.JFXListView
|
||||
import com.jfoenix.controls.JFXTabPane
|
||||
import javafx.collections.ObservableList
|
||||
import javafx.event.EventTarget
|
||||
import javafx.scene.Node
|
||||
import javafx.scene.control.Button
|
||||
import javafx.scene.control.ListView
|
||||
import javafx.scene.control.TabPane
|
||||
import tornadofx.SortedFilteredList
|
||||
import tornadofx.attachTo
|
||||
|
||||
internal fun EventTarget.jfxTabPane(op: TabPane.() -> Unit = {}) = JFXTabPane().attachTo(this, op)
|
||||
|
||||
internal fun EventTarget.jfxButton(text: String = "", graphic: Node? = null, op: Button.() -> Unit = {}) =
|
||||
JFXButton(text).attachTo(this, op) {
|
||||
if (graphic != null) it.graphic = graphic
|
||||
}
|
||||
|
||||
internal fun <T> EventTarget.jfxListView(values: ObservableList<T>? = null, op: ListView<T>.() -> Unit = {}) =
|
||||
JFXListView<T>().attachTo(this, op) {
|
||||
if (values != null) {
|
||||
if (values is SortedFilteredList<T>) values.bindTo(it)
|
||||
else it.items = values
|
||||
}
|
||||
}
|
@ -1,9 +1,15 @@
|
||||
package net.mamoe.mirai.console.graphical.view
|
||||
|
||||
import com.jfoenix.controls.JFXListCell
|
||||
import javafx.scene.control.TabPane
|
||||
import javafx.stage.Modality
|
||||
import javafx.scene.image.Image
|
||||
import net.mamoe.mirai.console.graphical.controller.MiraiGraphicalUIController
|
||||
import net.mamoe.mirai.console.graphical.model.BotModel
|
||||
import net.mamoe.mirai.console.graphical.util.jfxButton
|
||||
import net.mamoe.mirai.console.graphical.util.jfxListView
|
||||
import net.mamoe.mirai.console.graphical.util.jfxTabPane
|
||||
import tornadofx.*
|
||||
import java.io.FileInputStream
|
||||
|
||||
class PrimaryView : View() {
|
||||
|
||||
@ -11,45 +17,65 @@ class PrimaryView : View() {
|
||||
|
||||
override val root = borderpane {
|
||||
|
||||
top = menubar {
|
||||
menu("机器人") {
|
||||
item("登录").action {
|
||||
find<LoginFragment>().openModal(
|
||||
modality = Modality.APPLICATION_MODAL,
|
||||
resizable = false
|
||||
)
|
||||
prefWidth = 1000.0
|
||||
prefHeight = 650.0
|
||||
|
||||
left = vbox {
|
||||
|
||||
imageview(Image(FileInputStream("logo.png")))
|
||||
|
||||
// bot list
|
||||
jfxListView(controller.botList) {
|
||||
fitToParentSize()
|
||||
// prefHeight = 100.0
|
||||
setCellFactory {
|
||||
object : JFXListCell<BotModel>() {
|
||||
init {
|
||||
onDoubleClick {
|
||||
(center as TabPane).tab(item.uin.toString()) {
|
||||
listview(item.logHistory)
|
||||
select()
|
||||
onDoubleClick { close() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun updateItem(item: BotModel?, empty: Boolean) {
|
||||
super.updateItem(item, empty)
|
||||
if (item != null && !empty) {
|
||||
graphic = null
|
||||
text = item.uin.toString()
|
||||
} else {
|
||||
graphic = null
|
||||
text = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gridpane {
|
||||
row {
|
||||
jfxButton("登录")
|
||||
jfxButton("插件")
|
||||
jfxButton("设置")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
left = listview(controller.botList) {
|
||||
fitToParentHeight()
|
||||
center = jfxTabPane {
|
||||
tab("Main") {
|
||||
listview(controller.mainLog) {
|
||||
|
||||
cellFormat {
|
||||
|
||||
graphic = vbox {
|
||||
label(it.uin.toString())
|
||||
// label(stringBinding(it.botProperty) { if (value != null) value.nick else "登陆中" })
|
||||
}
|
||||
|
||||
onDoubleClick {
|
||||
(center as TabPane).tab(it.uin.toString()) {
|
||||
listview(it.logHistory)
|
||||
|
||||
isClosable = true
|
||||
select()
|
||||
fitToParentSize()
|
||||
cellFormat {
|
||||
graphic = label(it) {
|
||||
maxWidthProperty().bind(this@listview.widthProperty())
|
||||
isWrapText = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
center = tabpane {
|
||||
tab("Main") {
|
||||
listview(controller.mainLog)
|
||||
|
||||
isClosable = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user