mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
+glow ovals
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.ide.ui.laf;
|
||||
|
||||
import com.intellij.util.ui.MacUIUtil;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class DarculaUIUtil {
|
||||
public static final Color GLOW_COLOR = new Color(96, 175, 255);
|
||||
|
||||
public static void paintFocusRing(Graphics g, int x, int y, int width, int height) {
|
||||
MacUIUtil.paintFocusRing((Graphics2D)g, GLOW_COLOR, new Rectangle(x, y, width, height));
|
||||
}
|
||||
|
||||
public static void paintFocusOval(Graphics g, int x, int y, int width, int height) {
|
||||
MacUIUtil.paintFocusRing((Graphics2D)g, GLOW_COLOR, new Rectangle(x, y, width, height), true);
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,10 @@ public class MacUIUtil {
|
||||
}
|
||||
|
||||
public static void paintFocusRing(Graphics2D g2d, Color ringColor, Rectangle bounds) {
|
||||
paintFocusRing(g2d, ringColor, bounds, false);
|
||||
}
|
||||
|
||||
public static void paintFocusRing(Graphics2D g, Color ringColor, Rectangle bounds, boolean oval) {
|
||||
int correction = UIUtil.isUnderDarcula() ? 50 : 0;
|
||||
final Color[] colors = new Color[]{
|
||||
ColorUtil.toAlpha(ringColor, 180 - correction),
|
||||
@@ -54,34 +58,46 @@ public class MacUIUtil {
|
||||
ColorUtil.toAlpha(ringColor, 50 - correction)
|
||||
};
|
||||
|
||||
final Object oldAntialiasingValue = g2d.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
|
||||
final Object oldStrokeControlValue = g2d.getRenderingHint(RenderingHints.KEY_STROKE_CONTROL);
|
||||
final Object oldAntialiasingValue = g.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
|
||||
final Object oldStrokeControlValue = g.getRenderingHint(RenderingHints.KEY_STROKE_CONTROL);
|
||||
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
|
||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, !oval &&
|
||||
USE_QUARTZ ? RenderingHints.VALUE_STROKE_PURE : RenderingHints.VALUE_STROKE_NORMALIZE);
|
||||
|
||||
|
||||
final Rectangle r = new Rectangle(bounds.x - 3, bounds.y - 3, bounds.width + 6, bounds.height + 6);
|
||||
|
||||
g2d.setColor(colors[0]);
|
||||
g2d.drawRoundRect(r.x + 2, r.y + 2, r.width - 5, r.height - 5, 5, 5);
|
||||
g.setColor(colors[0]);
|
||||
drawRectOrOval(g, oval, 5, r.x + 2, r.y + 2, r.width - 5, r.height - 5);
|
||||
|
||||
g2d.setColor(colors[1]);
|
||||
g2d.drawRoundRect(r.x + 1, r.y + 1, r.width - 3, r.height - 3, 7, 7);
|
||||
g.setColor(colors[1]);
|
||||
drawRectOrOval(g, oval, 7, r.x + 1, r.y + 1, r.width - 3, r.height - 3);
|
||||
|
||||
g2d.setColor(colors[2]);
|
||||
g2d.drawRoundRect(r.x, r.y, r.width - 1, r.height - 1, 9, 9);
|
||||
g.setColor(colors[2]);
|
||||
drawRectOrOval(g, oval, 9, r.x, r.y, r.width - 1, r.height - 1);
|
||||
|
||||
g2d.setColor(colors[3]);
|
||||
g2d.drawRect(r.x + 3, r.y + 3, r.width - 7, r.height - 7);
|
||||
g.setColor(colors[3]);
|
||||
drawRectOrOval(g, oval, 0, r.x + 3, r.y + 3, r.width - 7, r.height - 7);
|
||||
|
||||
g2d.setColor(colors[4]);
|
||||
g2d.drawRect(r.x + 4, r.y + 4, r.width - 9, r.height - 9);
|
||||
g.setColor(colors[4]);
|
||||
drawRectOrOval(g, oval, 0, r.x + 4, r.y + 4, r.width - 9, r.height - 9);
|
||||
|
||||
// restore rendering hints
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, oldAntialiasingValue);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, oldStrokeControlValue);
|
||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, oldAntialiasingValue);
|
||||
g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, oldStrokeControlValue);
|
||||
}
|
||||
|
||||
private static void drawRectOrOval(Graphics2D g, boolean oval, int arc, int x, int y, int width, int height) {
|
||||
if (oval) {
|
||||
g.drawOval(x, y, width, height);
|
||||
} else {
|
||||
if (arc == 0) {
|
||||
g.drawRect(x, y, width, height);
|
||||
} else {
|
||||
g.drawRoundRect(x, y, width, height, arc, arc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void hideCursor() {
|
||||
|
||||
Reference in New Issue
Block a user