Browse Source

Merge pull request #281 in BA/design from ~ZHOUPING/design:dev to dev

* commit 'd1af504ea62419162b985f7e3c8ebeb77f100d74':
  绝对布局bug修改1
master
superman 8 years ago
parent
commit
dfffd72616
  1. 10
      designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java
  2. 11
      designer_form/src/com/fr/design/designer/beans/painters/FRAbsoluteLayoutPainter.java
  3. 2
      designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java

10
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();
}

11
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) {

2
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);

Loading…
Cancel
Save