Browse Source

REPORT-107973 弹窗样式翻新

newui
Leo.Qin 1 year ago
parent
commit
2cd30a5684
  1. 19
      designer-base/src/main/java/com/fine/theme/light/ui/FinePopupMenuBorder.java
  2. 57
      designer-base/src/main/java/com/fine/theme/light/ui/FinePopupMenuUI.java
  3. 9
      designer-base/src/main/java/com/fine/theme/light/ui/FineTooltipUI.java
  4. 8
      designer-base/src/main/java/com/fine/theme/light/ui/laf/FineLaf.java
  5. 17
      designer-base/src/main/java/com/fr/design/gui/imenu/UIPopupEastAttrMenu.java
  6. 31
      designer-base/src/main/java/com/fr/design/gui/imenu/UIPopupMenu.java
  7. 2
      designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLaf.properties
  8. 10
      designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties
  9. 1
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/local/GroupPane.java

19
designer-base/src/main/java/com/fine/theme/light/ui/FinePopupMenuBorder.java

@ -0,0 +1,19 @@
package com.fine.theme.light.ui;
import com.fine.theme.utils.FineUIUtils;
import com.formdev.flatlaf.ui.FlatPopupMenuBorder;
/**
* PopupMenu Border类
*
* @author Leo.Qin
* @since 11.0
* Created on 2023/12/25
*/
public class FinePopupMenuBorder extends FlatPopupMenuBorder {
@Override
public int getArc() {
return FineUIUtils.getAndScaleInt("PopupMenu.arc", 5);
}
}

57
designer-base/src/main/java/com/fine/theme/light/ui/FinePopupMenuUI.java

@ -0,0 +1,57 @@
package com.fine.theme.light.ui;
import com.fine.theme.utils.FineUIUtils;
import com.formdev.flatlaf.ui.FlatPopupMenuUI;
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.RoundRectangle2D;
/**
* PopupMenu UI类
*
* @author Leo.Qin
* @since 11.0
* Created on 2023/12/25
*/
public class FinePopupMenuUI extends FlatPopupMenuUI {
private int arc;
private final int DEFAULT_ARC = 5;
/**
* 创建UI
*
* @param c 组件
* @return UI
*/
public static ComponentUI createUI(JComponent c) {
return new FinePopupMenuUI();
}
@Override
public void installDefaults() {
super.installDefaults();
arc = FineUIUtils.getAndScaleInt("PopupMenu.arc", DEFAULT_ARC);
}
@Override
public void paint(Graphics g, JComponent c) {
// 绘制圆角矩形作为弹窗背景
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
RoundRectangle2D roundRect = new RoundRectangle2D.Double(0, 0, c.getWidth(), c.getHeight(), arc, arc);
g2d.setColor(c.getBackground());
g2d.fill(roundRect);
// 绘制组件内容
super.paint(g, c);
}
@Override
public void update(Graphics g, JComponent c) {
paint(g, c);
}
}

9
designer-base/src/main/java/com/fine/theme/light/ui/FineTooltipUI.java

