mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 13:20:05 -04:00
Small fixes and added TODOs
This commit is contained in:
@@ -11,7 +11,7 @@ struct Stats {
|
||||
}
|
||||
|
||||
/// Encapsulates input, layout and painting for ease of use.
|
||||
/// TODO: merge into Context
|
||||
/// TODO: merge into Context, and have generations of Context instead.
|
||||
pub struct Emigui {
|
||||
ctx: Arc<Context>,
|
||||
stats: Stats,
|
||||
|
||||
@@ -506,20 +506,25 @@ pub fn remap(x: f32, from: RangeInclusive<f32>, to: RangeInclusive<f32>) -> f32
|
||||
}
|
||||
|
||||
pub fn remap_clamp(x: f32, from: RangeInclusive<f32>, to: RangeInclusive<f32>) -> f32 {
|
||||
let t = if x <= *from.start() {
|
||||
0.0
|
||||
} else if x >= *from.end() {
|
||||
1.0
|
||||
if x <= *from.start() {
|
||||
*to.start()
|
||||
} else if *from.end() <= x {
|
||||
*to.end()
|
||||
} else {
|
||||
(x - from.start()) / (from.end() - from.start())
|
||||
};
|
||||
lerp(to, t)
|
||||
let t = (x - from.start()) / (from.end() - from.start());
|
||||
// Ensure no numerical inaccurcies sneak in:
|
||||
if 1.0 <= t {
|
||||
*to.end()
|
||||
} else {
|
||||
lerp(to, t)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn clamp(x: f32, range: RangeInclusive<f32>) -> f32 {
|
||||
if x <= *range.start() {
|
||||
*range.start()
|
||||
} else if x >= *range.end() {
|
||||
} else if *range.end() <= x {
|
||||
*range.end()
|
||||
} else {
|
||||
x
|
||||
|
||||
@@ -170,6 +170,10 @@ impl Style {
|
||||
*self = Default::default();
|
||||
}
|
||||
|
||||
region.add(label!("Debug:").text_style(TextStyle::Heading));
|
||||
region.add(Checkbox::new(&mut self.debug_regions, "debug_regions"));
|
||||
region.add(Separator::new());
|
||||
// TODO: region.section("Heading", |ui| ui.add(contents))
|
||||
|
||||
region.add(Slider::f32(&mut self.item_spacing.x, 0.0..=10.0).text("item_spacing.x").precision(0));
|
||||
region.add(Slider::f32(&mut self.item_spacing.y, 0.0..=10.0).text("item_spacing.y").precision(0));
|
||||
|
||||
Reference in New Issue
Block a user