Java Code Examples for de.lessvoid.nifty.elements.Element#setConstraintY()

The following examples show how to use de.lessvoid.nifty.elements.Element#setConstraintY() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NiftyDDManager.java    From niftyeditor with Apache License 2.0 6 votes vote down vote up
public void startDrag(final GElement element){
    if(dragged != null){
        throw new IllegalStateException("You can't start more than one drag&drop");
    }
    
    dragged = element;
    nifty.showPopup(nifty.getCurrentScreen(),popUp.getId(), null);
    final Element ele = this.dragged.getNiftyElement();
    final SizeValue width = SizeValue.px(ele.getWidth());
    this.previousX = ele.getX();
    this.previousY = ele.getY();
    this.previousIndex = this.findIndex(dragged);
    final SizeValue height = SizeValue.px(ele.getHeight());
     ele.setConstraintX(SizeValue.px(previousX));
    ele.setConstraintY(SizeValue.px(previousY));
    ele.setConstraintHeight(height);
    ele.setConstraintWidth(width);
    element.getNiftyElement().markForMove(popUp);
}
 
Example 2
Source File: NiftyDDManager.java    From niftyeditor with Apache License 2.0 5 votes vote down vote up
/**
 * Move dragged element around
 * @param x
 * @param y 
 */
public void dragAround(int x,int y){
        if(dragged == null){
            throw new IllegalStateException("You must start drag before!");
        }
        Element ele = this.dragged.getNiftyElement();
        ele.setConstraintX(SizeValue.px(x-ele.getWidth()/2));
        ele.setConstraintY(SizeValue.px(y-ele.getHeight()/2));
        
        popUp.layoutElements();
}