mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
Bump imgui to ecf82ca8066.
This commit is contained in:
parent
2da6c6b6f5
commit
211dfd7f7e
291
imgui/imgui.cpp
291
imgui/imgui.cpp
@ -4,7 +4,7 @@
|
||||
// Help:
|
||||
// - Read FAQ at http://dearimgui.org/faq
|
||||
// - Newcomers, read 'Programmer guide' below for notes on how to setup Dear ImGui in your codebase.
|
||||
// - Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp for demo code. All applications in examples/ are doing that.
|
||||
// - Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp. All applications in examples/ are doing that.
|
||||
// Read imgui.cpp for details, links and comments.
|
||||
|
||||
// Resources:
|
||||
@ -383,6 +383,7 @@ CODE
|
||||
- 2019/XX/XX (1.XX) - Moved IME support functions from io.ImeSetInputScreenPosFn, io.ImeWindowHandle to the PlatformIO api.
|
||||
|
||||
|
||||
- 2020/04/23 (1.77) - Removed unnecessary ID (first arg) of ImFontAtlas::AddCustomRectRegular().
|
||||
- 2020/01/22 (1.75) - ImDrawList::AddCircle()/AddCircleFilled() functions don't accept negative radius any more.
|
||||
- 2019/12/17 (1.75) - [undid this change in 1.76] made Columns() limited to 64 columns by asserting above that limit. While the current code technically supports it, future code may not so we're putting the restriction ahead.
|
||||
- 2019/12/13 (1.75) - [imgui_internal.h] changed ImRect() default constructor initializes all fields to 0.0f instead of (FLT_MAX,FLT_MAX,-FLT_MAX,-FLT_MAX). If you used ImRect::Add() to create bounding boxes by adding multiple points into it, you may need to fix your initial value.
|
||||
@ -910,7 +911,7 @@ static const float NAV_WINDOWING_LIST_APPEAR_DELAY = 0.15f; // Time
|
||||
// Window resizing from edges (when io.ConfigWindowsResizeFromEdges = true and ImGuiBackendFlags_HasMouseCursors is set in io.BackendFlags by back-end)
|
||||
static const float WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS = 4.0f; // Extend outside and inside windows. Affect FindHoveredWindow().
|
||||
static const float WINDOWS_RESIZE_FROM_EDGES_FEEDBACK_TIMER = 0.04f; // Reduce visual noise by only highlighting the border after a certain time.
|
||||
static const float WINDOWS_MOUSE_WHEEL_SCROLL_LOCK_TIMER = 2.00f; // Lock scrolled window (so it doesn't pick child windows that are scrolling through) for a certaint time, unless mouse moved.
|
||||
static const float WINDOWS_MOUSE_WHEEL_SCROLL_LOCK_TIMER = 2.00f; // Lock scrolled window (so it doesn't pick child windows that are scrolling through) for a certain time, unless mouse moved.
|
||||
|
||||
// Docking
|
||||
static const float DOCKING_TRANSPARENT_PAYLOAD_ALPHA = 0.50f; // For use with io.ConfigDockingTransparentPayload. Apply to Viewport _or_ WindowBg in host viewport.
|
||||
@ -922,13 +923,15 @@ static const float DOCKING_TRANSPARENT_PAYLOAD_ALPHA = 0.50f; // For u
|
||||
static void SetCurrentWindow(ImGuiWindow* window);
|
||||
static void SetWindowHitTestHole(ImGuiWindow* window, const ImVec2& pos, const ImVec2& size);
|
||||
static void FindHoveredWindow();
|
||||
static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFlags flags);
|
||||
static ImGuiWindow* CreateNewWindow(const char* name, ImGuiWindowFlags flags);
|
||||
static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window, bool snap_on_edges);
|
||||
|
||||
static void AddDrawListToDrawData(ImVector<ImDrawList*>* out_list, ImDrawList* draw_list);
|
||||
static void AddWindowToSortBuffer(ImVector<ImGuiWindow*>* out_sorted_windows, ImGuiWindow* window);
|
||||
|
||||
// Settings
|
||||
static void WindowSettingsHandler_ClearAll(ImGuiContext*, ImGuiSettingsHandler*);
|
||||
static void WindowSettingsHandler_ApplyAll(ImGuiContext*, ImGuiSettingsHandler*);
|
||||
static void* WindowSettingsHandler_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name);
|
||||
static void WindowSettingsHandler_ReadLine(ImGuiContext*, ImGuiSettingsHandler*, void* entry, const char* line);
|
||||
static void WindowSettingsHandler_WriteAll(ImGuiContext*, ImGuiSettingsHandler*, ImGuiTextBuffer* buf);
|
||||
@ -1054,6 +1057,7 @@ ImGuiStyle::ImGuiStyle()
|
||||
GrabRounding = 0.0f; // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
|
||||
TabRounding = 4.0f; // Radius of upper corners of a tab. Set to 0.0f to have rectangular tabs.
|
||||
TabBorderSize = 0.0f; // Thickness of border around tabs.
|
||||
TabMinWidthForUnselectedCloseButton = 0.0f; // Minimum width for close button to appears on an unselected tab when hovered. Set to 0.0f to always show when hovering, set to FLT_MAX to never show close button unless selected.
|
||||
ColorButtonPosition = ImGuiDir_Right; // Side of the color button in the ColorEdit4 widget (left/right). Defaults to ImGuiDir_Right.
|
||||
ButtonTextAlign = ImVec2(0.5f,0.5f);// Alignment of button text when button is larger than text.
|
||||
SelectableTextAlign = ImVec2(0.0f,0.0f);// Alignment of selectable text. Defaults to (0.0f, 0.0f) (top-left aligned). It's generally important to keep this left-aligned if you want to lay multiple items on a same line.
|
||||
@ -1090,6 +1094,8 @@ void ImGuiStyle::ScaleAllSizes(float scale_factor)
|
||||
GrabMinSize = ImFloor(GrabMinSize * scale_factor);
|
||||
GrabRounding = ImFloor(GrabRounding * scale_factor);
|
||||
TabRounding = ImFloor(TabRounding * scale_factor);
|
||||
if (TabMinWidthForUnselectedCloseButton != FLT_MAX)
|
||||
TabMinWidthForUnselectedCloseButton = ImFloor(TabMinWidthForUnselectedCloseButton * scale_factor);
|
||||
DisplayWindowPadding = ImFloor(DisplayWindowPadding * scale_factor);
|
||||
DisplaySafeAreaPadding = ImFloor(DisplaySafeAreaPadding * scale_factor);
|
||||
MouseCursorScale = ImFloor(MouseCursorScale * scale_factor);
|
||||
@ -4126,6 +4132,8 @@ void ImGui::Initialize(ImGuiContext* context)
|
||||
ImGuiSettingsHandler ini_handler;
|
||||
ini_handler.TypeName = "Window";
|
||||
ini_handler.TypeHash = ImHashStr("Window");
|
||||
ini_handler.ClearAllFn = WindowSettingsHandler_ClearAll;
|
||||
ini_handler.ApplyAllFn = WindowSettingsHandler_ApplyAll;
|
||||
ini_handler.ReadOpenFn = WindowSettingsHandler_ReadOpen;
|
||||
ini_handler.ReadLineFn = WindowSettingsHandler_ReadLine;
|
||||
ini_handler.WriteAllFn = WindowSettingsHandler_WriteAll;
|
||||
@ -4494,7 +4502,7 @@ void ImGui::EndFrame()
|
||||
}
|
||||
|
||||
// Drag and Drop: Fallback for source tooltip. This is not ideal but better than nothing.
|
||||
if (g.DragDropActive && g.DragDropSourceFrameCount < g.FrameCount)
|
||||
if (g.DragDropActive && g.DragDropSourceFrameCount < g.FrameCount && !(g.DragDropSourceFlags & ImGuiDragDropFlags_SourceNoPreviewTooltip))
|
||||
{
|
||||
g.DragDropWithinSource = true;
|
||||
SetTooltip("...");
|
||||
@ -4512,7 +4520,7 @@ void ImGui::EndFrame()
|
||||
UpdateViewportsEndFrame();
|
||||
|
||||
// Sort the window list so that all child windows are after their parent
|
||||
// We cannot do that on FocusWindow() because childs may not exist yet
|
||||
// We cannot do that on FocusWindow() because children may not exist yet
|
||||
g.WindowsTempSortBuffer.resize(0);
|
||||
g.WindowsTempSortBuffer.reserve(g.Windows.Size);
|
||||
for (int i = 0; i != g.Windows.Size; i++)
|
||||
@ -4631,7 +4639,7 @@ ImVec2 ImGui::CalcTextSize(const char* text, const char* text_end, bool hide_tex
|
||||
}
|
||||
|
||||
// Find window given position, search front-to-back
|
||||
// FIXME: Note that we have an inconsequential lag here: OuterRectClipped is updated in Begin(), so windows moved programatically
|
||||
// FIXME: Note that we have an inconsequential lag here: OuterRectClipped is updated in Begin(), so windows moved programmatically
|
||||
// with SetWindowPos() and not SetNextWindowPos() will have that rectangle lagging by a frame at the time FindHoveredWindow() is
|
||||
// called, aka before the next Begin(). Moving window isn't affected.
|
||||
static void FindHoveredWindow()
|
||||
@ -5196,7 +5204,24 @@ ImGuiWindow* ImGui::FindWindowByName(const char* name)
|
||||
return FindWindowByID(id);
|
||||
}
|
||||
|
||||
static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFlags flags)
|
||||
static void ApplyWindowSettings(ImGuiWindow* window, ImGuiWindowSettings* settings)
|
||||
{
|
||||
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||
window->ViewportPos = main_viewport->Pos;
|
||||
if (settings->ViewportId)
|
||||
{
|
||||
window->ViewportId = settings->ViewportId;
|
||||
window->ViewportPos = ImVec2(settings->ViewportPos.x, settings->ViewportPos.y);
|
||||
}
|
||||
window->Pos = ImFloor(ImVec2(settings->Pos.x + window->ViewportPos.x, settings->Pos.y + window->ViewportPos.y));
|
||||
if (settings->Size.x > 0 && settings->Size.y > 0)
|
||||
window->Size = window->SizeFull = ImFloor(ImVec2(settings->Size.x, settings->Size.y));
|
||||
window->Collapsed = settings->Collapsed;
|
||||
window->DockId = settings->DockId;
|
||||
window->DockOrder = settings->DockOrder;
|
||||
}
|
||||
|
||||
static ImGuiWindow* CreateNewWindow(const char* name, ImGuiWindowFlags flags)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
//IMGUI_DEBUG_LOG("CreateNewWindow '%s', flags = 0x%08X\n", name, flags);
|
||||
@ -5209,6 +5234,7 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFl
|
||||
// Default/arbitrary window position. Use SetNextWindowPos() with the appropriate condition flag to change the initial position of a window.
|
||||
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
||||
window->Pos = main_viewport->Pos + ImVec2(60, 60);
|
||||
window->ViewportPos = main_viewport->Pos;
|
||||
|
||||
// User can disable loading and saving of settings. Tooltip and child windows also don't store settings.
|
||||
if (!(flags & ImGuiWindowFlags_NoSavedSettings))
|
||||
@ -5217,23 +5243,8 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFl
|
||||
// Retrieve settings from .ini file
|
||||
window->SettingsOffset = g.SettingsWindows.offset_from_ptr(settings);
|
||||
SetWindowConditionAllowFlags(window, ImGuiCond_FirstUseEver, false);
|
||||
if (settings->ViewportId)
|
||||
{
|
||||
window->ViewportId = settings->ViewportId;
|
||||
window->ViewportPos = ImVec2(settings->ViewportPos.x, settings->ViewportPos.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
window->ViewportPos = main_viewport->Pos;
|
||||
}
|
||||
window->Pos = ImVec2(settings->Pos.x + window->ViewportPos.x, settings->Pos.y + window->ViewportPos.y);
|
||||
window->Collapsed = settings->Collapsed;
|
||||
if (settings->Size.x > 0 && settings->Size.y > 0)
|
||||
size = ImVec2(settings->Size.x, settings->Size.y);
|
||||
window->DockId = settings->DockId;
|
||||
window->DockOrder = settings->DockOrder;
|
||||
ApplyWindowSettings(window, settings);
|
||||
}
|
||||
window->Size = window->SizeFull = ImFloor(size);
|
||||
window->DC.CursorStartPos = window->DC.CursorMaxPos = window->Pos; // So first call to CalcContentSize() doesn't return crazy values
|
||||
|
||||
if ((flags & ImGuiWindowFlags_AlwaysAutoResize) != 0)
|
||||
@ -5857,10 +5868,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
ImGuiWindow* window = FindWindowByName(name);
|
||||
const bool window_just_created = (window == NULL);
|
||||
if (window_just_created)
|
||||
{
|
||||
ImVec2 size_on_first_use = (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSize) ? g.NextWindowData.SizeVal : ImVec2(0.0f, 0.0f); // Any condition flag will do since we are creating a new window here.
|
||||
window = CreateNewWindow(name, size_on_first_use, flags);
|
||||
}
|
||||
window = CreateNewWindow(name, flags);
|
||||
|
||||
// Automatically disable manual moving/resizing when NoInputs is set
|
||||
if ((flags & ImGuiWindowFlags_NoInputs) == ImGuiWindowFlags_NoInputs)
|
||||
@ -7011,7 +7019,7 @@ bool ImGui::IsWindowDocked()
|
||||
}
|
||||
|
||||
// Can we focus this window with CTRL+TAB (or PadMenu + PadFocusPrev/PadFocusNext)
|
||||
// Note that NoNavFocus makes the window not reachable with CTRL+TAB but it can still be focused with mouse or programmaticaly.
|
||||
// Note that NoNavFocus makes the window not reachable with CTRL+TAB but it can still be focused with mouse or programmatically.
|
||||
// If you want a window to never be focused, you may use the e.g. NoInputs flag.
|
||||
bool ImGui::IsWindowNavFocusable(ImGuiWindow* window)
|
||||
{
|
||||
@ -7302,6 +7310,7 @@ ImVec2 ImGui::GetFontTexUvWhitePixel()
|
||||
|
||||
void ImGui::SetWindowFontScale(float scale)
|
||||
{
|
||||
IM_ASSERT(scale > 0.0f);
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
window->FontWindowScale = scale;
|
||||
@ -7552,7 +7561,8 @@ static void ImGui::ErrorCheckEndFrameSanityChecks()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
||||
// Verify that io.KeyXXX fields haven't been tampered with. Key mods shoudl not be modified between NewFrame() and EndFrame()
|
||||
// Verify that io.KeyXXX fields haven't been tampered with. Key mods should not be modified between NewFrame() and EndFrame()
|
||||
// One possible reason leading to this assert is that your back-ends update inputs _AFTER_ NewFrame().
|
||||
const ImGuiKeyModFlags expected_key_mod_flags = GetMergedKeyModFlags();
|
||||
IM_ASSERT(g.IO.KeyMods == expected_key_mod_flags && "Mismatching io.KeyCtrl/io.KeyShift/io.KeyAlt/io.KeySuper vs io.KeyMods");
|
||||
IM_UNUSED(expected_key_mod_flags);
|
||||
@ -8553,7 +8563,7 @@ void ImGui::EndPopup()
|
||||
// Make all menus and popups wrap around for now, may need to expose that policy.
|
||||
NavMoveRequestTryWrapping(window, ImGuiNavMoveFlags_LoopY);
|
||||
|
||||
// Child-popups don't need to be layed out
|
||||
// Child-popups don't need to be laid out
|
||||
IM_ASSERT(g.WithinEndChild == false);
|
||||
if (window->Flags & ImGuiWindowFlags_ChildWindow)
|
||||
g.WithinEndChild = true;
|
||||
@ -10368,6 +10378,19 @@ void ImGui::LogButtons()
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] SETTINGS
|
||||
//-----------------------------------------------------------------------------
|
||||
// - UpdateSettings() [Internal]
|
||||
// - MarkIniSettingsDirty() [Internal]
|
||||
// - CreateNewWindowSettings() [Internal]
|
||||
// - FindWindowSettings() [Internal]
|
||||
// - FindOrCreateWindowSettings() [Internal]
|
||||
// - FindSettingsHandler() [Internal]
|
||||
// - ClearIniSettings() [Internal]
|
||||
// - LoadIniSettingsFromDisk()
|
||||
// - LoadIniSettingsFromMemory()
|
||||
// - SaveIniSettingsToDisk()
|
||||
// - SaveIniSettingsToMemory()
|
||||
// - WindowSettingsHandler_***() [Internal]
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Called by NewFrame()
|
||||
void ImGui::UpdateSettings()
|
||||
@ -10450,16 +10473,6 @@ ImGuiWindowSettings* ImGui::FindOrCreateWindowSettings(const char* name)
|
||||
return CreateNewWindowSettings(name);
|
||||
}
|
||||
|
||||
void ImGui::LoadIniSettingsFromDisk(const char* ini_filename)
|
||||
{
|
||||
size_t file_data_size = 0;
|
||||
char* file_data = (char*)ImFileLoadToMemory(ini_filename, "rb", &file_data_size);
|
||||
if (!file_data)
|
||||
return;
|
||||
LoadIniSettingsFromMemory(file_data, (size_t)file_data_size);
|
||||
IM_FREE(file_data);
|
||||
}
|
||||
|
||||
ImGuiSettingsHandler* ImGui::FindSettingsHandler(const char* type_name)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
@ -10470,21 +10483,48 @@ ImGuiSettingsHandler* ImGui::FindSettingsHandler(const char* type_name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void ImGui::ClearIniSettings()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
g.SettingsIniData.clear();
|
||||
for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++)
|
||||
if (g.SettingsHandlers[handler_n].ClearAllFn)
|
||||
g.SettingsHandlers[handler_n].ClearAllFn(&g, &g.SettingsHandlers[handler_n]);
|
||||
}
|
||||
|
||||
void ImGui::LoadIniSettingsFromDisk(const char* ini_filename)
|
||||
{
|
||||
size_t file_data_size = 0;
|
||||
char* file_data = (char*)ImFileLoadToMemory(ini_filename, "rb", &file_data_size);
|
||||
if (!file_data)
|
||||
return;
|
||||
LoadIniSettingsFromMemory(file_data, (size_t)file_data_size);
|
||||
IM_FREE(file_data);
|
||||
}
|
||||
|
||||
// Zero-tolerance, no error reporting, cheap .ini parsing
|
||||
void ImGui::LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(g.Initialized);
|
||||
IM_ASSERT(g.SettingsLoaded == false && g.FrameCount == 0);
|
||||
//IM_ASSERT(!g.WithinFrameScope && "Cannot be called between NewFrame() and EndFrame()");
|
||||
//IM_ASSERT(g.SettingsLoaded == false && g.FrameCount == 0);
|
||||
|
||||
// For user convenience, we allow passing a non zero-terminated string (hence the ini_size parameter).
|
||||
// For our convenience and to make the code simpler, we'll also write zero-terminators within the buffer. So let's create a writable copy..
|
||||
if (ini_size == 0)
|
||||
ini_size = strlen(ini_data);
|
||||
char* buf = (char*)IM_ALLOC(ini_size + 1);
|
||||
char* buf_end = buf + ini_size;
|
||||
g.SettingsIniData.Buf.resize((int)ini_size + 1);
|
||||
char* const buf = g.SettingsIniData.Buf.Data;
|
||||
char* const buf_end = buf + ini_size;
|
||||
memcpy(buf, ini_data, ini_size);
|
||||
buf[ini_size] = 0;
|
||||
buf_end[0] = 0;
|
||||
|
||||
// Call pre-read handlers
|
||||
// Some types will clear their data (e.g. dock information) some types will allow merge/override (window)
|
||||
for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++)
|
||||
if (g.SettingsHandlers[handler_n].ReadInitFn)
|
||||
g.SettingsHandlers[handler_n].ReadInitFn(&g, &g.SettingsHandlers[handler_n]);
|
||||
|
||||
void* entry_data = NULL;
|
||||
ImGuiSettingsHandler* entry_handler = NULL;
|
||||
@ -10522,9 +10562,15 @@ void ImGui::LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size)
|
||||
entry_handler->ReadLineFn(&g, entry_handler, entry_data, line);
|
||||
}
|
||||
}
|
||||
IM_FREE(buf);
|
||||
g.SettingsLoaded = true;
|
||||
DockContextOnLoadSettings(&g);
|
||||
|
||||
// [DEBUG] Restore untouched copy so it can be browsed in Metrics (not strictly necessary)
|
||||
memcpy(buf, ini_data, ini_size);
|
||||
|
||||
// Call post-read handlers
|
||||
for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++)
|
||||
if (g.SettingsHandlers[handler_n].ApplyAllFn)
|
||||
g.SettingsHandlers[handler_n].ApplyAllFn(&g, &g.SettingsHandlers[handler_n]);
|
||||
}
|
||||
|
||||
void ImGui::SaveIniSettingsToDisk(const char* ini_filename)
|
||||
@ -10560,11 +10606,34 @@ const char* ImGui::SaveIniSettingsToMemory(size_t* out_size)
|
||||
return g.SettingsIniData.c_str();
|
||||
}
|
||||
|
||||
static void WindowSettingsHandler_ClearAll(ImGuiContext* ctx, ImGuiSettingsHandler*)
|
||||
{
|
||||
ImGuiContext& g = *ctx;
|
||||
for (int i = 0; i != g.Windows.Size; i++)
|
||||
g.Windows[i]->SettingsOffset = -1;
|
||||
g.SettingsWindows.clear();
|
||||
}
|
||||
|
||||
// Apply to existing windows (if any)
|
||||
static void WindowSettingsHandler_ApplyAll(ImGuiContext* ctx, ImGuiSettingsHandler*)
|
||||
{
|
||||
ImGuiContext& g = *ctx;
|
||||
for (ImGuiWindowSettings* settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings))
|
||||
if (settings->WantApply)
|
||||
{
|
||||
if (ImGuiWindow* window = ImGui::FindWindowByID(settings->ID))
|
||||
ApplyWindowSettings(window, settings);
|
||||
settings->WantApply = false;
|
||||
}
|
||||
}
|
||||
|
||||
static void* WindowSettingsHandler_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name)
|
||||
{
|
||||
ImGuiWindowSettings* settings = ImGui::FindWindowSettings(ImHashStr(name));
|
||||
if (!settings)
|
||||
settings = ImGui::CreateNewWindowSettings(name);
|
||||
ImGuiWindowSettings* settings = ImGui::FindOrCreateWindowSettings(name);
|
||||
ImGuiID id = settings->ID;
|
||||
*settings = ImGuiWindowSettings();
|
||||
settings->ID = id;
|
||||
settings->WantApply = true;
|
||||
return (void*)settings;
|
||||
}
|
||||
|
||||
@ -11620,6 +11689,8 @@ namespace ImGui
|
||||
static void DockSettingsRenameNodeReferences(ImGuiID old_node_id, ImGuiID new_node_id);
|
||||
static void DockSettingsRemoveNodeReferences(ImGuiID* node_ids, int node_ids_count);
|
||||
static ImGuiDockNodeSettings* DockSettingsFindNodeSettings(ImGuiContext* ctx, ImGuiID node_id);
|
||||
static void DockSettingsHandler_ClearAll(ImGuiContext*, ImGuiSettingsHandler*);
|
||||
static void DockSettingsHandler_ApplyAll(ImGuiContext*, ImGuiSettingsHandler*);
|
||||
static void* DockSettingsHandler_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name);
|
||||
static void DockSettingsHandler_ReadLine(ImGuiContext*, ImGuiSettingsHandler*, void* entry, const char* line);
|
||||
static void DockSettingsHandler_WriteAll(ImGuiContext* imgui_ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* buf);
|
||||
@ -11637,7 +11708,6 @@ namespace ImGui
|
||||
//-----------------------------------------------------------------------------
|
||||
// - DockContextInitialize()
|
||||
// - DockContextShutdown()
|
||||
// - DockContextOnLoadSettings()
|
||||
// - DockContextClearNodes()
|
||||
// - DockContextRebuildNodes()
|
||||
// - DockContextUpdateUndocking()
|
||||
@ -11663,8 +11733,11 @@ void ImGui::DockContextInitialize(ImGuiContext* ctx)
|
||||
ImGuiSettingsHandler ini_handler;
|
||||
ini_handler.TypeName = "Docking";
|
||||
ini_handler.TypeHash = ImHashStr("Docking");
|
||||
ini_handler.ClearAllFn = DockSettingsHandler_ClearAll;
|
||||
ini_handler.ReadInitFn = DockSettingsHandler_ClearAll; // Also clear on read
|
||||
ini_handler.ReadOpenFn = DockSettingsHandler_ReadOpen;
|
||||
ini_handler.ReadLineFn = DockSettingsHandler_ReadLine;
|
||||
ini_handler.ApplyAllFn = DockSettingsHandler_ApplyAll;
|
||||
ini_handler.WriteAllFn = DockSettingsHandler_WriteAll;
|
||||
g.SettingsHandlers.push_back(ini_handler);
|
||||
}
|
||||
@ -11680,13 +11753,6 @@ void ImGui::DockContextShutdown(ImGuiContext* ctx)
|
||||
g.DockContext = NULL;
|
||||
}
|
||||
|
||||
void ImGui::DockContextOnLoadSettings(ImGuiContext* ctx)
|
||||
{
|
||||
ImGuiDockContext* dc = ctx->DockContext;
|
||||
DockContextPruneUnusedSettingsNodes(ctx);
|
||||
DockContextBuildNodesFromSettings(ctx, dc->SettingsNodes.Data, dc->SettingsNodes.Size);
|
||||
}
|
||||
|
||||
void ImGui::DockContextClearNodes(ImGuiContext* ctx, ImGuiID root_id, bool clear_persistent_docking_references)
|
||||
{
|
||||
IM_UNUSED(ctx);
|
||||
@ -11695,7 +11761,8 @@ void ImGui::DockContextClearNodes(ImGuiContext* ctx, ImGuiID root_id, bool clear
|
||||
DockBuilderRemoveNodeChildNodes(root_id);
|
||||
}
|
||||
|
||||
// This function also acts as a defacto test to make sure we can rebuild from scratch without a glitch
|
||||
// [DEBUG] This function also acts as a defacto test to make sure we can rebuild from scratch without a glitch
|
||||
// (Different from DockSettingsHandler_ClearAll() + DockSettingsHandler_ApplyAll() because this reuses current settings!)
|
||||
void ImGui::DockContextRebuildNodes(ImGuiContext* ctx)
|
||||
{
|
||||
IMGUI_DEBUG_LOG_DOCKING("DockContextRebuild()\n");
|
||||
@ -13529,7 +13596,7 @@ static void ImGui::DockNodePreviewDockRender(ImGuiWindow* host_window, ImGuiDock
|
||||
if (!tab_bar_rect.Contains(tab_bb))
|
||||
overlay_draw_lists[overlay_n]->PushClipRect(tab_bar_rect.Min, tab_bar_rect.Max);
|
||||
TabItemBackground(overlay_draw_lists[overlay_n], tab_bb, tab_flags, overlay_col_tabs);
|
||||
TabItemLabelAndCloseButton(overlay_draw_lists[overlay_n], tab_bb, tab_flags, g.Style.FramePadding, payload->Name, 0, 0);
|
||||
TabItemLabelAndCloseButton(overlay_draw_lists[overlay_n], tab_bb, tab_flags, g.Style.FramePadding, payload->Name, 0, 0, false);
|
||||
if (!tab_bar_rect.Contains(tab_bb))
|
||||
overlay_draw_lists[overlay_n]->PopClipRect();
|
||||
}
|
||||
@ -14188,6 +14255,7 @@ void ImGui::DockBuilderRemoveNode(ImGuiID node_id)
|
||||
DockContextRemoveNode(ctx, node, true);
|
||||
}
|
||||
|
||||
// root_id = 0 to remove all, root_id != 0 to remove child of given node.
|
||||
void ImGui::DockBuilderRemoveNodeChildNodes(ImGuiID root_id)
|
||||
{
|
||||
ImGuiContext* ctx = GImGui;
|
||||
@ -14758,6 +14826,7 @@ void ImGui::BeginDockableDragDropTarget(ImGuiWindow* window)
|
||||
// - DockSettingsRenameNodeReferences()
|
||||
// - DockSettingsRemoveNodeReferences()
|
||||
// - DockSettingsFindNodeSettings()
|
||||
// - DockSettingsHandler_ApplyAll()
|
||||
// - DockSettingsHandler_ReadOpen()
|
||||
// - DockSettingsHandler_ReadLine()
|
||||
// - DockSettingsHandler_DockNodeToSettings()
|
||||
@ -14808,6 +14877,25 @@ static ImGuiDockNodeSettings* ImGui::DockSettingsFindNodeSettings(ImGuiContext*
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Clear settings data
|
||||
static void ImGui::DockSettingsHandler_ClearAll(ImGuiContext* ctx, ImGuiSettingsHandler*)
|
||||
{
|
||||
ImGuiDockContext* dc = ctx->DockContext;
|
||||
dc->SettingsNodes.clear();
|
||||
DockContextClearNodes(ctx, 0, true);
|
||||
}
|
||||
|
||||
// Recreate dones based on settings data
|
||||
static void ImGui::DockSettingsHandler_ApplyAll(ImGuiContext* ctx, ImGuiSettingsHandler*)
|
||||
{
|
||||
// Prune settings at boot time only
|
||||
ImGuiDockContext* dc = ctx->DockContext;
|
||||
if (ctx->Windows.Size == 0)
|
||||
DockContextPruneUnusedSettingsNodes(ctx);
|
||||
DockContextBuildNodesFromSettings(ctx, dc->SettingsNodes.Data, dc->SettingsNodes.Size);
|
||||
DockContextBuildAddWindowsToNodes(ctx, 0);
|
||||
}
|
||||
|
||||
static void* ImGui::DockSettingsHandler_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name)
|
||||
{
|
||||
if (strcmp(name, "Data") != 0)
|
||||
@ -15422,6 +15510,12 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
static void NodeWindowSettings(ImGuiWindowSettings* settings)
|
||||
{
|
||||
ImGui::Text("0x%08X \"%s\" Pos (%d,%d) Size (%d,%d) Collapsed=%d",
|
||||
settings->ID, settings->GetName(), settings->Pos.x, settings->Pos.y, settings->Size.x, settings->Size.y, settings->Collapsed);
|
||||
}
|
||||
|
||||
static void NodeViewport(ImGuiViewportP* viewport)
|
||||
{
|
||||
ImGui::SetNextItemOpen(true, ImGuiCond_Once);
|
||||
@ -15621,40 +15715,68 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
|
||||
// Details for Docking
|
||||
#ifdef IMGUI_HAS_DOCK
|
||||
if (ImGui::TreeNode("Docking"))
|
||||
if (ImGui::TreeNode("Dock nodes"))
|
||||
{
|
||||
ImGuiDockContext* dc = g.DockContext;
|
||||
ImGui::Checkbox("Ctrl shows window dock info", &show_docking_nodes);
|
||||
if (ImGui::SmallButton("Clear nodes")) { DockContextClearNodes(&g, 0, true); }
|
||||
ImGui::SameLine();
|
||||
if (ImGui::SmallButton("Rebuild all")) { dc->WantFullRebuild = true; }
|
||||
for (int n = 0; n < dc->Nodes.Data.Size; n++)
|
||||
if (ImGuiDockNode* node = (ImGuiDockNode*)dc->Nodes.Data[n].val_p)
|
||||
if (node->IsRootNode())
|
||||
Funcs::NodeDockNode(node, "Node");
|
||||
ImGui::TreePop();
|
||||
}
|
||||
#endif // #define IMGUI_HAS_DOCK
|
||||
|
||||
if (ImGui::TreeNode("Dock nodes"))
|
||||
// Settings
|
||||
if (ImGui::TreeNode("Settings"))
|
||||
{
|
||||
if (ImGui::SmallButton("Clear"))
|
||||
ImGui::ClearIniSettings();
|
||||
ImGui::SameLine();
|
||||
if (ImGui::SmallButton("Save to memory"))
|
||||
ImGui::SaveIniSettingsToMemory();
|
||||
ImGui::SameLine();
|
||||
if (ImGui::SmallButton("Save to disk"))
|
||||
ImGui::SaveIniSettingsToDisk(g.IO.IniFilename);
|
||||
ImGui::SameLine();
|
||||
if (g.IO.IniFilename)
|
||||
ImGui::Text("\"%s\"", g.IO.IniFilename);
|
||||
else
|
||||
ImGui::TextUnformatted("<NULL>");
|
||||
ImGui::Text("SettingsDirtyTimer %.2f", g.SettingsDirtyTimer);
|
||||
if (ImGui::TreeNode("SettingsHandlers", "Settings handlers: (%d)", g.SettingsHandlers.Size))
|
||||
{
|
||||
if (ImGui::SmallButton("Clear settings")) { DockContextClearNodes(&g, 0, true); }
|
||||
ImGui::SameLine();
|
||||
if (ImGui::SmallButton("Rebuild all")) { dc->WantFullRebuild = true; }
|
||||
for (int n = 0; n < dc->Nodes.Data.Size; n++)
|
||||
if (ImGuiDockNode* node = (ImGuiDockNode*)dc->Nodes.Data[n].val_p)
|
||||
if (node->IsRootNode())
|
||||
Funcs::NodeDockNode(node, "Node");
|
||||
for (int n = 0; n < g.SettingsHandlers.Size; n++)
|
||||
ImGui::BulletText("%s", g.SettingsHandlers[n].TypeName);
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
if (ImGui::TreeNode("Settings"))
|
||||
if (ImGui::TreeNode("SettingsWindows", "Settings packed data: Windows: %d bytes", g.SettingsWindows.size()))
|
||||
{
|
||||
if (ImGui::SmallButton("Refresh"))
|
||||
SaveIniSettingsToMemory();
|
||||
ImGui::SameLine();
|
||||
if (ImGui::SmallButton("Save to disk"))
|
||||
SaveIniSettingsToDisk(g.IO.IniFilename);
|
||||
ImGui::Separator();
|
||||
ImGui::Text("Docked Windows:");
|
||||
for (ImGuiWindowSettings* settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings))
|
||||
Funcs::NodeWindowSettings(settings);
|
||||
ImGui::TreePop();
|
||||
}
|
||||
#ifdef IMGUI_HAS_TABLE
|
||||
if (ImGui::TreeNode("SettingsTables", "Settings packed data: Tables: %d bytes", g.SettingsTables.size()))
|
||||
{
|
||||
for (ImGuiTableSettings* settings = g.SettingsTables.begin(); settings != NULL; settings = g.SettingsTables.next_chunk(settings))
|
||||
Funcs::NodeTableSettings(settings);
|
||||
ImGui::TreePop();
|
||||
}
|
||||
#endif
|
||||
if (ImGui::TreeNode("SettingsDocking", "Settings packed data: Docking"))
|
||||
{
|
||||
ImGui::Text("In SettingsWindows:");
|
||||
for (ImGuiWindowSettings* settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings))
|
||||
if (settings->DockId != 0)
|
||||
ImGui::BulletText("Window '%s' -> DockId %08X", settings->GetName(), settings->DockId);
|
||||
ImGui::Separator();
|
||||
ImGui::Text("Dock Nodes:");
|
||||
for (int n = 0; n < dc->SettingsNodes.Size; n++)
|
||||
ImGui::Text("In SettingsNodes:");
|
||||
for (int n = 0; n < g.DockContext->SettingsNodes.Size; n++)
|
||||
{
|
||||
ImGuiDockNodeSettings* settings = &dc->SettingsNodes[n];
|
||||
ImGuiDockNodeSettings* settings = &g.DockContext->SettingsNodes[n];
|
||||
const char* selected_tab_name = NULL;
|
||||
if (settings->SelectedWindowId)
|
||||
{
|
||||
@ -15667,9 +15789,14 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
}
|
||||
ImGui::TreePop();
|
||||
}
|
||||
if (ImGui::TreeNode("SettingsIniData", "Settings unpacked data (.ini): %d bytes", g.SettingsIniData.size()))
|
||||
{
|
||||
char* buf = (char*)(void*)(g.SettingsIniData.Buf.Data ? g.SettingsIniData.Buf.Data : "");
|
||||
ImGui::InputTextMultiline("##Ini", buf, g.SettingsIniData.Buf.Size, ImVec2(-FLT_MIN, 0.0f), ImGuiInputTextFlags_ReadOnly);
|
||||
ImGui::TreePop();
|
||||
}
|
||||
ImGui::TreePop();
|
||||
}
|
||||
#endif // #define IMGUI_HAS_DOCK
|
||||
|
||||
// Misc Details
|
||||
if (ImGui::TreeNode("Internal state"))
|
||||
|
@ -4,7 +4,7 @@
|
||||
// Help:
|
||||
// - Read FAQ at http://dearimgui.org/faq
|
||||
// - Newcomers, read 'Programmer guide' in imgui.cpp for notes on how to setup Dear ImGui in your codebase.
|
||||
// - Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp for demo code. All applications in examples/ are doing that.
|
||||
// - Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp. All applications in examples/ are doing that.
|
||||
// Read imgui.cpp for details, links and comments.
|
||||
|
||||
// Resources:
|
||||
@ -383,7 +383,7 @@ namespace ImGui
|
||||
// Cursor / Layout
|
||||
// - By "cursor" we mean the current output position.
|
||||
// - The typical widget behavior is to output themselves at the current cursor position, then move the cursor one line down.
|
||||
// - You can call SameLine() between widgets to undo the last carriage return and output at the right of the preceeding widget.
|
||||
// - You can call SameLine() between widgets to undo the last carriage return and output at the right of the preceding widget.
|
||||
// - Attention! We currently have inconsistencies between window-local and absolute positions we will aim to fix with future API:
|
||||
// Window-local coordinates: SameLine(), GetCursorPos(), SetCursorPos(), GetCursorStartPos(), GetContentRegionMax(), GetWindowContentRegion*(), PushTextWrapPos()
|
||||
// Absolute coordinate: GetCursorScreenPos(), SetCursorScreenPos(), all ImDrawList:: functions.
|
||||
@ -603,13 +603,16 @@ namespace ImGui
|
||||
|
||||
// Popups, Modals
|
||||
// The properties of popups windows are:
|
||||
// - They block normal mouse hovering detection outside them. (*)
|
||||
// - They block normal mouse hovering detection outside them. (*1)
|
||||
// - Unless modal, they can be closed by clicking anywhere outside them, or by pressing ESCAPE.
|
||||
// - Their visibility state (~bool) is held internally by imgui instead of being held by the programmer as we are used to with regular Begin() calls.
|
||||
// User can manipulate the visibility state by calling OpenPopup().
|
||||
// Because hovering detection is disabled outside the popup, when clicking outside the click will not be seen by underlying widgets! (*1)
|
||||
// - Their visibility state (~bool) is held internally by Dear ImGui instead of being held by the programmer as we are used to with regular Begin() calls.
|
||||
// User can manipulate the visibility state by calling OpenPopup(), CloseCurrentPopup() etc.
|
||||
// - We default to use the right mouse (ImGuiMouseButton_Right=1) for the Popup Context functions.
|
||||
// (*) You can use IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup) to bypass it and detect hovering even when normally blocked by a popup.
|
||||
// Those three properties are connected. The library needs to hold their visibility state because it can close popups at any time.
|
||||
// Those three properties are connected: we need to retain popup visibility state in the library because popups may be closed as any time.
|
||||
// (*1) You can bypass that restriction and detect hovering even when normally blocked by a popup.
|
||||
// To do this use the ImGuiHoveredFlags_AllowWhenBlockedByPopup when calling IsItemHovered() or IsWindowHovered().
|
||||
// This is what BeginPopupContextItem() and BeginPopupContextWindow() are doing already, allowing a right-click to reopen another popups without losing the click.
|
||||
IMGUI_API void OpenPopup(const char* str_id); // call to mark popup as open (don't call every frame!). popups are closed when user click outside, or if CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block. By default, Selectable()/MenuItem() are calling CloseCurrentPopup(). Popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level).
|
||||
IMGUI_API bool BeginPopup(const char* str_id, ImGuiWindowFlags flags = 0); // return true if the popup is open, and you can start outputting to it. only call EndPopup() if BeginPopup() returns true!
|
||||
IMGUI_API bool BeginPopupContextItem(const char* str_id = NULL, ImGuiMouseButton mouse_button = 1); // helper to open and begin popup when clicked on last item. if you can pass a NULL str_id only if the previous item had an id. If you want to use that on a non-interactive item such as Text() you need to pass in an explicit ID here. read comments in .cpp!
|
||||
@ -669,6 +672,7 @@ namespace ImGui
|
||||
|
||||
// Drag and Drop
|
||||
// - [BETA API] API may evolve!
|
||||
// - If you stop calling BeginDragDropSource() the payload is preserved however it won't have a preview tooltip (we currently display a fallback "..." tooltip as replacement)
|
||||
IMGUI_API bool BeginDragDropSource(ImGuiDragDropFlags flags = 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 sz, ImGuiCond cond = 0); // type is a user defined string of maximum 32 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!
|
||||
@ -1340,7 +1344,7 @@ enum ImGuiMouseCursor_
|
||||
enum ImGuiCond_
|
||||
{
|
||||
ImGuiCond_Always = 1 << 0, // Set the variable
|
||||
ImGuiCond_Once = 1 << 1, // Set the variable once per runtime session (only the first call with succeed)
|
||||
ImGuiCond_Once = 1 << 1, // Set the variable once per runtime session (only the first call will succeed)
|
||||
ImGuiCond_FirstUseEver = 1 << 2, // Set the variable if the object/window has no persistently saved data (no entry in .ini file)
|
||||
ImGuiCond_Appearing = 1 << 3 // Set the variable if the object/window is appearing after being hidden/inactive (or the first time)
|
||||
};
|
||||
@ -1464,6 +1468,7 @@ struct ImGuiStyle
|
||||
float GrabRounding; // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
|
||||
float TabRounding; // Radius of upper corners of a tab. Set to 0.0f to have rectangular tabs.
|
||||
float TabBorderSize; // Thickness of border around tabs.
|
||||
float TabMinWidthForUnselectedCloseButton; // Minimum width for close button to appears on an unselected tab when hovered. Set to 0.0f to always show when hovering, set to FLT_MAX to never show close button unless selected.
|
||||
ImGuiDir ColorButtonPosition; // Side of the color button in the ColorEdit4 widget (left/right). Defaults to ImGuiDir_Right.
|
||||
ImVec2 ButtonTextAlign; // Alignment of button text when button is larger than text. Defaults to (0.5f, 0.5f) (centered).
|
||||
ImVec2 SelectableTextAlign; // Alignment of selectable text. Defaults to (0.0f, 0.0f) (top-left aligned). It's generally important to keep this left-aligned if you want to lay multiple items on a same line.
|
||||
@ -2252,13 +2257,13 @@ struct ImFontGlyphRangesBuilder
|
||||
// See ImFontAtlas::AddCustomRectXXX functions.
|
||||
struct ImFontAtlasCustomRect
|
||||
{
|
||||
unsigned int ID; // Input // User ID. Use < 0x110000 to map into a font glyph, >= 0x110000 for other/internal/custom texture data.
|
||||
unsigned short Width, Height; // Input // Desired rectangle dimension
|
||||
unsigned short X, Y; // Output // Packed position in Atlas
|
||||
float GlyphAdvanceX; // Input // For custom font glyphs only (ID < 0x110000): glyph xadvance
|
||||
ImVec2 GlyphOffset; // Input // For custom font glyphs only (ID < 0x110000): glyph display offset
|
||||
ImFont* Font; // Input // For custom font glyphs only (ID < 0x110000): target font
|
||||
ImFontAtlasCustomRect() { ID = 0xFFFFFFFF; Width = Height = 0; X = Y = 0xFFFF; GlyphAdvanceX = 0.0f; GlyphOffset = ImVec2(0,0); Font = NULL; }
|
||||
unsigned int GlyphID; // Input // For custom font glyphs only (ID < 0x110000)
|
||||
float GlyphAdvanceX; // Input // For custom font glyphs only: glyph xadvance
|
||||
ImVec2 GlyphOffset; // Input // For custom font glyphs only: glyph display offset
|
||||
ImFont* Font; // Input // For custom font glyphs only: target font
|
||||
ImFontAtlasCustomRect() { Width = Height = 0; X = Y = 0xFFFF; GlyphID = 0; GlyphAdvanceX = 0.0f; GlyphOffset = ImVec2(0,0); Font = NULL; }
|
||||
bool IsPacked() const { return X != 0xFFFF; }
|
||||
};
|
||||
|
||||
@ -2337,8 +2342,9 @@ struct ImFontAtlas
|
||||
// You can also request your rectangles to be mapped as font glyph (given a font + Unicode point),
|
||||
// so you can render e.g. custom colorful icons and use them as regular glyphs.
|
||||
// Read docs/FONTS.txt for more details about using colorful icons.
|
||||
IMGUI_API int AddCustomRectRegular(unsigned int id, int width, int height); // Id needs to be >= 0x110000. Id >= 0x80000000 are reserved for ImGui and ImDrawList
|
||||
IMGUI_API int AddCustomRectFontGlyph(ImFont* font, ImWchar id, int width, int height, float advance_x, const ImVec2& offset = ImVec2(0,0)); // Id needs to be < 0x110000 to register a rectangle to map into a specific font.
|
||||
// Note: this API may be redesigned later in order to support multi-monitor varying DPI settings.
|
||||
IMGUI_API int AddCustomRectRegular(int width, int height);
|
||||
IMGUI_API int AddCustomRectFontGlyph(ImFont* font, ImWchar id, int width, int height, float advance_x, const ImVec2& offset = ImVec2(0,0));
|
||||
const ImFontAtlasCustomRect*GetCustomRectByIndex(int index) const { if (index < 0) return NULL; return &CustomRects[index]; }
|
||||
|
||||
// [Internal]
|
||||
@ -2399,7 +2405,7 @@ struct ImFont
|
||||
float Scale; // 4 // in // = 1.f // Base font scale, multiplied by the per-window font scale which you can adjust with SetWindowFontScale()
|
||||
float Ascent, Descent; // 4+4 // out // // Ascent: distance from top to bottom of e.g. 'A' [0..FontSize]
|
||||
int MetricsTotalSurface;// 4 // out // // Total surface in pixels to get an idea of the font rasterization/texture cost (not exact, we approximate the cost of padding between glyphs)
|
||||
ImU8 Used4kPagesMap[(IM_UNICODE_CODEPOINT_MAX+1)/4096/8]; // 2 bytes if ImWchar=ImWchar16, 34 bytes if ImWchar==ImWchar32. Store 1-bit for each block of 4K codepoints that has one active glyph. This is mainly used to facilitate iterations accross all used codepoints.
|
||||
ImU8 Used4kPagesMap[(IM_UNICODE_CODEPOINT_MAX+1)/4096/8]; // 2 bytes if ImWchar=ImWchar16, 34 bytes if ImWchar==ImWchar32. Store 1-bit for each block of 4K codepoints that has one active glyph. This is mainly used to facilitate iterations across all used codepoints.
|
||||
|
||||
// Methods
|
||||
IMGUI_API ImFont();
|
||||
|
1417
imgui/imgui_demo.cpp
1417
imgui/imgui_demo.cpp
File diff suppressed because it is too large
Load Diff
@ -36,7 +36,7 @@ Index of this file:
|
||||
|
||||
#include <stdio.h> // vsnprintf, sscanf, printf
|
||||
#if !defined(alloca)
|
||||
#if defined(__GLIBC__) || defined(__sun) || defined(__CYGWIN__) || defined(__APPLE__) || defined(__SWITCH__)
|
||||
#if defined(__GLIBC__) || defined(__sun) || defined(__APPLE__) || defined(__NEWLIB__)
|
||||
#include <alloca.h> // alloca (glibc uses <alloca.h>. Note that Cygwin may have _WIN32 defined, so the order matters here)
|
||||
#elif defined(_WIN32)
|
||||
#include <malloc.h> // alloca
|
||||
@ -621,7 +621,7 @@ void ImDrawList::PrimQuadUV(const ImVec2& a, const ImVec2& b, const ImVec2& c, c
|
||||
_IdxWritePtr += 6;
|
||||
}
|
||||
|
||||
// On AddPolyline() and AddConvexPolyFilled() we intentionally avoid using ImVec2 and superflous function calls to optimize debug/non-inlined builds.
|
||||
// On AddPolyline() and AddConvexPolyFilled() we intentionally avoid using ImVec2 and superfluous function calls to optimize debug/non-inlined builds.
|
||||
// Those macros expects l-values.
|
||||
#define IM_NORMALIZE2F_OVER_ZERO(VX,VY) do { float d2 = VX*VX + VY*VY; if (d2 > 0.0f) { float inv_len = 1.0f / ImSqrt(d2); VX *= inv_len; VY *= inv_len; } } while (0)
|
||||
#define IM_FIXNORMAL2F(VX,VY) do { float d2 = VX*VX + VY*VY; if (d2 < 0.5f) d2 = 0.5f; float inv_lensq = 1.0f / d2; VX *= inv_lensq; VY *= inv_lensq; } while (0)
|
||||
@ -690,7 +690,7 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
|
||||
dm_x *= AA_SIZE;
|
||||
dm_y *= AA_SIZE;
|
||||
|
||||
// Add temporary vertexes
|
||||
// Add temporary vertices
|
||||
ImVec2* out_vtx = &temp_points[i2*2];
|
||||
out_vtx[0].x = points[i2].x + dm_x;
|
||||
out_vtx[0].y = points[i2].y + dm_y;
|
||||
@ -707,7 +707,7 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
|
||||
idx1 = idx2;
|
||||
}
|
||||
|
||||
// Add vertexes
|
||||
// Add vertices
|
||||
for (int i = 0; i < points_count; i++)
|
||||
{
|
||||
_VtxWritePtr[0].pos = points[i]; _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col;
|
||||
@ -747,7 +747,7 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
|
||||
float dm_in_x = dm_x * half_inner_thickness;
|
||||
float dm_in_y = dm_y * half_inner_thickness;
|
||||
|
||||
// Add temporary vertexes
|
||||
// Add temporary vertices
|
||||
ImVec2* out_vtx = &temp_points[i2*4];
|
||||
out_vtx[0].x = points[i2].x + dm_out_x;
|
||||
out_vtx[0].y = points[i2].y + dm_out_y;
|
||||
@ -770,7 +770,7 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
|
||||
idx1 = idx2;
|
||||
}
|
||||
|
||||
// Add vertexes
|
||||
// Add vertices
|
||||
for (int i = 0; i < points_count; i++)
|
||||
{
|
||||
_VtxWritePtr[0].pos = temp_points[i*4+0]; _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col_trans;
|
||||
@ -1549,7 +1549,6 @@ ImFontConfig::ImFontConfig()
|
||||
// The white texels on the top left are the ones we'll use everywhere in Dear ImGui to render filled shapes.
|
||||
const int FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF = 108;
|
||||
const int FONT_ATLAS_DEFAULT_TEX_DATA_H = 27;
|
||||
const unsigned int FONT_ATLAS_DEFAULT_TEX_DATA_ID = 0x80000000;
|
||||
static const char FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS[FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF * FONT_ATLAS_DEFAULT_TEX_DATA_H + 1] =
|
||||
{
|
||||
"..- -XXXXXXX- X - X -XXXXXXX - XXXXXXX- XX "
|
||||
@ -1832,14 +1831,11 @@ ImFont* ImFontAtlas::AddFontFromMemoryCompressedBase85TTF(const char* compressed
|
||||
return font;
|
||||
}
|
||||
|
||||
int ImFontAtlas::AddCustomRectRegular(unsigned int id, int width, int height)
|
||||
int ImFontAtlas::AddCustomRectRegular(int width, int height)
|
||||
{
|
||||
// Breaking change on 2019/11/21 (1.74): ImFontAtlas::AddCustomRectRegular() now requires an ID >= 0x110000 (instead of >= 0x10000)
|
||||
IM_ASSERT(id >= 0x110000);
|
||||
IM_ASSERT(width > 0 && width <= 0xFFFF);
|
||||
IM_ASSERT(height > 0 && height <= 0xFFFF);
|
||||
ImFontAtlasCustomRect r;
|
||||
r.ID = id;
|
||||
r.Width = (unsigned short)width;
|
||||
r.Height = (unsigned short)height;
|
||||
CustomRects.push_back(r);
|
||||
@ -1848,13 +1844,16 @@ int ImFontAtlas::AddCustomRectRegular(unsigned int id, int width, int height)
|
||||
|
||||
int ImFontAtlas::AddCustomRectFontGlyph(ImFont* font, ImWchar id, int width, int height, float advance_x, const ImVec2& offset)
|
||||
{
|
||||
#ifdef IMGUI_USE_WCHAR32
|
||||
IM_ASSERT(id <= IM_UNICODE_CODEPOINT_MAX);
|
||||
#endif
|
||||
IM_ASSERT(font != NULL);
|
||||
IM_ASSERT(width > 0 && width <= 0xFFFF);
|
||||
IM_ASSERT(height > 0 && height <= 0xFFFF);
|
||||
ImFontAtlasCustomRect r;
|
||||
r.ID = id;
|
||||
r.Width = (unsigned short)width;
|
||||
r.Height = (unsigned short)height;
|
||||
r.GlyphID = id;
|
||||
r.GlyphAdvanceX = advance_x;
|
||||
r.GlyphOffset = offset;
|
||||
r.Font = font;
|
||||
@ -1879,7 +1878,6 @@ bool ImFontAtlas::GetMouseCursorTexData(ImGuiMouseCursor cursor_type, ImVec2* ou
|
||||
|
||||
IM_ASSERT(CustomRectIds[0] != -1);
|
||||
ImFontAtlasCustomRect& r = CustomRects[CustomRectIds[0]];
|
||||
IM_ASSERT(r.ID == FONT_ATLAS_DEFAULT_TEX_DATA_ID);
|
||||
ImVec2 pos = FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[cursor_type][0] + ImVec2((float)r.X, (float)r.Y);
|
||||
ImVec2 size = FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[cursor_type][1];
|
||||
*out_size = size;
|
||||
@ -2214,9 +2212,9 @@ void ImFontAtlasBuildInit(ImFontAtlas* atlas)
|
||||
if (atlas->CustomRectIds[0] >= 0)
|
||||
return;
|
||||
if (!(atlas->Flags & ImFontAtlasFlags_NoMouseCursors))
|
||||
atlas->CustomRectIds[0] = atlas->AddCustomRectRegular(FONT_ATLAS_DEFAULT_TEX_DATA_ID, FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF*2+1, FONT_ATLAS_DEFAULT_TEX_DATA_H);
|
||||
atlas->CustomRectIds[0] = atlas->AddCustomRectRegular(FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF*2+1, FONT_ATLAS_DEFAULT_TEX_DATA_H);
|
||||
else
|
||||
atlas->CustomRectIds[0] = atlas->AddCustomRectRegular(FONT_ATLAS_DEFAULT_TEX_DATA_ID, 2, 2);
|
||||
atlas->CustomRectIds[0] = atlas->AddCustomRectRegular(2, 2);
|
||||
}
|
||||
|
||||
void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, float ascent, float descent)
|
||||
@ -2265,7 +2263,6 @@ static void ImFontAtlasBuildRenderDefaultTexData(ImFontAtlas* atlas)
|
||||
IM_ASSERT(atlas->CustomRectIds[0] >= 0);
|
||||
IM_ASSERT(atlas->TexPixelsAlpha8 != NULL);
|
||||
ImFontAtlasCustomRect& r = atlas->CustomRects[atlas->CustomRectIds[0]];
|
||||
IM_ASSERT(r.ID == FONT_ATLAS_DEFAULT_TEX_DATA_ID);
|
||||
IM_ASSERT(r.IsPacked());
|
||||
|
||||
const int w = atlas->TexWidth;
|
||||
@ -2300,13 +2297,13 @@ void ImFontAtlasBuildFinish(ImFontAtlas* atlas)
|
||||
for (int i = 0; i < atlas->CustomRects.Size; i++)
|
||||
{
|
||||
const ImFontAtlasCustomRect& r = atlas->CustomRects[i];
|
||||
if (r.Font == NULL || r.ID >= 0x110000)
|
||||
if (r.Font == NULL || r.GlyphID == 0)
|
||||
continue;
|
||||
|
||||
IM_ASSERT(r.Font->ContainerAtlas == atlas);
|
||||
ImVec2 uv0, uv1;
|
||||
atlas->CalcCustomRectUV(&r, &uv0, &uv1);
|
||||
r.Font->AddGlyph((ImWchar)r.ID, r.GlyphOffset.x, r.GlyphOffset.y, r.GlyphOffset.x + r.Width, r.GlyphOffset.y + r.Height, uv0.x, uv0.y, uv1.x, uv1.y, r.GlyphAdvanceX);
|
||||
r.Font->AddGlyph((ImWchar)r.GlyphID, r.GlyphOffset.x, r.GlyphOffset.y, r.GlyphOffset.x + r.Width, r.GlyphOffset.y + r.Height, uv0.x, uv0.y, uv1.x, uv1.y, r.GlyphAdvanceX);
|
||||
}
|
||||
|
||||
// Build all fonts lookup tables
|
||||
@ -2316,7 +2313,7 @@ void ImFontAtlasBuildFinish(ImFontAtlas* atlas)
|
||||
|
||||
// Ellipsis character is required for rendering elided text. We prefer using U+2026 (horizontal ellipsis).
|
||||
// However some old fonts may contain ellipsis at U+0085. Here we auto-detect most suitable ellipsis character.
|
||||
// FIXME: Also note that 0x2026 is currently seldomly included in our font ranges. Because of this we are more likely to use three individual dots.
|
||||
// FIXME: Also note that 0x2026 is currently seldom included in our font ranges. Because of this we are more likely to use three individual dots.
|
||||
for (int i = 0; i < atlas->Fonts.size(); i++)
|
||||
{
|
||||
ImFont* font = atlas->Fonts[i];
|
||||
@ -3366,7 +3363,7 @@ void ImGui::RenderRectFilledWithHole(ImDrawList* draw_list, ImRect outer, ImRect
|
||||
|
||||
// Helper for ColorPicker4()
|
||||
// NB: This is rather brittle and will show artifact when rounding this enabled if rounded corners overlap multiple cells. Caller currently responsible for avoiding that.
|
||||
// Spent a non reasonable amount of time trying to getting this right for ColorButton with rounding+anti-aliasing+ImGuiColorEditFlags_HalfAlphaPreview flag + various grid sizes and offsets, and eventually gave up... probably more reasonable to disable rounding alltogether.
|
||||
// Spent a non reasonable amount of time trying to getting this right for ColorButton with rounding+anti-aliasing+ImGuiColorEditFlags_HalfAlphaPreview flag + various grid sizes and offsets, and eventually gave up... probably more reasonable to disable rounding altogether.
|
||||
// FIXME: uses ImGui::GetColorU32
|
||||
void ImGui::RenderColorRectWithAlphaCheckerboard(ImDrawList* draw_list, ImVec2 p_min, ImVec2 p_max, ImU32 col, float grid_step, ImVec2 grid_off, float rounding, int rounding_corners_flags)
|
||||
{
|
||||
|
@ -730,6 +730,11 @@ struct IMGUI_API ImRect
|
||||
bool IsInverted() const { return Min.x > Max.x || Min.y > Max.y; }
|
||||
};
|
||||
|
||||
struct ImGuiDataTypeTempStorage
|
||||
{
|
||||
ImU8 Data[8]; // Can fit any data up to ImGuiDataType_COUNT
|
||||
};
|
||||
|
||||
// Type information associated to one ImGuiDataType. Retrieve with DataTypeGetInfo().
|
||||
struct ImGuiDataTypeInfo
|
||||
{
|
||||
@ -839,8 +844,9 @@ struct ImGuiWindowSettings
|
||||
ImGuiID ClassId; // ID of window class if specified
|
||||
short DockOrder; // Order of the last time the window was visible within its DockNode. This is used to reorder windows that are reappearing on the same frame. Same value between windows that were active and windows that were none are possible.
|
||||
bool Collapsed;
|
||||
bool WantApply; // Set when loaded from .ini data (to enable merging/loading .ini data into an already running context)
|
||||
|
||||
ImGuiWindowSettings() { ID = 0; Pos = Size = ViewportPos = ImVec2ih(0, 0); ViewportId = DockId = ClassId = 0; DockOrder = -1; Collapsed = false; }
|
||||
ImGuiWindowSettings() { ID = 0; Pos = Size = ViewportPos = ImVec2ih(0, 0); ViewportId = DockId = ClassId = 0; DockOrder = -1; Collapsed = WantApply = false; }
|
||||
char* GetName() { return (char*)(this + 1); }
|
||||
};
|
||||
|
||||
@ -848,8 +854,11 @@ struct ImGuiSettingsHandler
|
||||
{
|
||||
const char* TypeName; // Short description stored in .ini file. Disallowed characters: '[' ']'
|
||||
ImGuiID TypeHash; // == ImHashStr(TypeName)
|
||||
void (*ClearAllFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler); // Clear all settings data
|
||||
void (*ReadInitFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler); // Read: Called before reading (in registration order)
|
||||
void* (*ReadOpenFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, const char* name); // Read: Called when entering into a new ini entry e.g. "[Window][Name]"
|
||||
void (*ReadLineFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, void* entry, const char* line); // Read: Called for every line of text within an ini entry
|
||||
void (*ApplyAllFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler); // Read: Called after reading (in registration order)
|
||||
void (*WriteAllFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* out_buf); // Write: Output every entries into 'out_buf'
|
||||
void* UserData;
|
||||
|
||||
@ -1924,6 +1933,7 @@ namespace ImGui
|
||||
// Settings
|
||||
IMGUI_API void MarkIniSettingsDirty();
|
||||
IMGUI_API void MarkIniSettingsDirty(ImGuiWindow* window);
|
||||
IMGUI_API void ClearIniSettings();
|
||||
IMGUI_API ImGuiWindowSettings* CreateNewWindowSettings(const char* name);
|
||||
IMGUI_API ImGuiWindowSettings* FindWindowSettings(ImGuiID id);
|
||||
IMGUI_API ImGuiWindowSettings* FindOrCreateWindowSettings(const char* name);
|
||||
@ -2049,7 +2059,7 @@ namespace ImGui
|
||||
IMGUI_API ImGuiID DockBuilderAddNode(ImGuiID node_id = 0, ImGuiDockNodeFlags flags = 0);
|
||||
IMGUI_API void DockBuilderRemoveNode(ImGuiID node_id); // Remove node and all its child, undock all windows
|
||||
IMGUI_API void DockBuilderRemoveNodeDockedWindows(ImGuiID node_id, bool clear_persistent_docking_references = true);
|
||||
IMGUI_API void DockBuilderRemoveNodeChildNodes(ImGuiID node_id); // Remove all split/hierarchy. All remaining docked windows will be re-docked to the root.
|
||||
IMGUI_API void DockBuilderRemoveNodeChildNodes(ImGuiID node_id); // Remove all split/hierarchy. All remaining docked windows will be re-docked to the remaining root node (node_id).
|
||||
IMGUI_API void DockBuilderSetNodePos(ImGuiID node_id, ImVec2 pos);
|
||||
IMGUI_API void DockBuilderSetNodeSize(ImGuiID node_id, ImVec2 size);
|
||||
IMGUI_API ImGuiID DockBuilderSplitNode(ImGuiID node_id, ImGuiDir split_dir, float size_ratio_for_node_at_dir, ImGuiID* out_id_at_dir, ImGuiID* out_id_at_opposite_dir); // Create 2 child nodes in this parent node.
|
||||
@ -2085,7 +2095,7 @@ namespace ImGui
|
||||
IMGUI_API bool TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open, ImGuiTabItemFlags flags, ImGuiWindow* docked_window);
|
||||
IMGUI_API ImVec2 TabItemCalcSize(const char* label, bool has_close_button);
|
||||
IMGUI_API void TabItemBackground(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImU32 col);
|
||||
IMGUI_API bool TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImVec2 frame_padding, const char* label, ImGuiID tab_id, ImGuiID close_button_id);
|
||||
IMGUI_API bool TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImVec2 frame_padding, const char* label, ImGuiID tab_id, ImGuiID close_button_id, bool is_contents_visible);
|
||||
|
||||
// Render helpers
|
||||
// AVOID USING OUTSIDE OF IMGUI.CPP! NOT FOR PUBLIC CONSUMPTION. THOSE FUNCTIONS ARE A MESS. THEIR SIGNATURE AND BEHAVIOR WILL CHANGE, THEY NEED TO BE REFACTORED INTO SOMETHING DECENT.
|
||||
@ -2153,11 +2163,12 @@ namespace ImGui
|
||||
IMGUI_API int DataTypeFormatString(char* buf, int buf_size, ImGuiDataType data_type, const void* p_data, const char* format);
|
||||
IMGUI_API void DataTypeApplyOp(ImGuiDataType data_type, int op, void* output, void* arg_1, const void* arg_2);
|
||||
IMGUI_API bool DataTypeApplyOpFromText(const char* buf, const char* initial_value_buf, ImGuiDataType data_type, void* p_data, const char* format);
|
||||
IMGUI_API bool DataTypeClamp(ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max);
|
||||
|
||||
// InputText
|
||||
IMGUI_API bool InputTextEx(const char* label, const char* hint, char* buf, int buf_size, const ImVec2& size_arg, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback = NULL, void* user_data = NULL);
|
||||
IMGUI_API bool TempInputText(const ImRect& bb, ImGuiID id, const char* label, char* buf, int buf_size, ImGuiInputTextFlags flags);
|
||||
IMGUI_API bool TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImGuiDataType data_type, void* p_data, const char* format);
|
||||
IMGUI_API bool TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImGuiDataType data_type, void* p_data, const char* format, const void* p_clamp_min = NULL, const void* p_clamp_max = NULL);
|
||||
inline bool TempInputIsActive(ImGuiID id) { ImGuiContext& g = *GImGui; return (g.ActiveId == id && g.TempInputId == id); }
|
||||
inline ImGuiInputTextState* GetInputTextState(ImGuiID id) { ImGuiContext& g = *GImGui; return (g.InputTextState.ID == id) ? &g.InputTextState : NULL; } // Get input text state if active
|
||||
|
||||
|
@ -1676,6 +1676,7 @@ bool ImGui::Combo(const char* label, int* current_item, const char* items_separa
|
||||
// - DataTypeFormatString()
|
||||
// - DataTypeApplyOp()
|
||||
// - DataTypeApplyOpFromText()
|
||||
// - DataTypeClamp()
|
||||
// - GetMinimumStepAtDecimalPrecision
|
||||
// - RoundScalarWithFormat<>()
|
||||
//-------------------------------------------------------------------------
|
||||
@ -1827,11 +1828,9 @@ bool ImGui::DataTypeApplyOpFromText(const char* buf, const char* initial_value_b
|
||||
return false;
|
||||
|
||||
// Copy the value in an opaque buffer so we can compare at the end of the function if it changed at all.
|
||||
IM_ASSERT(data_type < ImGuiDataType_COUNT);
|
||||
int data_backup[2];
|
||||
const ImGuiDataTypeInfo* type_info = ImGui::DataTypeGetInfo(data_type);
|
||||
IM_ASSERT(type_info->Size <= sizeof(data_backup));
|
||||
memcpy(data_backup, p_data, type_info->Size);
|
||||
const ImGuiDataTypeInfo* type_info = DataTypeGetInfo(data_type);
|
||||
ImGuiDataTypeTempStorage data_backup;
|
||||
memcpy(&data_backup, p_data, type_info->Size);
|
||||
|
||||
if (format == NULL)
|
||||
format = type_info->ScanFmt;
|
||||
@ -1903,7 +1902,35 @@ bool ImGui::DataTypeApplyOpFromText(const char* buf, const char* initial_value_b
|
||||
IM_ASSERT(0);
|
||||
}
|
||||
|
||||
return memcmp(data_backup, p_data, type_info->Size) != 0;
|
||||
return memcmp(&data_backup, p_data, type_info->Size) != 0;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static bool ClampBehaviorT(T* v, T v_min, T v_max)
|
||||
{
|
||||
if (*v < v_min) { *v = v_min; return true; }
|
||||
if (*v > v_max) { *v = v_max; return true; }
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ImGui::DataTypeClamp(ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max)
|
||||
{
|
||||
switch (data_type)
|
||||
{
|
||||
case ImGuiDataType_S8: return ClampBehaviorT<ImS8 >((ImS8* )p_data, *(const ImS8* )p_min, *(const ImS8* )p_max);
|
||||
case ImGuiDataType_U8: return ClampBehaviorT<ImU8 >((ImU8* )p_data, *(const ImU8* )p_min, *(const ImU8* )p_max);
|
||||
case ImGuiDataType_S16: return ClampBehaviorT<ImS16 >((ImS16* )p_data, *(const ImS16* )p_min, *(const ImS16* )p_max);
|
||||
case ImGuiDataType_U16: return ClampBehaviorT<ImU16 >((ImU16* )p_data, *(const ImU16* )p_min, *(const ImU16* )p_max);
|
||||
case ImGuiDataType_S32: return ClampBehaviorT<ImS32 >((ImS32* )p_data, *(const ImS32* )p_min, *(const ImS32* )p_max);
|
||||
case ImGuiDataType_U32: return ClampBehaviorT<ImU32 >((ImU32* )p_data, *(const ImU32* )p_min, *(const ImU32* )p_max);
|
||||
case ImGuiDataType_S64: return ClampBehaviorT<ImS64 >((ImS64* )p_data, *(const ImS64* )p_min, *(const ImS64* )p_max);
|
||||
case ImGuiDataType_U64: return ClampBehaviorT<ImU64 >((ImU64* )p_data, *(const ImU64* )p_min, *(const ImU64* )p_max);
|
||||
case ImGuiDataType_Float: return ClampBehaviorT<float >((float* )p_data, *(const float* )p_min, *(const float* )p_max);
|
||||
case ImGuiDataType_Double: return ClampBehaviorT<double>((double*)p_data, *(const double*)p_min, *(const double*)p_max);
|
||||
case ImGuiDataType_COUNT: break;
|
||||
}
|
||||
IM_ASSERT(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
static float GetMinimumStepAtDecimalPrecision(int decimal_precision)
|
||||
@ -2155,8 +2182,10 @@ bool ImGui::DragScalar(const char* label, ImGuiDataType data_type, void* p_data,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Our current specs do NOT clamp when using CTRL+Click manual input, but we should eventually add a flag for that..
|
||||
if (temp_input_is_active || temp_input_start)
|
||||
return TempInputScalar(frame_bb, id, label, data_type, p_data, format);
|
||||
return TempInputScalar(frame_bb, id, label, data_type, p_data, format);// , p_min, p_max);
|
||||
|
||||
// Draw frame
|
||||
const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : g.HoveredId == id ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg);
|
||||
@ -2352,7 +2381,7 @@ float ImGui::SliderCalcRatioFromValueT(ImGuiDataType data_type, TYPE v, TYPE v_m
|
||||
return (float)((FLOATTYPE)(v_clamped - v_min) / (FLOATTYPE)(v_max - v_min));
|
||||
}
|
||||
|
||||
// FIXME: Move some of the code into SliderBehavior(). Current responsability is larger than what the equivalent DragBehaviorT<> does, we also do some rendering, etc.
|
||||
// FIXME: Move some of the code into SliderBehavior(). Current responsibility is larger than what the equivalent DragBehaviorT<> does, we also do some rendering, etc.
|
||||
template<typename TYPE, typename SIGNEDTYPE, typename FLOATTYPE>
|
||||
bool ImGui::SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, TYPE* v, const TYPE v_min, const TYPE v_max, const char* format, float power, ImGuiSliderFlags flags, ImRect* out_grab_bb)
|
||||
{
|
||||
@ -2606,8 +2635,10 @@ bool ImGui::SliderScalar(const char* label, ImGuiDataType data_type, void* p_dat
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Our current specs do NOT clamp when using CTRL+Click manual input, but we should eventually add a flag for that..
|
||||
if (temp_input_is_active || temp_input_start)
|
||||
return TempInputScalar(frame_bb, id, label, data_type, p_data, format);
|
||||
return TempInputScalar(frame_bb, id, label, data_type, p_data, format);// , p_min, p_max);
|
||||
|
||||
// Draw frame
|
||||
const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : g.HoveredId == id ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg);
|
||||
@ -2906,7 +2937,21 @@ bool ImGui::TempInputText(const ImRect& bb, ImGuiID id, const char* label, char*
|
||||
return value_changed;
|
||||
}
|
||||
|
||||
bool ImGui::TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImGuiDataType data_type, void* p_data, const char* format)
|
||||
// Note that Drag/Slider functions are currently NOT forwarding the min/max values clamping values!
|
||||
// This is intended: this way we allow CTRL+Click manual input to set a value out of bounds, for maximum flexibility.
|
||||
// However this may not be ideal for all uses, as some user code may break on out of bound values.
|
||||
// In the future we should add flags to Slider/Drag to specify how to enforce min/max values with CTRL+Click.
|
||||
// See GitHub issues #1829 and #3209
|
||||
// In the meanwhile, you can easily "wrap" those functions to enforce clamping, using wrapper functions, e.g.
|
||||
// bool SliderFloatClamp(const char* label, float* v, float v_min, float v_max)
|
||||
// {
|
||||
// float v_backup = *v;
|
||||
// if (!SliderFloat(label, v, v_min, v_max))
|
||||
// return false;
|
||||
// *v = ImClamp(*v, v_min, v_max);
|
||||
// return v_backup != *v;
|
||||
// }
|
||||
bool ImGui::TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImGuiDataType data_type, void* p_data, const char* format, const void* p_clamp_min, const void* p_clamp_max)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
||||
@ -2918,10 +2963,21 @@ bool ImGui::TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImG
|
||||
|
||||
ImGuiInputTextFlags flags = ImGuiInputTextFlags_AutoSelectAll | ImGuiInputTextFlags_NoMarkEdited;
|
||||
flags |= ((data_type == ImGuiDataType_Float || data_type == ImGuiDataType_Double) ? ImGuiInputTextFlags_CharsScientific : ImGuiInputTextFlags_CharsDecimal);
|
||||
bool value_changed = TempInputText(bb, id, label, data_buf, IM_ARRAYSIZE(data_buf), flags);
|
||||
if (value_changed)
|
||||
bool value_changed = false;
|
||||
if (TempInputText(bb, id, label, data_buf, IM_ARRAYSIZE(data_buf), flags))
|
||||
{
|
||||
value_changed = DataTypeApplyOpFromText(data_buf, g.InputTextState.InitialTextA.Data, data_type, p_data, NULL);
|
||||
// Backup old value
|
||||
size_t data_type_size = DataTypeGetInfo(data_type)->Size;
|
||||
ImGuiDataTypeTempStorage data_backup;
|
||||
memcpy(&data_backup, p_data, data_type_size);
|
||||
|
||||
// Apply new value (or operations) then clamp
|
||||
DataTypeApplyOpFromText(data_buf, g.InputTextState.InitialTextA.Data, data_type, p_data, NULL);
|
||||
if (p_clamp_min && p_clamp_max)
|
||||
DataTypeClamp(data_type, p_data, p_clamp_min, p_clamp_max);
|
||||
|
||||
// Only mark as edited if new value is different
|
||||
value_changed = memcmp(&data_type, p_data, data_type_size) != 0;
|
||||
if (value_changed)
|
||||
MarkItemEdited(id);
|
||||
}
|
||||
@ -2949,7 +3005,7 @@ bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* p_data
|
||||
if ((flags & (ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsScientific)) == 0)
|
||||
flags |= ImGuiInputTextFlags_CharsDecimal;
|
||||
flags |= ImGuiInputTextFlags_AutoSelectAll;
|
||||
flags |= ImGuiInputTextFlags_NoMarkEdited; // We call MarkItemEdited() ourselve by comparing the actual data rather than the string.
|
||||
flags |= ImGuiInputTextFlags_NoMarkEdited; // We call MarkItemEdited() ourselves by comparing the actual data rather than the string.
|
||||
|
||||
if (p_step != NULL)
|
||||
{
|
||||
@ -3367,7 +3423,7 @@ void ImGuiInputTextCallbackData::InsertChars(int pos, const char* new_text, cons
|
||||
if (!is_resizable)
|
||||
return;
|
||||
|
||||
// Contrary to STB_TEXTEDIT_INSERTCHARS() this is working in the UTF8 buffer, hence the midly similar code (until we remove the U16 buffer alltogether!)
|
||||
// Contrary to STB_TEXTEDIT_INSERTCHARS() this is working in the UTF8 buffer, hence the mildly similar code (until we remove the U16 buffer altogether!)
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiInputTextState* edit_state = &g.InputTextState;
|
||||
IM_ASSERT(edit_state->ID != 0 && g.ActiveId == edit_state->ID);
|
||||
@ -3474,6 +3530,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
||||
if (window->SkipItems)
|
||||
return false;
|
||||
|
||||
IM_ASSERT(buf != NULL && buf_size >= 0);
|
||||
IM_ASSERT(!((flags & ImGuiInputTextFlags_CallbackHistory) && (flags & ImGuiInputTextFlags_Multiline))); // Can't use both together (they both use up/down keys)
|
||||
IM_ASSERT(!((flags & ImGuiInputTextFlags_CallbackCompletion) && (flags & ImGuiInputTextFlags_AllowTabInput))); // Can't use both together (they both use tab key)
|
||||
|
||||
@ -4755,7 +4812,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
||||
if (flags & ImGuiColorEditFlags_DisplayRGB || (flags & ImGuiColorEditFlags__DisplayMask) == 0)
|
||||
if (ColorEdit4("##rgb", col, sub_flags | ImGuiColorEditFlags_DisplayRGB))
|
||||
{
|
||||
// FIXME: Hackily differenciating using the DragInt (ActiveId != 0 && !ActiveIdAllowOverlap) vs. using the InputText or DropTarget.
|
||||
// FIXME: Hackily differentiating using the DragInt (ActiveId != 0 && !ActiveIdAllowOverlap) vs. using the InputText or DropTarget.
|
||||
// For the later we don't want to run the hue-wrap canceling code. If you are well versed in HSV picker please provide your input! (See #2050)
|
||||
value_changed_fix_hue_wrap = (g.ActiveId != 0 && !g.ActiveIdAllowOverlap);
|
||||
value_changed = true;
|
||||
@ -6280,7 +6337,7 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
|
||||
g.NavWindow = window; // Odd hack to allow hovering across menus of a same menu-set (otherwise we wouldn't be able to hover parent)
|
||||
|
||||
// The reference position stored in popup_pos will be used by Begin() to find a suitable position for the child menu,
|
||||
// However the final position is going to be different! It is choosen by FindBestWindowPosForPopup().
|
||||
// However the final position is going to be different! It is chosen by FindBestWindowPosForPopup().
|
||||
// e.g. Menus tend to overlap each other horizontally to amplify relative Z-ordering.
|
||||
ImVec2 popup_pos, pos = window->DC.CursorPos;
|
||||
if (window->DC.LayoutType == ImGuiLayoutType_Horizontal)
|
||||
@ -7175,6 +7232,7 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
|
||||
tab_bar->NextSelectedTabId = id;
|
||||
|
||||
// Lock visibility
|
||||
// (Note: tab_contents_visible != tab_selected... because CTRL+TAB operations may preview some tabs without selecting them!)
|
||||
bool tab_contents_visible = (tab_bar->VisibleTabId == id);
|
||||
if (tab_contents_visible)
|
||||
tab_bar->VisibleTabWasSubmitted = true;
|
||||
@ -7323,7 +7381,7 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
|
||||
|
||||
// Render tab label, process close button
|
||||
const ImGuiID close_button_id = p_open ? window->GetID((void*)((intptr_t)id + 1)) : 0;
|
||||
bool just_closed = TabItemLabelAndCloseButton(display_draw_list, bb, flags, tab_bar->FramePadding, label, id, close_button_id);
|
||||
bool just_closed = TabItemLabelAndCloseButton(display_draw_list, bb, flags, tab_bar->FramePadding, label, id, close_button_id, tab_contents_visible);
|
||||
if (just_closed && p_open != NULL)
|
||||
{
|
||||
*p_open = false;
|
||||
@ -7408,13 +7466,21 @@ void ImGui::TabItemBackground(ImDrawList* draw_list, const ImRect& bb, ImGuiTabI
|
||||
|
||||
// Render text label (with custom clipping) + Unsaved Document marker + Close Button logic
|
||||
// We tend to lock style.FramePadding for a given tab-bar, hence the 'frame_padding' parameter.
|
||||
bool ImGui::TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImVec2 frame_padding, const char* label, ImGuiID tab_id, ImGuiID close_button_id)
|
||||
bool ImGui::TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImVec2 frame_padding, const char* label, ImGuiID tab_id, ImGuiID close_button_id, bool is_contents_visible)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImVec2 label_size = CalcTextSize(label, NULL, true);
|
||||
if (bb.GetWidth() <= 1.0f)
|
||||
return false;
|
||||
|
||||
// In Style V2 we'll have full override of all colors per state (e.g. focused, selected)
|
||||
// But right now if you want to alter text color of tabs this is what you need to do.
|
||||
#if 0
|
||||
const float backup_alpha = g.Style.Alpha;
|
||||
if (!is_contents_visible)
|
||||
g.Style.Alpha *= 0.7f;
|
||||
#endif
|
||||
|
||||
// Render text label (with clipping + alpha gradient) + unsaved marker
|
||||
const char* TAB_UNSAVED_MARKER = "*";
|
||||
ImRect text_pixel_clip_bb(bb.Min.x + frame_padding.x, bb.Min.y + frame_padding.y, bb.Max.x - frame_padding.x, bb.Max.y);
|
||||
@ -7434,8 +7500,9 @@ bool ImGui::TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb,
|
||||
bool close_button_pressed = false;
|
||||
bool close_button_visible = false;
|
||||
if (close_button_id != 0)
|
||||
if (g.HoveredId == tab_id || g.HoveredId == close_button_id || g.ActiveId == close_button_id)
|
||||
close_button_visible = true;
|
||||
if (is_contents_visible || bb.GetWidth() >= g.Style.TabMinWidthForUnselectedCloseButton)
|
||||
if (g.HoveredId == tab_id || g.HoveredId == close_button_id || g.ActiveId == close_button_id)
|
||||
close_button_visible = true;
|
||||
if (close_button_visible)
|
||||
{
|
||||
ImGuiItemHoveredDataBackup last_item_backup;
|
||||
@ -7456,6 +7523,11 @@ bool ImGui::TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb,
|
||||
float ellipsis_max_x = close_button_visible ? text_pixel_clip_bb.Max.x : bb.Max.x - 1.0f;
|
||||
RenderTextEllipsis(draw_list, text_ellipsis_clip_bb.Min, text_ellipsis_clip_bb.Max, text_pixel_clip_bb.Max.x, ellipsis_max_x, label, NULL, &label_size);
|
||||
|
||||
#if 0
|
||||
if (!is_contents_visible)
|
||||
g.Style.Alpha = backup_alpha;
|
||||
#endif
|
||||
|
||||
return close_button_pressed;
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2020-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||
// 2020-04-21: OpenGL: Fixed handling of glClipControl(GL_UPPER_LEFT) by inverting projection matrix.
|
||||
// 2020-04-12: OpenGL: Fixed context version check mistakenly testing for 4.0+ instead of 3.2+ to enable ImGuiBackendFlags_RendererHasVtxOffset.
|
||||
// 2020-03-24: OpenGL: Added support for glbinding 2.x OpenGL loader.
|
||||
// 2020-01-07: OpenGL: Added support for glbinding 3.x OpenGL loader.
|
||||
@ -122,12 +123,16 @@
|
||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
|
||||
#include <glad/glad.h> // Needs to be initialized with gladLoadGL() in user's code.
|
||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2)
|
||||
#ifndef GLFW_INCLUDE_NONE
|
||||
#define GLFW_INCLUDE_NONE // GLFW including OpenGL headers causes ambiguity or multiple definition errors.
|
||||
#endif
|
||||
#include <glbinding/Binding.h> // Needs to be initialized with glbinding::Binding::initialize() in user's code.
|
||||
#include <glbinding/gl/gl.h>
|
||||
using namespace gl;
|
||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING3)
|
||||
#ifndef GLFW_INCLUDE_NONE
|
||||
#define GLFW_INCLUDE_NONE // GLFW including OpenGL headers causes ambiguity or multiple definition errors.
|
||||
#endif
|
||||
#include <glbinding/glbinding.h>// Needs to be initialized with glbinding::initialize() in user's code.
|
||||
#include <glbinding/gl/gl.h>
|
||||
using namespace gl;
|
||||
@ -254,6 +259,14 @@ static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, int fb_wid
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
#endif
|
||||
|
||||
// Support for GL 4.5 rarely used glClipControl(GL_UPPER_LEFT)
|
||||
bool clip_origin_lower_left = true;
|
||||
#if defined(GL_CLIP_ORIGIN) && !defined(__APPLE__)
|
||||
GLenum current_clip_origin = 0; glGetIntegerv(GL_CLIP_ORIGIN, (GLint*)¤t_clip_origin);
|
||||
if (current_clip_origin == GL_UPPER_LEFT)
|
||||
clip_origin_lower_left = false;
|
||||
#endif
|
||||
|
||||
// Setup viewport, orthographic projection matrix
|
||||
// Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps.
|
||||
glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
|
||||
@ -261,6 +274,7 @@ static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, int fb_wid
|
||||
float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x;
|
||||
float T = draw_data->DisplayPos.y;
|
||||
float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y;
|
||||
if (!clip_origin_lower_left) { float tmp = T; T = B; B = tmp; } // Swap top and bottom if origin is upper left
|
||||
const float ortho_projection[4][4] =
|
||||
{
|
||||
{ 2.0f/(R-L), 0.0f, 0.0f, 0.0f },
|
||||
@ -329,12 +343,6 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
||||
GLboolean last_enable_cull_face = glIsEnabled(GL_CULL_FACE);
|
||||
GLboolean last_enable_depth_test = glIsEnabled(GL_DEPTH_TEST);
|
||||
GLboolean last_enable_scissor_test = glIsEnabled(GL_SCISSOR_TEST);
|
||||
bool clip_origin_lower_left = true;
|
||||
#if defined(GL_CLIP_ORIGIN) && !defined(__APPLE__)
|
||||
GLenum last_clip_origin = 0; glGetIntegerv(GL_CLIP_ORIGIN, (GLint*)&last_clip_origin); // Support for GL 4.5's glClipControl(GL_UPPER_LEFT)
|
||||
if (last_clip_origin == GL_UPPER_LEFT)
|
||||
clip_origin_lower_left = false;
|
||||
#endif
|
||||
|
||||
// Setup desired GL state
|
||||
// Recreate the VAO every time (this is to easily allow multiple GL contexts to be rendered to. VAO are not shared among GL contexts)
|
||||
@ -382,10 +390,7 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
||||
if (clip_rect.x < fb_width && clip_rect.y < fb_height && clip_rect.z >= 0.0f && clip_rect.w >= 0.0f)
|
||||
{
|
||||
// Apply scissor/clipping rectangle
|
||||
if (clip_origin_lower_left)
|
||||
glScissor((int)clip_rect.x, (int)(fb_height - clip_rect.w), (int)(clip_rect.z - clip_rect.x), (int)(clip_rect.w - clip_rect.y));
|
||||
else
|
||||
glScissor((int)clip_rect.x, (int)clip_rect.y, (int)clip_rect.z, (int)clip_rect.w); // Support for GL 4.5 rarely used glClipControl(GL_UPPER_LEFT)
|
||||
glScissor((int)clip_rect.x, (int)(fb_height - clip_rect.w), (int)(clip_rect.z - clip_rect.x), (int)(clip_rect.w - clip_rect.y));
|
||||
|
||||
// Bind texture, Draw
|
||||
glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
|
||||
|
Loading…
Reference in New Issue
Block a user