Compare commits

...

3 Commits

Author SHA1 Message Date
Emil Ernerfeldt 038350e3bd Revert "different child_next_auto_id_source"
This reverts commit 4620a124d7bf4eaf03ef7a408bc4e73887c8d171.
2024-02-01 11:53:26 +01:00
Emil Ernerfeldt 1e2df868ca different child_next_auto_id_source
Co-authored-by: Eric Van Albert <eric@van.al>
2024-02-01 11:53:26 +01:00
Emil Ernerfeldt 23a74900ae Auto-ids are seeded based on Ui::id 2024-02-01 11:53:26 +01:00
2 changed files with 9 additions and 10 deletions

View File

@ -60,8 +60,9 @@ impl Id {
format!("{:04X}", self.0 as u16)
}
/// The contained value.
#[inline(always)]
pub(crate) fn value(&self) -> u64 {
pub fn value(&self) -> u64 {
self.0
}

View File

@ -97,17 +97,19 @@ impl Ui {
id_source: impl Hash,
) -> Self {
crate::egui_assert!(!max_rect.any_nan());
let next_auto_id_source = Id::new(self.next_auto_id_source).with("child").value();
let child_id = self.id.with(id_source);
let child_next_auto_id_source = child_id.with(self.next_auto_id_source).value();
self.next_auto_id_source = self.next_auto_id_source.wrapping_add(1);
let menu_state = self.menu_state();
Ui {
id: self.id.with(id_source),
next_auto_id_source,
id: child_id,
next_auto_id_source: child_next_auto_id_source,
painter: self.painter.clone(),
style: self.style.clone(),
placer: Placer::new(max_rect, layout),
enabled: self.enabled,
menu_state,
menu_state: self.menu_state.clone(),
}
}
@ -2232,10 +2234,6 @@ impl Ui {
self.menu_state = None;
}
pub(crate) fn menu_state(&self) -> Option<Arc<RwLock<MenuState>>> {
self.menu_state.clone()
}
pub(crate) fn set_menu_state(&mut self, menu_state: Option<Arc<RwLock<MenuState>>>) {
self.menu_state = menu_state;
}