diff --git a/emigui/README.md b/emigui/README.md index f4a5c64b..3fe020a2 100644 --- a/emigui/README.md +++ b/emigui/README.md @@ -14,6 +14,8 @@ This is the core library crate Emigui. It is fully platform independent without * [x] Movable/resizable windows * [x] Kinetic windows * [ ] BUG FIX: Don't catch clicks on closed windows + * [ ] Windows should open from Regions and be boxed by parent region. + * Then we could open the example app inside a window in the example app, recursively. * [ ] Scroll areas * [x] Vertical scrolling * [ ] Horizontal scrolling @@ -37,11 +39,13 @@ This is the core library crate Emigui. It is fully platform independent without * [ ] Generalize Layout (separate from Region) * [ ] Cascading layout: same lite if it fits, else next line. Like text. * [ ] Grid layout +* [ ] Image support ### Web version: * [x] Scroll input * [x] Change to resize cursor on hover * [ ] Make it a JS library for easily creating your own stuff +* [ ] Read url fragment and redirect to a subpage (e.g. different examples apps) ### Animations Add extremely quick animations for some things, maybe 2-3 frames. For instance: diff --git a/emigui/src/emigui.rs b/emigui/src/emigui.rs index 09f581fd..50fc6c7b 100644 --- a/emigui/src/emigui.rs +++ b/emigui/src/emigui.rs @@ -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, stats: Stats, diff --git a/emigui/src/math.rs b/emigui/src/math.rs index cf120b20..5feef192 100644 --- a/emigui/src/math.rs +++ b/emigui/src/math.rs @@ -506,20 +506,25 @@ pub fn remap(x: f32, from: RangeInclusive, to: RangeInclusive) -> f32 } pub fn remap_clamp(x: f32, from: RangeInclusive, to: RangeInclusive) -> 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 { if x <= *range.start() { *range.start() - } else if x >= *range.end() { + } else if *range.end() <= x { *range.end() } else { x diff --git a/emigui/src/style.rs b/emigui/src/style.rs index e7e1f969..f0c2ed39 100644 --- a/emigui/src/style.rs +++ b/emigui/src/style.rs @@ -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));