Browse Source

Pull request #12909: REPORT-105998 设计器缩放比例较小,在画布选中组件有偏差

Merge in DESIGN/design from ~BRUCE.DENG/design:release/11.0 to release/11.0

* commit 'cd9cb64059e2ea24c644537e70104a09b5691d1f':
  REPORT-105998 设计器缩放比例较小,在画布选中组件有偏差
newui
parent
commit
94189aacc5
  1. 23
      designer-form/src/main/java/com/fr/design/mainframe/FormArea.java

23
designer-form/src/main/java/com/fr/design/mainframe/FormArea.java

@ -8,11 +8,11 @@ import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWBorderLayout; import com.fr.design.designer.creator.XWBorderLayout;
import com.fr.design.designer.creator.XWFitLayout; import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.creator.XWParameterLayout;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIButtonUI; import com.fr.design.gui.ibutton.UIButtonUI;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.designer.creator.XWParameterLayout;
import com.fr.design.gui.itextfield.UINumberField; import com.fr.design.gui.itextfield.UINumberField;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
@ -540,21 +540,26 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
} }
//获取在容器的绝对位置 //获取在容器的绝对位置
Rectangle rec = ComponentUtils.getRelativeBounds(creator); Rectangle rec = ComponentUtils.getRelativeBounds(creator);
// 组件实际大小、位置要考虑缩放
int dWidth = getDesignerWidth(); int dWidth = getDesignerWidth();
if (rec.width <= dWidth && rec.x < getHorizontalValue()) { double recRealWidth = rec.width * designer.getScale();
double recRealX = rec.x * designer.getScale();
if (recRealWidth <= dWidth && recRealX < getHorizontalValue()) {
//在边界内部且x位置小于水平滚动条的值 //在边界内部且x位置小于水平滚动条的值
horScrollBar.setValue(rec.x); horScrollBar.setValue((int) recRealX);
} else if (rec.x + rec.width > dWidth + horizontalValue) { } else if (recRealX + recRealWidth > dWidth + horizontalValue) {
//超出边界宽度 //超出边界宽度
horScrollBar.setValue(rec.x + rec.width - dWidth); horScrollBar.setValue((int) (recRealX + recRealWidth - dWidth));
} }
int dHeight = getDesignerHeight(); int dHeight = getDesignerHeight();
if (rec.height < dHeight && rec.y < getVerticalValue()) { double recRealHeight = rec.height * designer.getScale();
double recRealY = rec.y * designer.getScale();
if (recRealHeight < dHeight && recRealY < getVerticalValue()) {
//在边界内部且y位置小于竖直滚动条的值 //在边界内部且y位置小于竖直滚动条的值
verScrollBar.setValue(rec.y); verScrollBar.setValue((int) recRealY);
} else if (rec.y + rec.height > dHeight + verticalValue) { } else if (recRealY + recRealHeight > dHeight + verticalValue) {
//超出边界高度 //超出边界高度
verScrollBar.setValue(rec.y + rec.height - dHeight); verScrollBar.setValue((int) (recRealY + recRealHeight - dHeight));
} }
} }

Loading…
Cancel
Save