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] Movable/resizable windows
* [x] Kinetic windows * [x] Kinetic windows
* [ ] BUG FIX: Don't catch clicks on closed 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 * [ ] Scroll areas
* [x] Vertical scrolling * [x] Vertical scrolling
* [ ] Horizontal 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) * [ ] Generalize Layout (separate from Region)
* [ ] Cascading layout: same lite if it fits, else next line. Like text. * [ ] Cascading layout: same lite if it fits, else next line. Like text.
* [ ] Grid layout * [ ] Grid layout
* [ ] Image support
### Web version: ### Web version:
* [x] Scroll input * [x] Scroll input
* [x] Change to resize cursor on hover * [x] Change to resize cursor on hover
* [ ] Make it a JS library for easily creating your own stuff * [ ] 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 ### Animations
Add extremely quick animations for some things, maybe 2-3 frames. For instance: 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. /// 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 { pub struct Emigui {
ctx: Arc<Context>, ctx: Arc<Context>,
stats: Stats, 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 { pub fn remap_clamp(x: f32, from: RangeInclusive<f32>, to: RangeInclusive<f32>) -> f32 {
let t = if x <= *from.start() { if x <= *from.start() {
0.0 *to.start()
} else if x >= *from.end() { } else if *from.end() <= x {
1.0 *to.end()
} else {
let t = (x - from.start()) / (from.end() - from.start());
// Ensure no numerical inaccurcies sneak in:
if 1.0 <= t {
*to.end()
} else { } else {
(x - from.start()) / (from.end() - from.start())
};
lerp(to, t) lerp(to, t)
} }
}
}
pub fn clamp(x: f32, range: RangeInclusive<f32>) -> f32 { pub fn clamp(x: f32, range: RangeInclusive<f32>) -> f32 {
if x <= *range.start() { if x <= *range.start() {
*range.start() *range.start()
} else if x >= *range.end() { } else if *range.end() <= x {
*range.end() *range.end()
} else { } else {
x x

View file

@ -170,6 +170,10 @@ impl Style {
*self = Default::default(); *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.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)); region.add(Slider::f32(&mut self.item_spacing.y, 0.0..=10.0).text("item_spacing.y").precision(0));