mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[spleaner] memory indicator polishing on non-mac systems
This commit is contained in:
@@ -36,6 +36,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.wm.CustomStatusBarWidget;
|
||||
import com.intellij.openapi.wm.StatusBar;
|
||||
import com.intellij.openapi.wm.StatusBarCustomComponentFactory;
|
||||
@@ -50,7 +51,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -259,6 +259,9 @@ public class IdeRootPane extends JRootPane implements UISettingsListener {
|
||||
void setMemoryIndicatorVisible(final boolean visible) {
|
||||
if (myMemoryWidget != null) {
|
||||
myMemoryWidget.setShowing(visible);
|
||||
if (!SystemInfo.isMac) {
|
||||
myStatusBar.setBorder(BorderFactory.createEmptyBorder(1, 4, 0, visible ? 0 : 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -83,7 +83,7 @@ public class IdeStatusBarImpl extends JComponent implements StatusBarEx {
|
||||
|
||||
public IdeStatusBarImpl() {
|
||||
setLayout(new BorderLayout());
|
||||
setBorder(BorderFactory.createEmptyBorder(1, 4, 0, 2));
|
||||
setBorder(BorderFactory.createEmptyBorder(1, 4, 0, SystemInfo.isMac ? 2 : 0));
|
||||
|
||||
myInfoAndProgressPanel = new InfoAndProgressPanel();
|
||||
addWidget(myInfoAndProgressPanel, Position.CENTER);
|
||||
|
||||
+11
-7
@@ -107,11 +107,11 @@ public class MemoryUsagePanel extends JButton implements CustomStatusBarWidget {
|
||||
final long maxMemory = runtime.maxMemory();
|
||||
final long freeMemory = maxMemory - runtime.totalMemory() + runtime.freeMemory();
|
||||
|
||||
final Insets insets = getInsets();
|
||||
final Insets insets = SystemInfo.isMac ? getInsets() : new Insets(0, 0, 0, 0);
|
||||
|
||||
final int totalBarLength = size.width - insets.left - insets.right - (SystemInfo.isMac ? 0 : 0);
|
||||
final int usedBarLength = totalBarLength - (int)(totalBarLength * freeMemory / maxMemory);
|
||||
final int barHeight = HEIGHT; // size.height - insets.top - insets.bottom;
|
||||
final int barHeight = SystemInfo.isMac ? HEIGHT : size.height - insets.top - insets.bottom;
|
||||
final Graphics2D g2 = (Graphics2D)g;
|
||||
|
||||
final int yOffset = (size.height - barHeight) / 2;
|
||||
@@ -129,12 +129,16 @@ public class MemoryUsagePanel extends JButton implements CustomStatusBarWidget {
|
||||
g2.setPaint(new GradientPaint(1, 1, new Color(175, 185, 202), 0, size.height - 2, new Color(126, 138, 168)));
|
||||
g2.fillRect(xOffset + 1, yOffset, usedBarLength, barHeight);
|
||||
|
||||
g2.setColor(new Color(194, 197, 203));
|
||||
g2.drawLine(xOffset + 1, yOffset+1, xOffset + usedBarLength, yOffset+1);
|
||||
if (SystemInfo.isMac) {
|
||||
g2.setColor(new Color(194, 197, 203));
|
||||
g2.drawLine(xOffset + 1, yOffset+1, xOffset + usedBarLength, yOffset+1);
|
||||
}
|
||||
}
|
||||
|
||||
g2.setColor(new Color(110, 110, 110));
|
||||
g2.drawRect(xOffset, yOffset, totalBarLength, barHeight - 1);
|
||||
if (SystemInfo.isMac) {
|
||||
g2.setColor(new Color(110, 110, 110));
|
||||
g2.drawRect(xOffset, yOffset, totalBarLength, barHeight - 1);
|
||||
}
|
||||
|
||||
g.setFont(getFont());
|
||||
final long used = (maxMemory - freeMemory) / MEGABYTE;
|
||||
@@ -151,7 +155,7 @@ public class MemoryUsagePanel extends JButton implements CustomStatusBarWidget {
|
||||
|
||||
public final int getPreferredWidth() {
|
||||
final Insets insets = getInsets();
|
||||
return getFontMetrics(UIUtil.getLabelFont().deriveFont(11.0f)).stringWidth(SAMPLE_STRING) + insets.left + insets.right + (SystemInfo.isMac ? 2 : 0);
|
||||
return getFontMetrics(SystemInfo.isMac ? UIUtil.getLabelFont().deriveFont(11.0f) : UIUtil.getLabelFont()).stringWidth(SAMPLE_STRING) + insets.left + insets.right + (SystemInfo.isMac ? 2 : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user