Browse Source

Pull request #5076: REPORT-55553 & REPORT-55709 & REPORT-55694

Merge in DESIGN/design from ~STARRYI/design:bug-final/10.0 to final/10.0

* commit 'e527377c5cd696b02b462aadab3ed27278e084c2':
  REPORT-55694 【组件背景分离】组件复用-组件/控件锁定时,通过右侧设置面板先增加宽度时,高度不变;但减小宽度时,高度会1单位1单位减小,最后组件变成一条横线
  REPORT-55709 frm中body背景设置了背景,不透明度设置0%没有透明效果
  REPORT-55553 【组件背景分离】组件复用-现在组件右侧设置面板的层次效果和视觉稿不一样,层次间隔不清晰
final/10.0
Kara 3 years ago
parent
commit
0430f5e284
  1. 4
      designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java
  2. 10
      designer-form/src/main/java/com/fr/design/designer/creator/XLabel.java
  3. 89
      designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java
  4. 12
      designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java

4
designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java

@ -226,7 +226,11 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
public void paintBackground(Graphics2D g2d) { public void paintBackground(Graphics2D g2d) {
Background background4Painting = getBackground4Painting(); Background background4Painting = getBackground4Painting();
if (background4Painting != null) { if (background4Painting != null) {
BorderPacker style = toData().getBorderStyle();
Composite oldComposite = g2d.getComposite();
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, style.getAlpha()));
background4Painting.paint(g2d, new Rectangle2D.Double(0, 0, getWidth(), getHeight())); background4Painting.paint(g2d, new Rectangle2D.Double(0, 0, getWidth(), getHeight()));
g2d.setComposite(oldComposite);
} }
} }

10
designer-form/src/main/java/com/fr/design/designer/creator/XLabel.java

