mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-12 15:59:54 +02:00
Added Set/GetVoidPtr in ImGuiStorage
This commit is contained in:
19
imgui.cpp
19
imgui.cpp
@ -1163,6 +1163,14 @@ float* ImGuiStorage::GetFloatPtr(ImGuiID key, float default_val)
|
||||
return &it->val_f;
|
||||
}
|
||||
|
||||
void* ImGuiStorage::GetVoidPtr(ImGuiID key)
|
||||
{
|
||||
ImVector<Pair>::iterator it = LowerBound(Data, key);
|
||||
if (it == Data.end() || it->key != key)
|
||||
it = Data.insert(it, Pair(key, (void*)0));
|
||||
return it->val_p;
|
||||
}
|
||||
|
||||
// FIXME-OPT: Wasting CPU because all SetInt() are preceeded by GetInt() calls so we should have the result from lower_bound already in place.
|
||||
// However we only use SetInt() on explicit user action (so that's maximum once a frame) so the optimisation isn't much needed.
|
||||
void ImGuiStorage::SetInt(ImU32 key, int val)
|
||||
@ -1187,6 +1195,17 @@ void ImGuiStorage::SetFloat(ImU32 key, float val)
|
||||
it->val_f = val;
|
||||
}
|
||||
|
||||
void ImGuiStorage::SetVoidPtr(ImU32 key, void* val)
|
||||
{
|
||||
ImVector<Pair>::iterator it = LowerBound(Data, key);
|
||||
if (it == Data.end() || it->key != key)
|
||||
{
|
||||
Data.insert(it, Pair(key, val));
|
||||
return;
|
||||
}
|
||||
it->val_p = val;
|
||||
}
|
||||
|
||||
void ImGuiStorage::SetAllInt(int v)
|
||||
{
|
||||
for (size_t i = 0; i < Data.size(); i++)
|
||||
|
Reference in New Issue
Block a user