mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
use UIResource insets
(cherry-picked from 090d915)
This commit is contained in:
+3
-2
@@ -16,11 +16,11 @@
|
||||
package com.intellij.ide.ui.laf.darcula.ui;
|
||||
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.plaf.InsetsUIResource;
|
||||
import javax.swing.plaf.UIResource;
|
||||
import java.awt.*;
|
||||
|
||||
@@ -34,7 +34,8 @@ public class DarculaCheckBoxBorder implements Border, UIResource {
|
||||
|
||||
@Override
|
||||
public Insets getBorderInsets(Component c) {
|
||||
return SystemInfo.isMac || UIUtil.getParentOfType(CellRendererPane.class, c) != null ? JBInsets.NONE : new Insets(2,2,2,2);
|
||||
final int a = SystemInfo.isMac || UIUtil.getParentOfType(CellRendererPane.class, c) != null ? 0 : 2;
|
||||
return new InsetsUIResource(a, a, a, a);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-1
@@ -24,6 +24,7 @@ import sun.swing.SwingUtilities2;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.plaf.IconUIResource;
|
||||
import javax.swing.plaf.basic.BasicHTML;
|
||||
import javax.swing.plaf.metal.MetalCheckBoxUI;
|
||||
import javax.swing.text.View;
|
||||
@@ -138,6 +139,6 @@ public class DarculaCheckBoxUI extends MetalCheckBoxUI {
|
||||
|
||||
@Override
|
||||
public Icon getDefaultIcon() {
|
||||
return EmptyIcon.create(20);
|
||||
return new IconUIResource(EmptyIcon.create(20));
|
||||
}
|
||||
}
|
||||
|
||||
+3
-4
@@ -18,12 +18,12 @@ package com.intellij.ide.ui.laf.darcula.ui;
|
||||
import com.intellij.ide.ui.laf.darcula.DarculaUIUtil;
|
||||
import com.intellij.openapi.ui.GraphicsConfig;
|
||||
import com.intellij.ui.Gray;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.plaf.InsetsUIResource;
|
||||
import javax.swing.plaf.basic.BasicArrowButton;
|
||||
import javax.swing.plaf.basic.BasicComboBoxUI;
|
||||
import java.awt.*;
|
||||
@@ -34,7 +34,6 @@ import java.awt.geom.Path2D;
|
||||
*/
|
||||
public class DarculaComboBoxUI extends BasicComboBoxUI implements Border {
|
||||
private final JComboBox myComboBox;
|
||||
private JBInsets myComboBoxInsets = new JBInsets(4, 7, 4, 5);
|
||||
|
||||
public DarculaComboBoxUI(JComboBox comboBox) {
|
||||
myComboBox = comboBox;
|
||||
@@ -87,7 +86,7 @@ protected JButton createArrowButton() {
|
||||
|
||||
@Override
|
||||
protected Insets getInsets() {
|
||||
return myComboBoxInsets;
|
||||
return new InsetsUIResource(4, 7, 4, 5);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -139,7 +138,7 @@ protected JButton createArrowButton() {
|
||||
|
||||
@Override
|
||||
public Insets getBorderInsets(Component c) {
|
||||
return myComboBoxInsets;
|
||||
return new InsetsUIResource(4, 7, 4, 5);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-5
@@ -18,19 +18,16 @@ package com.intellij.ide.ui.laf.darcula.ui;
|
||||
import com.intellij.ide.ui.laf.darcula.DarculaUIUtil;
|
||||
import com.intellij.ui.EditorTextField;
|
||||
import com.intellij.ui.Gray;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.plaf.InsetsUIResource;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class DarculaEditorTextFieldBorder implements Border {
|
||||
|
||||
private JBInsets myInsets = new JBInsets(6, 7, 6, 7);
|
||||
|
||||
@Override
|
||||
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
|
||||
final EditorTextField textField = UIUtil.getParentOfType(EditorTextField.class, c);
|
||||
@@ -63,7 +60,7 @@ public class DarculaEditorTextFieldBorder implements Border {
|
||||
|
||||
@Override
|
||||
public Insets getBorderInsets(Component c) {
|
||||
return myInsets;
|
||||
return new InsetsUIResource(6, 7, 6, 7);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-1
@@ -18,6 +18,7 @@ package com.intellij.ide.ui.laf.darcula.ui;
|
||||
import com.intellij.ui.Gray;
|
||||
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.plaf.InsetsUIResource;
|
||||
import javax.swing.plaf.UIResource;
|
||||
import java.awt.*;
|
||||
|
||||
@@ -39,7 +40,7 @@ public class DarculaMenuBarBorder implements Border, UIResource {
|
||||
|
||||
@Override
|
||||
public Insets getBorderInsets(Component c) {
|
||||
return new Insets(0, 0, 2, 0);
|
||||
return new InsetsUIResource(0, 0, 2, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+7
-7
@@ -16,7 +16,6 @@
|
||||
package com.intellij.ide.ui.laf.darcula.ui;
|
||||
|
||||
import com.intellij.openapi.ui.GraphicsConfig;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
@@ -50,7 +49,8 @@ public class DarculaPasswordFieldUI extends BasicPasswordFieldUI {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintBackground(Graphics g) {
|
||||
protected void paintBackground(Graphics graphics) {
|
||||
Graphics2D g = (Graphics2D)graphics;
|
||||
final JTextComponent c = getComponent();
|
||||
final Container parent = c.getParent();
|
||||
if (parent != null) {
|
||||
@@ -62,17 +62,17 @@ public class DarculaPasswordFieldUI extends BasicPasswordFieldUI {
|
||||
g.setColor(c.getBackground());
|
||||
final int width = c.getWidth();
|
||||
final int height = c.getHeight();
|
||||
final JBInsets insets = ((DarculaTextBorder)border).getBorderInsets(c);
|
||||
final Insets i = border.getBorderInsets(c);
|
||||
if (c.hasFocus()) {
|
||||
final GraphicsConfig config = new GraphicsConfig(g);
|
||||
((Graphics2D)g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
((Graphics2D)g).setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
|
||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
|
||||
|
||||
g.fillRoundRect(insets.left - 5, insets.top - 2, width - insets.width() + 10, height - insets.height() + 6, 5, 5);
|
||||
g.fillRoundRect(i.left - 5, i.top - 2, width - i.left - i.right + 10, height - i.top - i.bottom + 6, 5, 5);
|
||||
config.restore();
|
||||
}
|
||||
else {
|
||||
g.fillRect(insets.left - 5, insets.top - 2, width - insets.width() + 12, height - insets.height() + 6);
|
||||
g.fillRect(i.left - 5, i.top - 2, width - i.left - i.right + 12, height - i.top - i.bottom + 6);
|
||||
}
|
||||
} else {
|
||||
super.paintBackground(g);
|
||||
|
||||
+2
-1
@@ -17,6 +17,7 @@ package com.intellij.ide.ui.laf.darcula.ui;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.AbstractBorder;
|
||||
import javax.swing.plaf.InsetsUIResource;
|
||||
import javax.swing.plaf.UIResource;
|
||||
import java.awt.*;
|
||||
|
||||
@@ -32,6 +33,6 @@ public class DarculaPopupMenuBorder extends AbstractBorder implements UIResource
|
||||
|
||||
@Override
|
||||
public Insets getBorderInsets(Component c) {
|
||||
return new Insets(1,1,1,1);
|
||||
return new InsetsUIResource(1,1,1,1);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -24,6 +24,7 @@ import sun.swing.SwingUtilities2;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.plaf.IconUIResource;
|
||||
import javax.swing.plaf.basic.BasicHTML;
|
||||
import javax.swing.plaf.metal.MetalRadioButtonUI;
|
||||
import javax.swing.text.View;
|
||||
@@ -130,6 +131,6 @@ public class DarculaRadioButtonUI extends MetalRadioButtonUI {
|
||||
|
||||
@Override
|
||||
public Icon getDefaultIcon() {
|
||||
return EmptyIcon.create(20);
|
||||
return new IconUIResource(EmptyIcon.create(20));
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -19,11 +19,11 @@ import com.intellij.ide.ui.laf.darcula.DarculaUIUtil;
|
||||
import com.intellij.openapi.ui.GraphicsConfig;
|
||||
import com.intellij.ui.Gray;
|
||||
import com.intellij.util.ui.GraphicsUtil;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.plaf.InsetsUIResource;
|
||||
import javax.swing.plaf.UIResource;
|
||||
import java.awt.*;
|
||||
|
||||
@@ -68,7 +68,7 @@ public class DarculaSpinnerBorder implements Border, UIResource {
|
||||
|
||||
@Override
|
||||
public Insets getBorderInsets(Component c) {
|
||||
return new JBInsets(6, 7, 6, 7);
|
||||
return new InsetsUIResource(6, 7, 6, 7);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-28
@@ -17,11 +17,10 @@ package com.intellij.ide.ui.laf.darcula.ui;
|
||||
|
||||
import com.intellij.ide.ui.laf.darcula.DarculaUIUtil;
|
||||
import com.intellij.openapi.ui.GraphicsConfig;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.ui.ColorUtil;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.plaf.InsetsUIResource;
|
||||
import javax.swing.plaf.UIResource;
|
||||
import javax.swing.text.JTextComponent;
|
||||
import java.awt.*;
|
||||
@@ -30,11 +29,9 @@ import java.awt.*;
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class DarculaTextBorder implements Border, UIResource {
|
||||
private JBInsets myInsets = new JBInsets(4, 7, 4, 7);
|
||||
|
||||
@Override
|
||||
public JBInsets getBorderInsets(Component c) {
|
||||
return myInsets;
|
||||
public Insets getBorderInsets(Component c) {
|
||||
return new InsetsUIResource(4, 7, 4, 7);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,34 +43,12 @@ public class DarculaTextBorder implements Border, UIResource {
|
||||
public void paintBorder(Component c, Graphics g2, int x, int y, int width, int height) {
|
||||
Graphics2D g = ((Graphics2D)g2);
|
||||
g.setColor(ColorUtil.fromHex("737373"));
|
||||
int cX = myInsets.right;
|
||||
int cY = myInsets.top;
|
||||
int cW = width - myInsets.width();
|
||||
int cH = height - myInsets.height();
|
||||
final GraphicsConfig config = new GraphicsConfig(g);
|
||||
g.translate(x, y);
|
||||
|
||||
if (c.hasFocus()) {
|
||||
int sysOffX = SystemInfo.isMac ? 0 : 1;
|
||||
int sysOffY = SystemInfo.isMac ? 0 : -1;
|
||||
DarculaUIUtil.paintFocusRing(g, 2, 2, width-4, height-4);
|
||||
|
||||
//g.setColor(DarculaUIUtil.GLOW_COLOR.darker().darker());
|
||||
//g.drawRect(1, 1, width - 2, height - 2);
|
||||
//g.drawRect(2, 2, width-4, height-4);
|
||||
//g.setColor(ColorUtil.toAlpha(DarculaUIUtil.GLOW_COLOR, 70));
|
||||
//g.drawRoundRect(0, 0, width, height, 5, 5);
|
||||
//g.setColor(ColorUtil.toAlpha(DarculaUIUtil.GLOW_COLOR, 80));
|
||||
//g.drawRoundRect(1, 1, width - 2, height-2, 5, 5);
|
||||
//g.setColor(ColorUtil.toAlpha(DarculaUIUtil.GLOW_COLOR, 120));
|
||||
//g.drawRoundRect(2, 2, width - 4, height - 4, 5, 5);
|
||||
//g.setColor(ColorUtil.toAlpha(DarculaUIUtil.GLOW_COLOR, 140));
|
||||
//g.drawRoundRect(3, 2, width - 6, height - 4, 5, 5);
|
||||
} else {
|
||||
//g.fillRect(2, 1, cX-2, height - 2); //left
|
||||
//g.fillRect(cX + cW , 1, width-cW - cX, height - 2); //right
|
||||
//g.fillRect(1, 1, width - 2, cY); //top
|
||||
//g.fillRect(1, cY + cH, width - 2, heigh7t - 2); //bottom
|
||||
boolean editable = !(c instanceof JTextComponent) || (((JTextComponent)c).isEditable());
|
||||
g.setColor(c.isEnabled() && editable ? new Color(0x939393) : new Color(0x535353));
|
||||
g.drawRect(1, 1, width - 2, height - 2);
|
||||
|
||||
+7
-7
@@ -16,7 +16,6 @@
|
||||
package com.intellij.ide.ui.laf.darcula.ui;
|
||||
|
||||
import com.intellij.openapi.ui.GraphicsConfig;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
@@ -49,7 +48,8 @@ public class DarculaTextFieldUI extends BasicTextFieldUI {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintBackground(Graphics g) {
|
||||
protected void paintBackground(Graphics graphics) {
|
||||
Graphics2D g = (Graphics2D)graphics;
|
||||
final JTextComponent c = getComponent();
|
||||
final Container parent = c.getParent();
|
||||
if (parent != null) {
|
||||
@@ -63,16 +63,16 @@ public class DarculaTextFieldUI extends BasicTextFieldUI {
|
||||
}
|
||||
final int width = c.getWidth();
|
||||
final int height = c.getHeight();
|
||||
final JBInsets insets = ((DarculaTextBorder)border).getBorderInsets(c);
|
||||
final Insets i = border.getBorderInsets(c);
|
||||
if (c.hasFocus()) {
|
||||
final GraphicsConfig config = new GraphicsConfig(g);
|
||||
((Graphics2D)g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
((Graphics2D)g).setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
|
||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
|
||||
|
||||
g.fillRoundRect(insets.left - 5, insets.top - 2, width - insets.width() + 10, height - insets.height() + 6, 5, 5);
|
||||
g.fillRoundRect(i.left - 5, i.top - 2, width - i.right - i.left + 10, height - i.top - i.bottom + 6, 5, 5);
|
||||
config.restore();
|
||||
} else {
|
||||
g.fillRect(insets.left - 5, insets.top - 2, width - insets.width() + 12, height - insets.height() + 6);
|
||||
g.fillRect(i.left - 5, i.top - 2, width - i.right - i.left + 12, height - i.top - i.bottom + 6);
|
||||
}
|
||||
} else {
|
||||
super.paintBackground(g);
|
||||
|
||||
Reference in New Issue
Block a user