diff --git a/README.md b/README.md index 0ff209dd..17f91883 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ ui.horizontal(|ui| { ui.text_edit_singleline(&mut name); }); ui.add(egui::Slider::new(&mut age, 0..=120).text("age")); -if ui.button("Click each year").clicked() { +if ui.button("Increment").clicked() { age += 1; } ui.label(format!("Hello '{name}', age {age}")); @@ -376,21 +376,21 @@ The library was originally called "Emigui", but was renamed to "egui" in 2020. ## Credits -egui author and maintainer: Emil Ernerfeldt [(@emilk](https://github.com/emilk)). +egui author and maintainer: Emil Ernerfeldt ([@emilk](https://github.com/emilk)). Notable contributions by: -* [@n2](https://github.com/n2): [Mobile web input and IME support](https://github.com/emilk/egui/pull/253). -* [@optozorax](https://github.com/optozorax): [Arbitrary widget data storage](https://github.com/emilk/egui/pull/257). -* [@quadruple-output](https://github.com/quadruple-output): [Multitouch](https://github.com/emilk/egui/pull/306). -* [@EmbersArc](https://github.com/EmbersArc): [Plots](https://github.com/emilk/egui/pulls?q=+is%3Apr+author%3AEmbersArc). -* [@AsmPrgmC3](https://github.com/AsmPrgmC3): [Proper sRGBA blending for web](https://github.com/emilk/egui/pull/650). -* [@AlexApps99](https://github.com/AlexApps99): [`egui_glow`](https://github.com/emilk/egui/pull/685). -* [@mankinskin](https://github.com/mankinskin): [Context menus](https://github.com/emilk/egui/pull/543). -* [@t18b219k](https://github.com/t18b219k): [Port glow painter to web](https://github.com/emilk/egui/pull/868). -* [@danielkeller](https://github.com/danielkeller): [`Context` refactor](https://github.com/emilk/egui/pull/1050). -* [@MaximOsipenko](https://github.com/MaximOsipenko): [`Context` lock refactor](https://github.com/emilk/egui/pull/2625). -* [@mwcampbell](https://github.com/mwcampbell): [AccessKit](https://github.com/AccessKit/accesskit) [integration](https://github.com/emilk/egui/pull/2294). +* [@n2](https://github.com/n2): [Mobile web input and IME support](https://github.com/emilk/egui/pull/253) +* [@optozorax](https://github.com/optozorax): [Arbitrary widget data storage](https://github.com/emilk/egui/pull/257) +* [@quadruple-output](https://github.com/quadruple-output): [Multitouch](https://github.com/emilk/egui/pull/306) +* [@EmbersArc](https://github.com/EmbersArc): [Plots](https://github.com/emilk/egui/pulls?q=+is%3Apr+author%3AEmbersArc) +* [@AsmPrgmC3](https://github.com/AsmPrgmC3): [Proper sRGBA blending for web](https://github.com/emilk/egui/pull/650) +* [@AlexApps99](https://github.com/AlexApps99): [`egui_glow`](https://github.com/emilk/egui/pull/685) +* [@mankinskin](https://github.com/mankinskin): [Context menus](https://github.com/emilk/egui/pull/543) +* [@t18b219k](https://github.com/t18b219k): [Port glow painter to web](https://github.com/emilk/egui/pull/868) +* [@danielkeller](https://github.com/danielkeller): [`Context` refactor](https://github.com/emilk/egui/pull/1050) +* [@MaximOsipenko](https://github.com/MaximOsipenko): [`Context` lock refactor](https://github.com/emilk/egui/pull/2625) +* [@mwcampbell](https://github.com/mwcampbell): [AccessKit](https://github.com/AccessKit/accesskit) [integration](https://github.com/emilk/egui/pull/2294) * [@hasenbanck](https://github.com/hasenbanck), [@s-nie](https://github.com/s-nie), [@Wumpf](https://github.com/Wumpf): [`egui-wgpu`](https://github.com/emilk/egui/tree/master/crates/egui-wgpu) * [@jprochazk](https://github.com/jprochazk): [egui image API](https://github.com/emilk/egui/issues/3291) * And [many more](https://github.com/emilk/egui/graphs/contributors?type=a). diff --git a/crates/eframe/src/lib.rs b/crates/eframe/src/lib.rs index 3bc480c6..d34d665b 100644 --- a/crates/eframe/src/lib.rs +++ b/crates/eframe/src/lib.rs @@ -293,7 +293,7 @@ pub fn run_native( /// .labelled_by(name_label.id); /// }); /// ui.add(egui::Slider::new(&mut age, 0..=120).text("age")); -/// if ui.button("Click each year").clicked() { +/// if ui.button("Increment").clicked() { /// age += 1; /// } /// ui.label(format!("Hello '{name}', age {age}")); diff --git a/crates/egui-wgpu/src/renderer.rs b/crates/egui-wgpu/src/renderer.rs index 780c9086..21227ef9 100644 --- a/crates/egui-wgpu/src/renderer.rs +++ b/crates/egui-wgpu/src/renderer.rs @@ -814,7 +814,7 @@ impl Renderer { }; if index_count > 0 { - crate::profile_scope!("indices"); + crate::profile_scope!("indices", index_count.to_string()); self.index_buffer.slices.clear(); let required_index_buffer_size = (std::mem::size_of::() * index_count) as u64; @@ -848,7 +848,7 @@ impl Renderer { } } if vertex_count > 0 { - crate::profile_scope!("vertices"); + crate::profile_scope!("vertices", vertex_count.to_string()); self.vertex_buffer.slices.clear(); let required_vertex_buffer_size = (std::mem::size_of::() * vertex_count) as u64; diff --git a/crates/egui/src/style.rs b/crates/egui/src/style.rs index 46531f9c..0cf9c5f6 100644 --- a/crates/egui/src/style.rs +++ b/crates/egui/src/style.rs @@ -455,7 +455,7 @@ impl ScrollStyle { pub fn thin() -> Self { Self { floating: true, - bar_width: 12.0, + bar_width: 10.0, floating_allocated_width: 6.0, foreground_color: false, @@ -479,7 +479,7 @@ impl ScrollStyle { pub fn floating() -> Self { Self { floating: true, - bar_width: 12.0, + bar_width: 10.0, foreground_color: true, floating_allocated_width: 0.0, dormant_background_opacity: 0.0, diff --git a/crates/egui/src/ui.rs b/crates/egui/src/ui.rs index 658b8676..559711a2 100644 --- a/crates/egui/src/ui.rs +++ b/crates/egui/src/ui.rs @@ -30,6 +30,7 @@ use crate::{ /// ``` pub struct Ui { /// ID of this ui. + /// /// Generated based on id of parent ui together with /// another source of child identity (e.g. window title). /// Acts like a namespace for child uis. @@ -38,6 +39,7 @@ pub struct Ui { id: Id, /// This is used to create a unique interact ID for some widgets. + /// /// This value is based on where in the hierarchy of widgets this Ui is in, /// and the value is increment with each added child widget. /// This works as an Id source only as long as new widgets aren't added or removed. @@ -99,7 +101,6 @@ impl Ui { crate::egui_assert!(!max_rect.any_nan()); let next_auto_id_source = Id::new(self.next_auto_id_source).with("child").value(); self.next_auto_id_source = self.next_auto_id_source.wrapping_add(1); - let menu_state = self.menu_state(); Ui { id: self.id.with(id_source), next_auto_id_source, @@ -107,7 +108,7 @@ impl Ui { style: self.style.clone(), placer: Placer::new(max_rect, layout), enabled: self.enabled, - menu_state, + menu_state: self.menu_state.clone(), } } @@ -2232,10 +2233,6 @@ impl Ui { self.menu_state = None; } - pub(crate) fn menu_state(&self) -> Option>> { - self.menu_state.clone() - } - pub(crate) fn set_menu_state(&mut self, menu_state: Option>>) { self.menu_state = menu_state; } diff --git a/crates/egui/src/widgets/drag_value.rs b/crates/egui/src/widgets/drag_value.rs index b5ae6545..09d3b9f3 100644 --- a/crates/egui/src/widgets/drag_value.rs +++ b/crates/egui/src/widgets/drag_value.rs @@ -79,6 +79,8 @@ impl<'a> DragValue<'a> { } /// How much the value changes when dragged one point (logical pixel). + /// + /// Should be finite and greater than zero. #[inline] pub fn speed(mut self, speed: impl Into) -> Self { self.speed = speed.into(); diff --git a/crates/egui_demo_lib/src/demo/code_example.rs b/crates/egui_demo_lib/src/demo/code_example.rs index 7edb6702..b4adf8fb 100644 --- a/crates/egui_demo_lib/src/demo/code_example.rs +++ b/crates/egui_demo_lib/src/demo/code_example.rs @@ -45,11 +45,11 @@ impl CodeExample { show_code( ui, r#" - if ui.button("Click each year").clicked() { + if ui.button("Increment").clicked() { self.age += 1; }"#, ); - if ui.button("Click each year").clicked() { + if ui.button("Increment").clicked() { self.age += 1; } ui.end_row(); diff --git a/crates/egui_plot/src/transform.rs b/crates/egui_plot/src/transform.rs index 722df5fc..42edef0b 100644 --- a/crates/egui_plot/src/transform.rs +++ b/crates/egui_plot/src/transform.rs @@ -359,22 +359,22 @@ impl PlotTransform { rect } - /// delta position / delta value + /// delta position / delta value = how many ui points per step in the X axis in "plot space" pub fn dpos_dvalue_x(&self) -> f64 { self.frame.width() as f64 / self.bounds.width() } - /// delta position / delta value + /// delta position / delta value = how many ui points per step in the Y axis in "plot space" pub fn dpos_dvalue_y(&self) -> f64 { -self.frame.height() as f64 / self.bounds.height() // negated y axis! } - /// delta position / delta value + /// delta position / delta value = how many ui points per step in "plot space" pub fn dpos_dvalue(&self) -> [f64; 2] { [self.dpos_dvalue_x(), self.dpos_dvalue_y()] } - /// delta value / delta position + /// delta value / delta position = how much ground do we cover in "plot space" per ui point? pub fn dvalue_dpos(&self) -> [f64; 2] { [1.0 / self.dpos_dvalue_x(), 1.0 / self.dpos_dvalue_y()] } diff --git a/examples/hello_world/src/main.rs b/examples/hello_world/src/main.rs index c27ae5a1..b3fda5a5 100644 --- a/examples/hello_world/src/main.rs +++ b/examples/hello_world/src/main.rs @@ -44,7 +44,7 @@ impl eframe::App for MyApp { .labelled_by(name_label.id); }); ui.add(egui::Slider::new(&mut self.age, 0..=120).text("age")); - if ui.button("Click each year").clicked() { + if ui.button("Increment").clicked() { self.age += 1; } ui.label(format!("Hello '{}', age {}", self.name, self.age)); diff --git a/examples/hello_world_par/src/main.rs b/examples/hello_world_par/src/main.rs index 604939ff..617e840d 100644 --- a/examples/hello_world_par/src/main.rs +++ b/examples/hello_world_par/src/main.rs @@ -49,7 +49,7 @@ impl ThreadState { ui.text_edit_singleline(&mut self.name); }); ui.add(egui::Slider::new(&mut self.age, 0..=120).text("age")); - if ui.button("Click each year").clicked() { + if ui.button("Increment").clicked() { self.age += 1; } ui.label(format!("Hello '{}', age {}", self.name, self.age)); diff --git a/examples/hello_world_simple/src/main.rs b/examples/hello_world_simple/src/main.rs index 80e263f4..5f0ed31a 100644 --- a/examples/hello_world_simple/src/main.rs +++ b/examples/hello_world_simple/src/main.rs @@ -23,7 +23,7 @@ fn main() -> Result<(), eframe::Error> { .labelled_by(name_label.id); }); ui.add(egui::Slider::new(&mut age, 0..=120).text("age")); - if ui.button("Click each year").clicked() { + if ui.button("Increment").clicked() { age += 1; } ui.label(format!("Hello '{name}', age {age}")); diff --git a/media/demo.gif b/media/demo.gif index 385c8228..2df2ed08 100644 Binary files a/media/demo.gif and b/media/demo.gif differ