Browse Source

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

newui
Bruce.Deng 1 year ago
parent
commit
cd9cb64059
  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.XWBorderLayout;
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.UIButtonUI;
import com.fr.design.gui.ilable.UILabel;
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.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
@ -540,21 +540,26 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
}
//获取在容器的绝对位置
Rectangle rec = ComponentUtils.getRelativeBounds(creator);
// 组件实际大小、位置要考虑缩放
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位置小于水平滚动条的值
horScrollBar.setValue(rec.x);
} else if (rec.x + rec.width > dWidth + horizontalValue) {
horScrollBar.setValue((int) recRealX);
} else if (recRealX + recRealWidth > dWidth + horizontalValue) {
//超出边界宽度
horScrollBar.setValue(rec.x + rec.width - dWidth);
horScrollBar.setValue((int) (recRealX + recRealWidth - dWidth));
}
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位置小于竖直滚动条的值
verScrollBar.setValue(rec.y);
} else if (rec.y + rec.height > dHeight + verticalValue) {
verScrollBar.setValue((int) recRealY);
} else if (recRealY + recRealHeight > dHeight + verticalValue) {
//超出边界高度
verScrollBar.setValue(rec.y + rec.height - dHeight);
verScrollBar.setValue((int) (recRealY + recRealHeight - dHeight));
}
}

Loading…
Cancel
Save