mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-13 08:19:55 +02:00
Compare commits
11 Commits
docking
...
features/s
Author | SHA1 | Date | |
---|---|---|---|
973806fe6b | |||
11083874bc | |||
c28be6ffce | |||
51ee9f7126 | |||
a643b23486 | |||
194bf63863 | |||
4e894ae1d9 | |||
7abe463801 | |||
35c0f9a29b | |||
88bcafd0a3 | |||
54fb051e52 |
@ -56,6 +56,7 @@ Other Changes:
|
||||
- IsItemHovered(): added ImGuiHoveredFlags_NoNavOverride to disable the behavior where the
|
||||
return value is overriden by focus when gamepad/keyboard navigation is active.
|
||||
- Inputs: Fixed IsMouseClicked() repeat mode rate being half of keyboard repeat rate.
|
||||
- ColorEdit: Fixed text baseline alignment after a SameLine() after a ColorEdit() with visible label.
|
||||
- Stack Tool: Added option to copy item path to clipboard. (#4631)
|
||||
- Misc: Fixed IsAnyItemHovered() returning false when using navigation.
|
||||
- Misc: Added constexpr to ImVec2/ImVec4 inline constructors. (#4995) [@Myriachan]
|
||||
|
@ -90,6 +90,15 @@
|
||||
operator MyVec4() const { return MyVec4(x,y,z,w); }
|
||||
*/
|
||||
|
||||
//---- Define constructor to convert your string type to ImStrv (which is a non-owning begin/end pair)
|
||||
// This will be inlined as part of ImStrv class declaration.
|
||||
// This has two benefits: you won't need to use .c_str(), if length is already computed it is faster.
|
||||
//#include <string>
|
||||
//#include <string_view>
|
||||
//#define IM_STR_CLASS_EXTRA ImStrv(const std::string& s) { Begin = s.c_str(); End = Begin + s.length(); }
|
||||
//#define IM_STR_CLASS_EXTRA ImStrv(const std::string_view& s) { Begin = s.data(); End = Begin + s.length(); }
|
||||
//#define IM_STR_CLASS_EXTRA ImStrv(const MyString& s) { Begin = s.Data; End = s.end(); }
|
||||
|
||||
//---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices.
|
||||
// Your renderer backend will need to support it (most example renderer backends support both 16/32-bit indices).
|
||||
// Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer.
|
||||
|
414
imgui.cpp
414
imgui.cpp
@ -918,7 +918,7 @@ static const float WINDOWS_MOUSE_WHEEL_SCROLL_LOCK_TIMER = 2.00f; // Lock
|
||||
|
||||
static void SetCurrentWindow(ImGuiWindow* window);
|
||||
static void FindHoveredWindow();
|
||||
static ImGuiWindow* CreateNewWindow(const char* name, ImGuiWindowFlags flags);
|
||||
static ImGuiWindow* CreateNewWindow(ImStrv name, ImGuiWindowFlags flags);
|
||||
static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window);
|
||||
|
||||
static void AddDrawListToDrawData(ImVector<ImDrawList*>* out_list, ImDrawList* draw_list);
|
||||
@ -974,7 +974,7 @@ static void UpdateMouseWheel();
|
||||
static bool UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_held, int resize_grip_count, ImU32 resize_grip_col[4], const ImRect& visibility_rect);
|
||||
static void RenderWindowOuterBorders(ImGuiWindow* window);
|
||||
static void RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar_rect, bool title_bar_is_highlight, int resize_grip_count, const ImU32 resize_grip_col[4], float resize_grip_draw_size);
|
||||
static void RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& title_bar_rect, const char* name, bool* p_open);
|
||||
static void RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& title_bar_rect, ImStrv name, bool* p_open);
|
||||
static void RenderDimmedBackgroundBehindWindow(ImGuiWindow* window, ImU32 col);
|
||||
static void RenderDimmedBackgrounds();
|
||||
static ImGuiWindow* FindBlockingModal(ImGuiWindow* window);
|
||||
@ -1510,6 +1510,15 @@ ImVec2 ImTriangleClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c,
|
||||
// [SECTION] MISC HELPERS/UTILITIES (String, Format, Hash functions)
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int ImStrcmp(ImStrv str1, ImStrv str2)
|
||||
{
|
||||
size_t str1_len = str1.length();
|
||||
size_t str2_len = str2.length();
|
||||
if (str1_len != str2_len)
|
||||
return (int)str1_len - (int)str2_len;
|
||||
return memcmp(str1.Begin, str2.Begin, str1_len);
|
||||
}
|
||||
|
||||
// Consider using _stricmp/_strnicmp under Windows or strcasecmp/strncasecmp. We don't actually use either ImStricmp/ImStrnicmp in the codebase any more.
|
||||
int ImStricmp(const char* str1, const char* str2)
|
||||
{
|
||||
@ -1534,6 +1543,13 @@ void ImStrncpy(char* dst, const char* src, size_t count)
|
||||
dst[count - 1] = 0;
|
||||
}
|
||||
|
||||
void ImStrncpy(char* dst, ImStrv src, size_t count)
|
||||
{
|
||||
// Even though src does not necessarily include \0 terminator it is ok to include it. ImStrncpy above does not
|
||||
// actually include that in a copy operation and inserts zero terminator manually.
|
||||
ImStrncpy(dst, src.Begin, ImMin(count, src.length() + 1));
|
||||
}
|
||||
|
||||
char* ImStrdup(const char* str)
|
||||
{
|
||||
size_t len = strlen(str);
|
||||
@ -1541,10 +1557,20 @@ char* ImStrdup(const char* str)
|
||||
return (char*)memcpy(buf, (const void*)str, len + 1);
|
||||
}
|
||||
|
||||
char* ImStrdupcpy(char* dst, size_t* p_dst_size, const char* src)
|
||||
char* ImStrdup(ImStrv str)
|
||||
{
|
||||
size_t len = str.length();
|
||||
void* buf = IM_ALLOC(len + 1);
|
||||
*((char*)buf + len) = 0; // str may not contain \0, it must be inserted manually.
|
||||
if (len > 0)
|
||||
return (char*)memcpy(buf, (const void*)str.Begin, len);
|
||||
return (char*)buf;
|
||||
}
|
||||
|
||||
char* ImStrdupcpy(char* dst, size_t* p_dst_size, ImStrv src)
|
||||
{
|
||||
size_t dst_buf_size = p_dst_size ? *p_dst_size : strlen(dst) + 1;
|
||||
size_t src_size = strlen(src) + 1;
|
||||
size_t src_size = src.length() + 1;
|
||||
if (dst_buf_size < src_size)
|
||||
{
|
||||
IM_FREE(dst);
|
||||
@ -1552,7 +1578,15 @@ char* ImStrdupcpy(char* dst, size_t* p_dst_size, const char* src)
|
||||
if (p_dst_size)
|
||||
*p_dst_size = src_size;
|
||||
}
|
||||
return (char*)memcpy(dst, (const void*)src, src_size);
|
||||
dst[src_size - 1] = 0; // str may not contain \0, it must be inserted manually.
|
||||
if (src_size > 1)
|
||||
return (char*)memcpy(dst, (const void*)src.Begin, src_size - 1);
|
||||
return dst;
|
||||
}
|
||||
|
||||
char* ImStrdupcpy(char* dst, size_t* p_dst_size, const char* src)
|
||||
{
|
||||
return ImStrdupcpy(dst, p_dst_size, ImStrv(src));
|
||||
}
|
||||
|
||||
const char* ImStrchrRange(const char* str, const char* str_end, char c)
|
||||
@ -1605,6 +1639,23 @@ const char* ImStristr(const char* haystack, const char* haystack_end, const char
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* ImStrstr(ImStrv haystack, ImStrv needle)
|
||||
{
|
||||
const char un0 = (char)*needle.Begin;
|
||||
const char* p = haystack.Begin;
|
||||
const size_t needle_len_m1 = needle.length() - 1;
|
||||
while (true)
|
||||
{
|
||||
p = (const char*)memchr(p, un0, haystack.End - p);
|
||||
if (p == NULL || (size_t)(haystack.End - p) - 1u < needle_len_m1)
|
||||
return NULL;
|
||||
if (needle_len_m1 == 0 || memcmp(p + 1, needle.Begin + 1, needle_len_m1) == 0)
|
||||
return p;
|
||||
p += 1;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Trim str by offsetting contents when there's leading data + writing a \0 at the trailing position. We use this in situation where the cost is negligible.
|
||||
void ImStrTrimBlanks(char* buf)
|
||||
{
|
||||
@ -1722,14 +1773,15 @@ ImGuiID ImHashData(const void* data_p, size_t data_size, ImU32 seed)
|
||||
// - If we reach ### in the string we discard the hash so far and reset to the seed.
|
||||
// - We don't do 'current += 2; continue;' after handling ### to keep the code smaller/faster (measured ~10% diff in Debug build)
|
||||
// FIXME-OPT: Replace with e.g. FNV1a hash? CRC32 pretty much randomly access 1KB. Need to do proper measurements.
|
||||
ImGuiID ImHashStr(const char* data_p, size_t data_size, ImU32 seed)
|
||||
ImGuiID ImHashStr(ImStrv str, ImU32 seed)
|
||||
{
|
||||
seed = ~seed;
|
||||
ImU32 crc = seed;
|
||||
const unsigned char* data = (const unsigned char*)data_p;
|
||||
const unsigned char* data = (const unsigned char*)str.Begin;
|
||||
const ImU32* crc32_lut = GCrc32LookupTable;
|
||||
if (data_size != 0)
|
||||
if (str.End != NULL)
|
||||
{
|
||||
size_t data_size = str.length();
|
||||
while (data_size-- != 0)
|
||||
{
|
||||
unsigned char c = *data++;
|
||||
@ -1757,20 +1809,27 @@ ImGuiID ImHashStr(const char* data_p, size_t data_size, ImU32 seed)
|
||||
// Default file functions
|
||||
#ifndef IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS
|
||||
|
||||
ImFileHandle ImFileOpen(const char* filename, const char* mode)
|
||||
ImFileHandle ImFileOpen(ImStrv filename, ImStrv mode)
|
||||
{
|
||||
#if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && !defined(__CYGWIN__) && !defined(__GNUC__)
|
||||
// We need a fopen() wrapper because MSVC/Windows fopen doesn't handle UTF-8 filenames.
|
||||
// Previously we used ImTextCountCharsFromUtf8/ImTextStrFromUtf8 here but we now need to support ImWchar16 and ImWchar32!
|
||||
const int filename_wsize = ::MultiByteToWideChar(CP_UTF8, 0, filename, -1, NULL, 0);
|
||||
const int mode_wsize = ::MultiByteToWideChar(CP_UTF8, 0, mode, -1, NULL, 0);
|
||||
ImVector<ImWchar> buf;
|
||||
buf.resize(filename_wsize + mode_wsize);
|
||||
::MultiByteToWideChar(CP_UTF8, 0, filename, -1, (wchar_t*)&buf[0], filename_wsize);
|
||||
::MultiByteToWideChar(CP_UTF8, 0, mode, -1, (wchar_t*)&buf[filename_wsize], mode_wsize);
|
||||
return ::_wfopen((const wchar_t*)&buf[0], (const wchar_t*)&buf[filename_wsize]);
|
||||
const int filename_wsize = ::MultiByteToWideChar(CP_UTF8, 0, filename.Begin, (int)filename.length(), NULL, 0);
|
||||
const int mode_wsize = ::MultiByteToWideChar(CP_UTF8, 0, mode.Begin, (int)mode.length(), NULL, 0);
|
||||
ImVector<wchar_t> buf;
|
||||
buf.resize(filename_wsize + 1 + mode_wsize + 1);
|
||||
::MultiByteToWideChar(CP_UTF8, 0, filename.Begin, (int)filename.length(), &buf[0], filename_wsize);
|
||||
::MultiByteToWideChar(CP_UTF8, 0, mode.Begin, (int)mode.length(), &buf[filename_wsize + 1], mode_wsize);
|
||||
buf[filename_wsize] = buf[filename_wsize + 1 + mode_wsize] = 0;
|
||||
return ::_wfopen(&buf[0], &buf[filename_wsize + 1]);
|
||||
#else
|
||||
return fopen(filename, mode);
|
||||
// ImStrv is not guaranteed to be zero-terminated.
|
||||
ImStrv filename_0 = ImStrdup(filename);
|
||||
ImStrv mode_0 = ImStrdup(mode);
|
||||
ImFileHandle handle = fopen(filename_0.Begin, mode_0.Begin);
|
||||
IM_FREE((char*)(void*)filename_0.Begin);
|
||||
IM_FREE((char*)(void*)mode_0.Begin);
|
||||
return handle;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1784,7 +1843,7 @@ ImU64 ImFileWrite(const void* data, ImU64 sz, ImU64 count, ImFileHandle f)
|
||||
// Helper: Load file content into memory
|
||||
// Memory allocated with IM_ALLOC(), must be freed by user using IM_FREE() == ImGui::MemFree()
|
||||
// This can't really be used with "rt" because fseek size won't match read size.
|
||||
void* ImFileLoadToMemory(const char* filename, const char* mode, size_t* out_file_size, int padding_bytes)
|
||||
void* ImFileLoadToMemory(ImStrv filename, ImStrv mode, size_t* out_file_size, int padding_bytes)
|
||||
{
|
||||
IM_ASSERT(filename && mode);
|
||||
if (out_file_size)
|
||||
@ -2241,7 +2300,7 @@ void ImGuiStorage::SetAllInt(int v)
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Helper: Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]"
|
||||
ImGuiTextFilter::ImGuiTextFilter(const char* default_filter)
|
||||
ImGuiTextFilter::ImGuiTextFilter(ImStrv default_filter)
|
||||
{
|
||||
if (default_filter)
|
||||
{
|
||||
@ -2255,7 +2314,7 @@ ImGuiTextFilter::ImGuiTextFilter(const char* default_filter)
|
||||
}
|
||||
}
|
||||
|
||||
bool ImGuiTextFilter::Draw(const char* label, float width)
|
||||
bool ImGuiTextFilter::Draw(ImStrv label, float width)
|
||||
{
|
||||
if (width != 0.0f)
|
||||
ImGui::SetNextItemWidth(width);
|
||||
@ -2265,68 +2324,66 @@ bool ImGuiTextFilter::Draw(const char* label, float width)
|
||||
return value_changed;
|
||||
}
|
||||
|
||||
void ImGuiTextFilter::ImGuiTextRange::split(char separator, ImVector<ImGuiTextRange>* out) const
|
||||
static void ImStrplit(ImStrv in, char separator, ImVector<ImStrv>* out)
|
||||
{
|
||||
out->resize(0);
|
||||
const char* wb = b;
|
||||
const char* wb = in.Begin;
|
||||
const char* we = wb;
|
||||
while (we < e)
|
||||
while (we < in.End)
|
||||
{
|
||||
if (*we == separator)
|
||||
{
|
||||
out->push_back(ImGuiTextRange(wb, we));
|
||||
out->push_back(ImStrv(wb, we));
|
||||
wb = we + 1;
|
||||
}
|
||||
we++;
|
||||
}
|
||||
if (wb != we)
|
||||
out->push_back(ImGuiTextRange(wb, we));
|
||||
out->push_back(ImStrv(wb, we));
|
||||
}
|
||||
|
||||
void ImGuiTextFilter::Build()
|
||||
{
|
||||
Filters.resize(0);
|
||||
ImGuiTextRange input_range(InputBuf, InputBuf + strlen(InputBuf));
|
||||
input_range.split(',', &Filters);
|
||||
ImStrplit(ImStrv(InputBuf, InputBuf + strlen(InputBuf)), ',', &Filters);
|
||||
|
||||
CountGrep = 0;
|
||||
for (int i = 0; i != Filters.Size; i++)
|
||||
{
|
||||
ImGuiTextRange& f = Filters[i];
|
||||
while (f.b < f.e && ImCharIsBlankA(f.b[0]))
|
||||
f.b++;
|
||||
while (f.e > f.b && ImCharIsBlankA(f.e[-1]))
|
||||
f.e--;
|
||||
ImStrv& f = Filters[i];
|
||||
while (f.Begin < f.End && ImCharIsBlankA(f.Begin[0]))
|
||||
f.Begin++;
|
||||
while (f.End > f.Begin && ImCharIsBlankA(f.End[-1]))
|
||||
f.End--;
|
||||
if (f.empty())
|
||||
continue;
|
||||
if (Filters[i].b[0] != '-')
|
||||
if (Filters[i].Begin[0] != '-')
|
||||
CountGrep += 1;
|
||||
}
|
||||
}
|
||||
|
||||
bool ImGuiTextFilter::PassFilter(const char* text, const char* text_end) const
|
||||
bool ImGuiTextFilter::PassFilter(ImStrv text) const
|
||||
{
|
||||
if (Filters.empty())
|
||||
return true;
|
||||
|
||||
if (text == NULL)
|
||||
if (!text)
|
||||
text = "";
|
||||
|
||||
for (int i = 0; i != Filters.Size; i++)
|
||||
{
|
||||
const ImGuiTextRange& f = Filters[i];
|
||||
const ImStrv& f = Filters[i];
|
||||
if (f.empty())
|
||||
continue;
|
||||
if (f.b[0] == '-')
|
||||
if (f.Begin[0] == '-')
|
||||
{
|
||||
// Subtract
|
||||
if (ImStristr(text, text_end, f.b + 1, f.e) != NULL)
|
||||
if (ImStristr(text.Begin, text.End, f.Begin + 1, f.End) != NULL)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Grep
|
||||
if (ImStristr(text, text_end, f.b, f.e) != NULL)
|
||||
if (ImStristr(text.Begin, text.End, f.Begin, f.End) != NULL)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -2354,9 +2411,11 @@ bool ImGuiTextFilter::PassFilter(const char* text, const char* text_end) const
|
||||
|
||||
char ImGuiTextBuffer::EmptyString[1] = { 0 };
|
||||
|
||||
void ImGuiTextBuffer::append(const char* str, const char* str_end)
|
||||
void ImGuiTextBuffer::append(ImStrv str)
|
||||
{
|
||||
int len = str_end ? (int)(str_end - str) : (int)strlen(str);
|
||||
int len = (int)str.length();
|
||||
if (len == 0)
|
||||
return;
|
||||
|
||||
// Add zero-terminator the first time
|
||||
const int write_off = (Buf.Size != 0) ? Buf.Size : 1;
|
||||
@ -2368,7 +2427,7 @@ void ImGuiTextBuffer::append(const char* str, const char* str_end)
|
||||
}
|
||||
|
||||
Buf.resize(needed_sz);
|
||||
memcpy(&Buf[write_off - 1], str, (size_t)len);
|
||||
memcpy(&Buf[write_off - 1], str.Begin, (size_t)len);
|
||||
Buf[write_off - 1 + len] = 0;
|
||||
}
|
||||
|
||||
@ -2957,68 +3016,53 @@ const char* ImGui::GetStyleColorName(ImGuiCol idx)
|
||||
// Also see imgui_draw.cpp for some more which have been reworked to not rely on ImGui:: context.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
const char* ImGui::FindRenderedTextEnd(const char* text, const char* text_end)
|
||||
const char* ImGui::FindRenderedTextEnd(ImStrv text)
|
||||
{
|
||||
const char* text_display_end = text;
|
||||
if (!text_end)
|
||||
text_end = (const char*)-1;
|
||||
|
||||
while (text_display_end < text_end && *text_display_end != '\0' && (text_display_end[0] != '#' || text_display_end[1] != '#'))
|
||||
const char* text_display_end = text.Begin;
|
||||
while (text_display_end < text.End && (text_display_end[0] != '#' || text_display_end[1] != '#'))
|
||||
text_display_end++;
|
||||
return text_display_end;
|
||||
}
|
||||
|
||||
// Internal ImGui functions to render text
|
||||
// RenderText***() functions calls ImDrawList::AddText() calls ImBitmapFont::RenderText()
|
||||
void ImGui::RenderText(ImVec2 pos, const char* text, const char* text_end, bool hide_text_after_hash)
|
||||
void ImGui::RenderText(ImVec2 pos, ImStrv text, bool hide_text_after_hash)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
|
||||
// Hide anything after a '##' string
|
||||
const char* text_display_end;
|
||||
if (hide_text_after_hash)
|
||||
{
|
||||
text_display_end = FindRenderedTextEnd(text, text_end);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!text_end)
|
||||
text_end = text + strlen(text); // FIXME-OPT
|
||||
text_display_end = text_end;
|
||||
}
|
||||
text.End = FindRenderedTextEnd(text);
|
||||
|
||||
if (text != text_display_end)
|
||||
if (text.Begin != text.End)
|
||||
{
|
||||
window->DrawList->AddText(g.Font, g.FontSize, pos, GetColorU32(ImGuiCol_Text), text, text_display_end);
|
||||
window->DrawList->AddText(g.Font, g.FontSize, pos, GetColorU32(ImGuiCol_Text), text);
|
||||
if (g.LogEnabled)
|
||||
LogRenderedText(&pos, text, text_display_end);
|
||||
LogRenderedText(&pos, text);
|
||||
}
|
||||
}
|
||||
|
||||
void ImGui::RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end, float wrap_width)
|
||||
void ImGui::RenderTextWrapped(ImVec2 pos, ImStrv text, float wrap_width)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
|
||||
if (!text_end)
|
||||
text_end = text + strlen(text); // FIXME-OPT
|
||||
|
||||
if (text != text_end)
|
||||
if (text.Begin != text.End)
|
||||
{
|
||||
window->DrawList->AddText(g.Font, g.FontSize, pos, GetColorU32(ImGuiCol_Text), text, text_end, wrap_width);
|
||||
window->DrawList->AddText(g.Font, g.FontSize, pos, GetColorU32(ImGuiCol_Text), text, wrap_width);
|
||||
if (g.LogEnabled)
|
||||
LogRenderedText(&pos, text, text_end);
|
||||
LogRenderedText(&pos, text);
|
||||
}
|
||||
}
|
||||
|
||||
// Default clip_rect uses (pos_min,pos_max)
|
||||
// Handle clipping on CPU immediately (vs typically let the GPU clip the triangles that are overlapping the clipping rectangle edges)
|
||||
void ImGui::RenderTextClippedEx(ImDrawList* draw_list, const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_display_end, const ImVec2* text_size_if_known, const ImVec2& align, const ImRect* clip_rect)
|
||||
void ImGui::RenderTextClippedEx(ImDrawList* draw_list, const ImVec2& pos_min, const ImVec2& pos_max, ImStrv text, const ImVec2* text_size_if_known, const ImVec2& align, const ImRect* clip_rect)
|
||||
{
|
||||
// Perform CPU side clipping for single clipped element to avoid using scissor state
|
||||
ImVec2 pos = pos_min;
|
||||
const ImVec2 text_size = text_size_if_known ? *text_size_if_known : CalcTextSize(text, text_display_end, false, 0.0f);
|
||||
const ImVec2 text_size = text_size_if_known ? *text_size_if_known : CalcTextSize(text, false, 0.0f);
|
||||
|
||||
const ImVec2* clip_min = clip_rect ? &clip_rect->Min : &pos_min;
|
||||
const ImVec2* clip_max = clip_rect ? &clip_rect->Max : &pos_max;
|
||||
@ -3034,39 +3078,36 @@ void ImGui::RenderTextClippedEx(ImDrawList* draw_list, const ImVec2& pos_min, co
|
||||
if (need_clipping)
|
||||
{
|
||||
ImVec4 fine_clip_rect(clip_min->x, clip_min->y, clip_max->x, clip_max->y);
|
||||
draw_list->AddText(NULL, 0.0f, pos, GetColorU32(ImGuiCol_Text), text, text_display_end, 0.0f, &fine_clip_rect);
|
||||
draw_list->AddText(NULL, 0.0f, pos, GetColorU32(ImGuiCol_Text), text, 0.0f, &fine_clip_rect);
|
||||
}
|
||||
else
|
||||
{
|
||||
draw_list->AddText(NULL, 0.0f, pos, GetColorU32(ImGuiCol_Text), text, text_display_end, 0.0f, NULL);
|
||||
draw_list->AddText(NULL, 0.0f, pos, GetColorU32(ImGuiCol_Text), text, 0.0f, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void ImGui::RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, const ImVec2& align, const ImRect* clip_rect)
|
||||
void ImGui::RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, ImStrv text, const ImVec2* text_size_if_known, const ImVec2& align, const ImRect* clip_rect)
|
||||
{
|
||||
// Hide anything after a '##' string
|
||||
const char* text_display_end = FindRenderedTextEnd(text, text_end);
|
||||
const int text_len = (int)(text_display_end - text);
|
||||
if (text_len == 0)
|
||||
// FIXME-IMSTR: This is not new but should be moved out of there.
|
||||
text.End = FindRenderedTextEnd(text);
|
||||
if (text.Begin == text.End)
|
||||
return;
|
||||
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
RenderTextClippedEx(window->DrawList, pos_min, pos_max, text, text_display_end, text_size_if_known, align, clip_rect);
|
||||
RenderTextClippedEx(window->DrawList, pos_min, pos_max, text, text_size_if_known, align, clip_rect);
|
||||
if (g.LogEnabled)
|
||||
LogRenderedText(&pos_min, text, text_display_end);
|
||||
LogRenderedText(&pos_min, text);
|
||||
}
|
||||
|
||||
|
||||
// Another overly complex function until we reorganize everything into a nice all-in-one helper.
|
||||
// This is made more complex because we have dissociated the layout rectangle (pos_min..pos_max) which define _where_ the ellipsis is, from actual clipping of text and limit of the ellipsis display.
|
||||
// This is because in the context of tabs we selectively hide part of the text when the Close Button appears, but we don't want the ellipsis to move.
|
||||
void ImGui::RenderTextEllipsis(ImDrawList* draw_list, const ImVec2& pos_min, const ImVec2& pos_max, float clip_max_x, float ellipsis_max_x, const char* text, const char* text_end_full, const ImVec2* text_size_if_known)
|
||||
void ImGui::RenderTextEllipsis(ImDrawList* draw_list, const ImVec2& pos_min, const ImVec2& pos_max, float clip_max_x, float ellipsis_max_x, ImStrv text, const ImVec2* text_size_if_known)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (text_end_full == NULL)
|
||||
text_end_full = FindRenderedTextEnd(text);
|
||||
const ImVec2 text_size = text_size_if_known ? *text_size_if_known : CalcTextSize(text, text_end_full, false, 0.0f);
|
||||
const ImVec2 text_size = text_size_if_known ? *text_size_if_known : CalcTextSize(text, false, 0.0f);
|
||||
|
||||
//draw_list->AddLine(ImVec2(pos_max.x, pos_min.y - 4), ImVec2(pos_max.x, pos_max.y + 4), IM_COL32(0, 0, 255, 255));
|
||||
//draw_list->AddLine(ImVec2(ellipsis_max_x, pos_min.y-2), ImVec2(ellipsis_max_x, pos_max.y+2), IM_COL32(0, 255, 0, 255));
|
||||
@ -3105,22 +3146,22 @@ void ImGui::RenderTextEllipsis(ImDrawList* draw_list, const ImVec2& pos_min, con
|
||||
|
||||
// We can now claim the space between pos_max.x and ellipsis_max.x
|
||||
const float text_avail_width = ImMax((ImMax(pos_max.x, ellipsis_max_x) - ellipsis_total_width) - pos_min.x, 1.0f);
|
||||
float text_size_clipped_x = font->CalcTextSizeA(font_size, text_avail_width, 0.0f, text, text_end_full, &text_end_ellipsis).x;
|
||||
if (text == text_end_ellipsis && text_end_ellipsis < text_end_full)
|
||||
float text_size_clipped_x = font->CalcTextSizeA(font_size, text_avail_width, 0.0f, text, &text_end_ellipsis).x;
|
||||
if (text.Begin == text_end_ellipsis && text_end_ellipsis < text.End)
|
||||
{
|
||||
// Always display at least 1 character if there's no room for character + ellipsis
|
||||
text_end_ellipsis = text + ImTextCountUtf8BytesFromChar(text, text_end_full);
|
||||
text_size_clipped_x = font->CalcTextSizeA(font_size, FLT_MAX, 0.0f, text, text_end_ellipsis).x;
|
||||
text_end_ellipsis = text.Begin + ImTextCountUtf8BytesFromChar(text);
|
||||
text_size_clipped_x = font->CalcTextSizeA(font_size, FLT_MAX, 0.0f, ImStrv(text.Begin, text_end_ellipsis)).x;
|
||||
}
|
||||
while (text_end_ellipsis > text && ImCharIsBlankA(text_end_ellipsis[-1]))
|
||||
while (text_end_ellipsis > text.Begin && ImCharIsBlankA(text_end_ellipsis[-1]))
|
||||
{
|
||||
// Trim trailing space before ellipsis (FIXME: Supporting non-ascii blanks would be nice, for this we need a function to backtrack in UTF-8 text)
|
||||
text_end_ellipsis--;
|
||||
text_size_clipped_x -= font->CalcTextSizeA(font_size, FLT_MAX, 0.0f, text_end_ellipsis, text_end_ellipsis + 1).x; // Ascii blanks are always 1 byte
|
||||
text_size_clipped_x -= font->CalcTextSizeA(font_size, FLT_MAX, 0.0f, ImStrv(text_end_ellipsis, text_end_ellipsis + 1)).x; // Ascii blanks are always 1 byte
|
||||
}
|
||||
|
||||
// Render text, render ellipsis
|
||||
RenderTextClippedEx(draw_list, pos_min, ImVec2(clip_max_x, pos_max.y), text, text_end_ellipsis, &text_size, ImVec2(0.0f, 0.0f));
|
||||
RenderTextClippedEx(draw_list, pos_min, ImVec2(clip_max_x, pos_max.y), ImStrv(text.Begin, text_end_ellipsis), &text_size, ImVec2(0.0f, 0.0f));
|
||||
float ellipsis_x = pos_min.x + text_size_clipped_x;
|
||||
if (ellipsis_x + ellipsis_total_width <= ellipsis_max_x)
|
||||
for (int i = 0; i < ellipsis_char_count; i++)
|
||||
@ -3131,11 +3172,11 @@ void ImGui::RenderTextEllipsis(ImDrawList* draw_list, const ImVec2& pos_min, con
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderTextClippedEx(draw_list, pos_min, ImVec2(clip_max_x, pos_max.y), text, text_end_full, &text_size, ImVec2(0.0f, 0.0f));
|
||||
RenderTextClippedEx(draw_list, pos_min, ImVec2(clip_max_x, pos_max.y), text, &text_size, ImVec2(0.0f, 0.0f));
|
||||
}
|
||||
|
||||
if (g.LogEnabled)
|
||||
LogRenderedText(&pos_min, text, text_end_full);
|
||||
LogRenderedText(&pos_min, text);
|
||||
}
|
||||
|
||||
// Render a rectangle shaped with optional rounding and borders
|
||||
@ -3227,11 +3268,11 @@ void ImGui::RenderMouseCursor(ImVec2 base_pos, float base_scale, ImGuiMouseCurso
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// ImGuiWindow is mostly a dumb struct. It merely has a constructor and a few helper methods
|
||||
ImGuiWindow::ImGuiWindow(ImGuiContext* context, const char* name) : DrawListInst(NULL)
|
||||
ImGuiWindow::ImGuiWindow(ImGuiContext* context, ImStrv name) : DrawListInst(NULL)
|
||||
{
|
||||
memset(this, 0, sizeof(*this));
|
||||
Name = ImStrdup(name);
|
||||
NameBufLen = (int)strlen(name) + 1;
|
||||
NameBufLen = (int)name.length() + 1;
|
||||
ID = ImHashStr(name);
|
||||
IDStack.push_back(ID);
|
||||
MoveId = GetID("#MOVE");
|
||||
@ -3257,14 +3298,14 @@ ImGuiWindow::~ImGuiWindow()
|
||||
ColumnsStorage.clear_destruct();
|
||||
}
|
||||
|
||||
ImGuiID ImGuiWindow::GetID(const char* str, const char* str_end)
|
||||
ImGuiID ImGuiWindow::GetID(ImStrv str)
|
||||
{
|
||||
ImGuiID seed = IDStack.back();
|
||||
ImGuiID id = ImHashStr(str, str_end ? (str_end - str) : 0, seed);
|
||||
ImGuiID id = ImHashStr(str, seed);
|
||||
ImGui::KeepAliveID(id);
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (g.DebugHookIdInfo == id)
|
||||
ImGui::DebugHookIdInfo(id, ImGuiDataType_String, str, str_end);
|
||||
ImGui::DebugHookIdInfo(id, ImGuiDataType_String, str.Begin, str.End);
|
||||
return id;
|
||||
}
|
||||
|
||||
@ -3290,13 +3331,13 @@ ImGuiID ImGuiWindow::GetID(int n)
|
||||
return id;
|
||||
}
|
||||
|
||||
ImGuiID ImGuiWindow::GetIDNoKeepAlive(const char* str, const char* str_end)
|
||||
ImGuiID ImGuiWindow::GetIDNoKeepAlive(ImStrv str)
|
||||
{
|
||||
ImGuiID seed = IDStack.back();
|
||||
ImGuiID id = ImHashStr(str, str_end ? (str_end - str) : 0, seed);
|
||||
ImGuiID id = ImHashStr(str, seed);
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (g.DebugHookIdInfo == id)
|
||||
ImGui::DebugHookIdInfo(id, ImGuiDataType_String, str, str_end);
|
||||
ImGui::DebugHookIdInfo(id, ImGuiDataType_String, str.Begin, str.End);
|
||||
return id;
|
||||
}
|
||||
|
||||
@ -3648,11 +3689,19 @@ const char* ImGui::GetClipboardText()
|
||||
return g.IO.GetClipboardTextFn ? g.IO.GetClipboardTextFn(g.IO.ClipboardUserData) : "";
|
||||
}
|
||||
|
||||
void ImGui::SetClipboardText(const char* text)
|
||||
void ImGui::SetClipboardText(ImStrv text)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (g.IO.SetClipboardTextFn)
|
||||
g.IO.SetClipboardTextFn(g.IO.ClipboardUserData, text);
|
||||
{
|
||||
int len = (int)text.length();
|
||||
char* text_p = (char*)IM_ALLOC(len + 1);
|
||||
if (len > 0)
|
||||
memcpy(text_p, text.Begin, len);
|
||||
text_p[len] = 0; // text may not contain \0, it must be inserted manually.
|
||||
g.IO.SetClipboardTextFn(g.IO.ClipboardUserData, text_p);
|
||||
IM_FREE(text_p);
|
||||
}
|
||||
}
|
||||
|
||||
const char* ImGui::GetVersion()
|
||||
@ -4945,21 +4994,18 @@ void ImGui::Render()
|
||||
|
||||
// Calculate text size. Text can be multi-line. Optionally ignore text after a ## marker.
|
||||
// CalcTextSize("") should return ImVec2(0.0f, g.FontSize)
|
||||
ImVec2 ImGui::CalcTextSize(const char* text, const char* text_end, bool hide_text_after_double_hash, float wrap_width)
|
||||
ImVec2 ImGui::CalcTextSize(ImStrv text, bool hide_text_after_double_hash, float wrap_width)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
||||
const char* text_display_end;
|
||||
if (hide_text_after_double_hash)
|
||||
text_display_end = FindRenderedTextEnd(text, text_end); // Hide anything after a '##' string
|
||||
else
|
||||
text_display_end = text_end;
|
||||
text.End = FindRenderedTextEnd(text); // Hide anything after a '##' string
|
||||
|
||||
ImFont* font = g.Font;
|
||||
const float font_size = g.FontSize;
|
||||
if (text == text_display_end)
|
||||
if (text.Begin == text.End)
|
||||
return ImVec2(0.0f, font_size);
|
||||
ImVec2 text_size = font->CalcTextSizeA(font_size, FLT_MAX, wrap_width, text, text_display_end, NULL);
|
||||
ImVec2 text_size = font->CalcTextSizeA(font_size, FLT_MAX, wrap_width, text, NULL);
|
||||
|
||||
// Round
|
||||
// FIXME: This has been here since Dec 2015 (7b0bf230) but down the line we want this out.
|
||||
@ -5166,7 +5212,7 @@ ImVec2 ImGui::GetItemRectSize()
|
||||
return g.LastItemData.Rect.GetSize();
|
||||
}
|
||||
|
||||
bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags flags)
|
||||
bool ImGui::BeginChildEx(ImStrv name, ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags flags)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* parent_window = g.CurrentWindow;
|
||||
@ -5186,7 +5232,7 @@ bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, b
|
||||
|
||||
// Build up name. If you need to append to a same child from multiple location in the ID stack, use BeginChild(ImGuiID id) with a stable value.
|
||||
if (name)
|
||||
ImFormatString(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), "%s/%s_%08X", parent_window->Name, name, id);
|
||||
ImFormatString(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), "%s/%.*s_%08X", parent_window->Name, (int)name.length(), name.Begin, id);
|
||||
else
|
||||
ImFormatString(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), "%s/%08X", parent_window->Name, id);
|
||||
|
||||
@ -5216,7 +5262,7 @@ bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, b
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool ImGui::BeginChild(const char* str_id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags)
|
||||
bool ImGui::BeginChild(ImStrv str_id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags)
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
return BeginChildEx(str_id, window->GetID(str_id), size_arg, border, extra_flags);
|
||||
@ -5307,7 +5353,7 @@ ImGuiWindow* ImGui::FindWindowByID(ImGuiID id)
|
||||
return (ImGuiWindow*)g.WindowsById.GetVoidPtr(id);
|
||||
}
|
||||
|
||||
ImGuiWindow* ImGui::FindWindowByName(const char* name)
|
||||
ImGuiWindow* ImGui::FindWindowByName(ImStrv name)
|
||||
{
|
||||
ImGuiID id = ImHashStr(name);
|
||||
return FindWindowByID(id);
|
||||
@ -5344,7 +5390,7 @@ static void UpdateWindowInFocusOrderList(ImGuiWindow* window, bool just_created,
|
||||
window->IsExplicitChild = new_is_explicit_child;
|
||||
}
|
||||
|
||||
static ImGuiWindow* CreateNewWindow(const char* name, ImGuiWindowFlags flags)
|
||||
static ImGuiWindow* CreateNewWindow(ImStrv name, ImGuiWindowFlags flags)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
//IMGUI_DEBUG_LOG("CreateNewWindow '%s', flags = 0x%08X\n", name, flags);
|
||||
@ -5833,7 +5879,7 @@ void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar
|
||||
}
|
||||
|
||||
// Render title text, collapse button, close button
|
||||
void ImGui::RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& title_bar_rect, const char* name, bool* p_open)
|
||||
void ImGui::RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& title_bar_rect, ImStrv name, bool* p_open)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiStyle& style = g.Style;
|
||||
@ -5887,7 +5933,7 @@ void ImGui::RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& titl
|
||||
// Title bar text (with: horizontal alignment, avoiding collapse/close button, optional "unsaved document" marker)
|
||||
// FIXME: Refactor text alignment facilities along with RenderText helpers, this is WAY too much messy code..
|
||||
const float marker_size_x = (flags & ImGuiWindowFlags_UnsavedDocument) ? button_sz * 0.80f : 0.0f;
|
||||
const ImVec2 text_size = CalcTextSize(name, NULL, true) + ImVec2(marker_size_x, 0.0f);
|
||||
const ImVec2 text_size = CalcTextSize(name, true) + ImVec2(marker_size_x, 0.0f);
|
||||
|
||||
// As a nice touch we try to ensure that centered title text doesn't get affected by visibility of Close/Collapse button,
|
||||
// while uncentered title text will still reach edges correctly.
|
||||
@ -5918,7 +5964,7 @@ void ImGui::RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& titl
|
||||
}
|
||||
//if (g.IO.KeyShift) window->DrawList->AddRect(layout_r.Min, layout_r.Max, IM_COL32(255, 128, 0, 255)); // [DEBUG]
|
||||
//if (g.IO.KeyCtrl) window->DrawList->AddRect(clip_r.Min, clip_r.Max, IM_COL32(255, 128, 0, 255)); // [DEBUG]
|
||||
RenderTextClipped(layout_r.Min, layout_r.Max, name, NULL, &text_size, style.WindowTitleAlign, &clip_r);
|
||||
RenderTextClipped(layout_r.Min, layout_r.Max, name, &text_size, style.WindowTitleAlign, &clip_r);
|
||||
}
|
||||
|
||||
void ImGui::UpdateWindowParentAndRootLinks(ImGuiWindow* window, ImGuiWindowFlags flags, ImGuiWindow* parent_window)
|
||||
@ -5977,11 +6023,11 @@ static ImGuiWindow* ImGui::FindBlockingModal(ImGuiWindow* window)
|
||||
// You can use the "##" or "###" markers to use the same label with different id, or same id with different label. See documentation at the top of this file.
|
||||
// - Return false when window is collapsed, so you can early out in your code. You always need to call ImGui::End() even if false is returned.
|
||||
// - Passing 'bool* p_open' displays a Close button on the upper-right corner of the window, the pointed value will be set to false when the button is pressed.
|
||||
bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
bool ImGui::Begin(ImStrv name, bool* p_open, ImGuiWindowFlags flags)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
const ImGuiStyle& style = g.Style;
|
||||
IM_ASSERT(name != NULL && name[0] != '\0'); // Window name required
|
||||
IM_ASSERT(name.Begin != name.End); // Window name required
|
||||
IM_ASSERT(g.WithinFrameScope); // Forgot to call ImGui::NewFrame()
|
||||
IM_ASSERT(g.FrameCountEnded != g.FrameCount); // Called ImGui::Render() or ImGui::EndFrame() and haven't called ImGui::NewFrame() again yet
|
||||
|
||||
@ -6138,7 +6184,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
bool window_title_visible_elsewhere = false;
|
||||
if (g.NavWindowingListWindow != NULL && (window->Flags & ImGuiWindowFlags_NoNavFocus) == 0) // Window titles visible when using CTRL+TAB
|
||||
window_title_visible_elsewhere = true;
|
||||
if (window_title_visible_elsewhere && !window_just_created && strcmp(name, window->Name) != 0)
|
||||
if (window_title_visible_elsewhere && !window_just_created && ImStrcmp(name, window->Name) != 0)
|
||||
{
|
||||
size_t buf_len = (size_t)window->NameBufLen;
|
||||
window->Name = ImStrdupcpy(window->Name, &buf_len, name);
|
||||
@ -7124,7 +7170,7 @@ void ImGui::SetWindowPos(const ImVec2& pos, ImGuiCond cond)
|
||||
SetWindowPos(window, pos, cond);
|
||||
}
|
||||
|
||||
void ImGui::SetWindowPos(const char* name, const ImVec2& pos, ImGuiCond cond)
|
||||
void ImGui::SetWindowPos(ImStrv name, const ImVec2& pos, ImGuiCond cond)
|
||||
{
|
||||
if (ImGuiWindow* window = FindWindowByName(name))
|
||||
SetWindowPos(window, pos, cond);
|
||||
@ -7173,7 +7219,7 @@ void ImGui::SetWindowSize(const ImVec2& size, ImGuiCond cond)
|
||||
SetWindowSize(GImGui->CurrentWindow, size, cond);
|
||||
}
|
||||
|
||||
void ImGui::SetWindowSize(const char* name, const ImVec2& size, ImGuiCond cond)
|
||||
void ImGui::SetWindowSize(ImStrv name, const ImVec2& size, ImGuiCond cond)
|
||||
{
|
||||
if (ImGuiWindow* window = FindWindowByName(name))
|
||||
SetWindowSize(window, size, cond);
|
||||
@ -7214,7 +7260,7 @@ bool ImGui::IsWindowAppearing()
|
||||
return window->Appearing;
|
||||
}
|
||||
|
||||
void ImGui::SetWindowCollapsed(const char* name, bool collapsed, ImGuiCond cond)
|
||||
void ImGui::SetWindowCollapsed(ImStrv name, bool collapsed, ImGuiCond cond)
|
||||
{
|
||||
if (ImGuiWindow* window = FindWindowByName(name))
|
||||
SetWindowCollapsed(window, collapsed, cond);
|
||||
@ -7225,7 +7271,7 @@ void ImGui::SetWindowFocus()
|
||||
FocusWindow(GImGui->CurrentWindow);
|
||||
}
|
||||
|
||||
void ImGui::SetWindowFocus(const char* name)
|
||||
void ImGui::SetWindowFocus(ImStrv name)
|
||||
{
|
||||
if (name)
|
||||
{
|
||||
@ -7408,7 +7454,7 @@ ImGuiStorage* ImGui::GetStateStorage()
|
||||
return window->DC.StateStorage;
|
||||
}
|
||||
|
||||
void ImGui::PushID(const char* str_id)
|
||||
void ImGui::PushID(ImStrv str_id)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
@ -7416,14 +7462,6 @@ void ImGui::PushID(const char* str_id)
|
||||
window->IDStack.push_back(id);
|
||||
}
|
||||
|
||||
void ImGui::PushID(const char* str_id_begin, const char* str_id_end)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
ImGuiID id = window->GetIDNoKeepAlive(str_id_begin, str_id_end);
|
||||
window->IDStack.push_back(id);
|
||||
}
|
||||
|
||||
void ImGui::PushID(const void* ptr_id)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
@ -7470,18 +7508,12 @@ void ImGui::PopID()
|
||||
window->IDStack.pop_back();
|
||||
}
|
||||
|
||||
ImGuiID ImGui::GetID(const char* str_id)
|
||||
ImGuiID ImGui::GetID(ImStrv str_id)
|
||||
{
|
||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||
return window->GetID(str_id);
|
||||
}
|
||||
|
||||
ImGuiID ImGui::GetID(const char* str_id_begin, const char* str_id_end)
|
||||
{
|
||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||
return window->GetID(str_id_begin, str_id_end);
|
||||
}
|
||||
|
||||
ImGuiID ImGui::GetID(const void* ptr_id)
|
||||
{
|
||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||
@ -7960,16 +7992,16 @@ void ImGui::UpdateInputEvents(bool trickle_fast_inputs)
|
||||
// If the user has inconsistent compilation settings, imgui configuration #define, packing pragma, etc. your user code
|
||||
// may see different structures than what imgui.cpp sees, which is problematic.
|
||||
// We usually require settings to be in imconfig.h to make sure that they are accessible to all compilation units involved with Dear ImGui.
|
||||
bool ImGui::DebugCheckVersionAndDataLayout(const char* version, size_t sz_io, size_t sz_style, size_t sz_vec2, size_t sz_vec4, size_t sz_vert, size_t sz_idx)
|
||||
bool ImGui::DebugCheckVersionAndDataLayout(ImStrv version, size_t sz_io, size_t sz_style, size_t sz_vec2, size_t sz_vec4, size_t sz_vert, size_t sz_idx)
|
||||
{
|
||||
bool error = false;
|
||||
if (strcmp(version, IMGUI_VERSION) != 0) { error = true; IM_ASSERT(strcmp(version, IMGUI_VERSION) == 0 && "Mismatched version string!"); }
|
||||
if (sz_io != sizeof(ImGuiIO)) { error = true; IM_ASSERT(sz_io == sizeof(ImGuiIO) && "Mismatched struct layout!"); }
|
||||
if (sz_style != sizeof(ImGuiStyle)) { error = true; IM_ASSERT(sz_style == sizeof(ImGuiStyle) && "Mismatched struct layout!"); }
|
||||
if (sz_vec2 != sizeof(ImVec2)) { error = true; IM_ASSERT(sz_vec2 == sizeof(ImVec2) && "Mismatched struct layout!"); }
|
||||
if (sz_vec4 != sizeof(ImVec4)) { error = true; IM_ASSERT(sz_vec4 == sizeof(ImVec4) && "Mismatched struct layout!"); }
|
||||
if (sz_vert != sizeof(ImDrawVert)) { error = true; IM_ASSERT(sz_vert == sizeof(ImDrawVert) && "Mismatched struct layout!"); }
|
||||
if (sz_idx != sizeof(ImDrawIdx)) { error = true; IM_ASSERT(sz_idx == sizeof(ImDrawIdx) && "Mismatched struct layout!"); }
|
||||
if (ImStrcmp(version, IMGUI_VERSION) != 0) { error = true; IM_ASSERT(0 && "Mismatched version string!"); }
|
||||
if (sz_io != sizeof(ImGuiIO)) { error = true; IM_ASSERT(sz_io == sizeof(ImGuiIO) && "Mismatched struct layout!"); }
|
||||
if (sz_style != sizeof(ImGuiStyle)) { error = true; IM_ASSERT(sz_style == sizeof(ImGuiStyle) && "Mismatched struct layout!"); }
|
||||
if (sz_vec2 != sizeof(ImVec2)) { error = true; IM_ASSERT(sz_vec2 == sizeof(ImVec2) && "Mismatched struct layout!"); }
|
||||
if (sz_vec4 != sizeof(ImVec4)) { error = true; IM_ASSERT(sz_vec4 == sizeof(ImVec4) && "Mismatched struct layout!"); }
|
||||
if (sz_vert != sizeof(ImDrawVert)) { error = true; IM_ASSERT(sz_vert == sizeof(ImDrawVert) && "Mismatched struct layout!"); }
|
||||
if (sz_idx != sizeof(ImDrawIdx)) { error = true; IM_ASSERT(sz_idx == sizeof(ImDrawIdx) && "Mismatched struct layout!"); }
|
||||
return !error;
|
||||
}
|
||||
|
||||
@ -9014,7 +9046,7 @@ bool ImGui::IsPopupOpen(ImGuiID id, ImGuiPopupFlags popup_flags)
|
||||
}
|
||||
}
|
||||
|
||||
bool ImGui::IsPopupOpen(const char* str_id, ImGuiPopupFlags popup_flags)
|
||||
bool ImGui::IsPopupOpen(ImStrv str_id, ImGuiPopupFlags popup_flags)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiID id = (popup_flags & ImGuiPopupFlags_AnyPopupId) ? 0 : g.CurrentWindow->GetID(str_id);
|
||||
@ -9043,7 +9075,7 @@ ImGuiWindow* ImGui::GetTopMostAndVisiblePopupModal()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void ImGui::OpenPopup(const char* str_id, ImGuiPopupFlags popup_flags)
|
||||
void ImGui::OpenPopup(ImStrv str_id, ImGuiPopupFlags popup_flags)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
OpenPopupEx(g.CurrentWindow->GetID(str_id), popup_flags);
|
||||
@ -9248,7 +9280,7 @@ bool ImGui::BeginPopupEx(ImGuiID id, ImGuiWindowFlags flags)
|
||||
return is_open;
|
||||
}
|
||||
|
||||
bool ImGui::BeginPopup(const char* str_id, ImGuiWindowFlags flags)
|
||||
bool ImGui::BeginPopup(ImStrv str_id, ImGuiWindowFlags flags)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (g.OpenPopupStack.Size <= g.BeginPopupStack.Size) // Early out for performance
|
||||
@ -9263,7 +9295,7 @@ bool ImGui::BeginPopup(const char* str_id, ImGuiWindowFlags flags)
|
||||
|
||||
// If 'p_open' is specified for a modal popup window, the popup will have a regular close button which will close the popup.
|
||||
// Note that popup visibility status is owned by Dear ImGui (and manipulated with e.g. OpenPopup) so the actual value of *p_open is meaningless here.
|
||||
bool ImGui::BeginPopupModal(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
bool ImGui::BeginPopupModal(ImStrv name, bool* p_open, ImGuiWindowFlags flags)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
@ -9316,7 +9348,7 @@ void ImGui::EndPopup()
|
||||
|
||||
// Helper to open a popup if mouse button is released over the item
|
||||
// - This is essentially the same as BeginPopupContextItem() but without the trailing BeginPopup()
|
||||
void ImGui::OpenPopupOnItemClick(const char* str_id, ImGuiPopupFlags popup_flags)
|
||||
void ImGui::OpenPopupOnItemClick(ImStrv str_id, ImGuiPopupFlags popup_flags)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
@ -9345,7 +9377,7 @@ void ImGui::OpenPopupOnItemClick(const char* str_id, ImGuiPopupFlags popup_flags
|
||||
// OpenPopup(id);
|
||||
// return BeginPopup(id);
|
||||
// The main difference being that this is tweaked to avoid computing the ID twice.
|
||||
bool ImGui::BeginPopupContextItem(const char* str_id, ImGuiPopupFlags popup_flags)
|
||||
bool ImGui::BeginPopupContextItem(ImStrv str_id, ImGuiPopupFlags popup_flags)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
@ -9359,7 +9391,7 @@ bool ImGui::BeginPopupContextItem(const char* str_id, ImGuiPopupFlags popup_flag
|
||||
return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings);
|
||||
}
|
||||
|
||||
bool ImGui::BeginPopupContextWindow(const char* str_id, ImGuiPopupFlags popup_flags)
|
||||
bool ImGui::BeginPopupContextWindow(ImStrv str_id, ImGuiPopupFlags popup_flags)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
@ -9373,7 +9405,7 @@ bool ImGui::BeginPopupContextWindow(const char* str_id, ImGuiPopupFlags popup_fl
|
||||
return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings);
|
||||
}
|
||||
|
||||
bool ImGui::BeginPopupContextVoid(const char* str_id, ImGuiPopupFlags popup_flags)
|
||||
bool ImGui::BeginPopupContextVoid(ImStrv str_id, ImGuiPopupFlags popup_flags)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
@ -11114,15 +11146,15 @@ void ImGui::EndDragDropSource()
|
||||
}
|
||||
|
||||
// Use 'cond' to choose to submit payload on drag start or every frame
|
||||
bool ImGui::SetDragDropPayload(const char* type, const void* data, size_t data_size, ImGuiCond cond)
|
||||
bool ImGui::SetDragDropPayload(ImStrv type, const void* data, size_t data_size, ImGuiCond cond)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiPayload& payload = g.DragDropPayload;
|
||||
if (cond == 0)
|
||||
cond = ImGuiCond_Always;
|
||||
|
||||
IM_ASSERT(type != NULL);
|
||||
IM_ASSERT(strlen(type) < IM_ARRAYSIZE(payload.DataType) && "Payload type can be at most 32 characters long");
|
||||
IM_ASSERT(type.End - type.Begin > 0 && "Payload type can not be empty");
|
||||
IM_ASSERT(type.End - type.Begin < IM_ARRAYSIZE(payload.DataType) && "Payload type can be at most 32 characters long");
|
||||
IM_ASSERT((data != NULL && data_size > 0) || (data == NULL && data_size == 0));
|
||||
IM_ASSERT(cond == ImGuiCond_Always || cond == ImGuiCond_Once);
|
||||
IM_ASSERT(payload.SourceId != 0); // Not called between BeginDragDropSource() and EndDragDropSource()
|
||||
@ -11218,14 +11250,14 @@ bool ImGui::IsDragDropPayloadBeingAccepted()
|
||||
return g.DragDropActive && g.DragDropAcceptIdPrev != 0;
|
||||
}
|
||||
|
||||
const ImGuiPayload* ImGui::AcceptDragDropPayload(const char* type, ImGuiDragDropFlags flags)
|
||||
const ImGuiPayload* ImGui::AcceptDragDropPayload(ImStrv type, ImGuiDragDropFlags flags)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
ImGuiPayload& payload = g.DragDropPayload;
|
||||
IM_ASSERT(g.DragDropActive); // Not called between BeginDragDropTarget() and EndDragDropTarget() ?
|
||||
IM_ASSERT(payload.DataFrameCount != -1); // Forgot to call EndDragDropTarget() ?
|
||||
if (type != NULL && !payload.IsDataType(type))
|
||||
if (type && !payload.IsDataType(type))
|
||||
return NULL;
|
||||
|
||||
// Accept smallest drag target bounding box, this allows us to nest drag targets conveniently without ordering constraints.
|
||||
@ -11316,7 +11348,7 @@ void ImGui::LogTextV(const char* fmt, va_list args)
|
||||
// Internal version that takes a position to decide on newline placement and pad items according to their depth.
|
||||
// We split text into individual lines to add current tree level padding
|
||||
// FIXME: This code is a little complicated perhaps, considering simplifying the whole system.
|
||||
void ImGui::LogRenderedText(const ImVec2* ref_pos, const char* text, const char* text_end)
|
||||
void ImGui::LogRenderedText(const ImVec2* ref_pos, ImStrv text)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
@ -11325,8 +11357,8 @@ void ImGui::LogRenderedText(const ImVec2* ref_pos, const char* text, const char*
|
||||
const char* suffix = g.LogNextSuffix;
|
||||
g.LogNextPrefix = g.LogNextSuffix = NULL;
|
||||
|
||||
if (!text_end)
|
||||
text_end = FindRenderedTextEnd(text, text_end);
|
||||
if (!text.End)
|
||||
text.End = FindRenderedTextEnd(text);
|
||||
|
||||
const bool log_new_line = ref_pos && (ref_pos->y > g.LogLinePosY + g.Style.FramePadding.y + 1);
|
||||
if (ref_pos)
|
||||
@ -11345,14 +11377,14 @@ void ImGui::LogRenderedText(const ImVec2* ref_pos, const char* text, const char*
|
||||
g.LogDepthRef = window->DC.TreeDepth;
|
||||
const int tree_depth = (window->DC.TreeDepth - g.LogDepthRef);
|
||||
|
||||
const char* text_remaining = text;
|
||||
const char* text_remaining = text.Begin;
|
||||
for (;;)
|
||||
{
|
||||
// Split the string. Each new line (after a '\n') is followed by indentation corresponding to the current depth of our log entry.
|
||||
// We don't add a trailing \n yet to allow a subsequent item on the same line to be captured.
|
||||
const char* line_start = text_remaining;
|
||||
const char* line_end = ImStreolRange(line_start, text_end);
|
||||
const bool is_last_line = (line_end == text_end);
|
||||
const char* line_end = ImStreolRange(line_start, text.End);
|
||||
const bool is_last_line = (line_end == text.End);
|
||||
if (line_start != line_end || !is_last_line)
|
||||
{
|
||||
const int line_length = (int)(line_end - line_start);
|
||||
@ -11412,7 +11444,7 @@ void ImGui::LogToTTY(int auto_open_depth)
|
||||
}
|
||||
|
||||
// Start logging/capturing text output to given file
|
||||
void ImGui::LogToFile(int auto_open_depth, const char* filename)
|
||||
void ImGui::LogToFile(int auto_open_depth, ImStrv filename)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (g.LogEnabled)
|
||||
@ -11423,7 +11455,7 @@ void ImGui::LogToFile(int auto_open_depth, const char* filename)
|
||||
// By opening the file in binary mode "ab" we have consistent output everywhere.
|
||||
if (!filename)
|
||||
filename = g.IO.LogFilename;
|
||||
if (!filename || !filename[0])
|
||||
if (filename.empty())
|
||||
return;
|
||||
ImFileHandle f = ImFileOpen(filename, "ab");
|
||||
if (!f)
|
||||
@ -11577,24 +11609,30 @@ void ImGui::MarkIniSettingsDirty(ImGuiWindow* window)
|
||||
g.SettingsDirtyTimer = g.IO.IniSavingRate;
|
||||
}
|
||||
|
||||
ImGuiWindowSettings* ImGui::CreateNewWindowSettings(const char* name)
|
||||
ImGuiWindowSettings* ImGui::CreateNewWindowSettings(ImStrv name)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
const size_t name_len = name.length();
|
||||
if (!name_len)
|
||||
{
|
||||
IM_ASSERT(false && "Name must not be empty.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if !IMGUI_DEBUG_INI_SETTINGS
|
||||
// Skip to the "###" marker if any. We don't skip past to match the behavior of GetID()
|
||||
// Preserve the full string when IMGUI_DEBUG_INI_SETTINGS is set to make .ini inspection easier.
|
||||
if (const char* p = strstr(name, "###"))
|
||||
name = p;
|
||||
if (const char* p = ImStrstr(name, "###"))
|
||||
name.Begin = p;
|
||||
#endif
|
||||
const size_t name_len = strlen(name);
|
||||
|
||||
// Allocate chunk
|
||||
const size_t chunk_size = sizeof(ImGuiWindowSettings) + name_len + 1;
|
||||
ImGuiWindowSettings* settings = g.SettingsWindows.alloc_chunk(chunk_size);
|
||||
IM_PLACEMENT_NEW(settings) ImGuiWindowSettings();
|
||||
settings->ID = ImHashStr(name, name_len);
|
||||
memcpy(settings->GetName(), name, name_len + 1); // Store with zero terminator
|
||||
settings->ID = ImHashStr(name);
|
||||
memcpy(settings->GetName(), name.Begin, name_len);
|
||||
settings->GetName()[name_len] = 0; // name may not contain \0, it must be inserted manually.
|
||||
|
||||
return settings;
|
||||
}
|
||||
@ -11608,14 +11646,14 @@ ImGuiWindowSettings* ImGui::FindWindowSettings(ImGuiID id)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ImGuiWindowSettings* ImGui::FindOrCreateWindowSettings(const char* name)
|
||||
ImGuiWindowSettings* ImGui::FindOrCreateWindowSettings(ImStrv name)
|
||||
{
|
||||
if (ImGuiWindowSettings* settings = FindWindowSettings(ImHashStr(name)))
|
||||
return settings;
|
||||
return CreateNewWindowSettings(name);
|
||||
}
|
||||
|
||||
ImGuiSettingsHandler* ImGui::FindSettingsHandler(const char* type_name)
|
||||
ImGuiSettingsHandler* ImGui::FindSettingsHandler(ImStrv type_name)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
const ImGuiID type_hash = ImHashStr(type_name);
|
||||
@ -11634,18 +11672,18 @@ void ImGui::ClearIniSettings()
|
||||
g.SettingsHandlers[handler_n].ClearAllFn(&g, &g.SettingsHandlers[handler_n]);
|
||||
}
|
||||
|
||||
void ImGui::LoadIniSettingsFromDisk(const char* ini_filename)
|
||||
void ImGui::LoadIniSettingsFromDisk(ImStrv ini_filename)
|
||||
{
|
||||
size_t file_data_size = 0;
|
||||
char* file_data = (char*)ImFileLoadToMemory(ini_filename, "rb", &file_data_size);
|
||||
if (!file_data)
|
||||
return;
|
||||
LoadIniSettingsFromMemory(file_data, (size_t)file_data_size);
|
||||
LoadIniSettingsFromMemory(ImStrv(file_data, file_data + file_data_size));
|
||||
IM_FREE(file_data);
|
||||
}
|
||||
|
||||
// Zero-tolerance, no error reporting, cheap .ini parsing
|
||||
void ImGui::LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size)
|
||||
void ImGui::LoadIniSettingsFromMemory(ImStrv ini_data)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(g.Initialized);
|
||||
@ -11654,12 +11692,11 @@ void ImGui::LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size)
|
||||
|
||||
// For user convenience, we allow passing a non zero-terminated string (hence the ini_size parameter).
|
||||
// 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);
|
||||
const int ini_size = (int)ini_data.length();
|
||||
g.SettingsIniData.Buf.resize((int)ini_size + 1);
|
||||
char* const buf = g.SettingsIniData.Buf.Data;
|
||||
char* const buf_end = buf + ini_size;
|
||||
memcpy(buf, ini_data, ini_size);
|
||||
memcpy(buf, ini_data.Begin, ini_size);
|
||||
buf_end[0] = 0;
|
||||
|
||||
// Call pre-read handlers
|
||||
@ -11707,7 +11744,7 @@ void ImGui::LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size)
|
||||
g.SettingsLoaded = true;
|
||||
|
||||
// [DEBUG] Restore untouched copy so it can be browsed in Metrics (not strictly necessary)
|
||||
memcpy(buf, ini_data, ini_size);
|
||||
memcpy(buf, ini_data.Begin, ini_size);
|
||||
|
||||
// Call post-read handlers
|
||||
for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++)
|
||||
@ -11715,7 +11752,7 @@ void ImGui::LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size)
|
||||
g.SettingsHandlers[handler_n].ApplyAllFn(&g, &g.SettingsHandlers[handler_n]);
|
||||
}
|
||||
|
||||
void ImGui::SaveIniSettingsToDisk(const char* ini_filename)
|
||||
void ImGui::SaveIniSettingsToDisk(ImStrv ini_filename)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
g.SettingsDirtyTimer = 0.0f;
|
||||
@ -12092,7 +12129,8 @@ void ImGui::DebugRenderViewportThumbnail(ImDrawList* draw_list, ImGuiViewportP*
|
||||
window->DrawList->AddRectFilled(thumb_r.Min, thumb_r.Max, GetColorU32(ImGuiCol_WindowBg, alpha_mul));
|
||||
window->DrawList->AddRectFilled(title_r.Min, title_r.Max, GetColorU32(window_is_focused ? ImGuiCol_TitleBgActive : ImGuiCol_TitleBg, alpha_mul));
|
||||
window->DrawList->AddRect(thumb_r.Min, thumb_r.Max, GetColorU32(ImGuiCol_Border, alpha_mul));
|
||||
window->DrawList->AddText(g.Font, g.FontSize * 1.0f, title_r.Min, GetColorU32(ImGuiCol_Text, alpha_mul), thumb_window->Name, FindRenderedTextEnd(thumb_window->Name));
|
||||
ImStrv label(thumb_window->Name, FindRenderedTextEnd(thumb_window->Name));
|
||||
window->DrawList->AddText(g.Font, g.FontSize * 1.0f, title_r.Min, GetColorU32(ImGuiCol_Text, alpha_mul), label);
|
||||
}
|
||||
draw_list->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_Border, alpha_mul));
|
||||
}
|
||||
|
378
imgui.h
378
imgui.h
@ -268,6 +268,27 @@ struct ImVec4
|
||||
IM_VEC4_CLASS_EXTRA // Define additional constructors and implicit cast operators in imconfig.h to convert back and forth between your math types and ImVec4.
|
||||
#endif
|
||||
};
|
||||
|
||||
// String view (non-owning pair of begin/end pointers, not necessarily zero-terminated)
|
||||
// ImStrv are used as function parameters instead of passing a pair of const char*.
|
||||
#define IMGUI_HAS_IMSTR
|
||||
struct ImStrv
|
||||
{
|
||||
const char* Begin;
|
||||
const char* End;
|
||||
ImStrv() { Begin = End = NULL; }
|
||||
ImStrv(const char* b) { Begin = b; End = b ? b + strlen(b) : NULL; }
|
||||
ImStrv(const char* b, const char* e){ Begin = b; End = e ? e : b + strlen(b); }
|
||||
inline size_t length() const { return (size_t)(End - Begin); }
|
||||
inline bool empty() const { return Begin == End; } // == "" or == NULL
|
||||
inline operator bool() const { return Begin != NULL; } // return true when valid ("" is valid, NULL construction is not)
|
||||
#ifdef IM_STR_CLASS_EXTRA
|
||||
IM_STR_CLASS_EXTRA // Define additional constructor in imconfig.h to convert your string types (e.g. std::string, std::string_view) to ImStrV.
|
||||
#endif
|
||||
// private: bool operator==(ImStrv) { return false; } // [DEBUG] Uncomment to catch undesirable uses of operators
|
||||
// private: bool operator!=(ImStrv) { return false; }
|
||||
};
|
||||
|
||||
IM_MSVC_RUNTIME_CHECKS_RESTORE
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -300,8 +321,8 @@ namespace ImGui
|
||||
IMGUI_API void ShowStackToolWindow(bool* p_open = NULL); // create Stack Tool window. hover items with mouse to query information about the source of their unique ID.
|
||||
IMGUI_API void ShowAboutWindow(bool* p_open = NULL); // create About window. display Dear ImGui version, credits and build/system information.
|
||||
IMGUI_API void ShowStyleEditor(ImGuiStyle* ref = NULL); // add style editor block (not a window). you can pass in a reference ImGuiStyle structure to compare to, revert to and save to (else it uses the default style)
|
||||
IMGUI_API bool ShowStyleSelector(const char* label); // add style selector block (not a window), essentially a combo listing the default styles.
|
||||
IMGUI_API void ShowFontSelector(const char* label); // add font selector block (not a window), essentially a combo listing the loaded fonts.
|
||||
IMGUI_API bool ShowStyleSelector(ImStrv label); // add style selector block (not a window), essentially a combo listing the default styles.
|
||||
IMGUI_API void ShowFontSelector(ImStrv label); // add font selector block (not a window), essentially a combo listing the loaded fonts.
|
||||
IMGUI_API void ShowUserGuide(); // add basic help/info block (not a window): how to manipulate ImGui as a end-user (mouse/keyboard controls).
|
||||
IMGUI_API const char* GetVersion(); // get the compiled version string e.g. "1.80 WIP" (essentially the value for IMGUI_VERSION from the compiled version of imgui.cpp)
|
||||
|
||||
@ -322,7 +343,7 @@ namespace ImGui
|
||||
// BeginPopup/EndPopup, etc. where the EndXXX call should only be called if the corresponding BeginXXX function
|
||||
// returned true. Begin and BeginChild are the only odd ones out. Will be fixed in a future update.]
|
||||
// - Note that the bottom of window stack always contains a window called "Debug".
|
||||
IMGUI_API bool Begin(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0);
|
||||
IMGUI_API bool Begin(ImStrv name, bool* p_open = NULL, ImGuiWindowFlags flags = 0);
|
||||
IMGUI_API void End();
|
||||
|
||||
// Child Windows
|
||||
@ -333,7 +354,7 @@ namespace ImGui
|
||||
// [Important: due to legacy reason, this is inconsistent with most other functions such as BeginMenu/EndMenu,
|
||||
// BeginPopup/EndPopup, etc. where the EndXXX call should only be called if the corresponding BeginXXX function
|
||||
// returned true. Begin and BeginChild are the only odd ones out. Will be fixed in a future update.]
|
||||
IMGUI_API bool BeginChild(const char* str_id, const ImVec2& size = ImVec2(0, 0), bool border = false, ImGuiWindowFlags flags = 0);
|
||||
IMGUI_API bool BeginChild(ImStrv str_id, const ImVec2& size = ImVec2(0, 0), bool border = false, ImGuiWindowFlags flags = 0);
|
||||
IMGUI_API bool BeginChild(ImGuiID id, const ImVec2& size = ImVec2(0, 0), bool border = false, ImGuiWindowFlags flags = 0);
|
||||
IMGUI_API void EndChild();
|
||||
|
||||
@ -363,10 +384,10 @@ namespace ImGui
|
||||
IMGUI_API void SetWindowCollapsed(bool collapsed, ImGuiCond cond = 0); // (not recommended) set current window collapsed state. prefer using SetNextWindowCollapsed().
|
||||
IMGUI_API void SetWindowFocus(); // (not recommended) set current window to be focused / top-most. prefer using SetNextWindowFocus().
|
||||
IMGUI_API void SetWindowFontScale(float scale); // [OBSOLETE] set font scale. Adjust IO.FontGlobalScale if you want to scale all windows. This is an old API! For correct scaling, prefer to reload font + rebuild ImFontAtlas + call style.ScaleAllSizes().
|
||||
IMGUI_API void SetWindowPos(const char* name, const ImVec2& pos, ImGuiCond cond = 0); // set named window position.
|
||||
IMGUI_API void SetWindowSize(const char* name, const ImVec2& size, ImGuiCond cond = 0); // set named window size. set axis to 0.0f to force an auto-fit on this axis.
|
||||
IMGUI_API void SetWindowCollapsed(const char* name, bool collapsed, ImGuiCond cond = 0); // set named window collapsed state
|
||||
IMGUI_API void SetWindowFocus(const char* name); // set named window to be focused / top-most. use NULL to remove focus.
|
||||
IMGUI_API void SetWindowPos(ImStrv name, const ImVec2& pos, ImGuiCond cond = 0); // set named window position.
|
||||
IMGUI_API void SetWindowSize(ImStrv name, const ImVec2& size, ImGuiCond cond = 0); // set named window size. set axis to 0.0f to force an auto-fit on this axis.
|
||||
IMGUI_API void SetWindowCollapsed(ImStrv name, bool collapsed, ImGuiCond cond = 0); // set named window collapsed state
|
||||
IMGUI_API void SetWindowFocus(ImStrv name); // set named window to be focused / top-most. use NULL to remove focus.
|
||||
|
||||
// Content region
|
||||
// - Retrieve available space from a given point. GetContentRegionAvail() is frequently useful.
|
||||
@ -462,17 +483,16 @@ namespace ImGui
|
||||
// - You can also use the "Label##foobar" syntax within widget label to distinguish them from each others.
|
||||
// - In this header file we use the "label"/"name" terminology to denote a string that will be displayed + used as an ID,
|
||||
// whereas "str_id" denote a string that is only used as an ID and not normally displayed.
|
||||
IMGUI_API void PushID(const char* str_id); // push string into the ID stack (will hash string).
|
||||
IMGUI_API void PushID(const char* str_id_begin, const char* str_id_end); // push string into the ID stack (will hash string).
|
||||
IMGUI_API void PushID(ImStrv str_id); // push string into the ID stack (will hash string).
|
||||
IMGUI_API void PushID(const void* ptr_id); // push pointer into the ID stack (will hash pointer).
|
||||
IMGUI_API void PushID(int int_id); // push integer into the ID stack (will hash integer).
|
||||
IMGUI_API void PopID(); // pop from the ID stack.
|
||||
IMGUI_API ImGuiID GetID(const char* str_id); // calculate unique ID (hash of whole ID stack + given parameter). e.g. if you want to query into ImGuiStorage yourself
|
||||
IMGUI_API ImGuiID GetID(const char* str_id_begin, const char* str_id_end);
|
||||
IMGUI_API ImGuiID GetID(ImStrv str_id); // calculate unique ID (hash of whole ID stack + given parameter). e.g. if you want to query into ImGuiStorage yourself
|
||||
IMGUI_API ImGuiID GetID(const void* ptr_id);
|
||||
|
||||
// Widgets: Text
|
||||
IMGUI_API void TextUnformatted(const char* text, const char* text_end = NULL); // raw text without formatting. Roughly equivalent to Text("%s", text) but: A) doesn't require null terminated string if 'text_end' is specified, B) it's faster, no memory copy is done, no buffer size limits, recommended for long chunks of text.
|
||||
// FIXME-IMSTR: Functions taking format should use ImStrv. It breaks IM_FMTARGS() macro however.
|
||||
IMGUI_API void TextUnformatted(ImStrv text); // raw text without formatting. Roughly equivalent to Text("%s", text) but: A) doesn't require null terminated string if 'text_end' is specified, B) it's faster, no memory copy is done, no buffer size limits, recommended for long chunks of text.
|
||||
IMGUI_API void Text(const char* fmt, ...) IM_FMTARGS(1); // formatted text
|
||||
IMGUI_API void TextV(const char* fmt, va_list args) IM_FMTLIST(1);
|
||||
IMGUI_API void TextColored(const ImVec4& col, const char* fmt, ...) IM_FMTARGS(2); // shortcut for PushStyleColor(ImGuiCol_Text, col); Text(fmt, ...); PopStyleColor();
|
||||
@ -481,36 +501,36 @@ namespace ImGui
|
||||
IMGUI_API void TextDisabledV(const char* fmt, va_list args) IM_FMTLIST(1);
|
||||
IMGUI_API void TextWrapped(const char* fmt, ...) IM_FMTARGS(1); // shortcut for PushTextWrapPos(0.0f); Text(fmt, ...); PopTextWrapPos();. Note that this won't work on an auto-resizing window if there's no other widgets to extend the window width, yoy may need to set a size using SetNextWindowSize().
|
||||
IMGUI_API void TextWrappedV(const char* fmt, va_list args) IM_FMTLIST(1);
|
||||
IMGUI_API void LabelText(const char* label, const char* fmt, ...) IM_FMTARGS(2); // display text+label aligned the same way as value+label widgets
|
||||
IMGUI_API void LabelTextV(const char* label, const char* fmt, va_list args) IM_FMTLIST(2);
|
||||
IMGUI_API void LabelText(ImStrv label, const char* fmt, ...) IM_FMTARGS(2); // display text+label aligned the same way as value+label widgets
|
||||
IMGUI_API void LabelTextV(ImStrv label, const char* fmt, va_list args) IM_FMTLIST(2);
|
||||
IMGUI_API void BulletText(const char* fmt, ...) IM_FMTARGS(1); // shortcut for Bullet()+Text()
|
||||
IMGUI_API void BulletTextV(const char* fmt, va_list args) IM_FMTLIST(1);
|
||||
|
||||
// Widgets: Main
|
||||
// - Most widgets return true when the value has been changed or when pressed/selected
|
||||
// - You may also use one of the many IsItemXXX functions (e.g. IsItemActive, IsItemHovered, etc.) to query widget state.
|
||||
IMGUI_API bool Button(const char* label, const ImVec2& size = ImVec2(0, 0)); // button
|
||||
IMGUI_API bool SmallButton(const char* label); // button with FramePadding=(0,0) to easily embed within text
|
||||
IMGUI_API bool InvisibleButton(const char* str_id, const ImVec2& size, ImGuiButtonFlags flags = 0); // flexible button behavior without the visuals, frequently useful to build custom behaviors using the public api (along with IsItemActive, IsItemHovered, etc.)
|
||||
IMGUI_API bool ArrowButton(const char* str_id, ImGuiDir dir); // square button with an arrow shape
|
||||
IMGUI_API bool Button(ImStrv label, const ImVec2& size = ImVec2(0, 0)); // button
|
||||
IMGUI_API bool SmallButton(ImStrv label); // button with FramePadding=(0,0) to easily embed within text
|
||||
IMGUI_API bool InvisibleButton(ImStrv str_id, const ImVec2& size, ImGuiButtonFlags flags = 0); // flexible button behavior without the visuals, frequently useful to build custom behaviors using the public api (along with IsItemActive, IsItemHovered, etc.)
|
||||
IMGUI_API bool ArrowButton(ImStrv str_id, ImGuiDir dir); // square button with an arrow shape
|
||||
IMGUI_API void Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1,1), const ImVec4& tint_col = ImVec4(1,1,1,1), const ImVec4& border_col = ImVec4(0,0,0,0));
|
||||
IMGUI_API bool ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1,1), int frame_padding = -1, const ImVec4& bg_col = ImVec4(0,0,0,0), const ImVec4& tint_col = ImVec4(1,1,1,1)); // <0 frame_padding uses default frame padding settings. 0 for no padding
|
||||
IMGUI_API bool Checkbox(const char* label, bool* v);
|
||||
IMGUI_API bool CheckboxFlags(const char* label, int* flags, int flags_value);
|
||||
IMGUI_API bool CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value);
|
||||
IMGUI_API bool RadioButton(const char* label, bool active); // use with e.g. if (RadioButton("one", my_value==1)) { my_value = 1; }
|
||||
IMGUI_API bool RadioButton(const char* label, int* v, int v_button); // shortcut to handle the above pattern when value is an integer
|
||||
IMGUI_API void ProgressBar(float fraction, const ImVec2& size_arg = ImVec2(-FLT_MIN, 0), const char* overlay = NULL);
|
||||
IMGUI_API bool Checkbox(ImStrv label, bool* v);
|
||||
IMGUI_API bool CheckboxFlags(ImStrv label, int* flags, int flags_value);
|
||||
IMGUI_API bool CheckboxFlags(ImStrv label, unsigned int* flags, unsigned int flags_value);
|
||||
IMGUI_API bool RadioButton(ImStrv label, bool active); // use with e.g. if (RadioButton("one", my_value==1)) { my_value = 1; }
|
||||
IMGUI_API bool RadioButton(ImStrv label, int* v, int v_button); // shortcut to handle the above pattern when value is an integer
|
||||
IMGUI_API void ProgressBar(float fraction, const ImVec2& size_arg = ImVec2(-FLT_MIN, 0), ImStrv overlay = ImStrv());
|
||||
IMGUI_API void Bullet(); // draw a small circle + keep the cursor on the same line. advance cursor x position by GetTreeNodeToLabelSpacing(), same distance that TreeNode() uses
|
||||
|
||||
// Widgets: Combo Box
|
||||
// - The BeginCombo()/EndCombo() api allows you to manage your contents and selection state however you want it, by creating e.g. Selectable() items.
|
||||
// - The old Combo() api are helpers over BeginCombo()/EndCombo() which are kept available for convenience purpose. This is analogous to how ListBox are created.
|
||||
IMGUI_API bool BeginCombo(const char* label, const char* preview_value, ImGuiComboFlags flags = 0);
|
||||
IMGUI_API bool BeginCombo(ImStrv label, ImStrv preview_value, ImGuiComboFlags flags = 0);
|
||||
IMGUI_API void EndCombo(); // only call EndCombo() if BeginCombo() returns true!
|
||||
IMGUI_API bool Combo(const char* label, int* current_item, const char* const items[], int items_count, int popup_max_height_in_items = -1);
|
||||
IMGUI_API bool Combo(const char* label, int* current_item, const char* items_separated_by_zeros, int popup_max_height_in_items = -1); // Separate items with \0 within a string, end item-list with \0\0. e.g. "One\0Two\0Three\0"
|
||||
IMGUI_API bool Combo(const char* label, int* current_item, bool(*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int popup_max_height_in_items = -1);
|
||||
IMGUI_API bool Combo(ImStrv label, int* current_item, const char* const items[], int items_count, int popup_max_height_in_items = -1);
|
||||
IMGUI_API bool Combo(ImStrv label, int* current_item, const char* items_separated_by_zeros, int popup_max_height_in_items = -1); // Separate items with \0 within a string, end item-list with \0\0. e.g. "One\0Two\0Three\0"
|
||||
IMGUI_API bool Combo(ImStrv label, int* current_item, bool(*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int popup_max_height_in_items = -1);
|
||||
|
||||
// Widgets: Drag Sliders
|
||||
// - CTRL+Click on any drag box to turn them into an input box. Manually input values aren't clamped by default and can go off-bounds. Use ImGuiSliderFlags_AlwaysClamp to always clamp.
|
||||
@ -524,18 +544,18 @@ namespace ImGui
|
||||
// - We use the same sets of flags for DragXXX() and SliderXXX() functions as the features are the same and it makes it easier to swap them.
|
||||
// - Legacy: Pre-1.78 there are DragXXX() function signatures that takes a final `float power=1.0f' argument instead of the `ImGuiSliderFlags flags=0' argument.
|
||||
// If you get a warning converting a float to ImGuiSliderFlags, read https://github.com/ocornut/imgui/issues/3361
|
||||
IMGUI_API bool DragFloat(const char* label, float* v, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0); // If v_min >= v_max we have no bound
|
||||
IMGUI_API bool DragFloat2(const char* label, float v[2], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool DragFloat3(const char* label, float v[3], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool DragFloat4(const char* label, float v[4], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool DragFloatRange2(const char* label, float* v_current_min, float* v_current_max, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", const char* format_max = NULL, ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool DragInt(const char* label, int* v, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", ImGuiSliderFlags flags = 0); // If v_min >= v_max we have no bound
|
||||
IMGUI_API bool DragInt2(const char* label, int v[2], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool DragInt3(const char* label, int v[3], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool DragInt4(const char* label, int v[4], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool DragIntRange2(const char* label, int* v_current_min, int* v_current_max, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", const char* format_max = NULL, ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool DragScalar(const char* label, ImGuiDataType data_type, void* p_data, float v_speed = 1.0f, const void* p_min = NULL, const void* p_max = NULL, const char* format = NULL, ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool DragScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, float v_speed = 1.0f, const void* p_min = NULL, const void* p_max = NULL, const char* format = NULL, ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool DragFloat(ImStrv label, float* v, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, ImStrv format = "%.3f", ImGuiSliderFlags flags = 0); // If v_min >= v_max we have no bound
|
||||
IMGUI_API bool DragFloat2(ImStrv label, float v[2], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, ImStrv format = "%.3f", ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool DragFloat3(ImStrv label, float v[3], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, ImStrv format = "%.3f", ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool DragFloat4(ImStrv label, float v[4], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, ImStrv format = "%.3f", ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool DragFloatRange2(ImStrv label, float* v_current_min, float* v_current_max, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, ImStrv format = "%.3f", ImStrv format_max = ImStrv(), ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool DragInt(ImStrv label, int* v, float v_speed = 1.0f, int v_min = 0, int v_max = 0, ImStrv format = "%d", ImGuiSliderFlags flags = 0); // If v_min >= v_max we have no bound
|
||||
IMGUI_API bool DragInt2(ImStrv label, int v[2], float v_speed = 1.0f, int v_min = 0, int v_max = 0, ImStrv format = "%d", ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool DragInt3(ImStrv label, int v[3], float v_speed = 1.0f, int v_min = 0, int v_max = 0, ImStrv format = "%d", ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool DragInt4(ImStrv label, int v[4], float v_speed = 1.0f, int v_min = 0, int v_max = 0, ImStrv format = "%d", ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool DragIntRange2(ImStrv label, int* v_current_min, int* v_current_max, float v_speed = 1.0f, int v_min = 0, int v_max = 0, ImStrv format = "%d", ImStrv format_max = ImStrv(), ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool DragScalar(ImStrv label, ImGuiDataType data_type, void* p_data, float v_speed = 1.0f, const void* p_min = NULL, const void* p_max = NULL, ImStrv format = ImStrv(), ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool DragScalarN(ImStrv label, ImGuiDataType data_type, void* p_data, int components, float v_speed = 1.0f, const void* p_min = NULL, const void* p_max = NULL, ImStrv format = ImStrv(), ImGuiSliderFlags flags = 0);
|
||||
|
||||
// Widgets: Regular Sliders
|
||||
// - CTRL+Click on any slider to turn them into an input box. Manually input values aren't clamped by default and can go off-bounds. Use ImGuiSliderFlags_AlwaysClamp to always clamp.
|
||||
@ -543,74 +563,75 @@ namespace ImGui
|
||||
// - Format string may also be set to NULL or use the default format ("%f" or "%d").
|
||||
// - Legacy: Pre-1.78 there are SliderXXX() function signatures that takes a final `float power=1.0f' argument instead of the `ImGuiSliderFlags flags=0' argument.
|
||||
// If you get a warning converting a float to ImGuiSliderFlags, read https://github.com/ocornut/imgui/issues/3361
|
||||
IMGUI_API bool SliderFloat(const char* label, float* v, float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0); // adjust format to decorate the value with a prefix or a suffix for in-slider labels or unit display.
|
||||
IMGUI_API bool SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool SliderFloat4(const char* label, float v[4], float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool SliderAngle(const char* label, float* v_rad, float v_degrees_min = -360.0f, float v_degrees_max = +360.0f, const char* format = "%.0f deg", ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool SliderInt(const char* label, int* v, int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool SliderInt2(const char* label, int v[2], int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool SliderInt3(const char* label, int v[3], int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool SliderInt4(const char* label, int v[4], int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool SliderScalar(const char* label, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format = NULL, ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool SliderScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, const void* p_min, const void* p_max, const char* format = NULL, ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool VSliderFloat(const char* label, const ImVec2& size, float* v, float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool VSliderInt(const char* label, const ImVec2& size, int* v, int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool VSliderScalar(const char* label, const ImVec2& size, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format = NULL, ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool SliderFloat(ImStrv label, float* v, float v_min, float v_max, ImStrv format = "%.3f", ImGuiSliderFlags flags = 0); // adjust format to decorate the value with a prefix or a suffix for in-slider labels or unit display.
|
||||
IMGUI_API bool SliderFloat2(ImStrv label, float v[2], float v_min, float v_max, ImStrv format = "%.3f", ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool SliderFloat3(ImStrv label, float v[3], float v_min, float v_max, ImStrv format = "%.3f", ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool SliderFloat4(ImStrv label, float v[4], float v_min, float v_max, ImStrv format = "%.3f", ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool SliderAngle(ImStrv label, float* v_rad, float v_degrees_min = -360.0f, float v_degrees_max = +360.0f, ImStrv format = "%.0f deg", ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool SliderInt(ImStrv label, int* v, int v_min, int v_max, ImStrv format = "%d", ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool SliderInt2(ImStrv label, int v[2], int v_min, int v_max, ImStrv format = "%d", ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool SliderInt3(ImStrv label, int v[3], int v_min, int v_max, ImStrv format = "%d", ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool SliderInt4(ImStrv label, int v[4], int v_min, int v_max, ImStrv format = "%d", ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool SliderScalar(ImStrv label, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, ImStrv format = ImStrv(), ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool SliderScalarN(ImStrv label, ImGuiDataType data_type, void* p_data, int components, const void* p_min, const void* p_max, ImStrv format = ImStrv(), ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool VSliderFloat(ImStrv label, const ImVec2& size, float* v, float v_min, float v_max, ImStrv format = "%.3f", ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool VSliderInt(ImStrv label, const ImVec2& size, int* v, int v_min, int v_max, ImStrv format = "%d", ImGuiSliderFlags flags = 0);
|
||||
IMGUI_API bool VSliderScalar(ImStrv label, const ImVec2& size, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, ImStrv format = ImStrv(), ImGuiSliderFlags flags = 0);
|
||||
|
||||
// Widgets: Input with Keyboard
|
||||
// - If you want to use InputText() with std::string or any custom dynamic string type, see misc/cpp/imgui_stdlib.h and comments in imgui_demo.cpp.
|
||||
// - Most of the ImGuiInputTextFlags flags are only useful for InputText() and not for InputFloatX, InputIntX, InputDouble etc.
|
||||
IMGUI_API bool InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL);
|
||||
IMGUI_API bool InputTextMultiline(const char* label, char* buf, size_t buf_size, const ImVec2& size = ImVec2(0, 0), ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL);
|
||||
IMGUI_API bool InputTextWithHint(const char* label, const char* hint, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL);
|
||||
IMGUI_API bool InputFloat(const char* label, float* v, float step = 0.0f, float step_fast = 0.0f, const char* format = "%.3f", ImGuiInputTextFlags flags = 0);
|
||||
IMGUI_API bool InputFloat2(const char* label, float v[2], const char* format = "%.3f", ImGuiInputTextFlags flags = 0);
|
||||
IMGUI_API bool InputFloat3(const char* label, float v[3], const char* format = "%.3f", ImGuiInputTextFlags flags = 0);
|
||||
IMGUI_API bool InputFloat4(const char* label, float v[4], const char* format = "%.3f", ImGuiInputTextFlags flags = 0);
|
||||
IMGUI_API bool InputInt(const char* label, int* v, int step = 1, int step_fast = 100, ImGuiInputTextFlags flags = 0);
|
||||
IMGUI_API bool InputInt2(const char* label, int v[2], ImGuiInputTextFlags flags = 0);
|
||||
IMGUI_API bool InputInt3(const char* label, int v[3], ImGuiInputTextFlags flags = 0);
|
||||
IMGUI_API bool InputInt4(const char* label, int v[4], ImGuiInputTextFlags flags = 0);
|
||||
IMGUI_API bool InputDouble(const char* label, double* v, double step = 0.0, double step_fast = 0.0, const char* format = "%.6f", ImGuiInputTextFlags flags = 0);
|
||||
IMGUI_API bool InputScalar(const char* label, ImGuiDataType data_type, void* p_data, const void* p_step = NULL, const void* p_step_fast = NULL, const char* format = NULL, ImGuiInputTextFlags flags = 0);
|
||||
IMGUI_API bool InputScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, const void* p_step = NULL, const void* p_step_fast = NULL, const char* format = NULL, ImGuiInputTextFlags flags = 0);
|
||||
// - Format parameter is limited to 63 bytes.
|
||||
IMGUI_API bool InputText(ImStrv label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL);
|
||||
IMGUI_API bool InputTextMultiline(ImStrv label, char* buf, size_t buf_size, const ImVec2& size = ImVec2(0, 0), ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL);
|
||||
IMGUI_API bool InputTextWithHint(ImStrv label, ImStrv hint, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL);
|
||||
IMGUI_API bool InputFloat(ImStrv label, float* v, float step = 0.0f, float step_fast = 0.0f, ImStrv format = "%.3f", ImGuiInputTextFlags flags = 0);
|
||||
IMGUI_API bool InputFloat2(ImStrv label, float v[2], ImStrv format = "%.3f", ImGuiInputTextFlags flags = 0);
|
||||
IMGUI_API bool InputFloat3(ImStrv label, float v[3], ImStrv format = "%.3f", ImGuiInputTextFlags flags = 0);
|
||||
IMGUI_API bool InputFloat4(ImStrv label, float v[4], ImStrv format = "%.3f", ImGuiInputTextFlags flags = 0);
|
||||
IMGUI_API bool InputInt(ImStrv label, int* v, int step = 1, int step_fast = 100, ImGuiInputTextFlags flags = 0);
|
||||
IMGUI_API bool InputInt2(ImStrv label, int v[2], ImGuiInputTextFlags flags = 0);
|
||||
IMGUI_API bool InputInt3(ImStrv label, int v[3], ImGuiInputTextFlags flags = 0);
|
||||
IMGUI_API bool InputInt4(ImStrv label, int v[4], ImGuiInputTextFlags flags = 0);
|
||||
IMGUI_API bool InputDouble(ImStrv label, double* v, double step = 0.0, double step_fast = 0.0, ImStrv format = "%.6f", ImGuiInputTextFlags flags = 0);
|
||||
IMGUI_API bool InputScalar(ImStrv label, ImGuiDataType data_type, void* p_data, const void* p_step = NULL, const void* p_step_fast = NULL, ImStrv format = ImStrv(), ImGuiInputTextFlags flags = 0);
|
||||
IMGUI_API bool InputScalarN(ImStrv label, ImGuiDataType data_type, void* p_data, int components, const void* p_step = NULL, const void* p_step_fast = NULL, ImStrv format = ImStrv(), ImGuiInputTextFlags flags = 0);
|
||||
|
||||
// Widgets: Color Editor/Picker (tip: the ColorEdit* functions have a little color square that can be left-clicked to open a picker, and right-clicked to open an option menu.)
|
||||
// - Note that in C++ a 'float v[X]' function argument is the _same_ as 'float* v', the array syntax is just a way to document the number of elements that are expected to be accessible.
|
||||
// - You can pass the address of a first float element out of a contiguous structure, e.g. &myvector.x
|
||||
IMGUI_API bool ColorEdit3(const char* label, float col[3], ImGuiColorEditFlags flags = 0);
|
||||
IMGUI_API bool ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flags = 0);
|
||||
IMGUI_API bool ColorPicker3(const char* label, float col[3], ImGuiColorEditFlags flags = 0);
|
||||
IMGUI_API bool ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags flags = 0, const float* ref_col = NULL);
|
||||
IMGUI_API bool ColorButton(const char* desc_id, const ImVec4& col, ImGuiColorEditFlags flags = 0, ImVec2 size = ImVec2(0, 0)); // display a color square/button, hover for details, return true when pressed.
|
||||
IMGUI_API bool ColorEdit3(ImStrv label, float col[3], ImGuiColorEditFlags flags = 0);
|
||||
IMGUI_API bool ColorEdit4(ImStrv label, float col[4], ImGuiColorEditFlags flags = 0);
|
||||
IMGUI_API bool ColorPicker3(ImStrv label, float col[3], ImGuiColorEditFlags flags = 0);
|
||||
IMGUI_API bool ColorPicker4(ImStrv label, float col[4], ImGuiColorEditFlags flags = 0, const float* ref_col = NULL);
|
||||
IMGUI_API bool ColorButton(ImStrv desc_id, const ImVec4& col, ImGuiColorEditFlags flags = 0, ImVec2 size = ImVec2(0, 0)); // display a color square/button, hover for details, return true when pressed.
|
||||
IMGUI_API void SetColorEditOptions(ImGuiColorEditFlags flags); // initialize current options (generally on application startup) if you want to select a default format, picker type, etc. User will be able to change many settings, unless you pass the _NoOptions flag to your calls.
|
||||
|
||||
// Widgets: Trees
|
||||
// - TreeNode functions return true when the node is open, in which case you need to also call TreePop() when you are finished displaying the tree node contents.
|
||||
IMGUI_API bool TreeNode(const char* label);
|
||||
IMGUI_API bool TreeNode(const char* str_id, const char* fmt, ...) IM_FMTARGS(2); // helper variation to easily decorelate the id from the displayed string. Read the FAQ about why and how to use ID. to align arbitrary text at the same level as a TreeNode() you can use Bullet().
|
||||
IMGUI_API bool TreeNode(ImStrv label);
|
||||
IMGUI_API bool TreeNode(ImStrv str_id, const char* fmt, ...) IM_FMTARGS(2); // helper variation to easily decorelate the id from the displayed string. Read the FAQ about why and how to use ID. to align arbitrary text at the same level as a TreeNode() you can use Bullet().
|
||||
IMGUI_API bool TreeNode(const void* ptr_id, const char* fmt, ...) IM_FMTARGS(2); // "
|
||||
IMGUI_API bool TreeNodeV(const char* str_id, const char* fmt, va_list args) IM_FMTLIST(2);
|
||||
IMGUI_API bool TreeNodeV(ImStrv str_id, const char* fmt, va_list args) IM_FMTLIST(2);
|
||||
IMGUI_API bool TreeNodeV(const void* ptr_id, const char* fmt, va_list args) IM_FMTLIST(2);
|
||||
IMGUI_API bool TreeNodeEx(const char* label, ImGuiTreeNodeFlags flags = 0);
|
||||
IMGUI_API bool TreeNodeEx(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, ...) IM_FMTARGS(3);
|
||||
IMGUI_API bool TreeNodeEx(ImStrv label, ImGuiTreeNodeFlags flags = 0);
|
||||
IMGUI_API bool TreeNodeEx(ImStrv str_id, ImGuiTreeNodeFlags flags, const char* fmt, ...) IM_FMTARGS(3);
|
||||
IMGUI_API bool TreeNodeEx(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, ...) IM_FMTARGS(3);
|
||||
IMGUI_API bool TreeNodeExV(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args) IM_FMTLIST(3);
|
||||
IMGUI_API bool TreeNodeExV(ImStrv str_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args) IM_FMTLIST(3);
|
||||
IMGUI_API bool TreeNodeExV(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args) IM_FMTLIST(3);
|
||||
IMGUI_API void TreePush(const char* str_id); // ~ Indent()+PushId(). Already called by TreeNode() when returning true, but you can call TreePush/TreePop yourself if desired.
|
||||
IMGUI_API void TreePush(ImStrv str_id); // ~ Indent()+PushId(). Already called by TreeNode() when returning true, but you can call TreePush/TreePop yourself if desired.
|
||||
IMGUI_API void TreePush(const void* ptr_id = NULL); // "
|
||||
IMGUI_API void TreePop(); // ~ Unindent()+PopId()
|
||||
IMGUI_API float GetTreeNodeToLabelSpacing(); // horizontal distance preceding label when using TreeNode*() or Bullet() == (g.FontSize + style.FramePadding.x*2) for a regular unframed TreeNode
|
||||
IMGUI_API bool CollapsingHeader(const char* label, ImGuiTreeNodeFlags flags = 0); // if returning 'true' the header is open. doesn't indent nor push on ID stack. user doesn't have to call TreePop().
|
||||
IMGUI_API bool CollapsingHeader(const char* label, bool* p_visible, ImGuiTreeNodeFlags flags = 0); // when 'p_visible != NULL': if '*p_visible==true' display an additional small close button on upper right of the header which will set the bool to false when clicked, if '*p_visible==false' don't display the header.
|
||||
IMGUI_API bool CollapsingHeader(ImStrv label, ImGuiTreeNodeFlags flags = 0); // if returning 'true' the header is open. doesn't indent nor push on ID stack. user doesn't have to call TreePop().
|
||||
IMGUI_API bool CollapsingHeader(ImStrv label, bool* p_visible, ImGuiTreeNodeFlags flags = 0); // when 'p_visible != NULL': if '*p_visible==true' display an additional small close button on upper right of the header which will set the bool to false when clicked, if '*p_visible==false' don't display the header.
|
||||
IMGUI_API void SetNextItemOpen(bool is_open, ImGuiCond cond = 0); // set next TreeNode/CollapsingHeader open state.
|
||||
|
||||
// Widgets: Selectables
|
||||
// - A selectable highlights when hovered, and can display another color when selected.
|
||||
// - Neighbors selectable extend their highlight bounds in order to leave no gap between them. This is so a series of selected Selectable appear contiguous.
|
||||
IMGUI_API bool Selectable(const char* label, bool selected = false, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0, 0)); // "bool selected" carry the selection state (read-only). Selectable() is clicked is returns true so you can modify your selection state. size.x==0.0: use remaining width, size.x>0.0: specify width. size.y==0.0: use label height, size.y>0.0: specify height
|
||||
IMGUI_API bool Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0, 0)); // "bool* p_selected" point to the selection state (read-write), as a convenient helper.
|
||||
IMGUI_API bool Selectable(ImStrv label, bool selected = false, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0, 0)); // "bool selected" carry the selection state (read-only). Selectable() is clicked is returns true so you can modify your selection state. size.x==0.0: use remaining width, size.x>0.0: specify width. size.y==0.0: use label height, size.y>0.0: specify height
|
||||
IMGUI_API bool Selectable(ImStrv label, bool* p_selected, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0, 0)); // "bool* p_selected" point to the selection state (read-write), as a convenient helper.
|
||||
|
||||
// Widgets: List Boxes
|
||||
// - This is essentially a thin wrapper to using BeginChild/EndChild with some stylistic changes.
|
||||
@ -618,24 +639,24 @@ namespace ImGui
|
||||
// - The simplified/old ListBox() api are helpers over BeginListBox()/EndListBox() which are kept available for convenience purpose. This is analoguous to how Combos are created.
|
||||
// - Choose frame width: size.x > 0.0f: custom / size.x < 0.0f or -FLT_MIN: right-align / size.x = 0.0f (default): use current ItemWidth
|
||||
// - Choose frame height: size.y > 0.0f: custom / size.y < 0.0f or -FLT_MIN: bottom-align / size.y = 0.0f (default): arbitrary default height which can fit ~7 items
|
||||
IMGUI_API bool BeginListBox(const char* label, const ImVec2& size = ImVec2(0, 0)); // open a framed scrolling region
|
||||
IMGUI_API bool BeginListBox(ImStrv label, const ImVec2& size = ImVec2(0, 0)); // open a framed scrolling region
|
||||
IMGUI_API void EndListBox(); // only call EndListBox() if BeginListBox() returned true!
|
||||
IMGUI_API bool ListBox(const char* label, int* current_item, const char* const items[], int items_count, int height_in_items = -1);
|
||||
IMGUI_API bool ListBox(const char* label, int* current_item, bool (*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int height_in_items = -1);
|
||||
IMGUI_API bool ListBox(ImStrv label, int* current_item, const char* const items[], int items_count, int height_in_items = -1);
|
||||
IMGUI_API bool ListBox(ImStrv label, int* current_item, bool (*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int height_in_items = -1);
|
||||
|
||||
// Widgets: Data Plotting
|
||||
// - Consider using ImPlot (https://github.com/epezent/implot) which is much better!
|
||||
IMGUI_API void PlotLines(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0, 0), int stride = sizeof(float));
|
||||
IMGUI_API void PlotLines(const char* label, float(*values_getter)(void* data, int idx), void* data, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0, 0));
|
||||
IMGUI_API void PlotHistogram(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0, 0), int stride = sizeof(float));
|
||||
IMGUI_API void PlotHistogram(const char* label, float(*values_getter)(void* data, int idx), void* data, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0, 0));
|
||||
IMGUI_API void PlotLines(ImStrv label, const float* values, int values_count, int values_offset = 0, ImStrv overlay_text = ImStrv(), float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0, 0), int stride = sizeof(float));
|
||||
IMGUI_API void PlotLines(ImStrv label, float(*values_getter)(void* data, int idx), void* data, int values_count, int values_offset = 0, ImStrv overlay_text = ImStrv(), float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0, 0));
|
||||
IMGUI_API void PlotHistogram(ImStrv label, const float* values, int values_count, int values_offset = 0, ImStrv overlay_text = ImStrv(), float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0, 0), int stride = sizeof(float));
|
||||
IMGUI_API void PlotHistogram(ImStrv label, float(*values_getter)(void* data, int idx), void* data, int values_count, int values_offset = 0, ImStrv overlay_text = ImStrv(), float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0, 0));
|
||||
|
||||
// Widgets: Value() Helpers.
|
||||
// - Those are merely shortcut to calling Text() with a format string. Output single value in "name: value" format (tip: freely declare more in your code to handle your types. you can add functions to the ImGui namespace)
|
||||
IMGUI_API void Value(const char* prefix, bool b);
|
||||
IMGUI_API void Value(const char* prefix, int v);
|
||||
IMGUI_API void Value(const char* prefix, unsigned int v);
|
||||
IMGUI_API void Value(const char* prefix, float v, const char* float_format = NULL);
|
||||
IMGUI_API void Value(ImStrv prefix, bool b);
|
||||
IMGUI_API void Value(ImStrv prefix, int v);
|
||||
IMGUI_API void Value(ImStrv prefix, unsigned int v);
|
||||
IMGUI_API void Value(ImStrv prefix, float v, ImStrv float_format = ImStrv());
|
||||
|
||||
// Widgets: Menus
|
||||
// - Use BeginMenuBar() on a window ImGuiWindowFlags_MenuBar to append to its menu bar.
|
||||
@ -646,10 +667,10 @@ namespace ImGui
|
||||
IMGUI_API void EndMenuBar(); // only call EndMenuBar() if BeginMenuBar() returns true!
|
||||
IMGUI_API bool BeginMainMenuBar(); // create and append to a full screen menu-bar.
|
||||
IMGUI_API void EndMainMenuBar(); // only call EndMainMenuBar() if BeginMainMenuBar() returns true!
|
||||
IMGUI_API bool BeginMenu(const char* label, bool enabled = true); // create a sub-menu entry. only call EndMenu() if this returns true!
|
||||
IMGUI_API bool BeginMenu(ImStrv label, bool enabled = true); // create a sub-menu entry. only call EndMenu() if this returns true!
|
||||
IMGUI_API void EndMenu(); // only call EndMenu() if BeginMenu() returns true!
|
||||
IMGUI_API bool MenuItem(const char* label, const char* shortcut = NULL, bool selected = false, bool enabled = true); // return true when activated.
|
||||
IMGUI_API bool MenuItem(const char* label, const char* shortcut, bool* p_selected, bool enabled = true); // return true when activated + toggle (*p_selected) if p_selected != NULL
|
||||
IMGUI_API bool MenuItem(ImStrv label, ImStrv shortcut = ImStrv(), bool selected = false, bool enabled = true); // return true when activated.
|
||||
IMGUI_API bool MenuItem(ImStrv label, ImStrv shortcut, bool* p_selected, bool enabled = true); // return true when activated + toggle (*p_selected) if p_selected != NULL
|
||||
|
||||
// Tooltips
|
||||
// - Tooltip are windows following the mouse. They do not take focus away.
|
||||
@ -670,8 +691,8 @@ namespace ImGui
|
||||
// Popups: begin/end functions
|
||||
// - BeginPopup(): query popup state, if open start appending into the window. Call EndPopup() afterwards. ImGuiWindowFlags are forwarded to the window.
|
||||
// - BeginPopupModal(): block every interactions behind the window, cannot be closed by user, add a dimming background, has a title bar.
|
||||
IMGUI_API bool BeginPopup(const char* str_id, ImGuiWindowFlags flags = 0); // return true if the popup is open, and you can start outputting to it.
|
||||
IMGUI_API bool BeginPopupModal(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0); // return true if the modal is open, and you can start outputting to it.
|
||||
IMGUI_API bool BeginPopup(ImStrv str_id, ImGuiWindowFlags flags = 0); // return true if the popup is open, and you can start outputting to it.
|
||||
IMGUI_API bool BeginPopupModal(ImStrv name, bool* p_open = NULL, ImGuiWindowFlags flags = 0); // return true if the modal is open, and you can start outputting to it.
|
||||
IMGUI_API void EndPopup(); // only call EndPopup() if BeginPopupXXX() returns true!
|
||||
|
||||
// Popups: open/close functions
|
||||
@ -682,9 +703,9 @@ namespace ImGui
|
||||
// - Use ImGuiPopupFlags_NoOpenOverExistingPopup to avoid opening a popup if there's already one at the same level. This is equivalent to e.g. testing for !IsAnyPopupOpen() prior to OpenPopup().
|
||||
// - Use IsWindowAppearing() after BeginPopup() to tell if a window just opened.
|
||||
// - IMPORTANT: Notice that for OpenPopupOnItemClick() we exceptionally default flags to 1 (== ImGuiPopupFlags_MouseButtonRight) for backward compatibility with older API taking 'int mouse_button = 1' parameter
|
||||
IMGUI_API void OpenPopup(const char* str_id, ImGuiPopupFlags popup_flags = 0); // call to mark popup as open (don't call every frame!).
|
||||
IMGUI_API void OpenPopup(ImStrv str_id, ImGuiPopupFlags popup_flags = 0); // call to mark popup as open (don't call every frame!).
|
||||
IMGUI_API void OpenPopup(ImGuiID id, ImGuiPopupFlags popup_flags = 0); // id overload to facilitate calling from nested stacks
|
||||
IMGUI_API void OpenPopupOnItemClick(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // helper to open popup when clicked on last item. Default to ImGuiPopupFlags_MouseButtonRight == 1. (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors)
|
||||
IMGUI_API void OpenPopupOnItemClick(ImStrv str_id = ImStrv(), ImGuiPopupFlags popup_flags = 1); // helper to open popup when clicked on last item. Default to ImGuiPopupFlags_MouseButtonRight == 1. (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors)
|
||||
IMGUI_API void CloseCurrentPopup(); // manually close the popup we have begin-ed into.
|
||||
|
||||
// Popups: open+begin combined functions helpers
|
||||
@ -692,15 +713,15 @@ namespace ImGui
|
||||
// - They are convenient to easily create context menus, hence the name.
|
||||
// - IMPORTANT: Notice that BeginPopupContextXXX takes ImGuiPopupFlags just like OpenPopup() and unlike BeginPopup(). For full consistency, we may add ImGuiWindowFlags to the BeginPopupContextXXX functions in the future.
|
||||
// - IMPORTANT: Notice that we exceptionally default their flags to 1 (== ImGuiPopupFlags_MouseButtonRight) for backward compatibility with older API taking 'int mouse_button = 1' parameter, so if you add other flags remember to re-add the ImGuiPopupFlags_MouseButtonRight.
|
||||
IMGUI_API bool BeginPopupContextItem(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // open+begin popup when clicked on last item. Use str_id==NULL to associate the popup to previous item. If you want to use that on a non-interactive item such as Text() you need to pass in an explicit ID here. read comments in .cpp!
|
||||
IMGUI_API bool BeginPopupContextWindow(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1);// open+begin popup when clicked on current window.
|
||||
IMGUI_API bool BeginPopupContextVoid(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // open+begin popup when clicked in void (where there are no windows).
|
||||
IMGUI_API bool BeginPopupContextItem(ImStrv str_id = ImStrv(), ImGuiPopupFlags popup_flags = 1); // open+begin popup when clicked on last item. Use str_id==NULL to associate the popup to previous item. If you want to use that on a non-interactive item such as Text() you need to pass in an explicit ID here. read comments in .cpp!
|
||||
IMGUI_API bool BeginPopupContextWindow(ImStrv str_id = ImStrv(), ImGuiPopupFlags popup_flags = 1); // open+begin popup when clicked on current window.
|
||||
IMGUI_API bool BeginPopupContextVoid(ImStrv str_id = ImStrv(), ImGuiPopupFlags popup_flags = 1); // open+begin popup when clicked in void (where there are no windows).
|
||||
|
||||
// Popups: query functions
|
||||
// - IsPopupOpen(): return true if the popup is open at the current BeginPopup() level of the popup stack.
|
||||
// - IsPopupOpen() with ImGuiPopupFlags_AnyPopupId: return true if any popup is open at the current BeginPopup() level of the popup stack.
|
||||
// - IsPopupOpen() with ImGuiPopupFlags_AnyPopupId + ImGuiPopupFlags_AnyPopupLevel: return true if any popup is open.
|
||||
IMGUI_API bool IsPopupOpen(const char* str_id, ImGuiPopupFlags flags = 0); // return true if the popup is open.
|
||||
IMGUI_API bool IsPopupOpen(ImStrv str_id, ImGuiPopupFlags flags = 0); // return true if the popup is open.
|
||||
|
||||
// Tables
|
||||
// - Full-featured replacement for old Columns API.
|
||||
@ -726,7 +747,7 @@ namespace ImGui
|
||||
// TableNextRow() -> Text("Hello 0") // Not OK! Missing TableSetColumnIndex() or TableNextColumn()! Text will not appear!
|
||||
// --------------------------------------------------------------------------------------------------------
|
||||
// - 5. Call EndTable()
|
||||
IMGUI_API bool BeginTable(const char* str_id, int column, ImGuiTableFlags flags = 0, const ImVec2& outer_size = ImVec2(0.0f, 0.0f), float inner_width = 0.0f);
|
||||
IMGUI_API bool BeginTable(ImStrv str_id, int column, ImGuiTableFlags flags = 0, const ImVec2& outer_size = ImVec2(0.0f, 0.0f), float inner_width = 0.0f);
|
||||
IMGUI_API void EndTable(); // only call EndTable() if BeginTable() returns true!
|
||||
IMGUI_API void TableNextRow(ImGuiTableRowFlags row_flags = 0, float min_row_height = 0.0f); // append into the first cell of a new row.
|
||||
IMGUI_API bool TableNextColumn(); // append into the next column (or first column of next row if currently in last column). Return true when column is visible.
|
||||
@ -740,10 +761,10 @@ namespace ImGui
|
||||
// - You may manually submit headers using TableNextRow() + TableHeader() calls, but this is only useful in
|
||||
// some advanced use cases (e.g. adding custom widgets in header row).
|
||||
// - Use TableSetupScrollFreeze() to lock columns/rows so they stay visible when scrolled.
|
||||
IMGUI_API void TableSetupColumn(const char* label, ImGuiTableColumnFlags flags = 0, float init_width_or_weight = 0.0f, ImGuiID user_id = 0);
|
||||
IMGUI_API void TableSetupColumn(ImStrv label, ImGuiTableColumnFlags flags = 0, float init_width_or_weight = 0.0f, ImGuiID user_id = 0);
|
||||
IMGUI_API void TableSetupScrollFreeze(int cols, int rows); // lock columns/rows so they stay visible when scrolled.
|
||||
IMGUI_API void TableHeadersRow(); // submit all headers cells based on data provided to TableSetupColumn() + submit context menu
|
||||
IMGUI_API void TableHeader(const char* label); // submit one header cell manually (rarely used)
|
||||
IMGUI_API void TableHeader(ImStrv label); // submit one header cell manually (rarely used)
|
||||
|
||||
// Tables: Sorting
|
||||
// - Call TableGetSortSpecs() to retrieve latest sort specs for the table. NULL when not sorting.
|
||||
@ -765,7 +786,7 @@ namespace ImGui
|
||||
|
||||
// Legacy Columns API (prefer using Tables!)
|
||||
// - You can also use SameLine(pos_x) to mimic simplified columns.
|
||||
IMGUI_API void Columns(int count = 1, const char* id = NULL, bool border = true);
|
||||
IMGUI_API void Columns(int count = 1, ImStrv id = ImStrv(), bool border = true);
|
||||
IMGUI_API void NextColumn(); // next column, defaults to current row or next row if the current row is finished
|
||||
IMGUI_API int GetColumnIndex(); // get current column index
|
||||
IMGUI_API float GetColumnWidth(int column_index = -1); // get column width (in pixels). pass -1 to use current column
|
||||
@ -775,17 +796,17 @@ namespace ImGui
|
||||
IMGUI_API int GetColumnsCount();
|
||||
|
||||
// Tab Bars, Tabs
|
||||
IMGUI_API bool BeginTabBar(const char* str_id, ImGuiTabBarFlags flags = 0); // create and append into a TabBar
|
||||
IMGUI_API bool BeginTabBar(ImStrv str_id, ImGuiTabBarFlags flags = 0); // create and append into a TabBar
|
||||
IMGUI_API void EndTabBar(); // only call EndTabBar() if BeginTabBar() returns true!
|
||||
IMGUI_API bool BeginTabItem(const char* label, bool* p_open = NULL, ImGuiTabItemFlags flags = 0); // create a Tab. Returns true if the Tab is selected.
|
||||
IMGUI_API bool BeginTabItem(ImStrv label, bool* p_open = NULL, ImGuiTabItemFlags flags = 0);// create a Tab. Returns true if the Tab is selected.
|
||||
IMGUI_API void EndTabItem(); // only call EndTabItem() if BeginTabItem() returns true!
|
||||
IMGUI_API bool TabItemButton(const char* label, ImGuiTabItemFlags flags = 0); // create a Tab behaving like a button. return true when clicked. cannot be selected in the tab bar.
|
||||
IMGUI_API void SetTabItemClosed(const char* tab_or_docked_window_label); // notify TabBar or Docking system of a closed tab/window ahead (useful to reduce visual flicker on reorderable tab bars). For tab-bar: call after BeginTabBar() and before Tab submissions. Otherwise call with a window name.
|
||||
IMGUI_API bool TabItemButton(ImStrv label, ImGuiTabItemFlags flags = 0); // create a Tab behaving like a button. return true when clicked. cannot be selected in the tab bar.
|
||||
IMGUI_API void SetTabItemClosed(ImStrv tab_or_docked_window_label); // notify TabBar or Docking system of a closed tab/window ahead (useful to reduce visual flicker on reorderable tab bars). For tab-bar: call after BeginTabBar() and before Tab submissions. Otherwise call with a window name.
|
||||
|
||||
// Logging/Capture
|
||||
// - All text output from the interface can be captured into tty/file/clipboard. By default, tree nodes are automatically opened during logging.
|
||||
IMGUI_API void LogToTTY(int auto_open_depth = -1); // start logging to tty (stdout)
|
||||
IMGUI_API void LogToFile(int auto_open_depth = -1, const char* filename = NULL); // start logging to file
|
||||
IMGUI_API void LogToFile(int auto_open_depth = -1, ImStrv filename = ImStrv()); // start logging to file
|
||||
IMGUI_API void LogToClipboard(int auto_open_depth = -1); // start logging to OS clipboard
|
||||
IMGUI_API void LogFinish(); // stop logging (close file, etc.)
|
||||
IMGUI_API void LogButtons(); // helper to display buttons for logging to tty/file/clipboard
|
||||
@ -798,10 +819,10 @@ namespace ImGui
|
||||
// - If you stop calling BeginDragDropSource() the payload is preserved however it won't have a preview tooltip (we currently display a fallback "..." tooltip, see #1725)
|
||||
// - An item can be both drag source and drop target.
|
||||
IMGUI_API bool BeginDragDropSource(ImGuiDragDropFlags flags = 0); // call after submitting an item which may be dragged. when this return true, you can call SetDragDropPayload() + EndDragDropSource()
|
||||
IMGUI_API bool SetDragDropPayload(const char* type, const void* data, size_t sz, ImGuiCond cond = 0); // type is a user defined string of maximum 32 characters. Strings starting with '_' are reserved for dear imgui internal types. Data is copied and held by imgui. Return true when payload has been accepted.
|
||||
IMGUI_API bool SetDragDropPayload(ImStrv type, const void* data, size_t sz, ImGuiCond cond = 0); // type is a user defined string of maximum 32 characters. Strings starting with '_' are reserved for dear imgui internal types. Data is copied and held by imgui. Return true when payload has been accepted.
|
||||
IMGUI_API void EndDragDropSource(); // only call EndDragDropSource() if BeginDragDropSource() returns true!
|
||||
IMGUI_API bool BeginDragDropTarget(); // call after submitting an item that may receive a payload. If this returns true, you can call AcceptDragDropPayload() + EndDragDropTarget()
|
||||
IMGUI_API const ImGuiPayload* AcceptDragDropPayload(const char* type, ImGuiDragDropFlags flags = 0); // accept contents of a given type. If ImGuiDragDropFlags_AcceptBeforeDelivery is set you can peek into the payload before the mouse button is released.
|
||||
IMGUI_API const ImGuiPayload* AcceptDragDropPayload(ImStrv type, ImGuiDragDropFlags flags = 0); // accept contents of a given type. If ImGuiDragDropFlags_AcceptBeforeDelivery is set you can peek into the payload before the mouse button is released.
|
||||
IMGUI_API void EndDragDropTarget(); // only call EndDragDropTarget() if BeginDragDropTarget() returns true!
|
||||
IMGUI_API const ImGuiPayload* GetDragDropPayload(); // peek directly into the current payload from anywhere. may return NULL. use ImGuiPayload::IsDataType() to test for the payload type.
|
||||
|
||||
@ -864,7 +885,7 @@ namespace ImGui
|
||||
IMGUI_API void EndChildFrame(); // always call EndChildFrame() regardless of BeginChildFrame() return values (which indicates a collapsed/clipped window)
|
||||
|
||||
// Text Utilities
|
||||
IMGUI_API ImVec2 CalcTextSize(const char* text, const char* text_end = NULL, bool hide_text_after_double_hash = false, float wrap_width = -1.0f);
|
||||
IMGUI_API ImVec2 CalcTextSize(ImStrv text, bool hide_text_after_double_hash = false, float wrap_width = -1.0f);
|
||||
|
||||
// Color Utilities
|
||||
IMGUI_API ImVec4 ColorConvertU32ToFloat4(ImU32 in);
|
||||
@ -909,20 +930,20 @@ namespace ImGui
|
||||
// Clipboard Utilities
|
||||
// - Also see the LogToClipboard() function to capture GUI into clipboard, or easily output text data to the clipboard.
|
||||
IMGUI_API const char* GetClipboardText();
|
||||
IMGUI_API void SetClipboardText(const char* text);
|
||||
IMGUI_API void SetClipboardText(ImStrv text);
|
||||
|
||||
// Settings/.Ini Utilities
|
||||
// - The disk functions are automatically called if io.IniFilename != NULL (default is "imgui.ini").
|
||||
// - Set io.IniFilename to NULL to load/save manually. Read io.WantSaveIniSettings description about handling .ini saving manually.
|
||||
// - Important: default value "imgui.ini" is relative to current working dir! Most apps will want to lock this to an absolute path (e.g. same path as executables).
|
||||
IMGUI_API void LoadIniSettingsFromDisk(const char* ini_filename); // call after CreateContext() and before the first call to NewFrame(). NewFrame() automatically calls LoadIniSettingsFromDisk(io.IniFilename).
|
||||
IMGUI_API void LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size=0); // call after CreateContext() and before the first call to NewFrame() to provide .ini data from your own data source.
|
||||
IMGUI_API void SaveIniSettingsToDisk(const char* ini_filename); // this is automatically called (if io.IniFilename is not empty) a few seconds after any modification that should be reflected in the .ini file (and also by DestroyContext).
|
||||
IMGUI_API void LoadIniSettingsFromDisk(ImStrv ini_filename); // call after CreateContext() and before the first call to NewFrame(). NewFrame() automatically calls LoadIniSettingsFromDisk(io.IniFilename).
|
||||
IMGUI_API void LoadIniSettingsFromMemory(ImStrv ini_data); // call after CreateContext() and before the first call to NewFrame() to provide .ini data from your own data source.
|
||||
IMGUI_API void SaveIniSettingsToDisk(ImStrv ini_filename); // this is automatically called (if io.IniFilename is not empty) a few seconds after any modification that should be reflected in the .ini file (and also by DestroyContext).
|
||||
IMGUI_API const char* SaveIniSettingsToMemory(size_t* out_ini_size = NULL); // return a zero-terminated string with the .ini data which you can save by your own mean. call when io.WantSaveIniSettings is set, then save data by your own mean and clear io.WantSaveIniSettings.
|
||||
|
||||
// Debug Utilities
|
||||
// - This is used by the IMGUI_CHECKVERSION() macro.
|
||||
IMGUI_API bool DebugCheckVersionAndDataLayout(const char* version_str, size_t sz_io, size_t sz_style, size_t sz_vec2, size_t sz_vec4, size_t sz_drawvert, size_t sz_drawidx); // This is called by IMGUI_CHECKVERSION() macro.
|
||||
IMGUI_API bool DebugCheckVersionAndDataLayout(ImStrv version_str, size_t sz_io, size_t sz_style, size_t sz_vec2, size_t sz_vec4, size_t sz_drawvert, size_t sz_drawidx);
|
||||
|
||||
// Memory Allocators
|
||||
// - Those functions are not reliant on the current context.
|
||||
@ -2091,10 +2112,13 @@ struct ImGuiInputTextCallbackData
|
||||
// Use those function to benefit from the CallbackResize behaviors. Calling those function reset the selection.
|
||||
IMGUI_API ImGuiInputTextCallbackData();
|
||||
IMGUI_API void DeleteChars(int pos, int bytes_count);
|
||||
IMGUI_API void InsertChars(int pos, const char* text, const char* text_end = NULL);
|
||||
IMGUI_API void InsertChars(int pos, ImStrv text);
|
||||
void SelectAll() { SelectionStart = 0; SelectionEnd = BufTextLen; }
|
||||
void ClearSelection() { SelectionStart = SelectionEnd = BufTextLen; }
|
||||
bool HasSelection() const { return SelectionStart != SelectionEnd; }
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
inline void InsertChars(int pos, const char* text, const char* text_end) { InsertChars(pos, ImStrv(text, text_end)); }
|
||||
#endif
|
||||
};
|
||||
|
||||
// Resizing callback data to apply custom constraint. As enabled by SetNextWindowSizeConstraints(). Callback is called during the next Begin().
|
||||
@ -2124,7 +2148,7 @@ struct ImGuiPayload
|
||||
|
||||
ImGuiPayload() { Clear(); }
|
||||
void Clear() { SourceId = SourceParentId = 0; Data = NULL; DataSize = 0; memset(DataType, 0, sizeof(DataType)); DataFrameCount = -1; Preview = Delivery = false; }
|
||||
bool IsDataType(const char* type) const { return DataFrameCount != -1 && strcmp(type, DataType) == 0; }
|
||||
bool IsDataType(ImStrv type) const { size_t len = type.length(); return DataFrameCount != -1 && memcmp(DataType, type.Begin, len) == 0 && DataType[len] == 0; }
|
||||
bool IsPreview() const { return Preview; }
|
||||
bool IsDelivery() const { return Delivery; }
|
||||
};
|
||||
@ -2177,27 +2201,23 @@ struct ImGuiOnceUponAFrame
|
||||
// Helper: Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]"
|
||||
struct ImGuiTextFilter
|
||||
{
|
||||
IMGUI_API ImGuiTextFilter(const char* default_filter = "");
|
||||
IMGUI_API bool Draw(const char* label = "Filter (inc,-exc)", float width = 0.0f); // Helper calling InputText+Build
|
||||
IMGUI_API bool PassFilter(const char* text, const char* text_end = NULL) const;
|
||||
// Private members
|
||||
char InputBuf[256];
|
||||
ImVector<ImStrv> Filters;
|
||||
int CountGrep;
|
||||
|
||||
// Functions
|
||||
IMGUI_API ImGuiTextFilter(ImStrv default_filter = "");
|
||||
IMGUI_API bool Draw(ImStrv label = "Filter (inc,-exc)", float width = 0.0f); // Helper calling InputText+Build
|
||||
IMGUI_API bool PassFilter(ImStrv text) const;
|
||||
IMGUI_API void Build();
|
||||
void Clear() { InputBuf[0] = 0; Build(); }
|
||||
bool IsActive() const { return !Filters.empty(); }
|
||||
|
||||
// [Internal]
|
||||
struct ImGuiTextRange
|
||||
{
|
||||
const char* b;
|
||||
const char* e;
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
inline bool PassFilter(const char* text, const char* text_end = NULL) const { return PassFilter(ImStrv(text, text_end)); }
|
||||
#endif
|
||||
|
||||
ImGuiTextRange() { b = e = NULL; }
|
||||
ImGuiTextRange(const char* _b, const char* _e) { b = _b; e = _e; }
|
||||
bool empty() const { return b == e; }
|
||||
IMGUI_API void split(char separator, ImVector<ImGuiTextRange>* out) const;
|
||||
};
|
||||
char InputBuf[256];
|
||||
ImVector<ImGuiTextRange>Filters;
|
||||
int CountGrep;
|
||||
};
|
||||
|
||||
// Helper: Growable text buffer for logging/accumulating text
|
||||
@ -2216,9 +2236,12 @@ struct ImGuiTextBuffer
|
||||
void clear() { Buf.clear(); }
|
||||
void reserve(int capacity) { Buf.reserve(capacity); }
|
||||
const char* c_str() const { return Buf.Data ? Buf.Data : EmptyString; }
|
||||
IMGUI_API void append(const char* str, const char* str_end = NULL);
|
||||
IMGUI_API void append(ImStrv str);
|
||||
IMGUI_API void appendf(const char* fmt, ...) IM_FMTARGS(2);
|
||||
IMGUI_API void appendfv(const char* fmt, va_list args) IM_FMTLIST(2);
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
inline void append(const char* str, const char* str_end) { append(ImStrv(str, str_end)); }
|
||||
#endif
|
||||
};
|
||||
|
||||
// Helper: Key->Value storage
|
||||
@ -2545,13 +2568,18 @@ struct ImDrawList
|
||||
IMGUI_API void AddCircleFilled(const ImVec2& center, float radius, ImU32 col, int num_segments = 0);
|
||||
IMGUI_API void AddNgon(const ImVec2& center, float radius, ImU32 col, int num_segments, float thickness = 1.0f);
|
||||
IMGUI_API void AddNgonFilled(const ImVec2& center, float radius, ImU32 col, int num_segments);
|
||||
IMGUI_API void AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL);
|
||||
IMGUI_API void AddText(const ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL, float wrap_width = 0.0f, const ImVec4* cpu_fine_clip_rect = NULL);
|
||||
IMGUI_API void AddText(const ImVec2& pos, ImU32 col, ImStrv text);
|
||||
IMGUI_API void AddText(const ImFont* font, float font_size, const ImVec2& pos, ImU32 col, ImStrv text, float wrap_width = 0.0f, const ImVec4* cpu_fine_clip_rect = NULL);
|
||||
IMGUI_API void AddPolyline(const ImVec2* points, int num_points, ImU32 col, ImDrawFlags flags, float thickness);
|
||||
IMGUI_API void AddConvexPolyFilled(const ImVec2* points, int num_points, ImU32 col); // Note: Anti-aliased filling requires points to be in clockwise order.
|
||||
IMGUI_API void AddBezierCubic(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col, float thickness, int num_segments = 0); // Cubic Bezier (4 control points)
|
||||
IMGUI_API void AddBezierQuadratic(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col, float thickness, int num_segments = 0); // Quadratic Bezier (3 control points)
|
||||
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
inline void AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end) { AddText(NULL, 0.0f, pos, col, ImStrv(text_begin, text_end)); }
|
||||
inline void AddText(const ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end, float wrap_width = 0.0f, const ImVec4* cpu_fine_clip_rect = NULL) { AddText(font, font_size, pos, col, ImStrv(text_begin, text_end), wrap_width, cpu_fine_clip_rect); }
|
||||
#endif
|
||||
|
||||
// Image primitives
|
||||
// - Read FAQ to understand what ImTextureID is.
|
||||
// - "p_min" and "p_max" represent the upper-left and lower-right corners of the rectangle.
|
||||
@ -2692,9 +2720,13 @@ struct ImFontGlyphRangesBuilder
|
||||
inline bool GetBit(size_t n) const { int off = (int)(n >> 5); ImU32 mask = 1u << (n & 31); return (UsedChars[off] & mask) != 0; } // Get bit n in the array
|
||||
inline void SetBit(size_t n) { int off = (int)(n >> 5); ImU32 mask = 1u << (n & 31); UsedChars[off] |= mask; } // Set bit n in the array
|
||||
inline void AddChar(ImWchar c) { SetBit(c); } // Add character
|
||||
IMGUI_API void AddText(const char* text, const char* text_end = NULL); // Add string (each character of the UTF-8 string are added)
|
||||
IMGUI_API void AddText(ImStrv text); // Add string (each character of the UTF-8 string are added)
|
||||
IMGUI_API void AddRanges(const ImWchar* ranges); // Add ranges, e.g. builder.AddRanges(ImFontAtlas::GetGlyphRangesDefault()) to force add all of ASCII/Latin+Ext
|
||||
IMGUI_API void BuildRanges(ImVector<ImWchar>* out_ranges); // Output new ranges
|
||||
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
inline void AddText(const char* text, const char* text_end = NULL) { AddText(ImStrv(text, text_end)); }
|
||||
#endif
|
||||
};
|
||||
|
||||
// See ImFontAtlas::AddCustomRectXXX functions.
|
||||
@ -2742,10 +2774,10 @@ struct ImFontAtlas
|
||||
IMGUI_API ~ImFontAtlas();
|
||||
IMGUI_API ImFont* AddFont(const ImFontConfig* font_cfg);
|
||||
IMGUI_API ImFont* AddFontDefault(const ImFontConfig* font_cfg = NULL);
|
||||
IMGUI_API ImFont* AddFontFromFileTTF(const char* filename, float size_pixels, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL);
|
||||
IMGUI_API ImFont* AddFontFromFileTTF(ImStrv filename, float size_pixels, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL);
|
||||
IMGUI_API ImFont* AddFontFromMemoryTTF(void* font_data, int font_size, float size_pixels, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL); // Note: Transfer ownership of 'ttf_data' to ImFontAtlas! Will be deleted after destruction of the atlas. Set font_cfg->FontDataOwnedByAtlas=false to keep ownership of your data and it won't be freed.
|
||||
IMGUI_API ImFont* AddFontFromMemoryCompressedTTF(const void* compressed_font_data, int compressed_font_size, float size_pixels, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL); // 'compressed_font_data' still owned by caller. Compress with binary_to_compressed_c.cpp.
|
||||
IMGUI_API ImFont* AddFontFromMemoryCompressedBase85TTF(const char* compressed_font_data_base85, float size_pixels, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL); // 'compressed_font_data_base85' still owned by caller. Compress with binary_to_compressed_c.cpp with -base85 parameter.
|
||||
IMGUI_API ImFont* AddFontFromMemoryCompressedBase85TTF(ImStrv compressed_font_data_base85, float size_pixels, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL); // 'compressed_font_data_base85' still owned by caller. Compress with binary_to_compressed_c.cpp with -base85 parameter.
|
||||
IMGUI_API void ClearInputData(); // Clear input data (all ImFontConfig structures including sizes, TTF data, glyph ranges, etc.) = all the data used to build the texture and fonts.
|
||||
IMGUI_API void ClearTexData(); // Clear output texture data (CPU side). Saves RAM once the texture has been copied to graphics memory.
|
||||
IMGUI_API void ClearFonts(); // Clear output font data (glyphs storage, UV coordinates).
|
||||
@ -2873,10 +2905,16 @@ struct ImFont
|
||||
|
||||
// 'max_width' stops rendering after a certain width (could be turned into a 2d size). FLT_MAX to disable.
|
||||
// 'wrap_width' enable automatic word-wrapping across multiple lines to fit into given width. 0.0f to disable.
|
||||
IMGUI_API ImVec2 CalcTextSizeA(float size, float max_width, float wrap_width, const char* text_begin, const char* text_end = NULL, const char** remaining = NULL) const; // utf8
|
||||
IMGUI_API const char* CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width) const;
|
||||
IMGUI_API ImVec2 CalcTextSizeA(float size, float max_width, float wrap_width, ImStrv text, const char** remaining = NULL) const; // utf8
|
||||
IMGUI_API const char* CalcWordWrapPositionA(float scale, ImStrv text, float wrap_width) const;
|
||||
IMGUI_API void RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, ImWchar c) const;
|
||||
IMGUI_API void RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, float wrap_width = 0.0f, bool cpu_fine_clip = false) const;
|
||||
IMGUI_API void RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, ImStrv text, float wrap_width = 0.0f, bool cpu_fine_clip = false) const;
|
||||
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
inline ImVec2 CalcTextSizeA(float size, float max_width, float wrap_width, const char* text_begin, const char* text_end, const char** remaining = NULL) const { return CalcTextSizeA(size, max_width, wrap_width, ImStrv(text_begin, text_end), remaining); }
|
||||
inline const char* CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width) const { return CalcWordWrapPositionA(scale, ImStrv(text, text_end), wrap_width); }
|
||||
inline void RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, float wrap_width = 0.0f, bool cpu_fine_clip = false) const { RenderText(draw_list, size, pos, col, clip_rect, ImStrv(text_begin, text_end), wrap_width, cpu_fine_clip); }
|
||||
#endif
|
||||
|
||||
// [Internal] Don't use!
|
||||
IMGUI_API void BuildLookupTable();
|
||||
@ -2958,33 +2996,39 @@ namespace ImGui
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
namespace ImGui
|
||||
{
|
||||
// OBSOLETED in 1.XX (string_view branch)
|
||||
inline void PushID(const char* str_id_begin, const char* str_id_end) { PushID(ImStrv(str_id_begin, str_id_end)); }
|
||||
inline ImGuiID GetID(const char* str_id_begin, const char* str_id_end) { return GetID(ImStrv(str_id_begin, str_id_end)); }
|
||||
inline void TextUnformatted(const char* text, const char* text_end) { TextUnformatted(ImStrv(text, text_end)); }
|
||||
inline ImVec2 CalcTextSize(const char* text, const char* text_end, bool hide_text_after_double_hash = false, float wrap_width = -1.0f) { return CalcTextSize(ImStrv(text, text_end), hide_text_after_double_hash, wrap_width); }
|
||||
|
||||
// OBSOLETED in 1.86 (from November 2021)
|
||||
IMGUI_API void CalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end); // Calculate coarse clipping for large list of evenly sized items. Prefer using ImGuiListClipper.
|
||||
// OBSOLETED in 1.85 (from August 2021)
|
||||
static inline float GetWindowContentRegionWidth() { return GetWindowContentRegionMax().x - GetWindowContentRegionMin().x; }
|
||||
// OBSOLETED in 1.81 (from February 2021)
|
||||
IMGUI_API bool ListBoxHeader(const char* label, int items_count, int height_in_items = -1); // Helper to calculate size from items_count and height_in_items
|
||||
static inline bool ListBoxHeader(const char* label, const ImVec2& size = ImVec2(0, 0)) { return BeginListBox(label, size); }
|
||||
IMGUI_API bool ListBoxHeader(ImStrv label, int items_count, int height_in_items = -1); // Helper to calculate size from items_count and height_in_items
|
||||
static inline bool ListBoxHeader(ImStrv label, const ImVec2& size = ImVec2(0, 0)) { return BeginListBox(label, size); }
|
||||
static inline void ListBoxFooter() { EndListBox(); }
|
||||
// OBSOLETED in 1.79 (from August 2020)
|
||||
static inline void OpenPopupContextItem(const char* str_id = NULL, ImGuiMouseButton mb = 1) { OpenPopupOnItemClick(str_id, mb); } // Bool return value removed. Use IsWindowAppearing() in BeginPopup() instead. Renamed in 1.77, renamed back in 1.79. Sorry!
|
||||
static inline void OpenPopupContextItem(ImStrv str_id = ImStrv(), ImGuiMouseButton mb = 1) { OpenPopupOnItemClick(str_id, mb); } // Bool return value removed. Use IsWindowAppearing() in BeginPopup() instead. Renamed in 1.77, renamed back in 1.79. Sorry!
|
||||
// OBSOLETED in 1.78 (from June 2020)
|
||||
// Old drag/sliders functions that took a 'float power = 1.0' argument instead of flags.
|
||||
// For shared code, you can version check at compile-time with `#if IMGUI_VERSION_NUM >= 17704`.
|
||||
IMGUI_API bool DragScalar(const char* label, ImGuiDataType data_type, void* p_data, float v_speed, const void* p_min, const void* p_max, const char* format, float power);
|
||||
IMGUI_API bool DragScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, float v_speed, const void* p_min, const void* p_max, const char* format, float power);
|
||||
static inline bool DragFloat(const char* label, float* v, float v_speed, float v_min, float v_max, const char* format, float power) { return DragScalar(label, ImGuiDataType_Float, v, v_speed, &v_min, &v_max, format, power); }
|
||||
static inline bool DragFloat2(const char* label, float v[2], float v_speed, float v_min, float v_max, const char* format, float power) { return DragScalarN(label, ImGuiDataType_Float, v, 2, v_speed, &v_min, &v_max, format, power); }
|
||||
static inline bool DragFloat3(const char* label, float v[3], float v_speed, float v_min, float v_max, const char* format, float power) { return DragScalarN(label, ImGuiDataType_Float, v, 3, v_speed, &v_min, &v_max, format, power); }
|
||||
static inline bool DragFloat4(const char* label, float v[4], float v_speed, float v_min, float v_max, const char* format, float power) { return DragScalarN(label, ImGuiDataType_Float, v, 4, v_speed, &v_min, &v_max, format, power); }
|
||||
IMGUI_API bool SliderScalar(const char* label, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format, float power);
|
||||
IMGUI_API bool SliderScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, const void* p_min, const void* p_max, const char* format, float power);
|
||||
static inline bool SliderFloat(const char* label, float* v, float v_min, float v_max, const char* format, float power) { return SliderScalar(label, ImGuiDataType_Float, v, &v_min, &v_max, format, power); }
|
||||
static inline bool SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* format, float power) { return SliderScalarN(label, ImGuiDataType_Float, v, 2, &v_min, &v_max, format, power); }
|
||||
static inline bool SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* format, float power) { return SliderScalarN(label, ImGuiDataType_Float, v, 3, &v_min, &v_max, format, power); }
|
||||
static inline bool SliderFloat4(const char* label, float v[4], float v_min, float v_max, const char* format, float power) { return SliderScalarN(label, ImGuiDataType_Float, v, 4, &v_min, &v_max, format, power); }
|
||||
IMGUI_API bool DragScalar(ImStrv label, ImGuiDataType data_type, void* p_data, float v_speed, const void* p_min, const void* p_max, ImStrv format, float power);
|
||||
IMGUI_API bool DragScalarN(ImStrv label, ImGuiDataType data_type, void* p_data, int components, float v_speed, const void* p_min, const void* p_max, ImStrv format, float power);
|
||||
static inline bool DragFloat(ImStrv label, float* v, float v_speed, float v_min, float v_max, ImStrv format, float power) { return DragScalar(label, ImGuiDataType_Float, v, v_speed, &v_min, &v_max, format, power); }
|
||||
static inline bool DragFloat2(ImStrv label, float v[2], float v_speed, float v_min, float v_max, ImStrv format, float power) { return DragScalarN(label, ImGuiDataType_Float, v, 2, v_speed, &v_min, &v_max, format, power); }
|
||||
static inline bool DragFloat3(ImStrv label, float v[3], float v_speed, float v_min, float v_max, ImStrv format, float power) { return DragScalarN(label, ImGuiDataType_Float, v, 3, v_speed, &v_min, &v_max, format, power); }
|
||||
static inline bool DragFloat4(ImStrv label, float v[4], float v_speed, float v_min, float v_max, ImStrv format, float power) { return DragScalarN(label, ImGuiDataType_Float, v, 4, v_speed, &v_min, &v_max, format, power); }
|
||||
IMGUI_API bool SliderScalar(ImStrv label, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, ImStrv format, float power);
|
||||
IMGUI_API bool SliderScalarN(ImStrv label, ImGuiDataType data_type, void* p_data, int components, const void* p_min, const void* p_max, ImStrv format, float power);
|
||||
static inline bool SliderFloat(ImStrv label, float* v, float v_min, float v_max, ImStrv format, float power) { return SliderScalar(label, ImGuiDataType_Float, v, &v_min, &v_max, format, power); }
|
||||
static inline bool SliderFloat2(ImStrv label, float v[2], float v_min, float v_max, ImStrv format, float power) { return SliderScalarN(label, ImGuiDataType_Float, v, 2, &v_min, &v_max, format, power); }
|
||||
static inline bool SliderFloat3(ImStrv label, float v[3], float v_min, float v_max, ImStrv format, float power) { return SliderScalarN(label, ImGuiDataType_Float, v, 3, &v_min, &v_max, format, power); }
|
||||
static inline bool SliderFloat4(ImStrv label, float v[4], float v_min, float v_max, ImStrv format, float power) { return SliderScalarN(label, ImGuiDataType_Float, v, 4, &v_min, &v_max, format, power); }
|
||||
// OBSOLETED in 1.77 (from June 2020)
|
||||
static inline bool BeginPopupContextWindow(const char* str_id, ImGuiMouseButton mb, bool over_items) { return BeginPopupContextWindow(str_id, mb | (over_items ? 0 : ImGuiPopupFlags_NoOpenOverItems)); }
|
||||
static inline bool BeginPopupContextWindow(ImStrv str_id, ImGuiMouseButton mb, bool over_items) { return BeginPopupContextWindow(str_id, mb | (over_items ? 0 : ImGuiPopupFlags_NoOpenOverItems)); }
|
||||
|
||||
// Some of the older obsolete names along with their replacement (commented out so they are not reported in IDE)
|
||||
//static inline void TreeAdvanceToLabelPos() { SetCursorPosX(GetCursorPosX() + GetTreeNodeToLabelSpacing()); } // OBSOLETED in 1.72 (from July 2019)
|
||||
|
@ -3240,7 +3240,7 @@ static void ShowDemoWindowLayout()
|
||||
"(this is often used internally to avoid altering the clipping rectangle and minimize draw calls)");
|
||||
ImVec4 clip_rect(p0.x, p0.y, p1.x, p1.y); // AddText() takes a ImVec4* here so let's convert.
|
||||
draw_list->AddRectFilled(p0, p1, IM_COL32(90, 90, 120, 255));
|
||||
draw_list->AddText(ImGui::GetFont(), ImGui::GetFontSize(), text_pos, IM_COL32_WHITE, text_str, NULL, 0.0f, &clip_rect);
|
||||
draw_list->AddText(ImGui::GetFont(), ImGui::GetFontSize(), text_pos, IM_COL32_WHITE, text_str, 0.0f, &clip_rect);
|
||||
break;
|
||||
}
|
||||
ImGui::EndGroup();
|
||||
@ -6050,7 +6050,7 @@ namespace ImGui { IMGUI_API void ShowFontAtlas(ImFontAtlas* atlas); }
|
||||
|
||||
// Demo helper function to select among loaded fonts.
|
||||
// Here we use the regular BeginCombo()/EndCombo() api which is the more flexible one.
|
||||
void ImGui::ShowFontSelector(const char* label)
|
||||
void ImGui::ShowFontSelector(ImStrv label)
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
ImFont* font_current = ImGui::GetFont();
|
||||
@ -6077,7 +6077,7 @@ void ImGui::ShowFontSelector(const char* label)
|
||||
// Demo helper function to select among default colors. See ShowStyleEditor() for more advanced options.
|
||||
// Here we use the simplified Combo() api that packs items into a single literal string.
|
||||
// Useful for quick combo boxes where the choices are known locally.
|
||||
bool ImGui::ShowStyleSelector(const char* label)
|
||||
bool ImGui::ShowStyleSelector(ImStrv label)
|
||||
{
|
||||
static int style_idx = -1;
|
||||
if (ImGui::Combo(label, &style_idx, "Dark\0Light\0Classic\0"))
|
||||
@ -6768,7 +6768,7 @@ struct ExampleAppConsole
|
||||
if (match_len > 0)
|
||||
{
|
||||
data->DeleteChars((int)(word_start - data->Buf), (int)(word_end - word_start));
|
||||
data->InsertChars(data->CursorPos, candidates[0], candidates[0] + match_len);
|
||||
data->InsertChars(data->CursorPos, ImStrv(candidates[0], candidates[0] + match_len));
|
||||
}
|
||||
|
||||
// List matches
|
||||
@ -6902,8 +6902,8 @@ struct ExampleAppLog
|
||||
{
|
||||
const char* line_start = buf + LineOffsets[line_no];
|
||||
const char* line_end = (line_no + 1 < LineOffsets.Size) ? (buf + LineOffsets[line_no + 1] - 1) : buf_end;
|
||||
if (Filter.PassFilter(line_start, line_end))
|
||||
ImGui::TextUnformatted(line_start, line_end);
|
||||
if (Filter.PassFilter(ImStrv(line_start, line_end)))
|
||||
ImGui::TextUnformatted(ImStrv(line_start, line_end));
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -6929,7 +6929,7 @@ struct ExampleAppLog
|
||||
{
|
||||
const char* line_start = buf + LineOffsets[line_no];
|
||||
const char* line_end = (line_no + 1 < LineOffsets.Size) ? (buf + LineOffsets[line_no + 1] - 1) : buf_end;
|
||||
ImGui::TextUnformatted(line_start, line_end);
|
||||
ImGui::TextUnformatted(ImStrv(line_start, line_end));
|
||||
}
|
||||
}
|
||||
clipper.End();
|
||||
@ -7162,7 +7162,7 @@ static void ShowExampleAppLongText(bool* p_open)
|
||||
{
|
||||
case 0:
|
||||
// Single call to TextUnformatted() with a big buffer
|
||||
ImGui::TextUnformatted(log.begin(), log.end());
|
||||
ImGui::TextUnformatted(ImStrv(log.begin(), log.end()));
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
|
@ -1573,14 +1573,11 @@ void ImDrawList::AddBezierQuadratic(const ImVec2& p1, const ImVec2& p2, const Im
|
||||
PathStroke(col, 0, thickness);
|
||||
}
|
||||
|
||||
void ImDrawList::AddText(const ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end, float wrap_width, const ImVec4* cpu_fine_clip_rect)
|
||||
void ImDrawList::AddText(const ImFont* font, float font_size, const ImVec2& pos, ImU32 col, ImStrv text, float wrap_width, const ImVec4* cpu_fine_clip_rect)
|
||||
{
|
||||
if ((col & IM_COL32_A_MASK) == 0)
|
||||
return;
|
||||
|
||||
if (text_end == NULL)
|
||||
text_end = text_begin + strlen(text_begin);
|
||||
if (text_begin == text_end)
|
||||
if (text.Begin == text.End)
|
||||
return;
|
||||
|
||||
// Pull default font/size from the shared ImDrawListSharedData instance
|
||||
@ -1599,12 +1596,12 @@ void ImDrawList::AddText(const ImFont* font, float font_size, const ImVec2& pos,
|
||||
clip_rect.z = ImMin(clip_rect.z, cpu_fine_clip_rect->z);
|
||||
clip_rect.w = ImMin(clip_rect.w, cpu_fine_clip_rect->w);
|
||||
}
|
||||
font->RenderText(this, font_size, pos, col, clip_rect, text_begin, text_end, wrap_width, cpu_fine_clip_rect != NULL);
|
||||
font->RenderText(this, font_size, pos, col, clip_rect, text, wrap_width, cpu_fine_clip_rect != NULL);
|
||||
}
|
||||
|
||||
void ImDrawList::AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end)
|
||||
void ImDrawList::AddText(const ImVec2& pos, ImU32 col, ImStrv text)
|
||||
{
|
||||
AddText(NULL, 0.0f, pos, col, text_begin, text_end);
|
||||
AddText(NULL, 0.0f, pos, col, text);
|
||||
}
|
||||
|
||||
void ImDrawList::AddImage(ImTextureID user_texture_id, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min, const ImVec2& uv_max, ImU32 col)
|
||||
@ -2108,13 +2105,15 @@ static unsigned int stb_decompress_length(const unsigned char* input);
|
||||
static unsigned int stb_decompress(unsigned char* output, const unsigned char* input, unsigned int length);
|
||||
static const char* GetDefaultCompressedFontDataTTFBase85();
|
||||
static unsigned int Decode85Byte(char c) { return c >= '\\' ? c-36 : c-35; }
|
||||
static void Decode85(const unsigned char* src, unsigned char* dst)
|
||||
static void Decode85(ImStrv src, unsigned char* dst)
|
||||
{
|
||||
while (*src)
|
||||
const char* p = src.Begin;
|
||||
const char* p_end = src.End;
|
||||
while (p < p_end)
|
||||
{
|
||||
unsigned int tmp = Decode85Byte(src[0]) + 85 * (Decode85Byte(src[1]) + 85 * (Decode85Byte(src[2]) + 85 * (Decode85Byte(src[3]) + 85 * Decode85Byte(src[4]))));
|
||||
unsigned int tmp = Decode85Byte(p[0]) + 85 * (Decode85Byte(p[1]) + 85 * (Decode85Byte(p[2]) + 85 * (Decode85Byte(p[3]) + 85 * Decode85Byte(p[4]))));
|
||||
dst[0] = ((tmp >> 0) & 0xFF); dst[1] = ((tmp >> 8) & 0xFF); dst[2] = ((tmp >> 16) & 0xFF); dst[3] = ((tmp >> 24) & 0xFF); // We can't assume little-endianness.
|
||||
src += 5;
|
||||
p += 5;
|
||||
dst += 4;
|
||||
}
|
||||
}
|
||||
@ -2141,7 +2140,7 @@ ImFont* ImFontAtlas::AddFontDefault(const ImFontConfig* font_cfg_template)
|
||||
return font;
|
||||
}
|
||||
|
||||
ImFont* ImFontAtlas::AddFontFromFileTTF(const char* filename, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges)
|
||||
ImFont* ImFontAtlas::AddFontFromFileTTF(ImStrv filename, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges)
|
||||
{
|
||||
IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!");
|
||||
size_t data_size = 0;
|
||||
@ -2156,8 +2155,9 @@ ImFont* ImFontAtlas::AddFontFromFileTTF(const char* filename, float size_pixels,
|
||||
{
|
||||
// Store a short copy of filename into into the font name for convenience
|
||||
const char* p;
|
||||
for (p = filename + strlen(filename); p > filename && p[-1] != '/' && p[-1] != '\\'; p--) {}
|
||||
ImFormatString(font_cfg.Name, IM_ARRAYSIZE(font_cfg.Name), "%s, %.0fpx", p, size_pixels);
|
||||
for (p = filename.End; p > filename.Begin && p[-1] != '/' && p[-1] != '\\'; p--) {}
|
||||
filename.Begin = p;
|
||||
ImFormatString(font_cfg.Name, IM_ARRAYSIZE(font_cfg.Name), "%.*s, %.0fpx", (int)filename.length(), filename.Begin, size_pixels);
|
||||
}
|
||||
return AddFontFromMemoryTTF(data, (int)data_size, size_pixels, &font_cfg, glyph_ranges);
|
||||
}
|
||||
@ -2188,11 +2188,11 @@ ImFont* ImFontAtlas::AddFontFromMemoryCompressedTTF(const void* compressed_ttf_d
|
||||
return AddFontFromMemoryTTF(buf_decompressed_data, (int)buf_decompressed_size, size_pixels, &font_cfg, glyph_ranges);
|
||||
}
|
||||
|
||||
ImFont* ImFontAtlas::AddFontFromMemoryCompressedBase85TTF(const char* compressed_ttf_data_base85, float size_pixels, const ImFontConfig* font_cfg, const ImWchar* glyph_ranges)
|
||||
ImFont* ImFontAtlas::AddFontFromMemoryCompressedBase85TTF(ImStrv compressed_ttf_data_base85, float size_pixels, const ImFontConfig* font_cfg, const ImWchar* glyph_ranges)
|
||||
{
|
||||
int compressed_ttf_size = (((int)strlen(compressed_ttf_data_base85) + 4) / 5) * 4;
|
||||
int compressed_ttf_size = (((int)compressed_ttf_data_base85.length() + 4) / 5) * 4;
|
||||
void* compressed_ttf = IM_ALLOC((size_t)compressed_ttf_size);
|
||||
Decode85((const unsigned char*)compressed_ttf_data_base85, (unsigned char*)compressed_ttf);
|
||||
Decode85(compressed_ttf_data_base85, (unsigned char*)compressed_ttf);
|
||||
ImFont* font = AddFontFromMemoryCompressedTTF(compressed_ttf, compressed_ttf_size, size_pixels, font_cfg, glyph_ranges);
|
||||
IM_FREE(compressed_ttf);
|
||||
return font;
|
||||
@ -3064,13 +3064,13 @@ const ImWchar* ImFontAtlas::GetGlyphRangesVietnamese()
|
||||
// [SECTION] ImFontGlyphRangesBuilder
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void ImFontGlyphRangesBuilder::AddText(const char* text, const char* text_end)
|
||||
void ImFontGlyphRangesBuilder::AddText(ImStrv text)
|
||||
{
|
||||
while (text_end ? (text < text_end) : *text)
|
||||
while (!text.empty())
|
||||
{
|
||||
unsigned int c = 0;
|
||||
int c_len = ImTextCharFromUtf8(&c, text, text_end);
|
||||
text += c_len;
|
||||
int c_len = ImTextCharFromUtf8(&c, text.Begin, text.End);
|
||||
text.Begin += c_len;
|
||||
if (c_len == 0)
|
||||
break;
|
||||
AddChar((ImWchar)c);
|
||||
@ -3329,7 +3329,7 @@ const ImFontGlyph* ImFont::FindGlyphNoFallback(ImWchar c) const
|
||||
return &Glyphs.Data[i];
|
||||
}
|
||||
|
||||
const char* ImFont::CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width) const
|
||||
const char* ImFont::CalcWordWrapPositionA(float scale, ImStrv text, float wrap_width) const
|
||||
{
|
||||
// Simple word-wrapping for English, not full-featured. Please submit failing cases!
|
||||
// FIXME: Much possible improvements (don't cut things like "word !", "word!!!" but cut within "word,,,,", more sensible support for punctuations, support for Unicode punctuations, etc.)
|
||||
@ -3351,11 +3351,14 @@ const char* ImFont::CalcWordWrapPositionA(float scale, const char* text, const c
|
||||
float blank_width = 0.0f;
|
||||
wrap_width /= scale; // We work with unscaled widths to avoid scaling every characters
|
||||
|
||||
const char* word_end = text;
|
||||
const char* text_begin = text.Begin;
|
||||
const char* text_end = text.End;
|
||||
|
||||
const char* word_end = text_begin;
|
||||
const char* prev_word_end = NULL;
|
||||
bool inside_word = true;
|
||||
|
||||
const char* s = text;
|
||||
const char* s = text_begin;
|
||||
while (s < text_end)
|
||||
{
|
||||
unsigned int c = (unsigned int)*s;
|
||||
@ -3428,17 +3431,17 @@ const char* ImFont::CalcWordWrapPositionA(float scale, const char* text, const c
|
||||
return s;
|
||||
}
|
||||
|
||||
ImVec2 ImFont::CalcTextSizeA(float size, float max_width, float wrap_width, const char* text_begin, const char* text_end, const char** remaining) const
|
||||
ImVec2 ImFont::CalcTextSizeA(float size, float max_width, float wrap_width, ImStrv text, const char** remaining) const
|
||||
{
|
||||
if (!text_end)
|
||||
text_end = text_begin + strlen(text_begin); // FIXME-OPT: Need to avoid this.
|
||||
|
||||
const float line_height = size;
|
||||
const float scale = size / FontSize;
|
||||
|
||||
ImVec2 text_size = ImVec2(0, 0);
|
||||
float line_width = 0.0f;
|
||||
|
||||
const char* text_begin = text.Begin;
|
||||
const char* text_end = text.End;
|
||||
|
||||
const bool word_wrap_enabled = (wrap_width > 0.0f);
|
||||
const char* word_wrap_eol = NULL;
|
||||
|
||||
@ -3450,7 +3453,7 @@ ImVec2 ImFont::CalcTextSizeA(float size, float max_width, float wrap_width, cons
|
||||
// Calculate how far we can render. Requires two passes on the string data but keeps the code simple and not intrusive for what's essentially an uncommon feature.
|
||||
if (!word_wrap_eol)
|
||||
{
|
||||
word_wrap_eol = CalcWordWrapPositionA(scale, s, text_end, wrap_width - line_width);
|
||||
word_wrap_eol = CalcWordWrapPositionA(scale, ImStrv(s, text_end), wrap_width - line_width);
|
||||
if (word_wrap_eol == s) // Wrap_width is too small to fit anything. Force displaying 1 character to minimize the height discontinuity.
|
||||
word_wrap_eol++; // +1 may not be a character start point in UTF-8 but it's ok because we use s >= word_wrap_eol below
|
||||
}
|
||||
@ -3538,11 +3541,8 @@ void ImFont::RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col
|
||||
}
|
||||
|
||||
// Note: as with every ImDrawList drawing function, this expects that the font atlas texture is bound.
|
||||
void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, float wrap_width, bool cpu_fine_clip) const
|
||||
void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, ImStrv text, float wrap_width, bool cpu_fine_clip) const
|
||||
{
|
||||
if (!text_end)
|
||||
text_end = text_begin + strlen(text_begin); // ImGui:: functions generally already provides a valid text_end, so this is merely to handle direct calls.
|
||||
|
||||
// Align to be pixel perfect
|
||||
pos.x = IM_FLOOR(pos.x);
|
||||
pos.y = IM_FLOOR(pos.y);
|
||||
@ -3557,7 +3557,8 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col
|
||||
const char* word_wrap_eol = NULL;
|
||||
|
||||
// Fast-forward to first visible line
|
||||
const char* s = text_begin;
|
||||
const char* s = text.Begin;
|
||||
const char* text_end = text.End;
|
||||
if (y + line_height < clip_rect.y && !word_wrap_enabled)
|
||||
while (y + line_height < clip_rect.y && s < text_end)
|
||||
{
|
||||
@ -3595,14 +3596,14 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col
|
||||
|
||||
const ImU32 col_untinted = col | ~IM_COL32_A_MASK;
|
||||
|
||||
while (s < text_end)
|
||||
while (s < text.End)
|
||||
{
|
||||
if (word_wrap_enabled)
|
||||
{
|
||||
// Calculate how far we can render. Requires two passes on the string data but keeps the code simple and not intrusive for what's essentially an uncommon feature.
|
||||
if (!word_wrap_eol)
|
||||
{
|
||||
word_wrap_eol = CalcWordWrapPositionA(scale, s, text_end, wrap_width - (x - pos.x));
|
||||
word_wrap_eol = CalcWordWrapPositionA(scale, ImStrv(s, text_end), wrap_width - (x - pos.x));
|
||||
if (word_wrap_eol == s) // Wrap_width is too small to fit anything. Force displaying 1 character to minimize the height discontinuity.
|
||||
word_wrap_eol++; // +1 may not be a character start point in UTF-8 but it's ok because we use s >= word_wrap_eol below
|
||||
}
|
||||
|
@ -295,7 +295,8 @@ namespace ImStb
|
||||
|
||||
// Helpers: Hashing
|
||||
IMGUI_API ImGuiID ImHashData(const void* data, size_t data_size, ImU32 seed = 0);
|
||||
IMGUI_API ImGuiID ImHashStr(const char* data, size_t data_size = 0, ImU32 seed = 0);
|
||||
IMGUI_API ImGuiID ImHashStr(ImStrv str, ImU32 seed = 0);
|
||||
static inline ImGuiID ImHashStr(const char* data, size_t data_size = 0, ImU32 seed = 0) { return ImHashStr(ImStrv(data, data_size ? data + data_size : NULL), seed); }
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
static inline ImGuiID ImHash(const void* data, int size, ImU32 seed = 0) { return size ? ImHashData(data, (size_t)size, seed) : ImHashStr((const char*)data, 0, seed); } // [moved to ImHashStr/ImHashData in 1.68]
|
||||
#endif
|
||||
@ -314,16 +315,22 @@ static inline bool ImIsPowerOfTwo(ImU64 v) { return v != 0 && (v &
|
||||
static inline int ImUpperPowerOfTwo(int v) { v--; v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16; v++; return v; }
|
||||
|
||||
// Helpers: String, Formatting
|
||||
static inline int ImStrcmp(const char* str1, const char* str2) { return strcmp(str1, str2); }
|
||||
IMGUI_API int ImStrcmp(ImStrv str1, ImStrv str2);
|
||||
IMGUI_API int ImStricmp(const char* str1, const char* str2);
|
||||
IMGUI_API int ImStrnicmp(const char* str1, const char* str2, size_t count);
|
||||
IMGUI_API void ImStrncpy(char* dst, ImStrv src, size_t count);
|
||||
IMGUI_API void ImStrncpy(char* dst, const char* src, size_t count);
|
||||
IMGUI_API char* ImStrdup(const char* str);
|
||||
IMGUI_API char* ImStrdup(ImStrv str);
|
||||
IMGUI_API char* ImStrdupcpy(char* dst, size_t* p_dst_size, ImStrv str);
|
||||
IMGUI_API char* ImStrdupcpy(char* dst, size_t* p_dst_size, const char* str);
|
||||
IMGUI_API const char* ImStrchrRange(const char* str_begin, const char* str_end, char c);
|
||||
IMGUI_API int ImStrlenW(const ImWchar* str);
|
||||
IMGUI_API const char* ImStreolRange(const char* str, const char* str_end); // End end-of-line
|
||||
IMGUI_API const ImWchar*ImStrbolW(const ImWchar* buf_mid_line, const ImWchar* buf_begin); // Find beginning-of-line
|
||||
IMGUI_API const char* ImStristr(const char* haystack, const char* haystack_end, const char* needle, const char* needle_end);
|
||||
IMGUI_API const char* ImStrstr(ImStrv haystack, ImStrv needle);
|
||||
IMGUI_API void ImStrTrimBlanks(char* str);
|
||||
IMGUI_API const char* ImStrSkipBlank(const char* str);
|
||||
IMGUI_API int ImFormatString(char* buf, size_t buf_size, const char* fmt, ...) IM_FMTARGS(3);
|
||||
@ -371,7 +378,7 @@ IM_MSVC_RUNTIME_CHECKS_RESTORE
|
||||
#ifdef IMGUI_DISABLE_FILE_FUNCTIONS
|
||||
#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS
|
||||
typedef void* ImFileHandle;
|
||||
static inline ImFileHandle ImFileOpen(const char*, const char*) { return NULL; }
|
||||
static inline ImFileHandle ImFileOpen(ImStrv, ImStrv) { return NULL; }
|
||||
static inline bool ImFileClose(ImFileHandle) { return false; }
|
||||
static inline ImU64 ImFileGetSize(ImFileHandle) { return (ImU64)-1; }
|
||||
static inline ImU64 ImFileRead(void*, ImU64, ImU64, ImFileHandle) { return 0; }
|
||||
@ -379,7 +386,7 @@ static inline ImU64 ImFileWrite(const void*, ImU64, ImU64, ImFileHandle)
|
||||
#endif
|
||||
#ifndef IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS
|
||||
typedef FILE* ImFileHandle;
|
||||
IMGUI_API ImFileHandle ImFileOpen(const char* filename, const char* mode);
|
||||
IMGUI_API ImFileHandle ImFileOpen(ImStrv filename, ImStrv mode);
|
||||
IMGUI_API bool ImFileClose(ImFileHandle file);
|
||||
IMGUI_API ImU64 ImFileGetSize(ImFileHandle file);
|
||||
IMGUI_API ImU64 ImFileRead(void* data, ImU64 size, ImU64 count, ImFileHandle file);
|
||||
@ -387,7 +394,7 @@ IMGUI_API ImU64 ImFileWrite(const void* data, ImU64 size, ImU64 coun
|
||||
#else
|
||||
#define IMGUI_DISABLE_TTY_FUNCTIONS // Can't use stdout, fflush if we are not using default file functions
|
||||
#endif
|
||||
IMGUI_API void* ImFileLoadToMemory(const char* filename, const char* mode, size_t* out_file_size = NULL, int padding_bytes = 0);
|
||||
IMGUI_API void* ImFileLoadToMemory(ImStrv filename, ImStrv mode, size_t* out_file_size = NULL, int padding_bytes = 0);
|
||||
|
||||
// Helpers: Maths
|
||||
IM_MSVC_RUNTIME_CHECKS_OFF
|
||||
@ -2107,13 +2114,16 @@ struct IMGUI_API ImGuiWindow
|
||||
bool MemoryCompacted; // Set when window extraneous data have been garbage collected
|
||||
|
||||
public:
|
||||
ImGuiWindow(ImGuiContext* context, const char* name);
|
||||
ImGuiWindow(ImGuiContext* context, ImStrv name);
|
||||
~ImGuiWindow();
|
||||
|
||||
ImGuiID GetID(const char* str, const char* str_end = NULL);
|
||||
ImGuiID GetID(ImStrv str);
|
||||
ImGuiID GetID(const char* str) { return GetID(ImStrv(str)); }
|
||||
ImGuiID GetID(const char* str, const char* str_end) { return GetID(ImStrv(str, str_end)); }
|
||||
ImGuiID GetID(const void* ptr);
|
||||
ImGuiID GetID(int n);
|
||||
ImGuiID GetIDNoKeepAlive(const char* str, const char* str_end = NULL);
|
||||
ImGuiID GetIDNoKeepAlive(ImStrv str);
|
||||
ImGuiID GetIDNoKeepAlive(const char* str, const char* str_end = NULL) { return GetIDNoKeepAlive(ImStrv(str, str_end));}
|
||||
ImGuiID GetIDNoKeepAlive(const void* ptr);
|
||||
ImGuiID GetIDNoKeepAlive(int n);
|
||||
ImGuiID GetIDFromRectangle(const ImRect& r_abs);
|
||||
@ -2477,7 +2487,7 @@ namespace ImGui
|
||||
inline ImGuiWindow* GetCurrentWindowRead() { ImGuiContext& g = *GImGui; return g.CurrentWindow; }
|
||||
inline ImGuiWindow* GetCurrentWindow() { ImGuiContext& g = *GImGui; g.CurrentWindow->WriteAccessed = true; return g.CurrentWindow; }
|
||||
IMGUI_API ImGuiWindow* FindWindowByID(ImGuiID id);
|
||||
IMGUI_API ImGuiWindow* FindWindowByName(const char* name);
|
||||
IMGUI_API ImGuiWindow* FindWindowByName(ImStrv name);
|
||||
IMGUI_API void UpdateWindowParentAndRootLinks(ImGuiWindow* window, ImGuiWindowFlags flags, ImGuiWindow* parent_window);
|
||||
IMGUI_API ImVec2 CalcWindowNextAutoFitSize(ImGuiWindow* window);
|
||||
IMGUI_API bool IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent, bool popup_hierarchy);
|
||||
@ -2528,10 +2538,10 @@ namespace ImGui
|
||||
IMGUI_API void MarkIniSettingsDirty();
|
||||
IMGUI_API void MarkIniSettingsDirty(ImGuiWindow* window);
|
||||
IMGUI_API void ClearIniSettings();
|
||||
IMGUI_API ImGuiWindowSettings* CreateNewWindowSettings(const char* name);
|
||||
IMGUI_API ImGuiWindowSettings* CreateNewWindowSettings(ImStrv name);
|
||||
IMGUI_API ImGuiWindowSettings* FindWindowSettings(ImGuiID id);
|
||||
IMGUI_API ImGuiWindowSettings* FindOrCreateWindowSettings(const char* name);
|
||||
IMGUI_API ImGuiSettingsHandler* FindSettingsHandler(const char* type_name);
|
||||
IMGUI_API ImGuiWindowSettings* FindOrCreateWindowSettings(ImStrv name);
|
||||
IMGUI_API ImGuiSettingsHandler* FindSettingsHandler(ImStrv type_name);
|
||||
|
||||
// Scrolling
|
||||
IMGUI_API void SetNextWindowScroll(const ImVec2& scroll); // Use -1.0f on one axis to leave as-is
|
||||
@ -2596,11 +2606,12 @@ namespace ImGui
|
||||
// Logging/Capture
|
||||
IMGUI_API void LogBegin(ImGuiLogType type, int auto_open_depth); // -> BeginCapture() when we design v2 api, for now stay under the radar by using the old name.
|
||||
IMGUI_API void LogToBuffer(int auto_open_depth = -1); // Start logging/capturing to internal buffer
|
||||
IMGUI_API void LogRenderedText(const ImVec2* ref_pos, const char* text, const char* text_end = NULL);
|
||||
IMGUI_API void LogRenderedText(const ImVec2* ref_pos, ImStrv text);
|
||||
inline void LogRenderedText(const ImVec2* ref_pos, const char* text, const char* text_end) { LogRenderedText(ref_pos, ImStrv(text, text_end)); }
|
||||
IMGUI_API void LogSetNextTextDecoration(const char* prefix, const char* suffix);
|
||||
|
||||
// Popups, Modals, Tooltips
|
||||
IMGUI_API bool BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags flags);
|
||||
IMGUI_API bool BeginChildEx(ImStrv name, ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags flags);
|
||||
IMGUI_API void OpenPopupEx(ImGuiID id, ImGuiPopupFlags popup_flags = ImGuiPopupFlags_None);
|
||||
IMGUI_API void ClosePopupToLevel(int remaining, bool restore_focus_to_window_under_popup);
|
||||
IMGUI_API void ClosePopupsOverWindow(ImGuiWindow* ref_window, bool restore_focus_to_window_under_popup);
|
||||
@ -2615,9 +2626,9 @@ namespace ImGui
|
||||
IMGUI_API ImVec2 FindBestWindowPosForPopupEx(const ImVec2& ref_pos, const ImVec2& size, ImGuiDir* last_dir, const ImRect& r_outer, const ImRect& r_avoid, ImGuiPopupPositionPolicy policy);
|
||||
|
||||
// Menus
|
||||
IMGUI_API bool BeginViewportSideBar(const char* name, ImGuiViewport* viewport, ImGuiDir dir, float size, ImGuiWindowFlags window_flags);
|
||||
IMGUI_API bool BeginMenuEx(const char* label, const char* icon, bool enabled = true);
|
||||
IMGUI_API bool MenuItemEx(const char* label, const char* icon, const char* shortcut = NULL, bool selected = false, bool enabled = true);
|
||||
IMGUI_API bool BeginViewportSideBar(ImStrv name, ImGuiViewport* viewport, ImGuiDir dir, float size, ImGuiWindowFlags window_flags);
|
||||
IMGUI_API bool BeginMenuEx(ImStrv label, ImStrv icon, bool enabled = true);
|
||||
IMGUI_API bool MenuItemEx(ImStrv label, ImStrv icon, ImStrv shortcut = ImStrv(), bool selected = false, bool enabled = true);
|
||||
|
||||
// Combos
|
||||
IMGUI_API bool BeginComboPopup(ImGuiID popup_id, const ImRect& bb, ImGuiComboFlags flags);
|
||||
@ -2676,12 +2687,12 @@ namespace ImGui
|
||||
|
||||
// Internal Columns API (this is not exposed because we will encourage transitioning to the Tables API)
|
||||
IMGUI_API void SetWindowClipRectBeforeSetChannel(ImGuiWindow* window, const ImRect& clip_rect);
|
||||
IMGUI_API void BeginColumns(const char* str_id, int count, ImGuiOldColumnFlags flags = 0); // setup number of columns. use an identifier to distinguish multiple column sets. close with EndColumns().
|
||||
IMGUI_API void BeginColumns(ImStrv str_id, int count, ImGuiOldColumnFlags flags = 0); // setup number of columns. use an identifier to distinguish multiple column sets. close with EndColumns().
|
||||
IMGUI_API void EndColumns(); // close columns
|
||||
IMGUI_API void PushColumnClipRect(int column_index);
|
||||
IMGUI_API void PushColumnsBackground();
|
||||
IMGUI_API void PopColumnsBackground();
|
||||
IMGUI_API ImGuiID GetColumnsID(const char* str_id, int count);
|
||||
IMGUI_API ImGuiID GetColumnsID(ImStrv str_id, int count);
|
||||
IMGUI_API ImGuiOldColumns* FindOrCreateColumns(ImGuiWindow* window, ImGuiID id);
|
||||
IMGUI_API float GetColumnOffsetFromNorm(const ImGuiOldColumns* columns, float offset_norm);
|
||||
IMGUI_API float GetColumnNormFromOffset(const ImGuiOldColumns* columns, float offset);
|
||||
@ -2698,7 +2709,7 @@ namespace ImGui
|
||||
// Tables: Internals
|
||||
inline ImGuiTable* GetCurrentTable() { ImGuiContext& g = *GImGui; return g.CurrentTable; }
|
||||
IMGUI_API ImGuiTable* TableFindByID(ImGuiID id);
|
||||
IMGUI_API bool BeginTableEx(const char* name, ImGuiID id, int columns_count, ImGuiTableFlags flags = 0, const ImVec2& outer_size = ImVec2(0, 0), float inner_width = 0.0f);
|
||||
IMGUI_API bool BeginTableEx(ImStrv name, ImGuiID id, int columns_count, ImGuiTableFlags flags = 0, const ImVec2& outer_size = ImVec2(0, 0), float inner_width = 0.0f);
|
||||
IMGUI_API void TableBeginInitMemory(ImGuiTable* table, int columns_count);
|
||||
IMGUI_API void TableBeginApplyRequests(ImGuiTable* table);
|
||||
IMGUI_API void TableSetupDrawChannels(ImGuiTable* table);
|
||||
@ -2745,24 +2756,29 @@ namespace ImGui
|
||||
IMGUI_API void TabBarQueueReorder(ImGuiTabBar* tab_bar, const ImGuiTabItem* tab, int offset);
|
||||
IMGUI_API void TabBarQueueReorderFromMousePos(ImGuiTabBar* tab_bar, const ImGuiTabItem* tab, ImVec2 mouse_pos);
|
||||
IMGUI_API bool TabBarProcessReorder(ImGuiTabBar* tab_bar);
|
||||
IMGUI_API bool TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open, ImGuiTabItemFlags flags);
|
||||
IMGUI_API ImVec2 TabItemCalcSize(const char* label, bool has_close_button);
|
||||
IMGUI_API bool TabItemEx(ImGuiTabBar* tab_bar, ImStrv label, bool* p_open, ImGuiTabItemFlags flags);
|
||||
IMGUI_API ImVec2 TabItemCalcSize(ImStrv label, bool has_close_button);
|
||||
IMGUI_API void TabItemBackground(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImU32 col);
|
||||
IMGUI_API void TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImVec2 frame_padding, const char* label, ImGuiID tab_id, ImGuiID close_button_id, bool is_contents_visible, bool* out_just_closed, bool* out_text_clipped);
|
||||
IMGUI_API void TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImVec2 frame_padding, ImStrv label, ImGuiID tab_id, ImGuiID close_button_id, bool is_contents_visible, bool* out_just_closed, bool* out_text_clipped);
|
||||
|
||||
// Render helpers
|
||||
// AVOID USING OUTSIDE OF IMGUI.CPP! NOT FOR PUBLIC CONSUMPTION. THOSE FUNCTIONS ARE A MESS. THEIR SIGNATURE AND BEHAVIOR WILL CHANGE, THEY NEED TO BE REFACTORED INTO SOMETHING DECENT.
|
||||
// NB: All position are in absolute pixels coordinates (we are never using window coordinates internally)
|
||||
IMGUI_API void RenderText(ImVec2 pos, const char* text, const char* text_end = NULL, bool hide_text_after_hash = true);
|
||||
IMGUI_API void RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end, float wrap_width);
|
||||
IMGUI_API void RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, const ImVec2& align = ImVec2(0, 0), const ImRect* clip_rect = NULL);
|
||||
IMGUI_API void RenderTextClippedEx(ImDrawList* draw_list, const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, const ImVec2& align = ImVec2(0, 0), const ImRect* clip_rect = NULL);
|
||||
IMGUI_API void RenderTextEllipsis(ImDrawList* draw_list, const ImVec2& pos_min, const ImVec2& pos_max, float clip_max_x, float ellipsis_max_x, const char* text, const char* text_end, const ImVec2* text_size_if_known);
|
||||
IMGUI_API void RenderText(ImVec2 pos, ImStrv text, bool hide_text_after_hash = true);
|
||||
inline void RenderText(ImVec2 pos, const char* text, const char* text_end, bool hide_text_after_hash = true) { RenderText(pos, ImStrv(text, text_end), hide_text_after_hash); }
|
||||
IMGUI_API void RenderTextWrapped(ImVec2 pos, ImStrv text, float wrap_width);
|
||||
inline void RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end, float wrap_width) { RenderTextWrapped(pos, ImStrv(text, text_end), wrap_width); }
|
||||
IMGUI_API void RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, ImStrv text, const ImVec2* text_size_if_known, const ImVec2& align = ImVec2(0, 0), const ImRect* clip_rect = NULL);
|
||||
inline void RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, const ImVec2& align = ImVec2(0,0), const ImRect* clip_rect = NULL) { RenderTextClipped(pos_min, pos_max, ImStrv(text, text_end), text_size_if_known, align, clip_rect); }
|
||||
IMGUI_API void RenderTextClippedEx(ImDrawList* draw_list, const ImVec2& pos_min, const ImVec2& pos_max, ImStrv text, const ImVec2* text_size_if_known, const ImVec2& align = ImVec2(0, 0), const ImRect* clip_rect = NULL);
|
||||
inline void RenderTextClippedEx(ImDrawList* draw_list, const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, const ImVec2& align = ImVec2(0, 0), const ImRect* clip_rect = NULL) { RenderTextClippedEx(draw_list, pos_min, pos_max, ImStrv(text, text_end), text_size_if_known, align, clip_rect); }
|
||||
IMGUI_API void RenderTextEllipsis(ImDrawList* draw_list, const ImVec2& pos_min, const ImVec2& pos_max, float clip_max_x, float ellipsis_max_x, ImStrv text, const ImVec2* text_size_if_known);
|
||||
IMGUI_API void RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border = true, float rounding = 0.0f);
|
||||
IMGUI_API void RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding = 0.0f);
|
||||
IMGUI_API void RenderColorRectWithAlphaCheckerboard(ImDrawList* draw_list, ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, float grid_step, ImVec2 grid_off, float rounding = 0.0f, ImDrawFlags flags = 0);
|
||||
IMGUI_API void RenderNavHighlight(const ImRect& bb, ImGuiID id, ImGuiNavHighlightFlags flags = ImGuiNavHighlightFlags_TypeDefault); // Navigation highlight
|
||||
IMGUI_API const char* FindRenderedTextEnd(const char* text, const char* text_end = NULL); // Find the optional ## from which we stop displaying text.
|
||||
IMGUI_API const char* FindRenderedTextEnd(ImStrv text); // Find the optional ## from which we stop displaying text.
|
||||
inline const char* FindRenderedTextEnd(const char* text, const char* text_end) { return FindRenderedTextEnd(ImStrv(text, text_end)); }
|
||||
IMGUI_API void RenderMouseCursor(ImVec2 pos, float scale, ImGuiMouseCursor mouse_cursor, ImU32 col_fill, ImU32 col_border, ImU32 col_shadow);
|
||||
|
||||
// Render helpers (those functions don't access any ImGui state!)
|
||||
@ -2780,11 +2796,12 @@ namespace ImGui
|
||||
#endif
|
||||
|
||||
// Widgets
|
||||
IMGUI_API void TextEx(const char* text, const char* text_end = NULL, ImGuiTextFlags flags = 0);
|
||||
IMGUI_API bool ButtonEx(const char* label, const ImVec2& size_arg = ImVec2(0, 0), ImGuiButtonFlags flags = 0);
|
||||
IMGUI_API void TextEx(ImStrv text, ImGuiTextFlags flags = 0);
|
||||
inline void TextEx(const char* text, const char* text_end, ImGuiTextFlags flags = 0) { TextEx(ImStrv(text, text_end), flags); }
|
||||
IMGUI_API bool ButtonEx(ImStrv label, const ImVec2& size_arg = ImVec2(0, 0), ImGuiButtonFlags flags = 0);
|
||||
IMGUI_API bool CloseButton(ImGuiID id, const ImVec2& pos);
|
||||
IMGUI_API bool CollapseButton(ImGuiID id, const ImVec2& pos);
|
||||
IMGUI_API bool ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size_arg, ImGuiButtonFlags flags = 0);
|
||||
IMGUI_API bool ArrowButtonEx(ImStrv str_id, ImGuiDir dir, ImVec2 size_arg, ImGuiButtonFlags flags = 0);
|
||||
IMGUI_API void Scrollbar(ImGuiAxis axis);
|
||||
IMGUI_API bool ScrollbarEx(const ImRect& bb, ImGuiID id, ImGuiAxis axis, ImS64* p_scroll_v, ImS64 avail_v, ImS64 contents_v, ImDrawFlags flags);
|
||||
IMGUI_API bool ImageButtonEx(ImGuiID id, ImTextureID texture_id, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, const ImVec2& padding, const ImVec4& bg_col, const ImVec4& tint_col);
|
||||
@ -2793,15 +2810,15 @@ namespace ImGui
|
||||
IMGUI_API ImGuiID GetWindowResizeCornerID(ImGuiWindow* window, int n); // 0..3: corners
|
||||
IMGUI_API ImGuiID GetWindowResizeBorderID(ImGuiWindow* window, ImGuiDir dir);
|
||||
IMGUI_API void SeparatorEx(ImGuiSeparatorFlags flags);
|
||||
IMGUI_API bool CheckboxFlags(const char* label, ImS64* flags, ImS64 flags_value);
|
||||
IMGUI_API bool CheckboxFlags(const char* label, ImU64* flags, ImU64 flags_value);
|
||||
IMGUI_API bool CheckboxFlags(ImStrv label, ImS64* flags, ImS64 flags_value);
|
||||
IMGUI_API bool CheckboxFlags(ImStrv label, ImU64* flags, ImU64 flags_value);
|
||||
|
||||
// Widgets low-level behaviors
|
||||
IMGUI_API bool ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool* out_held, ImGuiButtonFlags flags = 0);
|
||||
IMGUI_API bool DragBehavior(ImGuiID id, ImGuiDataType data_type, void* p_v, float v_speed, const void* p_min, const void* p_max, const char* format, ImGuiSliderFlags flags);
|
||||
IMGUI_API bool SliderBehavior(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, void* p_v, const void* p_min, const void* p_max, const char* format, ImGuiSliderFlags flags, ImRect* out_grab_bb);
|
||||
IMGUI_API bool SplitterBehavior(const ImRect& bb, ImGuiID id, ImGuiAxis axis, float* size1, float* size2, float min_size1, float min_size2, float hover_extend = 0.0f, float hover_visibility_delay = 0.0f);
|
||||
IMGUI_API bool TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end = NULL);
|
||||
IMGUI_API bool TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, ImStrv label);
|
||||
IMGUI_API bool TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags = 0); // Consume previous SetNextItemOpen() data, if any. May return true when logging
|
||||
IMGUI_API void TreePushOverrideID(ImGuiID id);
|
||||
|
||||
@ -2813,7 +2830,7 @@ namespace ImGui
|
||||
template<typename T, typename SIGNED_T, typename FLOAT_T> IMGUI_API bool DragBehaviorT(ImGuiDataType data_type, T* v, float v_speed, T v_min, T v_max, const char* format, ImGuiSliderFlags flags);
|
||||
template<typename T, typename SIGNED_T, typename FLOAT_T> IMGUI_API bool SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, T* v, T v_min, T v_max, const char* format, ImGuiSliderFlags flags, ImRect* out_grab_bb);
|
||||
template<typename T, typename SIGNED_T> IMGUI_API T RoundScalarWithFormatT(const char* format, ImGuiDataType data_type, T v);
|
||||
template<typename T> IMGUI_API bool CheckboxFlagsT(const char* label, T* flags, T flags_value);
|
||||
template<typename T> IMGUI_API bool CheckboxFlagsT(ImStrv label, T* flags, T flags_value);
|
||||
|
||||
// Data type helpers
|
||||
IMGUI_API const ImGuiDataTypeInfo* DataTypeGetInfo(ImGuiDataType data_type);
|
||||
@ -2824,19 +2841,19 @@ namespace ImGui
|
||||
IMGUI_API bool DataTypeClamp(ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max);
|
||||
|
||||
// InputText
|
||||
IMGUI_API bool InputTextEx(const char* label, const char* hint, char* buf, int buf_size, const ImVec2& size_arg, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback = NULL, void* user_data = NULL);
|
||||
IMGUI_API bool TempInputText(const ImRect& bb, ImGuiID id, const char* label, char* buf, int buf_size, ImGuiInputTextFlags flags);
|
||||
IMGUI_API bool TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImGuiDataType data_type, void* p_data, const char* format, const void* p_clamp_min = NULL, const void* p_clamp_max = NULL);
|
||||
IMGUI_API bool InputTextEx(ImStrv label, ImStrv hint, char* buf, int buf_size, const ImVec2& size_arg, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback = NULL, void* user_data = NULL);
|
||||
IMGUI_API bool TempInputText(const ImRect& bb, ImGuiID id, ImStrv label, char* buf, int buf_size, ImGuiInputTextFlags flags);
|
||||
IMGUI_API bool TempInputScalar(const ImRect& bb, ImGuiID id, ImStrv label, ImGuiDataType data_type, void* p_data, const char* format, const void* p_clamp_min = NULL, const void* p_clamp_max = NULL);
|
||||
inline bool TempInputIsActive(ImGuiID id) { ImGuiContext& g = *GImGui; return (g.ActiveId == id && g.TempInputId == id); }
|
||||
inline ImGuiInputTextState* GetInputTextState(ImGuiID id) { ImGuiContext& g = *GImGui; return (g.InputTextState.ID == id) ? &g.InputTextState : NULL; } // Get input text state if active
|
||||
|
||||
// Color
|
||||
IMGUI_API void ColorTooltip(const char* text, const float* col, ImGuiColorEditFlags flags);
|
||||
IMGUI_API void ColorTooltip(ImStrv text, const float* col, ImGuiColorEditFlags flags);
|
||||
IMGUI_API void ColorEditOptionsPopup(const float* col, ImGuiColorEditFlags flags);
|
||||
IMGUI_API void ColorPickerOptionsPopup(const float* ref_col, ImGuiColorEditFlags flags);
|
||||
|
||||
// Plot
|
||||
IMGUI_API int PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 frame_size);
|
||||
IMGUI_API int PlotEx(ImGuiPlotType plot_type, ImStrv label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, ImStrv overlay_text, float scale_min, float scale_max, ImVec2 frame_size);
|
||||
|
||||
// Shade functions (write over already created vertices)
|
||||
IMGUI_API void ShadeVertsLinearColorGradientKeepAlpha(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, ImVec2 gradient_p0, ImVec2 gradient_p1, ImU32 col0, ImU32 col1);
|
||||
@ -2902,7 +2919,7 @@ IMGUI_API void ImFontAtlasBuildMultiplyRectAlpha8(const unsigned char table
|
||||
|
||||
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
||||
extern void ImGuiTestEngineHook_ItemAdd(ImGuiContext* ctx, const ImRect& bb, ImGuiID id);
|
||||
extern void ImGuiTestEngineHook_ItemInfo(ImGuiContext* ctx, ImGuiID id, const char* label, ImGuiItemStatusFlags flags);
|
||||
extern void ImGuiTestEngineHook_ItemInfo(ImGuiContext* ctx, ImGuiID id, ImStrv label, ImGuiItemStatusFlags flags);
|
||||
extern void ImGuiTestEngineHook_Log(ImGuiContext* ctx, const char* fmt, ...);
|
||||
extern const char* ImGuiTestEngine_FindItemDebugLabel(ImGuiContext* ctx, ImGuiID id);
|
||||
|
||||
|
@ -301,13 +301,13 @@ ImGuiTable* ImGui::TableFindByID(ImGuiID id)
|
||||
}
|
||||
|
||||
// Read about "TABLE SIZING" at the top of this file.
|
||||
bool ImGui::BeginTable(const char* str_id, int columns_count, ImGuiTableFlags flags, const ImVec2& outer_size, float inner_width)
|
||||
bool ImGui::BeginTable(ImStrv str_id, int columns_count, ImGuiTableFlags flags, const ImVec2& outer_size, float inner_width)
|
||||
{
|
||||
ImGuiID id = GetID(str_id);
|
||||
return BeginTableEx(str_id, id, columns_count, flags, outer_size, inner_width);
|
||||
}
|
||||
|
||||
bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImGuiTableFlags flags, const ImVec2& outer_size, float inner_width)
|
||||
bool ImGui::BeginTableEx(ImStrv name, ImGuiID id, int columns_count, ImGuiTableFlags flags, const ImVec2& outer_size, float inner_width)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* outer_window = GetCurrentWindow();
|
||||
@ -1394,7 +1394,7 @@ void ImGui::EndTable()
|
||||
|
||||
// See "COLUMN SIZING POLICIES" comments at the top of this file
|
||||
// If (init_width_or_weight <= 0.0f) it is ignored
|
||||
void ImGui::TableSetupColumn(const char* label, ImGuiTableColumnFlags flags, float init_width_or_weight, ImGuiID user_id)
|
||||
void ImGui::TableSetupColumn(ImStrv label, ImGuiTableColumnFlags flags, float init_width_or_weight, ImGuiID user_id)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiTable* table = g.CurrentTable;
|
||||
@ -1454,10 +1454,12 @@ void ImGui::TableSetupColumn(const char* label, ImGuiTableColumnFlags flags, flo
|
||||
|
||||
// Store name (append with zero-terminator in contiguous buffer)
|
||||
column->NameOffset = -1;
|
||||
if (label != NULL && label[0] != 0)
|
||||
if (!label.empty())
|
||||
{
|
||||
char zero_terminator = 0;
|
||||
column->NameOffset = (ImS16)table->ColumnsNames.size();
|
||||
table->ColumnsNames.append(label, label + strlen(label) + 1);
|
||||
table->ColumnsNames.append(label);
|
||||
table->ColumnsNames.append(ImStrv(&zero_terminator, &zero_terminator + 1));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2856,7 +2858,7 @@ void ImGui::TableHeadersRow()
|
||||
// Emit a column header (text + optional sort order)
|
||||
// We cpu-clip text here so that all columns headers can be merged into a same draw call.
|
||||
// Note that because of how we cpu-clip and display sorting indicators, you _cannot_ use SameLine() after a TableHeader()
|
||||
void ImGui::TableHeader(const char* label)
|
||||
void ImGui::TableHeader(ImStrv label)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
@ -2870,10 +2872,11 @@ void ImGui::TableHeader(const char* label)
|
||||
ImGuiTableColumn* column = &table->Columns[column_n];
|
||||
|
||||
// Label
|
||||
if (label == NULL)
|
||||
if (!label)
|
||||
label = "";
|
||||
const char* label_end = FindRenderedTextEnd(label);
|
||||
ImVec2 label_size = CalcTextSize(label, label_end, true);
|
||||
ImGuiID id = window->GetID(label);
|
||||
label.End = FindRenderedTextEnd(label);
|
||||
ImVec2 label_size = CalcTextSize(label, true);
|
||||
ImVec2 label_pos = window->DC.CursorPos;
|
||||
|
||||
// If we already got a row height, there's use that.
|
||||
@ -2903,7 +2906,6 @@ void ImGui::TableHeader(const char* label)
|
||||
|
||||
// Keep header highlighted when context menu is open.
|
||||
const bool selected = (table->IsContextPopupOpen && table->ContextPopupColumn == column_n && table->InstanceInteracted == table->InstanceCurrent);
|
||||
ImGuiID id = window->GetID(label);
|
||||
ImRect bb(cell_r.Min.x, cell_r.Min.y, cell_r.Max.x, ImMax(cell_r.Max.y, cell_r.Min.y + label_height + g.Style.CellPadding.y * 2.0f));
|
||||
ItemSize(ImVec2(0.0f, label_height)); // Don't declare unclipped width, it'll be fed ContentMaxPosHeadersIdeal
|
||||
if (!ItemAdd(bb, id))
|
||||
@ -2984,11 +2986,11 @@ void ImGui::TableHeader(const char* label)
|
||||
// Render clipped label. Clipping here ensure that in the majority of situations, all our header cells will
|
||||
// be merged into a single draw call.
|
||||
//window->DrawList->AddCircleFilled(ImVec2(ellipsis_max, label_pos.y), 40, IM_COL32_WHITE);
|
||||
RenderTextEllipsis(window->DrawList, label_pos, ImVec2(ellipsis_max, label_pos.y + label_height + g.Style.FramePadding.y), ellipsis_max, ellipsis_max, label, label_end, &label_size);
|
||||
RenderTextEllipsis(window->DrawList, label_pos, ImVec2(ellipsis_max, label_pos.y + label_height + g.Style.FramePadding.y), ellipsis_max, ellipsis_max, label, &label_size);
|
||||
|
||||
const bool text_clipped = label_size.x > (ellipsis_max - label_pos.x);
|
||||
if (text_clipped && hovered && g.HoveredIdNotActiveTimer > g.TooltipSlowDelay)
|
||||
SetTooltip("%.*s", (int)(label_end - label), label);
|
||||
SetTooltip("%.*s", (int)(label.End - label.Begin), label.Begin);
|
||||
|
||||
// We don't use BeginPopupContextItem() because we want the popup to stay up even after the column is hidden
|
||||
if (IsMouseReleased(1) && IsItemHovered())
|
||||
@ -3810,7 +3812,7 @@ ImGuiOldColumns* ImGui::FindOrCreateColumns(ImGuiWindow* window, ImGuiID id)
|
||||
return columns;
|
||||
}
|
||||
|
||||
ImGuiID ImGui::GetColumnsID(const char* str_id, int columns_count)
|
||||
ImGuiID ImGui::GetColumnsID(ImStrv str_id, int columns_count)
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
|
||||
@ -3823,7 +3825,7 @@ ImGuiID ImGui::GetColumnsID(const char* str_id, int columns_count)
|
||||
return id;
|
||||
}
|
||||
|
||||
void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiOldColumnFlags flags)
|
||||
void ImGui::BeginColumns(ImStrv str_id, int columns_count, ImGuiOldColumnFlags flags)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
@ -4031,7 +4033,7 @@ void ImGui::EndColumns()
|
||||
window->DC.CursorPos.x = IM_FLOOR(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x);
|
||||
}
|
||||
|
||||
void ImGui::Columns(int columns_count, const char* id, bool border)
|
||||
void ImGui::Columns(int columns_count, ImStrv id, bool border)
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
IM_ASSERT(columns_count >= 1);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -51,6 +51,11 @@ More information at: https://docs.microsoft.com/en-us/visualstudio/debugger/crea
|
||||
</Expand>
|
||||
</Type>
|
||||
|
||||
<!-- String view (non zero-terminated begin/end pair) -->
|
||||
<Type Name="ImStrv">
|
||||
<DisplayString>{Begin,[End-Begin]s} ({End-Begin,d})</DisplayString>
|
||||
</Type>
|
||||
|
||||
<Type Name="ImGuiWindow">
|
||||
<DisplayString>{{Name {Name,s} Active {(Active||WasActive)?1:0,d} Child {(Flags & 0x01000000)?1:0,d} Popup {(Flags & 0x04000000)?1:0,d} Hidden {(Hidden)?1:0,d}}</DisplayString>
|
||||
</Type>
|
||||
|
Reference in New Issue
Block a user