Skip to content
Permalink
Browse files

Ignore any canvas move events that are outside of the canvas borders

Change-Id: I1ea1edae060ad5434b67e89f39442fb5496b126a
  • Loading branch information
halatmit authored and ewpatton committed Sep 20, 2019
1 parent 8bce6ff commit 4e7df342864c983858519cdc00348c8487cd2d2f
@@ -713,6 +713,10 @@ private static int upgradeCanvasProperties(Map<String, JSONValue> componentPrope
// DrawShape & DrawArc was added.
srcCompVersion = 11;
}
if (srcCompVersion < 12) {
// The ExtendMovesOutsideCanvas property was added in version 12.
srcCompVersion = 12;
}
return srcCompVersion;
}

@@ -1379,7 +1379,11 @@ Blockly.Versioning.AllUpgradeMaps =

// DrawShape & DrawArc was added
// No blocks need to be modified to upgrade to version 11.
11: "noUpgrade"
11: "noUpgrade",

// ExtendMovesOutsideCanvas was added
// No blocks need to be modified to upgrade to version 12.
12: "noUpgrade"

}, // End Canvas upgraders

@@ -471,8 +471,10 @@ private YaVersion() {
// - FORM_COMPONENT_VERSION was incremented to 25
// For YOUNG_ANDROID_VERSION 190:
// - WEB_COMPONENT_VERSION was incremented to 6
// For YOUNG_ANDROID_VERSION 191:
// - CANVAS_COMPONENT_VERSION was incremented to 12

public static final int YOUNG_ANDROID_VERSION = 190;
public static final int YOUNG_ANDROID_VERSION = 191;

// ............................... Blocks Language Version Number ...............................

@@ -700,7 +702,9 @@ private YaVersion() {
// - The default value of the TextAlignment property was changed to Component.ALIGNMENT_CENTER
// For CANVAS_COMPONENT_VERSION 11:
// - DrawShape & DrawArc was added
public static final int CANVAS_COMPONENT_VERSION = 11;
// For CANVAS_COMPONENT_VERSION 12
// - ExtendMovesOutsideCanvas was added
public static final int CANVAS_COMPONENT_VERSION = 12;

// For CHECKBOX_COMPONENT_VERSION 2:
// - The Value property was renamed to Checked.
@@ -113,6 +113,7 @@
private int backgroundColor;
private String backgroundImagePath = "";
private int textAlignment;
private boolean extendMovesOutsideCanvas = false;

// Default values
private static final int MIN_WIDTH_HEIGHT = 1;
@@ -278,6 +279,13 @@ void parse(MotionEvent event) {
isDrag = true;
drag = true;

// Don't let MOVE extend beyond the bounds of the canvas
// if ExtendMovesOutsideCanvas is false
if (((x <= 0) || (x > width) || (y <= 0) || (y > height))
&& (! extendMovesOutsideCanvas)) {
break;
}

// Update draggedSprites by adding any that are currently being
// touched.
for (Sprite sprite : sprites) {
@@ -1112,6 +1120,21 @@ public void TextAlignment(int alignment) {
}
}

@SimpleProperty(description =
"Determines whether moves can extend beyond the canvas borders. " +
" Default is false. This should normally be false, and the property " +
"is provided for backwards compatibility.",
category = PropertyCategory.BEHAVIOR,
userVisible = true)
public boolean ExtendMovesOutsideCanvas() {
return extendMovesOutsideCanvas;
}

@DesignerProperty(editorType = PropertyTypeConstants.PROPERTY_TYPE_BOOLEAN, defaultValue = "False")
@SimpleProperty(userVisible = true)
public void ExtendMovesOutsideCanvas(boolean extend){
extendMovesOutsideCanvas = extend;
}

// Methods supporting event handling

0 comments on commit 4e7df34

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