Skip to content
Permalink
Browse files

Refactored commits from PR #2910

Clarified the JavaDoc and refactored the interface name to be more consistent with Codename One conventions
  • Loading branch information...
codenameone committed Sep 14, 2019
1 parent 597a58e commit da75eef0c247d8d29039b0abea963efd80023909
@@ -56,7 +56,7 @@
*
* @author Chen Fishbein
*/
public class Button extends Label implements IReleasable {
public class Button extends Label implements ReleasableComponent {
/**
* Default value for the button ripple effect, this can be set with the theme constant buttonRippleBool
*/
@@ -3226,14 +3226,14 @@ private boolean isCurrentlyScrolling(Component cmp) {
}


public <C extends Component & IReleasable> void addComponentAwaitingRelease(C c) {
public <C extends Component & ReleasableComponent> void addComponentAwaitingRelease(C c) {
if(componentsAwatingRelease == null) {
componentsAwatingRelease = new ArrayList<Component>();
}
componentsAwatingRelease.add(c);
}

public <C extends Component & IReleasable> void removeComponentAwaitingRelease(C c) {
public <C extends Component & ReleasableComponent> void removeComponentAwaitingRelease(C c) {
if(componentsAwatingRelease != null) {
componentsAwatingRelease.remove(c);
}
@@ -3255,8 +3255,8 @@ private void autoRelease(int x, int y) {
}
Component pendingC = componentsAwatingRelease.get(0);
if (atXY != pendingC) {
if (pendingC instanceof IReleasable) {
IReleasable rc = (IReleasable) pendingC;
if (pendingC instanceof ReleasableComponent) {
ReleasableComponent rc = (ReleasableComponent) pendingC;
int relRadius = rc.getReleaseRadius();
if (relRadius > 0) {
Rectangle r = new Rectangle(pendingC.getAbsoluteX() - relRadius, pendingC.getAbsoluteY() - relRadius, pendingC.getWidth() + relRadius * 2, pendingC.getHeight() + relRadius * 2);
@@ -3269,7 +3269,7 @@ private void autoRelease(int x, int y) {
componentsAwatingRelease = null;
pendingC.dragInitiated();
}
} else if (pendingC instanceof IReleasable && ((IReleasable) pendingC).isAutoRelease()) {
} else if (pendingC instanceof ReleasableComponent && ((ReleasableComponent) pendingC).isAutoRelease()) {
componentsAwatingRelease = null;
pendingC.dragInitiated();
}
@@ -3564,8 +3564,8 @@ public void pointerReleased(int x, int y) {
return;
}

if(pendingC instanceof IReleasable) {
IReleasable rc = (IReleasable) pendingC;
if(pendingC instanceof ReleasableComponent) {
ReleasableComponent rc = (ReleasableComponent) pendingC;
int relRadius = rc.getReleaseRadius();
if(relRadius > 0 || pendingC.contains(x, y)) {
Rectangle r = new Rectangle(pendingC.getAbsoluteX() - relRadius, pendingC.getAbsoluteY() - relRadius, pendingC.getWidth() + relRadius * 2, pendingC.getHeight() + relRadius * 2);
@@ -3709,8 +3709,8 @@ public void pointerReleased(int x, int y) {
if (componentsAwatingRelease != null && !Display.getInstance().isRecursivePointerRelease()) {
for (int iter = 0; iter < componentsAwatingRelease.size(); iter++) {
Component c = componentsAwatingRelease.get(iter);
if (c instanceof IReleasable) {
IReleasable rc = (IReleasable) c;
if (c instanceof ReleasableComponent) {
ReleasableComponent rc = (ReleasableComponent) c;
rc.setReleased();
}
}
@@ -1,8 +1,14 @@
package com.codename1.ui;

/** An Interface that any Component that could be released from the parent Form can implement */
/**
* An Interface that any Component that could be released from the parent
* Form can implement. E.g. when a button is held down with a finger and dragged
* outside of the component bounds a release event might be discarded. With
* this interface we can register our desire for that release event even in that
* case.
*/

public interface IReleasable {
public interface ReleasableComponent {

/**
* Returns true if this is an auto-released Component.

0 comments on commit da75eef

Please sign in to comment.
You can’t perform that action at this time.