@ -9,13 +9,13 @@ import com.fr.stable.Constants;
import javax.swing.JComponent;
import javax.swing.JToolTip;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.RenderingHints;
import java.util.List;
/**
@ -39,9 +39,11 @@ public class FineTooltipUI extends FlatToolTipUI {
@Override
public void paint(Graphics g, JComponent c) {
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setColor(c.getBackground());
g.fillRoundRect(0, 0, c.getWidth(), c.getHeight(), arc, arc);
g2d.setColor(c.getBackground());
g2d.fillRoundRect(0, 0, c.getWidth(), c.getHeight(), arc, arc);
String text = ((JToolTip) c).getTipText();
if (text == null || text.isEmpty()) {
@ -49,7 +51,6 @@ public class FineTooltipUI extends FlatToolTipUI {
}
Insets insets = c.getInsets();
Graphics2D g2d = (Graphics2D) g;
FontMetrics fm = g2d.getFontMetrics();
int x = insets.left;

8
designer-base/src/main/java/com/fine/theme/light/ui/laf/FineLaf.java

@ -2,6 +2,8 @@ package com.fine.theme.light.ui.laf;
import com.formdev.flatlaf.FlatLaf;
import javax.swing.PopupFactory;
/**
* Fine designer new look and feel
* FineLaf.properties 定义公共属性如UI等
@ -25,4 +27,10 @@ public abstract class FineLaf extends FlatLaf {
public String getDescription() {
return "Fine New Look and Feel";
}
@Override
public void initialize() {
super.initialize();
PopupFactory.setSharedInstance(new PopupFactory());
}
}

17
designer-base/src/main/java/com/fr/design/gui/imenu/UIPopupEastAttrMenu.java

@ -1,28 +1,11 @@
package com.fr.design.gui.imenu;
import java.awt.Graphics;
import java.awt.Insets;
import javax.swing.JPopupMenu;
import com.fr.design.constants.UIConstants;
public class UIPopupEastAttrMenu extends JPopupMenu {
public UIPopupEastAttrMenu() {
super();
setBackground(UIConstants.NORMAL_BACKGROUND);
}
@Override
protected void paintBorder(Graphics g) {
g.setColor(UIConstants.POP_DIALOG_BORDER);
g.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
}
@Override
public Insets getInsets() {
return new Insets(0, 1, 1, 1);
}
}

31
designer-base/src/main/java/com/fr/design/gui/imenu/UIPopupMenu.java

@ -1,11 +1,6 @@
package com.fr.design.gui.imenu;
import com.fr.design.constants.UIConstants;
import javax.swing.JPopupMenu;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
public class UIPopupMenu extends JPopupMenu{
private static final float DEFAULT_REC = 8f;
@ -15,32 +10,6 @@ public class UIPopupMenu extends JPopupMenu{
public static UIPopupMenu EMPTY = new UIPopupMenu();
public UIPopupMenu() {
super();
// setBackground(UIConstants.NORMAL_BACKGROUND);
}
@Override
protected void paintComponent(Graphics g) {
// Graphics2D g2d = (Graphics2D) g;
// Shape shape = new RoundRectangle2D.Double(0, 0, getWidth(), getHeight(), rec, rec);
// g2d.setClip(shape);
// g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
super.paintComponent(g);
}
@Override
protected void paintBorder(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
g2d.setColor(UIConstants.UIPOPUPMENU_LINE_COLOR);
// g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.drawRoundRect(0, 0, getWidth() - 1, getHeight() - 1, (int) rec, (int) rec);
}
@Override
public Insets getInsets() {
if(onlyText) {
return super.getInsets();
}
return new Insets(10, 2, 10, 10);
}
public void setOnlyText(boolean onlyText) {

2
designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLaf.properties

@ -19,7 +19,7 @@ MenuItemUI=com.formdev.flatlaf.ui.FlatMenuItemUI
OptionPaneUI=com.formdev.flatlaf.ui.FlatOptionPaneUI
PanelUI=com.formdev.flatlaf.ui.FlatPanelUI
PasswordFieldUI=com.formdev.flatlaf.ui.FlatPasswordFieldUI
PopupMenuUI=com.formdev.flatlaf.ui.FlatPopupMenuUI
PopupMenuUI=com.fine.theme.light.ui.FinePopupMenuUI
PopupMenuSeparatorUI=com.formdev.flatlaf.ui.FlatPopupMenuSeparatorUI
ProgressBarUI=com.formdev.flatlaf.ui.FlatProgressBarUI
RadioButtonUI=com.formdev.flatlaf.ui.FlatRadioButtonUI

10
designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties

@ -547,14 +547,14 @@ PopupToolPane.height=34
PopupToolPane.borderInsets=0, 10, 0, 10
#---- PopupMenu ----
PopupMenu.border = com.formdev.flatlaf.ui.FlatPopupMenuBorder
PopupMenu.borderInsets = 4,1,4,1
PopupMenu.border=com.fine.theme.light.ui.FinePopupMenuBorder
PopupMenu.borderInsets=10,0,10,0
PopupMenu.borderCornerRadius = $Popup.borderCornerRadius
PopupMenu.background = @menuBackground
PopupMenu.background=$background.normal
PopupMenu.scrollArrowColor = @buttonArrowColor
PopupMenu.borderColor = shade(@background,28%)
PopupMenu.borderColor=$border.divider
PopupMenu.hoverScrollArrowBackground = darken(@background,5%)
PopupMenu.arc=$Component.arc
#---- PopupMenuSeparator ----

1
designer-form/src/main/java/com/fr/design/mainframe/share/ui/local/GroupPane.java

@ -289,7 +289,6 @@ public class GroupPane extends JPanel {
public void mouseClicked(MouseEvent e) {
UIPopupMenu popupMenu = new UIPopupMenu();
popupMenu.setOnlyText(true);
popupMenu.setBackground(UIConstants.DEFAULT_BG_RULER);
popupMenu.add(new PopupMenuItem(new RenameAction()));
popupMenu.add(new PopupMenuItem(new RemoveAction()));

Loading…
Cancel
Save