UI: alternative background color for lists with tall rows

GitOrigin-RevId: bb61dda8f22c12d9eddc4717d0169636245a1f5b
This commit is contained in:
Yuriy Artamonov
2020-08-18 19:55:19 +00:00
committed by intellij-monorepo-bot
parent 454fd852c1
commit 0504ee2f4a
2 changed files with 18 additions and 3 deletions
@@ -669,6 +669,10 @@
{
"key": "Table.lightSelectionInactiveForeground"
},
{
"key": "Table.alternativeRowBackground",
"description": "Contrast background color for lists with tall rows, e.g. View | Tool Windows | Endpoints"
},
{
"key": "Table.stripeColor"
},
@@ -1,4 +1,4 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.util.ui
import com.intellij.ui.JBColor
@@ -7,8 +7,9 @@ import javax.swing.JList
object ListUiUtil {
object WithTallRow {
private val selectionBackground = JBColor(0xE9EEF5, 0x464A4D)
private val unfocusedSelectionBackground = JBColor(0xF5F5F5, 0x464A4D)
private val selectionBackground: JBColor = JBColor(0xE9EEF5, 0x464A4D)
private val unfocusedSelectionBackground: JBColor = JBColor(0xF5F5F5, 0x464A4D)
private val alternativeRowBackground: JBColor = JBColor(0xFFFFFF, 0x313335)
fun foreground(isSelected: Boolean, hasFocus: Boolean): Color {
val default = UIUtil.getListForeground()
@@ -33,5 +34,15 @@ object ListUiUtil {
}
else list.background
}
fun alternativeBackground(isSelected: Boolean, hasFocus: Boolean): Color {
return if (isSelected) {
if (hasFocus) JBColor.namedColor("Table.lightSelectionBackground", selectionBackground)
else JBColor.namedColor("Table.lightSelectionInactiveBackground", unfocusedSelectionBackground)
}
else {
JBColor.namedColor("Table.alternativeRowBackground", alternativeRowBackground)
}
}
}
}