Enable and fix some more clippy lints (#7426)
One can never have too many lints
This commit is contained in:
parent
e8e99a0bb6
commit
3024c39eaf
16
Cargo.toml
16
Cargo.toml
|
|
@ -159,8 +159,8 @@ disallowed_types = "warn" # See clippy.toml
|
||||||
doc_link_with_quotes = "warn"
|
doc_link_with_quotes = "warn"
|
||||||
doc_markdown = "warn"
|
doc_markdown = "warn"
|
||||||
empty_enum = "warn"
|
empty_enum = "warn"
|
||||||
empty_line_after_outer_attr = "warn"
|
|
||||||
empty_enum_variants_with_brackets = "warn"
|
empty_enum_variants_with_brackets = "warn"
|
||||||
|
empty_line_after_outer_attr = "warn"
|
||||||
enum_glob_use = "warn"
|
enum_glob_use = "warn"
|
||||||
equatable_if_let = "warn"
|
equatable_if_let = "warn"
|
||||||
exit = "warn"
|
exit = "warn"
|
||||||
|
|
@ -180,6 +180,7 @@ if_let_mutex = "warn"
|
||||||
implicit_clone = "warn"
|
implicit_clone = "warn"
|
||||||
implied_bounds_in_impls = "warn"
|
implied_bounds_in_impls = "warn"
|
||||||
imprecise_flops = "warn"
|
imprecise_flops = "warn"
|
||||||
|
inconsistent_struct_constructor = "warn"
|
||||||
index_refutable_slice = "warn"
|
index_refutable_slice = "warn"
|
||||||
inefficient_to_string = "warn"
|
inefficient_to_string = "warn"
|
||||||
infinite_loop = "warn"
|
infinite_loop = "warn"
|
||||||
|
|
@ -295,8 +296,21 @@ verbose_file_reads = "warn"
|
||||||
wildcard_dependencies = "warn"
|
wildcard_dependencies = "warn"
|
||||||
zero_sized_map_values = "warn"
|
zero_sized_map_values = "warn"
|
||||||
|
|
||||||
|
# Enable these when we update MSRV:
|
||||||
|
# doc_comment_double_space_linebreaks = "warn"
|
||||||
|
# elidable_lifetime_names = "warn"
|
||||||
|
# ignore_without_reason = "warn"
|
||||||
|
# manual_midpoint = "warn"
|
||||||
|
# non_std_lazy_statics = "warn"
|
||||||
|
# precedence_bits = "warn"
|
||||||
|
# return_and_then = "warn"
|
||||||
|
# single_option_map = "warn"
|
||||||
|
# unnecessary_debug_formatting = "warn"
|
||||||
|
# unnecessary_semicolon = "warn"
|
||||||
|
|
||||||
|
|
||||||
# TODO(emilk): maybe enable more of these lints?
|
# TODO(emilk): maybe enable more of these lints?
|
||||||
|
comparison_chain = "allow"
|
||||||
should_panic_without_expect = "allow"
|
should_panic_without_expect = "allow"
|
||||||
too_many_lines = "allow"
|
too_many_lines = "allow"
|
||||||
unwrap_used = "allow" # TODO(emilk): We really wanna warn on this one
|
unwrap_used = "allow" # TODO(emilk): We really wanna warn on this one
|
||||||
|
|
|
||||||
|
|
@ -234,7 +234,7 @@ pub fn rgb_from_hsv((h, s, v): (f32, f32, f32)) -> [f32; 3] {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore] // a bit expensive
|
#[ignore = "too expensive"]
|
||||||
fn test_hsv_roundtrip() {
|
fn test_hsv_roundtrip() {
|
||||||
for r in 0..=255 {
|
for r in 0..=255 {
|
||||||
for g in 0..=255 {
|
for g in 0..=255 {
|
||||||
|
|
|
||||||
|
|
@ -893,16 +893,15 @@ pub trait Storage {
|
||||||
#[cfg(feature = "ron")]
|
#[cfg(feature = "ron")]
|
||||||
pub fn get_value<T: serde::de::DeserializeOwned>(storage: &dyn Storage, key: &str) -> Option<T> {
|
pub fn get_value<T: serde::de::DeserializeOwned>(storage: &dyn Storage, key: &str) -> Option<T> {
|
||||||
profiling::function_scope!(key);
|
profiling::function_scope!(key);
|
||||||
storage
|
let value = storage.get_string(key)?;
|
||||||
.get_string(key)
|
match ron::from_str(&value) {
|
||||||
.and_then(|value| match ron::from_str(&value) {
|
Ok(value) => Some(value),
|
||||||
Ok(value) => Some(value),
|
Err(err) => {
|
||||||
Err(err) => {
|
// This happens on when we break the format, e.g. when updating egui.
|
||||||
// This happens on when we break the format, e.g. when updating egui.
|
log::debug!("Failed to decode RON: {err}");
|
||||||
log::debug!("Failed to decode RON: {err}");
|
None
|
||||||
None
|
}
|
||||||
}
|
}
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Serialize the given value as [RON](https://github.com/ron-rs/ron) and store with the given key.
|
/// Serialize the given value as [RON](https://github.com/ron-rs/ron) and store with the given key.
|
||||||
|
|
|
||||||
|
|
@ -336,10 +336,10 @@ impl<'app> GlowWinitApp<'app> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(self.running.insert(GlowWinitRunning {
|
Ok(self.running.insert(GlowWinitRunning {
|
||||||
glutin,
|
|
||||||
painter,
|
|
||||||
integration,
|
integration,
|
||||||
app,
|
app,
|
||||||
|
glutin,
|
||||||
|
painter,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -362,8 +362,12 @@ impl WinitApp for GlowWinitApp<'_> {
|
||||||
|
|
||||||
fn window_id_from_viewport_id(&self, id: ViewportId) -> Option<WindowId> {
|
fn window_id_from_viewport_id(&self, id: ViewportId) -> Option<WindowId> {
|
||||||
self.running
|
self.running
|
||||||
.as_ref()
|
.as_ref()?
|
||||||
.and_then(|r| r.glutin.borrow().window_from_viewport.get(&id).copied())
|
.glutin
|
||||||
|
.borrow()
|
||||||
|
.window_from_viewport
|
||||||
|
.get(&id)
|
||||||
|
.copied()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn save(&mut self) {
|
fn save(&mut self) {
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,7 @@ impl<T: WinitApp> WinitAppWrapper<T> {
|
||||||
log::error!("Exiting because of error: {err}");
|
log::error!("Exiting because of error: {err}");
|
||||||
exit = true;
|
exit = true;
|
||||||
self.return_result = Err(err);
|
self.return_result = Err(err);
|
||||||
};
|
}
|
||||||
|
|
||||||
if save {
|
if save {
|
||||||
log::debug!("Received an EventResult::Save - saving app state");
|
log::debug!("Received an EventResult::Save - saving app state");
|
||||||
|
|
@ -176,7 +176,7 @@ impl<T: WinitApp> WinitAppWrapper<T> {
|
||||||
.retain(|window_id, repaint_time| {
|
.retain(|window_id, repaint_time| {
|
||||||
if now < *repaint_time {
|
if now < *repaint_time {
|
||||||
return true; // not yet ready
|
return true; // not yet ready
|
||||||
};
|
}
|
||||||
|
|
||||||
event_loop.set_control_flow(ControlFlow::Poll);
|
event_loop.set_control_flow(ControlFlow::Poll);
|
||||||
|
|
||||||
|
|
@ -192,7 +192,7 @@ impl<T: WinitApp> WinitAppWrapper<T> {
|
||||||
let next_repaint_time = self.windows_next_repaint_times.values().min().copied();
|
let next_repaint_time = self.windows_next_repaint_times.values().min().copied();
|
||||||
if let Some(next_repaint_time) = next_repaint_time {
|
if let Some(next_repaint_time) = next_repaint_time {
|
||||||
event_loop.set_control_flow(ControlFlow::WaitUntil(next_repaint_time));
|
event_loop.set_control_flow(ControlFlow::WaitUntil(next_repaint_time));
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -333,10 +333,8 @@ impl WinitApp for WgpuWinitApp<'_> {
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|r| {
|
.and_then(|r| {
|
||||||
let shared = r.shared.borrow();
|
let shared = r.shared.borrow();
|
||||||
shared
|
let id = shared.viewport_from_window.get(&window_id)?;
|
||||||
.viewport_from_window
|
shared.viewports.get(id).map(|v| v.window.clone())
|
||||||
.get(&window_id)
|
|
||||||
.and_then(|id| shared.viewports.get(id).map(|v| v.window.clone()))
|
|
||||||
})
|
})
|
||||||
.flatten()
|
.flatten()
|
||||||
}
|
}
|
||||||
|
|
@ -821,17 +819,16 @@ impl WgpuWinitRunning<'_> {
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => {}
|
_ => {}
|
||||||
};
|
}
|
||||||
|
|
||||||
let event_response = viewport_id
|
let event_response = viewport_id
|
||||||
.and_then(|viewport_id| {
|
.and_then(|viewport_id| {
|
||||||
shared.viewports.get_mut(&viewport_id).and_then(|viewport| {
|
let viewport = shared.viewports.get_mut(&viewport_id)?;
|
||||||
Some(integration.on_window_event(
|
Some(integration.on_window_event(
|
||||||
viewport.window.as_deref()?,
|
viewport.window.as_deref()?,
|
||||||
viewport.egui_winit.as_mut()?,
|
viewport.egui_winit.as_mut()?,
|
||||||
event,
|
event,
|
||||||
))
|
))
|
||||||
})
|
|
||||||
})
|
})
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -873,7 +873,7 @@ impl Renderer {
|
||||||
callbacks.push(c.0.as_ref());
|
callbacks.push(c.0.as_ref());
|
||||||
} else {
|
} else {
|
||||||
log::warn!("Unknown paint callback: expected `egui_wgpu::Callback`");
|
log::warn!("Unknown paint callback: expected `egui_wgpu::Callback`");
|
||||||
};
|
}
|
||||||
acc
|
acc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -328,7 +328,7 @@ impl Painter {
|
||||||
})
|
})
|
||||||
.create_view(&wgpu::TextureViewDescriptor::default()),
|
.create_view(&wgpu::TextureViewDescriptor::default()),
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn on_window_resized(
|
pub fn on_window_resized(
|
||||||
|
|
|
||||||
|
|
@ -372,7 +372,7 @@ impl State {
|
||||||
winit::event::Ime::Disabled | winit::event::Ime::Preedit(_, None) => {
|
winit::event::Ime::Disabled | winit::event::Ime::Preedit(_, None) => {
|
||||||
self.ime_event_disable();
|
self.ime_event_disable();
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
EventResponse {
|
EventResponse {
|
||||||
repaint: true,
|
repaint: true,
|
||||||
|
|
@ -583,7 +583,7 @@ impl State {
|
||||||
pos,
|
pos,
|
||||||
force: None,
|
force: None,
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -458,7 +458,7 @@ impl<'a> Popup<'a> {
|
||||||
|
|
||||||
/// Get the expected size of the popup.
|
/// Get the expected size of the popup.
|
||||||
pub fn get_expected_size(&self) -> Option<Vec2> {
|
pub fn get_expected_size(&self) -> Option<Vec2> {
|
||||||
AreaState::load(&self.ctx, self.id).and_then(|area| area.size)
|
AreaState::load(&self.ctx, self.id)?.size
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Calculate the best alignment for the popup, based on the last size and screen rect.
|
/// Calculate the best alignment for the popup, based on the last size and screen rect.
|
||||||
|
|
|
||||||
|
|
@ -1059,7 +1059,7 @@ impl Prepared {
|
||||||
|
|
||||||
delta += delta_update;
|
delta += delta_update;
|
||||||
animation = animation_update;
|
animation = animation_update;
|
||||||
};
|
}
|
||||||
|
|
||||||
if delta != 0.0 {
|
if delta != 0.0 {
|
||||||
let target_offset = state.offset[d] + delta;
|
let target_offset = state.offset[d] + delta;
|
||||||
|
|
@ -1090,7 +1090,7 @@ impl Prepared {
|
||||||
for d in 0..2 {
|
for d in 0..2 {
|
||||||
if saved_scroll_target[d].is_some() {
|
if saved_scroll_target[d].is_some() {
|
||||||
state.scroll_target[d] = saved_scroll_target[d].clone();
|
state.scroll_target[d] = saved_scroll_target[d].clone();
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -616,7 +616,7 @@ impl Window<'_> {
|
||||||
*where_to_put_header_background,
|
*where_to_put_header_background,
|
||||||
RectShape::filled(title_bar.inner_rect, round, header_color),
|
RectShape::filled(title_bar.inner_rect, round, header_color),
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
|
||||||
if false {
|
if false {
|
||||||
ctx.debug_painter().debug_rect(
|
ctx.debug_painter().debug_rect(
|
||||||
|
|
|
||||||
|
|
@ -1259,7 +1259,7 @@ impl Context {
|
||||||
viewport.this_pass.scroll_delta.0 += DISTANCE * Vec2::RIGHT;
|
viewport.this_pass.scroll_delta.0 += DISTANCE * Vec2::RIGHT;
|
||||||
}
|
}
|
||||||
_ => return false,
|
_ => return false,
|
||||||
};
|
}
|
||||||
true
|
true
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -729,7 +729,7 @@ impl WidgetInfo {
|
||||||
description = format!("{state} {description}");
|
description = format!("{state} {description}");
|
||||||
} else {
|
} else {
|
||||||
description += if *selected { "selected" } else { "" };
|
description += if *selected { "selected" } else { "" };
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(label) = label {
|
if let Some(label) = label {
|
||||||
|
|
|
||||||
|
|
@ -293,7 +293,7 @@ pub(crate) fn interact(
|
||||||
drag_started,
|
drag_started,
|
||||||
dragged,
|
dragged,
|
||||||
drag_stopped,
|
drag_stopped,
|
||||||
contains_pointer,
|
|
||||||
hovered,
|
hovered,
|
||||||
|
contains_pointer,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -753,7 +753,7 @@ impl Layout {
|
||||||
pos2(frame_rect.max.x, f32::NAN),
|
pos2(frame_rect.max.x, f32::NAN),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Make sure we also expand where we consider adding things (the cursor):
|
// Make sure we also expand where we consider adding things (the cursor):
|
||||||
|
|
@ -779,7 +779,7 @@ impl Layout {
|
||||||
Direction::BottomUp => {
|
Direction::BottomUp => {
|
||||||
cursor.max.y = widget_rect.min.y - item_spacing.y;
|
cursor.max.y = widget_rect.min.y - item_spacing.y;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Move to the next row in a wrapping layout.
|
/// Move to the next row in a wrapping layout.
|
||||||
|
|
|
||||||
|
|
@ -802,15 +802,12 @@ impl Memory {
|
||||||
|
|
||||||
/// Top-most layer at the given position.
|
/// Top-most layer at the given position.
|
||||||
pub fn layer_id_at(&self, pos: Pos2) -> Option<LayerId> {
|
pub fn layer_id_at(&self, pos: Pos2) -> Option<LayerId> {
|
||||||
self.areas()
|
let layer_id = self.areas().layer_id_at(pos, &self.to_global)?;
|
||||||
.layer_id_at(pos, &self.to_global)
|
if self.is_above_modal_layer(layer_id) {
|
||||||
.and_then(|layer_id| {
|
Some(layer_id)
|
||||||
if self.is_above_modal_layer(layer_id) {
|
} else {
|
||||||
Some(layer_id)
|
self.top_modal_layer()
|
||||||
} else {
|
}
|
||||||
self.top_modal_layer()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The currently set transform of a layer.
|
/// The currently set transform of a layer.
|
||||||
|
|
@ -855,7 +852,7 @@ impl Memory {
|
||||||
|
|
||||||
/// Which widget has keyboard focus?
|
/// Which widget has keyboard focus?
|
||||||
pub fn focused(&self) -> Option<Id> {
|
pub fn focused(&self) -> Option<Id> {
|
||||||
self.focus().and_then(|f| f.focused())
|
self.focus()?.focused()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set an event filter for a widget.
|
/// Set an event filter for a widget.
|
||||||
|
|
@ -1066,9 +1063,8 @@ impl Memory {
|
||||||
/// Get the position for this popup.
|
/// Get the position for this popup.
|
||||||
#[deprecated = "Use Popup::position_of_id instead"]
|
#[deprecated = "Use Popup::position_of_id instead"]
|
||||||
pub fn popup_position(&self, id: Id) -> Option<Pos2> {
|
pub fn popup_position(&self, id: Id) -> Option<Pos2> {
|
||||||
self.popups
|
let state = self.popups.get(&self.viewport_id)?;
|
||||||
.get(&self.viewport_id)
|
if state.id == id { state.pos } else { None }
|
||||||
.and_then(|state| if state.id == id { state.pos } else { None })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Close any currently open popup.
|
/// Close any currently open popup.
|
||||||
|
|
|
||||||
|
|
@ -766,9 +766,8 @@ impl MenuState {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn submenu(&self, id: Id) -> Option<&Arc<RwLock<Self>>> {
|
fn submenu(&self, id: Id) -> Option<&Arc<RwLock<Self>>> {
|
||||||
self.sub_menu
|
let (k, sub) = self.sub_menu.as_ref()?;
|
||||||
.as_ref()
|
if id == *k { Some(sub) } else { None }
|
||||||
.and_then(|(k, sub)| if id == *k { Some(sub) } else { None })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Open submenu at position, if not already open.
|
/// Open submenu at position, if not already open.
|
||||||
|
|
|
||||||
|
|
@ -2136,7 +2136,7 @@ impl Visuals {
|
||||||
ui.color_edit_button_srgba(color);
|
ui.color_edit_button_srgba(color);
|
||||||
} else {
|
} else {
|
||||||
*color = None;
|
*color = None;
|
||||||
};
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ui.end_row();
|
ui.end_row();
|
||||||
|
|
|
||||||
|
|
@ -325,7 +325,7 @@ impl<'a> Button<'a> {
|
||||||
.fill(fill)
|
.fill(fill)
|
||||||
.stroke(stroke)
|
.stroke(stroke)
|
||||||
.corner_radius(corner_radius.unwrap_or(visuals.corner_radius));
|
.corner_radius(corner_radius.unwrap_or(visuals.corner_radius));
|
||||||
};
|
}
|
||||||
|
|
||||||
prepared.paint(ui)
|
prepared.paint(ui)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -250,7 +250,7 @@ impl Label {
|
||||||
} else {
|
} else {
|
||||||
layout_job.halign = self.halign.unwrap_or(ui.layout().horizontal_placement());
|
layout_job.halign = self.halign.unwrap_or(ui.layout().horizontal_placement());
|
||||||
layout_job.justify = ui.layout().horizontal_justify();
|
layout_job.justify = ui.layout().horizontal_justify();
|
||||||
};
|
}
|
||||||
|
|
||||||
let galley = ui.fonts(|fonts| fonts.layout_job(layout_job));
|
let galley = ui.fonts(|fonts| fonts.layout_job(layout_job));
|
||||||
let (rect, mut response) = ui.allocate_exact_size(galley.size(), sense);
|
let (rect, mut response) = ui.allocate_exact_size(galley.size(), sense);
|
||||||
|
|
|
||||||
|
|
@ -806,7 +806,7 @@ impl Slider<'_> {
|
||||||
SliderOrientation::Vertical => {
|
SliderOrientation::Vertical => {
|
||||||
trailing_rail_rect.min.y = center.y - corner_radius.se as f32;
|
trailing_rail_rect.min.y = center.y - corner_radius.se as f32;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
ui.painter().rect_filled(
|
ui.painter().rect_filled(
|
||||||
trailing_rail_rect,
|
trailing_rail_rect,
|
||||||
|
|
@ -936,7 +936,7 @@ impl Slider<'_> {
|
||||||
|
|
||||||
if let Some(fmt) = &self.custom_formatter {
|
if let Some(fmt) = &self.custom_formatter {
|
||||||
dv = dv.custom_formatter(fmt);
|
dv = dv.custom_formatter(fmt);
|
||||||
};
|
}
|
||||||
if let Some(parser) = &self.custom_parser {
|
if let Some(parser) = &self.custom_parser {
|
||||||
dv = dv.custom_parser(parser);
|
dv = dv.custom_parser(parser);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ impl FractalClock {
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
ui.label("The fractal_clock clock is not showing the correct time");
|
ui.label("The fractal_clock clock is not showing the correct time");
|
||||||
};
|
}
|
||||||
ui.label(format!("Painted line count: {}", self.line_count));
|
ui.label(format!("Painted line count: {}", self.line_count));
|
||||||
|
|
||||||
ui.checkbox(&mut self.paused, "Paused");
|
ui.checkbox(&mut self.paused, "Paused");
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ impl eframe::App for ImageViewer {
|
||||||
ctx.forget_image(&self.current_uri);
|
ctx.forget_image(&self.current_uri);
|
||||||
self.uri_edit_text = self.uri_edit_text.trim().to_owned();
|
self.uri_edit_text = self.uri_edit_text.trim().to_owned();
|
||||||
self.current_uri = self.uri_edit_text.clone();
|
self.current_uri = self.uri_edit_text.clone();
|
||||||
};
|
}
|
||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
if ui.button("file…").clicked() {
|
if ui.button("file…").clicked() {
|
||||||
|
|
|
||||||
|
|
@ -91,5 +91,5 @@ fn start_puffin_server() {
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
log::error!("Failed to start puffin server: {err}");
|
log::error!("Failed to start puffin server: {err}");
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -805,7 +805,7 @@ impl TextRotation {
|
||||||
if let egui::epaint::Shape::Text(ts) = &mut t {
|
if let egui::epaint::Shape::Text(ts) = &mut t {
|
||||||
let new = ts.clone().with_angle_and_anchor(self.angle, self.align);
|
let new = ts.clone().with_angle_and_anchor(self.angle, self.align);
|
||||||
*ts = new;
|
*ts = new;
|
||||||
};
|
}
|
||||||
|
|
||||||
t
|
t
|
||||||
});
|
});
|
||||||
|
|
@ -814,7 +814,7 @@ impl TextRotation {
|
||||||
let align_pt =
|
let align_pt =
|
||||||
rect.min + start_pos + self.align.pos_in_rect(&ts.galley.rect).to_vec2();
|
rect.min + start_pos + self.align.pos_in_rect(&ts.galley.rect).to_vec2();
|
||||||
painter.circle(align_pt, 2.0, Color32::RED, (0.0, Color32::RED));
|
painter.circle(align_pt, 2.0, Color32::RED, (0.0, Color32::RED));
|
||||||
};
|
}
|
||||||
|
|
||||||
painter.rect(
|
painter.rect(
|
||||||
rect,
|
rect,
|
||||||
|
|
|
||||||
|
|
@ -152,7 +152,7 @@ impl PaintBezier {
|
||||||
_ => {
|
_ => {
|
||||||
unreachable!();
|
unreachable!();
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
painter.add(PathShape::line(points_in_screen, self.aux_stroke));
|
painter.add(PathShape::line(points_in_screen, self.aux_stroke));
|
||||||
painter.extend(control_point_shapes);
|
painter.extend(control_point_shapes);
|
||||||
|
|
|
||||||
|
|
@ -165,7 +165,7 @@ fn shortcuts(ui: &Ui, code: &mut dyn TextBuffer, ccursor_range: &mut CCursorRang
|
||||||
if ui.input_mut(|i| i.consume_shortcut(&shortcut)) {
|
if ui.input_mut(|i| i.consume_shortcut(&shortcut)) {
|
||||||
any_change = true;
|
any_change = true;
|
||||||
toggle_surrounding(code, ccursor_range, surrounding);
|
toggle_surrounding(code, ccursor_range, surrounding);
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
any_change
|
any_change
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ pub fn item_ui(ui: &mut Ui, item: easy_mark::Item<'_>) {
|
||||||
Shape::rect_filled(rect, 1.0, code_bg_color),
|
Shape::rect_filled(rect, 1.0, code_bg_color),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rich_text_from_style(text: &str, style: &easy_mark::Style) -> RichText {
|
fn rich_text_from_style(text: &str, style: &easy_mark::Style) -> RichText {
|
||||||
|
|
|
||||||
|
|
@ -336,7 +336,7 @@ impl DatePickerPopup<'_> {
|
||||||
if day.month() != popup_state.month {
|
if day.month() != popup_state.month {
|
||||||
text_color =
|
text_color =
|
||||||
text_color.linear_multiply(0.5);
|
text_color.linear_multiply(0.5);
|
||||||
};
|
}
|
||||||
|
|
||||||
let button_response = ui.add(
|
let button_response = ui.add(
|
||||||
Button::new(
|
Button::new(
|
||||||
|
|
|
||||||
|
|
@ -528,7 +528,7 @@ impl Painter {
|
||||||
|
|
||||||
self.upload_texture_srgb(delta.pos, image.size, delta.options, data);
|
self.upload_texture_srgb(delta.pos, image.size, delta.options, data);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn upload_texture_srgb(
|
fn upload_texture_srgb(
|
||||||
|
|
|
||||||
|
|
@ -232,7 +232,8 @@ impl Display for SnapshotError {
|
||||||
let diff_path = std::path::absolute(diff_path).unwrap_or(diff_path.clone());
|
let diff_path = std::path::absolute(diff_path).unwrap_or(diff_path.clone());
|
||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"'{name}' Image did not match snapshot. Diff: {diff}, {diff_path:?}. {HOW_TO_UPDATE_SCREENSHOTS}"
|
"'{name}' Image did not match snapshot. Diff: {diff}, {}. {HOW_TO_UPDATE_SCREENSHOTS}",
|
||||||
|
diff_path.display()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Self::OpenSnapshot { path, err } => {
|
Self::OpenSnapshot { path, err } => {
|
||||||
|
|
@ -240,19 +241,25 @@ impl Display for SnapshotError {
|
||||||
match err {
|
match err {
|
||||||
ImageError::IoError(io) => match io.kind() {
|
ImageError::IoError(io) => match io.kind() {
|
||||||
ErrorKind::NotFound => {
|
ErrorKind::NotFound => {
|
||||||
write!(f, "Missing snapshot: {path:?}. {HOW_TO_UPDATE_SCREENSHOTS}")
|
write!(
|
||||||
|
f,
|
||||||
|
"Missing snapshot: {}. {HOW_TO_UPDATE_SCREENSHOTS}",
|
||||||
|
path.display()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
err => {
|
err => {
|
||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"Error reading snapshot: {err:?}\nAt: {path:?}. {HOW_TO_UPDATE_SCREENSHOTS}"
|
"Error reading snapshot: {err:?}\nAt: {}. {HOW_TO_UPDATE_SCREENSHOTS}",
|
||||||
|
path.display()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
err => {
|
err => {
|
||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"Error decoding snapshot: {err:?}\nAt: {path:?}. Make sure git-lfs is setup correctly. Read the instructions here: https://github.com/emilk/egui/blob/main/CONTRIBUTING.md#making-a-pr"
|
"Error decoding snapshot: {err:?}\nAt: {}. Make sure git-lfs is setup correctly. Read the instructions here: https://github.com/emilk/egui/blob/main/CONTRIBUTING.md#making-a-pr",
|
||||||
|
path.display()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -269,7 +276,7 @@ impl Display for SnapshotError {
|
||||||
}
|
}
|
||||||
Self::WriteSnapshot { path, err } => {
|
Self::WriteSnapshot { path, err } => {
|
||||||
let path = std::path::absolute(path).unwrap_or(path.clone());
|
let path = std::path::absolute(path).unwrap_or(path.clone());
|
||||||
write!(f, "Error writing snapshot: {err:?}\nAt: {path:?}")
|
write!(f, "Error writing snapshot: {err:?}\nAt: {}", path.display())
|
||||||
}
|
}
|
||||||
Self::RenderError { err } => {
|
Self::RenderError { err } => {
|
||||||
write!(f, "Error rendering image: {err:?}")
|
write!(f, "Error rendering image: {err:?}")
|
||||||
|
|
@ -363,7 +370,7 @@ fn try_image_snapshot_options_impl(
|
||||||
// No need for an explicit `.new` file:
|
// No need for an explicit `.new` file:
|
||||||
std::fs::remove_file(&new_path).ok();
|
std::fs::remove_file(&new_path).ok();
|
||||||
|
|
||||||
println!("Updated snapshot: {snapshot_path:?}");
|
println!("Updated snapshot: {}", snapshot_path.display());
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ impl TestMenu {
|
||||||
.clicked()
|
.clicked()
|
||||||
{
|
{
|
||||||
ui.close();
|
ui.close();
|
||||||
};
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ fn test_scroll_harness() -> Harness<'static, bool> {
|
||||||
}
|
}
|
||||||
if ui.button("Hidden Button").clicked() {
|
if ui.button("Hidden Button").clicked() {
|
||||||
*state = true;
|
*state = true;
|
||||||
};
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ impl Align {
|
||||||
if size == f32::INFINITY {
|
if size == f32::INFINITY {
|
||||||
Rangef::new(f32::NEG_INFINITY, f32::INFINITY)
|
Rangef::new(f32::NEG_INFINITY, f32::INFINITY)
|
||||||
} else {
|
} else {
|
||||||
let left = (min + max) / 2.0 - size / 2.0;
|
let left = f32::midpoint(min, max) - size / 2.0;
|
||||||
Rangef::new(left, left + size)
|
Rangef::new(left, left + size)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -331,8 +331,8 @@ impl Rect {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn center(&self) -> Pos2 {
|
pub fn center(&self) -> Pos2 {
|
||||||
Pos2 {
|
Pos2 {
|
||||||
x: (self.min.x + self.max.x) / 2.0,
|
x: f32::midpoint(self.min.x, self.max.x),
|
||||||
y: (self.min.y + self.max.y) / 2.0,
|
y: f32::midpoint(self.min.y, self.max.y),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ pub fn best_in_range_f64(min: f64, max: f64) -> f64 {
|
||||||
|
|
||||||
if min_exponent.floor() != max_exponent.floor() {
|
if min_exponent.floor() != max_exponent.floor() {
|
||||||
// pick the geometric center of the two:
|
// pick the geometric center of the two:
|
||||||
let exponent = (min_exponent + max_exponent) / 2.0;
|
let exponent = f64::midpoint(min_exponent, max_exponent);
|
||||||
return 10.0_f64.powi(exponent.round() as i32);
|
return 10.0_f64.powi(exponent.round() as i32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,8 @@ impl TSTransform {
|
||||||
/// `(0, 0)`, then translates them.
|
/// `(0, 0)`, then translates them.
|
||||||
pub fn new(translation: Vec2, scaling: f32) -> Self {
|
pub fn new(translation: Vec2, scaling: f32) -> Self {
|
||||||
Self {
|
Self {
|
||||||
translation,
|
|
||||||
scaling,
|
scaling,
|
||||||
|
translation,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -177,5 +177,5 @@ fn start_puffin_server() {
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
log::error!("Failed to start puffin server: {err}");
|
log::error!("Failed to start puffin server: {err}");
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ impl eframe::App for MyApp {
|
||||||
ctx.set_theme(egui::Theme::Dark);
|
ctx.set_theme(egui::Theme::Dark);
|
||||||
} else {
|
} else {
|
||||||
ctx.set_theme(egui::Theme::Light);
|
ctx.set_theme(egui::Theme::Light);
|
||||||
};
|
}
|
||||||
ctx.send_viewport_cmd(
|
ctx.send_viewport_cmd(
|
||||||
egui::ViewportCommand::Screenshot(Default::default()),
|
egui::ViewportCommand::Screenshot(Default::default()),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ pub fn ask_to_run(mut cmd: Command, ask: bool, reason: &str) -> Result<(), DynEr
|
||||||
"" | "y" | "yes" => {}
|
"" | "y" | "yes" => {}
|
||||||
"n" | "no" => return Err("Aborting as per your request".into()),
|
"n" | "no" => return Err("Aborting as per your request".into()),
|
||||||
a => return Err(format!("Invalid answer `{a}`").into()),
|
a => return Err(format!("Invalid answer `{a}`").into()),
|
||||||
};
|
}
|
||||||
} else {
|
} else {
|
||||||
println!("Running `{cmd:?}` to {reason}.");
|
println!("Running `{cmd:?}` to {reason}.");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue