一个 100% Rust GUI 库:Conrod
jopen
10年前
Conrod 是一个超级年青,"immediate-mode",完全采用Rust编写,拥有花哨搜索功能的用户图形界面GUI。
可用的组件
- Buttons
- Toggles
- Envelope Editor
- Number Dialers
- Sliders
- TextBox
- XYPad
依赖
- rustc - we try to keep up to date with the latest nightly build.
- cargo - for handling other rust dependencies and building the project.
- freetype - at the moment, Conrod uses freetype-rs for its font rendering, which means you'll need to have the freetype library installed on your system. You can download and install the freetype library here.
// Inside our render loop... button::draw(&render_args, // Screen width and height. &mut gl, // The OpenGL instance used to draw the GUI. &mut ui_context, // A user interface context keeps track of state. unique_id, // Each widget needs it's own UI_ID. Point::new(x, y), // Screen location. width, // Rectangle width f64. height, // Rectangle height f64. Frame(frame_width, frame_color), // Or perhaps `NoFrame` if you don't want one. Color::new(r, g, b, a), // The color of the rectangle. Label("PRESS", font_size, font_color), // Here you can pass Label(...) or NoLabel. || { // Callback closure - Do your things here! });