|
@@ -1,34 +1,34 @@ |
1 |
|
- |
// This Source Code is in the Public Domain per: http://unlicense.org |
2 |
|
- |
package org.litesoft.GWT.client.widgets.nonpublic; |
3 |
|
- |
|
4 |
|
- |
public class DragPositionableController extends AbstractMovable { |
5 |
|
- |
public DragPositionableController( UiPositionable pTarget ) { |
6 |
|
- |
super( pTarget ); |
7 |
|
- |
} |
8 |
|
- |
|
9 |
|
- |
@Override |
10 |
|
- |
protected boolean dragBy( int pDeltaX, int pDeltaY ) { |
11 |
|
- |
getTarget().setPosition( calcNewPos( "X", getTarget().getPosLeft(), pDeltaX, // |
12 |
|
- |
getTarget().minPosLeft(), getTarget().maxPosLeft() ), calcNewPos( "Y", getTarget().getPosTop(), pDeltaY, // |
13 |
|
- |
getTarget().minPosTop(), |
14 |
|
- |
getTarget().maxPosTop() ) ); |
15 |
|
- |
return true; |
16 |
|
- |
} |
17 |
|
- |
|
18 |
|
- |
/** |
19 |
|
- |
* @noinspection UnusedDeclaration |
20 |
|
- |
*/ |
21 |
|
- |
private int calcNewPos( String pOrientation, int pCurrentPosition, int pDelta, int pMinimumPosition, int pMaximumPosition ) { |
22 |
|
- |
int zNewPosition = pCurrentPosition; |
23 |
|
- |
if ( pDelta < 0 ) { |
24 |
|
- |
if ( (zNewPosition += pDelta) < pMinimumPosition ) { |
25 |
|
- |
zNewPosition = pMinimumPosition; |
26 |
|
- |
} |
27 |
|
- |
} else if ( (pDelta > 0) && (pMaximumPosition > 0) ) { |
28 |
|
- |
if ( (zNewPosition += pDelta) > pMaximumPosition ) { |
29 |
|
- |
zNewPosition = pMaximumPosition; |
30 |
|
- |
} |
31 |
|
- |
} |
32 |
|
- |
return zNewPosition; |
33 |
|
- |
} |
34 |
|
- |
} |
|
1 |
+ |
// This Source Code is in the Public Domain per: http://unlicense.org |
|
2 |
+ |
package org.litesoft.GWT.client.widgets.nonpublic; |
|
3 |
+ |
|
|
4 |
+ |
public class DragPositionableController extends AbstractMovable { |
|
5 |
+ |
public DragPositionableController( UiPositionable pTarget ) { |
|
6 |
+ |
super( pTarget ); |
|
7 |
+ |
} |
|
8 |
+ |
|
|
9 |
+ |
@Override |
|
10 |
+ |
protected boolean dragBy( int pDeltaX, int pDeltaY ) { |
|
11 |
+ |
getTarget().setPosition( calcNewPos( "X", getTarget().getPosLeft(), pDeltaX, // |
|
12 |
+ |
getTarget().minPosLeft(), getTarget().maxPosLeft() ), calcNewPos( "Y", getTarget().getPosTop(), pDeltaY, // |
|
13 |
+ |
getTarget().minPosTop(), |
|
14 |
+ |
getTarget().maxPosTop() ) ); |
|
15 |
+ |
return true; |
|
16 |
+ |
} |
|
17 |
+ |
|
|
18 |
+ |
/** |
|
19 |
+ |
* @noinspection UnusedDeclaration |
|
20 |
+ |
*/ |
|
21 |
+ |
private int calcNewPos( String pOrientation, int pCurrentPosition, int pDelta, int pMinimumPosition, int pMaximumPosition ) { |
|
22 |
+ |
int zNewPosition = pCurrentPosition; |
|
23 |
+ |
if ( pDelta < 0 ) { |
|
24 |
+ |
if ( (zNewPosition += pDelta) < pMinimumPosition ) { |
|
25 |
+ |
zNewPosition = pMinimumPosition; |
|
26 |
+ |
} |
|
27 |
+ |
} else if ( (pDelta > 0) && (pMaximumPosition > 0) ) { |
|
28 |
+ |
if ( (zNewPosition += pDelta) > pMaximumPosition ) { |
|
29 |
+ |
zNewPosition = pMaximumPosition; |
|
30 |
+ |
} |
|
31 |
+ |
} |
|
32 |
+ |
return zNewPosition; |
|
33 |
+ |
} |
|
34 |
+ |
} |