New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

BREAKING CHANGES - Library Reform (see comment for details). #385

Merged
merged 5 commits into from Apr 20, 2015

Conversation

Projects
None yet
2 participants
@mitchmindtree
Member

mitchmindtree commented Apr 20, 2015

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:

  • Removed Drawable trait in favour of new .set method for deferred drawing (see below).
  • Removed Callable trait and moved callback method to the widget impls to save on imports.
  • Removed color.rs module in favour of PistonDevelopers/color crate.
  • Fixed / vastly improved Positionable trait and removed annoying Ui parameter.
  • Added methods for alignment (top, bottom, left, right, middle) i.e. .down(20.0).align_middle(). (the default vertical alignment is Left and the default horizontal alignment is Top.
  • Switched graphics over to elmesque.
  • Fixed issue where text would flow off widget.
  • Deleted unnecessary dimensions.rs, rectangle.rs, shape.rs, draw.rs, and point.rs modules.
  • Added a Widget struct to make the Uis widget_cache much cleaner.
  • Inlined a few unnecessary widget module functions that were only being called in one place.
  • Changed the macro-generated set_state function to ui.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. this

Button::new(ui_id).draw(ui, gl);

is now this

Button::new().set(ui_id, ui);

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 to elmesque

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 that elmesque still uses the graphics 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 the Elements 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:

  • Register captured widgets within the Ui for consideration when sorting for rendering order.
  • Scroll functionality for DropDownList.
  • The Positionable trait is ready for easy integration with Canvases (see #380), which will be one of the final steps towards offering a fully featured layout API without the need for coords :)
  • Unique per-widget theme-ing.

Closes #372, #350, #354, #374, #373, #347, #349, #218, #344 and #145 馃帀

@bvssvni

This comment has been minimized.

Member

bvssvni commented Apr 20, 2015

Nice! Now we can use Button as a object-as-function just like in piston-graphics!

@mitchmindtree

This comment has been minimized.

Member

mitchmindtree commented Apr 20, 2015

@bvssvni has reviewed - there are a few things to address but they can easily be done in a future PR - going to merge 馃憤

mitchmindtree added a commit that referenced this pull request Apr 20, 2015

Merge pull request #385 from mitchmindtree/experiment
BREAKING CHANGES - Library Reform (see comment for details).

@mitchmindtree mitchmindtree merged commit b3f23b9 into PistonDevelopers:master Apr 20, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment