diff --git a/designer-base/src/main/java/com/fr/design/components/tooltip/ModernToolTip.java b/designer-base/src/main/java/com/fr/design/components/tooltip/ModernToolTip.java index 0a01f8bbf2..5125c00271 100644 --- a/designer-base/src/main/java/com/fr/design/components/tooltip/ModernToolTip.java +++ b/designer-base/src/main/java/com/fr/design/components/tooltip/ModernToolTip.java @@ -12,11 +12,9 @@ import javax.swing.plaf.ToolTipUI; import java.awt.Color; import java.awt.Dimension; import java.awt.FontMetrics; -import java.awt.GradientPaint; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.RenderingHints; -import java.awt.geom.GeneralPath; import java.io.BufferedReader; import java.io.IOException; import java.io.StringReader; @@ -52,7 +50,7 @@ public class ModernToolTip extends UIToolTip { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setColor(new Color(51, 51, 52, (int) Math.round(0.7 * 255))); - g2.fillRoundRect(0, 0, width, height, 0, 0); + g2.fillRoundRect(0, 0, width, height, 4, 4); g2.setColor(Color.WHITE); if (strs != null) { diff --git a/designer-base/src/main/java/com/fr/design/utils/ColorUtils.java b/designer-base/src/main/java/com/fr/design/utils/ColorUtils.java index 7c0daa111f..992970043d 100644 --- a/designer-base/src/main/java/com/fr/design/utils/ColorUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/ColorUtils.java @@ -27,6 +27,26 @@ public class ColorUtils { } } } + + public static void syncBackgroundIfAbsent(Component component, Color replaceColor, Color defaultColor) { + + if (component.getBackground() != defaultColor) { + return; + } + component.setBackground(replaceColor); + if (component instanceof Container) { + Container container = (Container) component; + Component[] components = container.getComponents(); + if (components != null) { + Arrays.stream(components).forEach((e) -> syncBackgroundIfAbsent(e, replaceColor, defaultColor)); + } + } + } + + public static void transparentBackground(Component component) { + + syncBackgroundIfAbsent(component, new Color(0,0,0,0), ThemeUtils.BACK_COLOR); + } public static boolean isDarkColor(Color color) { if(color == null) { 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 ae27e1a9ef..8c414cecfe 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 @@ -1,5 +1,7 @@ package com.fr.startup.ui; +import java.awt.Color; + /** * created by Harrison on 2022/07/07 **/ @@ -14,4 +16,14 @@ public class StartupPageConstants { * 内容宽度 */ public static final int CONTENT_WIDTH = 850; + + /** + * 边框的颜色 + */ + public static final Color BORDER_COLOR = Color.WHITE; + + /** + * 透明的颜色 + */ + public static final Color TRANSPARENT_COLOR = new Color(0, 0, 0, 0); } 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 fd79c9fe36..f7cfa87267 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 @@ -6,6 +6,8 @@ import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; import javax.swing.Icon; +import javax.swing.JComponent; +import javax.swing.JRootPane; import java.net.URL; /** @@ -68,4 +70,12 @@ public class StartupPageUtil { return urlStr; } } + + public static void repaintAll(JComponent component) { + + JRootPane rootPane = component.getRootPane(); + if (rootPane != null) { + rootPane.repaint(); + } + } } 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 709152524c..e62005b283 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 @@ -11,8 +11,10 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.VerticalFlowLayout; import com.fr.design.ui.util.UIUtil; import com.fr.design.utils.ColorUtils; +import com.fr.design.utils.ThemeUtils; import com.fr.exit.DesignerExiter; import com.fr.general.GeneralUtils; +import com.fr.general.IOUtils; import com.fr.log.FineLoggerFactory; import com.fr.stable.ProductConstants; import com.fr.stable.collections.CollectionUtils; @@ -43,6 +45,7 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; +import java.awt.image.BufferedImage; import java.util.List; import java.util.Map; @@ -95,6 +98,7 @@ public class StartupPageWindow extends JFrame { setLayout(new BorderLayout()); this.body = FRGUIPaneFactory.createBorderLayout_S_Pane(); + this.body.setBackground(new Color(0, 0, 0, 0)); // Header UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Startup_Page_Select_Workspace")); Font font = label.getFont(); @@ -104,6 +108,7 @@ public class StartupPageWindow extends JFrame { LayoutManager centerFlowLayout = FRGUIPaneFactory.createCenterFlowLayout(); headerPanel.setLayout(centerFlowLayout); headerPanel.add(label); + headerPanel.setBackground(new Color(0, 0, 0, 0)); this.body.add(headerPanel, BorderLayout.NORTH); // Workspace-description @@ -125,7 +130,14 @@ public class StartupPageWindow extends JFrame { this.recentOpenPanel = generateRecentOpenPanel(pageModel); this.body.add(recentOpenPanel, BorderLayout.SOUTH); - this.contentPane = new JPanel(); + this.contentPane = new JPanel() { + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + BufferedImage image = IOUtils.readImage("com/fr/design/startup/startup_page_background.jpg"); + g.drawImage(image, 0, 0, SCREEN_SIZE.width, SCREEN_SIZE.height, this); + } + }; this.contentPane.setLayout(getCenterLayout(body)); this.contentPane.add(this.body, BorderLayout.CENTER); this.contentPane.setPreferredSize(this.body.getPreferredSize()); @@ -302,6 +314,7 @@ public class StartupPageWindow extends JFrame { 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); return recentOpenWrapperPanel; } @@ -330,11 +343,13 @@ public class StartupPageWindow extends JFrame { @Override public void mouseEntered(MouseEvent e) { recentFileLabel.setForeground(HOVER_COLOR); + StartupPageUtil.repaintAll(recentOpenGroupPanel); } @Override public void mouseExited(MouseEvent e) { recentFileLabel.setForeground(recentFileLabelForeground); + StartupPageUtil.repaintAll(recentOpenGroupPanel); } @Override @@ -362,8 +377,10 @@ public class StartupPageWindow extends JFrame { } private StartupPageWorkspacePanel generateWorkspacePanel(StartupPageModel pageModel) { - - return new StartupPageWorkspacePanel(pageModel); + + StartupPageWorkspacePanel startupPageWorkspacePanel = new StartupPageWorkspacePanel(pageModel); + ColorUtils.syncBackgroundIfAbsent(startupPageWorkspacePanel, new Color(0, 0, 0, 0), ThemeUtils.BACK_COLOR); + return startupPageWorkspacePanel; } protected LayoutManager getCenterLayout(JComponent centerBody) { @@ -376,4 +393,5 @@ public class StartupPageWindow extends JFrame { DesignerEnvManager.getEnvManager().setLastOpenFile(recentFile); pageModel.getOpenLastTemplateRunnable().run(); } + } 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 1cc1805497..de1e5f62be 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 @@ -89,6 +89,7 @@ public class StartupPageWorkspacePanel extends JPanel { public StartupPageWorkspacePanel(StartupPageModel pageModel) { this.setLayout(new BorderLayout(0, 0)); + this.setBorder(new EmptyBorder(15, 0, 20, 0)); this.pageModel = pageModel; @@ -129,10 +130,10 @@ public class StartupPageWorkspacePanel extends JPanel { JPanel workspaceDescWrapper = new JPanel(); workspaceDescWrapper.setLayout(new BorderLayout(0, 0)); - workspaceDescWrapper.setBorder(new EmptyBorder(20, 0, 0, 0)); + workspaceDescWrapper.setBorder(new EmptyBorder(0, 0, 0, 0)); JPanel workspaceDescPanel = new JPanel(); - workspaceDescPanel.setLayout(new GridLayout(partitions.size(), 1, 0, ITEM_VERTICAL_GAP)); + workspaceDescPanel.setLayout(new GridLayout(partitions.size(), 1, 0, 0)); for (List partition : partitions) { JPanel partitionPanel = generatePartitionPanel(partition); workspaceDescPanel.add(partitionPanel); @@ -144,15 +145,17 @@ public class StartupPageWorkspacePanel extends JPanel { scrollPane.setBorder(new EmptyBorder(10, 0, 0, 0)); scrollPane.setPreferredSize(new Dimension(CONTENT_WIDTH, SCROLL_HEIGHT)); workspaceDescWrapper.add(scrollPane, BorderLayout.CENTER); - return scrollPane; + return workspaceDescWrapper; } workspaceDescWrapper.add(workspaceDescPanel, BorderLayout.CENTER); + + ColorUtils.transparentBackground(workspaceDescWrapper); return workspaceDescWrapper; } private JPanel generateLimitContentPanel(List> partitions) { - JPanel workspaceDescPanel = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEFT, 0, ITEM_VERTICAL_GAP); + JPanel workspaceDescPanel = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEFT, 0, 0); int limit = 2; for (int i = 0; i < partitions.size(); i++) { if (i >= limit) { @@ -163,22 +166,38 @@ public class StartupPageWorkspacePanel extends JPanel { JPanel partitionPanel = generatePartitionPanel(partition); workspaceDescPanel.add(partitionPanel); } + + ColorUtils.transparentBackground(workspaceDescPanel); + 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(); + JPanel showAllPanel = new JPanel() { + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + if (hoverBackColorRef.get() != null) { + g.setColor(hoverBackColorRef.get()); + Dimension preferredSize = getPreferredSize(); + g.fillRoundRect(0, 0, preferredSize.width, preferredSize.height, 5, 5); + } + } + }; showAllPanel.setLayout(new BorderLayout(5, 0)); showAllPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); UILabel fontLabel = new UILabel(Toolkit.i18nText("Fine-Design_Startup_Page_Expand_All")); fontLabel.setForeground(HOVER_COLOR); + showAllPanel.setBackground(new Color(0, 0, 0, 0)); showAllPanel.add(fontLabel, BorderLayout.WEST); UILabel iconLabel = new UILabel(IconUtils.readIcon("/com/fr/design/startup/show_more.svg")); @@ -189,13 +208,16 @@ public class StartupPageWorkspacePanel extends JPanel { showAllPanel.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { - Color hoverColor = new Color(217, 235, 254); - showAllPanel.setBackground(hoverColor); + 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(); } @Override @@ -213,7 +235,11 @@ public class StartupPageWorkspacePanel extends JPanel { @NotNull private JPanel generatePartitionPanel(List partition) { - JPanel partitionPanel = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(0, 20, 0);; + 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"); for (StartupWorkspaceBean workspaceInfo : partition) { @@ -229,7 +255,9 @@ public class StartupPageWorkspacePanel extends JPanel { Dimension preferredSize = partitionPanel.getPreferredSize(); partitionPanel.setPreferredSize(new Dimension(CONTENT_WIDTH, (int) preferredSize.getHeight())); } - return partitionPanel; + + partitionPanelWrapper.add(partitionPanel, BorderLayout.CENTER); + return partitionPanelWrapper; } private void layoutSelectWorkspacePanel(StartupWorkspaceBean workspaceInfo, JPanel workspaceItemDesc) { @@ -294,8 +322,8 @@ public class StartupPageWorkspacePanel extends JPanel { int roundOffset = 15; // 画一个圆角 int fixRoundWidth = getWidth() - rectOffset; - int fixRoundHeight = getHeight() - BORDER_THIN * 2; - g2d.drawRoundRect(BORDER_THIN, BORDER_THIN, fixRoundWidth, fixRoundHeight, ARC_DIAMETER, ARC_DIAMETER); + int fixRoundHeight = getHeight() - BORDER_THIN; + g2d.drawRoundRect(strokeOffset, strokeOffset, fixRoundWidth, fixRoundHeight, ARC_DIAMETER, ARC_DIAMETER); g2d.setColor(backColor); @@ -309,9 +337,9 @@ public class StartupPageWorkspacePanel extends JPanel { g2d.fillRect(fixedX, BORDER_THIN, coverWidth, coverHeight); g2d.setColor(borderColor); - g2d.drawLine(getWidth() / 2, BORDER_THIN, getWidth(), BORDER_THIN); - g2d.drawLine(getWidth() / 2, getHeight() - BORDER_THIN, getWidth(), getHeight() - BORDER_THIN); - g2d.drawLine(getWidth() - strokeOffset, BORDER_THIN, getWidth() - strokeOffset, getHeight() - BORDER_THIN); + 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); } } }; @@ -362,7 +390,7 @@ public class StartupPageWorkspacePanel extends JPanel { borderColorRef.set(hoverColor); nameLabel.setForeground(hoverColor); pathLabel.setForeground(hoverColor ); - selectWorkspacePanel.getParent().repaint(); + repaintAll(); } @Override @@ -370,7 +398,7 @@ public class StartupPageWorkspacePanel extends JPanel { borderColorRef.set(Color.WHITE); nameLabel.setForeground(nameForeground); pathLabel.setForeground(pathColor); - selectWorkspacePanel.getParent().repaint(); + repaintAll(); } @Override @@ -455,16 +483,15 @@ public class StartupPageWorkspacePanel extends JPanel { int borderOffset = BORDER_THIN * 2; // 画画的笔触需要调整一下 - //g2d.drawRoundRect(strokeOffset, strokeOffset, getWidth() - rectOffset, getHeight() - BORDER_THIN, 0, 0); - g2d.drawRoundRect(BORDER_THIN, BORDER_THIN, getWidth() - borderOffset, getHeight() - borderOffset, ARC_DIAMETER, ARC_DIAMETER); + 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(BORDER_THIN, BORDER_THIN, fillWidth, BORDER_THIN); - g2d.drawLine(BORDER_THIN, getHeight() - BORDER_THIN, fillWidth, getHeight() - BORDER_THIN); - g2d.drawLine(BORDER_THIN, BORDER_THIN, BORDER_THIN, getHeight() - BORDER_THIN); + g2d.drawLine(strokeOffset, strokeOffset, fillWidth, strokeOffset); + g2d.drawLine(strokeOffset, getHeight() - strokeOffset, fillWidth, getHeight() - strokeOffset); + g2d.drawLine(strokeOffset, strokeOffset, strokeOffset, getHeight() - strokeOffset); } } @@ -481,15 +508,15 @@ public class StartupPageWorkspacePanel extends JPanel { @Override public void mouseEntered(MouseEvent e) { borderColorRef.set(HOVER_COLOR); - selectAndCreatePanel.getParent().repaint(); label.setIcon(IconUtils.readIcon("/com/fr/design/standard/system/add_hover.svg")); + repaintAll(); } @Override public void mouseExited(MouseEvent e) { borderColorRef.set(null); - selectAndCreatePanel.getParent().repaint(); label.setIcon(IconUtils.readIcon("/com/fr/design/standard/system/add.svg")); + repaintAll(); } @Override public void mousePressed(MouseEvent e) { @@ -533,5 +560,11 @@ public class StartupPageWorkspacePanel extends JPanel { showLessContent(); showMore = !showMore; } + repaintAll(); + } + + private void repaintAll() { + + this.getRootPane().repaint(); } } diff --git a/designer-base/src/main/resources/com/fr/design/startup/startup_page_background.jpg b/designer-base/src/main/resources/com/fr/design/startup/startup_page_background.jpg new file mode 100755 index 0000000000..ad0c5de365 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/startup/startup_page_background.jpg differ