mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-02-17 20:52:36 +01:00
Updated ImGui.
This commit is contained in:
15
3rdparty/dear-imgui/imgui.cpp
vendored
15
3rdparty/dear-imgui/imgui.cpp
vendored
@@ -1280,6 +1280,7 @@ ImVec2 ImTriangleClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c,
|
||||
return proj_ca;
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
int d;
|
||||
@@ -1296,9 +1297,11 @@ int ImStrnicmp(const char* str1, const char* str2, size_t count)
|
||||
|
||||
void ImStrncpy(char* dst, const char* src, size_t count)
|
||||
{
|
||||
if (count < 1) return;
|
||||
strncpy(dst, src, count);
|
||||
dst[count-1] = 0;
|
||||
if (count < 1)
|
||||
return;
|
||||
if (count > 1)
|
||||
strncpy(dst, src, count - 1);
|
||||
dst[count - 1] = 0;
|
||||
}
|
||||
|
||||
char* ImStrdup(const char* str)
|
||||
@@ -2643,6 +2646,7 @@ void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window)
|
||||
}
|
||||
g.ActiveId = id;
|
||||
g.ActiveIdAllowNavDirFlags = 0;
|
||||
g.ActiveIdBlockNavInputFlags = 0;
|
||||
g.ActiveIdAllowOverlap = false;
|
||||
g.ActiveIdWindow = window;
|
||||
if (id)
|
||||
@@ -2797,7 +2801,7 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg)
|
||||
|
||||
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
||||
if (id != 0)
|
||||
ImGuiTestEngineHook_ItemAdd(&g, bb, id);
|
||||
ImGuiTestEngineHook_ItemAdd(&g, nav_bb_arg ? *nav_bb_arg : bb, id);
|
||||
#endif
|
||||
|
||||
// Clipping test
|
||||
@@ -7629,7 +7633,8 @@ static void ImGui::NavUpdate()
|
||||
{
|
||||
if (g.ActiveId != 0)
|
||||
{
|
||||
ClearActiveID();
|
||||
if (!(g.ActiveIdBlockNavInputFlags & (1 << ImGuiNavInput_Cancel)))
|
||||
ClearActiveID();
|
||||
}
|
||||
else if (g.NavWindow && (g.NavWindow->Flags & ImGuiWindowFlags_ChildWindow) && !(g.NavWindow->Flags & ImGuiWindowFlags_Popup) && g.NavWindow->ParentWindow)
|
||||
{
|
||||
|
||||
24
3rdparty/dear-imgui/imgui_demo.cpp
vendored
24
3rdparty/dear-imgui/imgui_demo.cpp
vendored
@@ -1034,16 +1034,18 @@ static void ShowDemoWindowWidgets()
|
||||
|
||||
ImGui::Text("Color button with Custom Picker Popup:");
|
||||
|
||||
// Generate a dummy palette
|
||||
static bool saved_palette_inited = false;
|
||||
static ImVec4 saved_palette[32];
|
||||
if (!saved_palette_inited)
|
||||
// Generate a dummy default palette. The palette will persist and can be edited.
|
||||
static bool saved_palette_init = true;
|
||||
static ImVec4 saved_palette[32] = { };
|
||||
if (saved_palette_init)
|
||||
{
|
||||
for (int n = 0; n < IM_ARRAYSIZE(saved_palette); n++)
|
||||
{
|
||||
ImGui::ColorConvertHSVtoRGB(n / 31.0f, 0.8f, 0.8f, saved_palette[n].x, saved_palette[n].y, saved_palette[n].z);
|
||||
saved_palette[n].w = 1.0f; // Alpha
|
||||
}
|
||||
saved_palette_inited = true;
|
||||
saved_palette_init = false;
|
||||
}
|
||||
|
||||
static ImVec4 backup_color;
|
||||
bool open_popup = ImGui::ColorButton("MyColor##3b", color, misc_flags);
|
||||
@@ -1056,12 +1058,12 @@ static void ShowDemoWindowWidgets()
|
||||
}
|
||||
if (ImGui::BeginPopup("mypicker"))
|
||||
{
|
||||
// FIXME: Adding a drag and drop example here would be perfect!
|
||||
ImGui::Text("MY CUSTOM COLOR PICKER WITH AN AMAZING PALETTE!");
|
||||
ImGui::Separator();
|
||||
ImGui::ColorPicker4("##picker", (float*)&color, misc_flags | ImGuiColorEditFlags_NoSidePreview | ImGuiColorEditFlags_NoSmallPreview);
|
||||
ImGui::SameLine();
|
||||
ImGui::BeginGroup();
|
||||
|
||||
ImGui::BeginGroup(); // Lock X position
|
||||
ImGui::Text("Current");
|
||||
ImGui::ColorButton("##current", color, ImGuiColorEditFlags_NoPicker | ImGuiColorEditFlags_AlphaPreviewHalf, ImVec2(60,40));
|
||||
ImGui::Text("Previous");
|
||||
@@ -1077,6 +1079,8 @@ static void ShowDemoWindowWidgets()
|
||||
if (ImGui::ColorButton("##palette", saved_palette[n], ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoPicker | ImGuiColorEditFlags_NoTooltip, ImVec2(20,20)))
|
||||
color = ImVec4(saved_palette[n].x, saved_palette[n].y, saved_palette[n].z, color.w); // Preserve alpha!
|
||||
|
||||
// Allow user to drop colors into each palette entry
|
||||
// (Note that ColorButton is already a drag source by default, unless using ImGuiColorEditFlags_NoDragDrop)
|
||||
if (ImGui::BeginDragDropTarget())
|
||||
{
|
||||
if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_3F))
|
||||
@@ -3397,6 +3401,12 @@ struct ExampleAppLog
|
||||
ImVector<int> LineOffsets; // Index to lines offset. We maintain this with AddLog() calls, allowing us to have a random access on lines
|
||||
bool ScrollToBottom;
|
||||
|
||||
ExampleAppLog()
|
||||
{
|
||||
ScrollToBottom = false;
|
||||
Clear();
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
Buf.clear();
|
||||
|
||||
6
3rdparty/dear-imgui/imgui_internal.h
vendored
6
3rdparty/dear-imgui/imgui_internal.h
vendored
@@ -777,6 +777,7 @@ struct ImGuiContext
|
||||
bool ActiveIdPreviousFrameIsAlive;
|
||||
bool ActiveIdPreviousFrameHasBeenEdited;
|
||||
int ActiveIdAllowNavDirFlags; // Active widget allows using directional navigation (e.g. can activate a button and move away from it)
|
||||
int ActiveIdBlockNavInputFlags;
|
||||
ImVec2 ActiveIdClickOffset; // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior)
|
||||
ImGuiWindow* ActiveIdWindow;
|
||||
ImGuiWindow* ActiveIdPreviousFrameWindow;
|
||||
@@ -931,7 +932,8 @@ struct ImGuiContext
|
||||
ActiveIdHasBeenEdited = false;
|
||||
ActiveIdPreviousFrameIsAlive = false;
|
||||
ActiveIdPreviousFrameHasBeenEdited = false;
|
||||
ActiveIdAllowNavDirFlags = 0;
|
||||
ActiveIdAllowNavDirFlags = 0x00;
|
||||
ActiveIdBlockNavInputFlags = 0x00;
|
||||
ActiveIdClickOffset = ImVec2(-1,-1);
|
||||
ActiveIdWindow = ActiveIdPreviousFrameWindow = NULL;
|
||||
ActiveIdSource = ImGuiInputSource_None;
|
||||
@@ -1475,7 +1477,7 @@ IMGUI_API void ImFontAtlasBuildMultiplyRectAlpha8(const unsigned ch
|
||||
extern void ImGuiTestEngineHook_PreNewFrame(ImGuiContext* ctx);
|
||||
extern void ImGuiTestEngineHook_PostNewFrame(ImGuiContext* ctx);
|
||||
extern void ImGuiTestEngineHook_ItemAdd(ImGuiContext* ctx, const ImRect& bb, ImGuiID id);
|
||||
extern void ImGuiTestEngineHook_ItemInfo(ImGuiContext* ctx, ImGuiID id, const char* label, int flags);
|
||||
extern void ImGuiTestEngineHook_ItemInfo(ImGuiContext* ctx, ImGuiID id, const char* label, ImGuiItemStatusFlags flags);
|
||||
#define IMGUI_TEST_ENGINE_ITEM_INFO(_ID, _LABEL, _FLAGS) ImGuiTestEngineHook_ItemInfo(&g, _ID, _LABEL, _FLAGS) // Register status flags
|
||||
#else
|
||||
#define IMGUI_TEST_ENGINE_ITEM_INFO(_ID, _LABEL, _FLAGS) do { } while (0)
|
||||
|
||||
27
3rdparty/dear-imgui/imgui_widgets.cpp
vendored
27
3rdparty/dear-imgui/imgui_widgets.cpp
vendored
@@ -577,6 +577,7 @@ bool ImGui::ButtonEx(const char* label, const ImVec2& size_arg, ImGuiButtonFlags
|
||||
//if (pressed && !(flags & ImGuiButtonFlags_DontClosePopups) && (window->Flags & ImGuiWindowFlags_Popup))
|
||||
// CloseCurrentPopup();
|
||||
|
||||
IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.LastItemStatusFlags);
|
||||
return pressed;
|
||||
}
|
||||
|
||||
@@ -1929,6 +1930,7 @@ bool ImGui::DragScalar(const char* label, ImGuiDataType data_type, void* v, floa
|
||||
if (label_size.x > 0.0f)
|
||||
RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, inner_bb.Min.y), label);
|
||||
|
||||
IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.ItemFlags);
|
||||
return value_changed;
|
||||
}
|
||||
|
||||
@@ -2383,6 +2385,7 @@ bool ImGui::SliderScalar(const char* label, ImGuiDataType data_type, void* v, co
|
||||
if (label_size.x > 0.0f)
|
||||
RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label);
|
||||
|
||||
IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.ItemFlags);
|
||||
return value_changed;
|
||||
}
|
||||
|
||||
@@ -2629,17 +2632,15 @@ int ImParseFormatPrecision(const char* fmt, int default_precision)
|
||||
}
|
||||
|
||||
// Create text input in place of an active drag/slider (used when doing a CTRL+Click on drag/slider widgets)
|
||||
// FIXME: Logic is awkward and confusing. This should be reworked to facilitate using in other situations.
|
||||
// FIXME: Facilitate using this in variety of other situations.
|
||||
bool ImGui::InputScalarAsWidgetReplacement(const ImRect& bb, ImGuiID id, const char* label, ImGuiDataType data_type, void* data_ptr, const char* format)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
|
||||
// Our replacement widget will override the focus ID (registered previously to allow for a TAB focus to happen)
|
||||
// On the first frame, g.ScalarAsInputTextId == 0, then on subsequent frames it becomes == id
|
||||
SetActiveID(g.ScalarAsInputTextId, window);
|
||||
SetHoveredID(0);
|
||||
g.ActiveIdAllowNavDirFlags = (1 << ImGuiDir_Up) | (1 << ImGuiDir_Down);
|
||||
// On the first frame, g.ScalarAsInputTextId == 0, then on subsequent frames it becomes == id.
|
||||
// We clear ActiveID on the first frame to allow the InputText() taking it back.
|
||||
if (g.ScalarAsInputTextId == 0)
|
||||
ClearActiveID();
|
||||
|
||||
char fmt_buf[32];
|
||||
char data_buf[32];
|
||||
@@ -2648,11 +2649,11 @@ bool ImGui::InputScalarAsWidgetReplacement(const ImRect& bb, ImGuiID id, const c
|
||||
ImStrTrimBlanks(data_buf);
|
||||
ImGuiInputTextFlags flags = ImGuiInputTextFlags_AutoSelectAll | ((data_type == ImGuiDataType_Float || data_type == ImGuiDataType_Double) ? ImGuiInputTextFlags_CharsScientific : ImGuiInputTextFlags_CharsDecimal);
|
||||
bool value_changed = InputTextEx(label, data_buf, IM_ARRAYSIZE(data_buf), bb.GetSize(), flags);
|
||||
if (g.ScalarAsInputTextId == 0) // First frame we started displaying the InputText widget
|
||||
if (g.ScalarAsInputTextId == 0)
|
||||
{
|
||||
IM_ASSERT(g.ActiveId == id); // InputText ID expected to match the Slider ID
|
||||
// First frame we started displaying the InputText widget, we expect it to take the active id.
|
||||
IM_ASSERT(g.ActiveId == id);
|
||||
g.ScalarAsInputTextId = g.ActiveId;
|
||||
SetHoveredID(id);
|
||||
}
|
||||
if (value_changed)
|
||||
return DataTypeApplyOpFromText(data_buf, g.InputTextState.InitialText.Data, data_type, data_ptr, NULL);
|
||||
@@ -3269,8 +3270,9 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
||||
SetActiveID(id, window);
|
||||
SetFocusID(id, window);
|
||||
FocusWindow(window);
|
||||
g.ActiveIdBlockNavInputFlags = (1 << ImGuiNavInput_Cancel);
|
||||
if (!is_multiline && !(flags & ImGuiInputTextFlags_CallbackHistory))
|
||||
g.ActiveIdAllowNavDirFlags |= ((1 << ImGuiDir_Up) | (1 << ImGuiDir_Down));
|
||||
g.ActiveIdAllowNavDirFlags = ((1 << ImGuiDir_Up) | (1 << ImGuiDir_Down));
|
||||
}
|
||||
else if (io.MouseClicked[0])
|
||||
{
|
||||
@@ -3600,7 +3602,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
||||
}
|
||||
|
||||
// If the underlying buffer resize was denied or not carried to the next frame, apply_new_text_length+1 may be >= buf_size.
|
||||
ImStrncpy(buf, edit_state.TempBuffer.Data, ImMin(apply_new_text_length + 1, buf_size));
|
||||
ImStrncpy(buf, apply_new_text, ImMin(apply_new_text_length + 1, buf_size));
|
||||
value_changed = true;
|
||||
}
|
||||
|
||||
@@ -3806,6 +3808,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
||||
if (value_changed)
|
||||
MarkItemEdited(id);
|
||||
|
||||
IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.ItemFlags);
|
||||
if ((flags & ImGuiInputTextFlags_EnterReturnsTrue) != 0)
|
||||
return enter_pressed;
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user