mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-07 13:35:49 +02:00
Merge branch 'master' into docking + tweak dock node padding + use CheckboxFlags with int
# Conflicts: # imgui.cpp # imgui_demo.cpp # imgui_internal.h
This commit is contained in:
153
imgui.cpp
153
imgui.cpp
@ -382,6 +382,7 @@ CODE
|
||||
- 2020/XX/XX (1.XX) - Moved IME support functions from io.ImeSetInputScreenPosFn, io.ImeWindowHandle to the PlatformIO api.
|
||||
|
||||
|
||||
- 2020/11/03 (1.80) - renamed io.ConfigWindowsMemoryCompactTimer to io.ConfigMemoryCompactTimer as the feature will apply to other data structures
|
||||
- 2020/10/14 (1.80) - backends: moved all backends files (imgui_impl_XXXX.cpp, imgui_impl_XXXX.h) from examples/ to backends/.
|
||||
- 2020/10/12 (1.80) - removed redirecting functions/enums that were marked obsolete in 1.60 (April 2018):
|
||||
- io.RenderDrawListsFn pointer -> use ImGui::GetDrawData() value and call the render function of your backend
|
||||
@ -873,6 +874,7 @@ static float NavUpdatePageUpPageDown();
|
||||
static inline void NavUpdateAnyRequestFlag();
|
||||
static void NavEndFrame();
|
||||
static bool NavScoreItem(ImGuiNavMoveResult* result, ImRect cand);
|
||||
static void NavApplyItemToResult(ImGuiNavMoveResult* result, ImGuiWindow* window, ImGuiID id, const ImRect& nav_bb_rel);
|
||||
static void NavProcessItem(ImGuiWindow* window, const ImRect& nav_bb, ImGuiID id);
|
||||
static ImVec2 NavCalcPreferredRefPos();
|
||||
static void NavSaveLastChildNavWindowIntoParent(ImGuiWindow* nav_window);
|
||||
@ -1076,7 +1078,7 @@ ImGuiIO::ImGuiIO()
|
||||
ConfigInputTextCursorBlink = true;
|
||||
ConfigWindowsResizeFromEdges = true;
|
||||
ConfigWindowsMoveFromTitleBarOnly = false;
|
||||
ConfigWindowsMemoryCompactTimer = 60.0f;
|
||||
ConfigMemoryCompactTimer = 60.0f;
|
||||
|
||||
// Platform Functions
|
||||
BackendPlatformName = BackendRendererName = NULL;
|
||||
@ -1590,66 +1592,58 @@ void* ImFileLoadToMemory(const char* filename, const char* mode, size_t* out_f
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Convert UTF-8 to 32-bit character, process single character input.
|
||||
// Based on stb_from_utf8() from github.com/nothings/stb/
|
||||
// A nearly-branchless UTF-8 decoder, based on work of Christopher Wellons (https://github.com/skeeto/branchless-utf8).
|
||||
// We handle UTF-8 decoding error by skipping forward.
|
||||
int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char* in_text_end)
|
||||
{
|
||||
unsigned int c = (unsigned int)-1;
|
||||
const unsigned char* str = (const unsigned char*)in_text;
|
||||
if (!(*str & 0x80))
|
||||
static const char lengths[32] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 3, 3, 4, 0 };
|
||||
static const int masks[] = { 0x00, 0x7f, 0x1f, 0x0f, 0x07 };
|
||||
static const uint32_t mins[] = { 0x400000, 0, 0x80, 0x800, 0x10000 };
|
||||
static const int shiftc[] = { 0, 18, 12, 6, 0 };
|
||||
static const int shifte[] = { 0, 6, 4, 2, 0 };
|
||||
int len = lengths[*(const unsigned char*)in_text >> 3];
|
||||
int wanted = len + !len;
|
||||
|
||||
if (in_text_end == NULL)
|
||||
in_text_end = in_text + wanted; // Max length, nulls will be taken into account.
|
||||
|
||||
// Copy at most 'len' bytes, stop copying at 0 or past in_text_end. Branch predictor does a good job here,
|
||||
// so it is fast even with excessive branching.
|
||||
unsigned char s[4];
|
||||
s[0] = in_text + 0 < in_text_end ? in_text[0] : 0;
|
||||
s[1] = in_text + 1 < in_text_end ? in_text[1] : 0;
|
||||
s[2] = in_text + 2 < in_text_end ? in_text[2] : 0;
|
||||
s[3] = in_text + 3 < in_text_end ? in_text[3] : 0;
|
||||
|
||||
// Assume a four-byte character and load four bytes. Unused bits are shifted out.
|
||||
*out_char = (uint32_t)(s[0] & masks[len]) << 18;
|
||||
*out_char |= (uint32_t)(s[1] & 0x3f) << 12;
|
||||
*out_char |= (uint32_t)(s[2] & 0x3f) << 6;
|
||||
*out_char |= (uint32_t)(s[3] & 0x3f) << 0;
|
||||
*out_char >>= shiftc[len];
|
||||
|
||||
// Accumulate the various error conditions.
|
||||
int e = 0;
|
||||
e = (*out_char < mins[len]) << 6; // non-canonical encoding
|
||||
e |= ((*out_char >> 11) == 0x1b) << 7; // surrogate half?
|
||||
e |= (*out_char > IM_UNICODE_CODEPOINT_MAX) << 8; // out of range?
|
||||
e |= (s[1] & 0xc0) >> 2;
|
||||
e |= (s[2] & 0xc0) >> 4;
|
||||
e |= (s[3] ) >> 6;
|
||||
e ^= 0x2a; // top two bits of each tail byte correct?
|
||||
e >>= shifte[len];
|
||||
|
||||
if (e)
|
||||
{
|
||||
c = (unsigned int)(*str++);
|
||||
*out_char = c;
|
||||
return 1;
|
||||
// No bytes are consumed when *in_text == 0 || in_text == in_text_end.
|
||||
// One byte is consumed in case of invalid first byte of in_text.
|
||||
// All available bytes (at most `len` bytes) are consumed on incomplete/invalid second to last bytes.
|
||||
// Invalid or incomplete input may consume less bytes than wanted, therefore every byte has to be inspected in s.
|
||||
wanted = ImMin(wanted, !!s[0] + !!s[1] + !!s[2] + !!s[3]);
|
||||
*out_char = IM_UNICODE_CODEPOINT_INVALID;
|
||||
}
|
||||
if ((*str & 0xe0) == 0xc0)
|
||||
{
|
||||
*out_char = IM_UNICODE_CODEPOINT_INVALID; // will be invalid but not end of string
|
||||
if (in_text_end && in_text_end - (const char*)str < 2) return 1;
|
||||
if (*str < 0xc2) return 2;
|
||||
c = (unsigned int)((*str++ & 0x1f) << 6);
|
||||
if ((*str & 0xc0) != 0x80) return 2;
|
||||
c += (*str++ & 0x3f);
|
||||
*out_char = c;
|
||||
return 2;
|
||||
}
|
||||
if ((*str & 0xf0) == 0xe0)
|
||||
{
|
||||
*out_char = IM_UNICODE_CODEPOINT_INVALID; // will be invalid but not end of string
|
||||
if (in_text_end && in_text_end - (const char*)str < 3) return 1;
|
||||
if (*str == 0xe0 && (str[1] < 0xa0 || str[1] > 0xbf)) return 3;
|
||||
if (*str == 0xed && str[1] > 0x9f) return 3; // str[1] < 0x80 is checked below
|
||||
c = (unsigned int)((*str++ & 0x0f) << 12);
|
||||
if ((*str & 0xc0) != 0x80) return 3;
|
||||
c += (unsigned int)((*str++ & 0x3f) << 6);
|
||||
if ((*str & 0xc0) != 0x80) return 3;
|
||||
c += (*str++ & 0x3f);
|
||||
*out_char = c;
|
||||
return 3;
|
||||
}
|
||||
if ((*str & 0xf8) == 0xf0)
|
||||
{
|
||||
*out_char = IM_UNICODE_CODEPOINT_INVALID; // will be invalid but not end of string
|
||||
if (in_text_end && in_text_end - (const char*)str < 4) return 1;
|
||||
if (*str > 0xf4) return 4;
|
||||
if (*str == 0xf0 && (str[1] < 0x90 || str[1] > 0xbf)) return 4;
|
||||
if (*str == 0xf4 && str[1] > 0x8f) return 4; // str[1] < 0x80 is checked below
|
||||
c = (unsigned int)((*str++ & 0x07) << 18);
|
||||
if ((*str & 0xc0) != 0x80) return 4;
|
||||
c += (unsigned int)((*str++ & 0x3f) << 12);
|
||||
if ((*str & 0xc0) != 0x80) return 4;
|
||||
c += (unsigned int)((*str++ & 0x3f) << 6);
|
||||
if ((*str & 0xc0) != 0x80) return 4;
|
||||
c += (*str++ & 0x3f);
|
||||
// utf-8 encodings of values used in surrogate pairs are invalid
|
||||
if ((c & 0xFFFFF800) == 0xD800) return 4;
|
||||
// If codepoint does not fit in ImWchar, use replacement character U+FFFD instead
|
||||
if (c > IM_UNICODE_CODEPOINT_MAX) c = IM_UNICODE_CODEPOINT_INVALID;
|
||||
*out_char = c;
|
||||
return 4;
|
||||
}
|
||||
*out_char = 0;
|
||||
return 0;
|
||||
|
||||
return wanted;
|
||||
}
|
||||
|
||||
int ImTextStrFromUtf8(ImWchar* buf, int buf_size, const char* in_text, const char* in_text_end, const char** in_text_remaining)
|
||||
@ -4072,7 +4066,7 @@ void ImGui::NewFrame()
|
||||
|
||||
// Mark all windows as not visible and compact unused memory.
|
||||
IM_ASSERT(g.WindowsFocusOrder.Size == g.Windows.Size);
|
||||
const float memory_compact_start_time = (g.IO.ConfigWindowsMemoryCompactTimer >= 0.0f) ? (float)g.Time - g.IO.ConfigWindowsMemoryCompactTimer : FLT_MAX;
|
||||
const float memory_compact_start_time = (g.IO.ConfigMemoryCompactTimer >= 0.0f) ? (float)g.Time - g.IO.ConfigMemoryCompactTimer : FLT_MAX;
|
||||
for (int i = 0; i != g.Windows.Size; i++)
|
||||
{
|
||||
ImGuiWindow* window = g.Windows[i];
|
||||
@ -9121,6 +9115,14 @@ static bool ImGui::NavScoreItem(ImGuiNavMoveResult* result, ImRect cand)
|
||||
return new_best;
|
||||
}
|
||||
|
||||
static void ImGui::NavApplyItemToResult(ImGuiNavMoveResult* result, ImGuiWindow* window, ImGuiID id, const ImRect& nav_bb_rel)
|
||||
{
|
||||
result->Window = window;
|
||||
result->ID = id;
|
||||
result->FocusScopeId = window->DC.NavFocusScopeIdCurrent;
|
||||
result->RectRel = nav_bb_rel;
|
||||
}
|
||||
|
||||
// We get there when either NavId == id, or when g.NavAnyRequest is set (which is updated by NavUpdateAnyRequestFlag above)
|
||||
static void ImGui::NavProcessItem(ImGuiWindow* window, const ImRect& nav_bb, const ImGuiID id)
|
||||
{
|
||||
@ -9161,25 +9163,14 @@ static void ImGui::NavProcessItem(ImGuiWindow* window, const ImRect& nav_bb, con
|
||||
bool new_best = g.NavMoveRequest && NavScoreItem(result, nav_bb);
|
||||
#endif
|
||||
if (new_best)
|
||||
{
|
||||
result->Window = window;
|
||||
result->ID = id;
|
||||
result->FocusScopeId = window->DC.NavFocusScopeIdCurrent;
|
||||
result->RectRel = nav_bb_rel;
|
||||
}
|
||||
NavApplyItemToResult(result, window, id, nav_bb_rel);
|
||||
|
||||
// Features like PageUp/PageDown need to maintain a separate score for the visible set of items.
|
||||
const float VISIBLE_RATIO = 0.70f;
|
||||
if ((g.NavMoveRequestFlags & ImGuiNavMoveFlags_AlsoScoreVisibleSet) && window->ClipRect.Overlaps(nav_bb))
|
||||
if (ImClamp(nav_bb.Max.y, window->ClipRect.Min.y, window->ClipRect.Max.y) - ImClamp(nav_bb.Min.y, window->ClipRect.Min.y, window->ClipRect.Max.y) >= (nav_bb.Max.y - nav_bb.Min.y) * VISIBLE_RATIO)
|
||||
if (NavScoreItem(&g.NavMoveResultLocalVisibleSet, nav_bb))
|
||||
{
|
||||
result = &g.NavMoveResultLocalVisibleSet;
|
||||
result->Window = window;
|
||||
result->ID = id;
|
||||
result->FocusScopeId = window->DC.NavFocusScopeIdCurrent;
|
||||
result->RectRel = nav_bb_rel;
|
||||
}
|
||||
NavApplyItemToResult(&g.NavMoveResultLocalVisibleSet, window, id, nav_bb_rel);
|
||||
}
|
||||
|
||||
// Update window-relative bounding box of navigated item
|
||||
@ -15629,7 +15620,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
// Contents
|
||||
DebugNodeWindowsList(&g.Windows, "Windows");
|
||||
//DebugNodeWindowsList(&g.WindowsFocusOrder, "WindowsFocusOrder");
|
||||
if (TreeNode("Viewport", "Viewports (%d)", g.Viewports.Size))
|
||||
if (TreeNode("Viewports", "Viewports (%d)", g.Viewports.Size))
|
||||
{
|
||||
Indent(GetTreeNodeToLabelSpacing());
|
||||
RenderViewportsThumbnails();
|
||||
@ -15916,15 +15907,15 @@ void ImGui::DebugNodeDockNode(ImGuiDockNode* node, const char* label)
|
||||
node->WantLockSizeOnce ? " WantLockSizeOnce" : "");
|
||||
if (TreeNode("flags", "LocalFlags: 0x%04X SharedFlags: 0x%04X", node->LocalFlags, node->SharedFlags))
|
||||
{
|
||||
CheckboxFlags("LocalFlags: NoDocking", (ImU32*)&node->LocalFlags, ImGuiDockNodeFlags_NoDocking);
|
||||
CheckboxFlags("LocalFlags: NoSplit", (ImU32*)&node->LocalFlags, ImGuiDockNodeFlags_NoSplit);
|
||||
CheckboxFlags("LocalFlags: NoResize", (ImU32*)&node->LocalFlags, ImGuiDockNodeFlags_NoResize);
|
||||
CheckboxFlags("LocalFlags: NoResizeX", (ImU32*)&node->LocalFlags, ImGuiDockNodeFlags_NoResizeX);
|
||||
CheckboxFlags("LocalFlags: NoResizeY", (ImU32*)&node->LocalFlags, ImGuiDockNodeFlags_NoResizeY);
|
||||
CheckboxFlags("LocalFlags: NoTabBar", (ImU32*)&node->LocalFlags, ImGuiDockNodeFlags_NoTabBar);
|
||||
CheckboxFlags("LocalFlags: HiddenTabBar", (ImU32*)&node->LocalFlags, ImGuiDockNodeFlags_HiddenTabBar);
|
||||
CheckboxFlags("LocalFlags: NoWindowMenuButton", (ImU32*)&node->LocalFlags, ImGuiDockNodeFlags_NoWindowMenuButton);
|
||||
CheckboxFlags("LocalFlags: NoCloseButton", (ImU32*)&node->LocalFlags, ImGuiDockNodeFlags_NoCloseButton);
|
||||
CheckboxFlags("LocalFlags: NoDocking", &node->LocalFlags, ImGuiDockNodeFlags_NoDocking);
|
||||
CheckboxFlags("LocalFlags: NoSplit", &node->LocalFlags, ImGuiDockNodeFlags_NoSplit);
|
||||
CheckboxFlags("LocalFlags: NoResize", &node->LocalFlags, ImGuiDockNodeFlags_NoResize);
|
||||
CheckboxFlags("LocalFlags: NoResizeX", &node->LocalFlags, ImGuiDockNodeFlags_NoResizeX);
|
||||
CheckboxFlags("LocalFlags: NoResizeY", &node->LocalFlags, ImGuiDockNodeFlags_NoResizeY);
|
||||
CheckboxFlags("LocalFlags: NoTabBar", &node->LocalFlags, ImGuiDockNodeFlags_NoTabBar);
|
||||
CheckboxFlags("LocalFlags: HiddenTabBar", &node->LocalFlags, ImGuiDockNodeFlags_HiddenTabBar);
|
||||
CheckboxFlags("LocalFlags: NoWindowMenuButton", &node->LocalFlags, ImGuiDockNodeFlags_NoWindowMenuButton);
|
||||
CheckboxFlags("LocalFlags: NoCloseButton", &node->LocalFlags, ImGuiDockNodeFlags_NoCloseButton);
|
||||
TreePop();
|
||||
}
|
||||
if (node->ParentNode)
|
||||
@ -16224,7 +16215,7 @@ void ImGui::DebugNodeWindowsList(ImVector<ImGuiWindow*>* windows, const char* la
|
||||
|
||||
void ImGui::ShowMetricsWindow(bool*) {}
|
||||
void ImGui::DebugNodeColumns(ImGuiColumns*) {}
|
||||
void ImGui::DebugNodeDrawList(ImGuiWindow*, ImGuiViewportP* viewport, const ImDrawList*, const char*) {}
|
||||
void ImGui::DebugNodeDrawList(ImGuiWindow*, ImGuiViewportP*, const ImDrawList*, const char*) {}
|
||||
void ImGui::DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList*, const ImDrawList*, const ImDrawCmd*, bool, bool) {}
|
||||
void ImGui::DebugNodeStorage(ImGuiStorage*, const char*) {}
|
||||
void ImGui::DebugNodeTabBar(ImGuiTabBar*, const char*) {}
|
||||
|
Reference in New Issue
Block a user