-
-
Notifications
You must be signed in to change notification settings - Fork 55
Basic GUI support #35
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Also added `scale` field to `graphics::Sprite`.
Also, move widgets into their own module.
Now, the UI runtime tracks the cursor position by itself using a custom `Input` wrapper.
|
I have uploaded the new docs here: http://coffee-rs.surge.sh/coffee/index.html I am quite happy with how it's turning out. Any feedback is appreciated! |
|
There is still some work to be done: debugging some weird behavior and implementing a I think we should open issues so we can properly track the remaining work and deal with them in separate PRs. So, let's merge this! 🎉 |
|
I think you forgot to document the removal of |
|
@PvdBerg1998 In any case, we will review/rewrite the changelog a bit before releasing And thank you for taking a look! |
|
No sorry, I didn't see it was only added in this PR. Nice work! 🎉 |
Watch in higher quality / Code
This PR implements a basic UI runtime and integrates it with Coffee.
Features / Goals
stretch.Widgettrait with aRendererassociated type, allowing users to build their own custom widgets and UI renderers.elm-ui. Users define a function describing their UI layout. The resulting UI produces messages on user interaction. Produced messages are processed by another user-defined function, changing state as desired.Gamewith theUserInterfacetrait.Built-in widgets
Progress barImplement aProgressBarwidget #45Example
This branch includes an example that showcases all the built-in widgets so far (code). If you want to check it out simply run:
Limitations
This is a first iteration. The current implementation is still missing some basic features like:
glyph_brusha bit more. Implement aTextInputwidget #46Targetand the rendering pipelines a bit. I need to further investigate, but it should be doable. Scrollable widget support #47Also, there is no way to overlay elements as of now and there are probably many performance optimizations that we could make. However, I would like to wait a bit and gather use cases before implementing these.
Breaking changes
This PR contains breaking changes that affect the architecture of the engine for the better:
Viewassociated type has been removed. Thus, implementors of theGametrait are also meant to hold the game assets. This simplifies the API considerably, and it helps model your game state-view relationship with precision, avoiding inconsistencies.Game::Inputassociated type now has to implement the newInputtrait. This splits code quite nicely, as theon_inputmethod moves away fromGame. It also makesInputimplementors reusable. For instance, aKeyboardAndMousetype has been implemented that can be used out of the box!Game::LoadingScreenassociated type has been introduced. Given that all theGameassociated types implement a trait with aloadmethod, wiring a loading screen now is as simple as writing its name. Because of this, theGame::newmethod is no longer necessary and it is dropped.Additional implemented features
Textalignment, usingHorizontalAlignmentandVerticalAlignmentFont::measure, which allows to measure anyTextRectangle::contains, returns whether or not it contains the givenPointSprite::scaleDefaultimplementation forSpritePending work
UserInterface::EventtoUserInterface::MessageuiuimoduleImplementwidget Implement aProgressBarProgressBarwidget #45Debug some weirdstretchbehavior (maybe contact maintainers and/or open an issue)stretchseems to ignoreTextmeasurements #44Debugglyph_brushmeasuring functions (they seem to be off)Font::measurereturns wrong values #43stretch)READMECHANGELOG