mirror of
https://github.com/emilk/egui.git
synced 2026-09-01 22:30:03 -04:00
Destructure in apply
This commit is contained in:
@@ -95,23 +95,29 @@ impl AtomLayoutStyle {
|
|||||||
///
|
///
|
||||||
/// A per-widget [`AtomLayout::gap`] wins over [`Self::gap`], so widgets like
|
/// A per-widget [`AtomLayout::gap`] wins over [`Self::gap`], so widgets like
|
||||||
/// [`crate::DragValue`] can pack their atoms tighter than the theme does.
|
/// [`crate::DragValue`] can pack their atoms tighter than the theme does.
|
||||||
pub fn apply<'a>(&self, mut layout: AtomLayout<'a>) -> AtomLayout<'a> {
|
pub fn apply(self, mut layout: AtomLayout<'_>) -> AtomLayout<'_> {
|
||||||
|
let Self {
|
||||||
|
align2,
|
||||||
|
min_size,
|
||||||
|
gap,
|
||||||
|
frame,
|
||||||
|
text_style,
|
||||||
|
image_tint,
|
||||||
|
} = self;
|
||||||
layout.map_images(|image| {
|
layout.map_images(|image| {
|
||||||
if image.image_options().tint == Color32::WHITE {
|
let current_tint = image.image_options().tint;
|
||||||
image.tint(self.image_tint)
|
// Multiply the tints so they are combined
|
||||||
} else {
|
image.tint(current_tint * image_tint)
|
||||||
image
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let layout = layout
|
let layout = layout
|
||||||
.min_size(self.min_size)
|
.min_size(min_size)
|
||||||
.fallback_gap(self.gap)
|
.fallback_gap(gap)
|
||||||
.frame(self.frame)
|
.frame(frame)
|
||||||
.fallback_font(self.text_style.font_id.clone())
|
.fallback_font(text_style.font_id)
|
||||||
.fallback_text_color(self.text_style.color);
|
.fallback_text_color(text_style.color);
|
||||||
|
|
||||||
if let Some(align2) = self.align2 {
|
if let Some(align2) = align2 {
|
||||||
layout.align2(align2)
|
layout.align2(align2)
|
||||||
} else {
|
} else {
|
||||||
layout
|
layout
|
||||||
|
|||||||
Reference in New Issue
Block a user