Raylib Interactive
The library for people who want to do other things but stick to raylib
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 Documentation
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 better functionallity to the things allowing for mostly text changes but also other stuff and more! For more information, visit my GitHub homepage.
This library adds Buttons, Checkboxes, Textfields, and Dropdowns. Hope you enjoy! -James
Overview
Button Methods
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 button
Checkbox Methods
new(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 checkbox
TextField Methods
new(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 field
Dropdown Methods
new(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 dropdown
Common Traits
Drawable::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 styling
Event System
EventEmitter::on(&mut self, event: Event, callback: Box<dyn Fn(&T)>)
// Registers event callbackEventEmitter::emit(&self, event: Event, data: &T)
// Triggers registered event callbacks
Layout System
Layout::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 widgets
Introduction
Raylib 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.
Key Features
- Ready-to-use UI components (buttons, checkboxes, text fields, dropdowns)
- Event-driven architecture with custom callbacks
- Flexible layout system for complex UI arrangements
- Customizable themes and styling
- Automatic input handling and state management
- Seamless integration with existing Raylib applications
Usage Example
use *;
use *;