diff --git a/designer-base/src/main/java/com/fr/widgettheme/theme/edit/widget/DesktopWidgetStyleEditPane.java b/designer-base/src/main/java/com/fr/widgettheme/theme/edit/widget/DesktopWidgetStyleEditPane.java index 7cfebf316..aca4b690d 100644 --- a/designer-base/src/main/java/com/fr/widgettheme/theme/edit/widget/DesktopWidgetStyleEditPane.java +++ b/designer-base/src/main/java/com/fr/widgettheme/theme/edit/widget/DesktopWidgetStyleEditPane.java @@ -5,12 +5,14 @@ import com.fr.base.theme.TemplateTheme; import com.fr.design.style.color.NewColorSelectBox; import com.fr.widgettheme.theme.widget.style.BorderStyle; import com.fr.widgettheme.theme.widget.style.ButtonBackgroundStyle; +import com.fr.widgettheme.theme.widget.style.ThemeTextStyle; import com.fr.widgettheme.theme.widget.style.ThemedWidgetStyle; import com.fr.design.gui.ibutton.UIRadioButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.widgettheme.theme.widget.theme.WidgetThemeDisplayConstants; +import com.fr.widgettheme.util.ThemeTextStylePaneCreator; import javax.swing.ButtonGroup; import javax.swing.JPanel; @@ -52,7 +54,7 @@ public class DesktopWidgetStyleEditPane extends WidgetS new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Style")), stylePane}, new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Border_Line")), lineComboBox}, new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Border_Radius")), borderRadiusSpinner}, - new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Text_Style")), textStylePane}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Widget_Theme_Text_Style")), ThemeTextStylePaneCreator.create(fontSizePane, fontColorButton)}, new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Widget_Background_Select_Box")), selectBackgroundColorBox} }; } @@ -86,7 +88,8 @@ public class DesktopWidgetStyleEditPane extends WidgetS colorSelectBox.setSelectObject(style.getThemeColor()); lineComboBox.setSelectedLineStyle(style.getBorderStyle().getLineType()); borderRadiusSpinner.setValue(style.getBorderStyle().getRadius()); - textStylePane.setTextStyle(style.getTextStyle()); + fontSizePane.setValue(style.getTextStyle().getFontSize()); + fontColorButton.setColor(style.getTextStyle().getFontColor()); selectBackgroundColorBox.setSelectObject(style.getSelectBackgroundColor()); } @@ -102,7 +105,10 @@ public class DesktopWidgetStyleEditPane extends WidgetS borderStyle.setLineType(lineComboBox.getSelectedLineStyle()); borderStyle.setRadius((int) borderRadiusSpinner.getValue()); style.setBorderStyle(borderStyle); - style.setTextStyle(textStylePane.getTextStyle()); + ThemeTextStyle textStyle = new ThemeTextStyle(); + textStyle.setFontSize(fontSizePane.getValue()); + textStyle.setFontColor(fontColorButton.getColor()); + style.setTextStyle(textStyle); ButtonBackgroundStyle buttonBackgroundStyle = new ButtonBackgroundStyle(); ColorBackground buttonBackground = ColorBackground.getInstance(style.getThemeColor()); buttonBackgroundStyle.setInitialBackground(buttonBackground); diff --git a/designer-base/src/main/java/com/fr/widgettheme/theme/edit/widget/MobileWidgetStyleEditPane.java b/designer-base/src/main/java/com/fr/widgettheme/theme/edit/widget/MobileWidgetStyleEditPane.java index 228dce7b2..ec6ef9aeb 100644 --- a/designer-base/src/main/java/com/fr/widgettheme/theme/edit/widget/MobileWidgetStyleEditPane.java +++ b/designer-base/src/main/java/com/fr/widgettheme/theme/edit/widget/MobileWidgetStyleEditPane.java @@ -1,10 +1,11 @@ package com.fr.widgettheme.theme.edit.widget; import com.fr.base.theme.TemplateTheme; -import com.fr.widgettheme.theme.panel.WidgetTextStylePane; +import com.fr.design.gui.frpane.FontSizeComboPane; import com.fr.widgettheme.theme.widget.style.BorderStyle; import com.fr.widgettheme.theme.widget.style.MobileThemedWidgetStyle; import com.fr.design.gui.icombobox.LineComboBox; +import com.fr.widgettheme.theme.widget.style.ThemeTextStyle; import com.fr.widgettheme.theme.widget.theme.WidgetThemeDisplayConstants; import java.util.Arrays; @@ -38,8 +39,8 @@ public class MobileWidgetStyleEditPane extends WidgetSt } @Override - protected void initTextStylePane() { - textStylePane = new WidgetTextStylePane(FONT_SIZES, 140); + protected void initFontSizePane() { + fontSizePane = new FontSizeComboPane(FONT_SIZES); } @Override @@ -52,7 +53,8 @@ public class MobileWidgetStyleEditPane extends WidgetSt colorSelectBox.setSelectObject(style.getThemeColor()); lineComboBox.setSelectedLineStyle(style.getBorderStyle().getLineType()); borderRadiusSpinner.setValue(style.getBorderStyle().getRadius()); - textStylePane.setTextStyle(style.getTextStyle()); + fontSizePane.setValue(style.getTextStyle().getFontSize()); + fontColorButton.setColor(style.getTextStyle().getFontColor()); } @Override @@ -67,7 +69,10 @@ public class MobileWidgetStyleEditPane extends WidgetSt borderStyle.setLineType(lineComboBox.getSelectedLineStyle()); borderStyle.setRadius((int) borderRadiusSpinner.getValue()); style.setBorderStyle(borderStyle); - style.setTextStyle(textStylePane.getTextStyle()); + ThemeTextStyle textStyle = new ThemeTextStyle(); + textStyle.setFontSize(fontSizePane.getValue()); + textStyle.setFontColor(fontColorButton.getColor()); + style.setTextStyle(textStyle); } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/widgettheme/theme/panel/WidgetTextStylePane.java b/designer-base/src/main/java/com/fr/widgettheme/theme/panel/WidgetTextStylePane.java deleted file mode 100644 index 6b45d5e6f..000000000 --- a/designer-base/src/main/java/com/fr/widgettheme/theme/panel/WidgetTextStylePane.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.fr.widgettheme.theme.panel; - -import com.fr.design.gui.ibutton.UIColorButton; -import com.fr.design.gui.frpane.FontSizeComboPane; -import com.fr.widgettheme.theme.widget.style.ThemeTextStyle; - -import javax.swing.BorderFactory; -import javax.swing.Box; -import javax.swing.JPanel; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.util.Vector; - -/** - * 控件文本样式配置面板 - * 包含文本字体大小和字体颜色 - * - * @author oBo - * @since 11.0 - * Created on 2023/12/13 - */ -public class WidgetTextStylePane extends JPanel { - - private final FontSizeComboPane fontSizePane; - - private final UIColorButton fontColorButton; - - public WidgetTextStylePane(int preferredWidth) { - this(null, preferredWidth); - } - - public WidgetTextStylePane(Vector fontSizes, int preferredWidth) { - this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); - this.setBorder(BorderFactory.createEmptyBorder()); - fontSizePane = new FontSizeComboPane(fontSizes); - fontColorButton = new UIColorButton(); - fontSizePane.setPreferredSize(new Dimension(preferredWidth, fontSizePane.getPreferredSize().height)); - this.add(fontSizePane); - add(Box.createHorizontalStrut(5)); - this.add(fontColorButton); - } - - public void setTextStyle(ThemeTextStyle themeTextStyle) { - this.fontSizePane.setValue(themeTextStyle.getFontSize()); - this.fontColorButton.setColor(themeTextStyle.getFontColor()); - } - - public ThemeTextStyle getTextStyle() { - ThemeTextStyle themeTextStyle = new ThemeTextStyle(); - themeTextStyle.setFontSize(this.fontSizePane.getValue()); - themeTextStyle.setFontColor(this.fontColorButton.getColor()); - return themeTextStyle; - } - - public void setFontSizeValue(int fontSize) { - this.fontSizePane.setValue(fontSize); - } - - public void setFontColorValue(Color fontColor) { - this.fontColorButton.setColor(fontColor); - } - - public int getFontSizeValue() { - return this.fontSizePane.getValue(); - } - - public Color getFontColorValue() { - return this.fontColorButton.getColor(); - } - -} diff --git a/designer-base/src/main/java/com/fr/widgettheme/util/ThemeTextStylePaneCreator.java b/designer-base/src/main/java/com/fr/widgettheme/util/ThemeTextStylePaneCreator.java new file mode 100644 index 000000000..34de319e9 --- /dev/null +++ b/designer-base/src/main/java/com/fr/widgettheme/util/ThemeTextStylePaneCreator.java @@ -0,0 +1,40 @@ +package com.fr.widgettheme.util; + +import com.fr.design.gui.frpane.FontSizeComboPane; +import com.fr.design.gui.ibutton.UIColorButton; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; + +import javax.swing.Box; +import javax.swing.JPanel; +import java.awt.Component; + +/** + * 样式设置pane抽象类 + * + * @author obo + * @since 11.0 + * Created on 2023/12/21 + */ +public class ThemeTextStylePaneCreator { + private ThemeTextStylePaneCreator() {} + + /** + * 创建主题文本样式配置面板 + * 包含字体大小下拉框和字体颜色按钮 + * 可以自适应布局 + * + * @param fontSizePane 字体大小配置 + * @param fontColorButton 字体颜色配置 + * @return 文本样式面板 + */ + public static JPanel create(FontSizeComboPane fontSizePane, UIColorButton fontColorButton) { + Component[][] components = {{fontSizePane, Box.createHorizontalStrut(5), fontColorButton}}; + double f = TableLayout.FILL; + double p = TableLayout.PREFERRED; + double[] rowSize = {f}; + double[] columnSize = {f, p, p}; + int[][] rowCount = {{1, 1, 1}}; + return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, 0, 0); + } +} diff --git a/designer-form/src/main/java/com/fr/design/widgettheme/BaseStyleSettingPane.java b/designer-form/src/main/java/com/fr/design/widgettheme/BaseStyleSettingPane.java index f5c18f389..b2de7d11f 100644 --- a/designer-form/src/main/java/com/fr/design/widgettheme/BaseStyleSettingPane.java +++ b/designer-form/src/main/java/com/fr/design/widgettheme/BaseStyleSettingPane.java @@ -1,7 +1,8 @@ package com.fr.design.widgettheme; import com.fr.base.theme.TemplateTheme; -import com.fr.widgettheme.theme.panel.WidgetTextStylePane; +import com.fr.design.gui.frpane.FontSizeComboPane; +import com.fr.design.gui.ibutton.UIColorButton; import com.fr.widgettheme.theme.widget.style.BorderStyle; import com.fr.widgettheme.theme.widget.style.ThemeTextStyle; import com.fr.widgettheme.theme.widget.style.ThemedWidgetStyle; @@ -25,6 +26,7 @@ import com.fr.form.ui.Widget; import com.fr.general.FRFont; import com.fr.widgettheme.theme.panel.ButtonStyleDefinedPane; import com.fr.widgettheme.theme.widget.theme.WidgetThemeDisplayConstants; +import com.fr.widgettheme.util.ThemeTextStylePaneCreator; import javax.swing.BorderFactory; import javax.swing.ButtonGroup; @@ -63,12 +65,18 @@ public abstract class BaseStyleSettingPane extends BasicBeanPa protected FRFontPane frFontPane; // 按钮背景设置 protected ButtonStyleDefinedPane buttonStyleDefinedPane; + + protected NewColorSelectBox selectBgColorBox; + /** - * 文本样式 - * 包含字体大小、字体颜色 + * 主题文本样式的字体大小 */ - protected WidgetTextStylePane textStylePane; - protected NewColorSelectBox selectBgColorBox; + protected FontSizeComboPane fontSizePane; + + /** + * 主题文本样式的字体颜色 + */ + protected UIColorButton fontColorButton; private final Map labelMap = new HashMap<>(); private final Map paneMap = new HashMap<>(); @@ -94,12 +102,13 @@ public abstract class BaseStyleSettingPane extends BasicBeanPa borderRadiusSpinner = new UIBoundSpinner(0, Integer.MAX_VALUE, 1); frFontPane = new FRFontPane(); buttonStyleDefinedPane = new ButtonStyleDefinedPane(); - textStylePane = new WidgetTextStylePane(105); selectBgColorBox = new NewColorSelectBox(160, true); + fontSizePane = new FontSizeComboPane(); + fontColorButton = new UIColorButton(); paneMap.put(StyleSetting.STYLE_TYPE, createStyleTypePane()); paneMap.put(StyleSetting.THEME_COLOR, colorSelectBox); paneMap.put(StyleSetting.LINE_TYPE, lineComboBox); - paneMap.put(StyleSetting.TEXT_STYLE, textStylePane); + paneMap.put(StyleSetting.TEXT_STYLE, ThemeTextStylePaneCreator.create(fontSizePane, fontColorButton)); paneMap.put(StyleSetting.BORDER_RADIUS, borderRadiusSpinner); paneMap.put(StyleSetting.FONT, frFontPane); paneMap.put(StyleSetting.BTN_BACKGROUND, buttonStyleDefinedPane); @@ -242,7 +251,9 @@ public abstract class BaseStyleSettingPane extends BasicBeanPa } private void setTextStylePane(ThemedWidgetStyle widgetStyle) { - this.textStylePane.setTextStyle(widgetStyle.getTextStyle()); + ThemeTextStyle textStyle = widgetStyle.getTextStyle(); + this.fontSizePane.setValue(textStyle.getFontSize()); + this.fontColorButton.setColor(textStyle.getFontColor()); } private void setFrFontPane() { @@ -269,8 +280,11 @@ public abstract class BaseStyleSettingPane extends BasicBeanPa if (borderRadiusSpinner != null) { borderRadiusSpinner.setValue(BorderStyle.DEFAULT_BORDER_RADIUS); } - if (textStylePane != null) { - textStylePane.setTextStyle(new ThemeTextStyle()); + if (fontSizePane != null) { + fontSizePane.setValue(ThemeTextStyle.DEFAULT_FONT_SIZE); + } + if (fontColorButton != null) { + fontColorButton.setColor(ThemeTextStyle.DEFAULT_FONT_COLOR); } if (frFontPane != null) { frFontPane.populateBean(FRFont.getInstance()); diff --git a/designer-form/src/main/java/com/fr/design/widgettheme/ParaButtonSettingPane.java b/designer-form/src/main/java/com/fr/design/widgettheme/ParaButtonSettingPane.java index 0ba714d8d..084e183ab 100644 --- a/designer-form/src/main/java/com/fr/design/widgettheme/ParaButtonSettingPane.java +++ b/designer-form/src/main/java/com/fr/design/widgettheme/ParaButtonSettingPane.java @@ -2,6 +2,7 @@ package com.fr.design.widgettheme; import com.fr.design.widgettheme.common.ButtonSettingPane; import com.fr.form.ui.Widget; +import com.fr.widgettheme.theme.widget.style.ThemeTextStyle; import com.fr.widgettheme.theme.widget.theme.ParaButtonTheme; import com.fr.widgettheme.theme.widget.theme.cell.ButtonTheme; @@ -32,14 +33,18 @@ public class ParaButtonSettingPane extends ButtonSettingPane extends EditorSettingPane extends TreeEditorS @Override protected void assignFontSizePane(TreeTheme widgetTheme) { - ParaTreeTheme paraTreeTheme= (ParaTreeTheme) widgetTheme; - textStylePane.setTextStyle(paraTreeTheme.getTextStyle()); + ThemeTextStyle textStyle = widgetTheme.getTextStyle(); + fontSizePane.setValue(textStyle.getFontSize()); + fontColorButton.setColor(textStyle.getFontColor()); } @Override protected void assignFontSizeStyle(TreeTheme widgetTheme) { - ParaTreeTheme paraTreeTheme= (ParaTreeTheme) widgetTheme; - paraTreeTheme.setTextStyle(textStylePane.getTextStyle()); + ThemeTextStyle textStyle = new ThemeTextStyle(); + textStyle.setFontSize(fontSizePane.getValue()); + textStyle.setFontColor(fontColorButton.getColor()); + widgetTheme.setTextStyle(textStyle); } }