Given the goal of this function, I'm not sure it can get more optimal than this even with specialized data structures like KD-trees. The problem is that we want all widgets that are hovered, not just some, and that makes nearest neighbor useless. The main optimizations here are simple: - Group up all the render data we need in a single vec to help cache. - Precompute the rect's extents to make the contains check at most 4 comparisons. This had a noticable effect on the "wiggle the mouse frantically" performance, where Gooey isn't actually repainting but is routing mouse events. |
||
|---|---|---|
| .github/workflows | ||
| .rustme | ||
| examples | ||
| gooey-macros | ||
| src | ||
| .crate-docs.md | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| CODE_OF_CONDUCT.md | ||
| CONTRIBUTING.md | ||
| LICENSE-APACHE | ||
| LICENSE-MIT | ||
| README.md | ||
| rustfmt.toml | ||
Gooey
Gooey is an experimental Graphical User Interface (GUI) crate for the Rust
programming language. It is built using Kludgine, which is powered
by winit and wgpu. It is incredibly early in development,
and is being developed for a game that will hopefully be developed shortly.
The Widget trait is the building block of Gooey: Every user
interface element implements Widget. A full list of built-in widgets can be
found in the gooey::widgets module.
Gooey uses a reactive data model. To see an example of how reactive data models work, consider this example that displays a button that increments its own label:
fn main() -> gooey::Result {
// Create a dynamic usize.
let count = Dynamic::new(0_isize);
// Create a dynamic that contains `count.to_string()`
let count_label = count.map_each(ToString::to_string);
// Create a new button whose text is our dynamic string.
count_label
.into_button()
// Set the `on_click` callback to a closure that increments the counter.
.on_click(count.with_clone(|count| move |_| count.set(count.get() + 1)))
// Run the application
.run()
}
Open-source Licenses
This project, like all projects from Khonsu Labs, is open-source. This repository is available under the MIT License or the Apache License 2.0.
To learn more about contributing, please see CONTRIBUTING.md.