misc code cleanup

This commit is contained in:
Emil Ernerfeldt 2022-07-29 16:07:26 +02:00
parent b0fa0c65cc
commit 4e8a6e3370
6 changed files with 28 additions and 12 deletions

View file

@ -106,6 +106,7 @@ impl Placer {
/// This is what you then pass to `advance_after_rects`.
/// Use `justify_and_align` to get the inner `widget_rect`.
pub(crate) fn next_space(&self, child_size: Vec2, item_spacing: Vec2) -> Rect {
egui_assert!(child_size.is_finite() && child_size.x >= 0.0 && child_size.y >= 0.0);
self.region.sanity_check();
if let Some(grid) = &self.grid {
grid.next_cell(self.region.cursor, child_size)

View file

@ -142,13 +142,6 @@ impl BackendPanel {
if ui.button("Quit").clicked() {
frame.quit();
}
if ui
.button("Drag me to drag window")
.is_pointer_button_down_on()
{
frame.drag_window();
}
}
}
@ -191,9 +184,18 @@ impl BackendPanel {
{
// frame.set_window_size(egui::vec2(375.0, 812.0)); // iPhone 12 mini
frame.set_window_size(egui::vec2(375.0, 667.0)); // iPhone SE 2nd gen
frame.set_fullscreen(false);
ui.close_menu();
}
});
if !frame.info().window_info.fullscreen
&& ui
.button("Drag me to drag window")
.is_pointer_button_down_on()
{
frame.drag_window();
}
}
}

View file

@ -99,6 +99,16 @@ impl RetainedImage {
self.size
}
/// The width of the image.
pub fn width(&self) -> usize {
self.size[0]
}
/// The height of the image.
pub fn height(&self) -> usize {
self.size[1]
}
/// The size of the image data (number of pixels wide/high).
pub fn size_vec2(&self) -> egui::Vec2 {
let [w, h] = self.size();

View file

@ -468,6 +468,8 @@ impl Painter {
}
check_for_gl_error!(&self.gl, "paint_mesh");
} else {
tracing::warn!("Failed to find texture {:?}", mesh.texture_id);
}
}

View file

@ -1058,10 +1058,11 @@ impl Tessellator {
None => true,
Some(output_clipped_primitive) => {
output_clipped_primitive.clip_rect != new_clip_rect
|| if let Primitive::Mesh(output_mesh) = &output_clipped_primitive.primitive {
|| match &output_clipped_primitive.primitive {
Primitive::Mesh(output_mesh) => {
output_mesh.texture_id != new_shape.texture_id()
} else {
true
}
Primitive::Callback(_) => true,
}
}
};

View file

@ -62,8 +62,8 @@ cargo deny check
# Also try https://github.com/google/bloaty
# what compiles slowly?
# cargo clean && time cargo build -p eframe --timings
# https://fasterthanli.me/articles/why-is-my-rust-build-so-slow
# (cd egui_demo_app && cargo clean && RUSTC_BOOTSTRAP=1 cargo build --release --quiet -Z timings)
# what compiles slowly?
# cargo llvm-lines --lib -p egui | head -20