phetsims / scenery-phet

Reusable components based on Scenery that are specific to PhET simulations.
http://scenerystack.org/
MIT License
8 stars 6 forks source link

Create a broader supertype for GroupSort view #887

Open marlitas opened 5 days ago

marlitas commented 5 days ago

I discussed the alt-input interaction for the location based objects in Number Pairs with @zepumph. There are ways in which the newly created GroupSortInteraction would work well for the use case, and ways in which it would not. Mainly, GroupSortInteraction is really only made to handle 1D movement of items, while the location based objects in Number Pairs require 2D movement.

We both agreed that for navigating a group of objects within one tab stop is a common PhET pattern, therefore creating common code support for this pattern is appropriate.

After looking through GroupSortInteractionModel together we both agreed the class is general enough to cover both 1D and 2D scenarios. Therefore GroupSortInteractionModel can remain as-is.

GroupSortInteractionView will become a subtype of GroupSelectView that adds on the keyboard listeners, as well as other logic that constricts use cases to 1D scenarios.

marlitas commented 5 days ago

I did a first pass at this. So far I have not scene any buggy behavior. The use cases so far are in Center and Variability, and Mean: Share and Balance.

I also renamed GroupSortInteractionModel to GroupSelectModel since it is now more broad. However, there are a couple of class properties that I feel should also be renamed, for example hasMouseSortedGroupItem no longer feels appropriate if perhaps the action is not to sort but to drag, or to press, or to etc. I had difficulty thinking of an term to swap "sort" out with. The first thing that came to mind was "interact" but that also felt potentially overloaded with the name that's been adopted of "Group Sort Interaction" which is now a subtype interaction.

When chatting with @zepumph he request he not be the main reviewer on this since he is busy with some other work. It feels appropriate for @pixelzoom to review and be part of continued discussions. I am assuming this is @pixelzoom's first time working with Group Sort Interaction since it has only been implemented in two sims, so I am happy to connect synchronously first if that would be helpful.

Either way I think this is now in a place where the super type is usable for Number Pairs while still allowing space for changes.