mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-13 16:29:54 +02:00
Merge branch 'master' into viewport
# Conflicts: # examples/imgui_impl_dx11.cpp # examples/imgui_impl_glfw.cpp # examples/imgui_impl_sdl.cpp # imgui.cpp
This commit is contained in:
58
imgui.cpp
58
imgui.cpp
@ -317,9 +317,10 @@
|
||||
- 2018/XX/XX (1.XX) - Moved IME support functions from io.ImeSetInputScreenPosFn, io.ImeWindowHandle to the PlatformIO api.
|
||||
- 2018/XX/XX (1.XX) - removed io.DisplayVisibleMin, io.DisplayVisibleMax settings (it was used to clip within the DisplayMin..DisplayMax range, I don't know of anyone using it)
|
||||
|
||||
- 2018/08/01 (1.63) - removed per-window ImGuiWindowFlags_ResizeFromAnySide beta flag in favor of a global io.ConfigResizeWindowsFromEdges to enable the feature.
|
||||
- 2018/08/01 (1.63) - renamed io.OptCursorBlink to io.ConfigCursorBlink, io.OptMacOSXBehaviors to ConfigMacOSXBehaviors for consistency.
|
||||
- 2018/07/22 (1.63) - changed ImGui::GetTime() return value from float to double to avoid accumulating floating point imprecisions over time.
|
||||
- 2018/07/08 (1.63) - style: renamed ImGuiCol_ModalWindowDarkening to ImGuiCol_ModalWindowDimBg for consistency with other features. Kept redirection enum (will obsolete).
|
||||
- 2018/07/06 (1.63) - removed per-window ImGuiWindowFlags_ResizeFromAnySide beta flag in favor of a global io.OptResizeWindowsFromEdges to enable the feature.
|
||||
- 2018/06/06 (1.62) - renamed GetGlyphRangesChinese() to GetGlyphRangesChineseFull() to distinguish other variants and discourage using the full set.
|
||||
- 2018/06/06 (1.62) - TreeNodeEx()/TreeNodeBehavior(): the ImGuiTreeNodeFlags_CollapsingHeader helper now include the ImGuiTreeNodeFlags_NoTreePushOnOpen flag. See Changelog for details.
|
||||
- 2018/05/03 (1.61) - DragInt(): the default compile-time format string has been changed from "%.0f" to "%d", as we are not using integers internally any more.
|
||||
@ -1061,13 +1062,14 @@ ImGuiIO::ImGuiIO()
|
||||
FontAllowUserScaling = false;
|
||||
DisplayFramebufferScale = ImVec2(1.0f, 1.0f);
|
||||
|
||||
// Advanced/subtle behaviors
|
||||
// Miscellaneous configuration options
|
||||
#ifdef __APPLE__
|
||||
OptMacOSXBehaviors = true; // Set Mac OS X style defaults based on __APPLE__ compile time flag
|
||||
ConfigMacOSXBehaviors = true; // Set Mac OS X style defaults based on __APPLE__ compile time flag
|
||||
#else
|
||||
OptMacOSXBehaviors = false;
|
||||
ConfigMacOSXBehaviors = false;
|
||||
#endif
|
||||
OptCursorBlink = true;
|
||||
ConfigCursorBlink = true;
|
||||
ConfigResizeWindowsFromEdges = false;
|
||||
|
||||
// Settings (User Functions)
|
||||
GetClipboardTextFn = GetClipboardTextFn_DefaultImpl; // Platform dependent default implementations
|
||||
@ -2214,6 +2216,12 @@ ImGuiID ImGuiWindow::GetIDNoKeepAlive(const char* str, const char* str_end)
|
||||
return ImHash(str, str_end ? (int)(str_end - str) : 0, seed);
|
||||
}
|
||||
|
||||
ImGuiID ImGuiWindow::GetIDNoKeepAlive(const void* ptr)
|
||||
{
|
||||
ImGuiID seed = IDStack.back();
|
||||
return ImHash(&ptr, sizeof(void*), seed);
|
||||
}
|
||||
|
||||
// This is only used in rare/specific situations to manufacture an ID out of nowhere.
|
||||
ImGuiID ImGuiWindow::GetIDFromRectangle(const ImRect& r_abs)
|
||||
{
|
||||
@ -4307,9 +4315,9 @@ void ImGui::NewFrame()
|
||||
if (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard)
|
||||
IM_ASSERT(g.IO.KeyMap[ImGuiKey_Space] != -1 && "ImGuiKey_Space is not mapped, required for keyboard navigation.");
|
||||
|
||||
// Perform simple check: the beta io.OptResizeWindowsFromEdges option requires back-end to honor mouse cursor changes and set the ImGuiBackendFlags_HasMouseCursors flag accordingly.
|
||||
if (g.IO.OptResizeWindowsFromEdges && !(g.IO.BackendFlags & ImGuiBackendFlags_HasMouseCursors))
|
||||
g.IO.OptResizeWindowsFromEdges = false;
|
||||
// Perform simple check: the beta io.ConfigResizeWindowsFromEdges option requires back-end to honor mouse cursor changes and set the ImGuiBackendFlags_HasMouseCursors flag accordingly.
|
||||
if (g.IO.ConfigResizeWindowsFromEdges && !(g.IO.BackendFlags & ImGuiBackendFlags_HasMouseCursors))
|
||||
g.IO.ConfigResizeWindowsFromEdges = false;
|
||||
|
||||
// Perform simple checks: multi-viewport and platform windows support
|
||||
if (g.IO.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||
@ -4996,12 +5004,13 @@ void ImGui::EndFrame()
|
||||
|
||||
SetCurrentViewport(NULL, NULL);
|
||||
|
||||
// Drag and Drop: Elapse payload at the end of the frame if mouse has been released
|
||||
if (g.DragDropActive && g.DragDropPayload.DataFrameCount + 1 < g.FrameCount && !IsMouseDown(g.DragDropMouseButton))
|
||||
// Drag and Drop: Elapse payload (if delivered, or if source stops being submitted)
|
||||
if (g.DragDropActive)
|
||||
{
|
||||
ClearDragDrop();
|
||||
g.DragDropPayloadBufHeap.clear();
|
||||
memset(&g.DragDropPayloadBufLocal, 0, sizeof(g.DragDropPayloadBufLocal));
|
||||
bool is_delivered = g.DragDropPayload.Delivery;
|
||||
bool is_elapsed = (g.DragDropPayload.DataFrameCount + 1 < g.FrameCount) && ((g.DragDropSourceFlags & ImGuiDragDropFlags_SourceAutoExpirePayload) || !IsMouseDown(g.DragDropMouseButton));
|
||||
if (is_delivered || is_elapsed)
|
||||
ClearDragDrop();
|
||||
}
|
||||
|
||||
// Drag and Drop: Fallback for source tooltip. This is not ideal but better than nothing.
|
||||
@ -6984,7 +6993,7 @@ static void ImGui::UpdateManualResize(ImGuiWindow* window, const ImVec2& size_au
|
||||
if ((flags & ImGuiWindowFlags_NoResize) || (flags & ImGuiWindowFlags_AlwaysAutoResize) || window->AutoFitFramesX > 0 || window->AutoFitFramesY > 0)
|
||||
return;
|
||||
|
||||
const int resize_border_count = g.IO.OptResizeWindowsFromEdges ? 4 : 0;
|
||||
const int resize_border_count = g.IO.ConfigResizeWindowsFromEdges ? 4 : 0;
|
||||
const float grip_draw_size = (float)(int)ImMax(g.FontSize * 1.35f, window->WindowRounding + 1.0f + g.FontSize * 0.2f);
|
||||
const float grip_hover_size = (float)(int)(grip_draw_size * 0.75f);
|
||||
|
||||
@ -7470,7 +7479,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
// Handle manual resize: Resize Grips, Borders, Gamepad
|
||||
int border_held = -1;
|
||||
ImU32 resize_grip_col[4] = { 0 };
|
||||
const int resize_grip_count = g.IO.OptResizeWindowsFromEdges ? 2 : 1; // 4
|
||||
const int resize_grip_count = g.IO.ConfigResizeWindowsFromEdges ? 2 : 1; // 4
|
||||
const float grip_draw_size = (float)(int)ImMax(g.FontSize * 1.35f, window->WindowRounding + 1.0f + g.FontSize * 0.2f);
|
||||
if (!window->Collapsed)
|
||||
UpdateManualResize(window, size_auto_fit, &border_held, resize_grip_count, &resize_grip_col[0]);
|
||||
@ -9940,26 +9949,26 @@ void ImGui::SetNextTreeNodeOpen(bool is_open, ImGuiCond cond)
|
||||
void ImGui::PushID(const char* str_id)
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindowRead();
|
||||
window->IDStack.push_back(window->GetID(str_id));
|
||||
window->IDStack.push_back(window->GetIDNoKeepAlive(str_id));
|
||||
}
|
||||
|
||||
void ImGui::PushID(const char* str_id_begin, const char* str_id_end)
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindowRead();
|
||||
window->IDStack.push_back(window->GetID(str_id_begin, str_id_end));
|
||||
window->IDStack.push_back(window->GetIDNoKeepAlive(str_id_begin, str_id_end));
|
||||
}
|
||||
|
||||
void ImGui::PushID(const void* ptr_id)
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindowRead();
|
||||
window->IDStack.push_back(window->GetID(ptr_id));
|
||||
window->IDStack.push_back(window->GetIDNoKeepAlive(ptr_id));
|
||||
}
|
||||
|
||||
void ImGui::PushID(int int_id)
|
||||
{
|
||||
const void* ptr_id = (void*)(intptr_t)int_id;
|
||||
ImGuiWindow* window = GetCurrentWindowRead();
|
||||
window->IDStack.push_back(window->GetID(ptr_id));
|
||||
window->IDStack.push_back(window->GetIDNoKeepAlive(ptr_id));
|
||||
}
|
||||
|
||||
void ImGui::PopID()
|
||||
@ -11835,7 +11844,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
||||
const float mouse_x = (io.MousePos.x - frame_bb.Min.x - style.FramePadding.x) + edit_state.ScrollX;
|
||||
const float mouse_y = (is_multiline ? (io.MousePos.y - draw_window->DC.CursorPos.y - style.FramePadding.y) : (g.FontSize*0.5f));
|
||||
|
||||
const bool is_osx = io.OptMacOSXBehaviors;
|
||||
const bool is_osx = io.ConfigMacOSXBehaviors;
|
||||
if (select_all || (hovered && !is_osx && io.MouseDoubleClicked[0]))
|
||||
{
|
||||
edit_state.SelectAll();
|
||||
@ -11888,7 +11897,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
||||
{
|
||||
// Handle key-presses
|
||||
const int k_mask = (io.KeyShift ? STB_TEXTEDIT_K_SHIFT : 0);
|
||||
const bool is_osx = io.OptMacOSXBehaviors;
|
||||
const bool is_osx = io.ConfigMacOSXBehaviors;
|
||||
const bool is_shortcut_key = (is_osx ? (io.KeySuper && !io.KeyCtrl) : (io.KeyCtrl && !io.KeySuper)) && !io.KeyAlt && !io.KeyShift; // OS X style: Shortcuts using Cmd/Super instead of Ctrl
|
||||
const bool is_osx_shift_shortcut = is_osx && io.KeySuper && io.KeyShift && !io.KeyCtrl && !io.KeyAlt;
|
||||
const bool is_wordmove_key_down = is_osx ? io.KeyAlt : io.KeyCtrl; // OS X style: Text editing cursor movement using Alt instead of Ctrl
|
||||
@ -12247,7 +12256,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
||||
draw_window->DrawList->AddText(g.Font, g.FontSize, render_pos - render_scroll, GetColorU32(ImGuiCol_Text), buf_display, buf_display + edit_state.CurLenA, 0.0f, is_multiline ? NULL : &clip_rect);
|
||||
|
||||
// Draw blinking cursor
|
||||
bool cursor_is_visible = (!g.IO.OptCursorBlink) || (g.InputTextState.CursorAnim <= 0.0f) || ImFmod(g.InputTextState.CursorAnim, 1.20f) <= 0.80f;
|
||||
bool cursor_is_visible = (!g.IO.ConfigCursorBlink) || (g.InputTextState.CursorAnim <= 0.0f) || ImFmod(g.InputTextState.CursorAnim, 1.20f) <= 0.80f;
|
||||
ImVec2 cursor_screen_pos = render_pos + cursor_offset - render_scroll;
|
||||
ImRect cursor_screen_rect(cursor_screen_pos.x, cursor_screen_pos.y-g.FontSize+0.5f, cursor_screen_pos.x+1.0f, cursor_screen_pos.y-1.5f);
|
||||
if (cursor_is_visible && cursor_screen_rect.Overlaps(clip_rect))
|
||||
@ -14644,6 +14653,9 @@ void ImGui::ClearDragDrop()
|
||||
g.DragDropAcceptIdCurr = g.DragDropAcceptIdPrev = 0;
|
||||
g.DragDropAcceptIdCurrRectSurface = FLT_MAX;
|
||||
g.DragDropAcceptFrameCount = -1;
|
||||
|
||||
g.DragDropPayloadBufHeap.clear();
|
||||
memset(&g.DragDropPayloadBufLocal, 0, sizeof(g.DragDropPayloadBufLocal));
|
||||
}
|
||||
|
||||
// Call when current ID is active.
|
||||
@ -14817,6 +14829,8 @@ bool ImGui::BeginDragDropTargetCustom(const ImRect& bb, ImGuiID id)
|
||||
IM_ASSERT(id != 0);
|
||||
if (!IsMouseHoveringRect(bb.Min, bb.Max) || (id == g.DragDropPayload.SourceId))
|
||||
return false;
|
||||
if (window->SkipItems)
|
||||
return false;
|
||||
|
||||
IM_ASSERT(g.DragDropWithinSourceOrTarget == false);
|
||||
g.DragDropTargetRect = bb;
|
||||
|
Reference in New Issue
Block a user