Overlay support and PickList
widget
#444
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.
This PR introduces the foundations for overlay support and a
PickList
widget.A new
overlay
method has been added to theWidget
trait. A widget can choose to implement this method to display interactive content on top of other widgets by returning an implementor of the newOverlay
trait.While this new
Overlay
trait is very similar toWidget
, the layout logic of anOverlay
works with absolute window coordinates, instead of some relative limits. This can be leveraged to smartly overlay content based on the absolute position of a widget:Additionally, a
PickList
widget has been implemented to showcase the overlay support. This widget is equivalent to a "dropdown list" or a<select>
element on the Web.The
PickList
widget uses aMenu
as its overlay, which represents a list of selectable options. Currently,Menu
is the only built-in type implementing the newOverlay
trait. However, now that the foundations are laid out, I believe we should be able to implement different kinds of overlays relatively easily.It is important to note that the current overlay support has some limitations and, therefore, it is not equivalent to full layering support (see #30). Specifically, the
Overlay
trait does not currently allow nesting, which means we cannot satisfy some use cases yet (like displaying a modal with aPickList
inside). We will need to improve our rendering pipeline—specially text—before we are able to remove these limitations. In any case, I believe this is the first step in the right direction and the current implementation, while far from complete, already brings a lot of value.Finally, and as always, I have created a new
pick_list
example to showcase the newPickList
widget and also added a preset selector to thegame_of_life
example.Closes #235.