From a0d30759fe432d894a355c0454b710b4037b4bbd Mon Sep 17 00:00:00 2001 From: Lucas Meurer Date: Sun, 29 Dec 2024 13:41:44 +0100 Subject: [PATCH] Add `WidgetType::Image` --- crates/egui/src/data/output.rs | 1 + crates/egui/src/lib.rs | 2 ++ crates/egui/src/response.rs | 1 + crates/egui/src/widgets/image.rs | 3 ++- 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/egui/src/data/output.rs b/crates/egui/src/data/output.rs index a878bd5fd70..21e54d2cdc3 100644 --- a/crates/egui/src/data/output.rs +++ b/crates/egui/src/data/output.rs @@ -673,6 +673,7 @@ impl WidgetInfo { WidgetType::DragValue => "drag value", WidgetType::ColorButton => "color button", WidgetType::ImageButton => "image button", + WidgetType::Image => "image", WidgetType::CollapsingHeader => "collapsing header", WidgetType::ProgressIndicator => "progress indicator", WidgetType::Window => "window", diff --git a/crates/egui/src/lib.rs b/crates/egui/src/lib.rs index 1afaada95e1..d89b1c7eb2f 100644 --- a/crates/egui/src/lib.rs +++ b/crates/egui/src/lib.rs @@ -664,6 +664,8 @@ pub enum WidgetType { ColorButton, ImageButton, + + Image, CollapsingHeader, diff --git a/crates/egui/src/response.rs b/crates/egui/src/response.rs index 18ddf793cc6..c65d9ca8c71 100644 --- a/crates/egui/src/response.rs +++ b/crates/egui/src/response.rs @@ -1017,6 +1017,7 @@ impl Response { WidgetType::Button | WidgetType::ImageButton | WidgetType::CollapsingHeader => { Role::Button } + WidgetType::Image => Role::Image, WidgetType::Checkbox => Role::CheckBox, WidgetType::RadioButton => Role::RadioButton, WidgetType::RadioGroup => Role::RadioGroup, diff --git a/crates/egui/src/widgets/image.rs b/crates/egui/src/widgets/image.rs index 4cdfc5bf749..81fca264971 100644 --- a/crates/egui/src/widgets/image.rs +++ b/crates/egui/src/widgets/image.rs @@ -6,7 +6,7 @@ use epaint::RectShape; use crate::{ load::{Bytes, SizeHint, SizedTexture, TextureLoadResult, TexturePoll}, pos2, Align2, Color32, Context, Id, Mesh, Painter, Rect, Response, Rounding, Sense, Shape, - Spinner, Stroke, TextStyle, TextureOptions, Ui, Vec2, Widget, + Spinner, Stroke, TextStyle, TextureOptions, Ui, Vec2, Widget, WidgetInfo, WidgetType, }; /// A widget which displays an image. @@ -363,6 +363,7 @@ impl<'a> Widget for Image<'a> { let ui_size = self.calc_size(ui.available_size(), original_image_size); let (rect, response) = ui.allocate_exact_size(ui_size, self.sense); + response.widget_info(|| WidgetInfo::new(WidgetType::Image)); if ui.is_rect_visible(rect) { paint_texture_load_result( ui,