use SlotMap

This commit is contained in:
Aleksander 2026-02-14 16:04:36 +01:00
parent 4fc439abe2
commit 756c42609d
2 changed files with 6 additions and 6 deletions

View File

@ -6,7 +6,7 @@ use std::{
use anyhow::Context; use anyhow::Context;
use glam::{Affine3A, Vec3, Vec3A}; use glam::{Affine3A, Vec3, Vec3A};
use slotmap::{HopSlotMap, Key, SecondaryMap}; use slotmap::{Key, SecondaryMap, SlotMap};
use wgui::log::LogErr; use wgui::log::LogErr;
use wlx_common::{ use wlx_common::{
astr_containers::{AStrMap, AStrMapExt}, astr_containers::{AStrMap, AStrMapExt},
@ -42,7 +42,7 @@ pub const MAX_OVERLAY_SETS: usize = 6;
pub struct OverlayWindowManager<T> { pub struct OverlayWindowManager<T> {
wrappers: EditWrapperManager, wrappers: EditWrapperManager,
overlays: HopSlotMap<OverlayID, OverlayWindowData<T>>, overlays: SlotMap<OverlayID, OverlayWindowData<T>>,
sets: Vec<OverlayWindowSet>, sets: Vec<OverlayWindowSet>,
global_set: OverlayWindowSet, global_set: OverlayWindowSet,
/// The set that is currently visible. /// The set that is currently visible.
@ -65,7 +65,7 @@ where
pub fn new(app: &mut AppState, headless: bool) -> anyhow::Result<Self> { pub fn new(app: &mut AppState, headless: bool) -> anyhow::Result<Self> {
let mut me = Self { let mut me = Self {
wrappers: EditWrapperManager::default(), wrappers: EditWrapperManager::default(),
overlays: HopSlotMap::with_key(), overlays: SlotMap::<OverlayID, OverlayWindowData<T>>::with_key(),
current_set: Some(0), current_set: Some(0),
restore_set: 0, restore_set: 0,
sets: vec![OverlayWindowSet::default()], sets: vec![OverlayWindowSet::default()],

View File

@ -18,7 +18,7 @@ use crate::{
use anyhow::Context; use anyhow::Context;
use glam::{Vec2, vec2}; use glam::{Vec2, vec2};
use slotmap::{HopSlotMap, SecondaryMap, new_key_type}; use slotmap::{SecondaryMap, SlotMap, new_key_type};
use taffy::{NodeId, TaffyTree, TraversePartialTree}; use taffy::{NodeId, TaffyTree, TraversePartialTree};
new_key_type! { new_key_type! {
@ -57,7 +57,7 @@ impl WeakWidget {
} }
} }
pub struct WidgetMap(HopSlotMap<WidgetID, Widget>); pub struct WidgetMap(SlotMap<WidgetID, Widget>);
pub type WidgetNodeMap = SecondaryMap<WidgetID, taffy::NodeId>; pub type WidgetNodeMap = SecondaryMap<WidgetID, taffy::NodeId>;
#[derive(Clone)] #[derive(Clone)]
@ -68,7 +68,7 @@ pub struct WidgetPair {
impl WidgetMap { impl WidgetMap {
fn new() -> Self { fn new() -> Self {
Self(HopSlotMap::with_key()) Self(SlotMap::<WidgetID, Widget>::with_key())
} }
pub fn get_as<T: 'static>(&self, handle: WidgetID) -> Option<RefMut<'_, T>> { pub fn get_as<T: 'static>(&self, handle: WidgetID) -> Option<RefMut<'_, T>> {