Skip to content
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

Handling the GUI #4

Open
tgross35 opened this issue Jul 25, 2023 · 0 comments
Open

Handling the GUI #4

tgross35 opened this issue Jul 25, 2023 · 0 comments

Comments

@tgross35
Copy link
Contributor

Brainstorming some ways that we could make the GUI nicely pluggable. I think that we need to be able to decompose to a handful of simple items:

trait Renderable {
    /// Decompose this item into renderable elements
    fn decompose(&self) -> impl Iterator<Item = Render>;
}

trait RenderItem {
    fn hitbox(&self) -> Hitbox;
    fn render(...) -> ...
}

struct Hitbox {
    x: i32,
    y: i32,
    width: i32,
    height: i32
}

Basically, have a quick method (hitbox) that the caller can use to check whether the item is in the viewport, then a slow method to actually get the information needed to render it. The slow method could return something like &dyn Draw or a concrete enum type, I'm not sure what would be best.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant