Updated ImGui.
This commit is contained in:
parent
b4338ce0d2
commit
a0d744c23b
45
3rdparty/ocornut-imgui/imgui.cpp
vendored
45
3rdparty/ocornut-imgui/imgui.cpp
vendored
@ -2285,6 +2285,8 @@ void ImGui::NewFrame()
|
||||
IM_ASSERT(g.Style.CurveTessellationTol > 0.0f && "Invalid style setting");
|
||||
IM_ASSERT(g.Style.Alpha >= 0.0f && g.Style.Alpha <= 1.0f && "Invalid style setting. Alpha cannot be negative (allows us to avoid a few clamps in color computations)");
|
||||
IM_ASSERT((g.FrameCount == 0 || g.FrameCountEnded == g.FrameCount) && "Forgot to call Render() or EndFrame() at the end of the previous frame?");
|
||||
for (int n = 0; n < ImGuiKey_COUNT; n++)
|
||||
IM_ASSERT(g.IO.KeyMap[n] >= -1 && g.IO.KeyMap[n] < IM_ARRAYSIZE(g.IO.KeysDown) && "io.KeyMap[] contains an out of bound value (need to be 0..512, or -1 for unmapped key)");
|
||||
|
||||
// Initialize on first frame
|
||||
if (!g.Initialized)
|
||||
@ -2394,11 +2396,8 @@ void ImGui::NewFrame()
|
||||
if (g.IO.MouseDown[0])
|
||||
{
|
||||
// MovingWindow = window we clicked on, could be a child window. We track it to preserve Focus and so that ActiveIdWindow == MovingWindow and ActiveId == MovingWindow->MoveId for consistency.
|
||||
// actually_moving_window = MovingWindow->RootWindow.
|
||||
ImGuiWindow* actually_moving_window = g.MovingWindow->RootWindow;
|
||||
ImVec2 pos = g.IO.MousePos - g.ActiveIdClickOffset;
|
||||
if (actually_moving_window != g.MovingWindow)
|
||||
pos += actually_moving_window->PosFloat - g.MovingWindow->PosFloat;
|
||||
if (actually_moving_window->PosFloat.x != pos.x || actually_moving_window->PosFloat.y != pos.y)
|
||||
{
|
||||
MarkIniSettingsDirty(actually_moving_window);
|
||||
@ -2980,7 +2979,7 @@ void ImGui::EndFrame()
|
||||
// Set ActiveId even if the _NoMove flag is set, without it dragging away from a window with _NoMove would activate hover on other windows.
|
||||
FocusWindow(g.HoveredWindow);
|
||||
SetActiveID(g.HoveredWindow->MoveId, g.HoveredWindow);
|
||||
g.ActiveIdClickOffset = g.IO.MousePos - g.HoveredWindow->Pos;
|
||||
g.ActiveIdClickOffset = g.IO.MousePos - g.HoveredRootWindow->Pos;
|
||||
if (!(g.HoveredWindow->Flags & ImGuiWindowFlags_NoMove) && !(g.HoveredRootWindow->Flags & ImGuiWindowFlags_NoMove))
|
||||
{
|
||||
g.MovingWindow = g.HoveredWindow;
|
||||
@ -3581,6 +3580,7 @@ bool ImGui::IsMousePosValid(const ImVec2* mouse_pos)
|
||||
return mouse_pos->x >= MOUSE_INVALID && mouse_pos->y >= MOUSE_INVALID;
|
||||
}
|
||||
|
||||
// NB: This is only valid if IsMousePosValid(). Backends in theory should always keep mouse position valid when dragging even outside the client window.
|
||||
ImVec2 ImGui::GetMouseDragDelta(int button, float lock_threshold)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
@ -4563,10 +4563,12 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
// When reusing window again multiple times a frame, just append content (don't need to setup again)
|
||||
if (first_begin_of_the_frame)
|
||||
{
|
||||
const bool is_pinned_child_tooltip = (flags & ImGuiWindowFlags_ChildWindow) && (flags & ImGuiWindowFlags_Tooltip); // FIXME-WIP: Undocumented behavior of Child+Tooltip for pinned tooltip (#1345)
|
||||
|
||||
// Initialize
|
||||
window->ParentWindow = parent_window;
|
||||
window->RootWindow = window->RootNonPopupWindow = window;
|
||||
if (parent_window && (flags & ImGuiWindowFlags_ChildWindow))
|
||||
if (parent_window && (flags & ImGuiWindowFlags_ChildWindow) && !is_pinned_child_tooltip)
|
||||
window->RootWindow = parent_window->RootWindow;
|
||||
if (parent_window && !(flags & ImGuiWindowFlags_Modal) && (flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Popup)))
|
||||
window->RootNonPopupWindow = parent_window->RootNonPopupWindow;
|
||||
@ -4652,12 +4654,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
|
||||
// Apply minimum/maximum window size constraints and final size
|
||||
window->SizeFull = CalcSizeAfterConstraint(window, window->SizeFull);
|
||||
window->Size = window->Collapsed ? window->TitleBarRect().GetSize() : window->SizeFull;
|
||||
if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Popup))
|
||||
{
|
||||
IM_ASSERT(window_size_x_set_by_api && window_size_y_set_by_api); // Submitted by BeginChild()
|
||||
window->Size = window->SizeFull;
|
||||
}
|
||||
window->Size = window->Collapsed && !(flags & ImGuiWindowFlags_ChildWindow) ? window->TitleBarRect().GetSize() : window->SizeFull;
|
||||
|
||||
// SCROLLBAR STATUS
|
||||
|
||||
@ -4689,8 +4686,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
{
|
||||
window->BeginOrderWithinParent = parent_window->DC.ChildWindows.Size;
|
||||
parent_window->DC.ChildWindows.push_back(window);
|
||||
|
||||
if (!(flags & ImGuiWindowFlags_Popup) && !window_pos_set_by_api)
|
||||
if (!(flags & ImGuiWindowFlags_Popup) && !window_pos_set_by_api && !is_pinned_child_tooltip)
|
||||
window->Pos = window->PosFloat = parent_window->DC.CursorPos;
|
||||
}
|
||||
|
||||
@ -4721,7 +4717,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
}
|
||||
|
||||
// Position tooltip (always follows mouse)
|
||||
if ((flags & ImGuiWindowFlags_Tooltip) != 0 && !window_pos_set_by_api)
|
||||
if ((flags & ImGuiWindowFlags_Tooltip) != 0 && !window_pos_set_by_api && !is_pinned_child_tooltip)
|
||||
{
|
||||
ImVec2 ref_pos = g.IO.MousePos;
|
||||
ImRect rect_to_avoid(ref_pos.x - 16, ref_pos.y - 8, ref_pos.x + 24, ref_pos.y + 24); // FIXME: Completely hard-coded. Store boxes in mouse cursor data? Scale? Center on cursor hit-point?
|
||||
@ -4779,7 +4775,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
window->DrawList->Flags = (g.Style.AntiAliasedLines ? ImDrawListFlags_AntiAliasedLines : 0) | (g.Style.AntiAliasedFill ? ImDrawListFlags_AntiAliasedFill : 0);
|
||||
window->DrawList->PushTextureID(g.Font->ContainerAtlas->TexID);
|
||||
ImRect fullscreen_rect(GetVisibleRect());
|
||||
if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Popup))
|
||||
if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Popup) && !is_pinned_child_tooltip)
|
||||
PushClipRect(parent_window->ClipRect.Min, parent_window->ClipRect.Max, true);
|
||||
else
|
||||
PushClipRect(fullscreen_rect.Min, fullscreen_rect.Max, true);
|
||||
@ -7624,16 +7620,19 @@ bool ImGui::DragBehavior(const ImRect& frame_bb, ImGuiID id, float* v, float v_s
|
||||
float v_cur = g.DragCurrentValue;
|
||||
const ImVec2 mouse_drag_delta = GetMouseDragDelta(0, 1.0f);
|
||||
float adjust_delta = 0.0f;
|
||||
//if (g.ActiveIdSource == ImGuiInputSource_Mouse)
|
||||
if (IsMousePosValid())
|
||||
{
|
||||
adjust_delta = mouse_drag_delta.x - g.DragLastMouseDelta.x;
|
||||
if (g.IO.KeyShift && g.DragSpeedScaleFast >= 0.0f)
|
||||
adjust_delta *= g.DragSpeedScaleFast;
|
||||
if (g.IO.KeyAlt && g.DragSpeedScaleSlow >= 0.0f)
|
||||
adjust_delta *= g.DragSpeedScaleSlow;
|
||||
//if (g.ActiveIdSource == ImGuiInputSource_Mouse)
|
||||
{
|
||||
adjust_delta = mouse_drag_delta.x - g.DragLastMouseDelta.x;
|
||||
if (g.IO.KeyShift && g.DragSpeedScaleFast >= 0.0f)
|
||||
adjust_delta *= g.DragSpeedScaleFast;
|
||||
if (g.IO.KeyAlt && g.DragSpeedScaleSlow >= 0.0f)
|
||||
adjust_delta *= g.DragSpeedScaleSlow;
|
||||
}
|
||||
g.DragLastMouseDelta.x = mouse_drag_delta.x;
|
||||
}
|
||||
adjust_delta *= v_speed;
|
||||
g.DragLastMouseDelta.x = mouse_drag_delta.x;
|
||||
|
||||
if (fabsf(adjust_delta) > 0.0f)
|
||||
{
|
||||
@ -11399,7 +11398,7 @@ bool ImGui::SetDragDropPayload(const char* type, const void* data, size_t data_s
|
||||
cond = ImGuiCond_Always;
|
||||
|
||||
IM_ASSERT(type != NULL);
|
||||
IM_ASSERT(strlen(type) < IM_ARRAYSIZE(payload.DataType)); // Payload type can be at most 8 characters longs
|
||||
IM_ASSERT(strlen(type) < IM_ARRAYSIZE(payload.DataType) && "Payload type can be at most 12 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()
|
||||
|
12
3rdparty/ocornut-imgui/imgui.h
vendored
12
3rdparty/ocornut-imgui/imgui.h
vendored
@ -429,7 +429,7 @@ namespace ImGui
|
||||
// Drag and Drop
|
||||
// [BETA API] Missing Demo code. API may evolve.
|
||||
IMGUI_API bool BeginDragDropSource(ImGuiDragDropFlags flags = 0, int mouse_button = 0); // call when the current item is active. If this return true, you can call SetDragDropPayload() + EndDragDropSource()
|
||||
IMGUI_API bool SetDragDropPayload(const char* type, const void* data, size_t size, ImGuiCond cond = 0);// type is a user defined string of maximum 8 characters. Strings starting with '_' are reserved for dear imgui internal types. Data is copied and held by imgui.
|
||||
IMGUI_API bool SetDragDropPayload(const char* type, const void* data, size_t size, ImGuiCond cond = 0);// type is a user defined string of maximum 12 characters. Strings starting with '_' are reserved for dear imgui internal types. Data is copied and held by imgui.
|
||||
IMGUI_API void EndDragDropSource(); // only call EndDragDropSource() if BeginDragDropSource() returns true!
|
||||
IMGUI_API bool BeginDragDropTarget(); // call after submitting an item that may receive an item. 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.
|
||||
@ -655,7 +655,7 @@ enum ImGuiDragDropFlags_
|
||||
ImGuiDragDropFlags_AcceptPeekOnly = ImGuiDragDropFlags_AcceptBeforeDelivery | ImGuiDragDropFlags_AcceptNoDrawDefaultRect // For peeking ahead and inspecting the payload before delivery.
|
||||
};
|
||||
|
||||
// Standard Drag and Drop payload types. You can define you own payload types using 8-characters long strings. Types starting with '_' are defined by Dear ImGui.
|
||||
// Standard Drag and Drop payload types. You can define you own payload types using 12-characters long strings. Types starting with '_' are defined by Dear ImGui.
|
||||
#define IMGUI_PAYLOAD_TYPE_COLOR_3F "_COL3F" // float[3] // Standard type for colors, without alpha. User code may use this type.
|
||||
#define IMGUI_PAYLOAD_TYPE_COLOR_4F "_COL4F" // float[4] // Standard type for colors. User code may use this type.
|
||||
|
||||
@ -883,8 +883,8 @@ struct ImGuiIO
|
||||
const char* LogFilename; // = "imgui_log.txt" // Path to .log file (default parameter to ImGui::LogToFile when no file is specified).
|
||||
float MouseDoubleClickTime; // = 0.30f // Time for a double-click, in seconds.
|
||||
float MouseDoubleClickMaxDist; // = 6.0f // Distance threshold to stay in to validate a double-click, in pixels.
|
||||
float MouseDragThreshold; // = 6.0f // Distance threshold before considering we are dragging
|
||||
int KeyMap[ImGuiKey_COUNT]; // <unset> // Map of indices into the KeysDown[512] entries array
|
||||
float MouseDragThreshold; // = 6.0f // Distance threshold before considering we are dragging.
|
||||
int KeyMap[ImGuiKey_COUNT]; // <unset> // Map of indices into the KeysDown[512] entries array which represent your "native" keyboard state.
|
||||
float KeyRepeatDelay; // = 0.250f // When holding a key/button, time before it starts repeating, in seconds (for buttons in Repeat mode, etc.).
|
||||
float KeyRepeatRate; // = 0.050f // When holding a key/button, rate at which it repeats, in seconds.
|
||||
void* UserData; // = NULL // Store your own data for retrieval by callbacks.
|
||||
@ -938,7 +938,7 @@ struct ImGuiIO
|
||||
bool KeyShift; // Keyboard modifier pressed: Shift
|
||||
bool KeyAlt; // Keyboard modifier pressed: Alt
|
||||
bool KeySuper; // Keyboard modifier pressed: Cmd/Super/Windows
|
||||
bool KeysDown[512]; // Keyboard keys that are pressed (in whatever storage order you naturally have access to keyboard data)
|
||||
bool KeysDown[512]; // Keyboard keys that are pressed (ideally left in the "native" order your engine has access to keyboard keys, so you can use your own defines/enums for keys).
|
||||
ImWchar InputCharacters[16+1]; // List of characters input (translated by user from keypress+keyboard state). Fill using AddInputCharacter() helper.
|
||||
|
||||
// Functions
|
||||
@ -1241,7 +1241,7 @@ struct ImGuiPayload
|
||||
ImGuiID SourceId; // Source item id
|
||||
ImGuiID SourceParentId; // Source parent id (if available)
|
||||
int DataFrameCount; // Data timestamp
|
||||
char DataType[8 + 1]; // Data type tag (short user-supplied string)
|
||||
char DataType[12 + 1]; // Data type tag (short user-supplied string, 12 characters max)
|
||||
bool Preview; // Set when AcceptDragDropPayload() was called and mouse has been hovering the target item (nb: handle overlapping drag targets)
|
||||
bool Delivery; // Set when AcceptDragDropPayload() was called and mouse button is released over the target item.
|
||||
|
||||
|
3
3rdparty/ocornut-imgui/imgui_internal.h
vendored
3
3rdparty/ocornut-imgui/imgui_internal.h
vendored
@ -170,9 +170,6 @@ template <typename T> void IM_DELETE(T*& p) { if (p) { p->~T(); ImGui::MemFree(p
|
||||
// Types
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Internal Drag and Drop payload types. String starting with '_' are reserved for Dear ImGui.
|
||||
#define IMGUI_PAYLOAD_TYPE_DOCKABLE "_IMDOCK" // ImGuiWindow* // [Internal] Docking/tabs
|
||||
|
||||
enum ImGuiButtonFlags_
|
||||
{
|
||||
ImGuiButtonFlags_Repeat = 1 << 0, // hold to repeat
|
||||
|
Loading…
Reference in New Issue
Block a user