Browse Source

Pull request #13505: REPORT-107973 修改部分透明色按钮、弹窗边距、可折叠面板点击色

Merge in DESIGN/design from ~LEO.QIN/design:newui to newui

* commit 'f277e0984a6fc1f1d6a8dfed3e4632959ae31b8a':
  REPORT-107973 修改部分透明色按钮、弹窗边距、可折叠面板点击色
newui
Leo.Qin-覃宇攀 10 months ago
parent
commit
fffdd8b22c
  1. 55
      designer-base/src/main/java/com/fine/theme/light/ui/FineInputUI.java
  2. 2
      designer-base/src/main/java/com/fine/theme/utils/FineUIStyle.java
  3. 10
      designer-base/src/main/java/com/fr/design/data/datapane/management/search/pane/FineSearchPane.java
  4. 7
      designer-base/src/main/java/com/fr/design/foldablepane/HeaderPane.java
  5. 10
      designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java
  6. 6
      designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/BaseAccessibleEditor.java
  7. 8
      designer-base/src/main/java/com/fr/design/style/color/ColorControlWindow.java
  8. 10
      designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties
  9. 9
      designer-realize/src/main/java/com/fr/design/actions/cell/UIToolbarBorderButton.java

55
designer-base/src/main/java/com/fine/theme/light/ui/FineInputUI.java

@ -1,10 +1,8 @@
package com.fine.theme.light.ui; package com.fine.theme.light.ui;
import com.fine.theme.utils.FineUIUtils; import com.fine.theme.utils.FineUIUtils;
import com.formdev.flatlaf.ui.FlatButtonUI;
import com.formdev.flatlaf.ui.FlatPanelUI; import com.formdev.flatlaf.ui.FlatPanelUI;
import javax.swing.AbstractButton;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.UIManager; import javax.swing.UIManager;
@ -67,57 +65,4 @@ public class FineInputUI extends FlatPanelUI {
} }
} }
/**
* input输入框中的Button UI类
*
* @author Leo.Qin
* @since 11.0
* Created on 2023/12/12
*/
public static class FineInputButtonUI extends FlatButtonUI {
public FineInputButtonUI(boolean shared) {
super(shared);
}
/**
* 创建UI
*/
public static ComponentUI createUI(JComponent c) {
return new FineInputButtonUI(false);
}
@Override
public void installUI(JComponent c) {
super.installUI(c);
c.setBorder(null);
c.setOpaque(false);
}
@Override
protected void installDefaults(AbstractButton b) {
super.installDefaults(b);
hoverBackground = UIManager.getColor("InputButton.hoverBackground");
pressedBackground = UIManager.getColor("InputButton.pressedBackground");
background = UIManager.getColor("InputButton.background");
}
@Override
public void propertyChange(AbstractButton b, PropertyChangeEvent e) {
String propertyName = e.getPropertyName();
if (EDITABLE.equals(propertyName) || ENABLED.equals(propertyName)) {
updateBackground(b, e);
} else {
super.propertyChange(b, e);
}
}
private void updateBackground(AbstractButton b, PropertyChangeEvent e) {
if (e.getNewValue() == Boolean.FALSE) {
b.setBackground(UIManager.getColor("InputButton.disabledBackground"));
} else {
b.setBackground(UIManager.getColor("InputButton.background"));
}
}
}
} }

2
designer-base/src/main/java/com/fine/theme/utils/FineUIStyle.java

