diff --git a/designer-base/src/main/java/com/fine/theme/light/ui/FineComboBoxUI.java b/designer-base/src/main/java/com/fine/theme/light/ui/FineComboBoxUI.java index 1e712238df..b410afc207 100644 --- a/designer-base/src/main/java/com/fine/theme/light/ui/FineComboBoxUI.java +++ b/designer-base/src/main/java/com/fine/theme/light/ui/FineComboBoxUI.java @@ -2,16 +2,21 @@ package com.fine.theme.light.ui; import com.fine.theme.utils.FineClientProperties; import com.fine.theme.utils.FineUIScale; +import com.fine.theme.utils.FineUIUtils; import com.formdev.flatlaf.ui.FlatComboBoxUI; import com.formdev.flatlaf.ui.FlatUIUtils; -import org.jetbrains.annotations.Nullable; import javax.swing.JButton; +import javax.swing.JComboBox; import javax.swing.JComponent; +import javax.swing.JScrollPane; +import javax.swing.ScrollPaneConstants; import javax.swing.SwingConstants; import javax.swing.plaf.ComponentUI; +import javax.swing.plaf.basic.ComboPopup; import java.awt.Dimension; import java.awt.Graphics2D; +import java.awt.Rectangle; /** * 提供 {@link javax.swing.JComboBox} 的UI类 @@ -47,8 +52,10 @@ public class FineComboBoxUI extends FlatComboBoxUI { @Override public Dimension getMinimumSize(JComponent c) { // ComboBox基于子组件计算适配尺寸性能一般,仅考虑部分ComboBox进行适配计算,其他采用默认值 - if (FineClientProperties.ADAPTIVE_COMBO_BOX.equals(getComboBoxTypeStr(c))) { - return super.getMinimumSize(c); + if (isAdaptiveComboBox(c)) { + Dimension dimension = super.getMinimumSize(c); + return new Dimension(Math.min(dimension.width, + FineUIUtils.getAndScaleInt("ComboBox.maximumWidth", 400)), dimension.height); } return FineUIScale.scale(new Dimension( FlatUIUtils.getUIInt("ComboBox.minimumWidth", 72), @@ -56,12 +63,41 @@ public class FineComboBoxUI extends FlatComboBoxUI { )); } - @Nullable - static String getComboBoxTypeStr(JComponent c) { + static boolean isAdaptiveComboBox(JComponent c) { Object value = c.getClientProperty(FineClientProperties.COMBO_BOX_TYPE); if (value instanceof String) { - return (String) value; + return FineClientProperties.ADAPTIVE_COMBO_BOX.equals(value); + } + return false; + } + + @Override + protected ComboPopup createPopup() { + return new FineComboPopup(this.comboBox); + } + + protected class FineComboPopup extends FlatComboPopup { + + protected FineComboPopup(JComboBox combo) { + super(combo); + } + + @Override + protected Rectangle computePopupBounds(int px, int py, int pw, int ph) { + Rectangle fitRectangle = super.computePopupBounds(px, py, pw, ph); + // 限制最大宽度,如超出则高度预留展示横向滚动条所需宽度 + int comboWidth = comboBox.getWidth(); + if (fitRectangle.width > comboWidth) { + return new Rectangle(px, py, comboWidth, fitRectangle.height + FlatUIUtils.getUIInt("ScrollBar.width", 10)); + } + return fitRectangle; + } + + @Override + protected JScrollPane createScroller() { + return new JScrollPane( list, + ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, + ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); } - return null; } } diff --git a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java index 598ec35677..60e26e75a3 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java +++ b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java @@ -452,21 +452,6 @@ public class UIResizableContainer extends JPanel { repaint(); } - @Override - public void mouseClicked(MouseEvent e) { - if (e.getY() <= ARROW_RANGE_VERTICAL) { - if (containerWidth == toolPaneHeight) { - containerWidth = preferredWidth; - } else { - setPreferredWidth(containerWidth); - containerWidth = toolPaneHeight; - } - refreshContainer(); - if (DesignModeContext.isAuthorityEditing()) { - DesignerContext.getDesignerFrame().doResize(); - } - } - } }); } diff --git a/designer-base/src/main/java/com/fr/design/gui/ilist/CheckBoxList.java b/designer-base/src/main/java/com/fr/design/gui/ilist/CheckBoxList.java index 66c697bd89..174d8bc199 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ilist/CheckBoxList.java +++ b/designer-base/src/main/java/com/fr/design/gui/ilist/CheckBoxList.java @@ -256,13 +256,6 @@ public class CheckBoxList extends JComponent { this.setBackground(list.getBackground()); this.setForeground(list.getForeground()); } - - if (cellHasFocus) { - this.setBorder(UIManager.getBorder("List.focusCellHighlightBorder")); - } else { - this.setBorder(NO_FOCUS_BORDER); - } - return this; } } diff --git a/designer-base/src/main/java/com/fr/design/widget/component/BackgroundCompPane.java b/designer-base/src/main/java/com/fr/design/widget/component/BackgroundCompPane.java index 98e4844ade..c3cdb42990 100644 --- a/designer-base/src/main/java/com/fr/design/widget/component/BackgroundCompPane.java +++ b/designer-base/src/main/java/com/fr/design/widget/component/BackgroundCompPane.java @@ -1,5 +1,6 @@ package com.fr.design.widget.component; +import com.formdev.flatlaf.util.ScaledEmptyBorder; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ilable.UILabel; @@ -12,7 +13,6 @@ import javax.swing.JPanel; import static com.fine.swing.ui.layout.Layouts.cell; import static com.fine.swing.ui.layout.Layouts.column; -import static com.fine.swing.ui.layout.Layouts.flex; import static com.fine.swing.ui.layout.Layouts.row; import static com.fr.design.constants.LayoutConstants.LEFT_WEIGHT; import static com.fr.design.constants.LayoutConstants.RIGHT_WEIGHT; @@ -40,26 +40,24 @@ public abstract class BackgroundCompPane extends BasicPane { backgroundHead = new UIButtonGroup(titles); panel = column(VERTICAL_GAP, row( - flex(LEFT_WEIGHT), cell(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Background_Initial"))).weight(RIGHT_WEIGHT / 2), cell(initialBackgroundEditor).weight(RIGHT_WEIGHT / 2) ), row( - flex(LEFT_WEIGHT), cell(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Background_Over"))).weight(RIGHT_WEIGHT / 2), cell(overBackgroundEditor).weight(RIGHT_WEIGHT / 2) ), row( - flex(LEFT_WEIGHT), cell(getClickLabel()).weight(RIGHT_WEIGHT / 2), cell(clickBackgroundEditor).weight(RIGHT_WEIGHT / 2) ) - ).getComponent(); + ).with(it -> it.setBorder(new ScaledEmptyBorder(0, 10, 0, 0))).getComponent(); this.add(column(VERTICAL_GAP, row( cell(headLabel).weight(LEFT_WEIGHT), cell(backgroundHead).weight(RIGHT_WEIGHT) - ) + ), + cell(panel) ).getComponent()); } diff --git a/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_bottom_align.svg b/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_bottom_align.svg new file mode 100644 index 0000000000..25544d99e1 --- /dev/null +++ b/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_bottom_align.svg @@ -0,0 +1,4 @@ + + + + diff --git a/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_bottom_align_disable.svg b/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_bottom_align_disable.svg new file mode 100644 index 0000000000..a3f5e89fb5 --- /dev/null +++ b/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_bottom_align_disable.svg @@ -0,0 +1,4 @@ + + + + diff --git a/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_horizontal_center.svg b/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_horizontal_center.svg new file mode 100644 index 0000000000..0686dc97bf --- /dev/null +++ b/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_horizontal_center.svg @@ -0,0 +1,4 @@ + + + + diff --git a/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_horizontal_center_disable.svg b/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_horizontal_center_disable.svg new file mode 100644 index 0000000000..15185165ab --- /dev/null +++ b/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_horizontal_center_disable.svg @@ -0,0 +1,4 @@ + + + + diff --git a/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_horizontal_distribute.svg b/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_horizontal_distribute.svg new file mode 100644 index 0000000000..0cb2dba130 --- /dev/null +++ b/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_horizontal_distribute.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_horizontal_distribute_disable.svg b/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_horizontal_distribute_disable.svg new file mode 100644 index 0000000000..bdbc4cb218 --- /dev/null +++ b/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_horizontal_distribute_disable.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_left_align.svg b/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_left_align.svg new file mode 100644 index 0000000000..f611b29c34 --- /dev/null +++ b/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_left_align.svg @@ -0,0 +1,4 @@ + + + + diff --git a/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_left_align_disable.svg b/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_left_align_disable.svg new file mode 100644 index 0000000000..2dad9aa3c1 --- /dev/null +++ b/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_left_align_disable.svg @@ -0,0 +1,4 @@ + + + + diff --git a/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_right_align.svg b/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_right_align.svg new file mode 100644 index 0000000000..d914b29fef --- /dev/null +++ b/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_right_align.svg @@ -0,0 +1,4 @@ + + + + diff --git a/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_right_align_disable.svg b/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_right_align_disable.svg new file mode 100644 index 0000000000..1e2368cc87 --- /dev/null +++ b/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_right_align_disable.svg @@ -0,0 +1,4 @@ + + + + diff --git a/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_top_align.svg b/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_top_align.svg new file mode 100644 index 0000000000..efc6bd391d --- /dev/null +++ b/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_top_align.svg @@ -0,0 +1,4 @@ + + + + diff --git a/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_top_align_disable.svg b/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_top_align_disable.svg new file mode 100644 index 0000000000..2087739095 --- /dev/null +++ b/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_top_align_disable.svg @@ -0,0 +1,4 @@ + + + + diff --git a/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_vertical_center.svg b/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_vertical_center.svg new file mode 100644 index 0000000000..0fd18a1aa4 --- /dev/null +++ b/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_vertical_center.svg @@ -0,0 +1,4 @@ + + + + diff --git a/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_vertical_center_disable.svg b/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_vertical_center_disable.svg new file mode 100644 index 0000000000..0479e03629 --- /dev/null +++ b/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_vertical_center_disable.svg @@ -0,0 +1,4 @@ + + + + diff --git a/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_vertical_distribute.svg b/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_vertical_distribute.svg new file mode 100644 index 0000000000..45c0fdea12 --- /dev/null +++ b/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_vertical_distribute.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_vertical_distribute_disable.svg b/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_vertical_distribute_disable.svg new file mode 100644 index 0000000000..4c799c85cf --- /dev/null +++ b/designer-base/src/main/resources/com/fine/theme/icon/arrange/arrange_vertical_distribute_disable.svg @@ -0,0 +1,5 @@ + + + + + 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 3d09c571bf..475c24d733 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 @@ -472,7 +472,14 @@ "layout_top_right": "layout/layout_top_right.svg", "theme_edit": "theme_edit.svg", "folder_half_authority" : "filetree/folder_half_authority.svg", - "folder_half_authority_open" : "filetree/folder_half_authority_open.svg" - + "folder_half_authority_open" : "filetree/folder_half_authority_open.svg", + "arrange_left_align": "arrange/arrange_left_align.svg", + "arrange_horizontal_center": "arrange/arrange_horizontal_center.svg", + "arrange_right_align": "arrange/arrange_right_align.svg", + "arrange_top_align": "arrange/arrange_top_align.svg", + "arrange_vertical_center": "arrange/arrange_vertical_center.svg", + "arrange_bottom_align": "arrange/arrange_bottom_align.svg", + "arrange_horizontal_distribute": "arrange/arrange_horizontal_distribute.svg", + "arrange_vertical_distribute": "arrange/arrange_vertical_distribute.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 34e9f8e3c5..0adc8cf686 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 @@ -302,6 +302,7 @@ ColorChooser.swatchesDefaultRecentColor = $control ComboBox.border = com.fine.theme.light.ui.FineRoundBorder ComboBox.padding = @componentMargin ComboBox.minimumWidth = 72 +ComboBox.maximumWidth = 400 ComboBox.editorColumns = 0 ComboBox.maximumRowCount = 15 [mac]ComboBox.showPopupOnNavigation = true diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/MapAreaMatchPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/MapAreaMatchPane.java index 0334044235..970b5ea9fc 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/MapAreaMatchPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/MapAreaMatchPane.java @@ -1,7 +1,6 @@ package com.fr.design.chartx.component; import com.fine.theme.icon.LazyIcon; -import com.fine.theme.utils.FineLayoutBuilder; import com.fine.theme.utils.FineUIUtils; import com.formdev.flatlaf.util.ScaledEmptyBorder; import com.fr.chartx.TwoTuple; @@ -48,8 +47,8 @@ import java.awt.event.ItemListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import static com.fine.theme.utils.FineClientProperties.ADAPTIVE_COMBO_BOX; -import static com.fine.theme.utils.FineClientProperties.COMBO_BOX_TYPE; +import static com.fine.swing.ui.layout.Layouts.cell; +import static com.fine.swing.ui.layout.Layouts.row; import static com.fine.theme.utils.FineUIScale.scale; /** @@ -102,12 +101,13 @@ public class MapAreaMatchPane extends BasicBeanPane { } private JPanel createContentPane() { - tableNameCombox.putClientProperty(COMBO_BOX_TYPE, ADAPTIVE_COMBO_BOX); - areaNameBox.putClientProperty(COMBO_BOX_TYPE, ADAPTIVE_COMBO_BOX); - return FineLayoutBuilder.createHorizontalLayout(10, - new UILabel(Toolkit.i18nText("Fine-Design_Chart_Table_Data") + ":"), tableNameCombox, - new UILabel(Toolkit.i18nText("Fine-Design_Chart_Area_Name") + ":"), areaNameBox, - refreshLabel); + return row(10, + cell(new UILabel(Toolkit.i18nText("Fine-Design_Chart_Table_Data") + ":")), + cell(tableNameCombox).weight(1), + cell(new UILabel(Toolkit.i18nText("Fine-Design_Chart_Area_Name") + ":")), + cell(areaNameBox).weight(1), + cell(refreshLabel) + ).getComponent(); } private void initTable(TwoTuple> treeNodeAndItems) { diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/AbstractMultiSelectionArrangementButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/AbstractMultiSelectionArrangementButton.java index 9474295049..2bfd21a30c 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/AbstractMultiSelectionArrangementButton.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/AbstractMultiSelectionArrangementButton.java @@ -1,10 +1,13 @@ package com.fr.design.mainframe.widget.arrangement.buttons; +import com.fine.theme.icon.LazyIcon; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.mainframe.MultiSelectionArrangement; +import com.fr.stable.StringUtils; +import javax.swing.Icon; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -16,11 +19,21 @@ public abstract class AbstractMultiSelectionArrangementButton extends UIButton i public AbstractMultiSelectionArrangementButton(MultiSelectionArrangement arrangement) { super(); this.arrangement = arrangement; - this.setNormalPainted(false); - this.setBorderPaintedOnlyWhenPressed(true); - this.setIcon(getIcon()); this.setToolTipText(getTipText()); this.addActionListener(getActionListener()); + setBorderPainted(false); + setBackground(null); + setBackground(null); + } + + @Override + public Icon getIcon() { + LazyIcon icon = new LazyIcon(getIconId()); + return isEnabled() ? icon : icon.disabled(); + } + + public String getIconId() { + return StringUtils.EMPTY; } @Override diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/BottomAlignButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/BottomAlignButton.java index 97974298a5..8cacba2055 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/BottomAlignButton.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/BottomAlignButton.java @@ -3,9 +3,6 @@ package com.fr.design.mainframe.widget.arrangement.buttons; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.ArrangementType; import com.fr.design.mainframe.MultiSelectionArrangement; -import com.fr.general.IOUtils; - -import javax.swing.Icon; public class BottomAlignButton extends AbstractMultiSelectionArrangementButton { private static final long serialVersionUID = 2397455240682353024L; @@ -15,8 +12,8 @@ public class BottomAlignButton extends AbstractMultiSelectionArrangementButton { } @Override - public Icon getIcon() { - return IOUtils.readIcon("/com/fr/design/images/buttonicon/multi_selection_bottom_align.png"); + public String getIconId() { + return "arrange_bottom_align"; } @Override diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/HorizontalCenterButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/HorizontalCenterButton.java index ec8f315df2..d55cd0b0c9 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/HorizontalCenterButton.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/HorizontalCenterButton.java @@ -3,9 +3,6 @@ package com.fr.design.mainframe.widget.arrangement.buttons; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.ArrangementType; import com.fr.design.mainframe.MultiSelectionArrangement; -import com.fr.general.IOUtils; - -import javax.swing.Icon; public class HorizontalCenterButton extends AbstractMultiSelectionArrangementButton { private static final long serialVersionUID = 6290178236460051049L; @@ -15,8 +12,8 @@ public class HorizontalCenterButton extends AbstractMultiSelectionArrangementBut } @Override - public Icon getIcon() { - return IOUtils.readIcon("/com/fr/design/images/buttonicon/multi_selection_horizontal_center_align.png"); + public String getIconId() { + return "arrange_horizontal_center"; } @Override diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/HorizontalDistributionButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/HorizontalDistributionButton.java index 0702248ed4..3b2c057b41 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/HorizontalDistributionButton.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/HorizontalDistributionButton.java @@ -3,9 +3,6 @@ package com.fr.design.mainframe.widget.arrangement.buttons; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.ArrangementType; import com.fr.design.mainframe.MultiSelectionArrangement; -import com.fr.general.IOUtils; - -import javax.swing.Icon; public class HorizontalDistributionButton extends AbstractMultiSelectionArrangementButton { private static final long serialVersionUID = 5052092252720664954L; @@ -15,8 +12,8 @@ public class HorizontalDistributionButton extends AbstractMultiSelectionArrangem } @Override - public Icon getIcon() { - return IOUtils.readIcon("/com/fr/design/images/buttonicon/multi_selection_horizontal_auto_spacing.png"); + public String getIconId() { + return "arrange_horizontal_distribute"; } @Override diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/LeftAlignButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/LeftAlignButton.java index 02a6a2c796..09f2a282cd 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/LeftAlignButton.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/LeftAlignButton.java @@ -3,9 +3,6 @@ package com.fr.design.mainframe.widget.arrangement.buttons; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.ArrangementType; import com.fr.design.mainframe.MultiSelectionArrangement; -import com.fr.general.IOUtils; - -import javax.swing.Icon; public class LeftAlignButton extends AbstractMultiSelectionArrangementButton { private static final long serialVersionUID = -8177637788632733710L; @@ -15,8 +12,8 @@ public class LeftAlignButton extends AbstractMultiSelectionArrangementButton { } @Override - public Icon getIcon() { - return IOUtils.readIcon("/com/fr/design/images/buttonicon/multi_selection_left_align.png"); + public String getIconId() { + return "arrange_left_align"; } @Override diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/RightAlignButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/RightAlignButton.java index 1b047b6ba8..2112758564 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/RightAlignButton.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/RightAlignButton.java @@ -3,9 +3,6 @@ package com.fr.design.mainframe.widget.arrangement.buttons; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.ArrangementType; import com.fr.design.mainframe.MultiSelectionArrangement; -import com.fr.general.IOUtils; - -import javax.swing.Icon; public class RightAlignButton extends AbstractMultiSelectionArrangementButton { private static final long serialVersionUID = -8698936349956288409L; @@ -15,8 +12,8 @@ public class RightAlignButton extends AbstractMultiSelectionArrangementButton { } @Override - public Icon getIcon() { - return IOUtils.readIcon("/com/fr/design/images/buttonicon/multi_selection_right_align.png"); + public String getIconId() { + return "arrange_right_align"; } @Override diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/TopAlignButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/TopAlignButton.java index 0adfb9378e..fb551282d7 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/TopAlignButton.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/TopAlignButton.java @@ -3,9 +3,6 @@ package com.fr.design.mainframe.widget.arrangement.buttons; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.ArrangementType; import com.fr.design.mainframe.MultiSelectionArrangement; -import com.fr.general.IOUtils; - -import javax.swing.Icon; public class TopAlignButton extends AbstractMultiSelectionArrangementButton { private static final long serialVersionUID = 2896267783075870924L; @@ -15,8 +12,8 @@ public class TopAlignButton extends AbstractMultiSelectionArrangementButton { } @Override - public Icon getIcon() { - return IOUtils.readIcon("/com/fr/design/images/buttonicon/multi_selection_top_align.png"); + public String getIconId() { + return "arrange_top_align"; } @Override diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/VerticalCenterButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/VerticalCenterButton.java index 4fb8b62a28..77c1255cbd 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/VerticalCenterButton.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/VerticalCenterButton.java @@ -3,9 +3,6 @@ package com.fr.design.mainframe.widget.arrangement.buttons; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.ArrangementType; import com.fr.design.mainframe.MultiSelectionArrangement; -import com.fr.general.IOUtils; - -import javax.swing.Icon; public class VerticalCenterButton extends AbstractMultiSelectionArrangementButton { public VerticalCenterButton(MultiSelectionArrangement arrangement) { @@ -13,8 +10,8 @@ public class VerticalCenterButton extends AbstractMultiSelectionArrangementButto } @Override - public Icon getIcon() { - return IOUtils.readIcon("/com/fr/design/images/buttonicon/multi_selection_vertical_center_align.png"); + public String getIconId() { + return "arrange_vertical_center"; } @Override diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/VerticalDistributionButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/VerticalDistributionButton.java index 76dcf9427a..8906923c37 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/VerticalDistributionButton.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/VerticalDistributionButton.java @@ -3,9 +3,6 @@ package com.fr.design.mainframe.widget.arrangement.buttons; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.ArrangementType; import com.fr.design.mainframe.MultiSelectionArrangement; -import com.fr.general.IOUtils; - -import javax.swing.Icon; public class VerticalDistributionButton extends AbstractMultiSelectionArrangementButton { public VerticalDistributionButton(MultiSelectionArrangement arrangement) { @@ -13,8 +10,8 @@ public class VerticalDistributionButton extends AbstractMultiSelectionArrangemen } @Override - public Icon getIcon() { - return IOUtils.readIcon("/com/fr/design/images/buttonicon/multi_selection_vertical_auto_spacing.png"); + public String getIconId() { + return "arrange_vertical_distribute"; } @Override diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java index cf59b595c5..b4c0776e38 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java @@ -1,5 +1,8 @@ package com.fr.design.mainframe.widget.ui; +import com.fine.theme.icon.LazyIcon; +import com.fine.theme.utils.FineLayoutBuilder; +import com.formdev.flatlaf.util.ScaledEmptyBorder; import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.gui.ibutton.UIButton; @@ -24,7 +27,6 @@ import com.fr.general.IOUtils; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; -import javax.swing.BorderFactory; import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.Component; @@ -43,93 +45,46 @@ public class FormMultiWidgetCardPane extends FormWidgetCardPane { public void initPropertyPane() { arrangement = new MultiSelectionArrangement(designer); - content.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 0)); content.add(createArrangementLayoutPane(), BorderLayout.CENTER); - this.listener = new AttributeChangeListener() { - @Override - public void attributeChange() { - designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_RESIZED); - } - }; + setBorder(new ScaledEmptyBorder(10, 0, 0, 0)); + this.listener = () -> designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_RESIZED); } - // 整个排列分布面板的layout,可以看成一个三行一列的表格,第一行是分布,第二行是自动间距,第三行是手动间距 + /** + * 整个排列分布面板的layout,可以看成一个两行一列的表格,第一行是分布,第二行是自动间距 + */ private JPanel createArrangementLayoutPane() { - double[] rowSize = {TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED}; - double[] columnSize = {TableLayout.PREFERRED}; - Component[][] components = new Component[][] { - new Component[] { - createAlignmentPane() - }, - new Component[] { - createAutoSpacingPane() - } - }; - return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 16); + return FineLayoutBuilder.createVerticalLayout(10, createAlignmentPane(), createAutoSpacingPane()); } // 对齐 private JPanel createAlignmentPane() { - double[] rowSize = {TableLayout.PREFERRED}; - double[] columnSize = { - TableLayout.PREFERRED, - TableLayout.PREFERRED, - TableLayout.PREFERRED, - TableLayout.PREFERRED, - TableLayout.PREFERRED, - TableLayout.PREFERRED - }; - Component[][] components = new Component[][] { - new Component[] { - new LeftAlignButton(arrangement), - new HorizontalCenterButton(arrangement), - new RightAlignButton(arrangement), - new TopAlignButton(arrangement), - new VerticalCenterButton(arrangement), - new BottomAlignButton(arrangement) - } - }; - JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 18, 0); + JPanel centerPane = FineLayoutBuilder.createHorizontalLayout(16, + new LeftAlignButton(arrangement), + new HorizontalCenterButton(arrangement), + new RightAlignButton(arrangement), + new TopAlignButton(arrangement), + new VerticalCenterButton(arrangement), + new BottomAlignButton(arrangement)); + return createTitleLayout(Toolkit.i18nText("Fine-Design_Multi_Selection_Align"), centerPane); } // 自动间距 private JPanel createAutoSpacingPane() { - double[] rowSize = {TableLayout.PREFERRED}; - double[] columnSize = { - TableLayout.PREFERRED, - TableLayout.PREFERRED - }; UIButton horizontalAutoSpacingBtn = new HorizontalDistributionButton(arrangement); UIButton verticalAutoSpacingBtn = new VerticalDistributionButton(arrangement); if (designer.getSelectionModel().getSelection().size() < 3) { horizontalAutoSpacingBtn.setEnabled(false); verticalAutoSpacingBtn.setEnabled(false); } - Component[][] components = new Component[][] { - new Component[] { - horizontalAutoSpacingBtn, - verticalAutoSpacingBtn - } - }; - JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 18, 0); + JPanel centerPane = FineLayoutBuilder.createHorizontalLayout(16, horizontalAutoSpacingBtn, verticalAutoSpacingBtn); - - UILabel tip = new UILabel(IOUtils.readIcon("/com/fr/design/images/buttonicon/multi_selection_auto_spacing_tip.png")); + UILabel tip = new UILabel(new LazyIcon("jumpHelp", 12)); tip.setToolTipText(Toolkit.i18nText("Fine-Design_Multi_Selection_Auto_Spacing_Tip")); - Component[][] titleComponents = new Component[][] { - new Component[] { - new UILabel(Toolkit.i18nText("Fine-Design_Multi_Selection_Auto_Spacing")), - tip - } - }; - JPanel northPane = TableLayoutHelper.createGapTableLayoutPane(titleComponents, rowSize, columnSize, 5, 0); + JPanel northPane = FineLayoutBuilder.createHorizontalLayout(5, new UILabel(Toolkit.i18nText("Fine-Design_Multi_Selection_Auto_Spacing")), tip); - JPanel jPanel = new JPanel(); - jPanel.setLayout(new BorderLayout(0, 8)); - jPanel.add(northPane, BorderLayout.NORTH); - jPanel.add(centerPane, BorderLayout.CENTER); - return jPanel; + return FineLayoutBuilder.createVerticalLayout(10, northPane, centerPane); } // 手动间距 @@ -195,13 +150,11 @@ public class FormMultiWidgetCardPane extends FormWidgetCardPane { } } - // 创建一个BorderLayout布局,上面是标题,例如“对齐”,下面是个容器 + /** + * 创建一个面板,上面是标题,例如“对齐”,下面是个容器 + */ private JPanel createTitleLayout(String title, JPanel centerPane) { - JPanel jPanel = new JPanel(); - jPanel.setLayout(new BorderLayout(0, 8)); - jPanel.add(new UILabel(title), BorderLayout.NORTH); - jPanel.add(centerPane, BorderLayout.CENTER); - return jPanel; + return FineLayoutBuilder.createVerticalLayout(10, new UILabel(title), centerPane); } @Override