Docking: Added ImVec2[] non const operator. Added ImStrSkipBlank. Reseting some values earlier in Begin. Added IMGUI_DEBUG_LOG() helper. Added docking source code section.
This commit is contained in:
parent
58d46e1fe6
commit
2ec135c9f7
21
imgui.cpp
21
imgui.cpp
@ -1257,6 +1257,13 @@ void ImStrTrimBlanks(char* buf)
|
||||
buf[p - p_start] = 0; // Zero terminate
|
||||
}
|
||||
|
||||
const char* ImStrSkipBlank(const char* str)
|
||||
{
|
||||
while (str[0] == ' ' || str[0] == '\t')
|
||||
str++;
|
||||
return str;
|
||||
}
|
||||
|
||||
// A) MSVC version appears to return -1 on overflow, whereas glibc appears to return total count (which may be >= buf_size).
|
||||
// Ideally we would test for only one of those limits at runtime depending on the behavior the vsnprintf(), but trying to deduct it at compile time sounds like a pandora can of worm.
|
||||
// B) When buf==NULL vsnprintf() will return the output size.
|
||||
@ -3234,6 +3241,7 @@ void ImGui::NewFrame()
|
||||
{
|
||||
ImGuiWindow* window = g.Windows[i];
|
||||
window->WasActive = window->Active;
|
||||
window->BeginCount = 0;
|
||||
window->Active = false;
|
||||
window->WriteAccessed = false;
|
||||
}
|
||||
@ -3266,7 +3274,7 @@ void ImGui::Initialize(ImGuiContext* context)
|
||||
ini_handler.ReadOpenFn = SettingsHandlerWindow_ReadOpen;
|
||||
ini_handler.ReadLineFn = SettingsHandlerWindow_ReadLine;
|
||||
ini_handler.WriteAllFn = SettingsHandlerWindow_WriteAll;
|
||||
g.SettingsHandlers.push_front(ini_handler);
|
||||
g.SettingsHandlers.push_back(ini_handler);
|
||||
|
||||
g.Initialized = true;
|
||||
}
|
||||
@ -4527,9 +4535,15 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
const int current_frame = g.FrameCount;
|
||||
const bool first_begin_of_the_frame = (window->LastFrameActive != current_frame);
|
||||
if (first_begin_of_the_frame)
|
||||
{
|
||||
window->Flags = (ImGuiWindowFlags)flags;
|
||||
window->BeginOrderWithinParent = 0;
|
||||
window->BeginOrderWithinContext = g.WindowsActiveCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
flags = window->Flags;
|
||||
}
|
||||
|
||||
// Parent window is latched only on the first call to Begin() of the frame, so further append-calls can be done from a different window stack
|
||||
ImGuiWindow* parent_window_in_stack = g.CurrentWindowStack.empty() ? NULL : g.CurrentWindowStack.back();
|
||||
@ -4616,9 +4630,6 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
UpdateWindowParentAndRootLinks(window, flags, parent_window);
|
||||
|
||||
window->Active = true;
|
||||
window->BeginOrderWithinParent = 0;
|
||||
window->BeginOrderWithinContext = g.WindowsActiveCount++;
|
||||
window->BeginCount = 0;
|
||||
window->ClipRect = ImVec4(-FLT_MAX,-FLT_MAX,+FLT_MAX,+FLT_MAX);
|
||||
window->LastFrameActive = current_frame;
|
||||
window->IDStack.resize(1);
|
||||
@ -8788,6 +8799,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
ImGui::End();
|
||||
return;
|
||||
}
|
||||
|
||||
static bool show_draw_cmd_clip_rects = true;
|
||||
static bool show_window_begin_order = false;
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
@ -8798,7 +8810,6 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
ImGui::Text("%d allocations", io.MetricsActiveAllocations);
|
||||
ImGui::Checkbox("Show clipping rectangles when hovering draw commands", &show_draw_cmd_clip_rects);
|
||||
ImGui::Checkbox("Ctrl shows window begin order", &show_window_begin_order);
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
struct Funcs
|
||||
|
3
imgui.h
3
imgui.h
@ -139,7 +139,8 @@ struct ImVec2
|
||||
float x, y;
|
||||
ImVec2() { x = y = 0.0f; }
|
||||
ImVec2(float _x, float _y) { x = _x; y = _y; }
|
||||
float operator[] (size_t i) const { IM_ASSERT(i <= 1); return (&x)[i]; } // We very rarely use this [] operator, the assert overhead is fine.
|
||||
float operator[] (size_t idx) const { IM_ASSERT(idx <= 1); return (&x)[idx]; } // We very rarely use this [] operator, the assert overhead is fine.
|
||||
float& operator[] (size_t idx) { IM_ASSERT(idx <= 1); return (&x)[idx]; } // We very rarely use this [] operator, the assert overhead is fine.
|
||||
#ifdef IM_VEC2_CLASS_EXTRA
|
||||
IM_VEC2_CLASS_EXTRA // Define additional constructors and implicit cast operators in imconfig.h to convert back and forth between your math types and ImVec2.
|
||||
#endif
|
||||
|
@ -100,6 +100,8 @@ extern IMGUI_API ImGuiContext* GImGui; // Current implicit ImGui context pointe
|
||||
#else
|
||||
#define IM_NEWLINE "\n"
|
||||
#endif
|
||||
|
||||
#define IMGUI_DEBUG_LOG(FMT,...) printf("[%05d] " FMT, GImGui->FrameCount, __VA_ARGS__)
|
||||
#define IM_STATIC_ASSERT(_COND) typedef char static_assertion_##__line__[(_COND)?1:-1]
|
||||
#define IM_F32_TO_INT8_UNBOUND(_VAL) ((int)((_VAL) * 255.0f + ((_VAL)>=0 ? 0.5f : -0.5f))) // Unsaturated, for display purpose
|
||||
#define IM_F32_TO_INT8_SAT(_VAL) ((int)(ImSaturate(_VAL) * 255.0f + 0.5f)) // Saturated, always output 0..255
|
||||
@ -146,6 +148,7 @@ IMGUI_API int ImStrlenW(const ImWchar* str);
|
||||
IMGUI_API const ImWchar*ImStrbolW(const ImWchar* buf_mid_line, const ImWchar* buf_begin); // Find beginning-of-line
|
||||
IMGUI_API const char* ImStristr(const char* haystack, const char* haystack_end, const char* needle, const char* needle_end);
|
||||
IMGUI_API void ImStrTrimBlanks(char* str);
|
||||
IMGUI_API const char* ImStrSkipBlank(const char* str);
|
||||
IMGUI_API int ImFormatString(char* buf, size_t buf_size, const char* fmt, ...) IM_FMTARGS(3);
|
||||
IMGUI_API int ImFormatStringV(char* buf, size_t buf_size, const char* fmt, va_list args) IM_FMTLIST(3);
|
||||
IMGUI_API const char* ImParseFormatFindStart(const char* format);
|
||||
@ -291,6 +294,19 @@ enum ImGuiSeparatorFlags_
|
||||
ImGuiSeparatorFlags_Vertical = 1 << 1
|
||||
};
|
||||
|
||||
// Transient per-window ItemFlags, reset at the beginning of the frame. For child windows: inherited from parent on first Begin().
|
||||
// This is going to be exposed in imgui.h when stabilized enough.
|
||||
enum ImGuiItemFlags_
|
||||
{
|
||||
ImGuiItemFlags_AllowKeyboardFocus = 1 << 0, // true
|
||||
ImGuiItemFlags_ButtonRepeat = 1 << 1, // false // Button() will return true multiple times based on io.KeyRepeatDelay and io.KeyRepeatRate settings.
|
||||
ImGuiItemFlags_Disabled = 1 << 2, // false // [BETA] Disable interactions but doesn't affect visuals yet. See github.com/ocornut/imgui/issues/211
|
||||
ImGuiItemFlags_NoNav = 1 << 3, // false
|
||||
ImGuiItemFlags_NoNavDefaultFocus = 1 << 4, // false
|
||||
ImGuiItemFlags_SelectableDontClosePopup = 1 << 5, // false // MenuItem/Selectable() automatically closes current Popup window
|
||||
ImGuiItemFlags_Default_ = ImGuiItemFlags_AllowKeyboardFocus
|
||||
};
|
||||
|
||||
// Storage for LastItem data
|
||||
enum ImGuiItemStatusFlags_
|
||||
{
|
||||
@ -935,18 +951,9 @@ struct ImGuiContext
|
||||
}
|
||||
};
|
||||
|
||||
// Transient per-window flags, reset at the beginning of the frame. For child window, inherited from parent on first Begin().
|
||||
// This is going to be exposed in imgui.h when stabilized enough.
|
||||
enum ImGuiItemFlags_
|
||||
{
|
||||
ImGuiItemFlags_AllowKeyboardFocus = 1 << 0, // true
|
||||
ImGuiItemFlags_ButtonRepeat = 1 << 1, // false // Button() will return true multiple times based on io.KeyRepeatDelay and io.KeyRepeatRate settings.
|
||||
ImGuiItemFlags_Disabled = 1 << 2, // false // [BETA] Disable interactions but doesn't affect visuals yet. See github.com/ocornut/imgui/issues/211
|
||||
ImGuiItemFlags_NoNav = 1 << 3, // false
|
||||
ImGuiItemFlags_NoNavDefaultFocus = 1 << 4, // false
|
||||
ImGuiItemFlags_SelectableDontClosePopup = 1 << 5, // false // MenuItem/Selectable() automatically closes current Popup window
|
||||
ImGuiItemFlags_Default_ = ImGuiItemFlags_AllowKeyboardFocus
|
||||
};
|
||||
//-----------------------------------------------------------------------------
|
||||
// ImGuiWindow
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Transient per-window data, reset at the beginning of the frame. This used to be called ImGuiDrawContext, hence the DC variable name in ImGuiWindow.
|
||||
// FIXME: That's theory, in practice the delimitation between ImGuiWindow and ImGuiWindowTempData is quite tenuous and could be reconsidered.
|
||||
@ -1215,7 +1222,7 @@ namespace ImGui
|
||||
inline ImGuiWindow* GetCurrentWindowRead() { ImGuiContext& g = *GImGui; return g.CurrentWindow; }
|
||||
inline ImGuiWindow* GetCurrentWindow() { ImGuiContext& g = *GImGui; g.CurrentWindow->WriteAccessed = true; return g.CurrentWindow; }
|
||||
IMGUI_API ImGuiWindow* FindWindowByName(const char* name);
|
||||
IMGUI_API void FocusWindow(ImGuiWindow* window);
|
||||
IMGUI_API void FocusWindow(ImGuiWindow* window); // FIXME: Rename to SetWindowFocus()
|
||||
IMGUI_API void FocusFrontMostActiveWindowIgnoringOne(ImGuiWindow* ignore_window);
|
||||
IMGUI_API void BringWindowToFront(ImGuiWindow* window);
|
||||
IMGUI_API void BringWindowToBack(ImGuiWindow* window);
|
||||
@ -1226,6 +1233,7 @@ namespace ImGui
|
||||
IMGUI_API void SetWindowScrollX(ImGuiWindow* window, float new_scroll_x);
|
||||
IMGUI_API void SetWindowScrollY(ImGuiWindow* window, float new_scroll_y);
|
||||
IMGUI_API ImRect GetWindowAllowedExtentRect(ImGuiWindow* window);
|
||||
|
||||
IMGUI_API void SetCurrentFont(ImFont* font);
|
||||
inline ImFont* GetDefaultFont() { ImGuiContext& g = *GImGui; return g.IO.FontDefault ? g.IO.FontDefault : g.IO.Fonts->Fonts[0]; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user