1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-29 04:40:03 -04:00

Let a Popup carry classes

This commit is contained in:
Lucas Meurer
2026-08-21 16:46:41 +02:00
parent 0099cc1fe6
commit 08f3a2b03b

View File

@@ -7,7 +7,7 @@ use crate::{
Sense, Ui, UiKind, UiStackInfo,
containers::menu::{MenuConfig, MenuState, menu_style},
style::StyleModifier,
widget_style::{Classes, HasClasses as _, MENU_CLASS, PopupStyle},
widget_style::{Classes, HasClasses, MENU_CLASS, PopupStyle},
};
/// What should we anchor the popup to?
@@ -186,6 +186,17 @@ pub struct Popup<'a> {
layout: Layout,
frame: Option<Frame>,
style: StyleModifier,
classes: Classes,
}
impl HasClasses for Popup<'_> {
fn classes(&self) -> &Classes {
&self.classes
}
fn classes_mut(&mut self) -> &mut Classes {
&mut self.classes
}
}
impl<'a> Popup<'a> {
@@ -210,6 +221,7 @@ impl<'a> Popup<'a> {
layout: Layout::default(),
frame: None,
style: StyleModifier::default(),
classes: Classes::default(),
}
}
@@ -578,6 +590,7 @@ impl<'a> Popup<'a> {
layout,
frame,
style,
mut classes,
} = self;
if kind != PopupKind::Tooltip {
@@ -594,7 +607,7 @@ impl<'a> Popup<'a> {
let (pivot, anchor) = best_align.pivot_pos(&anchor_rect, gap);
let classes = Classes::default().with_class_if(MENU_CLASS, kind == PopupKind::Menu);
classes.add_class_if(MENU_CLASS, kind == PopupKind::Menu);
let mut area = Area::new(id)
.with_classes(classes.clone())