@ -31,6 +31,8 @@ public interface FineUIStyle {
String MENU_TOOL_BAR = "menuToolBar"; String MENU_TOOL_BAR = "menuToolBar";
String MENU_ITEM_TOOL_BAR = "menuItemToolBar"; String MENU_ITEM_TOOL_BAR = "menuItemToolBar";
String POPUP_MENU_TOOL_BAR = "popupMenuToolBar"; String POPUP_MENU_TOOL_BAR = "popupMenuToolBar";
String POPUP_MENU_DROPDOWN = "dropdownPopupMenu";
String TRANSPARENT_TEXT_FIELD = "transparentTextField";
/** /**

10
designer-base/src/main/java/com/fr/design/data/datapane/management/search/pane/FineSearchPane.java

@ -1,7 +1,6 @@
package com.fr.design.data.datapane.management.search.pane; package com.fr.design.data.datapane.management.search.pane;
import com.fine.theme.icon.LazyIcon; import com.fine.theme.icon.LazyIcon;
import com.fine.theme.light.ui.FineInputUI;
import com.fine.theme.utils.FineUIUtils; import com.fine.theme.utils.FineUIUtils;
import com.fr.design.event.HoverAware; import com.fr.design.event.HoverAware;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
@ -18,6 +17,10 @@ import java.awt.event.KeyListener;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import static com.fine.theme.utils.FineUIStyle.STYLE_TEXT;
import static com.fine.theme.utils.FineUIStyle.TRANSPARENT_TEXT_FIELD;
import static com.fine.theme.utils.FineUIStyle.setStyle;
/** /**
* 搜索面板 * 搜索面板
* *
@ -56,8 +59,7 @@ public class FineSearchPane extends JPanel implements HoverAware {
// 中间输入框 // 中间输入框
searchTextField = new UITextField(); searchTextField = new UITextField();
searchTextField.setBorder(null); setStyle(searchTextField, TRANSPARENT_TEXT_FIELD);
searchTextField.setOpaque(false);
searchTextField.addMouseListener(new MouseAdapter() { searchTextField.addMouseListener(new MouseAdapter() {
@Override @Override
public void mouseEntered(MouseEvent e) { public void mouseEntered(MouseEvent e) {
@ -74,7 +76,7 @@ public class FineSearchPane extends JPanel implements HoverAware {
// 右侧返回图标 // 右侧返回图标
clearButton = new UIButton(new LazyIcon("clear")); clearButton = new UIButton(new LazyIcon("clear"));
clearButton.setUI(new FineInputUI.FineInputButtonUI(false)); setStyle(clearButton, STYLE_TEXT);
Insets buttonInsets = FineUIUtils.getAndScaleUIInsets("SearchPanel.buttonBorderInsets", defaultButtonInsets); Insets buttonInsets = FineUIUtils.getAndScaleUIInsets("SearchPanel.buttonBorderInsets", defaultButtonInsets);
clearButton.setBorder(BorderFactory.createEmptyBorder(buttonInsets.top, buttonInsets.left, buttonInsets.bottom, buttonInsets.right)); clearButton.setBorder(BorderFactory.createEmptyBorder(buttonInsets.top, buttonInsets.left, buttonInsets.bottom, buttonInsets.right));

7
designer-base/src/main/java/com/fr/design/foldablepane/HeaderPane.java

@ -14,6 +14,7 @@ import java.awt.Font;
import java.awt.FontMetrics; import java.awt.FontMetrics;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Insets;
/** /**
* Created by MoMeak on 2017/7/5. * Created by MoMeak on 2017/7/5.
@ -48,7 +49,11 @@ public class HeaderPane extends JPanel {
protected void paintComponent(Graphics g) { protected void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g.create(); Graphics2D g2d = (Graphics2D) g.create();
g2d.setColor(getBackground()); g2d.setColor(getBackground());
g2d.fillRect(0, 0, this.getWidth(), this.getHeight()); if (isPressed) {
g2d.setColor(UIManager.getColor("Button.pressedBackground"));
}
Insets insets = this.getInsets();
g2d.fillRect(0, insets.top / 2, this.getWidth(), this.getHeight() - (insets.top + insets.bottom) / 2);
int iconY = (this.getHeight() - triangleDown.getIconHeight()) / 2; int iconY = (this.getHeight() - triangleDown.getIconHeight()) / 2;
if (this.isShow) { if (this.isShow) {

10
designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java

@ -1,8 +1,6 @@
package com.fr.design.gui.ispinner; package com.fr.design.gui.ispinner;
import com.fine.theme.icon.LazyIcon; import com.fine.theme.icon.LazyIcon;
import com.fine.theme.light.ui.FineInputUI;
import com.fine.theme.utils.FineUIScale;
import com.fine.theme.utils.FineUIUtils; import com.fine.theme.utils.FineUIUtils;
import com.fr.design.event.GlobalNameListener; import com.fr.design.event.GlobalNameListener;
import com.fr.design.event.GlobalNameObserver; import com.fr.design.event.GlobalNameObserver;
@ -17,7 +15,6 @@ import com.fr.stable.StringUtils;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
@ -36,6 +33,9 @@ import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent; import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener; import java.awt.event.MouseWheelListener;
import static com.fine.theme.utils.FineUIStyle.STYLE_TEXT;
import static com.fine.theme.utils.FineUIStyle.setStyle;
/** /**
* Spinner类 * Spinner类
* *
@ -239,7 +239,7 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver,
@Override @Override
public Dimension getPreferredSize() { public Dimension getPreferredSize() {
Dimension dim = super.getPreferredSize(); Dimension dim = super.getPreferredSize();
dim.height = FineUIScale.scale(UIManager.getInt("Input.height")); dim.height = FineUIUtils.getAndScaleInt("Input.height", defaultButtonSize);
return dim; return dim;
} }
@ -309,7 +309,7 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver,
return false; return false;
} }
}; };
arrowButton.setUI(new FineInputUI.FineInputButtonUI(false)); setStyle(arrowButton, STYLE_TEXT);
return arrowButton; return arrowButton;
} }

6
designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/BaseAccessibleEditor.java

@ -1,7 +1,6 @@
package com.fr.design.mainframe.widget.accessibles; package com.fr.design.mainframe.widget.accessibles;
import com.fine.theme.icon.LazyIcon; import com.fine.theme.icon.LazyIcon;
import com.fine.theme.light.ui.FineInputUI;
import com.fine.theme.utils.FineUIScale; import com.fine.theme.utils.FineUIScale;
import com.fine.theme.utils.FineUIUtils; import com.fine.theme.utils.FineUIUtils;
import com.fr.design.Exception.ValidationException; import com.fr.design.Exception.ValidationException;
@ -32,6 +31,9 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.ArrayList; import java.util.ArrayList;
import static com.fine.theme.utils.FineUIStyle.STYLE_TEXT;
import static com.fine.theme.utils.FineUIStyle.setStyle;
/** /**
* 编辑器 * 编辑器
* @author anonymous * @author anonymous
@ -126,7 +128,7 @@ public class BaseAccessibleEditor extends BasicPane implements AccessibleEditor,
if (showButton) { if (showButton) {
btPopup = new UIButton(); btPopup = new UIButton();
initPopupButton(); initPopupButton();
btPopup.setUI(new FineInputUI.FineInputButtonUI(false)); setStyle(btPopup, STYLE_TEXT);
btPopup.addActionListener(new ActionListener() { btPopup.addActionListener(new ActionListener() {
@Override @Override

8
designer-base/src/main/java/com/fr/design/style/color/ColorControlWindow.java

@ -9,6 +9,9 @@ import javax.swing.event.ChangeListener;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import static com.fine.theme.utils.FineUIStyle.POPUP_MENU_DROPDOWN;
import static com.fine.theme.utils.FineUIStyle.setStyle;
public abstract class ColorControlWindow extends JPopupMenu { public abstract class ColorControlWindow extends JPopupMenu {
private static final long serialVersionUID = 4317136753151221742L; private static final long serialVersionUID = 4317136753151221742L;
private PopupHider popupHider; private PopupHider popupHider;
@ -29,6 +32,7 @@ public abstract class ColorControlWindow extends JPopupMenu {
public ColorControlWindow(boolean isSupportTransparent, PopupHider popupHider) { public ColorControlWindow(boolean isSupportTransparent, PopupHider popupHider) {
this.initComponents(isSupportTransparent); this.initComponents(isSupportTransparent);
this.popupHider = popupHider; this.popupHider = popupHider;
setStyle(this, POPUP_MENU_DROPDOWN);
} }
public Color getColor() { public Color getColor() {
@ -53,10 +57,6 @@ public abstract class ColorControlWindow extends JPopupMenu {
setLightWeightPopupEnabled(JPopupMenu.getDefaultLightWeightPopupEnabled()); setLightWeightPopupEnabled(JPopupMenu.getDefaultLightWeightPopupEnabled());
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
setBorderPainted(false);
setOpaque(false);
setDoubleBuffered(true);
setFocusable(false);
initSelectionPopupPane(isSupportTransparent); initSelectionPopupPane(isSupportTransparent);
this.pack(); this.pack();
} }

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

@ -748,10 +748,6 @@ Spinner.editorBorderPainted = false
# allowed values: button or none # allowed values: button or none
Spinner.buttonStyle = button Spinner.buttonStyle = button
#---- Input ---- #---- Input ----
InputButton.background=$fill.normal
InputButton.hoverBackground=$fill.hover
InputButton.pressedBackground=$fill.click
InputButton.disabledBackground=$fill.disabled
InputButton.width=$Component.defaultHeight InputButton.width=$Component.defaultHeight
InputButton.height=$Component.defaultHeight InputButton.height=$Component.defaultHeight
InputTextField.borderInsets=0, 6, 0, 6 InputTextField.borderInsets=0, 6, 0, 6
@ -1281,6 +1277,12 @@ CellOtherSetPane.height=$Component.defaultHeight
acceleratorSelectionForeground : $text.white acceleratorSelectionForeground : $text.white
[style]PopupMenu.popupMenuToolBar=\ [style]PopupMenu.popupMenuToolBar=\
background: $fill.gray background: $fill.gray
[style]TextField.transparentTextField=\
background: fade(@background, 0%); \
border: null;
[style]PopupMenu.dropdownPopupMenu=\
background: fade(@background, 0%); \
borderInsets: 0,0,0,0;
#---- clearButton ---- #---- clearButton ----
# for clear/cancel button in text fields # for clear/cancel button in text fields

9
designer-realize/src/main/java/com/fr/design/actions/cell/UIToolbarBorderButton.java

@ -23,7 +23,6 @@ import javax.swing.JPanel;
import javax.swing.JPopupMenu; import javax.swing.JPopupMenu;
import javax.swing.JSeparator; import javax.swing.JSeparator;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import javax.swing.event.EventListenerList; import javax.swing.event.EventListenerList;
@ -33,6 +32,9 @@ import java.awt.GridLayout;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import static com.fine.theme.utils.FineUIStyle.POPUP_MENU_DROPDOWN;
import static com.fine.theme.utils.FineUIStyle.setStyle;
/** /**
* 这个Pane用来显示常用边框和设置自定义边框 * 这个Pane用来显示常用边框和设置自定义边框
* *
@ -127,11 +129,8 @@ public class UIToolbarBorderButton extends UICombinationButton implements PopupH
setLightWeightPopupEnabled(JPopupMenu.getDefaultLightWeightPopupEnabled()); setLightWeightPopupEnabled(JPopupMenu.getDefaultLightWeightPopupEnabled());
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
setBorderPainted(true);
setBorder(UIManager.getBorder("PopupMenu.border"));
setOpaque(false);
setDoubleBuffered(true);
setFocusable(false); setFocusable(false);
setStyle(this, POPUP_MENU_DROPDOWN);
this.add(new NormalBorderPane(isSupportTransparent, UIToolbarBorderButton.this), BorderLayout.CENTER); this.add(new NormalBorderPane(isSupportTransparent, UIToolbarBorderButton.this), BorderLayout.CENTER);
this.pack(); this.pack();

Loading…
Cancel
Save