mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-149210 Rework IDE notifications
This commit is contained in:
+9
-8
@@ -594,7 +594,7 @@ public class NotificationsManagerImpl extends NotificationsManager {
|
||||
|
||||
if (title != null && layoutData.showActions != null && layoutData.showActions.compute()) {
|
||||
int width = layoutData.configuration.allActionsOffset;
|
||||
int x = getWidth() - width - 5;
|
||||
int x = getWidth() - width - JBUI.scale(5);
|
||||
int y = layoutData.configuration.topSpaceHeight;
|
||||
|
||||
int height = title instanceof JEditorPane ? getFirstLineHeight((JEditorPane)title) : title.getHeight();
|
||||
@@ -654,7 +654,7 @@ public class NotificationsManagerImpl extends NotificationsManager {
|
||||
|
||||
JPanel buttons = createButtons(notification, content, listener);
|
||||
if (buttons != null) {
|
||||
buttons.setBorder(new EmptyBorder(0, 0, 5, 7));
|
||||
buttons.setBorder(new EmptyBorder(0, 0, JBUI.scale(5), JBUI.scale(7)));
|
||||
}
|
||||
|
||||
if (buttons == null && !actions.isEmpty()) {
|
||||
@@ -727,7 +727,7 @@ public class NotificationsManagerImpl extends NotificationsManager {
|
||||
}
|
||||
}
|
||||
ActionPopupMenu menu = ActionManager.getInstance().createActionPopupMenu(ActionPlaces.UNKNOWN, group);
|
||||
menu.getComponent().show(link, -10, link.getHeight() + 2);
|
||||
menu.getComponent().show(link, JBUI.scale(-10), link.getHeight() + JBUI.scale(2));
|
||||
}
|
||||
});
|
||||
action.setVisible(false);
|
||||
@@ -780,6 +780,8 @@ public class NotificationsManagerImpl extends NotificationsManager {
|
||||
}
|
||||
|
||||
private static class DropDownAction extends LinkLabel<Void> {
|
||||
Icon myIcon = AllIcons.Ide.Notification.DropTriangle;
|
||||
|
||||
public DropDownAction(String text, @Nullable LinkListener<Void> listener) {
|
||||
super(text, null, listener);
|
||||
|
||||
@@ -789,19 +791,18 @@ public class NotificationsManagerImpl extends NotificationsManager {
|
||||
setIcon(new Icon() {
|
||||
@Override
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
Icon icon = AllIcons.Ide.Notification.DropTriangle;
|
||||
int lineY = getUI().getBaseline(DropDownAction.this, getWidth(), getHeight()) - icon.getIconHeight();
|
||||
IconUtil.colorize(icon, getTextColor()).paintIcon(c, g, x - 1, lineY);
|
||||
int lineY = getUI().getBaseline(DropDownAction.this, getWidth(), getHeight()) - getIconHeight();
|
||||
IconUtil.colorize(myIcon, getTextColor()).paintIcon(c, g, x - 1, lineY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconWidth() {
|
||||
return 16;
|
||||
return myIcon.getIconWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconHeight() {
|
||||
return 16;
|
||||
return myIcon.getIconHeight();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.ui;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.notification.Notification;
|
||||
import com.intellij.notification.impl.NotificationsManagerImpl;
|
||||
import com.intellij.util.ui.JBDimension;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -47,7 +48,7 @@ public class BalloonLayoutConfiguration {
|
||||
public static final int MaxWidth = JBUI.scale(350);
|
||||
public static final int MinWidth = JBUI.scale(100);
|
||||
|
||||
public static final int NotificationSpace = 10;
|
||||
public static final int NotificationSpace = JBUI.scale(10);
|
||||
|
||||
@NotNull
|
||||
public static BalloonLayoutConfiguration create(@NotNull Notification notification, @NotNull BalloonLayoutData layoutData) {
|
||||
@@ -65,12 +66,14 @@ public class BalloonLayoutConfiguration {
|
||||
|
||||
@NotNull
|
||||
private static BalloonLayoutConfiguration twoLines() {
|
||||
return new BalloonLayoutConfiguration(new Dimension(10, 11), 14, 8, 8, 8, 14).setName("twoLines");
|
||||
return new BalloonLayoutConfiguration(new JBDimension(10, 11),
|
||||
JBUI.scale(14), JBUI.scale(8), JBUI.scale(8), JBUI.scale(8), JBUI.scale(14));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static BalloonLayoutConfiguration treeLines() {
|
||||
return new BalloonLayoutConfiguration(new Dimension(10, 7), 10, 6, 10, 0, 8).setName("treeLines");
|
||||
return new BalloonLayoutConfiguration(new JBDimension(10, 7),
|
||||
JBUI.scale(10), JBUI.scale(6), JBUI.scale(10), 0, JBUI.scale(8));
|
||||
}
|
||||
|
||||
private BalloonLayoutConfiguration(@NotNull Dimension iconOffset,
|
||||
@@ -79,10 +82,10 @@ public class BalloonLayoutConfiguration {
|
||||
int contentActionsSpaceHeight,
|
||||
int titleActionsSpaceHeight,
|
||||
int bottomSpaceHeight) {
|
||||
this(32, iconOffset,
|
||||
this(JBUI.scale(32), iconOffset,
|
||||
topSpaceHeight, titleContentSpaceHeight, contentActionsSpaceHeight, titleActionsSpaceHeight, bottomSpaceHeight,
|
||||
16,
|
||||
new Dimension(8, 6), 7, 5, 15);
|
||||
JBUI.scale(16),
|
||||
new JBDimension(8, 6), JBUI.scale(7), JBUI.scale(5), JBUI.scale(15));
|
||||
}
|
||||
|
||||
private BalloonLayoutConfiguration(int iconPanelWidth,
|
||||
@@ -112,16 +115,4 @@ public class BalloonLayoutConfiguration {
|
||||
this.allActionsOffset = closeOffset + afterGearSpace + AllIcons.Ide.Notification.Gear.getIconWidth();
|
||||
this.beforeGearSpace = beforeGearSpace;
|
||||
}
|
||||
|
||||
private String myName;
|
||||
|
||||
public BalloonLayoutConfiguration setName(String name) {
|
||||
myName = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return myName;
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import com.intellij.notification.impl.NotificationsConfigurationImpl;
|
||||
import com.intellij.openapi.options.ShowSettingsUtil;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.ui.JBRectangle;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -44,6 +45,8 @@ public class NotificationBalloonActionProvider implements BalloonImpl.ActionProv
|
||||
private final BalloonImpl.ActionButton myCloseButton;
|
||||
private final List<BalloonImpl.ActionButton> myActions = new ArrayList<BalloonImpl.ActionButton>();
|
||||
|
||||
private static final Rectangle CloseHoverBounds = new JBRectangle(5, 5, 12, 10);
|
||||
|
||||
public NotificationBalloonActionProvider(@NotNull BalloonImpl balloon,
|
||||
@Nullable Component repaintPanel,
|
||||
@NotNull BalloonLayoutData layoutData,
|
||||
@@ -116,7 +119,12 @@ public class NotificationBalloonActionProvider implements BalloonImpl.ActionProv
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}) {
|
||||
@Override
|
||||
protected void paintIcon(@NotNull Graphics g, @NotNull Icon icon) {
|
||||
icon.paintIcon(this, g, CloseHoverBounds.x, CloseHoverBounds.y);
|
||||
}
|
||||
};
|
||||
myActions.add(myCloseButton);
|
||||
}
|
||||
|
||||
@@ -132,7 +140,8 @@ public class NotificationBalloonActionProvider implements BalloonImpl.ActionProv
|
||||
Insets borderInsets = myBalloon.getShadowBorderInsets();
|
||||
int x = bounds.x + bounds.width - borderInsets.right - closeSize.width - myLayoutData.configuration.rightActionsOffset.width;
|
||||
int y = bounds.y + borderInsets.top + myLayoutData.configuration.rightActionsOffset.height;
|
||||
myCloseButton.setBounds(x, y, closeSize.width, closeSize.height);
|
||||
myCloseButton.setBounds(x - CloseHoverBounds.x, y - CloseHoverBounds.y,
|
||||
closeSize.width + CloseHoverBounds.width, closeSize.height + CloseHoverBounds.height);
|
||||
|
||||
if (mySettingButton != null) {
|
||||
Dimension size = mySettingButton.getPreferredSize();
|
||||
|
||||
+2
-1
@@ -16,6 +16,7 @@
|
||||
package com.intellij.ui;
|
||||
|
||||
import com.intellij.icons.AllIcons.Ide.Notification.Shadow;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -27,7 +28,7 @@ import java.awt.geom.RoundRectangle2D;
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public class NotificationBalloonShadowBorderProvider implements BalloonImpl.ShadowBorderProvider {
|
||||
private static final Insets INSETS = new Insets(4, 6, 8, 6);
|
||||
private static final Insets INSETS = new JBInsets(4, 6, 8, 6);
|
||||
private final Color myFillColor;
|
||||
private final Color myBorderColor;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user