From cc40bb82e8b5dfb6043c84185fb38beeeab4685b Mon Sep 17 00:00:00 2001 From: "Leo.Qin" Date: Wed, 13 Dec 2023 16:51:54 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-107973=20=E4=B8=BB=E9=A1=B5=E5=8F=8A?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E8=A7=86=E8=A7=89=E6=A0=B7=E5=BC=8F=E7=BF=BB?= =?UTF-8?q?=E6=96=B0=20=E3=80=90=E9=97=AE=E9=A2=98=E5=8E=9F=E5=9B=A0?= =?UTF-8?q?=E3=80=91rt=20=E3=80=90=E6=94=B9=E5=8A=A8=E6=80=9D=E8=B7=AF?= =?UTF-8?q?=E3=80=91tooltip=E7=BF=BB=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fine/theme/light/ui/FineTooltipUI.java | 97 +++++++++++++++++++ .../light/ui/laf/FineLightLaf.properties | 41 ++++++-- 2 files changed, 132 insertions(+), 6 deletions(-) create mode 100644 designer-base/src/main/java/com/fine/theme/light/ui/FineTooltipUI.java diff --git a/designer-base/src/main/java/com/fine/theme/light/ui/FineTooltipUI.java b/designer-base/src/main/java/com/fine/theme/light/ui/FineTooltipUI.java new file mode 100644 index 0000000000..ae02f09849 --- /dev/null +++ b/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 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); + } +} \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties b/designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties index b6552575b5..d3fd944d1e 100644 --- a/designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties +++ b/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 ToolBarUI = com.formdev.flatlaf.ui.FlatToolBarUI 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 ViewportUI = com.formdev.flatlaf.ui.FlatViewportUI #---- variables ---- Component.defaultHeight=24 +Component.defaultVGap=10 # general background and foreground (text color) @background = #F6F8FA @@ -162,13 +163,18 @@ defaultHighlightBorderColor = #2576EF defaultBorderFocusShadow = #2576ef19 defaultBorderFocusWidth = 0 brand.normal=#2576EF +color.brand4=#84B1F6 background.normal=#FFFFFF text.white=#ffffff text.placeholder=fade(@foreground, 40%) text.highlight=fade(@foreground, 90%) fill.hover=#E6E9EF +fill.click=#DADEE7 fill.normal=#FFFFFF +fill.disabled=#F2F4F8 border.divider=#DADEE7 +tooltip.normal=#3F506A +tooltip.disabled=#A3ADBD #---- Button ---- @@ -362,7 +368,9 @@ DesktopIcon.closeIcon = com.formdev.flatlaf.icons.FlatInternalFrameCloseIcon EditorPane.border = com.formdev.flatlaf.ui.FlatMarginBorder EditorPane.margin = @componentMargin EditorPane.background = @componentBackground - +DataBindingEditor.vgap=$Component.defaultVGap +DataBindingEditor.hgap=1 +DataBindingEditor.height=$Component.defaultHeight #---- FileChooser ---- @@ -390,6 +398,7 @@ FileView.fullRowSelection = true FormattedTextField.border = com.formdev.flatlaf.ui.FlatTextBorder FormattedTextField.margin = @componentMargin FormattedTextField.background = @componentBackground +FormattedTextField.selectionBackground=$color.brand4 FormattedTextField.placeholderForeground = @disabledForeground FormattedTextField.iconTextGap = 4 @@ -751,7 +760,20 @@ Spinner.padding = @componentMargin Spinner.editorBorderPainted = false # allowed values: button or none 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 ---- @@ -910,6 +932,7 @@ TextComponent.arc=$Component.arc TextField.border=com.fine.theme.light.ui.FineRoundBorder TextField.margin = @componentMargin TextField.background=$background.normal +TextField.selectionBackground=$color.brand4 TextField.placeholderForeground = @disabledForeground TextField.iconTextGap = 4 TextField.height=$Component.defaultHeight @@ -1049,8 +1072,13 @@ ToolTipManager.enableToolTipMode = activeApplication #---- ToolTip ---- ToolTip.borderCornerRadius = $Popup.borderCornerRadius -ToolTip.border = 4,6,4,6,shade(@background,40%) -ToolTip.background = lighten(@background,3%) +ToolTip.background=$tooltip.normal +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 ---- @@ -1134,7 +1162,8 @@ Center.ZoneBorderColor = #E6E9EF Center.GridColumnRowColor = #F8F9FC Center.SpaceColor = #FFF Center.border = 0, 10, 10, 10 - +#---- CellOtherSetPane ---- +CellOtherSetPane.height=$Component.defaultHeight #---- Styles ------------------------------------------------------------------