mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-186723 The toolbar height changed. Unify for all themes.
This commit is contained in:
@@ -47,7 +47,7 @@ public interface ActionToolbar {
|
||||
int AUTO_LAYOUT_POLICY = 2;
|
||||
|
||||
/** This is default minimum size of the toolbar button */
|
||||
Dimension DEFAULT_MINIMUM_BUTTON_SIZE = JBUI.size(25, 25);
|
||||
Dimension DEFAULT_MINIMUM_BUTTON_SIZE = JBUI.size(22, 22);
|
||||
|
||||
Dimension NAVBAR_MINIMUM_BUTTON_SIZE = JBUI.size(20, 20);
|
||||
|
||||
@@ -89,8 +89,8 @@ public interface ActionToolbar {
|
||||
/**
|
||||
* Sets toolbar orientation
|
||||
*
|
||||
* @see javax.swing.SwingConstants#HORIZONTAL
|
||||
* @see javax.swing.SwingConstants#VERTICAL
|
||||
* @see SwingConstants#HORIZONTAL
|
||||
* @see SwingConstants#VERTICAL
|
||||
*/
|
||||
void setOrientation(int orientation);
|
||||
|
||||
|
||||
@@ -200,7 +200,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
|
||||
JPanel panel = new BorderLayoutPanel() {
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
return JBUI.size(25);
|
||||
return JBUI.size(24);
|
||||
}
|
||||
};
|
||||
panel.setOpaque(false);
|
||||
|
||||
+63
-70
@@ -43,6 +43,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.geom.Path2D;
|
||||
import java.awt.geom.RoundRectangle2D;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
|
||||
@@ -157,7 +159,7 @@ public abstract class ComboBoxAction extends AnAction implements CustomComponent
|
||||
setVisible(presentation.isVisible());
|
||||
setHorizontalAlignment(LEFT);
|
||||
setFocusable(ScreenReader.isActive());
|
||||
putClientProperty("styleCombo", Boolean.TRUE);
|
||||
putClientProperty("styleCombo", ComboBoxAction.this);
|
||||
Insets margins = getMargin();
|
||||
setMargin(JBUI.insets(margins.top, 2, margins.bottom, 2));
|
||||
if (isSmallVariant() && !UIUtil.isUnderGTKLookAndFeel()) {
|
||||
@@ -347,10 +349,10 @@ public abstract class ComboBoxAction extends AnAction implements CustomComponent
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
boolean isEmpty = getIcon() == null && StringUtil.isEmpty(getText());
|
||||
int width = isEmpty ? JBUI.scale(10) : super.getPreferredSize().width;
|
||||
width += getArrowIcon(isEnabled()).getIconWidth();
|
||||
return new Dimension(width, isSmallVariant() ? JBUI.scale(24) : super.getPreferredSize().height);
|
||||
Dimension prefSize = super.getPreferredSize();
|
||||
int width = prefSize.width + getArrowIcon(isEnabled()).getIconWidth() + JBUI.scale(5);
|
||||
width += UIUtil.isUnderWin10LookAndFeel() ? JBUI.scale(10) : 0;
|
||||
return new Dimension(width, isSmallVariant() ? JBUI.scale(24) : prefSize.height);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -374,100 +376,91 @@ public abstract class ComboBoxAction extends AnAction implements CustomComponent
|
||||
|
||||
if (UIUtil.isUnderDefaultMacTheme() || UIUtil.isUnderWin10LookAndFeel()) {
|
||||
super.paint(g);
|
||||
}
|
||||
else {
|
||||
UISettings.setupAntialiasing(g);
|
||||
GraphicsUtil.setupRoundedBorderAntialiasing(g);
|
||||
} else {
|
||||
Graphics2D g2 = (Graphics2D)g.create();
|
||||
try {
|
||||
UISettings.setupAntialiasing(g2);
|
||||
GraphicsUtil.setupRoundedBorderAntialiasing(g2);
|
||||
|
||||
final Color textColor = isEnabled()
|
||||
? UIManager.getColor("Panel.foreground")
|
||||
: UIUtil.getInactiveTextColor();
|
||||
Color textColor = isEnabled() ? UIManager.getColor("Panel.foreground") : UIUtil.getInactiveTextColor();
|
||||
|
||||
if (myForceTransparent) {
|
||||
final Icon icon = getIcon();
|
||||
int x = 7;
|
||||
if (icon != null) {
|
||||
icon.paintIcon(this, g, x, (size.height - icon.getIconHeight()) / 2);
|
||||
x += icon.getIconWidth() + 3;
|
||||
}
|
||||
if (!StringUtil.isEmpty(getText())) {
|
||||
final Font font = getFont();
|
||||
g.setFont(font);
|
||||
g.setColor(textColor);
|
||||
UIUtil.drawCenteredString((Graphics2D)g, new Rectangle(x, 0, Integer.MAX_VALUE, size.height), getText(), false, true);
|
||||
}
|
||||
} else {
|
||||
if (isSmallVariant()) {
|
||||
final Graphics2D g2 = (Graphics2D)g;
|
||||
if (myForceTransparent) {
|
||||
paintIconAndText(size, g2, textColor);
|
||||
} else if (isSmallVariant()) {
|
||||
g2.setColor(UIUtil.getControlColor());
|
||||
final int w = getWidth();
|
||||
final int h = getHeight();
|
||||
|
||||
int w = getWidth();
|
||||
int h = getHeight();
|
||||
|
||||
if (getModel().isArmed() && getModel().isPressed()) {
|
||||
g2.setPaint(UIUtil.getGradientPaint(0, 0, UIUtil.getControlColor(), 0, h, ColorUtil.shift(UIUtil.getControlColor(), 0.8)));
|
||||
}
|
||||
else {
|
||||
if (UIUtil.isUnderDarcula()) {
|
||||
g2.setPaint(UIUtil.getGradientPaint(0, 0, ColorUtil.shift(UIUtil.getControlColor(), 1.1), 0, h,
|
||||
ColorUtil.shift(UIUtil.getControlColor(), 0.9)));
|
||||
}
|
||||
else {
|
||||
g2.setPaint(UIUtil.getGradientPaint(0, 0, new JBColor(SystemInfo.isMac ? Gray._226 : Gray._245, Gray._131), 0, h,
|
||||
new JBColor(SystemInfo.isMac ? Gray._198 : Gray._208, Gray._128)));
|
||||
}
|
||||
} else if (UIUtil.isUnderDarcula()) {
|
||||
g2.setPaint(UIUtil.getGradientPaint(0, 0, ColorUtil.shift(UIUtil.getControlColor(), 1.1), 0, h,
|
||||
ColorUtil.shift(UIUtil.getControlColor(), 0.9)));
|
||||
} else {
|
||||
g2.setPaint(UIUtil.getGradientPaint(0, 0, new JBColor(SystemInfo.isMac ? Gray._226 : Gray._245, Gray._131), 0, h,
|
||||
new JBColor(SystemInfo.isMac ? Gray._198 : Gray._208, Gray._128)));
|
||||
}
|
||||
|
||||
g2.fillRoundRect(2, 0, w - 2, h, 5, 5);
|
||||
Rectangle r = new Rectangle(w, h);
|
||||
JBInsets.removeFrom(r, JBUI.insets(1));
|
||||
|
||||
float arc = JBUI.scale(3.0f);
|
||||
Shape outerShape = new RoundRectangle2D.Float(r.x, r.y, r.width, r.height, arc, arc);
|
||||
g2.fill(outerShape);
|
||||
|
||||
Color borderColor = myMouseInside ? new JBColor(Gray._111, Gray._118) : new JBColor(Gray._151, Gray._95);
|
||||
g2.setPaint(borderColor);
|
||||
g2.drawRoundRect(2, 0, w - 3, h - 1, 5, 5);
|
||||
|
||||
final Icon icon = getIcon();
|
||||
int x = 7;
|
||||
if (icon != null) {
|
||||
icon.paintIcon(this, g, x, (size.height - icon.getIconHeight()) / 2);
|
||||
x += icon.getIconWidth() + 3;
|
||||
}
|
||||
if (!StringUtil.isEmpty(getText())) {
|
||||
final Font font = getFont();
|
||||
g2.setFont(font);
|
||||
g2.setColor(textColor);
|
||||
UIUtil.drawCenteredString(g2, new Rectangle(x, 0, Integer.MAX_VALUE, size.height), getText(), false, true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
float lw = JBUI.scale(1.0f);
|
||||
Path2D outline = new Path2D.Float(Path2D.WIND_EVEN_ODD);
|
||||
outline.append(outerShape, false);
|
||||
outline.append(new RoundRectangle2D.Float(r.x + lw, r.y + lw, r.width - lw*2, r.height - lw*2, arc - lw, arc - lw), false);
|
||||
g2.fill(outline);
|
||||
|
||||
paintIconAndText(size, g2, textColor);
|
||||
} else {
|
||||
super.paint(g);
|
||||
}
|
||||
} finally {
|
||||
g2.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
Insets insets = getInsets();
|
||||
Icon icon = getArrowIcon(isEnabled());
|
||||
|
||||
int x = size.width - icon.getIconWidth();
|
||||
int x = size.width - icon.getIconWidth() - insets.right;
|
||||
if (UIUtil.isUnderWin10LookAndFeel()) {
|
||||
x -= JBUI.scale(6);
|
||||
x -= JBUI.scale(UIUtil.getParentOfType(ActionToolbar.class, this) != null ? 2 : 0);
|
||||
}
|
||||
else {
|
||||
x -= insets.right;
|
||||
|
||||
if (isSmallVariant()) {
|
||||
x += JBUI.scale(1);
|
||||
|
||||
x -= JBUI.scale(5);
|
||||
} else if (isSmallVariant()) {
|
||||
if (UIUtil.isUnderDefaultMacTheme()) {
|
||||
x -= JBUI.scale(3);
|
||||
}
|
||||
}
|
||||
else {
|
||||
x += JBUI.scale(2);
|
||||
}
|
||||
} else {
|
||||
x += JBUI.scale(2);
|
||||
}
|
||||
|
||||
icon.paintIcon(null, g, x, (size.height - icon.getIconHeight()) / 2);
|
||||
g.setPaintMode();
|
||||
}
|
||||
|
||||
private void paintIconAndText(Dimension size, Graphics2D g2, Color textColor) {
|
||||
Icon icon = getIcon();
|
||||
int x = JBUI.scale(7);
|
||||
if (icon != null) {
|
||||
icon.paintIcon(this, g2, x, (size.height - icon.getIconHeight()) / 2);
|
||||
x += icon.getIconWidth() + JBUI.scale(3);
|
||||
}
|
||||
|
||||
if (!StringUtil.isEmpty(getText())) {
|
||||
Font font = getFont();
|
||||
g2.setFont(font);
|
||||
g2.setColor(textColor);
|
||||
UIUtil.drawCenteredString(g2, new Rectangle(x, 0, Integer.MAX_VALUE, size.height), getText(), false, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void updateUI() {
|
||||
super.updateUI();
|
||||
updateButtonSize();
|
||||
|
||||
+1
-1
@@ -127,7 +127,6 @@ public abstract class AbstractSchemesPanel<T extends Scheme, InfoComponent exten
|
||||
mySchemesCombo.getComponent().setMaximumSize(mySchemesCombo.getComponent().getPreferredSize());
|
||||
|
||||
int height = mySchemesCombo.getComponent().getPreferredSize().height;
|
||||
height += JBUI.scale(2) * 2;
|
||||
controlsPanel.setMaximumSize(new Dimension(controlsPanel.getMaximumSize().width, height));
|
||||
return controlsPanel;
|
||||
}
|
||||
@@ -138,6 +137,7 @@ public abstract class AbstractSchemesPanel<T extends Scheme, InfoComponent exten
|
||||
toolbar.setReservePlaceAutoPopupIcon(false);
|
||||
toolbar.setLayoutPolicy(ActionToolbar.NOWRAP_LAYOUT_POLICY);
|
||||
JComponent toolbarComponent = toolbar.getComponent();
|
||||
toolbarComponent.setBorder(JBUI.Borders.empty(3));
|
||||
toolbarActionGroup.add(new ShowSchemesActionsListAction(myActions.getActions(), toolbarComponent));
|
||||
return toolbarComponent;
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ public class DarculaUIUtil {
|
||||
@SuppressWarnings("SuspiciousNameCombination")
|
||||
private static void doPaint(Graphics2D g, int width, int height, float arc, boolean symmetric) {
|
||||
float bw = UIUtil.isUnderDefaultMacTheme() ? JBUI.scale(3) : bw();
|
||||
float lw = UIUtil.isUnderDefaultMacTheme() ? JBUI.scale(UIUtil.isRetina(g) ? 0.5f : 1.0f) : JBUI.scale(0.5f);
|
||||
float lw = UIUtil.isUnderDefaultMacTheme() ? JBUI.scale(UIUtil.isRetina(g) ? 0.5f : 1.0f) : lw(g);
|
||||
|
||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, MacUIUtil.USE_QUARTZ ? RenderingHints.VALUE_STROKE_PURE : RenderingHints.VALUE_STROKE_NORMALIZE);
|
||||
@@ -391,8 +391,9 @@ public class DarculaUIUtil {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static float lw(Graphics2D g2) {
|
||||
return UIUtil.isJreHiDPI(g2) ? JBUI.scale(0.5f) : 1.0f;
|
||||
return JBUI.scale(1.0f);
|
||||
}
|
||||
|
||||
public static float bw() {
|
||||
|
||||
+3
-14
@@ -16,7 +16,6 @@
|
||||
package com.intellij.ide.ui.laf.darcula.ui;
|
||||
|
||||
import com.intellij.ide.ui.laf.darcula.DarculaUIUtil;
|
||||
import com.intellij.openapi.actionSystem.ActionToolbar;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.MacUIUtil;
|
||||
@@ -60,11 +59,11 @@ public class DarculaButtonPainter implements Border, UIResource {
|
||||
|
||||
if (c.hasFocus()) {
|
||||
if (UIUtil.isHelpButton(c)) {
|
||||
DarculaUIUtil.paintFocusOval(g2, (r.width - diam) / 2 + lw, (r.height - diam) / 2 + lw, diam - lw, diam - lw);
|
||||
DarculaUIUtil.paintFocusOval(g2, (r.width - diam) / 2, (r.height - diam) / 2, diam, diam);
|
||||
} else {
|
||||
DarculaUIUtil.paintFocusBorder(g2, r.width, r.height, arc, true);
|
||||
}
|
||||
} else {
|
||||
} else if (!UIUtil.isHelpButton(c)){
|
||||
paintShadow(g2, r);
|
||||
}
|
||||
|
||||
@@ -110,17 +109,7 @@ public class DarculaButtonPainter implements Border, UIResource {
|
||||
|
||||
@Override
|
||||
public Insets getBorderInsets(Component c) {
|
||||
if (c.getParent() instanceof ActionToolbar) {
|
||||
return JBUI.insets(5, 14);
|
||||
} else if (DarculaButtonUI.isSquare(c)) {
|
||||
return JBUI.insets(4).asUIResource();
|
||||
} else if (UIUtil.isHelpButton(c)) {
|
||||
return JBUI.insets(3).asUIResource();
|
||||
} if (DarculaButtonUI.isComboButton((JComponent)c)) {
|
||||
return JBUI.insets(5, 10, 5, 5).asUIResource();
|
||||
} else {
|
||||
return JBUI.insets(5, 14).asUIResource();
|
||||
}
|
||||
return JBUI.insets(3).asUIResource();
|
||||
}
|
||||
|
||||
protected int getOffset() {
|
||||
|
||||
+16
-16
@@ -20,6 +20,7 @@ import com.intellij.ide.ui.UISettings;
|
||||
import com.intellij.ide.ui.laf.darcula.DarculaLaf;
|
||||
import com.intellij.ide.ui.laf.darcula.DarculaUIUtil;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
@@ -64,7 +65,7 @@ public class DarculaButtonUI extends BasicButtonUI {
|
||||
}
|
||||
|
||||
public static boolean isComboButton(JComponent c) {
|
||||
return c instanceof AbstractButton && c.getClientProperty("styleCombo") == Boolean.TRUE;
|
||||
return c instanceof AbstractButton && c.getClientProperty("styleCombo") != null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,7 +123,7 @@ public class DarculaButtonUI extends BasicButtonUI {
|
||||
@Override
|
||||
public void paint(Graphics g, JComponent c) {
|
||||
if (paintDecorations((Graphics2D)g, c)) {
|
||||
super.paint(g, c);
|
||||
paintContents(g, (AbstractButton)c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,15 +204,17 @@ public class DarculaButtonUI extends BasicButtonUI {
|
||||
}
|
||||
|
||||
protected Dimension getDarculaButtonSize(JComponent c, Dimension prefSize) {
|
||||
float bw = DarculaUIUtil.bw();
|
||||
|
||||
Insets i = c.getInsets();
|
||||
int helpDiam = JBUI.scale(HELP_BUTTON_DIAMETER);
|
||||
return UIUtil.isHelpButton(c) ?
|
||||
new Dimension(Math.max(prefSize.width, helpDiam + i.left + i.right),
|
||||
Math.max(prefSize.height, helpDiam + i.top + i.bottom)):
|
||||
new Dimension(Math.max(prefSize.width, (int)(JBUI.scale(74) + bw * 2)),
|
||||
Math.max(prefSize.height, (int)(JBUI.scale(26) + bw * 2)));
|
||||
if (isComboButton(c)) {
|
||||
return prefSize;
|
||||
} else {
|
||||
Insets i = c.getInsets();
|
||||
int helpDiam = JBUI.scale(HELP_BUTTON_DIAMETER);
|
||||
return UIUtil.isHelpButton(c) ?
|
||||
new Dimension(Math.max(prefSize.width, helpDiam + i.left + i.right),
|
||||
Math.max(prefSize.height, helpDiam + i.top + i.bottom)):
|
||||
new Dimension(Math.max(JBUI.scale(26) + prefSize.width, JBUI.scale(72) + i.left + i.right),
|
||||
Math.max(prefSize.height, JBUI.scale(24) + i.top + i.bottom));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -263,14 +266,11 @@ public class DarculaButtonUI extends BasicButtonUI {
|
||||
b, fm, text, icon,
|
||||
b.getVerticalAlignment(), b.getHorizontalAlignment(),
|
||||
b.getVerticalTextPosition(), b.getHorizontalTextPosition(),
|
||||
viewRect, iconRect, textRect, text == null ? 0 : b.getIconTextGap());
|
||||
viewRect, iconRect, textRect,
|
||||
StringUtil.isEmpty(text) || icon == null ? 0 : b.getIconTextGap());
|
||||
}
|
||||
|
||||
protected void modifyViewRect(AbstractButton b, Rectangle rect) {
|
||||
JBInsets.removeFrom(rect, b.getInsets());
|
||||
|
||||
if (isComboButton(b)) {
|
||||
rect.x += 6;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-4
@@ -128,13 +128,16 @@ public class MacIntelliJButtonUI extends DarculaButtonUI {
|
||||
|
||||
@Override
|
||||
protected Dimension getDarculaButtonSize(JComponent c, Dimension prefSize) {
|
||||
if (UIUtil.isHelpButton(c)) {
|
||||
if (isComboButton(c)) {
|
||||
return prefSize;
|
||||
} else if (UIUtil.isHelpButton(c)) {
|
||||
Icon icon = IconCache.getIcon("helpButton", false, false);
|
||||
return new Dimension(icon.getIconWidth(), icon.getIconHeight());
|
||||
} else if (c.getBorder() instanceof MacIntelliJButtonBorder || isComboButton(c)) {
|
||||
return JBUI.size(prefSize.width + (isComboButton(c) ? 10 : 18), 27);
|
||||
} else {
|
||||
Insets i = c.getInsets();
|
||||
return new Dimension(Math.max(JBUI.scale(28) + prefSize.width, JBUI.scale(72) + i.left + i.right),
|
||||
Math.max(prefSize.height, JBUI.scale(21) + i.top + i.bottom));
|
||||
}
|
||||
return JBUI.size(prefSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-14
@@ -2,7 +2,6 @@
|
||||
package com.intellij.ide.ui.laf.intellij;
|
||||
|
||||
import com.intellij.ide.ui.laf.darcula.ui.DarculaButtonUI;
|
||||
import com.intellij.openapi.actionSystem.ActionToolbar;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
@@ -14,7 +13,6 @@ import javax.swing.plaf.UIResource;
|
||||
import java.awt.*;
|
||||
import java.awt.geom.Path2D;
|
||||
|
||||
import static com.intellij.ide.ui.laf.darcula.ui.DarculaButtonUI.isSquare;
|
||||
import static com.intellij.ide.ui.laf.intellij.WinIntelliJButtonUI.DISABLED_ALPHA_LEVEL;
|
||||
|
||||
/**
|
||||
@@ -31,9 +29,6 @@ public class WinIntelliJButtonBorder implements Border, UIResource {
|
||||
Rectangle outerRect = new Rectangle(x, y, width, height);
|
||||
try {
|
||||
JBInsets.removeFrom(outerRect, getOuterInsets());
|
||||
if (UIUtil.getParentOfType(ActionToolbar.class, c) != null) {
|
||||
JBInsets.removeFrom(outerRect, JBUI.insetsRight(3));
|
||||
}
|
||||
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
|
||||
@@ -82,15 +77,7 @@ public class WinIntelliJButtonBorder implements Border, UIResource {
|
||||
|
||||
@Override
|
||||
public Insets getBorderInsets(Component c) {
|
||||
if (isSquare(c)) {
|
||||
return JBUI.insets(2).asUIResource();
|
||||
} else if (UIUtil.isHelpButton(c)) {
|
||||
return JBUI.insets(0, 0, 0, 10).asUIResource();
|
||||
} else if (DarculaButtonUI.isComboButton((JComponent)c)) {
|
||||
return JBUI.insets(4, 10).asUIResource();
|
||||
} else {
|
||||
return JBUI.insets(4, 18).asUIResource();
|
||||
}
|
||||
return JBUI.insets(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+13
-12
@@ -17,8 +17,10 @@ package com.intellij.ide.ui.laf.intellij;
|
||||
|
||||
import com.intellij.ide.ui.laf.IconCache;
|
||||
import com.intellij.ide.ui.laf.darcula.ui.DarculaButtonUI;
|
||||
import com.intellij.openapi.actionSystem.ActionToolbar;
|
||||
import com.intellij.util.ui.*;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.MacUIUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import sun.swing.SwingUtilities2;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -83,9 +85,6 @@ public class WinIntelliJButtonUI extends DarculaButtonUI {
|
||||
}
|
||||
|
||||
JBInsets.removeFrom(r, JBUI.insets(2));
|
||||
if (UIUtil.getParentOfType(ActionToolbar.class, c) != null) {
|
||||
JBInsets.removeFrom(r, JBUI.insetsRight(3));
|
||||
}
|
||||
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, MacUIUtil.USE_QUARTZ ? RenderingHints.VALUE_STROKE_PURE : RenderingHints.VALUE_STROKE_NORMALIZE);
|
||||
@@ -124,14 +123,16 @@ public class WinIntelliJButtonUI extends DarculaButtonUI {
|
||||
|
||||
@Override
|
||||
protected Dimension getDarculaButtonSize(JComponent c, Dimension prefSize) {
|
||||
if (UIUtil.isHelpButton(c)) {
|
||||
Icon icon = IconCache.getIcon("winHelp");
|
||||
Insets i = c.getInsets();
|
||||
return new Dimension(icon.getIconWidth() + i.left + i.right, JBUI.scale(24));
|
||||
} else if (isSquare(c)) {
|
||||
return new JBDimension(24, 24);
|
||||
} else {
|
||||
Insets i = c.getInsets();
|
||||
if (isComboButton(c)) {
|
||||
return prefSize;
|
||||
} else if (UIUtil.isHelpButton(c) || isSquare(c)) {
|
||||
Dimension size = JBUI.size(22);
|
||||
JBInsets.addTo(size, i);
|
||||
return size;
|
||||
} else {
|
||||
return new Dimension(Math.max(JBUI.scale(28) + prefSize.width, JBUI.scale(72) + i.left + i.right),
|
||||
Math.max(prefSize.height, JBUI.scale(22) + i.top + i.bottom));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
@@ -33,6 +33,9 @@ public class WinIntelliJSpinnerBorder extends DarculaSpinnerBorder implements Er
|
||||
JSpinner spinner = (JSpinner)c;
|
||||
Graphics2D g2 = (Graphics2D)g.create();
|
||||
try {
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
|
||||
|
||||
Rectangle r = new Rectangle(x, y, width, height);
|
||||
|
||||
int bw = 1;
|
||||
|
||||
@@ -126,6 +126,9 @@ public class WinIntelliJSpinnerUI extends DarculaSpinnerUI {
|
||||
@Override public void paint(Graphics g) {
|
||||
Graphics2D g2 = (Graphics2D)g.create();
|
||||
try {
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
|
||||
|
||||
int bw = scale(1);
|
||||
ButtonModel bm = getModel();
|
||||
|
||||
|
||||
+1
-1
@@ -86,6 +86,6 @@ public abstract class ActionButtonLook {
|
||||
}
|
||||
|
||||
public Insets getInsets() {
|
||||
return JBUI.emptyInsets();
|
||||
return JBUI.insets(2);
|
||||
}
|
||||
}
|
||||
|
||||
+10
-41
@@ -22,7 +22,6 @@ import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
import com.intellij.openapi.wm.ex.WindowManagerEx;
|
||||
import com.intellij.ui.ColorUtil;
|
||||
import com.intellij.ui.Gray;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.ui.awt.RelativeRectangle;
|
||||
@@ -946,48 +945,23 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
}
|
||||
|
||||
private final class MySeparator extends JComponent {
|
||||
private final JBDimension mySize;
|
||||
|
||||
public MySeparator() {
|
||||
if (myOrientation == SwingConstants.HORIZONTAL) {
|
||||
mySize = JBUI.size(6, 24);
|
||||
}
|
||||
else {
|
||||
mySize = JBUI.size(24, 6);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
return mySize.size();
|
||||
return (myOrientation == SwingConstants.HORIZONTAL) ? JBUI.size(6, 24) : JBUI.size(24, 6);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(final Graphics g) {
|
||||
final Insets i = getInsets();
|
||||
int gap = JBUI.scale(2);
|
||||
int gap = JBUI.scale(3);
|
||||
int offset = JBUI.scale(3);
|
||||
|
||||
if (UIUtil.isUnderAquaBasedLookAndFeel() || UIUtil.isUnderDarcula()) {
|
||||
if (getParent() != null) {
|
||||
final JBColor col = new JBColor(Gray._128, Gray._111);
|
||||
final Graphics2D g2 = (Graphics2D)g;
|
||||
if (myOrientation == SwingConstants.HORIZONTAL) {
|
||||
UIUtil.drawDoubleSpaceDottedLine(g2, i.top + gap, getParent().getSize().height - gap - i.top - i.bottom, offset, col, false);
|
||||
} else {
|
||||
UIUtil.drawDoubleSpaceDottedLine(g2, i.left + gap, getParent().getSize().width - gap - i.left - i.right, offset, col, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (getParent() != null) {
|
||||
g.setColor(UIUtil.getSeparatorColor());
|
||||
if (getParent() != null) {
|
||||
if (myOrientation == SwingConstants.HORIZONTAL) {
|
||||
LinePainter2D.paint((Graphics2D)g, offset, gap, offset, getParent().getSize().height - gap);
|
||||
}
|
||||
else {
|
||||
LinePainter2D.paint((Graphics2D)g, gap, offset, getParent().getSize().width - gap, offset);
|
||||
}
|
||||
if (myOrientation == SwingConstants.HORIZONTAL) {
|
||||
LinePainter2D.paint((Graphics2D)g, offset, gap, offset, getParent().getSize().height - gap * 2);
|
||||
}
|
||||
else {
|
||||
LinePainter2D.paint((Graphics2D)g, gap, offset, getParent().getSize().width - gap * 2, offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1363,13 +1337,8 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
|
||||
setBorder(JBUI.Borders.empty());
|
||||
setOpaque(false);
|
||||
} else {
|
||||
if (UIUtil.isUnderWin10LookAndFeel()) {
|
||||
setBorder(JBUI.Borders.empty(0));
|
||||
setMinimumButtonSize(myDecorateButtons ? JBUI.size(30, 22) : JBUI.size(25, 22));
|
||||
} else {
|
||||
setBorder(JBUI.Borders.empty(3));
|
||||
setMinimumButtonSize(myDecorateButtons ? JBUI.size(30, 20) : DEFAULT_MINIMUM_BUTTON_SIZE);
|
||||
}
|
||||
setBorder(JBUI.Borders.empty(2));
|
||||
setMinimumButtonSize(myDecorateButtons ? JBUI.size(30, 20) : DEFAULT_MINIMUM_BUTTON_SIZE);
|
||||
setOpaque(true);
|
||||
setLayoutPolicy(AUTO_LAYOUT_POLICY);
|
||||
}
|
||||
|
||||
+24
-10
@@ -15,14 +15,17 @@
|
||||
*/
|
||||
package com.intellij.openapi.actionSystem.impl;
|
||||
|
||||
import com.intellij.ide.ui.laf.darcula.DarculaUIUtil;
|
||||
import com.intellij.openapi.actionSystem.ActionButtonComponent;
|
||||
import com.intellij.openapi.actionSystem.ex.ActionButtonLook;
|
||||
import com.intellij.ui.Gray;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.geom.Path2D;
|
||||
import java.awt.geom.RoundRectangle2D;
|
||||
|
||||
/**
|
||||
@@ -39,14 +42,17 @@ public class IdeaActionButtonLook extends ActionButtonLook {
|
||||
|
||||
public void paintBackground(Graphics g, JComponent component, int state) {
|
||||
if (state != ActionButtonComponent.NORMAL) {
|
||||
paintBackground(g, component.getSize(), state);
|
||||
Rectangle rect = new Rectangle(component.getSize());
|
||||
JBInsets.removeFrom(rect, component.getInsets());
|
||||
paintBackground(g, rect, state);
|
||||
}
|
||||
}
|
||||
|
||||
protected static void paintBackground(Graphics g, Dimension size, int state) {
|
||||
protected static void paintBackground(Graphics g, Rectangle rect, int state) {
|
||||
Graphics2D g2 = (Graphics2D)g.create();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
|
||||
g2.translate(rect.x, rect.y);
|
||||
|
||||
try {
|
||||
if (UIUtil.isUnderAquaLookAndFeel() || UIUtil.isUnderDefaultMacTheme()) {
|
||||
@@ -54,7 +60,9 @@ public class IdeaActionButtonLook extends ActionButtonLook {
|
||||
} else {
|
||||
g2.setColor(state == ActionButtonComponent.PUSHED ? PRESSED_BG : POPPED_BG);
|
||||
}
|
||||
g2.fill(getShape(size));
|
||||
|
||||
float arc = DarculaUIUtil.buttonArc();
|
||||
g2.fill(new RoundRectangle2D.Float(0, 0, rect.width, rect.height, arc, arc));
|
||||
} finally {
|
||||
g2.dispose();
|
||||
}
|
||||
@@ -62,14 +70,17 @@ public class IdeaActionButtonLook extends ActionButtonLook {
|
||||
|
||||
public void paintBorder(Graphics g, JComponent component, int state) {
|
||||
if (state != ActionButtonComponent.NORMAL) {
|
||||
paintBorder(g, component.getSize(), state);
|
||||
Rectangle rect = new Rectangle(component.getSize());
|
||||
JBInsets.removeFrom(rect, component.getInsets());
|
||||
paintBorder(g, rect, state);
|
||||
}
|
||||
}
|
||||
|
||||
protected static void paintBorder(Graphics g, Dimension size, int state) {
|
||||
protected static void paintBorder(Graphics g, Rectangle rect, int state) {
|
||||
Graphics2D g2 = (Graphics2D)g.create();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
|
||||
g2.translate(rect.x, rect.y);
|
||||
|
||||
try {
|
||||
if (UIUtil.isUnderAquaLookAndFeel() || UIUtil.isUnderDefaultMacTheme()) {
|
||||
@@ -77,13 +88,16 @@ public class IdeaActionButtonLook extends ActionButtonLook {
|
||||
} else {
|
||||
g2.setColor(state == ActionButtonComponent.PUSHED ? PRESSED_BORDER : POPPED_BORDER);
|
||||
}
|
||||
g2.draw(getShape(size));
|
||||
|
||||
float arc = DarculaUIUtil.buttonArc();
|
||||
float lw = DarculaUIUtil.lw(g2);
|
||||
Path2D border = new Path2D.Float(Path2D.WIND_EVEN_ODD);
|
||||
border.append(new RoundRectangle2D.Float(0, 0, rect.width, rect.height, arc, arc), false);
|
||||
border.append(new RoundRectangle2D.Float(lw, lw, rect.width - lw*2, rect.height- lw*2, arc - lw, arc - lw), false);
|
||||
|
||||
g2.fill(border);
|
||||
} finally {
|
||||
g2.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private static Shape getShape(Dimension size) {
|
||||
return new RoundRectangle2D.Double(0, 0, size.width - 1, size.height - 1, 4, 4);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,9 +38,9 @@ public class PoppedIcon implements Icon {
|
||||
|
||||
@Override
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
final Dimension size = new Dimension(getIconWidth() + 2*x, getIconHeight() + 2*x);
|
||||
IdeaActionButtonLook.paintBackground(g, size, ActionButtonComponent.POPPED);
|
||||
IdeaActionButtonLook.paintBorder(g, size, ActionButtonComponent.POPPED);
|
||||
Rectangle rect = new Rectangle(getIconWidth() + 2*x, getIconHeight() + 2*x);
|
||||
IdeaActionButtonLook.paintBackground(g, rect, ActionButtonComponent.POPPED);
|
||||
IdeaActionButtonLook.paintBorder(g, rect, ActionButtonComponent.POPPED);
|
||||
myIcon.paintIcon(c, g, x + (getIconWidth() - myIcon.getIconWidth())/2, y + (getIconHeight() - myIcon.getIconHeight())/2);
|
||||
}
|
||||
|
||||
|
||||
+6
-8
@@ -53,16 +53,18 @@ public class Win10ActionButtonLook extends ActionButtonLook {
|
||||
if (state != NORMAL) {
|
||||
Graphics2D g2 = (Graphics2D)g.create();
|
||||
try {
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
|
||||
g2.setColor(getBorderColorForState(state));
|
||||
|
||||
Rectangle outerRect = new Rectangle(component.getSize());
|
||||
JBInsets.removeFrom(outerRect, JBUI.insets(1));
|
||||
Rectangle rect = new Rectangle(component.getSize());
|
||||
JBInsets.removeFrom(rect, component.getInsets());
|
||||
|
||||
Rectangle innerRect = new Rectangle(outerRect);
|
||||
Rectangle innerRect = new Rectangle(rect);
|
||||
JBInsets.removeFrom(innerRect, JBUI.insets(1));
|
||||
|
||||
Path2D border = new Path2D.Float(Path2D.WIND_EVEN_ODD);
|
||||
border.append(outerRect, false);
|
||||
border.append(rect, false);
|
||||
border.append(innerRect, false);
|
||||
|
||||
g2.fill(border);
|
||||
@@ -72,10 +74,6 @@ public class Win10ActionButtonLook extends ActionButtonLook {
|
||||
}
|
||||
}
|
||||
|
||||
@Override public Insets getInsets() {
|
||||
return JBUI.insets(2, 1);
|
||||
}
|
||||
|
||||
private static Color getBorderColorForState(int state) {
|
||||
switch (state) {
|
||||
case POPPED:
|
||||
|
||||
@@ -454,9 +454,7 @@ public class AbstractPopup implements JBPopup {
|
||||
|
||||
@Override
|
||||
public void showUnderneathOf(@NotNull Component aComponent) {
|
||||
show(new RelativePoint(aComponent, UIUtil.isUnderWin10LookAndFeel() ?
|
||||
new Point(JBUI.scale(2), aComponent.getHeight()) :
|
||||
new Point(0, aComponent.getHeight())));
|
||||
show(new RelativePoint(aComponent, new Point(JBUI.scale(2), aComponent.getHeight())));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1293,15 +1293,7 @@ public class UIUtil {
|
||||
}
|
||||
|
||||
public static Color getSeparatorColor() {
|
||||
Color separatorColor = getSeparatorForeground();
|
||||
if (false) {
|
||||
separatorColor = getSeparatorShadow();
|
||||
}
|
||||
//under GTK+ L&F colors set hard
|
||||
if (isUnderGTKLookAndFeel()) {
|
||||
separatorColor = Gray._215;
|
||||
}
|
||||
return separatorColor;
|
||||
return isUnderGTKLookAndFeel() ? Gray._215 : getSeparatorForeground();
|
||||
}
|
||||
|
||||
public static Border getTableFocusCellHighlightBorder() {
|
||||
|
||||
Reference in New Issue
Block a user