mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-24 23:20:09 +08:00
Play with css
This commit is contained in:
parent
82d48ca175
commit
af05bc517f
@ -1,8 +1,14 @@
|
||||
package net.mamoe.mirai.console.graphical.styleSheet
|
||||
|
||||
import tornadofx.Stylesheet
|
||||
import tornadofx.c
|
||||
import javafx.scene.layout.BackgroundPosition
|
||||
import javafx.scene.layout.BackgroundRepeat
|
||||
import javafx.scene.layout.BackgroundSize
|
||||
import javafx.scene.paint.Color
|
||||
import net.mamoe.mirai.console.MiraiConsole
|
||||
import tornadofx.*
|
||||
import java.io.File
|
||||
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
open class BaseStyleSheet : Stylesheet() {
|
||||
|
||||
companion object {
|
||||
@ -10,6 +16,40 @@ open class BaseStyleSheet : Stylesheet() {
|
||||
const val stressColor = "35867C"
|
||||
const val secondaryColor = "32CABA"
|
||||
const val lightColor ="9FD1CC"
|
||||
const val FontColor = "FFFFFF"
|
||||
const val fontColor = "FFFFFF"
|
||||
val TRANSPARENT: Color = Color.TRANSPARENT
|
||||
|
||||
val rootPane by cssclass("root-pane")
|
||||
val jfxTabPane by cssclass("jfx-tab-pane")
|
||||
val myButtonBar by cssclass("my-button-bar")
|
||||
|
||||
val vbox by csselement("VBox")
|
||||
}
|
||||
|
||||
init {
|
||||
|
||||
rootPane {
|
||||
|
||||
child(imageView) {}
|
||||
|
||||
|
||||
jfxTabPane {
|
||||
val bg = File(MiraiConsole.path, "background")
|
||||
if (bg.exists() && bg.isDirectory) {
|
||||
bg.listFiles()!!.randomOrNull()?.also {
|
||||
backgroundImage += it.toURI()
|
||||
backgroundRepeat += BackgroundRepeat.REPEAT to BackgroundRepeat.REPEAT
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
listView {
|
||||
backgroundColor += TRANSPARENT
|
||||
|
||||
listCell {
|
||||
backgroundColor += TRANSPARENT
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package net.mamoe.mirai.console.graphical.styleSheet
|
||||
|
||||
import javafx.geometry.Pos
|
||||
import javafx.scene.paint.Color
|
||||
import javafx.scene.text.FontWeight
|
||||
import tornadofx.box
|
||||
import tornadofx.c
|
||||
import tornadofx.cssclass
|
||||
import tornadofx.px
|
||||
|
||||
class PluginViewStyleSheet : BaseStyleSheet() {
|
||||
|
||||
companion object {
|
||||
val jfxTreeTableView by cssclass("jfx-tree-table-view")
|
||||
val treeTableRowCell by cssclass("tree-table-row-cell")
|
||||
val columnHeader by cssclass("column-header")
|
||||
val columnHeaderBg by cssclass("column-header-background")
|
||||
}
|
||||
|
||||
|
||||
init {
|
||||
jfxTreeTableView {
|
||||
backgroundColor += TRANSPARENT
|
||||
|
||||
columnHeader {
|
||||
borderWidth += box(0.px)
|
||||
|
||||
label {
|
||||
textFill = Color.BLACK
|
||||
}
|
||||
}
|
||||
|
||||
columnHeaderBg {
|
||||
backgroundColor += c(lightColor, 0.4)
|
||||
}
|
||||
|
||||
treeTableCell {
|
||||
alignment = Pos.CENTER
|
||||
}
|
||||
|
||||
treeTableRowCell {
|
||||
|
||||
fontWeight = FontWeight.SEMI_BOLD
|
||||
|
||||
|
||||
backgroundColor += TRANSPARENT
|
||||
|
||||
and(":selected") {
|
||||
backgroundColor += c(stressColor, 1.0)
|
||||
}
|
||||
|
||||
and(":hover:filled") {
|
||||
backgroundColor += c(stressColor, 0.6)
|
||||
and(":selected") {
|
||||
backgroundColor += c(stressColor, 1.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,10 @@
|
||||
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 PrimaryStyleSheet : BaseStyleSheet() {
|
||||
@ -10,9 +13,14 @@ class PrimaryStyleSheet : BaseStyleSheet() {
|
||||
val jfxTitle by cssclass("jfx-decorator-buttons-container")
|
||||
val container by cssclass("jfx-decorator-content-container")
|
||||
|
||||
// tab
|
||||
val jfxTabPane by cssclass("tab-header-background")
|
||||
// jfx tab
|
||||
val jfxTabHeader by cssclass("tab-header-background")
|
||||
val closeButton by cssclass("tab-close-button")
|
||||
|
||||
// jfx list view
|
||||
val leftPane by cssclass("left-pane")
|
||||
val jfxListView by cssclass("jfx-list-view")
|
||||
val jfxListCell by cssclass("jfx-list-cell")
|
||||
}
|
||||
|
||||
init {
|
||||
@ -28,14 +36,105 @@ class PrimaryStyleSheet : BaseStyleSheet() {
|
||||
borderWidth += box(0.px, 4.px, 4.px, 4.px)
|
||||
}
|
||||
|
||||
/*
|
||||
* bot list
|
||||
*/
|
||||
rootPane {
|
||||
child(vbox) {
|
||||
|
||||
backgroundColor += c(primaryColor)
|
||||
// 这个padding有bug,十分神奇
|
||||
padding = box(0.px, 4.px, 0.px, 0.px)
|
||||
spacing = 4.px
|
||||
|
||||
jfxListView {
|
||||
|
||||
jfxListCell {
|
||||
backgroundColor += c(100, 100, 100, 0.4)
|
||||
backgroundRadius += box(5.px)
|
||||
|
||||
textFill = c(fontColor)
|
||||
fontWeight = FontWeight.BOLD
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
textField {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* tab pane
|
||||
*/
|
||||
jfxTabPane {
|
||||
jfxTabHeader {
|
||||
backgroundColor += c(primaryColor)
|
||||
}
|
||||
|
||||
jfxTabPane {
|
||||
|
||||
// 日志列表样式
|
||||
vbox {
|
||||
padding = box(15.px)
|
||||
spacing = 15.px
|
||||
}
|
||||
|
||||
myButtonBar {
|
||||
spacing = 15.px
|
||||
|
||||
button {
|
||||
backgroundColor += c(secondaryColor, 0.8)
|
||||
padding = box(2.px, 10.px)
|
||||
cursor = Cursor.HAND
|
||||
textFill = c(fontColor)
|
||||
fontSize = 12.px
|
||||
}
|
||||
}
|
||||
|
||||
listView {
|
||||
// 字体在label里,大坑
|
||||
label {
|
||||
fontSize = 13.px
|
||||
}
|
||||
|
||||
listCell {
|
||||
and(":selected") {
|
||||
backgroundColor += c(stressColor, 1.0)
|
||||
}
|
||||
|
||||
and(":hover:filled") {
|
||||
backgroundColor += c(stressColor, 0.6)
|
||||
and(":selected") {
|
||||
backgroundColor += c(stressColor, 1.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 调整滚动条
|
||||
scrollBar {
|
||||
|
||||
backgroundColor += TRANSPARENT
|
||||
|
||||
// 隐藏水平滚动条
|
||||
and(horizontal) {
|
||||
prefHeight = 0.px
|
||||
s(incrementArrow, decrementArrow) { backgroundColor += TRANSPARENT }
|
||||
}
|
||||
|
||||
and(vertical) {
|
||||
thumb {
|
||||
backgroundColor += c(stressColor, 0.6)
|
||||
}
|
||||
|
||||
track {
|
||||
backgroundColor += TRANSPARENT
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 去除JFoenix默认样式
|
||||
tab {
|
||||
and(":closable") {
|
||||
|
@ -3,8 +3,10 @@ package net.mamoe.mirai.console.graphical.view
|
||||
import com.jfoenix.controls.JFXTreeTableColumn
|
||||
import net.mamoe.mirai.console.graphical.controller.MiraiGraphicalUIController
|
||||
import net.mamoe.mirai.console.graphical.model.PluginModel
|
||||
import net.mamoe.mirai.console.graphical.styleSheet.PluginViewStyleSheet
|
||||
import net.mamoe.mirai.console.graphical.util.jfxTreeTableView
|
||||
import tornadofx.View
|
||||
import tornadofx.addStylesheet
|
||||
|
||||
class PluginsView : View() {
|
||||
|
||||
@ -12,6 +14,9 @@ class PluginsView : View() {
|
||||
val plugins = controller.pluginList
|
||||
|
||||
override val root = jfxTreeTableView(plugins) {
|
||||
|
||||
addStylesheet(PluginViewStyleSheet::class)
|
||||
|
||||
isShowRoot = false
|
||||
columns.addAll(
|
||||
JFXTreeTableColumn<PluginModel, String>("插件名").apply {
|
||||
|
@ -2,6 +2,7 @@ package net.mamoe.mirai.console.graphical.view
|
||||
|
||||
import com.jfoenix.controls.JFXListCell
|
||||
import javafx.collections.ObservableList
|
||||
import javafx.geometry.Insets
|
||||
import javafx.geometry.Pos
|
||||
import javafx.scene.control.Tab
|
||||
import javafx.scene.control.TabPane
|
||||
@ -24,15 +25,19 @@ class PrimaryView : View() {
|
||||
|
||||
override val root = borderpane {
|
||||
|
||||
addClass("root-pane")
|
||||
|
||||
left = vbox {
|
||||
|
||||
imageview(Image(PrimaryView::class.java.classLoader.getResourceAsStream("logo.png"))) {
|
||||
fitHeight = 40.0
|
||||
alignment = Pos.CENTER
|
||||
isPreserveRatio = true
|
||||
}
|
||||
|
||||
// bot list
|
||||
jfxListView(controller.botList) {
|
||||
fitToParentSize()
|
||||
fitToParentHeight()
|
||||
|
||||
setCellFactory {
|
||||
object : JFXListCell<BotModel>() {
|
||||
@ -40,7 +45,7 @@ class PrimaryView : View() {
|
||||
|
||||
init {
|
||||
onDoubleClick {
|
||||
tab?.select() ?: (center as TabPane).logTab(
|
||||
tab?.select() ?: (mainTabPane as TabPane).logTab(
|
||||
text = item.uin.toString(),
|
||||
logs = item.logHistory
|
||||
).select().also { tab = it }
|
||||
|
Loading…
Reference in New Issue
Block a user