diff --git a/crates/egui/src/widgets/button.rs b/crates/egui/src/widgets/button.rs index 5330ff098..a1d2f84ed 100644 --- a/crates/egui/src/widgets/button.rs +++ b/crates/egui/src/widgets/button.rs @@ -1,9 +1,9 @@ use epaint::Margin; use crate::{ - Atom, AtomExt as _, AtomKind, AtomLayout, AtomLayoutResponse, Color32, CornerRadius, Frame, - Image, IntoAtoms, NumExt as _, Response, Sense, Stroke, TextStyle, TextWrapMode, Ui, Vec2, - Widget, WidgetInfo, WidgetText, WidgetType, + Atom, AtomExt as _, AtomKind, AtomLayout, AtomLayoutResponse, Atoms, Color32, CornerRadius, + Frame, Image, IntoAtoms, NumExt as _, Response, Sense, Stroke, TextStyle, TextWrapMode, Ui, + Vec2, Widget, WidgetInfo, WidgetText, WidgetType, widget_style::{ButtonStyle, Classes, HasClasses, SELECTED_CLASS, WidgetState}, }; @@ -279,6 +279,13 @@ impl<'a> Button<'a> { self } + /// Output the button's [`Atoms`]. + /// + /// This includes any images you have on the button. + pub fn atoms(&self) -> &Atoms<'a> { + &self.layout.atoms + } + /// Show the button and return a [`AtomLayoutResponse`] for painting custom contents. pub fn atom_ui(self, ui: &mut Ui) -> AtomLayoutResponse { let Button { diff --git a/crates/egui/src/widgets/checkbox.rs b/crates/egui/src/widgets/checkbox.rs index 194bc0688..0aaedec76 100644 --- a/crates/egui/src/widgets/checkbox.rs +++ b/crates/egui/src/widgets/checkbox.rs @@ -41,6 +41,13 @@ impl<'a> Checkbox<'a> { Self::new(checked, ()) } + /// Output the checkbox's [`Atoms`]. + /// + /// This includes any images you have on the checkbox. + pub fn atoms(&self) -> &Atoms<'a> { + &self.atoms + } + /// Display an indeterminate state (neither checked nor unchecked) /// /// This only affects the checkbox's appearance. It will still toggle its boolean value when diff --git a/crates/egui/src/widgets/drag_value.rs b/crates/egui/src/widgets/drag_value.rs index bac5c33f4..7f1140bd9 100644 --- a/crates/egui/src/widgets/drag_value.rs +++ b/crates/egui/src/widgets/drag_value.rs @@ -409,6 +409,13 @@ impl<'a> DragValue<'a> { self.update_while_editing = update; self } + + /// Output the [`DragValue`]'s [`Atoms`]. + /// + /// This includes any images you have on the [`DragValue`]. + pub fn atoms(&self) -> &Atoms<'a> { + &self.atoms + } } impl Widget for DragValue<'_> { diff --git a/crates/egui/src/widgets/radio_button.rs b/crates/egui/src/widgets/radio_button.rs index 8b1f7cc4b..d7f31744f 100644 --- a/crates/egui/src/widgets/radio_button.rs +++ b/crates/egui/src/widgets/radio_button.rs @@ -35,6 +35,13 @@ impl<'a> RadioButton<'a> { atoms: atoms.into_atoms(), } } + + /// Output the [`RadioButton`]'s [`Atoms`]. + /// + /// This includes any images you have on the [`RadioButton`]. + pub fn atoms(&self) -> &Atoms<'a> { + &self.atoms + } } impl Widget for RadioButton<'_> {