mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-12 00:14:20 +00:00
Added Set/GetVoidPtr in ImGuiStorage
This commit is contained in:
parent
00842d18e4
commit
c9c41c3874
2 changed files with 23 additions and 1 deletions
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++)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue