From c6d8d3253b4b25e2f350190d7cf23ea554d84211 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Levy=2EXie-=E8=A7=A3=E5=AE=89=E6=A3=AE?= Date: Thu, 8 Aug 2024 15:15:51 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-113994=20=E3=80=90NewUI=E3=80=91?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E5=99=A8=E5=90=AF=E5=8A=A8=E9=A1=B5=E7=BF=BB?= =?UTF-8?q?=E6=96=B0=E3=80=81=E8=BF=9B=E5=BA=A6=E6=9D=A1=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fine/theme/light/ui/laf/FineLaf.java | 4 +- .../theme/utils/FineClientProperties.java | 4 + .../com/fine/theme/utils/FineUIStyle.java | 1 + .../com/fine/theme/utils/FineUIUtils.java | 23 +- .../gui/iprogressbar/ProgressDialog.java | 4 +- .../gui/itree/filetree/FileTreeIcon.java | 32 +- .../start/common/DesignerOpenEmptyPanel.java | 46 +- .../fr/startup/ui/StartupPageConstants.java | 2 +- .../com/fr/startup/ui/StartupPageUtil.java | 13 +- .../com/fr/startup/ui/StartupPageWindow.java | 61 ++- .../startup/ui/StartupPageWorkspacePanel.java | 468 ++++++++---------- .../com/fine/theme/icon/add_hover.svg | 5 + .../icon/filetree/filetype/fvs_locked.svg | 15 + .../icon/startup/local_server_background.svg | 16 + .../com/fine/theme/icon/startup/more.svg | 3 + .../fine/theme/icon/startup/more_hover.svg | 3 + .../icon/startup/remote_server_background.svg | 18 + .../com/fine/theme/icon/startup/show_less.svg | 3 + .../com/fine/theme/icon/startup/show_more.svg | 3 + .../fine/theme/light/ui/fine_light.icon.json | 10 +- .../light/ui/laf/FineLightLaf.properties | 20 +- .../share/ui/base/DownloadProgressPane.java | 1 - 22 files changed, 402 insertions(+), 353 deletions(-) create mode 100644 designer-base/src/main/resources/com/fine/theme/icon/add_hover.svg create mode 100644 designer-base/src/main/resources/com/fine/theme/icon/filetree/filetype/fvs_locked.svg create mode 100644 designer-base/src/main/resources/com/fine/theme/icon/startup/local_server_background.svg create mode 100755 designer-base/src/main/resources/com/fine/theme/icon/startup/more.svg create mode 100644 designer-base/src/main/resources/com/fine/theme/icon/startup/more_hover.svg create mode 100644 designer-base/src/main/resources/com/fine/theme/icon/startup/remote_server_background.svg create mode 100755 designer-base/src/main/resources/com/fine/theme/icon/startup/show_less.svg create mode 100755 designer-base/src/main/resources/com/fine/theme/icon/startup/show_more.svg diff --git a/designer-base/src/main/java/com/fine/theme/light/ui/laf/FineLaf.java b/designer-base/src/main/java/com/fine/theme/light/ui/laf/FineLaf.java index fa29de7466..f5bcbafe76 100644 --- a/designer-base/src/main/java/com/fine/theme/light/ui/laf/FineLaf.java +++ b/designer-base/src/main/java/com/fine/theme/light/ui/laf/FineLaf.java @@ -43,8 +43,8 @@ public abstract class FineLaf extends FlatLaf { */ private static void resetWindowDecorations() { if (SystemInfo.isWindows_10_orLater) { - System.setProperty("flatlaf.useWindowDecorations", "false"); - System.setProperty("flatlaf.menuBarEmbedded", "false"); + System.setProperty("flatlaf.useWindowDecorations", "true"); + System.setProperty("flatlaf.menuBarEmbedded", "true"); } } } diff --git a/designer-base/src/main/java/com/fine/theme/utils/FineClientProperties.java b/designer-base/src/main/java/com/fine/theme/utils/FineClientProperties.java index 038e53a8cf..3b1e5933b2 100644 --- a/designer-base/src/main/java/com/fine/theme/utils/FineClientProperties.java +++ b/designer-base/src/main/java/com/fine/theme/utils/FineClientProperties.java @@ -28,6 +28,10 @@ public interface FineClientProperties extends FlatClientProperties { String PANEL_TYPE = "panelType"; String ROUNDED_PANEL = "roundedPanel"; + //--------------------------- ComboBox ---------------------------- + String COMBO_BOX_TYPE = "comboBoxType"; + String ADAPTIVE_COMBO_BOX = "adaptiveComboBox"; + int GROUP_BUTTON_POSITION_INNER = 0; int GROUP_BUTTON_POSITION_LEFT = 1; int GROUP_BUTTON_POSITION_RIGHT = 2; diff --git a/designer-base/src/main/java/com/fine/theme/utils/FineUIStyle.java b/designer-base/src/main/java/com/fine/theme/utils/FineUIStyle.java index 5e15fffb0b..d2b64bea31 100644 --- a/designer-base/src/main/java/com/fine/theme/utils/FineUIStyle.java +++ b/designer-base/src/main/java/com/fine/theme/utils/FineUIStyle.java @@ -38,6 +38,7 @@ public interface FineUIStyle { String POPUP_MENU_TOOL_BAR = "popupMenuToolBar"; String POPUP_MENU_DROPDOWN = "dropdownPopupMenu"; String TRANSPARENT_TEXT_FIELD = "transparentTextField"; + String TRANSPARENT_BACKGROUND = "transparentBackground"; String PURE_LIST = "pureList"; String PURE_TREE = "pureTree"; String PASTEL_BUTTON = "pastelButton"; diff --git a/designer-base/src/main/java/com/fine/theme/utils/FineUIUtils.java b/designer-base/src/main/java/com/fine/theme/utils/FineUIUtils.java index 1ca238934e..458be0dc6d 100644 --- a/designer-base/src/main/java/com/fine/theme/utils/FineUIUtils.java +++ b/designer-base/src/main/java/com/fine/theme/utils/FineUIUtils.java @@ -13,14 +13,7 @@ import javax.swing.JLabel; import javax.swing.JLayer; import javax.swing.ScrollPaneConstants; import javax.swing.UIManager; -import java.awt.Color; -import java.awt.Component; -import java.awt.Composite; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.GraphicsDevice; -import java.awt.GraphicsEnvironment; -import java.awt.Insets; +import java.awt.*; import java.awt.geom.Path2D; import java.awt.geom.RoundRectangle2D; import java.lang.reflect.Field; @@ -388,7 +381,7 @@ public class FineUIUtils { * 面板元素头部添加小标题 * * @param component 面板元素 - * @param title 标题文本 + * @param title 标题文本 * @return 包装面板 */ public static Component wrapComponentWithTitle(Component component, String title) { @@ -422,4 +415,16 @@ public class FineUIUtils { return new JLayer<>(new UIScrollPane(c, ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER), new CollapsibleScrollBarLayerUI(verticalPolicy, horizontalPolicy)); } + + /** + * 设置组件字体大小,已适配字体缩放 + * + * @param c 组件 + * @param size 字体大小 + */ + public static void setFontSize(Component c, int size) { + Font font = c.getFont(); + Font newSizeFont = font.deriveFont(font.getStyle(), scale(size)); + c.setFont(newSizeFont); + } } diff --git a/designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java b/designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java index 44e697d043..67f696569e 100644 --- a/designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java +++ b/designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java @@ -1,5 +1,6 @@ package com.fr.design.gui.iprogressbar; +import com.fine.theme.utils.FineUIScale; import com.fr.design.constants.UIConstants; import com.fr.design.dialog.UIDialog; import com.fr.design.gui.ilable.UILabel; @@ -58,7 +59,7 @@ public class ProgressDialog extends UIDialog { protected void initCenterDialog(Frame parent) { centerDialog = new JDialog(this); - centerDialog.setSize(new Dimension(482, 124)); + centerDialog.setSize(FineUIScale.scale(new Dimension(482, 124))); centerDialog.setUndecorated(true); centerDialog.setLocationRelativeTo(parent); centerDialog.getContentPane().add(progressPanel); @@ -66,7 +67,6 @@ public class ProgressDialog extends UIDialog { protected void initProgressBar() { progressBar = new JProgressBar(); - progressBar.setUI(new ModernUIProgressBarUI()); progressBar.setBorderPainted(false); progressBar.setOpaque(false); progressBar.setBorder(null); diff --git a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java index 4a2525d7c1..ca26e435aa 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java +++ b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java @@ -28,6 +28,7 @@ public class FileTreeIcon { public static final Icon FOLDER_OPEN_IMAGE_ICON = new LazyIcon("folder_open"); public static final Icon MODERN_CPT_FILE_IMAGE_ICON = new LazyIcon("cpt_icon"); public static final Icon MODERN_FRM_FILE_IMAGE_ICON = new LazyIcon("frm_icon"); + public static final Icon MODERN_FVS_FILE_IMAGE_ICON = new LazyIcon("fvs_icon"); public static final Icon FILE_IMAGE_ICON = UIManager.getIcon("FileView.fileIcon"); @@ -44,6 +45,10 @@ public class FileTreeIcon { public static final Icon MODERN_CHT_FILE_IMAGE_ICON = new LazyIcon("chtFile"); public static final Icon CPTX_ICON = new LazyIcon("cpt_icon"); + public static final Icon CPT_FILE_LOCK_ICON = new LazyIcon("cpt_locked"); + public static final Icon FRM_FILE_LOCK_ICON = new LazyIcon("frm_locked"); + public static final Icon FVS_FILE_LOCK_ICON = new LazyIcon("fvs_locked"); + // TODO: 以下Icon视觉暂未提供,需提供后替换 public static final Icon BLANK_IMAGE_ICON = BaseUtils.readIcon("/com/fr/design/images/gui/blank.gif"); public static final Icon FOLDER_HALF_IMAGE_ICON = IconUtils.readIcon("/com/fr/design/standard/fileicon/folder_half_authority.svg"); @@ -76,10 +81,6 @@ public class FileTreeIcon { new LockIcon(BaseUtils.readImage("/com/fr/design/images/gui/jpgFile.gif")); public static final LockIcon BMP_FILE_LOCK_ICON = new LockIcon(BaseUtils.readImage("/com/fr/design/images/gui/bmpFile.gif")); - public static final LockIcon CPT_FILE_LOCK_ICON = - new LockIcon(BaseUtils.readImage("/com/fr/base/images/oem/cptlocked.png")); - public static final LockIcon FRM_FILE_LOCK_ICON = - new LockIcon(BaseUtils.readImage("/com/fr/design/images/gui/frmlocked.png")); public static final LockIcon CHT_FILE_LOCK_ICON = new LockIcon(BaseUtils.readImage("/com/fr/design/images/gui/frmlocked.png")); /** @@ -110,6 +111,7 @@ public class FileTreeIcon { public final static int FRM_FILE = 12; //.form .frm public final static int CHT_FILE = 13; //.chart .cht public final static int CPTX_FILE = 14; //.cptx + public final static int FVS_FILE = 15; //.fvs public static Icon getIcon(File file) { return FileTreeIcon.getIcon(file, false); @@ -143,6 +145,20 @@ public class FileTreeIcon { return getIcon(node, showLock); } + /** + * 获取文件名对应的图标 + * + * @param filename 文件名 + * @return 文件的图标 + */ + public static Icon getIconByFileName(String filename) { + Icon icon = getExtraIcon(filename, false); + if (icon != null) { + return icon; + } + return getIcon(getFileType(filename), false); + } + /** * 获取文件节点对应的图标(含展开与否的属性) * @@ -298,6 +314,12 @@ public class FileTreeIcon { } else { return FileTreeIcon.MODERN_CHT_FILE_IMAGE_ICON; } + } else if (fileType == FVS_FILE) { // fvs + if (isLocked) { + return FileTreeIcon.FVS_FILE_LOCK_ICON; + } else { + return FileTreeIcon.MODERN_FVS_FILE_IMAGE_ICON; + } } else { if (isLocked) { return FileTreeIcon.FILE_LOCK_ICON; @@ -354,6 +376,8 @@ public class FileTreeIcon { return FRM_FILE; } else if (fileName.endsWith(".cht") || fileName.endsWith(".chart")) { return CHT_FILE; + } else if (fileName.endsWith(".fvs")) { + return FVS_FILE; } else { return TEXT_FILE; } diff --git a/designer-base/src/main/java/com/fr/start/common/DesignerOpenEmptyPanel.java b/designer-base/src/main/java/com/fr/start/common/DesignerOpenEmptyPanel.java index b42cc4ed8f..9ef7a9c1ef 100644 --- a/designer-base/src/main/java/com/fr/start/common/DesignerOpenEmptyPanel.java +++ b/designer-base/src/main/java/com/fr/start/common/DesignerOpenEmptyPanel.java @@ -1,36 +1,32 @@ package com.fr.start.common; +import com.fine.theme.utils.FineUIStyle; import com.fr.base.svg.IconUtils; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.MultiTemplateTabPane; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.i18n.DesignSizeI18nManager; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrame; -import com.fr.design.utils.ColorUtils; import javax.swing.JButton; import javax.swing.JPanel; -import javax.swing.border.EmptyBorder; import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.RenderingHints; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import static com.fine.swing.ui.layout.Layouts.cell; +import static com.fine.swing.ui.layout.Layouts.flex; +import static com.fine.swing.ui.layout.Layouts.row; +import static com.fine.theme.utils.FineUIStyle.setStyle; + /** * created by Harrison on 2022/07/09 **/ public class DesignerOpenEmptyPanel extends JPanel { - private static final Color BUTTON_COLOR = new Color(63, 155, 249); - private static final int ARC = 4; - private final JPanel body; public DesignerOpenEmptyPanel() { @@ -38,20 +34,8 @@ public class DesignerOpenEmptyPanel extends JPanel { this.body = FRGUIPaneFactory.createBorderLayout_S_Pane(); UILabel createIcon = new UILabel(IconUtils.readIcon("/com/fr/design/startup/create_new_template.svg")); - JButton createButton = new JButton(Toolkit.i18nText("Fine-Design_New_Template")) { - @Override - public void paintComponent(Graphics g) { - Graphics2D g2d = (Graphics2D) g; - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - g2d.setColor(BUTTON_COLOR); - g2d.fillRoundRect(0, 0, getWidth(), getHeight(), ARC, ARC); - super.paintComponent(g2d); - } - }; - createButton.setPreferredSize(DesignSizeI18nManager.getInstance().i18nDimension("com.fr.start.common.DesignerOpenEmptyPanel.createButton")); - createButton.setForeground(Color.WHITE); - createButton.setBorderPainted(false); - createButton.setContentAreaFilled(false); + JButton createButton = new JButton(Toolkit.i18nText("Fine-Design_New_Template")); + setStyle(createButton, FineUIStyle.STYLE_PRIMARY); createButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -62,18 +46,14 @@ public class DesignerOpenEmptyPanel extends JPanel { MultiTemplateTabPane.getInstance().setTemTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); } }); - createButton.setBorder(new EmptyBorder(0, 10, 0, 10)); - JPanel createButtonPanel = new JPanel(FRGUIPaneFactory.createCenterFlowLayout()); - createButtonPanel.add(createButton); - createButtonPanel.setBorder(new EmptyBorder(0, 0, 0, 0)); - createButtonPanel.setBackground(Color.WHITE); this.body.add(createIcon, BorderLayout.NORTH); - this.body.add(createButtonPanel, BorderLayout.SOUTH); + this.body.add(row( + flex(),cell(createButton),flex() + ).getComponent(), BorderLayout.SOUTH); setLayout(FRGUIPaneFactory.createCenterLayout(this.body, 0.4d, 0.4d)); - - ColorUtils.syncBackground(this, Color.WHITE); - + setStyle(this.body, FineUIStyle.NORMAL_COLOR); + setStyle(this, FineUIStyle.NORMAL_COLOR); add(this.body); } } diff --git a/designer-base/src/main/java/com/fr/startup/ui/StartupPageConstants.java b/designer-base/src/main/java/com/fr/startup/ui/StartupPageConstants.java index 8c414cecfe..2dab229850 100644 --- a/designer-base/src/main/java/com/fr/startup/ui/StartupPageConstants.java +++ b/designer-base/src/main/java/com/fr/startup/ui/StartupPageConstants.java @@ -10,7 +10,7 @@ public class StartupPageConstants { /** * 圆弧长度 */ - public static final int ARC_DIAMETER = 20; + public static final int ARC_DIAMETER = 10; /** * 内容宽度 diff --git a/designer-base/src/main/java/com/fr/startup/ui/StartupPageUtil.java b/designer-base/src/main/java/com/fr/startup/ui/StartupPageUtil.java index 153aa4ce0e..20bf1c8464 100644 --- a/designer-base/src/main/java/com/fr/startup/ui/StartupPageUtil.java +++ b/designer-base/src/main/java/com/fr/startup/ui/StartupPageUtil.java @@ -1,7 +1,8 @@ package com.fr.startup.ui; -import com.fr.base.svg.SVGIcon; +import com.fine.theme.icon.LazyIcon; import com.fr.design.env.DesignerWorkspaceType; +import com.fr.design.gui.itree.filetree.FileTreeIcon; import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; @@ -27,9 +28,9 @@ public class StartupPageUtil { public static Icon getIcon4RecentAreaByWorkspace(StartupWorkspaceBean workspaceBean) { if (workspaceBean.getType() == DesignerWorkspaceType.Local) { - return SVGIcon.readSVGIcon("/com/fr/design/startup/local_server_background_36.svg", 36, 36); + return new LazyIcon("local_server_background", 36); } - return SVGIcon.readSVGIcon("/com/fr/design/startup/remote_server_background_36.svg", 36, 36); + return new LazyIcon("remote_server_background", 36); } /** @@ -41,11 +42,11 @@ public class StartupPageUtil { public static Icon getIcon4DescAreaByWorkspace(StartupWorkspaceBean workspaceBean) { if (workspaceBean.getType() == DesignerWorkspaceType.Local) { - return SVGIcon.readSVGIcon("/com/fr/design/startup/local_server_background_28.svg", 28, 28); + return new LazyIcon("local_server_background", 28); } - return SVGIcon.readSVGIcon("/com/fr/design/startup/remote_server_background_28.svg", 28, 28); + return new LazyIcon("remote_server_background", 28); } - + /** * 返回 ip : port * diff --git a/designer-base/src/main/java/com/fr/startup/ui/StartupPageWindow.java b/designer-base/src/main/java/com/fr/startup/ui/StartupPageWindow.java index a2d9965e50..b758ac6c49 100644 --- a/designer-base/src/main/java/com/fr/startup/ui/StartupPageWindow.java +++ b/designer-base/src/main/java/com/fr/startup/ui/StartupPageWindow.java @@ -1,11 +1,14 @@ package com.fr.startup.ui; -import com.fr.base.svg.IconUtils; -import com.fr.concurrent.NamedThreadFactory; +import com.fine.theme.utils.FineUIStyle; +import com.fine.theme.utils.FineUIUtils; +import com.formdev.flatlaf.ui.FlatUIUtils; +import com.formdev.flatlaf.util.ScaledEmptyBorder; import com.fr.design.DesignerEnvManager; import com.fr.design.dialog.UIExpandDialog; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itree.filetree.FileTreeIcon; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.VerticalFlowLayout; @@ -13,7 +16,6 @@ import com.fr.design.mainframe.messagecollect.StartErrorMessageCollector; import com.fr.design.mainframe.messagecollect.entity.DesignerErrorMessage; import com.fr.design.ui.util.UIUtil; import com.fr.design.utils.ColorUtils; -import com.fr.design.utils.ThemeUtils; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.exit.DesignerExiter; import com.fr.general.GeneralUtils; @@ -26,7 +28,6 @@ import com.fr.start.common.DesignerStartupContext; import com.fr.startup.metric.DesignerMetrics; import org.jetbrains.annotations.NotNull; -import javax.swing.BorderFactory; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JPanel; @@ -34,12 +35,10 @@ import javax.swing.JSeparator; import javax.swing.ScrollPaneConstants; import javax.swing.SwingConstants; import javax.swing.SwingWorker; -import javax.swing.border.EmptyBorder; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.FlowLayout; -import java.awt.Font; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.GridLayout; @@ -52,8 +51,8 @@ import java.awt.event.WindowEvent; import java.awt.image.BufferedImage; import java.util.List; import java.util.Map; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; + +import static com.fine.theme.utils.FineUIScale.scale; /** * 启动页 @@ -66,12 +65,12 @@ public class StartupPageWindow extends JFrame { private static final Color HOVER_COLOR = new Color(65, 155, 249); private static final Color SEP_COLOR = new Color(224, 224, 225); - private static final int GROUP_WIDTH = 600; + private static final int GROUP_WIDTH = scale(600); + private static final int WORKSPACE_PANEL_WIDTH = scale(180); private static final int RECENT_FILE_LIMIT = 6; - private static final int RECENT_FILE_SCROLL = RECENT_FILE_LIMIT + 1; - private static final int WORKSPACE_PANEL_WIDTH = 180; private static final int TITLE_FONT_SIZE = 24; private static final int ITEM_VERTICAL_GAP = 5; + private static final Dimension SCREEN_SIZE = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); @@ -117,7 +116,7 @@ public class StartupPageWindow extends JFrame { } private void initHeaderPanel() { - this.body = FRGUIPaneFactory.createBorderLayout_S_Pane(); + this.body = new JPanel(new BorderLayout(0, scale(20))); this.body.setBackground(new Color(0, 0, 0, 0)); JPanel headerPanel = createHeader(); this.body.add(headerPanel, BorderLayout.NORTH); @@ -169,9 +168,7 @@ public class StartupPageWindow extends JFrame { // Header UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Startup_Page_Select_Workspace")); - Font font = label.getFont(); - Font titleFont = font.deriveFont(font.getStyle(), TITLE_FONT_SIZE); - label.setFont(titleFont); + FineUIUtils.setFontSize(label, TITLE_FONT_SIZE); JPanel headerPanel = new JPanel(); LayoutManager centerFlowLayout = FRGUIPaneFactory.createCenterFlowLayout(); headerPanel.setLayout(centerFlowLayout); @@ -288,18 +285,18 @@ public class StartupPageWindow extends JFrame { } private JPanel generateRecentOpenPanel(StartupPageModel pageModel) { - + Color color = FlatUIUtils.getUIColor("fill.normal", Color.WHITE); JPanel recentOpenPanel = new JPanel() { @Override protected void paintComponent(Graphics g) { Graphics2D g2d = (Graphics2D) g; g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - g2d.setColor(Color.WHITE); - g2d.fillRoundRect(0, 0, getWidth(), getHeight(), StartupPageConstants.ARC_DIAMETER, StartupPageConstants.ARC_DIAMETER); + g2d.setColor(color); + g2d.fillRoundRect(0, 0, getWidth(), getHeight(), 2 * StartupPageConstants.ARC_DIAMETER, 2 * StartupPageConstants.ARC_DIAMETER); } }; recentOpenPanel.setLayout(new BorderLayout()); - recentOpenPanel.setBorder(BorderFactory.createEmptyBorder(25, 25, 25, 6)); + recentOpenPanel.setBorder(new ScaledEmptyBorder(25, 25, 25, 6)); StartupWorkspaceBean workspaceInfo = pageModel.getSelectWorkspaceInfo(); JPanel workspaceWrapperYPanel = new JPanel(); @@ -309,15 +306,15 @@ public class StartupPageWindow extends JFrame { JPanel workspaceWrapperXPanel = new JPanel(); workspaceWrapperXPanel.setLayout(new FlowLayout()); - workspaceWrapperXPanel.setBorder(BorderFactory.createEmptyBorder()); - + JPanel workspacePanel = new JPanel(); - workspacePanel.setLayout(new BorderLayout(0, 15)); + workspacePanel.setLayout(new BorderLayout(0, scale(15))); UILabel workspaceIcon = new UILabel(StartupPageUtil.getIcon4RecentAreaByWorkspace(workspaceInfo)); workspacePanel.add(workspaceIcon, BorderLayout.NORTH); UILabel nameLabel = new UILabel(workspaceInfo.getName()); + FineUIUtils.setFontSize(nameLabel, 15); nameLabel.setHorizontalAlignment(SwingConstants.CENTER); workspacePanel.add(nameLabel, BorderLayout.SOUTH); workspaceWrapperXPanel.add(workspacePanel); @@ -340,18 +337,17 @@ public class StartupPageWindow extends JFrame { JComponent recentOpenGroupPanel = generateRecentOpenGroupPanel(pageModel, workspaceInfo); recentOpenPanel.add(recentOpenGroupPanel, BorderLayout.EAST); - ColorUtils.syncBackground(recentOpenPanel, Color.WHITE); - + ColorUtils.syncBackground(recentOpenPanel, color); + Dimension preferredSize = recentOpenPanel.getPreferredSize(); - recentOpenPanel.setPreferredSize(new Dimension(StartupPageConstants.CONTENT_WIDTH, (int) preferredSize.getHeight())); + recentOpenPanel.setPreferredSize(new Dimension(scale(StartupPageConstants.CONTENT_WIDTH), (int) preferredSize.getHeight())); JPanel recentOpenWrapperPanel = new JPanel(); recentOpenWrapperPanel.setName("recentOpenWrapper"); recentOpenWrapperPanel.setLayout(new BorderLayout(0, 0)); - recentOpenWrapperPanel.setBorder(new EmptyBorder(0, 0, 0, 20)); recentOpenWrapperPanel.add(recentOpenPanel, BorderLayout.CENTER); - ColorUtils.syncBackgroundIfAbsent(recentOpenWrapperPanel, new Color(0,0,0,0), ThemeUtils.BACK_COLOR); + FineUIStyle.setStyle(recentOpenWrapperPanel, FineUIStyle.TRANSPARENT_BACKGROUND); return recentOpenWrapperPanel; } @@ -372,8 +368,9 @@ public class StartupPageWindow extends JFrame { for (String recentFile : recentFiles) { JPanel recentItemPanel = new JPanel(); recentItemPanel.setLayout(new FlowLayout(FlowLayout.LEFT, ITEM_VERTICAL_GAP, 0)); - recentItemPanel.add(new UILabel(IconUtils.readIcon("/com/fr/design/standard/system/cpt"))); + recentItemPanel.add(new UILabel(FileTreeIcon.getIconByFileName(recentFile))); UILabel recentFileLabel = new UILabel(recentFile); + FineUIUtils.setFontSize(recentFileLabel, 13); Color recentFileLabelForeground = recentFileLabel.getForeground(); recentItemPanel.add(recentFileLabel); recentItemPanel.addMouseListener(new MouseAdapter() { @@ -406,7 +403,7 @@ public class StartupPageWindow extends JFrame { if (needScroll) { int scrollHeight = (int) Math.round(itemHeight * RECENT_FILE_LIMIT + ITEM_VERTICAL_GAP * (RECENT_FILE_LIMIT)); UIScrollPane scrollPane = new UIScrollPane(recentOpenGroupPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); - scrollPane.setBorder(new EmptyBorder(0, 0, 0, 0)); + scrollPane.setBorder(new ScaledEmptyBorder(0, 0, 0, 0)); scrollPane.setPreferredSize(new Dimension(GROUP_WIDTH, scrollHeight)); return scrollPane; } @@ -414,10 +411,8 @@ public class StartupPageWindow extends JFrame { } private StartupPageWorkspacePanel generateWorkspacePanel(StartupPageModel pageModel) { - - StartupPageWorkspacePanel startupPageWorkspacePanel = new StartupPageWorkspacePanel(pageModel); - ColorUtils.syncBackgroundIfAbsent(startupPageWorkspacePanel, new Color(0, 0, 0, 0), ThemeUtils.BACK_COLOR); - return startupPageWorkspacePanel; + + return new StartupPageWorkspacePanel(pageModel); } protected LayoutManager getCenterLayout(JComponent centerBody) { diff --git a/designer-base/src/main/java/com/fr/startup/ui/StartupPageWorkspacePanel.java b/designer-base/src/main/java/com/fr/startup/ui/StartupPageWorkspacePanel.java index e41304e23b..2767f8945b 100644 --- a/designer-base/src/main/java/com/fr/startup/ui/StartupPageWorkspacePanel.java +++ b/designer-base/src/main/java/com/fr/startup/ui/StartupPageWorkspacePanel.java @@ -1,211 +1,223 @@ package com.fr.startup.ui; -import com.fr.base.svg.IconUtils; +import com.fine.swing.ui.layout.Column; +import com.fine.theme.icon.LazyIcon; +import com.fine.theme.utils.FineLayoutBuilder; +import com.fine.theme.utils.FineUIStyle; +import com.fine.theme.utils.FineUIUtils; +import com.formdev.flatlaf.ui.FlatUIUtils; +import com.formdev.flatlaf.util.ScaledEmptyBorder; import com.fr.design.components.tooltip.ModernToolTip; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.FRGraphics2D; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.utils.ColorUtils; import com.fr.start.common.DesignerStartupContext; import com.fr.startup.metric.DesignerMetrics; import com.fr.third.guava.collect.Lists; import org.jetbrains.annotations.NotNull; -import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.JComponent; import javax.swing.JPanel; +import javax.swing.JScrollBar; import javax.swing.JToolTip; import javax.swing.JViewport; -import javax.swing.RepaintManager; import javax.swing.ScrollPaneConstants; -import javax.swing.border.EmptyBorder; import java.awt.BasicStroke; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.FlowLayout; -import java.awt.Font; import java.awt.Graphics; import java.awt.Graphics2D; -import java.awt.GridLayout; import java.awt.Image; import java.awt.RenderingHints; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.awt.geom.Path2D; import java.awt.image.ImageObserver; +import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicReference; +import static com.fine.theme.utils.FineUIScale.scale; +import static com.fine.theme.utils.FineUIStyle.setStyle; import static com.fr.startup.ui.StartupPageConstants.ARC_DIAMETER; /** * created by Harrison on 2022/07/06 **/ public class StartupPageWorkspacePanel extends JPanel { - + /* color */ - - private static final Color SHALLOW_WHITE_COLOR = new Color(248, 250, 254); + private static final Color HOVER_COLOR = new Color(65, 155, 249); private static final Color PATH_COLOR = new Color(51, 51, 52, (int) Math.round(255 * 0.5)); - + /* 长度 */ private static final int SCROLL_BAR_WIDTH = 20; - private static final int CONTENT_WIDTH = StartupPageConstants.CONTENT_WIDTH + SCROLL_BAR_WIDTH; + private static final int CONTENT_WIDTH = scale(StartupPageConstants.CONTENT_WIDTH + SCROLL_BAR_WIDTH); private static final int BORDER_THIN = 2; - - private static final int ITEM_VERTICAL_GAP = 20; - private static final int SINGLE_ITEM_HEIGHT = 72; + + private static final int ITEM_VERTICAL_GAP = scale(20); + private static final int SINGLE_ITEM_HEIGHT = scale(72); private static final int SCROLL_HEIGHT = SINGLE_ITEM_HEIGHT * 4 + ITEM_VERTICAL_GAP * 4; - + private static final int NAME_LABEL_SIZE = 15; private static final int PATH_LABEL_SIZE = 10; - - private static final Dimension LABEL_DIMENSION = new Dimension(28, 28); - private static final Dimension PATH_DIMENSION = new Dimension(100, 20); - private static final Dimension SELECT_WORKSPACE_DIMENSION = new Dimension(210, 72); - private static final Dimension SELECT_CREATE_DIMENSION = new Dimension(60, 72); - + + private static final Dimension LABEL_DIMENSION = scale(new Dimension(28, 28)); + private static final Dimension PATH_DIMENSION = scale(new Dimension(100, 20)); + private static final Dimension SELECT_WORKSPACE_DIMENSION = scale(new Dimension(210, 72)); + private static final Dimension SELECT_CREATE_DIMENSION = scale(new Dimension(70, 72)); + private static final int COLUMN_LIMIT = 3; private static final int DOUBLE_CLICK_COUNT = 2; public static final int PARTITION_LIMIT = 2; - + /* model */ - + private final StartupPageModel pageModel; - + private final List> partitions; - + private Runnable selectWorkspaceRunnable; - + private final Runnable createNewTemplateRunnable; - + private final Runnable openEmptyTemplateRunnable; - + private JComponent contentPanel; - + private JPanel tailPanel; - + private boolean showMore = true; - + public StartupPageWorkspacePanel(StartupPageModel pageModel) { - - this.setLayout(new BorderLayout(0, 0)); - this.setBorder(new EmptyBorder(15, 0, 20, 0)); - + + this.setLayout(new BorderLayout(0, scale(10))); + this.pageModel = pageModel; - + List workspaceInfos = pageModel.getWorkspaceInfos(); this.partitions = Lists.partition(workspaceInfos, COLUMN_LIMIT); - + this.contentPanel = generateLimitContentPanel(partitions); + this.add(contentPanel, BorderLayout.NORTH); - + if (partitions.size() > PARTITION_LIMIT) { this.tailPanel = generateTailPanel(); this.add(tailPanel, BorderLayout.SOUTH); } - + this.createNewTemplateRunnable = pageModel.getCreateNewTemplateRunnable(); this.openEmptyTemplateRunnable = pageModel.getOpenEmptyTemplateRunnable(); - + + setStyle(contentPanel, FineUIStyle.TRANSPARENT_BACKGROUND); + setStyle(this, FineUIStyle.TRANSPARENT_BACKGROUND); + this.repaint(); } - + public void showLessContent() { - + this.remove(this.contentPanel); - + this.contentPanel = generateLimitContentPanel(this.partitions); this.add(contentPanel, BorderLayout.NORTH); } - + public void showMoreContent() { - + this.remove(this.contentPanel); - + this.contentPanel = generateUnLimitContentPanel(this.partitions); + this.contentPanel.setOpaque(false); this.add(contentPanel, BorderLayout.NORTH); } private JComponent generateUnLimitContentPanel(List> partitions) { - + JComponent panel = generateUnLimitContentPanel0(partitions); - ColorUtils.transparentBackground(panel); + setStyle(panel, FineUIStyle.TRANSPARENT_BACKGROUND); return panel; } - + private JComponent generateUnLimitContentPanel0(List> partitions) { - + JPanel workspaceDescWrapper = new JPanel(); - workspaceDescWrapper.setLayout(new BorderLayout(0, 0)); - workspaceDescWrapper.setBorder(new EmptyBorder(0, 0, 0, 0)); - - JPanel workspaceDescPanel = new JPanel(); - workspaceDescPanel.setLayout(new GridLayout(partitions.size(), 1, 0, 0)); + setStyle(workspaceDescWrapper, FineUIStyle.TRANSPARENT_BACKGROUND); + workspaceDescWrapper.setLayout(new BorderLayout()); + Column workSpaceDescPanel = new Column(); + workSpaceDescPanel.setSpacing(20); + setStyle(workSpaceDescPanel, FineUIStyle.TRANSPARENT_BACKGROUND); for (List partition : partitions) { JPanel partitionPanel = generatePartitionPanel(partition); - workspaceDescPanel.add(partitionPanel); + workSpaceDescPanel.add(partitionPanel); } boolean needScroll = partitions.size() > 4; if (needScroll) { - return generateScrollUnLimitContentPanel(workspaceDescWrapper, workspaceDescPanel); + return generateScrollUnLimitContentPanel(workspaceDescWrapper, workSpaceDescPanel); } - workspaceDescWrapper.add(workspaceDescPanel, BorderLayout.CENTER); - + workspaceDescWrapper.add(workSpaceDescPanel, BorderLayout.CENTER); return workspaceDescWrapper; } - + @NotNull private JPanel generateScrollUnLimitContentPanel(JPanel workspaceDescWrapper, JPanel workspaceDescPanel) { - + // 滚动条 - UIScrollPane scrollPane = new UIScrollPane(workspaceDescPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + UIScrollPane scrollPane = new UIScrollPane(workspaceDescPanel, + ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + workspaceDescWrapper.setPreferredSize(new Dimension(CONTENT_WIDTH + SCROLL_BAR_WIDTH, SCROLL_HEIGHT)); + JViewport viewport = scrollPane.getViewport(); JViewport scrollViewport = new TransparentScrollViewPort(); // 动态画图 scrollViewport.addChangeListener(e -> repaintAll()); scrollViewport.setView(viewport.getView()); scrollPane.setViewport(scrollViewport); - scrollPane.setBorder(new EmptyBorder(10, 0, 0, 0)); - scrollPane.setPreferredSize(new Dimension(CONTENT_WIDTH, SCROLL_HEIGHT)); + // 透明度配置 + InReactiveScrollBar bar = new InReactiveScrollBar(); + scrollPane.setVerticalScrollBar(bar); + setStyle(bar, FineUIStyle.TRANSPARENT_BACKGROUND); + scrollViewport.setOpaque(false); + workspaceDescWrapper.add(scrollPane, BorderLayout.CENTER); - return workspaceDescWrapper; } - + private JPanel generateLimitContentPanel(List> partitions) { - - JPanel workspaceDescPanel = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEFT, 0, 0); + + Column workspaceDescPanel = new Column(); + workspaceDescPanel.setSpacing(20); int limit = 2; for (int i = 0; i < partitions.size(); i++) { if (i >= limit) { break; } List partition = partitions.get(i); - + JPanel partitionPanel = generatePartitionPanel(partition); workspaceDescPanel.add(partitionPanel); } - - ColorUtils.transparentBackground(workspaceDescPanel); - + + setStyle(workspaceDescPanel, FineUIStyle.TRANSPARENT_BACKGROUND); return workspaceDescPanel; } - + @NotNull private JPanel generateTailPanel() { - + AtomicReference hoverBackColorRef = new AtomicReference<>(); - + JPanel tailPanel = new JPanel(); { tailPanel.setLayout(new FlowLayout(FlowLayout.RIGHT)); - tailPanel.setBorder(new EmptyBorder(0, 0, 0, 20)); JPanel showAllPanel = new JPanel() { @Override protected void paintComponent(Graphics g) { @@ -217,34 +229,17 @@ public class StartupPageWorkspacePanel extends JPanel { } } }; - showAllPanel.setLayout(new BorderLayout(5, 0)); - showAllPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); - + showAllPanel.setLayout(new BorderLayout()); + UILabel fontLabel = new UILabel(Toolkit.i18nText("Fine-Design_Startup_Page_Expand_All")); - fontLabel.setForeground(HOVER_COLOR); - showAllPanel.setBackground(new Color(0, 0, 0, 0)); + fontLabel.setForeground(FlatUIUtils.getUIColor("brand.normal", HOVER_COLOR)); showAllPanel.add(fontLabel, BorderLayout.WEST); - - UILabel iconLabel = new UILabel(IconUtils.readIcon("/com/fr/design/startup/show_more.svg")); + setStyle(showAllPanel, FineUIStyle.TRANSPARENT_BACKGROUND); + + UILabel iconLabel = new UILabel(new LazyIcon("show_more")); showAllPanel.add(iconLabel, BorderLayout.EAST); - - Color showAllBackground = showAllPanel.getBackground(); - - showAllPanel.addMouseListener(new MouseAdapter() { - @Override - public void mouseEntered(MouseEvent e) { - Color hoverBackColor = new Color(217, 235, 254); - hoverBackColorRef.set(hoverBackColor); - repaintAll(); - } - @Override - public void mouseExited(MouseEvent e) { - hoverBackColorRef.set(null); - ColorUtils.syncBackground(showAllPanel, showAllBackground); - repaintAll(); - } - + showAllPanel.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { doShowAllAction(fontLabel, iconLabel); @@ -252,172 +247,132 @@ public class StartupPageWorkspacePanel extends JPanel { }); tailPanel.add(showAllPanel); Dimension preferredSize = tailPanel.getPreferredSize(); - tailPanel.setPreferredSize(new Dimension(CONTENT_WIDTH, (int) preferredSize.getHeight())); + tailPanel.setPreferredSize(new Dimension(scale(StartupPageConstants.CONTENT_WIDTH), (int) preferredSize.getHeight())); } + setStyle(tailPanel, FineUIStyle.TRANSPARENT_BACKGROUND); return tailPanel; } - + @NotNull private JPanel generatePartitionPanel(List partition) { - - JPanel partitionPanelWrapper = new JPanel(); - partitionPanelWrapper.setBorder(new EmptyBorder(10,0,10,0)); - partitionPanelWrapper.setLayout(new BorderLayout()); - - JPanel partitionPanel = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(0, 20, 0); - partitionPanel.setName("partitionPanel"); - + + List workSpacePaneList = new ArrayList<>(); for (StartupWorkspaceBean workspaceInfo : partition) { - + JPanel workspaceItemDesc = FRGUIPaneFactory.createBorderLayout_S_Pane(); - + layoutSelectWorkspacePanel(workspaceInfo, workspaceItemDesc); - + layoutSelectAndCreatePanel(workspaceInfo, workspaceItemDesc); - - partitionPanel.add(workspaceItemDesc); - - Dimension preferredSize = partitionPanel.getPreferredSize(); - partitionPanel.setPreferredSize(new Dimension(CONTENT_WIDTH, (int) preferredSize.getHeight())); + + setStyle(workspaceItemDesc, FineUIStyle.TRANSPARENT_BACKGROUND); + + workSpacePaneList.add(workspaceItemDesc); } - - partitionPanelWrapper.add(partitionPanel, BorderLayout.CENTER); + + JPanel singleRow = FineLayoutBuilder.createCommonTableLayout(3, 20, 0, workSpacePaneList); + singleRow.setName("partitionPanel"); + + JPanel partitionPanelWrapper = FineLayoutBuilder.asBorderLayoutWrapped(singleRow); + setStyle(singleRow, FineUIStyle.TRANSPARENT_BACKGROUND); + setStyle(partitionPanelWrapper, FineUIStyle.TRANSPARENT_BACKGROUND); return partitionPanelWrapper; } - + private void layoutSelectWorkspacePanel(StartupWorkspaceBean workspaceInfo, JPanel workspaceItemDesc) { - + // 选择工作目录 // 图标 / 分隔符 / 说明-进入 // 选择并新建 AtomicReference borderColorRef = new AtomicReference<>(null); - + JPanel selectWorkspacePanel = new JPanel() { @Override public JToolTip createToolTip() { return new ModernToolTip(); } - + @Override protected void paintComponent(Graphics g) { Graphics2D g2d = (Graphics2D) g; g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - Color borderColor = borderColorRef.get(); - - Color backColor = Color.WHITE; + + Color backColor = FlatUIUtils.getUIColor("fill.normal", Color.WHITE); g2d.setColor(backColor); - // 直角和圆角上下叠合在一起 - int rectOffset = 10; - int roundOffset = 15; - // 填充一个直角 - g2d.fillRoundRect(0, 0, getWidth() - rectOffset, getHeight(), ARC_DIAMETER, ARC_DIAMETER); - // 填充一个圆角 - g2d.fillRoundRect(getWidth() - roundOffset, 0, roundOffset, getHeight(), 0, 0); + Path2D path2D = FineUIUtils.createLeftRoundRectangle(0, 0, this.getWidth(), this.getHeight(), ARC_DIAMETER); + g2d.fill(path2D); + + Color borderColor = borderColorRef.get(); paintBorderIfHover(g2d, borderColor, backColor); } - + /** * 当悬浮的时候,将边框展示出来 - * 会叠合,然后填充中间 - * - * |----【-|--】 - * | A 【C| B】 - * |----【-|--】 - * - * 见上面有两种线,分别是 A-| 和 B-【 - * 这里会将 A 和 B 叠在一起,中间则存在 C,然后将 C 的部分扩大一点,然后填充上背景 - * 则形成下面这种图形 - * - * |----】 - * |----】 - * * @param g2d 绘画 * @param borderColor 边框颜色 * @param backColor 背景颜色 */ private void paintBorderIfHover(Graphics2D g2d, Color borderColor, Color backColor) { - + if (borderColor != null) { g2d.setColor(borderColor); g2d.setStroke(new BasicStroke(BORDER_THIN)); - // 需要一个修正值 - int strokeOffset = BORDER_THIN / 2; - // 直角和圆角上下叠合在一起 - int rectOffset = 10; - int roundOffset = 15; - // 画一个圆角 - int fixRoundWidth = getWidth() - rectOffset; - int fixRoundHeight = getHeight() - BORDER_THIN; - g2d.drawRoundRect(strokeOffset, strokeOffset, fixRoundWidth, fixRoundHeight, ARC_DIAMETER, ARC_DIAMETER); - - g2d.setColor(backColor); - - // 绘制一个矩形,覆盖住多余的相交线 - // 需要考虑上下的线宽 - int coverHeight = getHeight() - (BORDER_THIN * 2); - // 偏左一点的 fixedX - int fixedX = getWidth() - roundOffset - BORDER_THIN; - // 圆角和直角相交的区域 - int coverWidth = 15; - g2d.fillRect(fixedX, BORDER_THIN, coverWidth, coverHeight); - - g2d.setColor(borderColor); - g2d.drawLine(getWidth() / 2, strokeOffset, getWidth(), strokeOffset); - g2d.drawLine(getWidth() / 2, getHeight() - strokeOffset, getWidth(), getHeight() - strokeOffset); - g2d.drawLine(getWidth() - strokeOffset, strokeOffset, getWidth() - strokeOffset, getHeight() - strokeOffset); + FlatUIUtils.setRenderingHints(g2d); + Path2D path2D = FineUIUtils.createLeftRoundRectangle(0, 0, + getWidth() - BORDER_THIN, getHeight() - BORDER_THIN, ARC_DIAMETER); + g2d.draw(path2D); } } }; - selectWorkspacePanel.setLayout(new BorderLayout(0,0)); + selectWorkspacePanel.setLayout(new BorderLayout()); selectWorkspacePanel.setToolTipText(Toolkit.i18nText("Fine-Design_Startup_Page_Double_Click_Enter_Workspace")); - selectWorkspacePanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + selectWorkspacePanel.setBorder(new ScaledEmptyBorder(10, 10, 10, 10)); { - + JPanel iconPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); - iconPanel.setBorder(new EmptyBorder(0, 10, 0, 10)); Icon icon = StartupPageUtil.getIcon4DescAreaByWorkspace(workspaceInfo); UILabel label = new UILabel(icon); label.setPreferredSize(LABEL_DIMENSION); iconPanel.add(label, BorderLayout.CENTER); + iconPanel.setOpaque(false); selectWorkspacePanel.add(iconPanel, BorderLayout.WEST); - + // desc / >箭头 JPanel descPanel = new JPanel(); + descPanel.setOpaque(false); descPanel.setLayout(FRGUIPaneFactory.createM_BorderLayout()); - descPanel.setBorder(new EmptyBorder(0, 10, 0, 0)); JPanel simpleDescPanelWrapper = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.CENTER, 0, 0); JPanel simpleDescPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); UILabel nameLabel = new UILabel(workspaceInfo.getName()); - Font font = nameLabel.getFont(); - Font newSizeFont = font.deriveFont(font.getStyle(), NAME_LABEL_SIZE); - nameLabel.setFont(newSizeFont); + FineUIUtils.setFontSize(nameLabel, NAME_LABEL_SIZE); nameLabel.setPreferredSize(PATH_DIMENSION); Color nameForeground = nameLabel.getForeground(); simpleDescPanel.add(nameLabel,BorderLayout.NORTH); - + UILabel pathLabel = new UILabel(workspaceInfo.getPath()); pathLabel.setPreferredSize(PATH_DIMENSION); - Font pathFont = pathLabel.getFont(); - pathLabel.setFont(pathFont.deriveFont(pathFont.getStyle(), PATH_LABEL_SIZE)); + FineUIUtils.setFontSize(pathLabel, PATH_LABEL_SIZE); Color pathColor = PATH_COLOR; pathLabel.setForeground(pathColor); simpleDescPanel.add(pathLabel, BorderLayout.SOUTH); + simpleDescPanel.setOpaque(false); simpleDescPanelWrapper.add(simpleDescPanel); - + simpleDescPanelWrapper.setOpaque(false); + descPanel.add(simpleDescPanelWrapper, BorderLayout.WEST); - + MouseAdapter selectWorkspaceMouseListener = new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { - Color hoverColor = HOVER_COLOR; + Color hoverColor = FlatUIUtils.getUIColor("brand.normal", HOVER_COLOR); borderColorRef.set(hoverColor); nameLabel.setForeground(hoverColor); pathLabel.setForeground(hoverColor ); repaintAll(); } - + @Override public void mouseExited(MouseEvent e) { borderColorRef.set(Color.WHITE); @@ -436,10 +391,10 @@ public class StartupPageWorkspacePanel extends JPanel { } doSwitchWorkspace(workspaceInfo); } - + }; - - UILabel arrowLabel = new UILabel(IconUtils.readIcon("/com/fr/design/startup/more.svg")) { + + UILabel arrowLabel = new UILabel(new LazyIcon("more_arrow", 20)) { @Override public JToolTip createToolTip() { return new ModernToolTip(); @@ -449,13 +404,13 @@ public class StartupPageWorkspacePanel extends JPanel { arrowLabel.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { - arrowLabel.setIcon(IconUtils.readIcon("/com/fr/design/startup/more_hover.svg")); + arrowLabel.setIcon(new LazyIcon("more_arrow_hover", 20)); selectWorkspaceMouseListener.mouseEntered(e); } - + @Override public void mouseExited(MouseEvent e) { - arrowLabel.setIcon(IconUtils.readIcon("/com/fr/design/startup/more.svg")); + arrowLabel.setIcon(new LazyIcon("more_arrow", 20)); selectWorkspaceMouseListener.mouseExited(e); } @@ -465,18 +420,16 @@ public class StartupPageWorkspacePanel extends JPanel { } }); descPanel.add(arrowLabel, BorderLayout.EAST); - selectWorkspacePanel.add(descPanel, BorderLayout.CENTER); selectWorkspacePanel.addMouseListener(selectWorkspaceMouseListener); } - - ColorUtils.syncBackground(selectWorkspacePanel, Color.WHITE); + selectWorkspacePanel.setPreferredSize(SELECT_WORKSPACE_DIMENSION); workspaceItemDesc.add(selectWorkspacePanel, BorderLayout.WEST); } - + private void layoutSelectAndCreatePanel(StartupWorkspaceBean workspaceInfo, JPanel workspaceItemDesc) { - + // 选择并新建 AtomicReference borderColorRef = new AtomicReference<>(null); JPanel selectAndCreatePanel = new JPanel() { @@ -489,58 +442,43 @@ public class StartupPageWorkspacePanel extends JPanel { protected void paintComponent(Graphics g) { Graphics2D g2d = (Graphics2D) g; g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - Color borderColor = borderColorRef.get(); - - Color backColor = SHALLOW_WHITE_COLOR; + + Color backColor = FlatUIUtils.getUIColor("fill.deep", Color.GRAY); g2d.setColor(backColor); - - // 见 layoutSelectWorkspacePanel 部分的分析 - // 直角和圆角上下叠合在一起 - int rectOffset = 10; - int roundOffset = 15; - int strokeOffset = BORDER_THIN / 2; - int fixedRoundOffset = roundOffset + strokeOffset; - g2d.fillRoundRect(0, 0, getWidth() - rectOffset, getHeight(), 0, 0); - g2d.fillRoundRect(getWidth() - fixedRoundOffset, 0, roundOffset, getHeight(), ARC_DIAMETER, ARC_DIAMETER); + Path2D shape = FineUIUtils.createRightRoundRectangle(0, 0, this.getWidth(), this.getHeight(), ARC_DIAMETER); + g2d.fill(shape); + + Color borderColor = borderColorRef.get(); if (borderColor != null) { g2d.setColor(borderColor); g2d.setStroke(new BasicStroke(BORDER_THIN)); - - int borderOffset = BORDER_THIN * 2; - // 画画的笔触需要调整一下 - g2d.drawRoundRect(strokeOffset, strokeOffset, getWidth() - borderOffset, getHeight() - BORDER_THIN, ARC_DIAMETER, ARC_DIAMETER); - g2d.setColor(backColor); - int fillWidth = 15; - g2d.fillRect(0, 0, fillWidth, getHeight()); - - g2d.setColor(borderColor); - g2d.drawLine(strokeOffset, strokeOffset, fillWidth, strokeOffset); - g2d.drawLine(strokeOffset, getHeight() - strokeOffset, fillWidth, getHeight() - strokeOffset); - g2d.drawLine(strokeOffset, strokeOffset, strokeOffset, getHeight() - strokeOffset); + FlatUIUtils.setRenderingHints(g2d); + Path2D path2D = FineUIUtils.createRightRoundRectangle(0, 0, + getWidth() - BORDER_THIN, getHeight() - BORDER_THIN, ARC_DIAMETER); + g2d.draw(path2D); } } - + }; selectAndCreatePanel.setToolTipText(Toolkit.i18nText("Fine-Design_Startup_Page_Enter_Workspace_And_Create")); - selectAndCreatePanel.setBorder(new EmptyBorder(0, 0, 0, 0)); selectAndCreatePanel.setLayout(new BorderLayout()); { - UILabel label = new UILabel(IconUtils.readIcon("/com/fr/design/standard/system/add")); + UILabel label = new UILabel(new LazyIcon("add", 20)); label.setPreferredSize(new Dimension(ARC_DIAMETER, ARC_DIAMETER)); - label.setForeground(HOVER_COLOR); + label.setForeground(FlatUIUtils.getUIColor("brand.normal", HOVER_COLOR)); selectAndCreatePanel.add(label, BorderLayout.CENTER); selectAndCreatePanel.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { - borderColorRef.set(HOVER_COLOR); - label.setIcon(IconUtils.readIcon("/com/fr/design/standard/system/add_hover.svg")); + borderColorRef.set(FlatUIUtils.getUIColor("brand.normal", HOVER_COLOR)); + label.setIcon(new LazyIcon("add_hover", 20)); repaintAll(); } - + @Override public void mouseExited(MouseEvent e) { borderColorRef.set(null); - label.setIcon(IconUtils.readIcon("/com/fr/design/standard/system/add")); + label.setIcon(new LazyIcon("add", 20)); repaintAll(); } @Override @@ -550,73 +488,91 @@ public class StartupPageWorkspacePanel extends JPanel { } }); } - ColorUtils.syncBackground(selectAndCreatePanel, Color.GREEN); selectAndCreatePanel.setPreferredSize(SELECT_CREATE_DIMENSION); workspaceItemDesc.add(selectAndCreatePanel, BorderLayout.EAST); } - + public void setSelectWorkspaceRunnable(Runnable selectWorkspaceRunnable) { - + this.selectWorkspaceRunnable = selectWorkspaceRunnable; } - + private void doOpenEmptyTemplate(StartupWorkspaceBean workspaceInfo) { - + pageModel.setSelectWorkspaceInfo(workspaceInfo); openEmptyTemplateRunnable.run(); - + DesignerMetrics designerMetrics = DesignerStartupContext.getInstance().getDesignerMetrics(); designerMetrics.getStatistic().recordOpenEmptyTemplate(); } - + private void doSwitchWorkspace(StartupWorkspaceBean workspaceInfo) { - + StartupWorkspaceBean lastWorkspaceInfo = pageModel.getSelectWorkspaceInfo(); // selectWorkspaceRunnable pageModel.setSelectWorkspaceInfo(workspaceInfo); selectWorkspaceRunnable.run(); - + DesignerMetrics designerMetrics = DesignerStartupContext.getInstance().getDesignerMetrics(); designerMetrics.getStatistic().recordSwitchWorkspace(lastWorkspaceInfo, workspaceInfo); } - + private void doShowAllAction(UILabel fontLabel, UILabel iconLabel) { - + if (showMore) { fontLabel.setText(Toolkit.i18nText("Fine-Design_Startup_Page_Collapse_Workspace")); - iconLabel.setIcon(IconUtils.readIcon("/com/fr/design/startup/show_less.svg")); + iconLabel.setIcon(new LazyIcon("show_less")); showMoreContent(); showMore = !showMore; } else { fontLabel.setText(Toolkit.i18nText("Fine-Design_Startup_Page_Expand_All")); - iconLabel.setIcon(IconUtils.readIcon("/com/fr/design/startup/show_more.svg")); + iconLabel.setIcon(new LazyIcon("show_more")); showLessContent(); showMore = !showMore; } DesignerMetrics designerMetrics = DesignerStartupContext.getInstance().getDesignerMetrics(); designerMetrics.getStatistic().recordShowAllAction(); - + repaintAll(); } - + private void repaintAll() { - + this.getRootPane().repaint(); } - + /** * 支持透明的滚动视图 */ - private class TransparentScrollViewPort extends JViewport { - + private static class TransparentScrollViewPort extends JViewport { + /** - * 从而屏蔽掉 {@link RepaintManager.PaintManager#paintDoubleBuffered(JComponent, Image, Graphics, int, int, int, int)} - * * @return 创建一个不会实际画图的 Graphics */ @Override public Graphics getGraphics() { - + + Graphics graphics = super.getGraphics(); + return new FRGraphics2D((Graphics2D) graphics) { + @Override + public boolean drawImage(Image img, int x, int y, ImageObserver observer) { + return true; + } + }; + } + } + + /** + * 支持透明的滚动条 + */ + private static class InReactiveScrollBar extends JScrollBar { + + /** + * @return 创建一个不会实际画图的 Graphics + */ + @Override + public Graphics getGraphics() { + Graphics graphics = super.getGraphics(); return new FRGraphics2D((Graphics2D) graphics) { @Override diff --git a/designer-base/src/main/resources/com/fine/theme/icon/add_hover.svg b/designer-base/src/main/resources/com/fine/theme/icon/add_hover.svg new file mode 100644 index 0000000000..f1e8fadf5d --- /dev/null +++ b/designer-base/src/main/resources/com/fine/theme/icon/add_hover.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/designer-base/src/main/resources/com/fine/theme/icon/filetree/filetype/fvs_locked.svg b/designer-base/src/main/resources/com/fine/theme/icon/filetree/filetype/fvs_locked.svg new file mode 100644 index 0000000000..1213c7fde6 --- /dev/null +++ b/designer-base/src/main/resources/com/fine/theme/icon/filetree/filetype/fvs_locked.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/designer-base/src/main/resources/com/fine/theme/icon/startup/local_server_background.svg b/designer-base/src/main/resources/com/fine/theme/icon/startup/local_server_background.svg new file mode 100644 index 0000000000..f4fbedca90 --- /dev/null +++ b/designer-base/src/main/resources/com/fine/theme/icon/startup/local_server_background.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/designer-base/src/main/resources/com/fine/theme/icon/startup/more.svg b/designer-base/src/main/resources/com/fine/theme/icon/startup/more.svg new file mode 100755 index 0000000000..65f7b7c701 --- /dev/null +++ b/designer-base/src/main/resources/com/fine/theme/icon/startup/more.svg @@ -0,0 +1,3 @@ + + + diff --git a/designer-base/src/main/resources/com/fine/theme/icon/startup/more_hover.svg b/designer-base/src/main/resources/com/fine/theme/icon/startup/more_hover.svg new file mode 100644 index 0000000000..5b4ee1d6fd --- /dev/null +++ b/designer-base/src/main/resources/com/fine/theme/icon/startup/more_hover.svg @@ -0,0 +1,3 @@ + + + diff --git a/designer-base/src/main/resources/com/fine/theme/icon/startup/remote_server_background.svg b/designer-base/src/main/resources/com/fine/theme/icon/startup/remote_server_background.svg new file mode 100644 index 0000000000..7313efc9c4 --- /dev/null +++ b/designer-base/src/main/resources/com/fine/theme/icon/startup/remote_server_background.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/designer-base/src/main/resources/com/fine/theme/icon/startup/show_less.svg b/designer-base/src/main/resources/com/fine/theme/icon/startup/show_less.svg new file mode 100755 index 0000000000..b929630e7f --- /dev/null +++ b/designer-base/src/main/resources/com/fine/theme/icon/startup/show_less.svg @@ -0,0 +1,3 @@ + + + diff --git a/designer-base/src/main/resources/com/fine/theme/icon/startup/show_more.svg b/designer-base/src/main/resources/com/fine/theme/icon/startup/show_more.svg new file mode 100755 index 0000000000..1b7c059d97 --- /dev/null +++ b/designer-base/src/main/resources/com/fine/theme/icon/startup/show_more.svg @@ -0,0 +1,3 @@ + + + diff --git a/designer-base/src/main/resources/com/fine/theme/light/ui/fine_light.icon.json b/designer-base/src/main/resources/com/fine/theme/light/ui/fine_light.icon.json index f80479a974..34d8c06713 100644 --- a/designer-base/src/main/resources/com/fine/theme/light/ui/fine_light.icon.json +++ b/designer-base/src/main/resources/com/fine/theme/light/ui/fine_light.icon.json @@ -18,6 +18,7 @@ "remove": "remove.svg", "search": "search.svg", "add": "add.svg", + "add_hover": "add_hover.svg", "detail": "detail.svg", "dataLink": "dataLink.svg", "jumpHelp": "jumpHelp.svg", @@ -78,6 +79,7 @@ "excelFile": "filetree/filetype/excelFile.svg", "flashFile": "filetree/filetype/flashFile.svg", "frm_locked": "filetree/filetype/frm_locked.svg", + "fvs_locked": "filetree/filetype/fvs_locked.svg", "gifFile": "filetree/filetype/gifFile.svg", "htmlFile": "filetree/filetype/htmlFile.svg", "jarFile": "filetree/filetype/jarFile.svg", @@ -341,6 +343,12 @@ "data_analysis": "preview/data_analysis.svg", "variable": "variable/variable.svg", "dataItem": "variable/dataItem.svg", - "param_global": "variable/param_global.svg" + "param_global": "variable/param_global.svg", + "local_server_background": "startup/local_server_background.svg", + "remote_server_background": "startup/remote_server_background.svg", + "more_arrow": "startup/more.svg", + "more_arrow_hover": "startup/more_hover.svg", + "show_less": "startup/show_less.svg", + "show_more": "startup/show_more.svg" } } 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 5310524e57..35bc2aa9fe 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 @@ -142,6 +142,7 @@ border.divider=#DADEE7 tooltip.normal=#3F506A tooltip.disabled=#A3ADBD hover.deep=#e2fbe6 +fill.deep=#F6F9FE #---- Button ---- @@ -583,14 +584,14 @@ PopupMenuSeparator.Insets=0,10,0,10 #---- ProgressBar ---- ProgressBar.border = com.formdev.flatlaf.ui.FlatEmptyBorder -ProgressBar.arc = 4 +ProgressBar.arc = 10 ProgressBar.horizontalSize = 146,4 ProgressBar.verticalSize = 4,146 ProgressBar.cycleTime = 4000 ProgressBar.repaintInterval = 15 ProgressBar.font = -2 -ProgressBar.background = darken(@background,13%) -ProgressBar.foreground = @accentSliderColor +ProgressBar.background = #E8E8E9 +ProgressBar.foreground = #419BF9 ProgressBar.selectionBackground = @foreground ProgressBar.selectionForeground = contrast($ProgressBar.foreground, @foreground, @componentBackground) @@ -658,7 +659,7 @@ ScrollBar.allowsAbsolutePositioning = true ScrollBar.track = #00000000 ScrollBar.thumb = #0a1c3833 -ScrollBar.hoverTrackColor = darken($ScrollBar.track,3%,derived noAutoInverse) +ScrollBar.hoverTrackColor = fade(@background, 0%) ScrollBar.hoverThumbColor = darken($ScrollBar.thumb,10%,derived noAutoInverse) ScrollBar.pressedThumbColor = #0a1c3849 ScrollBar.hoverButtonBackground = darken(@background,5%,derived noAutoInverse) @@ -671,7 +672,7 @@ ScrollBar.largeBar.thumbInsets = 0,4,0,4 ScrollBar.largeBar.buttonBackground = $ScrollBar.track #---- Panel ---- -Panel.arc = 5 +Panel.arc = 20 #---- ScrollPane ---- @@ -1294,6 +1295,10 @@ CellOtherSetPane.height=$Component.defaultHeight background: fade(@background, 0%); \ borderInsets: 0,0,0,0; +[style]Panel.transparentBackground=\ + background: fade(@background, 0%); \ + border: null; + #---- clearButton ---- # for clear/cancel button in text fields @@ -1333,3 +1338,8 @@ CellOtherSetPane.height=$Component.defaultHeight [style]Tree.pureTree = \ background: $fill.normal + +[style]ScrollBar.transparentBackground = \ + background: null;\ + track: fade(@background, 0%); \ + hoverTrackColor : fade(@background, 0%) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/base/DownloadProgressPane.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/base/DownloadProgressPane.java index c7f09f453b..5401ffafb4 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/base/DownloadProgressPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/base/DownloadProgressPane.java @@ -79,7 +79,6 @@ public class DownloadProgressPane extends JPanel { private JProgressBar createProgressBar() { JProgressBar jProgressBar = new JProgressBar(); - jProgressBar.setUI(new ModernUIProgressBarUI()); jProgressBar.setBorderPainted(false); jProgressBar.setOpaque(false); jProgressBar.setBorder(null);