status bar widgets: unify the padding between text and arrows

This commit is contained in:
Sergey Ignatov
2015-05-08 01:46:21 +03:00
parent bf866ac011
commit 6e937d1e56
4 changed files with 18 additions and 15 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -74,15 +74,16 @@ public class EncodingPanel extends EditorBasedWidget implements StatusBarWidget.
public EncodingPanel(@NotNull final Project project) {
super(project);
update = new Alarm(this);
myComponent = new TextPanel() {
myComponent = new TextPanel.PlusTwo() {
@Override
protected void paintComponent(@NotNull final Graphics g) {
super.paintComponent(g);
if (actionEnabled && getText() != null) {
final Rectangle r = getBounds();
final Insets insets = getInsets();
AllIcons.Ide.Statusbar_arrows.paintIcon(this, g, r.width - insets.right - AllIcons.Ide.Statusbar_arrows.getIconWidth() - 2,
r.height / 2 - AllIcons.Ide.Statusbar_arrows.getIconHeight() / 2);
Icon arrows = AllIcons.Ide.Statusbar_arrows;
arrows.paintIcon(this, g, r.width - insets.right - arrows.getIconWidth() - 2,
r.height / 2 - arrows.getIconHeight() / 2);
}
}
};
@@ -735,16 +735,10 @@ public class IdeStatusBarImpl extends JComponent implements StatusBarEx {
final Insets insets = getInsets();
Icon icon = AllIcons.Ide.Statusbar_arrows;
icon.paintIcon(this, g,
r.width - insets.right - icon.getIconWidth() - 2,
r.width - insets.right - icon.getIconWidth(),
r.height / 2 - icon.getIconHeight() / 2);
}
}
@Override
public Dimension getPreferredSize() {
final Dimension preferredSize = super.getPreferredSize();
return new Dimension(preferredSize.width + AllIcons.Ide.Statusbar_arrows.getIconWidth() + 4, preferredSize.height);
}
}
private static final class TextPresentationWrapper extends TextPanel implements StatusBarWrapper {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -61,15 +61,16 @@ public class LineSeparatorPanel extends EditorBasedWidget implements StatusBarWi
public LineSeparatorPanel(@NotNull final Project project) {
super(project);
myComponent = new TextPanel() {
myComponent = new TextPanel.PlusTwo() {
@Override
protected void paintComponent(@NotNull final Graphics g) {
super.paintComponent(g);
if (myActionEnabled && getText() != null) {
final Rectangle r = getBounds();
final Insets insets = getInsets();
AllIcons.Ide.Statusbar_arrows.paintIcon(this, g, r.width - insets.right - AllIcons.Ide.Statusbar_arrows.getIconWidth() - 2,
r.height / 2 - AllIcons.Ide.Statusbar_arrows.getIconHeight() / 2);
Icon arrows = AllIcons.Ide.Statusbar_arrows;
arrows.paintIcon(this, g, r.width - insets.right - arrows.getIconWidth() - 2,
r.height / 2 - arrows.getIconHeight() / 2);
}
}
};
@@ -233,4 +233,11 @@ public class TextPanel extends JComponent {
myIcon = icon;
}
}
public static class PlusTwo extends TextPanel {
public Dimension getPreferredSize() {
Dimension size = super.getPreferredSize();
return new Dimension(size.width + 2, size.height);
}
}
}