Browse Source

REPORT-107973 主页及组件视觉样式翻新

【问题原因】rt
【改动思路】tooltip翻新
newui
Leo.Qin 12 months ago
parent
commit
cc40bb82e8
  1. 97
      designer-base/src/main/java/com/fine/theme/light/ui/FineTooltipUI.java
  2. 41
      designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties

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

@ -0,0 +1,97 @@
package com.fine.theme.light.ui;
import com.formdev.flatlaf.ui.FlatToolTipUI;
import com.formdev.flatlaf.ui.FlatUIUtils;
import com.fr.base.BaseUtils;
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.util.List;
/**
* ToolTip UI类
*
* @author Leo.Qin
* @since 11.0
* Created on 2023/12/8
*/
public class FineTooltipUI extends FlatToolTipUI {
private int maxWidth;
private int arc;
private List<String> lines;
/**
* 创建UI
*/
public static ComponentUI createUI(JComponent c) {
return FlatUIUtils.createSharedUI(FineTooltipUI.class, FineTooltipUI::new);
}
@Override
public void paint(Graphics g, JComponent c) {
g.setColor(c.getBackground());
g.fillRoundRect(0, 0, c.getWidth(), c.getHeight(), arc, arc);
String text = ((JToolTip) c).getTipText();
if (text == null || text.isEmpty()) {
return;
}
Insets insets = c.getInsets();
Graphics2D g2d = (Graphics2D) g;
FontMetrics fm = g2d.getFontMetrics();
int x = insets.left;
int y = insets.top + fm.getAscent();
g2d.setColor(c.getForeground());
for (String line : lines) {
g2d.drawString(line, x, y);
y += fm.getHeight();
}
}
@Override
protected void installDefaults(JComponent c) {
super.installDefaults(c);
c.setOpaque(false);
arc = UIManager.getInt("ToolTip.arc");
maxWidth = UIManager.getInt("ToolTip.maxWidth");
}
@Override
public Dimension getPreferredSize(JComponent c) {
String text = ((JToolTip) c).getTipText();
if (text == null || text.isEmpty()) {
return new Dimension();
}
Insets insets = c.getInsets();
int fontWidth = this.maxWidth - insets.left - insets.right;
lines = BaseUtils.getLineTextList(text, null, null, fontWidth, Constants.FR_PAINT_RESOLUTION);
FontMetrics fm = c.getFontMetrics(c.getFont());
int width = 0;
int height = fm.getHeight() * Math.max(lines.size(), 1);
for (String line : lines) {
width = Math.max(width, SwingUtilities.computeStringWidth(fm, line));
}
return new Dimension(insets.left + width + insets.right, insets.top + height + insets.bottom);
}
}

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

