mirror of
https://github.com/emilk/egui.git
synced 2026-09-01 22:30:03 -04:00
Update MSRV to 1.80 (#5457)
Because some dependencies now require it, see: * https://github.com/emilk/egui/pull/5456
This commit is contained in:
@@ -260,7 +260,7 @@ impl AppRunner {
|
||||
self.frame.info.cpu_usage = Some(cpu_usage_seconds);
|
||||
}
|
||||
|
||||
fn handle_platform_output(&mut self, platform_output: egui::PlatformOutput) {
|
||||
fn handle_platform_output(&self, platform_output: egui::PlatformOutput) {
|
||||
#[cfg(feature = "web_screen_reader")]
|
||||
if self.egui_ctx.options(|o| o.screen_reader) {
|
||||
super::screen_reader::speak(&platform_output.events_description());
|
||||
|
||||
@@ -728,7 +728,7 @@ impl Painter {
|
||||
.retain(|id, _| active_viewports.contains(id));
|
||||
}
|
||||
|
||||
#[allow(clippy::unused_self)]
|
||||
#[allow(clippy::needless_pass_by_ref_mut, clippy::unused_self)]
|
||||
pub fn destroy(&mut self) {
|
||||
// TODO(emilk): something here?
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ struct Prepared {
|
||||
}
|
||||
|
||||
impl Resize {
|
||||
fn begin(&mut self, ui: &mut Ui) -> Prepared {
|
||||
fn begin(&self, ui: &mut Ui) -> Prepared {
|
||||
let position = ui.available_rect_before_wrap().min;
|
||||
let id = self.id.unwrap_or_else(|| {
|
||||
let id_salt = self.id_salt.unwrap_or_else(|| Id::new("resize"));
|
||||
@@ -295,7 +295,7 @@ impl Resize {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn show<R>(mut self, ui: &mut Ui, add_contents: impl FnOnce(&mut Ui) -> R) -> R {
|
||||
pub fn show<R>(self, ui: &mut Ui, add_contents: impl FnOnce(&mut Ui) -> R) -> R {
|
||||
let mut prepared = self.begin(ui);
|
||||
let ret = add_contents(&mut prepared.content_ui);
|
||||
self.end(ui, prepared);
|
||||
|
||||
@@ -227,7 +227,7 @@ impl GridLayout {
|
||||
self.col += 1;
|
||||
}
|
||||
|
||||
fn paint_row(&mut self, cursor: &Rect, painter: &Painter) {
|
||||
fn paint_row(&self, cursor: &Rect, painter: &Painter) {
|
||||
// handle row color painting based on color-picker function
|
||||
let Some(color_picker) = self.color_picker.as_ref() else {
|
||||
return;
|
||||
@@ -450,7 +450,7 @@ impl Grid {
|
||||
ui.allocate_new_ui(ui_builder, |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
let is_color = color_picker.is_some();
|
||||
let mut grid = GridLayout {
|
||||
let grid = GridLayout {
|
||||
num_columns,
|
||||
color_picker,
|
||||
min_cell_size: vec2(min_col_width, min_row_height),
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//! Try the live web demo: <https://www.egui.rs/#demo>. Read more about egui at <https://github.com/emilk/egui>.
|
||||
//!
|
||||
//! `egui` is in heavy development, with each new version having breaking changes.
|
||||
//! You need to have rust 1.79.0 or later to use `egui`.
|
||||
//! You need to have rust 1.80.0 or later to use `egui`.
|
||||
//!
|
||||
//! To quickly get started with egui, you can take a look at [`eframe_template`](https://github.com/emilk/eframe_template)
|
||||
//! which uses [`eframe`](https://docs.rs/eframe).
|
||||
|
||||
@@ -165,8 +165,11 @@ fn color_slider_1d(ui: &mut Ui, value: &mut f32, color_at: impl Fn(f32) -> Color
|
||||
/// * `x_value` - X axis, either saturation or value (0.0-1.0).
|
||||
/// * `y_value` - Y axis, either saturation or value (0.0-1.0).
|
||||
/// * `color_at` - A function that dictates how the mix of saturation and value will be displayed in the 2d slider.
|
||||
/// E.g.: `|x_value, y_value| HsvaGamma { h: 1.0, s: x_value, v: y_value, a: 1.0 }.into()` displays the colors as follows: top-left: white \[s: 0.0, v: 1.0], top-right: fully saturated color \[s: 1.0, v: 1.0], bottom-right: black \[s: 0.0, v: 1.0].
|
||||
///
|
||||
/// e.g.: `|x_value, y_value| HsvaGamma { h: 1.0, s: x_value, v: y_value, a: 1.0 }.into()` displays the colors as follows:
|
||||
/// * top-left: white `[s: 0.0, v: 1.0]`
|
||||
/// * top-right: fully saturated color `[s: 1.0, v: 1.0]`
|
||||
/// * bottom-right: black `[s: 0.0, v: 1.0].`
|
||||
fn color_slider_2d(
|
||||
ui: &mut Ui,
|
||||
x_value: &mut f32,
|
||||
|
||||
@@ -89,6 +89,7 @@ impl TextEditState {
|
||||
self.undoer.lock().clone()
|
||||
}
|
||||
|
||||
#[allow(clippy::needless_pass_by_ref_mut)] // Intentionally hide interiority of mutability
|
||||
pub fn set_undoer(&mut self, undoer: TextEditUndoer) {
|
||||
*self.undoer.lock() = undoer;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ impl FrameHistory {
|
||||
1.0 / self.frame_times.mean_time_interval().unwrap_or_default()
|
||||
}
|
||||
|
||||
pub fn ui(&mut self, ui: &mut egui::Ui) {
|
||||
pub fn ui(&self, ui: &mut egui::Ui) {
|
||||
ui.label(format!(
|
||||
"Mean CPU usage: {:.2} ms / frame",
|
||||
1e3 * self.mean_frame_time()
|
||||
|
||||
@@ -1227,7 +1227,7 @@ impl<'a> TableBody<'a> {
|
||||
|
||||
// Capture the hover information for the just created row. This is used in the next render
|
||||
// to ensure that the entire row is highlighted.
|
||||
fn capture_hover_state(&mut self, response: &Option<Response>, row_index: usize) {
|
||||
fn capture_hover_state(&self, response: &Option<Response>, row_index: usize) {
|
||||
let is_row_hovered = response.as_ref().map_or(false, |r| r.hovered());
|
||||
if is_row_hovered {
|
||||
self.layout
|
||||
|
||||
@@ -60,7 +60,7 @@ impl TestRenderer {
|
||||
}
|
||||
|
||||
/// Render the [`Harness`] and return the resulting image.
|
||||
pub fn render<State>(&mut self, harness: &Harness<'_, State>) -> RgbaImage {
|
||||
pub fn render<State>(&self, harness: &Harness<'_, State>) -> RgbaImage {
|
||||
// We need to create a new renderer each time we render, since the renderer stores
|
||||
// textures related to the Harnesses' egui Context.
|
||||
// Calling the renderer from different Harnesses would cause problems if we store the renderer.
|
||||
|
||||
@@ -207,17 +207,21 @@ impl CubicBezierShape {
|
||||
/// B.x = (P3.x - 3 * P2.x + 3 * P1.x - P0.x) * t^3 + (3 * P2.x - 6 * P1.x + 3 * P0.x) * t^2 + (3 * P1.x - 3 * P0.x) * t + P0.x
|
||||
/// B.y = (P3.y - 3 * P2.y + 3 * P1.y - P0.y) * t^3 + (3 * P2.y - 6 * P1.y + 3 * P0.y) * t^2 + (3 * P1.y - 3 * P0.y) * t + P0.y
|
||||
/// Combine the above three equations and iliminate B.x and B.y, we get:
|
||||
/// ```text
|
||||
/// t^3 * ( (P3.x - 3*P2.x + 3*P1.x - P0.x) * (P3.y - P0.y) - (P3.y - 3*P2.y + 3*P1.y - P0.y) * (P3.x - P0.x))
|
||||
/// + t^2 * ( (3 * P2.x - 6 * P1.x + 3 * P0.x) * (P3.y - P0.y) - (3 * P2.y - 6 * P1.y + 3 * P0.y) * (P3.x - P0.x))
|
||||
/// + t^1 * ( (3 * P1.x - 3 * P0.x) * (P3.y - P0.y) - (3 * P1.y - 3 * P0.y) * (P3.x - P0.x))
|
||||
/// + (P0.x * (P3.y - P0.y) - P0.y * (P3.x - P0.x)) + P0.x * (P0.y - P3.y) + P0.y * (P3.x - P0.x)
|
||||
/// = 0
|
||||
/// or a * t^3 + b * t^2 + c * t + d = 0
|
||||
/// ```
|
||||
/// or `a * t^3 + b * t^2 + c * t + d = 0`
|
||||
///
|
||||
/// let x = t - b / (3 * a), then we have:
|
||||
/// ```text
|
||||
/// x^3 + p * x + q = 0, where:
|
||||
/// p = (3.0 * a * c - b^2) / (3.0 * a^2)
|
||||
/// q = (2.0 * b^3 - 9.0 * a * b * c + 27.0 * a^2 * d) / (27.0 * a^3)
|
||||
/// ```
|
||||
///
|
||||
/// when p > 0, there will be one real root, two complex roots
|
||||
/// when p = 0, there will be two real roots, when p=q=0, there will be three real roots but all 0.
|
||||
|
||||
@@ -66,6 +66,7 @@ impl TextureHandle {
|
||||
}
|
||||
|
||||
/// Assign a new image to an existing texture.
|
||||
#[allow(clippy::needless_pass_by_ref_mut)] // Intentionally hide interiority of mutability
|
||||
pub fn set(&mut self, image: impl Into<ImageData>, options: TextureOptions) {
|
||||
self.tex_mngr
|
||||
.write()
|
||||
@@ -73,6 +74,7 @@ impl TextureHandle {
|
||||
}
|
||||
|
||||
/// Assign a new image to a subregion of the whole texture.
|
||||
#[allow(clippy::needless_pass_by_ref_mut)] // Intentionally hide interiority of mutability
|
||||
pub fn set_partial(
|
||||
&mut self,
|
||||
pos: [usize; 2],
|
||||
|
||||
Reference in New Issue
Block a user