-
-
Notifications
You must be signed in to change notification settings - Fork 55
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
Basic GUI support #35
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
.Widget
trait with aRenderer
associated 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.Game
with theUserInterface
trait.Built-in widgets
Progress barImplement aProgressBar
widget #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_brush
a bit more. Implement aTextInput
widget #46Target
and 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:
View
associated type has been removed. Thus, implementors of theGame
trait 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::Input
associated type now has to implement the newInput
trait. This splits code quite nicely, as theon_input
method moves away fromGame
. It also makesInput
implementors reusable. For instance, aKeyboardAndMouse
type has been implemented that can be used out of the box!Game::LoadingScreen
associated type has been introduced. Given that all theGame
associated types implement a trait with aload
method, wiring a loading screen now is as simple as writing its name. Because of this, theGame::new
method is no longer necessary and it is dropped.Additional implemented features
Text
alignment, usingHorizontalAlignment
andVerticalAlignment
Font::measure
, which allows to measure anyText
Rectangle::contains
, returns whether or not it contains the givenPoint
Sprite::scale
Default
implementation forSprite
Pending work
UserInterface::Event
toUserInterface::Message
ui
ui
moduleImplementwidget Implement aProgressBar
ProgressBar
widget #45Debug some weirdstretch
behavior (maybe contact maintainers and/or open an issue)stretch
seems to ignoreText
measurements #44Debugglyph_brush
measuring functions (they seem to be off)Font::measure
returns wrong values #43stretch
)README
CHANGELOG