mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-23 22:00:10 +08:00
Real closable tab
This commit is contained in:
parent
6aa8f6a75b
commit
1b60a1b499
@ -1,9 +1,8 @@
|
||||
package net.mamoe.mirai.console.graphical.styleSheet
|
||||
|
||||
import tornadofx.box
|
||||
import tornadofx.c
|
||||
import tornadofx.cssclass
|
||||
import tornadofx.px
|
||||
import javafx.scene.Cursor
|
||||
import javafx.scene.paint.Color
|
||||
import tornadofx.*
|
||||
|
||||
class PrimaryStyleSheet : BaseStyleSheet() {
|
||||
companion object {
|
||||
@ -12,7 +11,8 @@ class PrimaryStyleSheet : BaseStyleSheet() {
|
||||
val container by cssclass("jfx-decorator-content-container")
|
||||
|
||||
// tab
|
||||
val tabPane by cssclass("tab-header-background")
|
||||
val jfxTabPane by cssclass("tab-header-background")
|
||||
val closeButton by cssclass("tab-close-button")
|
||||
}
|
||||
|
||||
init {
|
||||
@ -32,8 +32,20 @@ class PrimaryStyleSheet : BaseStyleSheet() {
|
||||
/*
|
||||
* tab pane
|
||||
*/
|
||||
tabPane {
|
||||
jfxTabPane {
|
||||
backgroundColor += c(primaryColor)
|
||||
}
|
||||
|
||||
// 去除JFoenix默认样式
|
||||
tab {
|
||||
and(":closable") {
|
||||
borderWidth += box(0.px)
|
||||
borderInsets += box(6.px, 0.px)
|
||||
}
|
||||
|
||||
closeButton {
|
||||
and(hover) { cursor = Cursor.HAND }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -8,12 +8,11 @@ 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
|
||||
import tornadofx.bind
|
||||
|
||||
internal fun EventTarget.jfxTabPane(op: TabPane.() -> Unit = {}) = JFXTabPane().attachTo(this, op)
|
||||
internal fun EventTarget.jfxTabPane(op: JFXTabPane.() -> Unit = {}) = JFXTabPane().attachTo(this, op)
|
||||
|
||||
internal fun EventTarget.jfxButton(text: String = "", graphic: Node? = null, op: Button.() -> Unit = {}) =
|
||||
JFXButton(text).attachTo(this, op) {
|
||||
|
@ -72,13 +72,15 @@ class PrimaryView : View() {
|
||||
|
||||
center = jfxTabPane {
|
||||
|
||||
tabClosingPolicy = TabPane.TabClosingPolicy.ALL_TABS
|
||||
|
||||
logTab("Main", controller.mainLog, closeable = false)
|
||||
|
||||
tab("Plugins").content = find<PluginsView>().root
|
||||
tab("Plugins").apply { isClosable = false }.content = find<PluginsView>().root
|
||||
|
||||
tab("Settings").content = find<SettingsView>().root
|
||||
tab("Settings").apply { isClosable = false }.content = find<SettingsView>().root
|
||||
|
||||
tab("Login").content = find<LoginView>().root
|
||||
tab("Login").apply { isClosable = false }.content = find<LoginView>().root
|
||||
|
||||
mainTabPane = this
|
||||
}
|
||||
@ -97,6 +99,8 @@ private fun TabPane.logTab(
|
||||
op: Tab.() -> Unit = {}
|
||||
) = tab(text) {
|
||||
|
||||
this.isClosable = closeable
|
||||
|
||||
vbox {
|
||||
buttonbar {
|
||||
|
||||
@ -119,8 +123,6 @@ private fun TabPane.logTab(
|
||||
}.ui {// isSucceed: Boolean ->
|
||||
// notify something
|
||||
}
|
||||
|
||||
if (closeable) button("关闭").action { close() }
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user