Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OriginAtCenter property to Ball #1823

Merged
merged 35 commits into from
Sep 29, 2019
Merged

Add OriginAtCenter property to Ball #1823

merged 35 commits into from
Sep 29, 2019

Conversation

espertus
Copy link
Contributor

@espertus espertus commented Sep 6, 2019

This addresses Issue 1777: Fix Ball so the x- and y-coordinates are at the center. It also contains unrelated minor fixes, primarily to documentation.

An instance is running on http://spertus-ai3.appspot.com

I know it is a big PR. Would you like for me to add comments on GitHub or provide my test programs?

Some descriptions still need to be updated.
This code compiles but has not been tested.
This gives us consisentency with Scratch.
Some of the duplicated code will be replaced in a later commit.

I had to make getLeftX() and getTopY() public instead of package-private
because they were defined in an interface (MockSprite) that both
MockBall and MockImageSprite implement. They have different superclasses,
so I could not put the code there.
I also changed setXProperty() and setYProperty() to call
mockCanvas.refreshForm() instead of mockCanvas.reorderComponents().
The latter is needed only when the Z-coordinate is changed.
This should be done regardless of other changes.
The file animation.html still needs to be updated.
I'm waiting until additional changes are made.
TODO in later commits: Update animation.html.
@AppInventorWorkerBee
Copy link
Collaborator

Can one of the admins verify this patch?

@halatmit
Copy link
Contributor

halatmit commented Sep 7, 2019 via email

@ewpatton
Copy link
Member

ewpatton commented Sep 7, 2019

@espertus
Copy link
Contributor Author

espertus commented Sep 8, 2019

Thanks @halatmit. I've attached a zip file with 4 test programs: two I wrote (BallDragTest and BallPlacementTest), one from the gallery that I modified (Pong) and one from the gallery that I didn't modify (BrickBreakFinal). The modification I made to Pong was to fix the drag issue I recently reported.

all-projects.zip

I've also attached a companion APK if you don't want to build your own and trust me.

MIT AI2 Companion.apk.zip

Copy link
Member

@ewpatton ewpatton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of minor things, but I'm wondering if we could make a change to the documentation generation that would make it easier to handle the component name in the description rather than having to duplicate all of the descriptions in each child class. Maps suffers a similar issue because most shared properties are defined in MapFeatureBase rather than the concrete classes. For example, we could allow for {type} as a placeholder and have the ComponentProcessor replace it with the class name.

Copy link
Member

@ewpatton ewpatton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have one minor issue with the location of an @SimpleFunction annotation. Otherwise, LGTM unless you are planning to make more changes.

@halatmit
Copy link
Contributor

halatmit commented Sep 19, 2019 via email

@espertus
Copy link
Contributor Author

is it centerAtOrigin or originAtCenter? == Hal Hal Abelson hal@mit.edu Prof. of Comp. Sci. and Eng. MIT Dept. of Elec. Eng. and Comp. Sci.

originAtCenter

@espertus
Copy link
Contributor Author

I have made the requested change.

Copy link
Member

@ewpatton ewpatton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functionality looks good. @espertus Do you want to bump the BALL_COMPONENT_VERSION and YOUNG_ANDROID_VERSION and write the corresponding upgraders, or would you prefer to hand that off to us?

@espertus
Copy link
Contributor Author

I'll do that @ewpatton

@espertus
Copy link
Contributor Author

I made the changes @ewpatton but think I must have done something wrong: When I try loading my old programs on the instance (spertus-ai3), I get the below error:
image

@espertus
Copy link
Contributor Author

Wait, I see a bug.

@espertus
Copy link
Contributor Author

I fixed the bug I was aware of, but I'm still getting the same error.

@ewpatton
Copy link
Member

The blocks upgrade is now handled in blocklyeditor/src/versioning.js. There's a dictionary mapping component to a version mapping of upgrades to perform. Since you've only added a property, you can specify "noUpgrade" for the corresponding new version number.

@espertus
Copy link
Contributor Author

espertus commented Sep 23, 2019 via email

@ewpatton
Copy link
Member

@espertus AFAIK, it's only mentioned in YaVersion.java. It would be good to update the "How to add a property" doc with the new location. I've also started some new templates in #1850 that should guide people in the future as to the steps required to make a complete PR that more saliently outlines all of the steps.

@espertus
Copy link
Contributor Author

Thanks for the pointer. Please take another look. The latest version is running at http://spertus-ai3.appspot.com, as usual.

Copy link
Member

@ewpatton ewpatton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wxbit
Copy link
Contributor

wxbit commented Sep 30, 2019

Why not add CenterAtOrigin to ImageSprite?

@espertus
Copy link
Contributor Author

espertus commented Sep 30, 2019 via email

@wxbit
Copy link
Contributor

wxbit commented Oct 1, 2019

Got it, thanks.

@espertus espertus changed the title Add CenterAtOrigin property to Ball Oct 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment