From 0504ee2f4a855326159a1bbd131c7ec998d7d24c Mon Sep 17 00:00:00 2001 From: Yuriy Artamonov Date: Mon, 17 Aug 2020 12:59:54 +0300 Subject: [PATCH] UI: alternative background color for lists with tall rows GitOrigin-RevId: bb61dda8f22c12d9eddc4717d0169636245a1f5b --- .../IntelliJPlatform.themeMetadata.json | 4 ++++ .../ui}/src/com/intellij/util/ui/ListUiUtil.kt | 17 ++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) rename platform/{vcs-impl => util/ui}/src/com/intellij/util/ui/ListUiUtil.kt (63%) diff --git a/platform/platform-resources/src/themes/metadata/IntelliJPlatform.themeMetadata.json b/platform/platform-resources/src/themes/metadata/IntelliJPlatform.themeMetadata.json index 99f98858ef5b..1cfd88d280a7 100644 --- a/platform/platform-resources/src/themes/metadata/IntelliJPlatform.themeMetadata.json +++ b/platform/platform-resources/src/themes/metadata/IntelliJPlatform.themeMetadata.json @@ -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" }, diff --git a/platform/vcs-impl/src/com/intellij/util/ui/ListUiUtil.kt b/platform/util/ui/src/com/intellij/util/ui/ListUiUtil.kt similarity index 63% rename from platform/vcs-impl/src/com/intellij/util/ui/ListUiUtil.kt rename to platform/util/ui/src/com/intellij/util/ui/ListUiUtil.kt index 71c8893caa53..504b933c46ad 100644 --- a/platform/vcs-impl/src/com/intellij/util/ui/ListUiUtil.kt +++ b/platform/util/ui/src/com/intellij/util/ui/ListUiUtil.kt @@ -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) + } + } } } \ No newline at end of file