mirror of
https://github.com/ocornut/imgui.git
synced 2026-02-05 04:10:07 +00:00
Merge branch 'master' into docking
# Conflicts: # backends/imgui_impl_glfw.cpp # backends/imgui_impl_osx.mm # backends/imgui_impl_sdl.cpp # backends/imgui_impl_win32.cpp # imgui.cpp # imgui.h # imgui_internal.h # imgui_widgets.cpp
This commit is contained in:
commit
887abe9578
30 changed files with 676 additions and 180 deletions
70
imgui.cpp
70
imgui.cpp
|
|
@ -11,7 +11,7 @@
|
|||
// - FAQ http://dearimgui.org/faq
|
||||
// - Homepage & latest https://github.com/ocornut/imgui
|
||||
// - Releases & changelog https://github.com/ocornut/imgui/releases
|
||||
// - Gallery https://github.com/ocornut/imgui/issues/5243 (please post your screenshots/video there!)
|
||||
// - Gallery https://github.com/ocornut/imgui/issues/5886 (please post your screenshots/video there!)
|
||||
// - Wiki https://github.com/ocornut/imgui/wiki (lots of good stuff there)
|
||||
// - Glossary https://github.com/ocornut/imgui/wiki/Glossary
|
||||
// - Issues & support https://github.com/ocornut/imgui/issues
|
||||
|
|
@ -1503,7 +1503,7 @@ void ImGuiIO::AddMouseButtonEvent(int mouse_button, bool down)
|
|||
g.InputEventsQueue.push_back(e);
|
||||
}
|
||||
|
||||
// Queue a mouse wheel event (most mouse/API will only have a Y component)
|
||||
// Queue a mouse wheel event (some mouse/API may only have a Y component)
|
||||
void ImGuiIO::AddMouseWheelEvent(float wheel_x, float wheel_y)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
|
@ -1862,18 +1862,36 @@ void ImFormatStringToTempBuffer(const char** out_buf, const char** out_buf_end,
|
|||
ImGuiContext& g = *GImGui;
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
int buf_len = ImFormatStringV(g.TempBuffer.Data, g.TempBuffer.Size, fmt, args);
|
||||
*out_buf = g.TempBuffer.Data;
|
||||
if (out_buf_end) { *out_buf_end = g.TempBuffer.Data + buf_len; }
|
||||
if (fmt[0] == '%' && fmt[1] == 's' && fmt[2] == 0)
|
||||
{
|
||||
const char* buf = va_arg(args, const char*); // Skip formatting when using "%s"
|
||||
*out_buf = buf;
|
||||
if (out_buf_end) { *out_buf_end = buf + strlen(buf); }
|
||||
}
|
||||
else
|
||||
{
|
||||
int buf_len = ImFormatStringV(g.TempBuffer.Data, g.TempBuffer.Size, fmt, args);
|
||||
*out_buf = g.TempBuffer.Data;
|
||||
if (out_buf_end) { *out_buf_end = g.TempBuffer.Data + buf_len; }
|
||||
}
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void ImFormatStringToTempBufferV(const char** out_buf, const char** out_buf_end, const char* fmt, va_list args)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
int buf_len = ImFormatStringV(g.TempBuffer.Data, g.TempBuffer.Size, fmt, args);
|
||||
*out_buf = g.TempBuffer.Data;
|
||||
if (out_buf_end) { *out_buf_end = g.TempBuffer.Data + buf_len; }
|
||||
if (fmt[0] == '%' && fmt[1] == 's' && fmt[2] == 0)
|
||||
{
|
||||
const char* buf = va_arg(args, const char*); // Skip formatting when using "%s"
|
||||
*out_buf = buf;
|
||||
if (out_buf_end) { *out_buf_end = buf + strlen(buf); }
|
||||
}
|
||||
else
|
||||
{
|
||||
int buf_len = ImFormatStringV(g.TempBuffer.Data, g.TempBuffer.Size, fmt, args);
|
||||
*out_buf = g.TempBuffer.Data;
|
||||
if (out_buf_end) { *out_buf_end = g.TempBuffer.Data + buf_len; }
|
||||
}
|
||||
}
|
||||
|
||||
// CRC32 needs a 1KB lookup table (not cache friendly)
|
||||
|
|
@ -1960,7 +1978,7 @@ ImFileHandle ImFileOpen(const char* filename, const char* mode)
|
|||
// 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;
|
||||
ImVector<wchar_t> 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);
|
||||
|
|
@ -6173,12 +6191,15 @@ void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar
|
|||
{
|
||||
for (int resize_grip_n = 0; resize_grip_n < resize_grip_count; resize_grip_n++)
|
||||
{
|
||||
const ImU32 col = resize_grip_col[resize_grip_n];
|
||||
if ((col & IM_COL32_A_MASK) == 0)
|
||||
continue;
|
||||
const ImGuiResizeGripDef& grip = resize_grip_def[resize_grip_n];
|
||||
const ImVec2 corner = ImLerp(window->Pos, window->Pos + window->Size, grip.CornerPosN);
|
||||
window->DrawList->PathLineTo(corner + grip.InnerDir * ((resize_grip_n & 1) ? ImVec2(window_border_size, resize_grip_draw_size) : ImVec2(resize_grip_draw_size, window_border_size)));
|
||||
window->DrawList->PathLineTo(corner + grip.InnerDir * ((resize_grip_n & 1) ? ImVec2(resize_grip_draw_size, window_border_size) : ImVec2(window_border_size, resize_grip_draw_size)));
|
||||
window->DrawList->PathArcToFast(ImVec2(corner.x + grip.InnerDir.x * (window_rounding + window_border_size), corner.y + grip.InnerDir.y * (window_rounding + window_border_size)), window_rounding, grip.AngleMin12, grip.AngleMax12);
|
||||
window->DrawList->PathFillConvex(resize_grip_col[resize_grip_n]);
|
||||
window->DrawList->PathFillConvex(col);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -9075,7 +9096,8 @@ void ImGui::UpdateMouseWheel()
|
|||
|
||||
// Mouse wheel scrolling
|
||||
// As a standard behavior holding SHIFT while using Vertical Mouse Wheel triggers Horizontal scroll instead
|
||||
// (we avoid doing it on OSX as it the OS input layer handles this already)
|
||||
// - We avoid doing it on OSX as it the OS input layer handles this already.
|
||||
// - However this means when running on OSX over Emcripten, Shift+WheelY will incur two swappings (1 in OS, 1 here), cancelling the feature.
|
||||
const bool swap_axis = g.IO.KeyShift && !g.IO.ConfigMacOSXBehaviors;
|
||||
if (swap_axis)
|
||||
{
|
||||
|
|
@ -9462,6 +9484,13 @@ static void ImGui::ErrorCheckNewFrameSanityChecks()
|
|||
// #define IM_ASSERT(EXPR) do { if (SomeCode(EXPR)) SomeMoreCode(); } while (0) // Correct!
|
||||
if (true) IM_ASSERT(1); else IM_ASSERT(0);
|
||||
|
||||
// Emscripten backends are often imprecise in their submission of DeltaTime. (#6114, #3644)
|
||||
// Ideally the Emscripten app/backend should aim to fix or smooth this value and avoid feeding zero, but we tolerate it.
|
||||
#ifdef __EMSCRIPTEN__
|
||||
if (g.IO.DeltaTime <= 0.0f && g.FrameCount > 0)
|
||||
g.IO.DeltaTime = 0.00001f;
|
||||
#endif
|
||||
|
||||
// Check user data
|
||||
// (We pass an error message in the assert expression to make it visible to programmers who are not using a debugger, as most assert handlers display their argument)
|
||||
IM_ASSERT(g.Initialized);
|
||||
|
|
@ -15311,7 +15340,7 @@ int ImGui::DockNodeGetTabOrder(ImGuiWindow* window)
|
|||
if (tab_bar == NULL)
|
||||
return -1;
|
||||
ImGuiTabItem* tab = TabBarFindTabByID(tab_bar, window->TabId);
|
||||
return tab ? tab_bar->GetTabOrder(tab) : -1;
|
||||
return tab ? TabBarGetTabOrder(tab_bar, tab) : -1;
|
||||
}
|
||||
|
||||
static void DockNodeHideWindowDuringHostWindowCreation(ImGuiWindow* window)
|
||||
|
|
@ -16063,7 +16092,7 @@ static ImGuiID ImGui::DockNodeUpdateWindowMenu(ImGuiDockNode* node, ImGuiTabBar*
|
|||
ImGuiTabItem* tab = &tab_bar->Tabs[tab_n];
|
||||
if (tab->Flags & ImGuiTabItemFlags_Button)
|
||||
continue;
|
||||
if (Selectable(tab_bar->GetTabName(tab), tab->ID == tab_bar->SelectedTabId))
|
||||
if (Selectable(TabBarGetTabName(tab_bar, tab), tab->ID == tab_bar->SelectedTabId))
|
||||
ret_tab_id = tab->ID;
|
||||
SameLine();
|
||||
Text(" ");
|
||||
|
|
@ -18639,10 +18668,13 @@ void ImGui::ShowFontAtlas(ImFontAtlas* atlas)
|
|||
DebugNodeFont(font);
|
||||
PopID();
|
||||
}
|
||||
if (TreeNode("Atlas texture", "Atlas texture (%dx%d pixels)", atlas->TexWidth, atlas->TexHeight))
|
||||
if (TreeNode("Font Atlas", "Font Atlas (%dx%d pixels)", atlas->TexWidth, atlas->TexHeight))
|
||||
{
|
||||
ImVec4 tint_col = ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
ImVec4 border_col = ImVec4(1.0f, 1.0f, 1.0f, 0.5f);
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiMetricsConfig* cfg = &g.DebugMetricsConfig;
|
||||
Checkbox("Tint with Text Color", &cfg->ShowAtlasTintedWithTextColor); // Using text color ensure visibility of core atlas data, but will alter custom colored icons
|
||||
ImVec4 tint_col = cfg->ShowAtlasTintedWithTextColor ? GetStyleColorVec4(ImGuiCol_Text) : ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
ImVec4 border_col = GetStyleColorVec4(ImGuiCol_Border);
|
||||
Image(atlas->TexID, ImVec2((float)atlas->TexWidth, (float)atlas->TexHeight), ImVec2(0.0f, 0.0f), ImVec2(1.0f, 1.0f), tint_col, border_col);
|
||||
TreePop();
|
||||
}
|
||||
|
|
@ -19606,7 +19638,7 @@ void ImGui::DebugNodeTabBar(ImGuiTabBar* tab_bar, const char* label)
|
|||
{
|
||||
ImGuiTabItem* tab = &tab_bar->Tabs[tab_n];
|
||||
p += ImFormatString(p, buf_end - p, "%s'%s'",
|
||||
tab_n > 0 ? ", " : "", (tab->Window || tab->NameOffset != -1) ? tab_bar->GetTabName(tab) : "???");
|
||||
tab_n > 0 ? ", " : "", (tab->Window || tab->NameOffset != -1) ? TabBarGetTabName(tab_bar, tab) : "???");
|
||||
}
|
||||
p += ImFormatString(p, buf_end - p, (tab_bar->Tabs.Size > 3) ? " ... }" : " } ");
|
||||
if (!is_active) { PushStyleColor(ImGuiCol_Text, GetStyleColorVec4(ImGuiCol_TextDisabled)); }
|
||||
|
|
@ -19623,12 +19655,12 @@ void ImGui::DebugNodeTabBar(ImGuiTabBar* tab_bar, const char* label)
|
|||
{
|
||||
for (int tab_n = 0; tab_n < tab_bar->Tabs.Size; tab_n++)
|
||||
{
|
||||
const ImGuiTabItem* tab = &tab_bar->Tabs[tab_n];
|
||||
ImGuiTabItem* tab = &tab_bar->Tabs[tab_n];
|
||||
PushID(tab);
|
||||
if (SmallButton("<")) { TabBarQueueReorder(tab_bar, tab, -1); } SameLine(0, 2);
|
||||
if (SmallButton(">")) { TabBarQueueReorder(tab_bar, tab, +1); } SameLine();
|
||||
Text("%02d%c Tab 0x%08X '%s' Offset: %.2f, Width: %.2f/%.2f",
|
||||
tab_n, (tab->ID == tab_bar->SelectedTabId) ? '*' : ' ', tab->ID, (tab->Window || tab->NameOffset != -1) ? tab_bar->GetTabName(tab) : "???", tab->Offset, tab->Width, tab->ContentWidth);
|
||||
tab_n, (tab->ID == tab_bar->SelectedTabId) ? '*' : ' ', tab->ID, (tab->Window || tab->NameOffset != -1) ? TabBarGetTabName(tab_bar, tab) : "???", tab->Offset, tab->Width, tab->ContentWidth);
|
||||
PopID();
|
||||
}
|
||||
TreePop();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue