From e499e39b623deececd44a7c6cd559a367515c0c7 Mon Sep 17 00:00:00 2001 From: Vassiliy Kudryashov Date: Thu, 27 Sep 2012 15:55:00 +0400 Subject: [PATCH] IDEA-92112 Antialising issue on `Before launch` component --- .../src/com/intellij/ide/ui/laf/IdeaLaf.java | 1 + .../src/com/intellij/ui/DropDownPanel.java | 4 +- .../com/intellij/ui/plaf/beg/BegButtonUI.java | 21 ---------- .../ui/plaf/beg/BegToggleButtonUI.java | 40 +++++++++++++++++++ 4 files changed, 43 insertions(+), 23 deletions(-) create mode 100644 platform/platform-impl/src/com/intellij/ui/plaf/beg/BegToggleButtonUI.java diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/IdeaLaf.java b/platform/platform-impl/src/com/intellij/ide/ui/laf/IdeaLaf.java index a90ea276869a..110de5a78f96 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/laf/IdeaLaf.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/IdeaLaf.java @@ -59,6 +59,7 @@ public final class IdeaLaf extends MetalLookAndFeel { defaults.put("ScrollPane.border", BegBorders.getScrollPaneBorder()); defaults.put("ButtonUI", BegButtonUI.class.getName()); + defaults.put("ToggleButtonUI", BegToggleButtonUI.class.getName()); defaults.put("ComboBoxUI", BegComboBoxUI.class.getName()); defaults.put("RadioButtonUI", BegRadioButtonUI.class.getName()); defaults.put("CheckBoxUI", BegCheckBoxUI.class.getName()); diff --git a/platform/platform-impl/src/com/intellij/ui/DropDownPanel.java b/platform/platform-impl/src/com/intellij/ui/DropDownPanel.java index 8a40c780924f..52291f81f2d2 100644 --- a/platform/platform-impl/src/com/intellij/ui/DropDownPanel.java +++ b/platform/platform-impl/src/com/intellij/ui/DropDownPanel.java @@ -142,8 +142,8 @@ public class DropDownPanel extends JPanel { myButton.setSelectedIcon(ICONS[1]); myButton.setBorderPainted(false); myButton.setContentAreaFilled(false); - myButton.setFocusPainted(true); - myButton.setMargin(new Insets(0,0,0,0)); + myButton.setFocusPainted(false); + myButton.setMargin(new Insets(0, 0, 0, 0)); setLayout(new MigLayout("fill, ins 0 0 0 5, gap 2, align left")); add(myButton); add(new JSeparator(), "pushx, growx"); diff --git a/platform/platform-impl/src/com/intellij/ui/plaf/beg/BegButtonUI.java b/platform/platform-impl/src/com/intellij/ui/plaf/beg/BegButtonUI.java index 6816064f56e2..8c1683fbcae3 100644 --- a/platform/platform-impl/src/com/intellij/ui/plaf/beg/BegButtonUI.java +++ b/platform/platform-impl/src/com/intellij/ui/plaf/beg/BegButtonUI.java @@ -89,27 +89,6 @@ public class BegButtonUI extends MetalButtonUI { } protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect, Rectangle textRect, Rectangle iconRect) { - Rectangle focusRect = new Rectangle(); - String text = b.getText(); - boolean isIcon = b.getIcon() != null; - - // If there is text - if (text != null && !text.equals("")){ - if (!isIcon){ - focusRect.setBounds(textRect); - } - else{ - focusRect.setBounds(iconRect.union(textRect)); - } - } - // If there is an icon and no text - else - if (isIcon){ - focusRect.setBounds(iconRect); - } - - g.setColor(getFocusColor()); -// g.drawRect(focusRect.x - 1, focusRect.y - 1, focusRect.width + 1, focusRect.height + 1); UIUtil.drawDottedRectangle(g, viewRect.x, viewRect.y, viewRect.x + viewRect.width, viewRect.y + viewRect.height); } } diff --git a/platform/platform-impl/src/com/intellij/ui/plaf/beg/BegToggleButtonUI.java b/platform/platform-impl/src/com/intellij/ui/plaf/beg/BegToggleButtonUI.java new file mode 100644 index 000000000000..2c6461804692 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/ui/plaf/beg/BegToggleButtonUI.java @@ -0,0 +1,40 @@ +/* + * 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.ui.plaf.beg; + +import com.intellij.util.ui.UIUtil; + +import javax.swing.*; +import javax.swing.plaf.ComponentUI; +import javax.swing.plaf.metal.MetalToggleButtonUI; +import java.awt.*; + +/** + * User: Vassiliy.Kudryashov + */ +public class BegToggleButtonUI extends MetalToggleButtonUI{ + private final static BegToggleButtonUI begToggleButtonUI = new BegToggleButtonUI(); + + public static ComponentUI createUI(JComponent c) { + return begToggleButtonUI; + } + + @Override + protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect, Rectangle textRect, Rectangle iconRect) { + g.setColor(getFocusColor()); + UIUtil.drawDottedRectangle(g, viewRect.x, viewRect.y, viewRect.x + viewRect.width, viewRect.y + viewRect.height); + } +}