Skip to content

Conversation

@BeksOmega
Copy link
Contributor

The basics

  • I branched from develop
  • My pull request is against develop
  • My code follows the style guide

The details

Resolves

#2315 plus some

Proposed Changes

  • Adds modes: Compass and Protractor to the angle field JSON definition.
  • Also adds properties: clockwise, offset, wrap, and round to the angle field JSON definition.
  • Adds functions for setting the individual properties programmatically.
  • Adds functions for getting the value of the property (with respect for globals).

Reason for Changes

  • Requested.
  • More info below.
  • Good practice.
  • Good practice.

Why did I add individual properties?

I absolutely love love love angle fields. I think they're probably the coolest field in Blockly and I think they're super under utilized. I would hate to see them hamstrung by the JSON.

For example, if there were only the two modes available you couldn't make super cool blocks like this:
AngelJSON

which have built-in affordances for directionally-challenged users.

Providing the modes & the properties (with the properties given override power since they're more specific) is the best of both ease of use, and power.

Test Coverage

Added test blocks for all of the modes and all of the properties.

Tested all of the blocks to make sure they were functioning properly.

Tested on:

  • Desktop Chrome

Additional Information

  • Doc ticket should be created once this is merged.

Setting round to 0 looks crazy lol:
AngelJSON_Round0

But devs can fix it by setting round to 1 instead, so it doesn't need a fix.

*/
Blockly.FieldAngle.RADIUS = Blockly.FieldAngle.HALF - 1;

/* See <DOCS LINK HERE> for more information about these properties. */
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Needs a link.

@BeksOmega
Copy link
Contributor Author

Do you want any block factory support for this? Maybe a mutator with the extra options?

* or the global setting (null).
* @return {!Blockly.FieldAngle} Returns itself (for method chaining).
*/
Blockly.FieldAngle.prototype.setClockwise = function(clockwise) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@RoboErikG thoughts on returning itself for method chaining? It's a reasonable pattern, but 1) we don't use it anywhere else and 2) we probably want to be consistent.

Copy link
Contributor

@RoboErikG RoboErikG Jul 26, 2019

Choose a reason for hiding this comment

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

It's nice for convenience, but it's pretty non-standard for instances. I think I'd rather start using an opt_config parameter on the constructor with a map of the configuration options. The keys should be the same as the JSON config which will also let you use the same code for both.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you want me to go ahead and update it? or are you waiting for feedback from Rachel?

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1 to Erik. Go ahead and update it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I went to go update this, and then I realized I had more questions and wasn't sure how far reaching the change should be. I created an issue to make discussion easier.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If you're happy with the clarification on #2722, then just remove the method chaining and this will be good to go.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was planning on getting the abstract field changes in first (just to make sure how I'm thinking about it in my head is actually going to work). But don't worry I haven't forgotten about this little guy!

Also atm #2722 has this guy down as no hooks. This is b/c, for example, changing the WRAP value at runtime means the field would have to do some extra work recalculating it's value. I think I could get it to work though.

Did you want hooks for the angle field or no?

@BeksOmega
Copy link
Contributor Author

Closing after discussion with Sam. Will revive after configuration is happy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants