mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-22 15:46:35 +00:00
Merge branch 'viewport' into docking
# Conflicts: # imgui.cpp # imgui_widgets.cpp
This commit is contained in:
commit
e6cc547a94
@ -86,7 +86,7 @@ Other Changes:
|
|||||||
introduced in 1.50 and broken in 1.60. (#1698, #894, #713).
|
introduced in 1.50 and broken in 1.60. (#1698, #894, #713).
|
||||||
- TextUnformatted(): Fixed a case where large-text path would read bytes past the text_end marker depending
|
- TextUnformatted(): Fixed a case where large-text path would read bytes past the text_end marker depending
|
||||||
on the position of new lines in the buffer (it wasn't affecting the output but still not the right thing to do!)
|
on the position of new lines in the buffer (it wasn't affecting the output but still not the right thing to do!)
|
||||||
- InputTextMultiline(), RenderText(): Some optimization for very large text buffers, useful for non-optimized builds.
|
- RenderText(): Some optimization for very large text buffers, useful for non-optimized builds.
|
||||||
- BeginMenu(): Fixed menu popup horizontal offset being off the item in the menu bar when WindowPadding=0.0f.
|
- BeginMenu(): Fixed menu popup horizontal offset being off the item in the menu bar when WindowPadding=0.0f.
|
||||||
- ArrowButton(): Fixed arrow shape being horizontally misaligned by (FramePadding.y-FramePadding.x) if they are different.
|
- ArrowButton(): Fixed arrow shape being horizontally misaligned by (FramePadding.y-FramePadding.x) if they are different.
|
||||||
- Drag and Drop: Added GetDragDropPayload() to peek directly into the payload (if any) from anywhere. (#143)
|
- Drag and Drop: Added GetDragDropPayload() to peek directly into the payload (if any) from anywhere. (#143)
|
||||||
|
27
imgui.cpp
27
imgui.cpp
@ -863,13 +863,13 @@ CODE
|
|||||||
|
|
||||||
#include <ctype.h> // toupper, isprint
|
#include <ctype.h> // toupper, isprint
|
||||||
#include <stdio.h> // vsnprintf, sscanf, printf
|
#include <stdio.h> // vsnprintf, sscanf, printf
|
||||||
#include <wchar.h> // wcslen
|
|
||||||
#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
|
#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
|
||||||
#include <stddef.h> // intptr_t
|
#include <stddef.h> // intptr_t
|
||||||
#else
|
#else
|
||||||
#include <stdint.h> // intptr_t
|
#include <stdint.h> // intptr_t
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Debug options
|
||||||
#define IMGUI_DEBUG_NAV_SCORING 0 // Display navigation scoring preview when hovering items. Display last moving direction matches when holding CTRL
|
#define IMGUI_DEBUG_NAV_SCORING 0 // Display navigation scoring preview when hovering items. Display last moving direction matches when holding CTRL
|
||||||
#define IMGUI_DEBUG_NAV_RECTS 0 // Display the reference navigation rectangle for each window
|
#define IMGUI_DEBUG_NAV_RECTS 0 // Display the reference navigation rectangle for each window
|
||||||
#define IMGUI_DEBUG_DOCKING_INI 0 // Save additional comments in .ini file (makes saving slower)
|
#define IMGUI_DEBUG_DOCKING_INI 0 // Save additional comments in .ini file (makes saving slower)
|
||||||
@ -972,6 +972,14 @@ static int FindPlatformMonitorForRect(const ImRect& r);
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test engine hooks (imgui-test)
|
||||||
|
//#define IMGUI_ENABLE_TEST_ENGINE_HOOKS
|
||||||
|
#ifdef IMGUI_ENABLE_TEST_ENGINE_HOOKS
|
||||||
|
extern void ImGuiTestEngineHook_PreNewFrame();
|
||||||
|
extern void ImGuiTestEngineHook_PostNewFrame();
|
||||||
|
extern void ImGuiTestEngineHook_ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg);
|
||||||
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] CONTEXT AND MEMORY ALLOCATORS
|
// [SECTION] CONTEXT AND MEMORY ALLOCATORS
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -1235,7 +1243,10 @@ const char* ImStrchrRange(const char* str, const char* str_end, char c)
|
|||||||
|
|
||||||
int ImStrlenW(const ImWchar* str)
|
int ImStrlenW(const ImWchar* str)
|
||||||
{
|
{
|
||||||
return (int)wcslen((const wchar_t*)str);
|
//return (int)wcslen((const wchar_t*)str); // FIXME-OPT: Could use this when wchar_t are 16-bits
|
||||||
|
int n = 0;
|
||||||
|
while (*str++) n++;
|
||||||
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find end-of-line. Return pointer will point to either first \n, either str_end.
|
// Find end-of-line. Return pointer will point to either first \n, either str_end.
|
||||||
@ -2640,6 +2651,10 @@ void ImGui::ItemSize(const ImRect& bb, float text_offset_y)
|
|||||||
// declare their minimum size requirement to ItemSize() and then use a larger region for drawing/interaction, which is passed to ItemAdd().
|
// declare their minimum size requirement to ItemSize() and then use a larger region for drawing/interaction, which is passed to ItemAdd().
|
||||||
bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg)
|
bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg)
|
||||||
{
|
{
|
||||||
|
#ifdef IMGUI_ENABLE_TEST_ENGINE_HOOKS
|
||||||
|
ImGuiTestEngineHook_ItemAdd(bb, id, nav_bb_arg);
|
||||||
|
#endif
|
||||||
|
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
ImGuiWindow* window = g.CurrentWindow;
|
ImGuiWindow* window = g.CurrentWindow;
|
||||||
|
|
||||||
@ -3219,6 +3234,10 @@ void ImGui::NewFrame()
|
|||||||
IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() or ImGui::SetCurrentContext()?");
|
IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() or ImGui::SetCurrentContext()?");
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
|
|
||||||
|
#ifdef IMGUI_ENABLE_TEST_ENGINE_HOOKS
|
||||||
|
ImGuiTestEngineHook_PreNewFrame();
|
||||||
|
#endif
|
||||||
|
|
||||||
// Check user data
|
// Check user data
|
||||||
// (We pass an error message in the assert expression to make it visible to programmers who are not using a debugger, as most assert handlers display their argument)
|
// (We pass an error message in the assert expression to make it visible to programmers who are not using a debugger, as most assert handlers display their argument)
|
||||||
IM_ASSERT(g.Initialized);
|
IM_ASSERT(g.Initialized);
|
||||||
@ -3435,6 +3454,10 @@ void ImGui::NewFrame()
|
|||||||
// We don't use "Debug" to avoid colliding with user trying to create a "Debug" window with custom flags.
|
// We don't use "Debug" to avoid colliding with user trying to create a "Debug" window with custom flags.
|
||||||
SetNextWindowSize(ImVec2(400,400), ImGuiCond_FirstUseEver);
|
SetNextWindowSize(ImVec2(400,400), ImGuiCond_FirstUseEver);
|
||||||
Begin("Debug##Default");
|
Begin("Debug##Default");
|
||||||
|
|
||||||
|
#ifdef IMGUI_ENABLE_TEST_ENGINE_HOOKS
|
||||||
|
ImGuiTestEngineHook_PostNewFrame();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::Initialize(ImGuiContext* context)
|
void ImGui::Initialize(ImGuiContext* context)
|
||||||
|
@ -38,7 +38,6 @@ Index of this file:
|
|||||||
#include "imgui_internal.h"
|
#include "imgui_internal.h"
|
||||||
|
|
||||||
#include <ctype.h> // toupper, isprint
|
#include <ctype.h> // toupper, isprint
|
||||||
#include <wchar.h> // wmemchr
|
|
||||||
#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
|
#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
|
||||||
#include <stddef.h> // intptr_t
|
#include <stddef.h> // intptr_t
|
||||||
#else
|
#else
|
||||||
@ -3641,7 +3640,9 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
|||||||
// In multi-line mode, we never exit the loop until all lines are counted, so add one extra to the searches_remaining counter.
|
// In multi-line mode, we never exit the loop until all lines are counted, so add one extra to the searches_remaining counter.
|
||||||
searches_remaining += is_multiline ? 1 : 0;
|
searches_remaining += is_multiline ? 1 : 0;
|
||||||
int line_count = 0;
|
int line_count = 0;
|
||||||
for (const ImWchar* s = text_begin; (s = (const ImWchar*)wcschr((const wchar_t*)s, (wchar_t)'\n')) != NULL; s++)
|
//for (const ImWchar* s = text_begin; (s = (const ImWchar*)wcschr((const wchar_t*)s, (wchar_t)'\n')) != NULL; s++) // FIXME-OPT: Could use this when wchar_t are 16-bits
|
||||||
|
for (const ImWchar* s = text_begin; *s != 0; s++)
|
||||||
|
if (*s == '\n')
|
||||||
{
|
{
|
||||||
line_count++;
|
line_count++;
|
||||||
if (searches_result_line_number[0] == -1 && s >= searches_input_ptr[0]) { searches_result_line_number[0] = line_count; if (--searches_remaining <= 0) break; }
|
if (searches_result_line_number[0] == -1 && s >= searches_input_ptr[0]) { searches_result_line_number[0] = line_count; if (--searches_remaining <= 0) break; }
|
||||||
@ -3714,8 +3715,11 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
|||||||
break;
|
break;
|
||||||
if (rect_pos.y < clip_rect.y)
|
if (rect_pos.y < clip_rect.y)
|
||||||
{
|
{
|
||||||
p = (const ImWchar*)wmemchr((const wchar_t*)p, '\n', text_selected_end - p);
|
//p = (const ImWchar*)wmemchr((const wchar_t*)p, '\n', text_selected_end - p); // FIXME-OPT: Could use this when wchar_t are 16-bits
|
||||||
p = p ? p + 1 : text_selected_end;
|
//p = p ? p + 1 : text_selected_end;
|
||||||
|
while (p < text_selected_end)
|
||||||
|
if (*p++ == '\n')
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user