Crates.io | raylib_interactive |
lib.rs | raylib_interactive |
version | |
source | src |
created_at | 2024-12-23 19:42:32.797872+00 |
updated_at | 2025-03-21 03:01:20.766348+00 |
description | An interactive library for Raylib |
homepage | https://github.com/OrtheSnowJames/rayinteract |
repository | |
max_upload_size | |
id | 1493358 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
This is a library that supports c++ and rust and adds many interactive things to your current raylib project, such as:
Buttons, Checkboxes, Dropdowns, and Textfields.
A copy of "rust docs.md" is pasted below:
Raylib Interactive is a library built on raylib that adds many components to raylib-rs, allowing you to make better graphical interfaces. The latest version: Added backspace hold functionality to TextField. For more information, visit my GitHub homepage.
This library adds Buttons, Checkboxes, Textfields, and Dropdowns. Hope you enjoy! -James
new(x: f32, y: f32, width: f32, height: f32, text: &str) -> Self
// Creates a new button with specified position, dimensions and textwith_style(mut self, style: ButtonStyle) -> Self
// Applies a custom style to the buttonset_enabled(&mut self, enabled: bool)
// Enables or disables the button interactivityis_enabled(&self) -> bool
// Returns whether the button is currently enabledset_position(&mut self, x: f32, y: f32)
// Updates the button's positionset_size(&mut self, width: f32, height: f32)
// Updates the button's dimensionsset_text(&mut self, text: &str)
// Changes the button's textget_text(&self) -> &str
// Returns the current button textget_position(&self) -> Vector2
// Returns the current positionget_size(&self) -> Vector2
// Returns the current dimensionsis_clicked(&self, rl: &RaylibHandle) -> bool
// Checks if button was clicked this frameis_hovered(&self) -> bool
// Checks if mouse is hovering over buttonupdate(&mut self, rl: &RaylibHandle)
// Updates button statedraw(&self, d: &mut RaylibDrawHandle)
// Renders the buttonnew(x: f32, y: f32, size: f32, label: &str) -> Self
// Creates a new checkbox with position, size and labelset_checked(&mut self, checked: bool)
// Sets the checked stateis_checked(&self) -> bool
// Returns current checked statetoggle(&mut self)
// Toggles between checked/uncheckedset_position(&mut self, x: f32, y: f32)
// Updates checkbox positionset_size(&mut self, size: f32)
// Updates checkbox sizeset_label(&mut self, label: &str)
// Changes the label textget_label(&self) -> &str
// Returns current label textwith_animation(mut self, animation: CheckboxAnimation) -> Self
// Applies custom animationupdate(&mut self, rl: &RaylibHandle)
// Updates checkbox statedraw(&self, d: &mut RaylibDrawHandle)
// Renders the checkboxnew(x: f32, y: f32, width: f32, height: f32, max_length: usize) -> Self
// Creates new text field with position, size and max lengthset_text(&mut self, text: &str)
// Sets the field's text contentget_text(&self) -> &str
// Returns current text contentset_placeholder(&mut self, placeholder: &str)
// Sets placeholder text shown when emptyget_placeholder(&self) -> &str
// Returns current placeholder textset_mask_char(&mut self, mask: Option<char>)
// Sets masking character for password fieldsset_max_length(&mut self, max_length: usize)
// Updates maximum text lengthis_focused(&self) -> bool
// Returns whether field has input focusset_position(&mut self, x: f32, y: f32)
// Updates field positionset_size(&mut self, width: f32, height: f32)
// Updates field dimensionsclear(&mut self)
// Clears all text contenthandle_input(&mut self, rl: &RaylibHandle)
// Processes keyboard inputupdate(&mut self, rl: &RaylibHandle)
// Updates field statedraw(&self, d: &mut RaylibDrawHandle)
// Renders the text fieldnew(x: f32, y: f32, width: f32, height: f32, items: Vec<String>) -> Self
// Creates dropdown with position, size and itemsset_items(&mut self, items: Vec<String>)
// Updates the list of itemsget_items(&self) -> &[String]
// Returns current item listset_selected_index(&mut self, index: Option<usize>)
// Sets currently selected itemget_selected_index(&self) -> Option<usize>
// Returns index of selected itemget_selected_item(&self) -> Option<&String>
// Returns currently selected itemenable_search(&mut self, enabled: bool)
// Enables/disables search functionalityis_search_enabled(&self) -> bool
// Returns whether search is enabledset_max_height(&mut self, height: f32)
// Sets maximum height when openedset_position(&mut self, x: f32, y: f32)
// Updates dropdown positionset_size(&mut self, width: f32, height: f32)
// Updates dropdown dimensionsis_opened(&self) -> bool
// Returns whether dropdown is expandedupdate(&mut self, rl: &RaylibHandle)
// Updates dropdown statedraw(&self, d: &mut RaylibDrawHandle)
// Renders the dropdownDrawable::draw(&self, d: &mut RaylibDrawHandle)
// Renders a UI componentInteractive::update(&mut self, rl: &RaylibHandle)
// Updates component stateInteractive::handle_input(&mut self, rl: &RaylibHandle)
// Processes user inputStyleable::with_theme(self, theme: Theme) -> Self
// Applies a theme to componentStyleable::override_style(self, style: Style) -> Self
// Overrides default stylingEventEmitter::on(&mut self, event: Event, callback: Box<dyn Fn(&T)>)
// Registers event callbackEventEmitter::emit(&self, event: Event, data: &T)
// Triggers registered event callbacksLayout::horizontal()
// Creates horizontal layout containerLayout::vertical()
// Creates vertical layout containerLayout::grid(rows: u32, cols: u32)
// Creates grid layout containerLayout::add<T: Widget>(&mut self, widget: T)
// Adds widget to layoutLayout::remove(&mut self, index: usize)
// Removes widget at indexLayout::clear(&mut self)
// Removes all widgetsRaylib Interactive is a high-level UI library built on top of Raylib, providing an intuitive and flexible interface for creating interactive graphical user interfaces in Rust. It offers a comprehensive set of widgets, event handling, and layout management tools while maintaining Raylib's simplicity and performance.
use raylib::prelude::*;
use raylib_interactive::*;
fn main() {
let (mut rl, thread) = raylib::init()
.size(800, 600)
.title("Raylib Interactive Demo")
.build();
let mut button = Button::new(350.0, 200.0, 100.0, 40.0, "Click Me!")
.with_style(ButtonStyle::default());
let mut checkbox = Checkbox::new(350.0, 300.0, 20.0, "Enable Feature");
let mut text_field = TextField::new(300.0, 400.0, 200.0, 30.0, 50);
while !rl.window_should_close() {
button.update(&rl);
checkbox.update(&rl);
text_field.update(&rl);
if button.is_clicked(&rl) {
println!("Button clicked!");
}
let mut d = rl.begin_drawing(&thread);
d.clear_background(Color::WHITE);
button.draw(&mut d);
checkbox.draw(&mut d);
text_field.draw(&mut d);
}
}