Small fixes and added TODOs

This commit is contained in:
Emil Ernerfeldt 2020-05-08 21:31:27 +02:00
parent 702e135f07
commit e317f697c0
4 changed files with 22 additions and 9 deletions

View file

@ -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:

View file

@ -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,

View file

@ -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

View file

@ -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));