Skip to content
This repository has been archived by the owner on Apr 12, 2023. It is now read-only.

Commit

Permalink
Fix context menu style (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewinci authored Nov 4, 2020
1 parent de18cdb commit 61ec2be
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
3 changes: 3 additions & 0 deletions app/src/main/kotlin/insulator/ui/common/InsulatorView.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package insulator.ui.common

import insulator.ui.style.Root
import insulator.viewmodel.common.InsulatorViewModel
import javafx.scene.control.Alert
import tornadofx.View
import tornadofx.addClass
import tornadofx.alert
import tornadofx.onChange

Expand All @@ -13,6 +15,7 @@ abstract class InsulatorView(title: String? = null) : View(title) {
open fun onError(throwable: Throwable) {}

override fun onDock() {
root.addClass(Root.insulatorView)
val handleError: (Throwable?) -> Unit = {
if (it != null) {
alert(Alert.AlertType.WARNING, it.message ?: it.toString())
Expand Down
35 changes: 23 additions & 12 deletions app/src/main/kotlin/insulator/ui/style/Root.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,39 @@ import tornadofx.Dimension
import tornadofx.Stylesheet
import tornadofx.box
import tornadofx.c
import tornadofx.cssclass
import tornadofx.em
import tornadofx.multi
import tornadofx.px

class Root : Stylesheet() {
companion object {
val insulatorView by cssclass("insulator-view")
}

init {
root {
font = Font.font("Helvetica", 10.0)
backgroundColor = multi(theme.backgroundColor)
}

insulatorView {
padding = box(theme.viewPadding)
contextMenu {
padding = box(0.px)
minWidth = 100.0.px
textFill = theme.black
menuItem {
padding = box(10.0.px)
and(focused) {
backgroundColor = multi(theme.mainColor)
label {
textFill = theme.backgroundColor
textFill = theme.backgroundColor
}
}

contextMenu {
padding = box(0.px)
minWidth = 100.0.px
backgroundColor = multi(theme.backgroundColor.brighter())
menuItem {
padding = box(10.0.px)
label {
textFill = theme.black
}
and(focused) {
backgroundColor = multi(theme.mainColor)
label {
textFill = theme.backgroundColor
}
}
}
Expand Down

0 comments on commit 61ec2be

Please sign in to comment.