IDEA-171869 Win10 LaF fix ActionButton outer padding

This commit is contained in:
Kirill Kirichenko
2017-08-08 16:48:48 +03:00
parent 1c780451f0
commit 46ae37cdf2
12 changed files with 48 additions and 36 deletions
@@ -188,7 +188,6 @@ public class InstancesWindow extends DialogWrapper {
myFilterConditionEditor = new ExpressionEditorWithHistory(myProject, myClassName,
editorsProvider, InstancesWindow.this.myDisposable);
myFilterButton.setBorder(BorderFactory.createEmptyBorder());
final Dimension filteringButtonSize = myFilterConditionEditor.getEditorComponent().getPreferredSize();
filteringButtonSize.width = JBUI.scale(FILTERING_BUTTON_ADDITIONAL_WIDTH) +
myFilterButton.getPreferredSize().width;
@@ -196,7 +195,7 @@ public class InstancesWindow extends DialogWrapper {
final JBPanel filteringPane = new JBPanel(new BorderLayout(JBUI.scale(BORDER_LAYOUT_DEFAULT_GAP), 0));
final JBLabel sideEffectsWarning = new JBLabel("Warning: filtering may have side effects", SwingConstants.RIGHT);
sideEffectsWarning.setBorder(JBUI.Borders.empty(1, 0, 0, 0));
sideEffectsWarning.setBorder(JBUI.Borders.emptyTop(1));
sideEffectsWarning.setComponentStyle(UIUtil.ComponentStyle.SMALL);
sideEffectsWarning.setFontColor(UIUtil.FontColor.BRIGHTER);
@@ -124,9 +124,8 @@ public class RunConfigurationsComboBoxAction extends ComboBoxAction implements D
@Override
public JComponent createCustomComponent(final Presentation presentation) {
ComboBoxButton button = createComboBoxButton(presentation);
button.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2));
NonOpaquePanel panel = new NonOpaquePanel(new BorderLayout());
panel.setBorder(JBUI.Borders.empty(0, 0, 0, 2));
panel.setBorder(JBUI.Borders.emptyRight(2));
panel.add(button);
return panel;
}
@@ -240,12 +240,14 @@ public class RunnerContentUi implements ContentUI, Disposable, CellTransform.Fac
myTabs.getPresentation().setPaintBorder(0, 0, 0, 0).setPaintFocus(false)
.setRequestFocusOnLastFocusedComponent(true);
myTabs.getComponent().setBackground(myToolbar.getBackground());
myTabs.getComponent().setBorder(new EmptyBorder(0, 1, 0, 0));
myTabs.getComponent().setBorder(JBUI.Borders.emptyLeft(1));
final NonOpaquePanel wrapper = new MyComponent(new BorderLayout(0, 0));
myToolbar.setBorder(JBUI.Borders.emptyTop(1)); // Compensate negative insets below
NonOpaquePanel wrapper = new MyComponent(new BorderLayout(0, 0));
wrapper.add(myToolbar, BorderLayout.WEST);
wrapper.add(myTabs.getComponent(), BorderLayout.CENTER);
wrapper.setBorder(new EmptyBorder(-1, 0, 0, 0));
wrapper.setBorder(JBUI.Borders.emptyTop(-1));
myComponent = wrapper;
@@ -165,7 +165,10 @@ public abstract class ComboBoxAction extends AnAction implements CustomComponent
Insets margins = getMargin();
setMargin(JBUI.insets(margins.top, 2, margins.bottom, 2));
if (isSmallVariant()) {
setBorder(JBUI.Borders.empty(0, 2));
if (!UIUtil.isUnderWin10LookAndFeel()) {
setBorder(JBUI.Borders.empty(0, 2));
}
if (!UIUtil.isUnderGTKLookAndFeel()) {
setFont(JBUI.Fonts.label(11));
}
@@ -46,7 +46,7 @@ public class MacIntelliJButtonBorder implements Border, UIResource {
@Override
public Insets getBorderInsets(Component c) {
return JBUI.insets(3, 3).asUIResource();
return JBUI.insets(3).asUIResource();
}
@Override
@@ -36,10 +36,6 @@ import static com.intellij.ide.ui.laf.intellij.WinIntelliJButtonUI.DISABLED_ALPH
public class WinIntelliJButtonBorder implements Border, UIResource {
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
paint(c, g, x, y, width, height);
}
static void paint(Component c, Graphics g, int x, int y, int width, int height) {
if (!(c instanceof AbstractButton) || DarculaButtonUI.isHelpButton((JComponent)c)) return;
Graphics2D g2 = (Graphics2D)g.create();
@@ -86,7 +82,9 @@ public class WinIntelliJButtonBorder implements Border, UIResource {
@Override
public Insets getBorderInsets(Component c) {
if (UIUtil.getParentOfType(ActionToolbar.class, c) != null) {
if (DarculaButtonUI.isComboButton((JComponent)c)) {
return JBUI.insets(2).asUIResource();
} else if (UIUtil.getParentOfType(ActionToolbar.class, c) != null) {
return JBUI.insets(4, 16, 4, 19).asUIResource();
} else if (isSquare(c)) {
return JBUI.insets(2).asUIResource();
@@ -106,11 +106,6 @@ public class WinIntelliJButtonUI extends DarculaButtonUI {
g2.dispose();
}
}
// Draw border for emptyBorder buttons
if (!(c.getBorder() instanceof WinIntelliJButtonBorder)) {
WinIntelliJButtonBorder.paint(c, g, 0, 0, c.getWidth(), c.getHeight());
}
}
@Override protected void modifyViewRect(AbstractButton b, Rectangle rect) {
@@ -18,6 +18,7 @@ package com.intellij.openapi.actionSystem.ex;
import com.intellij.openapi.actionSystem.ActionButtonComponent;
import com.intellij.openapi.actionSystem.impl.IdeaActionButtonLook;
import com.intellij.openapi.actionSystem.impl.Win10ActionButtonLook;
import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.UIUtil;
import javax.swing.*;
@@ -64,4 +65,8 @@ public abstract class ActionButtonLook {
public void paintIconAt(Graphics g, ActionButtonComponent button, Icon icon, int x, int y) {
icon.paintIcon(null, g, x, y);
}
public Insets getInsets() {
return JBUI.emptyInsets();
}
}
@@ -26,10 +26,7 @@ import com.intellij.openapi.actionSystem.ex.CustomComponentAction;
import com.intellij.openapi.application.impl.LaterInvocator;
import com.intellij.openapi.keymap.KeymapUtil;
import com.intellij.openapi.util.IconLoader;
import com.intellij.util.ui.EmptyIcon;
import com.intellij.util.ui.JBDimension;
import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.UIUtil;
import com.intellij.util.ui.*;
import com.intellij.util.ui.accessibility.ScreenReader;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -215,17 +212,26 @@ public class ActionButton extends JComponent implements ActionButtonComponent, A
super.setToolTipText(tooltipText.length() > 0 ? tooltipText : null);
}
public Dimension getPreferredSize() {
@Override public Insets getInsets() {
return myLook.getInsets();
}
@Override public Dimension getPreferredSize() {
Icon icon = getIcon();
if (icon.getIconWidth() < myMinimumButtonSize.width &&
icon.getIconHeight() < myMinimumButtonSize.height) {
return myMinimumButtonSize;
Dimension size = new Dimension(myMinimumButtonSize);
JBInsets.addTo(size, getInsets());
return size;
}
else {
return new Dimension(
Dimension size = new Dimension(
Math.max(myMinimumButtonSize.width, icon.getIconWidth() + myInsets.left + myInsets.right),
Math.max(myMinimumButtonSize.height, icon.getIconHeight() + myInsets.top + myInsets.bottom)
);
Math.max(myMinimumButtonSize.height, icon.getIconHeight() + myInsets.top + myInsets.bottom));
JBInsets.addTo(size, getInsets());
return size;
}
}
@@ -1320,7 +1320,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct
setOpaque(false);
} else {
if (UIUtil.isUnderWin10LookAndFeel()) {
setBorder(JBUI.Borders.empty(1));
setBorder(JBUI.Borders.empty(0));
setMinimumButtonSize(myDecorateButtons ? JBUI.size(30, 20) : JBUI.size(25, 22));
} else {
setBorder(JBUI.Borders.empty(2));
@@ -26,11 +26,13 @@ import java.awt.geom.Path2D;
import static com.intellij.openapi.actionSystem.ActionButtonComponent.*;
public class Win10ActionButtonLook extends ActionButtonLook {
@Override
public void paintBackground(Graphics g, JComponent component, int state) {
@Override public void paintBackground(Graphics g, JComponent component, int state) {
if (state != NORMAL) {
Rectangle rect = new Rectangle(component.getSize());
JBInsets.removeFrom(rect, component.getInsets());
g.setColor(getBackgroundColorForState(state));
g.fillRect(0, 0, component.getWidth(), component.getHeight());
g.fillRect(rect.x, rect.y, rect.width, rect.height);
}
}
@@ -46,14 +48,15 @@ public class Win10ActionButtonLook extends ActionButtonLook {
}
}
@Override
public void paintBorder(Graphics g, JComponent component, int state) {
@Override public void paintBorder(Graphics g, JComponent component, int state) {
if (state != NORMAL) {
Graphics2D g2 = (Graphics2D)g.create();
try {
g2.setColor(getBorderColorForState(state));
Rectangle outerRect = new Rectangle(component.getSize());
JBInsets.removeFrom(outerRect, component.getInsets());
Path2D border = new Path2D.Double(Path2D.WIND_EVEN_ODD);
border.append(outerRect, false);
@@ -68,6 +71,10 @@ public class Win10ActionButtonLook extends ActionButtonLook {
}
}
@Override public Insets getInsets() {
return JBUI.insets(1);
}
private static Color getBorderColorForState(int state) {
switch (state) {
case POPPED:
@@ -39,7 +39,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.PopupMenuEvent;
@@ -198,7 +197,6 @@ public class XFramesView extends XDebugView {
(ActionToolbarImpl)ActionManager.getInstance().createActionToolbar(ActionPlaces.DEBUGGER_TOOLBAR, framesGroup, true);
toolbar.setReservePlaceAutoPopupIcon(false);
toolbar.setAddSeparatorFirst(true);
toolbar.getComponent().setBorder(new EmptyBorder(1, 0, 0, 0));
return toolbar;
}