From b54655f2866d4707829867c8d8bfdda4293ac753 Mon Sep 17 00:00:00 2001 From: zhouping Date: Tue, 23 Aug 2016 21:36:07 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9D=E5=AF=B9=E5=B8=83=E5=B1=80bug?= =?UTF-8?q?=E4=BF=AE=E6=94=B91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adapters/layout/FRAbsoluteLayoutAdapter.java | 10 ++++++++++ .../beans/painters/FRAbsoluteLayoutPainter.java | 11 ++++++----- .../fr/design/designer/creator/XWAbsoluteLayout.java | 2 +- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java index e54271cd0..28516a4b2 100644 --- a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java +++ b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java @@ -58,6 +58,16 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter { XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer((XCreator)comp).getTopLayout(); if(topLayout != null){ if (topLayout.isEditable()){ + //判断有没有和当前控件重叠 + Rectangle curRec = new Rectangle(x, y, creator.getWidth(), creator.getHeight()); + WAbsoluteLayout wAbsoluteLayout = (WAbsoluteLayout)topLayout.toData(); + for (int i = 0, count = wAbsoluteLayout.getWidgetCount(); i < count; i++) { + WAbsoluteLayout.BoundsWidget temp = (WAbsoluteLayout.BoundsWidget) wAbsoluteLayout.getWidget(i); + Rectangle rectangle = temp.getBounds(); + if (curRec.intersects(rectangle)){ + return false; + } + } return x >= 0 && y >= 0 && creator.getHeight() <= container.getHeight() && creator.getWidth() <= container.getWidth(); } diff --git a/designer_form/src/com/fr/design/designer/beans/painters/FRAbsoluteLayoutPainter.java b/designer_form/src/com/fr/design/designer/beans/painters/FRAbsoluteLayoutPainter.java index a6da42a04..61e9260e3 100644 --- a/designer_form/src/com/fr/design/designer/beans/painters/FRAbsoluteLayoutPainter.java +++ b/designer_form/src/com/fr/design/designer/beans/painters/FRAbsoluteLayoutPainter.java @@ -46,11 +46,7 @@ public class FRAbsoluteLayoutPainter extends AbstractPainter { return; } super.paint(g, startX, startY); - //如果absolute不可编辑那么就将之当普通控件处理,在周围添加控件, - //否则,只往内部添加,不需要出现蓝色悬浮提示框 - if(container.isEditable()){ - return; - } + int x = hotspot.x - hotspot_bounds.x; int y = hotspot.y - hotspot_bounds.y; FRAbsoluteLayoutAdapter adapter = (FRAbsoluteLayoutAdapter) container.getLayoutAdapter(); @@ -58,6 +54,11 @@ public class FRAbsoluteLayoutPainter extends AbstractPainter { int[] hot_rec; boolean accept = adapter.accept(creator, x, y); + //如果absolute不可编辑那么就将之当普通控件处理,在周围添加控件, + //否则,只往内部添加,不需要出现蓝色悬浮提示框 + if(container.isEditable() && accept){ + return; + } Component currentComp = container.getComponentAt(x, y); //不可编辑的时候要获取顶层的绝对布局容器 if (XCreatorUtils.getHotspotContainer((XCreator) currentComp) != null) { diff --git a/designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java b/designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java index 4c543300b..34a2a156d 100644 --- a/designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java +++ b/designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java @@ -182,7 +182,7 @@ public class XWAbsoluteLayout extends XLayoutContainer { XCreator creator = (XCreator) this.getComponent(index); BoundsWidget wgt = layout.getBoundsWidget(creator.toData()); // 用当前的显示大小计算后调正具体位置 - Rectangle wgtBound = dealWidgetBound(creator.getBounds()); + Rectangle wgtBound = creator.getBounds(); Rectangle rec = calculateBound(wgtBound, percentW, percentH); wgt.setBounds(rec); creator.setBounds(rec);