From c457dc1f613840f9d2a981ad42cbf669f3a91e59 Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Mon, 27 Nov 2017 20:03:16 +0300 Subject: [PATCH] add ability to tune a track color on hover --- .../intellij/ui/components/ScrollPainter.java | 18 ++++++++++++++++-- .../util/resources/misc/registry.properties | 12 ++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/platform/platform-api/src/com/intellij/ui/components/ScrollPainter.java b/platform/platform-api/src/com/intellij/ui/components/ScrollPainter.java index 81fb6bdb7381..cf53f6e28779 100644 --- a/platform/platform-api/src/com/intellij/ui/components/ScrollPainter.java +++ b/platform/platform-api/src/com/intellij/ui/components/ScrollPainter.java @@ -50,8 +50,8 @@ class ScrollPainter extends RegionPainter.Alpha { } static final class Track { - static final RegionPainter DARCULA = new ScrollPainter(0, .0f, .1f, Gray.x80, null); - static final RegionPainter DEFAULT = DARCULA; + static final RegionPainter DARCULA = new TrackPainter("ide.scroll.track.darcula.alpha", "ide.scroll.track.darcula.fill"); + static final RegionPainter DEFAULT = new TrackPainter("ide.scroll.track.default.alpha", "ide.scroll.track.default.fill"); } static final class Thumb { @@ -377,4 +377,18 @@ class ScrollPainter extends RegionPainter.Alpha { RectanglePainter.paint(g, x, y, width, height, SystemInfo.isMac ? Math.min(width, height) : 0, myFillColor, myDrawColor); } } + + private static class TrackPainter extends ScrollPainter { + private final IntSupplier supplier; + + private TrackPainter(String alpha, String fill) { + super(0, 0, 0, gray(fill, 0x80), null); + supplier = value(alpha, 26); + } + + @Override + protected float getAlpha(Float value) { + return value == null ? 0 : value * supplier.getAsInt() / 255; + } + } } diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index d5b13cd183fd..eb8a92d76dd8 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -149,6 +149,18 @@ ide.scroll.layout.header.over.corner.description=Expand a scroll pane header if ide.scroll.thumb.small.if.opaque=false ide.scroll.thumb.small.if.opaque.description=Allows to tune an opaque thumb thickness. Affects Windows and Linux only. +ide.scroll.track.darcula.alpha=26 +ide.scroll.track.darcula.alpha.description=Allows to tune a track color on hover. + +ide.scroll.track.darcula.fill=128 +ide.scroll.track.darcula.fill.description=Allows to tune a track color on hover. + +ide.scroll.track.default.alpha=26 +ide.scroll.track.default.alpha.description=Allows to tune a track color on hover. + +ide.scroll.track.default.fill=128 +ide.scroll.track.default.fill.description=Allows to tune a track color on hover. + ide.editor.thumb.experimental=true ide.editor.thumb.experimental.description=Another approach to paint editor's scroll thumb.