mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-04 12:08:47 +02:00
Merge branch 'master' into docking
# Conflicts: # examples/imgui_impl_vulkan.cpp
This commit is contained in:
62
imgui.cpp
62
imgui.cpp
@ -37,9 +37,14 @@ DOCUMENTATION
|
||||
- Using gamepad/keyboard navigation controls.
|
||||
- API BREAKING CHANGES (read me when you update!)
|
||||
- FREQUENTLY ASKED QUESTIONS (FAQ), TIPS
|
||||
- Where is the documentation?
|
||||
- Which version should I get?
|
||||
- Who uses Dear ImGui?
|
||||
- Why the odd dual naming, "Dear ImGui" vs "ImGui"?
|
||||
- How can I tell whether to dispatch mouse/keyboard to imgui or to my application?
|
||||
- How can I display an image? What is ImTextureID, how does it works?
|
||||
- How can I have multiple widgets with the same label or with an empty label? A primer on labels and the ID Stack.
|
||||
- Why are multiple widgets reacting when I interact with a single one? How can I have
|
||||
multiple widgets with the same label or with an empty label? A primer on labels and the ID Stack...
|
||||
- How can I use my own math types instead of ImVec2/ImVec4?
|
||||
- How can I load a different font than the default?
|
||||
- How can I easily use icons in my application?
|
||||
@ -563,6 +568,39 @@ CODE
|
||||
FREQUENTLY ASKED QUESTIONS (FAQ), TIPS
|
||||
======================================
|
||||
|
||||
Q: Where is the documentation?
|
||||
A: This library is poorly documented at the moment and expects of the user to be acquainted with C/C++.
|
||||
- Run the examples/ and explore them.
|
||||
- See demo code in imgui_demo.cpp and particularly the ImGui::ShowDemoWindow() function.
|
||||
- The demo covers most features of Dear ImGui, so you can read the code and see its output.
|
||||
- See documentation and comments at the top of imgui.cpp + effectively imgui.h.
|
||||
- Dozens of standalone example applications using e.g. OpenGL/DirectX are provided in the examples/
|
||||
folder to explain how to integrate Dear ImGui with your own engine/application.
|
||||
- Your programming IDE is your friend, find the type or function declaration to find comments
|
||||
associated to it.
|
||||
|
||||
Q: Which version should I get?
|
||||
A: I occasionally tag Releases (https://github.com/ocornut/imgui/releases) but it is generally safe
|
||||
and recommended to sync to master/latest. The library is fairly stable and regressions tend to be
|
||||
fixed fast when reported. You may also peak at the 'docking' branch which includes:
|
||||
- Docking/Merging features (https://github.com/ocornut/imgui/issues/2109)
|
||||
- Multi-viewport features (https://github.com/ocornut/imgui/issues/1542)
|
||||
Many projects are using this branch and it is kept in sync with master regularly.
|
||||
|
||||
Q: Who uses Dear ImGui?
|
||||
A: See "Quotes" (https://github.com/ocornut/imgui/wiki/Quotes) and
|
||||
"Software using Dear ImGui" (https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui) Wiki pages
|
||||
for a list of games/software which are publicly known to use dear imgui. Please add yours if you can!
|
||||
|
||||
Q: Why the odd dual naming, "Dear ImGui" vs "ImGui"?
|
||||
A: The library started its life as "ImGui" due to the fact that I didn't give it a proper name when
|
||||
when I released 1.0, and had no particular expectation that it would take off. However, the term IMGUI
|
||||
(immediate-mode graphical user interface) was coined before and is being used in variety of other
|
||||
situations (e.g. Unity uses it own implementation of the IMGUI paradigm).
|
||||
To reduce the ambiguity without affecting existing code bases, I have decided on an alternate,
|
||||
longer name "Dear ImGui" that people can use to refer to this specific library.
|
||||
Please try to refer to this library as "Dear ImGui".
|
||||
|
||||
Q: How can I tell whether to dispatch mouse/keyboard to imgui or to my application?
|
||||
A: You can read the 'io.WantCaptureMouse', 'io.WantCaptureKeyboard' and 'io.WantTextInput' flags from the ImGuiIO structure (e.g. if (ImGui::GetIO().WantCaptureMouse) { ... } )
|
||||
- When 'io.WantCaptureMouse' is set, imgui wants to use your mouse state, and you may want to discard/hide the inputs from the rest of your application.
|
||||
@ -664,8 +702,8 @@ CODE
|
||||
|
||||
Finally, you may call ImGui::ShowMetricsWindow() to explore/visualize/understand how the ImDrawList are generated.
|
||||
|
||||
Q: Why are multiple widgets reacting when I interact with a single one?
|
||||
Q: How can I have multiple widgets with the same label or with an empty label?
|
||||
Q: I have multiple widgets with the same label, and only the first one works. Why is that?
|
||||
A: A primer on labels and the ID Stack...
|
||||
|
||||
Dear ImGui internally need to uniquely identify UI elements.
|
||||
@ -1344,7 +1382,7 @@ void ImStrncpy(char* dst, const char* src, size_t count)
|
||||
char* ImStrdup(const char* str)
|
||||
{
|
||||
size_t len = strlen(str);
|
||||
void* buf = ImGui::MemAlloc(len + 1);
|
||||
void* buf = IM_ALLOC(len + 1);
|
||||
return (char*)memcpy(buf, (const void*)str, len + 1);
|
||||
}
|
||||
|
||||
@ -1354,8 +1392,8 @@ char* ImStrdupcpy(char* dst, size_t* p_dst_size, const char* src)
|
||||
size_t src_size = strlen(src) + 1;
|
||||
if (dst_buf_size < src_size)
|
||||
{
|
||||
ImGui::MemFree(dst);
|
||||
dst = (char*)ImGui::MemAlloc(src_size);
|
||||
IM_FREE(dst);
|
||||
dst = (char*)IM_ALLOC(src_size);
|
||||
if (p_dst_size)
|
||||
*p_dst_size = src_size;
|
||||
}
|
||||
@ -1571,7 +1609,7 @@ FILE* ImFileOpen(const char* filename, const char* mode)
|
||||
}
|
||||
|
||||
// Load file content into memory
|
||||
// Memory allocated with ImGui::MemAlloc(), must be freed by user using ImGui::MemFree()
|
||||
// Memory allocated with IM_ALLOC(), must be freed by user using IM_FREE() == ImGui::MemFree()
|
||||
void* ImFileLoadToMemory(const char* filename, const char* file_open_mode, size_t* out_file_size, int padding_bytes)
|
||||
{
|
||||
IM_ASSERT(filename && file_open_mode);
|
||||
@ -1590,7 +1628,7 @@ void* ImFileLoadToMemory(const char* filename, const char* file_open_mode, size_
|
||||
}
|
||||
|
||||
size_t file_size = (size_t)file_size_signed;
|
||||
void* file_data = ImGui::MemAlloc(file_size + padding_bytes);
|
||||
void* file_data = IM_ALLOC(file_size + padding_bytes);
|
||||
if (file_data == NULL)
|
||||
{
|
||||
fclose(f);
|
||||
@ -1599,7 +1637,7 @@ void* ImFileLoadToMemory(const char* filename, const char* file_open_mode, size_
|
||||
if (fread(file_data, 1, file_size, f) != file_size)
|
||||
{
|
||||
fclose(f);
|
||||
ImGui::MemFree(file_data);
|
||||
IM_FREE(file_data);
|
||||
return NULL;
|
||||
}
|
||||
if (padding_bytes > 0)
|
||||
@ -3024,6 +3062,7 @@ float ImGui::CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x)
|
||||
return ImMax(wrap_pos_x - pos.x, 1.0f);
|
||||
}
|
||||
|
||||
// IM_ALLOC() == ImGui::MemAlloc()
|
||||
void* ImGui::MemAlloc(size_t size)
|
||||
{
|
||||
if (ImGuiContext* ctx = GImGui)
|
||||
@ -3031,6 +3070,7 @@ void* ImGui::MemAlloc(size_t size)
|
||||
return GImAllocatorAllocFunc(size, GImAllocatorUserData);
|
||||
}
|
||||
|
||||
// IM_FREE() == ImGui::MemFree()
|
||||
void ImGui::MemFree(void* ptr)
|
||||
{
|
||||
if (ptr)
|
||||
@ -9790,7 +9830,7 @@ void ImGui::LoadIniSettingsFromDisk(const char* ini_filename)
|
||||
if (!file_data)
|
||||
return;
|
||||
LoadIniSettingsFromMemory(file_data, (size_t)file_data_size);
|
||||
ImGui::MemFree(file_data);
|
||||
IM_FREE(file_data);
|
||||
}
|
||||
|
||||
ImGuiSettingsHandler* ImGui::FindSettingsHandler(const char* type_name)
|
||||
@ -9814,7 +9854,7 @@ void ImGui::LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size)
|
||||
// For our convenience and to make the code simpler, we'll also write zero-terminators within the buffer. So let's create a writable copy..
|
||||
if (ini_size == 0)
|
||||
ini_size = strlen(ini_data);
|
||||
char* buf = (char*)ImGui::MemAlloc(ini_size + 1);
|
||||
char* buf = (char*)IM_ALLOC(ini_size + 1);
|
||||
char* buf_end = buf + ini_size;
|
||||
memcpy(buf, ini_data, ini_size);
|
||||
buf[ini_size] = 0;
|
||||
@ -9861,7 +9901,7 @@ void ImGui::LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size)
|
||||
entry_handler->ReadLineFn(&g, entry_handler, entry_data, line);
|
||||
}
|
||||
}
|
||||
ImGui::MemFree(buf);
|
||||
IM_FREE(buf);
|
||||
g.SettingsLoaded = true;
|
||||
DockContextOnLoadSettings(&g);
|
||||
}
|
||||
|
Reference in New Issue
Block a user