mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 03:21:12 +07:00
IDEA-270929 Rework UI for alerts messages: close button
GitOrigin-RevId: cf13c6d9a73e4126a6d6f878165d7e25797f07d8
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b9ddc5a07d
commit
9826742350
@@ -17,14 +17,14 @@ import com.intellij.ui.components.panels.HorizontalLayout
|
||||
import com.intellij.ui.components.panels.Wrapper
|
||||
import com.intellij.ui.mac.MacMessages
|
||||
import com.intellij.ui.mac.TouchbarDataKeys
|
||||
import com.intellij.util.ui.JBFont
|
||||
import com.intellij.util.ui.JBUI
|
||||
import com.intellij.util.ui.UIUtil
|
||||
import com.intellij.ui.scale.JBUIScale
|
||||
import com.intellij.util.ui.*
|
||||
import com.intellij.util.ui.UIUtil.JBWordWrapHtmlEditorKit
|
||||
import org.jetbrains.annotations.Nls
|
||||
import java.awt.*
|
||||
import java.awt.event.ActionEvent
|
||||
import java.awt.event.MouseEvent
|
||||
import java.awt.geom.RoundRectangle2D
|
||||
import javax.accessibility.AccessibleContext
|
||||
import javax.swing.*
|
||||
import javax.swing.border.Border
|
||||
@@ -165,9 +165,29 @@ private class AlertDialog(project: Project?,
|
||||
setDoNotAskOption(doNotAskOption)
|
||||
|
||||
if (myIsTitleComponent && !SystemInfoRt.isMac) {
|
||||
myCloseButton = InplaceButton(IconButton(null, AllIcons.Ide.Notification.Close, AllIcons.Ide.Notification.CloseHover, null)) {
|
||||
myCloseButton = object : InplaceButton(IconButton(null, AllIcons.Windows.CloseActive, null, null), {
|
||||
doCancelAction()
|
||||
}) {
|
||||
override fun paintHover(g: Graphics) {
|
||||
val g2 = g.create() as Graphics2D
|
||||
|
||||
try {
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)
|
||||
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE)
|
||||
g2.color = JBUI.CurrentTheme.ActionButton.hoverBorder()
|
||||
|
||||
val rect = Rectangle(size)
|
||||
JBInsets.removeFrom(rect, insets)
|
||||
|
||||
val arc = JBUIScale.scale(JBUI.getInt("Button.arc", 6).toFloat())
|
||||
g2.fill(RoundRectangle2D.Float(rect.x.toFloat(), rect.y.toFloat(), rect.width.toFloat(), rect.height.toFloat(), arc, arc))
|
||||
}
|
||||
finally {
|
||||
g2.dispose()
|
||||
}
|
||||
}
|
||||
}
|
||||
myCloseButton.preferredSize = JBDimension(22, 22)
|
||||
}
|
||||
else {
|
||||
myCloseButton = null
|
||||
@@ -299,7 +319,7 @@ private class AlertDialog(project: Project?,
|
||||
super.layoutContainer(target)
|
||||
|
||||
if (myCloseButton != null) {
|
||||
val offset = JBUI.scale(20)
|
||||
val offset = JBUI.scale(24)
|
||||
val size = myCloseButton.preferredSize
|
||||
myCloseButton.setBounds(target.width - offset, offset - size.height, size.width, size.height)
|
||||
}
|
||||
|
||||
@@ -178,6 +178,7 @@ public class InplaceButton extends JComponent implements ActiveComponent, Access
|
||||
|
||||
|
||||
if ((myBehavior.isHovered() && myHoveringEnabled) || hasFocus()) {
|
||||
paintHover(g);
|
||||
if (myBehavior.isPressedByMouse()) {
|
||||
myHovered.paintIcon(this, g, 1, 1);
|
||||
}
|
||||
@@ -197,6 +198,9 @@ public class InplaceButton extends JComponent implements ActiveComponent, Access
|
||||
g.translate(0, 0);
|
||||
}
|
||||
|
||||
protected void paintHover(Graphics g) {
|
||||
}
|
||||
|
||||
public void setTransform(int x, int y) {
|
||||
myXTransform = x;
|
||||
myYTransform = y;
|
||||
|
||||
Reference in New Issue
Block a user