germangb / imgui-ext Goto Github PK
View Code? Open in Web Editor NEWRust library for building imgui GUIs using a derive macro
Home Page: https://crates.io/crates/imgui-ext
License: MIT License
Rust library for building imgui GUIs using a derive macro
Home Page: https://crates.io/crates/imgui-ext
License: MIT License
Using mem::transmute
should be safe in most situations as long as the types have the Copy
trait.
Right now the implementation is trait based, and traits are implemented for just a handful types (arrays and tuples, mostly). By using mem::transmute
, foreign types would be supported:
#[imgui(input)]
foo: [f32; 3]
#[imgui(input)]
foo_cgmath: cgmath::Vector3<f32>
This example works every time because Vector3 has the #[repr(C)]
annotation, i.e. its memory layout is the same as the array's. If it didn't, the order of the fields could be altered by the compiler.
Also, the size of the types would have to be checked at runtime, I think...
At the moment, the default widget is a label, which means that if you don't specify a widget type inside an annotation, that particular struct field is rendered as a text label (provided it implements Display
), which is not interactive.
The idea is to define the following default widgets for each type:
rust type | default widget | remarks |
---|---|---|
i32 , u32 , f32 , [f32; 2] , (f32, f32) etc... |
input | |
bool |
checkbox | |
String , ImString |
input | String might need an extra allocation, which is not desirable |
NOTE: Table not definitive
This way you can save a few keystrokes:
#[derive(imgui_ext::Gui)]
struct Example {
#[imgui(checkbox)]
a: bool,
#[imgui(input)]
b: [f32; 2],
}
// would become equivalent to:
#[derive(imgui_ext::Gui)]
struct Example {
#[imgui]
a: bool,
#[imgui]
b: [f32; 2],
}
Having a drop down box to select a variant would be awesome (I'm sadly not sure about the derive logic for this).
I could also see this being useful to select an item out of an array of values.
The documentation page is in need of a lot of polish. I'm trying to improve it incrementally with every new commit, but the constant context switching between writing features/refactoring and writing docs leaves a lot to desire...
On top of that, I'm not a native speaker (english) which I think it shows in the sometimes poor use of grammar and lack of lexicon.
Some of the things I think need to be done:
no_run
or ignore
(lacking set up code).Hey,
this seems to be pretty awesome and I'd love to use it. However I am bound to imgui 0.2.1^ for my project, and manually upgrading resulted in 1458 errors. Not-Upgrading resulted in one error about a version mismatch between the imgui::Ui struct versions.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.