BREAKING CHANGES - Library Reform (see comment for details). #385
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.
Sorry for the massive commit! The reform involved a lot of changes and it made sense to address some older issues while I was going. In general, I'm super excited about these changes :)
Here's a quick summary of changes before going into deets for a couple:
.set
method for deferred drawing (see below)..down(20.0).align_middle()
. (the default vertical alignment isLeft
and the default horizontal alignment isTop
.graphics
over toelmesque
.dimensions.rs
,rectangle.rs
,shape.rs
,draw.rs
, andpoint.rs
modules.Widget
struct to make theUi
swidget_cache
much cleaner.set_state
function toui.set_widget(ui_id, Widget {...})
.Removed Drawable trait in favour of
.set
method.This change allows us to store renderable Elements in the Ui for deferred drawing, rather than drawing the widgets at their call site. This will allow ourselves and users to set custom rendering depths for widgets and will also make it extremely easy to make sure that captured widgets are rendered last (i.e. drawing an open DropDownList on top of widgets that are called after it).
Also, I've moved the UiId from the widget constructor to this set method so the user only has to deal with
Ui
related things in a single method. i.e. thisis now this
Now, draw is only called once: on the
Ui
type after all the widgets have been set. When called, it will sort the widgets by rendering depth and then render all of the stored elements.ui.draw(gl);
Switched
graphics
over toelmesque
This is the change that made deferring the rendering of widgets possible - rather than having to directly draw the widgets at the widgets' call site, we can use elmesque to compose an
Element
and store it within our WidgetCache. Note thatelmesque
still uses thegraphics
crate under the hood, but offers a high level interface for composition and layout. One issue with this is that it will require more allocations in order to be able to store the data within theElement
s and in turn this may impact performance. I have a few ideas for addressing this, but that will be for a future PR.What next?
These changes open up a few doorways! These are what I'm hoping to implement over the next couple days:
Ui
for consideration when sorting for rendering order.Canvas
es (see #380), which will be one of the final steps towards offering a fully featured layout API without the need for coords :)Closes #372, #350, #354, #374, #373, #347, #349, #218, #344 and #145🎉