|
|
@ -842,26 +842,59 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection |
|
|
|
if (shouldContinue) { |
|
|
|
if (shouldContinue) { |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
//如果组件为XWCardMainBorderLayout的子组件,直接从XWCardMainBorderLayout中去找
|
|
|
|
//获取当前组件父组件相对于rootComponent或者paraComponent的距离
|
|
|
|
XWCardMainBorderLayout borderLayout = XCreatorUtils.getTopXMainBorderLayout(creator); |
|
|
|
int relativeParentX = getRelativeParentX(creator.getParent()); |
|
|
|
if (borderLayout != null) { |
|
|
|
int relativeParentY = getRelativeParentY(creator.getParent()); |
|
|
|
return xCreatorAt(x, y, borderLayout, null); |
|
|
|
|
|
|
|
|
|
|
|
//如果不是布局容器,直接进行对比
|
|
|
|
|
|
|
|
if (!(creator instanceof XLayoutContainer)) { |
|
|
|
|
|
|
|
x -= relativeParentX + creator.getX(); |
|
|
|
|
|
|
|
y -= relativeParentY + creator.getY(); |
|
|
|
|
|
|
|
Rectangle rect = ComponentUtils.computeVisibleRect(creator); |
|
|
|
|
|
|
|
// 判断是否处于交叉区域
|
|
|
|
|
|
|
|
if (isIntersectArea(x, y, rect)) { |
|
|
|
|
|
|
|
return creator; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//如果是布局容器,从布局容器向下找
|
|
|
|
if (creator instanceof XLayoutContainer) { |
|
|
|
if (creator instanceof XLayoutContainer) { |
|
|
|
return xCreatorAt(x, y, creator, null); |
|
|
|
XCreator result = xCreatorAt(x - relativeParentX, y - relativeParentY, creator, null); |
|
|
|
|
|
|
|
if (result != null) return result; |
|
|
|
} |
|
|
|
} |
|
|
|
x -= creator.getX(); |
|
|
|
|
|
|
|
y -= creator.getY(); |
|
|
|
//最后,如果组件为Tab容器中的子组件,再从Tab容器中去找
|
|
|
|
Rectangle rect = ComponentUtils.computeVisibleRect(creator); |
|
|
|
XWCardMainBorderLayout borderLayout = XCreatorUtils.getTopXMainBorderLayout(creator); |
|
|
|
// 判断是否处于交叉区域
|
|
|
|
if (borderLayout != null) { |
|
|
|
if (!isIntersectArea(x, y, rect)) { |
|
|
|
relativeParentX = getRelativeParentX(borderLayout.getParent()); |
|
|
|
continue; |
|
|
|
relativeParentY = getRelativeParentY(borderLayout.getParent()); |
|
|
|
|
|
|
|
return xCreatorAt(x - relativeParentX, y - relativeParentY, borderLayout, null); |
|
|
|
} |
|
|
|
} |
|
|
|
return creator; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取当前组件相对于rootComponent或者paraComponent的横向距离 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private int getRelativeParentX(Container container) { |
|
|
|
|
|
|
|
return returnZero(container) ? 0 : container.getX() + getRelativeParentX(container.getParent()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取当前组件相对于rootComponent或者paraComponent的纵向距离 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private int getRelativeParentY(Container container) { |
|
|
|
|
|
|
|
return returnZero(container) ? 0 : container.getY() + getRelativeParentY(container.getParent()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean returnZero(Container container) { |
|
|
|
|
|
|
|
return !(container instanceof XLayoutContainer) |
|
|
|
|
|
|
|
|| container == rootComponent |
|
|
|
|
|
|
|
|| (paraComponent != null && container == paraComponent); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 刷新顶层组件 |
|
|
|
* 刷新顶层组件 |
|
|
|
* */ |
|
|
|
* */ |
|
|
|