forked from fanruan/design
hades
3 years ago
6 changed files with 108 additions and 8 deletions
@ -0,0 +1,65 @@ |
|||||||
|
package com.fr.design.mainframe; |
||||||
|
|
||||||
|
import com.fr.design.designer.creator.XCreator; |
||||||
|
import com.fr.design.designer.creator.XCreatorUtils; |
||||||
|
import com.fr.design.designer.creator.XLayoutContainer; |
||||||
|
import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; |
||||||
|
|
||||||
|
/** |
||||||
|
* 判断tab块是否能拖入 |
||||||
|
* |
||||||
|
* @author hades |
||||||
|
* @version 10.0 |
||||||
|
* Created by hades on 2021/6/29 |
||||||
|
*/ |
||||||
|
public class TabDragInner { |
||||||
|
|
||||||
|
/** |
||||||
|
* 悬浮停留的时间间隔 |
||||||
|
*/ |
||||||
|
private static final long TIME_GAP = 1000; |
||||||
|
|
||||||
|
private FormDesigner designer; |
||||||
|
private XLayoutContainer belowXLayoutContainer; |
||||||
|
private long timer; |
||||||
|
private int oldX; |
||||||
|
private int oldY; |
||||||
|
|
||||||
|
public TabDragInner(FormDesigner designer) { |
||||||
|
this.designer = designer; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 判断拖入 |
||||||
|
* |
||||||
|
* @param creator 当前拖拽的组件下方所在布局最上层的组件 |
||||||
|
* @param x |
||||||
|
* @param y |
||||||
|
*/ |
||||||
|
public void dragIn(XCreator creator, int x, int y) { |
||||||
|
XCreator xCreator = designer.getComponentAt(x, y); |
||||||
|
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer(xCreator).getTopLayout(); |
||||||
|
boolean dragInAble = false; |
||||||
|
if (topLayout != null && topLayout.acceptType(XWCardMainBorderLayout.class) && belowXLayoutContainer == null) { |
||||||
|
belowXLayoutContainer = topLayout; |
||||||
|
timer = System.currentTimeMillis(); |
||||||
|
} else if (topLayout == belowXLayoutContainer && topLayout != null && oldX == x && oldY == y) { |
||||||
|
if (System.currentTimeMillis() - timer > TIME_GAP) { |
||||||
|
dragInAble = true; |
||||||
|
} |
||||||
|
} else { |
||||||
|
timer = 0; |
||||||
|
belowXLayoutContainer = null; |
||||||
|
} |
||||||
|
if (topLayout != null) { |
||||||
|
topLayout.setDragInAble(dragInAble); |
||||||
|
} |
||||||
|
oldX = x; |
||||||
|
oldY = y; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public XLayoutContainer getBelowXLayoutContainer() { |
||||||
|
return belowXLayoutContainer; |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue