Skip to content

Commit 85abf78

Browse files
committed
working fine with imgui 1.91
1 parent 73cf7f1 commit 85abf78

27 files changed

+42634
-18552
lines changed

libs/imgui/src/LICENSE.txt

100755100644
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2014-2020 Omar Cornut
3+
Copyright (c) 2014-2024 Omar Cornut
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

libs/imgui/src/imgui.cpp

100755100644
Lines changed: 16587 additions & 9581 deletions
Large diffs are not rendered by default.

libs/imgui/src/imgui.h

100755100644
Lines changed: 2352 additions & 975 deletions
Large diffs are not rendered by default.

libs/imgui/src/imgui_demo.cpp

100755100644
Lines changed: 7614 additions & 2107 deletions
Large diffs are not rendered by default.

libs/imgui/src/imgui_draw.cpp

100755100644
Lines changed: 1796 additions & 731 deletions
Large diffs are not rendered by default.

libs/imgui/src/imgui_internal.h

100755100644
Lines changed: 2787 additions & 1162 deletions
Large diffs are not rendered by default.

libs/imgui/src/imgui_stdlib.cpp

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// dear imgui: wrappers for C++ standard library (STL) types (std::string, etc.)
2+
// This is also an example of how you may wrap your own similar types.
3+
4+
// Changelog:
5+
// - v0.10: Initial version. Added InputText() / InputTextMultiline() calls with std::string
6+
7+
// See more C++ related extension (fmt, RAII, syntaxis sugar) on Wiki:
8+
// https://github.com/ocornut/imgui/wiki/Useful-Extensions#cness
9+
10+
#include "imgui.h"
11+
#include "imgui_stdlib.h"
12+
13+
// Clang warnings with -Weverything
14+
#if defined(__clang__)
15+
#pragma clang diagnostic push
16+
#pragma clang diagnostic ignored "-Wsign-conversion" // warning: implicit conversion changes signedness
17+
#endif
18+
19+
struct InputTextCallback_UserData
20+
{
21+
std::string* Str;
22+
ImGuiInputTextCallback ChainCallback;
23+
void* ChainCallbackUserData;
24+
};
25+
26+
static int InputTextCallback(ImGuiInputTextCallbackData* data)
27+
{
28+
InputTextCallback_UserData* user_data = (InputTextCallback_UserData*)data->UserData;
29+
if (data->EventFlag == ImGuiInputTextFlags_CallbackResize)
30+
{
31+
// Resize string callback
32+
// If for some reason we refuse the new length (BufTextLen) and/or capacity (BufSize) we need to set them back to what we want.
33+
std::string* str = user_data->Str;
34+
IM_ASSERT(data->Buf == str->c_str());
35+
str->resize(data->BufTextLen);
36+
data->Buf = (char*)str->c_str();
37+
}
38+
else if (user_data->ChainCallback)
39+
{
40+
// Forward to user callback, if any
41+
data->UserData = user_data->ChainCallbackUserData;
42+
return user_data->ChainCallback(data);
43+
}
44+
return 0;
45+
}
46+
47+
bool ImGui::InputText(const char* label, std::string* str, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data)
48+
{
49+
IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0);
50+
flags |= ImGuiInputTextFlags_CallbackResize;
51+
52+
InputTextCallback_UserData cb_user_data;
53+
cb_user_data.Str = str;
54+
cb_user_data.ChainCallback = callback;
55+
cb_user_data.ChainCallbackUserData = user_data;
56+
return InputText(label, (char*)str->c_str(), str->capacity() + 1, flags, InputTextCallback, &cb_user_data);
57+
}
58+
59+
bool ImGui::InputTextMultiline(const char* label, std::string* str, const ImVec2& size, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data)
60+
{
61+
IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0);
62+
flags |= ImGuiInputTextFlags_CallbackResize;
63+
64+
InputTextCallback_UserData cb_user_data;
65+
cb_user_data.Str = str;
66+
cb_user_data.ChainCallback = callback;
67+
cb_user_data.ChainCallbackUserData = user_data;
68+
return InputTextMultiline(label, (char*)str->c_str(), str->capacity() + 1, size, flags, InputTextCallback, &cb_user_data);
69+
}
70+
71+
bool ImGui::InputTextWithHint(const char* label, const char* hint, std::string* str, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data)
72+
{
73+
IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0);
74+
flags |= ImGuiInputTextFlags_CallbackResize;
75+
76+
InputTextCallback_UserData cb_user_data;
77+
cb_user_data.Str = str;
78+
cb_user_data.ChainCallback = callback;
79+
cb_user_data.ChainCallbackUserData = user_data;
80+
return InputTextWithHint(label, hint, (char*)str->c_str(), str->capacity() + 1, flags, InputTextCallback, &cb_user_data);
81+
}
82+
83+
#if defined(__clang__)
84+
#pragma clang diagnostic pop
85+
#endif

libs/imgui/src/imgui_stdlib.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// dear imgui: wrappers for C++ standard library (STL) types (std::string, etc.)
2+
// This is also an example of how you may wrap your own similar types.
3+
4+
// Changelog:
5+
// - v0.10: Initial version. Added InputText() / InputTextMultiline() calls with std::string
6+
7+
// See more C++ related extension (fmt, RAII, syntaxis sugar) on Wiki:
8+
// https://github.com/ocornut/imgui/wiki/Useful-Extensions#cness
9+
10+
#pragma once
11+
12+
#include <string>
13+
14+
namespace ImGui
15+
{
16+
// ImGui::InputText() with std::string
17+
// Because text input needs dynamic resizing, we need to setup a callback to grow the capacity
18+
IMGUI_API bool InputText(const char* label, std::string* str, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr);
19+
IMGUI_API bool InputTextMultiline(const char* label, std::string* str, const ImVec2& size = ImVec2(0, 0), ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr);
20+
IMGUI_API bool InputTextWithHint(const char* label, const char* hint, std::string* str, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = nullptr, void* user_data = nullptr);
21+
}

0 commit comments

Comments
 (0)