From 03270389f8045d3d6f4daeea4b3659dc2026255a Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Thu, 17 Jan 2019 17:49:41 +0300 Subject: [PATCH] IDEA-198348: remove obsolete ScrollPainter and corresponding registry keys --- .../intellij/ui/components/JBScrollPane.java | 14 +- .../intellij/ui/components/ScrollPainter.java | 275 ------------------ .../util/resources/misc/registry.properties | 66 ----- 3 files changed, 1 insertion(+), 354 deletions(-) delete mode 100644 platform/platform-api/src/com/intellij/ui/components/ScrollPainter.java diff --git a/platform/platform-api/src/com/intellij/ui/components/JBScrollPane.java b/platform/platform-api/src/com/intellij/ui/components/JBScrollPane.java index 2b48c88017fd..f6459e2b2efc 100644 --- a/platform/platform-api/src/com/intellij/ui/components/JBScrollPane.java +++ b/platform/platform-api/src/com/intellij/ui/components/JBScrollPane.java @@ -38,24 +38,12 @@ public class JBScrollPane extends JScrollPane { * If a client property is set to {@code true} the bar's brightness * will be modified according to the view's background. * - * @see UIUtil#putClientProperty + * @see UIUtil#putClientProperty(JComponent, Key, Object) * @see UIUtil#isUnderDarcula */ @Deprecated public static final Key BRIGHTNESS_FROM_VIEW = Key.create("JB_SCROLL_PANE_BRIGHTNESS_FROM_VIEW"); - @Deprecated - public static final RegionPainter THUMB_PAINTER = ScrollPainter.EditorThumb.DEFAULT; - - @Deprecated - public static final RegionPainter THUMB_DARK_PAINTER = ScrollPainter.EditorThumb.DARCULA; - - @Deprecated - public static final RegionPainter MAC_THUMB_PAINTER = ScrollPainter.EditorThumb.Mac.DEFAULT; - - @Deprecated - public static final RegionPainter MAC_THUMB_DARK_PAINTER = ScrollPainter.EditorThumb.Mac.DARCULA; - /** * Supposed to be used as a client property key for scrollbar and indicates if this scrollbar should be ignored * when insets for {@code JScrollPane's} content are being calculated. diff --git a/platform/platform-api/src/com/intellij/ui/components/ScrollPainter.java b/platform/platform-api/src/com/intellij/ui/components/ScrollPainter.java deleted file mode 100644 index 6a7e5a20bd68..000000000000 --- a/platform/platform-api/src/com/intellij/ui/components/ScrollPainter.java +++ /dev/null @@ -1,275 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.ui.components; - -import com.intellij.openapi.util.SystemInfo; -import com.intellij.openapi.util.registry.Registry; -import com.intellij.ui.Gray; -import com.intellij.ui.JBColor; -import com.intellij.ui.paint.RectanglePainter; -import com.intellij.util.ui.JBUI; -import com.intellij.util.ui.RegionPainter; - -import java.awt.*; -import java.util.function.Function; -import java.util.function.IntSupplier; - -/** - * @author Sergey.Malenkov - */ -class ScrollPainter extends RegionPainter.Alpha { - private static final Color x0D = gray("mac.scroll.thumb.darcula.border", 0x0D); - private static final Color xA6 = gray("mac.scroll.thumb.darcula.fill", 0xA6); - - private static Color gray(String key, int defaultValue) { - return new JBColor(() -> { - int value = Registry.intValue(key, defaultValue); - return value <= 0 ? Gray._0 : value >= 255 ? Gray._255 : Gray.get(value); - }); - } - - private static IntSupplier value(String key, int defaultValue) { - return () -> { - int value = Registry.intValue(key, defaultValue); - return value <= 0 ? 0 : value >= 255 ? 255 : value; - }; - } - - static final class Thumb { - static final RegionPainter DARCULA = new ScrollPainter(0, .28f, .07f, Gray.xA6, Gray.x38); - static final RegionPainter DEFAULT = new ScrollPainter(0, .20f, .08f, Gray.x73, Gray.x59); - - static final class Mac { - static final RegionPainter DARCULA = new Round(1, .35f, .20f, Gray.x80, Gray.x26); - static final RegionPainter DEFAULT = new Round(2, .20f, .30f, Gray.x00, null); - - static final class Overlay { - static final RegionPainter DARCULA = new Round(1, 0f, .55f, Gray.x80, Gray.x26); - static final RegionPainter DEFAULT = new Round(2, 0f, .50f, Gray.x00, null); - } - } - } - - static final class EditorThumb { - private static final RegionPainter DARCULA_OLD = new ScrollPainter(0, .33f, .12f, Gray.xA6, Gray.x1A); - private static final RegionPainter DARCULA_NEW = new EditorThumbPainter( - 0, - value("win.editor.thumb.darcula.alpha.base", 89), - value("win.editor.thumb.darcula.alpha.delta", 166), - new ColorFunction( - value("win.editor.thumb.darcula.fill.min", 0x8C), - value("win.editor.thumb.darcula.fill.max", 0xA1)), - gray("win.editor.thumb.darcula.border", 0x1F)); - - private static final RegionPainter DEFAULT_OLD = new ScrollPainter(0, .25f, .15f, Gray.x80, Gray.x59); - private static final RegionPainter DEFAULT_NEW = new EditorThumbPainter( - 0, - value("win.editor.thumb.default.alpha.base", 140), - value("win.editor.thumb.default.alpha.delta", 115), - new ColorFunction( - value("win.editor.thumb.default.fill.min", 0x9E), - value("win.editor.thumb.default.fill.max", 0xBD)), - gray("win.editor.thumb.default.border", 0x8C)); - - static final RegionPainter DARCULA = new RegionPainter() { - @Override - public void paint(Graphics2D g, int x, int y, int width, int height, Float value) { - RegionPainter painter = Registry.is("ide.editor.thumb.experimental") ? DARCULA_NEW : DARCULA_OLD; - painter.paint(g, x, y, width, height, value); - } - }; - static final RegionPainter DEFAULT = new RegionPainter() { - @Override - public void paint(Graphics2D g, int x, int y, int width, int height, Float value) { - RegionPainter painter = Registry.is("ide.editor.thumb.experimental") ? DEFAULT_NEW : DEFAULT_OLD; - painter.paint(g, x, y, width, height, value); - } - }; - - static final class Mac { - private static final RegionPainter DARCULA_OLD = new Round(1, .35f, .20f, xA6, x0D); - private static final RegionPainter DARCULA_NEW = new EditorThumbPainter( - 1, - value("mac.editor.thumb.darcula.alpha.base", 102), - value("mac.editor.thumb.darcula.alpha.delta", 153), - new ColorFunction( - value("mac.editor.thumb.darcula.fill.min", 0x8C), - value("mac.editor.thumb.darcula.fill.max", 0xA1)), - gray("mac.editor.thumb.darcula.border", 0x1F)); - - private static final RegionPainter DEFAULT_OLD = Thumb.Mac.DEFAULT; - private static final RegionPainter DEFAULT_NEW = new EditorThumbPainter( - 2, - value("mac.editor.thumb.default.alpha.base", 102), - value("mac.editor.thumb.default.alpha.delta", 153), - new ColorFunction( - value("mac.editor.thumb.default.fill.min", 0x59), - value("mac.editor.thumb.default.fill.max", 0x73)), - null); - - static final RegionPainter DARCULA = new RegionPainter() { - @Override - public void paint(Graphics2D g, int x, int y, int width, int height, Float value) { - RegionPainter painter = Registry.is("ide.editor.thumb.experimental") ? DARCULA_NEW : DARCULA_OLD; - painter.paint(g, x, y, width, height, value); - } - }; - static final RegionPainter DEFAULT = new RegionPainter() { - @Override - public void paint(Graphics2D g, int x, int y, int width, int height, Float value) { - RegionPainter painter = Registry.is("ide.editor.thumb.experimental") ? DEFAULT_NEW : DEFAULT_OLD; - painter.paint(g, x, y, width, height, value); - } - }; - } - } - - private final int myOffset; - private final float myAlphaBase; - private final float myAlphaDelta; - private final Color myFillColor; - private final Color myDrawColor; - - private ScrollPainter(int offset, float base, float delta, Color fill, Color draw) { - myOffset = offset; - myAlphaBase = base; - myAlphaDelta = delta; - myFillColor = fill; - myDrawColor = draw; - } - - @Override - protected float getAlpha(Float value) { - return value != null ? myAlphaBase + myAlphaDelta * value : 0; - } - - @Override - protected void paint(Graphics2D g, int x, int y, int width, int height) { - if (myOffset > 0) { - x += myOffset; - y += myOffset; - width -= myOffset + myOffset; - height -= myOffset + myOffset; - } - if (width > 0 && height > 0) { - if (myFillColor != null) { - g.setColor(myFillColor); - fill(g, x, y, width, height, myDrawColor != null); - } - if (myDrawColor != null) { - g.setColor(myDrawColor); - draw(g, x, y, width, height); - } - } - } - - protected void fill(Graphics2D g, int x, int y, int width, int height, boolean border) { - if (border) { - g.fillRect(x + 1, y + 1, width - 2, height - 2); - } - else { - g.fillRect(x, y, width, height); - } - } - - protected void draw(Graphics2D g, int x, int y, int width, int height) { - RectanglePainter.DRAW.paint(g, x, y, width, height, null); - } - - private static class Round extends ScrollPainter { - private Round(int offset, float base, float delta, Color fill, Color draw) { - super(offset, base, delta, fill, draw); - } - - @Override - protected void fill(Graphics2D g, int x, int y, int width, int height, boolean border) { - RectanglePainter.FILL.paint(g, x, y, width, height, Math.min(width, height)); - } - - @Override - protected void draw(Graphics2D g, int x, int y, int width, int height) { - RectanglePainter.DRAW.paint(g, x, y, width, height, Math.min(width, height)); - } - } - - private static final class ColorFunction implements Function { - private final IntSupplier myMinSupplier; - private final IntSupplier myMaxSupplier; - - private ColorFunction(IntSupplier min, IntSupplier max) { - myMinSupplier = min; - myMaxSupplier = max; - } - - @Override - public Color apply(Float value) { - int min = myMinSupplier.getAsInt(); - if (value != null) { - int max = myMaxSupplier.getAsInt(); - if (max != min) min += (int)(0.5 + value * (max - min)); - } - //noinspection UseJBColor - return new Color(min, min, min); - } - } - - private static final class EditorThumbPainter extends RegionPainter.Alpha { - private final int myOffset; - private final IntSupplier myAlphaBase; - private final IntSupplier myAlphaDelta; - private final Function myFillFunction; - private final Color myDrawColor; - private Color myFillColor; - - private EditorThumbPainter(int offset, IntSupplier base, IntSupplier delta, Function fill, Color draw) { - myOffset = offset; - myAlphaBase = base; - myAlphaDelta = delta; - myFillFunction = fill; - myDrawColor = draw; - } - - private float getAlpha(int width, int height) { - if (width == height) return myAlphaBase.getAsInt() + myAlphaDelta.getAsInt(); - - int size = Math.abs(width - height); - float threshold = JBUI.scale(500f); - if (threshold <= size) return myAlphaBase.getAsInt(); - - float function = 1 - size / threshold; - return myAlphaBase.getAsInt() + myAlphaDelta.getAsInt() * function * function; - } - - @Override - public void paint(Graphics2D g, int x, int y, int width, int height, Float value) { - if (myOffset > 0) { - x += myOffset; - y += myOffset; - width -= myOffset + myOffset; - height -= myOffset + myOffset; - } - if (width > 0 && height > 0) { - myFillColor = myFillFunction.apply(value); - super.paint(g, x, y, width, height, getAlpha(width, height) / 255); - } - } - - @Override - protected void paint(Graphics2D g, int x, int y, int width, int height) { - RectanglePainter.paint(g, x, y, width, height, SystemInfo.isMac ? Math.min(width, height) : 0, myFillColor, myDrawColor); - } - } -} diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index 211a6ec9f509..bd93cef109e5 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -159,72 +159,6 @@ 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.editor.thumb.experimental=true -ide.editor.thumb.experimental.description=Another approach to paint editor's scroll thumb. - -mac.editor.thumb.darcula.border=33 -mac.editor.thumb.darcula.border.description=Allows to tune an experimental thumb border in the editor component. - -mac.editor.thumb.darcula.fill.min=133 -mac.editor.thumb.darcula.fill.min.description=Allows to tune an experimental thumb color in the editor component. - -mac.editor.thumb.darcula.fill.max=150 -mac.editor.thumb.darcula.fill.max.description=Allows to tune an experimental thumb color in the editor component. - -mac.editor.thumb.darcula.alpha.base=128 -mac.editor.thumb.darcula.alpha.base.description=Allows to tune an experimental thumb color in the editor component. - -mac.editor.thumb.darcula.alpha.delta=127 -mac.editor.thumb.darcula.alpha.delta.description=Allows to tune an experimental thumb color in the editor component. - -mac.editor.thumb.default.fill.min=90 -mac.editor.thumb.default.fill.min.description=Allows to tune an experimental thumb color in the editor component. - -mac.editor.thumb.default.fill.max=50 -mac.editor.thumb.default.fill.max.description=Allows to tune an experimental thumb color in the editor component. - -mac.editor.thumb.default.alpha.base=75 -mac.editor.thumb.default.alpha.base.description=Allows to tune an experimental thumb color in the editor component. - -mac.editor.thumb.default.alpha.delta=120 -mac.editor.thumb.default.alpha.delta.description=Allows to tune an experimental thumb color in the editor component. - -win.editor.thumb.darcula.border=33 -win.editor.thumb.darcula.border.description=Allows to tune an experimental thumb border in the editor component. - -win.editor.thumb.darcula.fill.min=133 -win.editor.thumb.darcula.fill.min.description=Allows to tune an experimental thumb color in the editor component. - -win.editor.thumb.darcula.fill.max=150 -win.editor.thumb.darcula.fill.max.description=Allows to tune an experimental thumb color in the editor component. - -win.editor.thumb.darcula.alpha.base=128 -win.editor.thumb.darcula.alpha.base.description=Allows to tune an experimental thumb color in the editor component. - -win.editor.thumb.darcula.alpha.delta=127 -win.editor.thumb.darcula.alpha.delta.description=Allows to tune an experimental thumb color in the editor component. - -win.editor.thumb.default.border=152 -win.editor.thumb.default.border.description=Allows to tune an experimental thumb border in the editor component. - -win.editor.thumb.default.fill.min=193 -win.editor.thumb.default.fill.min.description=Allows to tune an experimental thumb color in the editor component. - -win.editor.thumb.default.fill.max=163 -win.editor.thumb.default.fill.max.description=Allows to tune an experimental thumb color in the editor component. - -win.editor.thumb.default.alpha.base=120 -win.editor.thumb.default.alpha.base.description=Allows to tune an experimental thumb color in the editor component. - -win.editor.thumb.default.alpha.delta=135 -win.editor.thumb.default.alpha.delta.description=Allows to tune an experimental thumb color in the editor component. - -mac.scroll.thumb.darcula.fill=166 -mac.scroll.thumb.darcula.fill.description=Allows to tune a thumb color in the editor component. - -mac.scroll.thumb.darcula.border=13 -mac.scroll.thumb.darcula.border.description=Allows to tune a thumb border in the editor component. - mac.scroll.horizontal.gap=false mac.scroll.horizontal.gap.description=Shows additional space after the last row of a list or a tree. Affect MacOS only.