pub struct Window<'a> { /* private fields */ }Expand description
A named window containing UI elements. Created via Context::window().
Implementations§
Source§impl<'a> Window<'a>
impl<'a> Window<'a>
Sourcepub fn slider(
&mut self,
label: &str,
value: &mut f32,
range: RangeInclusive<f32>,
)
pub fn slider( &mut self, label: &str, value: &mut f32, range: RangeInclusive<f32>, )
A floating-point slider with a range.
Sourcepub fn slider_int(
&mut self,
label: &str,
value: &mut i32,
range: RangeInclusive<i32>,
)
pub fn slider_int( &mut self, label: &str, value: &mut i32, range: RangeInclusive<i32>, )
An integer slider with a range.
Sourcepub fn color_picker(&mut self, label: &str, value: &mut [f32; 3])
pub fn color_picker(&mut self, label: &str, value: &mut [f32; 3])
An RGB color picker (3-component).
Sourcepub fn color_picker4(&mut self, label: &str, value: &mut [f32; 4])
pub fn color_picker4(&mut self, label: &str, value: &mut [f32; 4])
An RGBA color picker (4-component).
Sourcepub fn text_input(&mut self, label: &str, value: &mut String)
pub fn text_input(&mut self, label: &str, value: &mut String)
A text input field.
Sourcepub fn dropdown(&mut self, label: &str, selected: &mut usize, options: &[&str])
pub fn dropdown(&mut self, label: &str, selected: &mut usize, options: &[&str])
A dropdown selector. Returns the selected index.
A button. Returns true for one frame when clicked.
Sourcepub fn progress_bar(&mut self, label: &str, value: f64, accent: AccentColor)
pub fn progress_bar(&mut self, label: &str, value: f64, accent: AccentColor)
A progress bar (0.0 to 1.0 or 0 to 100).
§Example
let mut progress = 0.75;
win.progress_bar("Loading", progress, AccentColor::Blue);Sourcepub fn progress_bar_with_subtitle(
&mut self,
label: &str,
value: f64,
accent: AccentColor,
subtitle: &str,
)
pub fn progress_bar_with_subtitle( &mut self, label: &str, value: f64, accent: AccentColor, subtitle: &str, )
A progress bar with subtitle text.
Sourcepub fn stat(
&mut self,
label: &str,
value: &str,
subvalue: Option<&str>,
accent: AccentColor,
)
pub fn stat( &mut self, label: &str, value: &str, subvalue: Option<&str>, accent: AccentColor, )
A stat card displaying a value with optional subvalue.
§Example
win.stat("FPS", "60", Some("avg 58"), AccentColor::Green);Sourcepub fn status(
&mut self,
label: &str,
active: bool,
active_text: Option<&str>,
inactive_text: Option<&str>,
active_color: AccentColor,
inactive_color: AccentColor,
)
pub fn status( &mut self, label: &str, active: bool, active_text: Option<&str>, inactive_text: Option<&str>, active_color: AccentColor, inactive_color: AccentColor, )
A status indicator with colored dot.
§Example
win.status("AI State", true, Some("Enabled"), Some("Disabled"), AccentColor::Green, AccentColor::Red);Sourcepub fn mini_chart(
&mut self,
label: &str,
values: &[f32],
unit: Option<&str>,
accent: AccentColor,
)
pub fn mini_chart( &mut self, label: &str, values: &[f32], unit: Option<&str>, accent: AccentColor, )
A mini sparkline chart.
§Example
let values = vec![10.0, 15.0, 12.0, 18.0, 20.0];
win.mini_chart("Velocity", &values, Some("m/s"), AccentColor::Coral);Sourcepub fn set_accent(&mut self, accent: AccentColor)
pub fn set_accent(&mut self, accent: AccentColor)
Set the accent color for this window (affects all cards in the window). Call this first before other widgets in the window.
Sourcepub fn grid<F>(&mut self, cols: usize, f: F)
pub fn grid<F>(&mut self, cols: usize, f: F)
Create a grid layout container. Elements added within the closure will be arranged in a grid with the specified number of columns.
§Example
win.grid(2, |grid| {
grid.stat("FPS", "60", None, AccentColor::Green);
grid.stat("MS", "16.7", Some("avg"), AccentColor::Blue);
grid.stat("Entities", "1024", None, AccentColor::Coral);
grid.stat("Memory", "256", Some("MB"), AccentColor::Purple);
});Sourcepub fn plot(
&mut self,
label: &str,
series: &[(&str, &[f32], AccentColor)],
x_label: Option<&str>,
y_label: Option<&str>,
)
pub fn plot( &mut self, label: &str, series: &[(&str, &[f32], AccentColor)], x_label: Option<&str>, y_label: Option<&str>, )
Plot a data series as a larger chart.
§Example
let values = vec![10.0, 15.0, 12.0, 18.0, 20.0, 22.0, 19.0];
win.plot("Performance", &[("FPS", &values, AccentColor::Green)], Some("Time"), Some("FPS"));