refactor!: Update flyouts to use inflaters. #8601
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The basics
The details
Resolves
Fixes #8546
Proposed Changes
This PR updates the base, horizontal and vertical flyout classes to use the newly introduced inflaters rather than hardcoding support for buttons/labels/blocks. As a result, it's now possible to add arbitrary elements of different types to flyouts.
Breaking Changes
This is a fairly extensive refactor, and makes several changes to the behavior of flyouts. At a high level, support for recycling blocks has been removed. This always required a subclass to enable, and is still achievable through subclassing, but the mostly-inaccessible code that partially supported it has been removed. The continuous toolbox plugin in blockly-samples, which did use recycling, will be updated to implement it using the new API.
Additionally, the backing mats/rects placed behind blocks in the flyout have been removed. These were used to fill in the gaps in C-shaped blocks or empty inputs to allow initiating block drags even when not clicking on the actual block, but instead in one of its voids. This behavior is inconsistent with the main workspace, and was mostly a workaround for not having shadow blocks, which are largely a better solution to this problem.
At an API level, the following have been adjusted:
FlyoutItemType
enum has been removed, since flyout items may now be of arbitrary types.Flyout.layout_
no longer takes the secondgaps
argument. Flyouts no longer maintain separate lists of gaps and content; instead, there is one list of content, which may include elements representing gaps.Flyout.buttons_
field has been removed, along with the protectedFlyout.initFlyoutButton_()
andFlyout.addBlockListeners_()
methods. Flyouts are now agnostic as to their contents, so special handling for special types of items is now unneeded.Flyout.rectMap_
field, along with the protectedFlyout.createRect_()
andFlyout.moveRectToBlock_()
methods have been removed. Flyouts no longer include backing rects for blocks.Flyout.blockIsRecyclable_()
method has been removed, since recycling support has been removed from core.FlyoutItem
interface has been adjusted to remove theblock
andbutton
fields, and replace them with anelement
field of typeIBoundedElement
. Thetype
field remains, and may be used to distinguish the types of individual flyout elements.