@ -19,6 +19,7 @@ import com.fr.form.ui.Label;
import com.fr.form.ui.container.WParameterLayout; import com.fr.form.ui.container.WParameterLayout;
import com.fr.general.Background; import com.fr.general.Background;
import com.fr.general.act.BorderPacker;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.stable.core.PropertyChangeAdapter; import com.fr.stable.core.PropertyChangeAdapter;
@ -91,8 +92,13 @@ public class XLabel extends XWidgetCreator {
Label label = (Label) data; Label label = (Label) data;
Dimension size = this.getSize(); Dimension size = this.getSize();
//先画背景,再画标题 //先画背景,再画标题
if (toData().getBackground() != null) { Background background = label.getBackground();
toData().getBackground().paint(g, new Rectangle2D.Double(0, 0, size.getWidth(), size.getHeight())); if (background != null) {
Graphics2D g2d = (Graphics2D) g;
Composite oldComposite = g2d.getComposite();
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, label.getBackgroundOpacity()));
background.paint(g, new Rectangle2D.Double(0, 0, size.getWidth(), size.getHeight()));
g2d.setComposite(oldComposite);
} }
if (label.getWidgetValue() != null) { if (label.getWidgetValue() != null) {
Graphics2D g2d = (Graphics2D) g.create(); Graphics2D g2d = (Graphics2D) g.create();

89
designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java

@ -1,10 +1,8 @@
package com.fr.design.gui.xpane; package com.fr.design.gui.xpane;
import com.fr.base.GraphHelper;
import com.fr.base.Utils; import com.fr.base.Utils;
import com.fr.base.svg.IconUtils; import com.fr.base.svg.IconUtils;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.constants.UIConstants;
import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.IntervalConstants;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.formula.TinyFormulaPane; import com.fr.design.formula.TinyFormulaPane;
@ -13,7 +11,6 @@ import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ibutton.UIColorButton; import com.fr.design.gui.ibutton.UIColorButton;
import com.fr.design.gui.ibutton.UIToggleButton; import com.fr.design.gui.ibutton.UIToggleButton;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.LineComboBox;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.gui.ispinner.UISpinner;
@ -105,42 +102,46 @@ public class LayoutStylePane extends BasicBeanPane<LayoutBorderStyle> {
boolean currentIsRootLayout = currentEditingTemplate != null && !currentEditingTemplate.isJWorkBook() && ((JForm)currentEditingTemplate).isSelectRootPane(); boolean currentIsRootLayout = currentEditingTemplate != null && !currentEditingTemplate.isJWorkBook() && ((JForm)currentEditingTemplate).isSelectRootPane();
JPanel titlePane = createTitleStylePane(); JPanel titlePane = createTitleStylePane();
JPanel bodyContentPane = currentIsRootLayout ? createBodyContentPane4RootLayout() : createBodyContentPane();
JPanel backgroundPane = createBackgroundStylePane();
if (titlePane != null) { if (titlePane != null) {
container.add(titlePane, BorderLayout.NORTH); container.add(titlePane, BorderLayout.NORTH);
if (currentIsRootLayout) { if (currentIsRootLayout) {
titlePane.setVisible(false); titlePane.setVisible(false);
} }
} }
JPanel nextContainerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
container.add(nextContainerPane, BorderLayout.CENTER);
//界面上表单主体只有背景和透明度可以设置 if (bodyContentPane != null) {
JPanel mainStylePane = currentIsRootLayout ? createMainStylePane4RootLayout() : createMainStylePane4WidgetLayout(); //界面上表单主体只有背景和透明度可以设置
if (mainStylePane != null) { nextContainerPane.add(bodyContentPane, BorderLayout.NORTH);
container.add(mainStylePane, BorderLayout.CENTER); }
if (backgroundPane != null) {
nextContainerPane.add(backgroundPane, BorderLayout.CENTER);
if (currentIsRootLayout) {
backgroundPane.setVisible(false);
}
} }
this.add(container, BorderLayout.CENTER); this.add(container, BorderLayout.CENTER);
} }
protected void initMainComponents() { protected JPanel createBackgroundStylePane() {
borderStyleCombo = new UIComboBox(BORDER_STYLE); borderStyleCombo = new UIComboBox(BORDER_STYLE);
borderLineAndImagePane = new BorderLineAndImagePane(); borderLineAndImagePane = new BorderLineAndImagePane();
cornerSpinner = new UISpinner(0,1000,1,0); cornerSpinner = new UISpinner(0,1000,1,0);
backgroundPane = new LayoutBackgroundSpecialPane();
backgroundOpacityPane = new UIPercentDragPane();
}
protected JPanel createMainStylePane4WidgetLayout() {
initMainComponents();
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double f = TableLayout.FILL; double f = TableLayout.FILL;
double[] rowSize = {p, p, p, p, p}; double[] rowSize = {p, p, p, p};
double[] columnSize = {SETTING_LABEL_WIDTH, f}; double[] columnSize = {SETTING_LABEL_WIDTH, f};
JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{ JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Frame_Style")), null}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Background_Style")), null},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Render_Style")), borderStyleCombo}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Render_Style")), borderStyleCombo},
{this.borderLineAndImagePane, null}, {this.borderLineAndImagePane, null},
{this.createMainBackgroundAndOpacityPane(), null},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Radius")), cornerSpinner}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Radius")), cornerSpinner},
}, },
rowSize, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1); rowSize, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1);
@ -153,16 +154,23 @@ public class LayoutStylePane extends BasicBeanPane<LayoutBorderStyle> {
return container; return container;
} }
protected JPanel createMainStylePane4RootLayout() { protected JPanel createBodyContentPane() {
initMainComponents(); backgroundPane = new LayoutBackgroundSpecialPane();
backgroundOpacityPane = new UIPercentDragPane();
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double f = TableLayout.FILL; double f = TableLayout.FILL;
double[] rowSize = {p, p}; double[] rowSize = {p, p};
double[] columnSize = {SETTING_LABEL_WIDTH, f}; double[] columnSize = {SETTING_LABEL_WIDTH, f};
JPanel bodyBackground = createBackgroundAndOpacityPane(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Body_Fill"),
this.backgroundPane,
this.backgroundOpacityPane);
JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{ JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Frame_Style")), null}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Body_Content")), null},
{this.createMainBackgroundAndOpacityPane(), null}, {bodyBackground, null},
}, },
rowSize, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1); rowSize, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1);
contentPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); contentPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
@ -174,11 +182,31 @@ public class LayoutStylePane extends BasicBeanPane<LayoutBorderStyle> {
return container; return container;
} }
protected JPanel createMainBackgroundAndOpacityPane() { protected JPanel createBodyContentPane4RootLayout() {
return createBackgroundAndOpacityPane( backgroundPane = new LayoutBackgroundSpecialPane();
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Body_Background"), backgroundOpacityPane = new UIPercentDragPane();
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] rowSize = {p};
double[] columnSize = {SETTING_LABEL_WIDTH, f};
JPanel bodyBackground = createBackgroundAndOpacityPane(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Body_Fill"),
this.backgroundPane, this.backgroundPane,
this.backgroundOpacityPane); this.backgroundOpacityPane);
JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{
{bodyBackground, null},
},
rowSize, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1);
contentPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane();
container.setBorder(new BottomLineBorder());
container.add(contentPane, BorderLayout.NORTH);
return container;
} }
protected void initTitleComponents() { protected void initTitleComponents() {
@ -489,16 +517,25 @@ public class LayoutStylePane extends BasicBeanPane<LayoutBorderStyle> {
protected static class BottomLineBorder extends LineBorder { protected static class BottomLineBorder extends LineBorder {
public BottomLineBorder() { public BottomLineBorder() {
super(Color.lightGray, 1); super(new Color(217, 218, 221), 1);
} }
@Override @Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
Color oldColor = g2d.getColor(); Color oldColor = g2d.getColor();
g2d.setColor(this.lineColor); Stroke oldStroke = g2d.getStroke();
GraphHelper.drawLine(g, 0, height, width, height, 1);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setColor(getLineColor());
g2d.setStroke(new BasicStroke(getThickness() * 2));
g2d.drawLine(0, height, width, height);
g2d.setStroke(oldStroke);
g2d.setColor(oldColor); g2d.setColor(oldColor);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
} }
} }

12
designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java

@ -265,11 +265,13 @@ public class WidgetBoundPane extends BasicPane {
@Override @Override
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
if (isLockEnabled() && isLocked()) { if (isLockEnabled() && isLocked()) {
setLocked(false); if (mHeightSpinner.getValue() == 0) {
aspectRatioBackup = -1; setLocked(false);
} else if (aspectRatioBackup > 0) { aspectRatioBackup = -1;
double value = mHeightSpinner.getValue() * aspectRatioBackup; }else if (aspectRatioBackup > 0) {
mWidthSpinner.setValue(Math.round(value), false); double value = mHeightSpinner.getValue() * aspectRatioBackup;
mWidthSpinner.setValue(Math.round(value), false);
}
} }
} }
}); });

Loading…
Cancel
Save