mirror of https://github.com/bkaradzic/bgfx
Updated ImGui.
This commit is contained in:
parent
734ff0ad34
commit
6b0840cf7c
|
@ -1,4 +1,4 @@
|
|||
// dear imgui, v1.52 WIP
|
||||
// dear imgui, v1.52
|
||||
// (main code and documentation)
|
||||
|
||||
// See ImGui::ShowTestWindow() in imgui_demo.cpp for demo code.
|
||||
|
@ -634,7 +634,7 @@ static void SetWindowScrollY(ImGuiWindow* window, float new_scroll_y
|
|||
static void SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond);
|
||||
static void SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond cond);
|
||||
static void SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiCond cond);
|
||||
static ImGuiWindow* FindHoveredWindow(ImVec2 pos, bool excluding_childs);
|
||||
static ImGuiWindow* FindHoveredWindow(ImVec2 pos);
|
||||
static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFlags flags);
|
||||
static void ClearSetNextWindowData();
|
||||
static void CheckStacksSize(ImGuiWindow* window, bool write);
|
||||
|
@ -2333,29 +2333,29 @@ void ImGui::NewFrame()
|
|||
g.IO.Framerate = 1.0f / (g.FramerateSecPerFrameAccum / (float)IM_ARRAYSIZE(g.FramerateSecPerFrame));
|
||||
|
||||
// Handle user moving window with mouse (at the beginning of the frame to avoid input lag or sheering). Only valid for root windows.
|
||||
if (g.MovedWindowMoveId && g.MovedWindowMoveId == g.ActiveId)
|
||||
if (g.MovingWindowMoveId && g.MovingWindowMoveId == g.ActiveId)
|
||||
{
|
||||
KeepAliveID(g.MovedWindowMoveId);
|
||||
IM_ASSERT(g.MovedWindow && g.MovedWindow->RootWindow);
|
||||
IM_ASSERT(g.MovedWindow->MoveId == g.MovedWindowMoveId);
|
||||
KeepAliveID(g.MovingWindowMoveId);
|
||||
IM_ASSERT(g.MovingWindow && g.MovingWindow->RootWindow);
|
||||
IM_ASSERT(g.MovingWindow->MoveId == g.MovingWindowMoveId);
|
||||
if (g.IO.MouseDown[0])
|
||||
{
|
||||
g.MovedWindow->RootWindow->PosFloat += g.IO.MouseDelta;
|
||||
g.MovingWindow->RootWindow->PosFloat += g.IO.MouseDelta;
|
||||
if (g.IO.MouseDelta.x != 0.0f || g.IO.MouseDelta.y != 0.0f)
|
||||
MarkIniSettingsDirty(g.MovedWindow->RootWindow);
|
||||
FocusWindow(g.MovedWindow);
|
||||
MarkIniSettingsDirty(g.MovingWindow->RootWindow);
|
||||
FocusWindow(g.MovingWindow);
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearActiveID();
|
||||
g.MovedWindow = NULL;
|
||||
g.MovedWindowMoveId = 0;
|
||||
g.MovingWindow = NULL;
|
||||
g.MovingWindowMoveId = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
g.MovedWindow = NULL;
|
||||
g.MovedWindowMoveId = 0;
|
||||
g.MovingWindow = NULL;
|
||||
g.MovingWindowMoveId = 0;
|
||||
}
|
||||
|
||||
// Delay saving settings so we don't spam disk too much
|
||||
|
@ -2366,12 +2366,12 @@ void ImGui::NewFrame()
|
|||
SaveIniSettingsToDisk(g.IO.IniFilename);
|
||||
}
|
||||
|
||||
// Find the window we are hovering. Child windows can extend beyond the limit of their parent so we need to derive HoveredRootWindow from HoveredWindow
|
||||
g.HoveredWindow = g.MovedWindow ? g.MovedWindow : FindHoveredWindow(g.IO.MousePos, false);
|
||||
if (g.HoveredWindow && (g.HoveredWindow->Flags & ImGuiWindowFlags_ChildWindow))
|
||||
g.HoveredRootWindow = g.HoveredWindow->RootWindow;
|
||||
else
|
||||
g.HoveredRootWindow = g.MovedWindow ? g.MovedWindow->RootWindow : FindHoveredWindow(g.IO.MousePos, true);
|
||||
// Find the window we are hovering
|
||||
// - Child windows can extend beyond the limit of their parent so we need to derive HoveredRootWindow from HoveredWindow.
|
||||
// - When moving a window we can skip the search, which also conveniently bypasses the fact that window->WindowRectClipped is lagging as this point.
|
||||
// - We also support the moved window toggling the NoInputs flag after moving has started in order to be able to detect windows below it, which is useful for e.g. docking mechanisms.
|
||||
g.HoveredWindow = (g.MovingWindow && !(g.MovingWindow->Flags & ImGuiWindowFlags_NoInputs)) ? g.MovingWindow : FindHoveredWindow(g.IO.MousePos);
|
||||
g.HoveredRootWindow = g.HoveredWindow ? g.HoveredWindow->RootWindow : NULL;
|
||||
|
||||
if (ImGuiWindow* modal_window = GetFrontMostModalRootWindow())
|
||||
{
|
||||
|
@ -2509,7 +2509,7 @@ void ImGui::Shutdown()
|
|||
g.HoveredWindow = NULL;
|
||||
g.HoveredRootWindow = NULL;
|
||||
g.ActiveIdWindow = NULL;
|
||||
g.MovedWindow = NULL;
|
||||
g.MovingWindow = NULL;
|
||||
for (int i = 0; i < g.Settings.Size; i++)
|
||||
ImGui::MemFree(g.Settings[i].Name);
|
||||
g.Settings.clear();
|
||||
|
@ -2804,9 +2804,9 @@ void ImGui::EndFrame()
|
|||
FocusWindow(g.HoveredWindow);
|
||||
if (!(g.HoveredWindow->Flags & ImGuiWindowFlags_NoMove) && !(g.HoveredRootWindow->Flags & ImGuiWindowFlags_NoMove))
|
||||
{
|
||||
g.MovedWindow = g.HoveredWindow;
|
||||
g.MovedWindowMoveId = g.HoveredWindow->MoveId;
|
||||
SetActiveID(g.MovedWindowMoveId, g.HoveredRootWindow);
|
||||
g.MovingWindow = g.HoveredWindow;
|
||||
g.MovingWindowMoveId = g.MovingWindow->MoveId;
|
||||
SetActiveID(g.MovingWindowMoveId, g.HoveredRootWindow);
|
||||
}
|
||||
}
|
||||
else if (g.NavWindow != NULL && GetFrontMostModalRootWindow() == NULL)
|
||||
|
@ -3244,7 +3244,7 @@ void ImGui::CalcListClipping(int items_count, float items_height, int* out_items
|
|||
|
||||
// Find window given position, search front-to-back
|
||||
// FIXME: Note that we have a lag here because WindowRectClipped is updated in Begin() so windows moved by user via SetWindowPos() and not SetNextWindowPos() will have that rectangle lagging by a frame at the time FindHoveredWindow() is called, aka before the next Begin(). Moving window thankfully isn't affected.
|
||||
static ImGuiWindow* FindHoveredWindow(ImVec2 pos, bool excluding_childs)
|
||||
static ImGuiWindow* FindHoveredWindow(ImVec2 pos)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
for (int i = g.Windows.Size-1; i >= 0; i--)
|
||||
|
@ -3254,10 +3254,8 @@ static ImGuiWindow* FindHoveredWindow(ImVec2 pos, bool excluding_childs)
|
|||
continue;
|
||||
if (window->Flags & ImGuiWindowFlags_NoInputs)
|
||||
continue;
|
||||
if (excluding_childs && (window->Flags & ImGuiWindowFlags_ChildWindow) != 0)
|
||||
continue;
|
||||
|
||||
// Using the clipped AABB so a child window will typically be clipped by its parent.
|
||||
// Using the clipped AABB, a child window will typically be clipped by its parent (not always)
|
||||
ImRect bb(window->WindowRectClipped.Min - g.Style.TouchExtraPadding, window->WindowRectClipped.Max + g.Style.TouchExtraPadding);
|
||||
if (bb.Contains(pos))
|
||||
return window;
|
||||
|
@ -3541,7 +3539,7 @@ static ImRect GetVisibleRect()
|
|||
}
|
||||
|
||||
// Not exposed publicly as BeginTooltip() because bool parameters are evil. Let's see if other needs arise first.
|
||||
static void BeginTooltipEx(ImGuiWindowFlags extra_flags, bool override_previous_tooltip)
|
||||
void ImGui::BeginTooltipEx(ImGuiWindowFlags extra_flags, bool override_previous_tooltip)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
char window_name[16];
|
||||
|
@ -4616,24 +4614,31 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||
if (g.IO.KeyCtrl && IsKeyPressedMap(ImGuiKey_C))
|
||||
ImGui::LogToClipboard();
|
||||
*/
|
||||
|
||||
// Inner rectangle
|
||||
// We set this up after processing the resize grip so that our clip rectangle doesn't lag by a frame
|
||||
// Note that if our window is collapsed we will end up with a null clipping rectangle which is the correct behavior.
|
||||
window->InnerRect.Min.x = title_bar_rect.Min.x;
|
||||
window->InnerRect.Min.y = title_bar_rect.Max.y + window->MenuBarHeight();
|
||||
window->InnerRect.Max.x = window->Pos.x + window->Size.x - window->ScrollbarSizes.x;
|
||||
window->InnerRect.Max.y = window->Pos.y + window->Size.y - window->ScrollbarSizes.y;
|
||||
//window->DrawList->AddRect(window->InnerRect.Min, window->InnerRect.Max, IM_COL32_WHITE);
|
||||
}
|
||||
|
||||
// Inner clipping rectangle
|
||||
// We set this up after processing the resize grip so that our clip rectangle doesn't lag by a frame
|
||||
// Note that if our window is collapsed we will end up with a null clipping rectangle which is the correct behavior.
|
||||
const ImRect title_bar_rect = window->TitleBarRect();
|
||||
// Force round operator last to ensure that e.g. (int)(max.x-min.x) in user's render code produce correct result.
|
||||
const float border_size = window->BorderSize;
|
||||
// Force round to ensure that e.g. (int)(max.x-min.x) in user's render code produce correct result.
|
||||
ImRect clip_rect;
|
||||
clip_rect.Min.x = ImFloor(0.5f + title_bar_rect.Min.x + ImMax(border_size, ImFloor(window->WindowPadding.x*0.5f)));
|
||||
clip_rect.Min.y = ImFloor(0.5f + title_bar_rect.Max.y + window->MenuBarHeight() + border_size);
|
||||
clip_rect.Max.x = ImFloor(0.5f + window->Pos.x + window->Size.x - window->ScrollbarSizes.x - ImMax(border_size, ImFloor(window->WindowPadding.x*0.5f)));
|
||||
clip_rect.Max.y = ImFloor(0.5f + window->Pos.y + window->Size.y - window->ScrollbarSizes.y - border_size);
|
||||
clip_rect.Min.x = ImFloor(0.5f + window->InnerRect.Min.x + ImMax(border_size, ImFloor(window->WindowPadding.x*0.5f)));
|
||||
clip_rect.Min.y = ImFloor(0.5f + window->InnerRect.Min.y + border_size);
|
||||
clip_rect.Max.x = ImFloor(0.5f + window->InnerRect.Max.x - ImMax(border_size, ImFloor(window->WindowPadding.x*0.5f)));
|
||||
clip_rect.Max.y = ImFloor(0.5f + window->InnerRect.Max.y - border_size);
|
||||
PushClipRect(clip_rect.Min, clip_rect.Max, true);
|
||||
|
||||
// Clear 'accessed' flag last thing
|
||||
// Clear 'accessed' flag last thing (After PushClipRect which will set the flag. We want the flag to stay false when the default "Debug" window is unused)
|
||||
if (first_begin_of_the_frame)
|
||||
window->Accessed = false;
|
||||
|
||||
window->BeginCount++;
|
||||
g.SetNextWindowSizeConstraint = false;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// dear imgui, v1.52 WIP
|
||||
// dear imgui, v1.52
|
||||
// (headers)
|
||||
|
||||
// See imgui.cpp file for documentation.
|
||||
|
@ -16,7 +16,7 @@
|
|||
#include <stddef.h> // ptrdiff_t, NULL
|
||||
#include <string.h> // memset, memmove, memcpy, strlen, strchr, strcpy, strcmp
|
||||
|
||||
#define IMGUI_VERSION "1.52 WIP"
|
||||
#define IMGUI_VERSION "1.52"
|
||||
|
||||
// Define attributes of all API symbols declarations, e.g. for DLL under Windows.
|
||||
#ifndef IMGUI_API
|
||||
|
@ -29,14 +29,16 @@
|
|||
#define IM_ASSERT(_EXPR, ...) assert(_EXPR)
|
||||
#endif
|
||||
|
||||
// Helpers
|
||||
// Some compilers support applying printf-style warnings to user functions.
|
||||
#if 0 // defined(__clang__) || defined(__GNUC__)
|
||||
#define IM_FMTARGS(FMT) __attribute__((format(printf, FMT, FMT+1)))
|
||||
#define IM_FMTLIST(FMT) __attribute__((format(printf, FMT, 0)))
|
||||
#define IM_FMTARGS(FMT) __attribute__((format(printf, FMT, FMT+1)))
|
||||
#define IM_FMTLIST(FMT) __attribute__((format(printf, FMT, 0)))
|
||||
#else
|
||||
#define IM_FMTARGS(FMT)
|
||||
#define IM_FMTLIST(FMT)
|
||||
#endif
|
||||
#define IM_ARRAYSIZE(_ARR) ((int)(sizeof(_ARR)/sizeof(*_ARR)))
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
|
@ -500,7 +502,7 @@ enum ImGuiWindowFlags_
|
|||
ImGuiWindowFlags_AlwaysAutoResize = 1 << 6, // Resize every window to its content every frame
|
||||
ImGuiWindowFlags_ShowBorders = 1 << 7, // Show borders around windows and items
|
||||
ImGuiWindowFlags_NoSavedSettings = 1 << 8, // Never load/save settings in .ini file
|
||||
ImGuiWindowFlags_NoInputs = 1 << 9, // Disable catching mouse or keyboard inputs
|
||||
ImGuiWindowFlags_NoInputs = 1 << 9, // Disable catching mouse or keyboard inputs, hovering test with pass through.
|
||||
ImGuiWindowFlags_MenuBar = 1 << 10, // Has a menu-bar
|
||||
ImGuiWindowFlags_HorizontalScrollbar = 1 << 11, // Allow horizontal scrollbar to appear (off by default). You may use SetNextWindowContentSize(ImVec2(width,0.0f)); prior to calling Begin() to specify width. Read code in imgui_demo in the "Horizontal Scrolling" section.
|
||||
ImGuiWindowFlags_NoFocusOnAppearing = 1 << 12, // Disable taking focus when transitioning from hidden to visible state
|
||||
|
@ -569,6 +571,7 @@ enum ImGuiSelectableFlags_
|
|||
ImGuiSelectableFlags_AllowDoubleClick = 1 << 2 // Generate press events on double clicks too
|
||||
};
|
||||
|
||||
// Flags for ImGui::IsItemHovered(), ImGui::IsWindowHovered()
|
||||
enum ImGuiHoveredFlags_
|
||||
{
|
||||
ImGuiHoveredFlags_Default = 0, // Return true if directly over the item/window, not obstructed by another window, not obstructed by an active popup or modal blocking inputs under them.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// dear imgui, v1.52 WIP
|
||||
// dear imgui, v1.52
|
||||
// (demo code)
|
||||
|
||||
// Message to the person tempted to delete this file when integrating ImGui into their code base:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// dear imgui, v1.52 WIP
|
||||
// dear imgui, v1.52
|
||||
// (drawing and font code)
|
||||
|
||||
// Contains implementation for
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// dear imgui, v1.52 WIP
|
||||
// dear imgui, v1.52
|
||||
// (internals)
|
||||
|
||||
// You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility!
|
||||
|
@ -44,12 +44,11 @@ struct ImGuiMouseCursorData;
|
|||
struct ImGuiPopupRef;
|
||||
struct ImGuiWindow;
|
||||
|
||||
typedef int ImGuiLayoutType; // enum ImGuiLayoutType_
|
||||
typedef int ImGuiButtonFlags; // enum ImGuiButtonFlags_
|
||||
typedef int ImGuiTreeNodeFlags; // enum ImGuiTreeNodeFlags_
|
||||
typedef int ImGuiSliderFlags; // enum ImGuiSliderFlags_
|
||||
typedef int ImGuiSeparatorFlags; // enum ImGuiSeparatorFlags_
|
||||
typedef int ImGuiItemFlags; // enum ImGuiItemFlags_
|
||||
typedef int ImGuiLayoutType; // enum: horizontal or vertical // enum ImGuiLayoutType_
|
||||
typedef int ImGuiButtonFlags; // flags: for ButtonEx(), ButtonBehavior() // enum ImGuiButtonFlags_
|
||||
typedef int ImGuiItemFlags; // flags: for PushItemFlag() // enum ImGuiItemFlags_
|
||||
typedef int ImGuiSeparatorFlags; // flags: for Separator() - internal // enum ImGuiSeparatorFlags_
|
||||
typedef int ImGuiSliderFlags; // flags: for SliderBehavior() // enum ImGuiSliderFlags_
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// STB libraries
|
||||
|
@ -79,9 +78,8 @@ extern IMGUI_API ImGuiContext* GImGui; // Current implicit ImGui context pointe
|
|||
// Helpers
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#define IM_ARRAYSIZE(_ARR) ((int)(sizeof(_ARR)/sizeof(*_ARR)))
|
||||
#define IM_PI 3.14159265358979323846f
|
||||
#define IM_OFFSETOF(_TYPE,_ELM) ((size_t)&(((_TYPE*)0)->_ELM))
|
||||
#define IM_PI 3.14159265358979323846f
|
||||
#define IM_OFFSETOF(_TYPE,_ELM) ((size_t)&(((_TYPE*)0)->_ELM))
|
||||
|
||||
// Helpers: UTF-8 <> wchar
|
||||
IMGUI_API int ImTextStrToUtf8(char* buf, int buf_size, const ImWchar* in_text, const ImWchar* in_text_end); // return output UTF-8 bytes count
|
||||
|
@ -128,7 +126,9 @@ static inline ImVec2& operator+=(ImVec2& lhs, const ImVec2& rhs)
|
|||
static inline ImVec2& operator-=(ImVec2& lhs, const ImVec2& rhs) { lhs.x -= rhs.x; lhs.y -= rhs.y; return lhs; }
|
||||
static inline ImVec2& operator*=(ImVec2& lhs, const float rhs) { lhs.x *= rhs; lhs.y *= rhs; return lhs; }
|
||||
static inline ImVec2& operator/=(ImVec2& lhs, const float rhs) { lhs.x /= rhs; lhs.y /= rhs; return lhs; }
|
||||
static inline ImVec4 operator+(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x+rhs.x, lhs.y+rhs.y, lhs.z+rhs.z, lhs.w+rhs.w); }
|
||||
static inline ImVec4 operator-(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x-rhs.x, lhs.y-rhs.y, lhs.z-rhs.z, lhs.w-rhs.w); }
|
||||
static inline ImVec4 operator*(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x*rhs.x, lhs.y*rhs.y, lhs.z*rhs.z, lhs.w*rhs.w); }
|
||||
#endif
|
||||
|
||||
static inline int ImMin(int lhs, int rhs) { return lhs < rhs ? lhs : rhs; }
|
||||
|
@ -436,8 +436,8 @@ struct ImGuiContext
|
|||
bool ActiveIdAllowOverlap; // Active widget allows another widget to steal active id (generally for overlapping widgets, but not always)
|
||||
ImVec2 ActiveIdClickOffset; // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior)
|
||||
ImGuiWindow* ActiveIdWindow;
|
||||
ImGuiWindow* MovedWindow; // Track the child window we clicked on to move a window.
|
||||
ImGuiID MovedWindowMoveId; // == MovedWindow->RootWindow->MoveId
|
||||
ImGuiWindow* MovingWindow; // Track the child window we clicked on to move a window.
|
||||
ImGuiID MovingWindowMoveId; // == MovingWindow->MoveId
|
||||
ImVector<ImGuiIniData> Settings; // .ini Settings
|
||||
float SettingsDirtyTimer; // Save .ini Settings on disk when time reaches zero
|
||||
ImVector<ImGuiColMod> ColorModifiers; // Stack for PushStyleColor()/PopStyleColor()
|
||||
|
@ -528,8 +528,8 @@ struct ImGuiContext
|
|||
ActiveIdAllowOverlap = false;
|
||||
ActiveIdClickOffset = ImVec2(-1,-1);
|
||||
ActiveIdWindow = NULL;
|
||||
MovedWindow = NULL;
|
||||
MovedWindowMoveId = 0;
|
||||
MovingWindow = NULL;
|
||||
MovingWindowMoveId = 0;
|
||||
SettingsDirtyTimer = 0.0f;
|
||||
|
||||
SetNextWindowPosVal = ImVec2(0.0f, 0.0f);
|
||||
|
@ -715,6 +715,7 @@ struct IMGUI_API ImGuiWindow
|
|||
ImVector<ImGuiID> IDStack; // ID stack. ID are hashes seeded with the value at the top of the stack
|
||||
ImRect ClipRect; // = DrawList->clip_rect_stack.back(). Scissoring / clipping rectangle. x1, y1, x2, y2.
|
||||
ImRect WindowRectClipped; // = WindowRect just after setup in Begin(). == window->Rect() for root window.
|
||||
ImRect InnerRect;
|
||||
int LastFrameActive;
|
||||
float ItemWidthDefault;
|
||||
ImGuiSimpleColumns MenuColumns; // Simplified columns storage for menu items
|
||||
|
@ -802,6 +803,7 @@ namespace ImGui
|
|||
IMGUI_API void ClosePopup(ImGuiID id);
|
||||
IMGUI_API bool IsPopupOpen(ImGuiID id);
|
||||
IMGUI_API bool BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags);
|
||||
IMGUI_API void BeginTooltipEx(ImGuiWindowFlags extra_flags, bool override_previous_tooltip = true);
|
||||
|
||||
IMGUI_API int CalcTypematicPressedRepeatAmount(float t, float t_prev, float repeat_delay, float repeat_rate);
|
||||
|
||||
|
|
Loading…
Reference in New Issue