@ -83,13 +83,14 @@ TextPaneUI = com.formdev.flatlaf.ui.FlatTextPaneUI
ToggleButtonUI = com.fine.theme.light.ui.FineToggleButtonUI ToggleButtonUI = com.fine.theme.light.ui.FineToggleButtonUI
ToolBarUI = com.formdev.flatlaf.ui.FlatToolBarUI ToolBarUI = com.formdev.flatlaf.ui.FlatToolBarUI
ToolBarSeparatorUI = com.formdev.flatlaf.ui.FlatToolBarSeparatorUI ToolBarSeparatorUI = com.formdev.flatlaf.ui.FlatToolBarSeparatorUI
ToolTipUI = com.formdev.flatlaf.ui.FlatToolTipUI ToolTipUI=com.fine.theme.light.ui.FineTooltipUI
TreeUI = com.fine.theme.light.ui.UIFlatTreeUI TreeUI = com.fine.theme.light.ui.UIFlatTreeUI
ViewportUI = com.formdev.flatlaf.ui.FlatViewportUI ViewportUI = com.formdev.flatlaf.ui.FlatViewportUI
#---- variables ---- #---- variables ----
Component.defaultHeight=24 Component.defaultHeight=24
Component.defaultVGap=10
# general background and foreground (text color) # general background and foreground (text color)
@background = #F6F8FA @background = #F6F8FA
@ -162,13 +163,18 @@ defaultHighlightBorderColor = #2576EF
defaultBorderFocusShadow = #2576ef19 defaultBorderFocusShadow = #2576ef19
defaultBorderFocusWidth = 0 defaultBorderFocusWidth = 0
brand.normal=#2576EF brand.normal=#2576EF
color.brand4=#84B1F6
background.normal=#FFFFFF background.normal=#FFFFFF
text.white=#ffffff text.white=#ffffff
text.placeholder=fade(@foreground, 40%) text.placeholder=fade(@foreground, 40%)
text.highlight=fade(@foreground, 90%) text.highlight=fade(@foreground, 90%)
fill.hover=#E6E9EF fill.hover=#E6E9EF
fill.click=#DADEE7
fill.normal=#FFFFFF fill.normal=#FFFFFF
fill.disabled=#F2F4F8
border.divider=#DADEE7 border.divider=#DADEE7
tooltip.normal=#3F506A
tooltip.disabled=#A3ADBD
#---- Button ---- #---- Button ----
@ -362,7 +368,9 @@ DesktopIcon.closeIcon = com.formdev.flatlaf.icons.FlatInternalFrameCloseIcon
EditorPane.border = com.formdev.flatlaf.ui.FlatMarginBorder EditorPane.border = com.formdev.flatlaf.ui.FlatMarginBorder
EditorPane.margin = @componentMargin EditorPane.margin = @componentMargin
EditorPane.background = @componentBackground EditorPane.background = @componentBackground
DataBindingEditor.vgap=$Component.defaultVGap
DataBindingEditor.hgap=1
DataBindingEditor.height=$Component.defaultHeight
#---- FileChooser ---- #---- FileChooser ----
@ -390,6 +398,7 @@ FileView.fullRowSelection = true
FormattedTextField.border = com.formdev.flatlaf.ui.FlatTextBorder FormattedTextField.border = com.formdev.flatlaf.ui.FlatTextBorder
FormattedTextField.margin = @componentMargin FormattedTextField.margin = @componentMargin
FormattedTextField.background = @componentBackground FormattedTextField.background = @componentBackground
FormattedTextField.selectionBackground=$color.brand4
FormattedTextField.placeholderForeground = @disabledForeground FormattedTextField.placeholderForeground = @disabledForeground
FormattedTextField.iconTextGap = 4 FormattedTextField.iconTextGap = 4
@ -751,7 +760,20 @@ Spinner.padding = @componentMargin
Spinner.editorBorderPainted = false Spinner.editorBorderPainted = false
# allowed values: button or none # allowed values: button or none
Spinner.buttonStyle = button Spinner.buttonStyle = button
#---- Input ----
InputButton.background=$fill.normal
InputButton.hoverBackground=$fill.hover
InputButton.pressedBackground=$fill.click
InputButton.width=$Component.defaultHeight
InputButton.height=$Component.defaultHeight
InputTextField.borderInsets=0, 6, 0, 6
Input.border=com.fine.theme.light.ui.FineRoundBorder
Input.background=$fill.normal
Input.height=$Component.defaultHeight
Input.arc=$Component.arc
#---- FormulaPane ----
FormulaPane.buttonWidth=$Component.defaultHeight
FormulaPane.buttonHeight=$Component.defaultHeight
#---- SplitPane ---- #---- SplitPane ----
@ -910,6 +932,7 @@ TextComponent.arc=$Component.arc
TextField.border=com.fine.theme.light.ui.FineRoundBorder TextField.border=com.fine.theme.light.ui.FineRoundBorder
TextField.margin = @componentMargin TextField.margin = @componentMargin
TextField.background=$background.normal TextField.background=$background.normal
TextField.selectionBackground=$color.brand4
TextField.placeholderForeground = @disabledForeground TextField.placeholderForeground = @disabledForeground
TextField.iconTextGap = 4 TextField.iconTextGap = 4
TextField.height=$Component.defaultHeight TextField.height=$Component.defaultHeight
@ -1049,8 +1072,13 @@ ToolTipManager.enableToolTipMode = activeApplication
#---- ToolTip ---- #---- ToolTip ----
ToolTip.borderCornerRadius = $Popup.borderCornerRadius ToolTip.borderCornerRadius = $Popup.borderCornerRadius
ToolTip.border = 4,6,4,6,shade(@background,40%) ToolTip.background=$tooltip.normal
ToolTip.background = lighten(@background,3%) ToolTip.foreground=$text.white
ToolTip.border=3,10,3,10
ToolTip.backgroundInactive=$tooltip.disabled
ToolTip.foregroundInactive=$text.white
ToolTip.arc=$Component.arc
ToolTip.maxWidth=392
#---- Tree ---- #---- Tree ----
@ -1134,7 +1162,8 @@ Center.ZoneBorderColor = #E6E9EF
Center.GridColumnRowColor = #F8F9FC Center.GridColumnRowColor = #F8F9FC
Center.SpaceColor = #FFF Center.SpaceColor = #FFF
Center.border = 0, 10, 10, 10 Center.border = 0, 10, 10, 10
#---- CellOtherSetPane ----
CellOtherSetPane.height=$Component.defaultHeight
#---- Styles ------------------------------------------------------------------ #---- Styles ------------------------------------------------------------------

Loading…
Cancel
Save