mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-11 04:40:10 +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
|
package net.mamoe.mirai.console.graphical.view
|
||||||
|
|
||||||
|
import com.jfoenix.controls.JFXListCell
|
||||||
import javafx.scene.control.TabPane
|
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.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 tornadofx.*
|
||||||
|
import java.io.FileInputStream
|
||||||
|
|
||||||
class PrimaryView : View() {
|
class PrimaryView : View() {
|
||||||
|
|
||||||
@ -11,45 +17,65 @@ class PrimaryView : View() {
|
|||||||
|
|
||||||
override val root = borderpane {
|
override val root = borderpane {
|
||||||
|
|
||||||
top = menubar {
|
prefWidth = 1000.0
|
||||||
menu("机器人") {
|
prefHeight = 650.0
|
||||||
item("登录").action {
|
|
||||||
find<LoginFragment>().openModal(
|
|
||||||
modality = Modality.APPLICATION_MODAL,
|
|
||||||
resizable = false
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
left = listview(controller.botList) {
|
left = vbox {
|
||||||
fitToParentHeight()
|
|
||||||
|
|
||||||
cellFormat {
|
imageview(Image(FileInputStream("logo.png")))
|
||||||
|
|
||||||
graphic = vbox {
|
|
||||||
label(it.uin.toString())
|
|
||||||
// label(stringBinding(it.botProperty) { if (value != null) value.nick else "登陆中" })
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// bot list
|
||||||
|
jfxListView(controller.botList) {
|
||||||
|
fitToParentSize()
|
||||||
|
// prefHeight = 100.0
|
||||||
|
setCellFactory {
|
||||||
|
object : JFXListCell<BotModel>() {
|
||||||
|
init {
|
||||||
onDoubleClick {
|
onDoubleClick {
|
||||||
(center as TabPane).tab(it.uin.toString()) {
|
(center as TabPane).tab(item.uin.toString()) {
|
||||||
listview(it.logHistory)
|
listview(item.logHistory)
|
||||||
|
|
||||||
isClosable = true
|
|
||||||
select()
|
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 = ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
center = tabpane {
|
gridpane {
|
||||||
|
row {
|
||||||
|
jfxButton("登录")
|
||||||
|
jfxButton("插件")
|
||||||
|
jfxButton("设置")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
center = jfxTabPane {
|
||||||
tab("Main") {
|
tab("Main") {
|
||||||
listview(controller.mainLog)
|
listview(controller.mainLog) {
|
||||||
|
|
||||||
isClosable = false
|
fitToParentSize()
|
||||||
|
cellFormat {
|
||||||
|
graphic = label(it) {
|
||||||
|
maxWidthProperty().bind(this@listview.widthProperty())
|
||||||
|
isWrapText = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user