mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-23 16:16:36 +00:00
Merge branch 'master' into docking
# Conflicts: # docs/CHANGELOG.txt # imgui.cpp
This commit is contained in:
commit
b8d8355f10
@ -99,7 +99,22 @@ Other changes:
|
|||||||
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
VERSION 1.72 (In Progress)
|
VERSION 1.72b (Released 2019-07-31)
|
||||||
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Other Changes:
|
||||||
|
|
||||||
|
- Nav, Scrolling: Fixed programmatic scroll leading to a slightly incorrect scroll offset when
|
||||||
|
the window has decorations or a menu-bar (broken in 1.71). This was mostly noticeable when
|
||||||
|
a keyboard/gamepad movement led to scrolling the view, or using e.g. SetScrollHereY() function.
|
||||||
|
- Nav: Made hovering non-MenuItem Selectable not re-assign the source item for keyboard navigation.
|
||||||
|
- Nav: Fixed an issue with NavFlattened window flag (beta) where widgets not entirely fitting
|
||||||
|
in child window (often selectables because of their protruding sides) would be not considered
|
||||||
|
as entry points to to navigate toward the child window. (#787)
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------
|
||||||
|
VERSION 1.72 (Released 2019-07-27)
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
Breaking Changes:
|
Breaking Changes:
|
||||||
@ -114,7 +129,6 @@ Breaking Changes:
|
|||||||
Kept redirection function (will obsolete). (#581, #324)
|
Kept redirection function (will obsolete). (#581, #324)
|
||||||
|
|
||||||
Other Changes:
|
Other Changes:
|
||||||
comments about the right way to scale your UI (load a font at the right side, rebuild atlas, scale style).
|
|
||||||
- Scrolling: Made mouse-wheel scrolling lock the underlying window until the mouse is moved again or
|
- Scrolling: Made mouse-wheel scrolling lock the underlying window until the mouse is moved again or
|
||||||
until a short delay expires (~2 seconds). This allow uninterrupted scroll even if child windows are
|
until a short delay expires (~2 seconds). This allow uninterrupted scroll even if child windows are
|
||||||
passing under the mouse cursor. (#2604)
|
passing under the mouse cursor. (#2604)
|
||||||
@ -131,6 +145,7 @@ Other Changes:
|
|||||||
any more. Forwarding can still be disabled by setting ImGuiWindowFlags_NoInputs. (amend #1502, #1380).
|
any more. Forwarding can still be disabled by setting ImGuiWindowFlags_NoInputs. (amend #1502, #1380).
|
||||||
- Window: Fixed InnerClipRect right-most coordinates using wrong padding setting (introduced in 1.71).
|
- Window: Fixed InnerClipRect right-most coordinates using wrong padding setting (introduced in 1.71).
|
||||||
- Window: Fixed old SetWindowFontScale() api value from not being inherited by child window. Added
|
- Window: Fixed old SetWindowFontScale() api value from not being inherited by child window. Added
|
||||||
|
comments about the right way to scale your UI (load a font at the right side, rebuild atlas, scale style).
|
||||||
- Scrollbar: Avoid overlapping the opposite side when window (often a child window) is forcibly too small.
|
- Scrollbar: Avoid overlapping the opposite side when window (often a child window) is forcibly too small.
|
||||||
- Combo: Hide arrow when there's not enough space even for the square button.
|
- Combo: Hide arrow when there's not enough space even for the square button.
|
||||||
- InputText: Testing for newly added ImGuiKey_KeyPadEnter key. (#2677, #2005) [@amc522]
|
- InputText: Testing for newly added ImGuiKey_KeyPadEnter key. (#2677, #2005) [@amc522]
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
dear imgui, v1.72
|
dear imgui, v1.72b
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
examples/README.txt
|
examples/README.txt
|
||||||
(This is the README file for the examples/ folder. See docs/ for more documentation)
|
(This is the README file for the examples/ folder. See docs/ for more documentation)
|
||||||
|
346
imgui.cpp
346
imgui.cpp
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.72
|
// dear imgui, v1.72b
|
||||||
// (main code and documentation)
|
// (main code and documentation)
|
||||||
|
|
||||||
// Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp for demo code.
|
// Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp for demo code.
|
||||||
@ -72,6 +72,7 @@ CODE
|
|||||||
// [SECTION] ImGuiListClipper
|
// [SECTION] ImGuiListClipper
|
||||||
// [SECTION] RENDER HELPERS
|
// [SECTION] RENDER HELPERS
|
||||||
// [SECTION] MAIN CODE (most of the code! lots of stuff, needs tidying up!)
|
// [SECTION] MAIN CODE (most of the code! lots of stuff, needs tidying up!)
|
||||||
|
// [SECTION] SCROLLING
|
||||||
// [SECTION] TOOLTIPS
|
// [SECTION] TOOLTIPS
|
||||||
// [SECTION] POPUPS
|
// [SECTION] POPUPS
|
||||||
// [SECTION] KEYBOARD/GAMEPAD NAVIGATION
|
// [SECTION] KEYBOARD/GAMEPAD NAVIGATION
|
||||||
@ -3234,13 +3235,15 @@ void ImGui::MemFree(void* ptr)
|
|||||||
|
|
||||||
const char* ImGui::GetClipboardText()
|
const char* ImGui::GetClipboardText()
|
||||||
{
|
{
|
||||||
return GImGui->IO.GetClipboardTextFn ? GImGui->IO.GetClipboardTextFn(GImGui->IO.ClipboardUserData) : "";
|
ImGuiContext& g = *GImGui;
|
||||||
|
return g.IO.GetClipboardTextFn ? g.IO.GetClipboardTextFn(g.IO.ClipboardUserData) : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::SetClipboardText(const char* text)
|
void ImGui::SetClipboardText(const char* text)
|
||||||
{
|
{
|
||||||
if (GImGui->IO.SetClipboardTextFn)
|
ImGuiContext& g = *GImGui;
|
||||||
GImGui->IO.SetClipboardTextFn(GImGui->IO.ClipboardUserData, text);
|
if (g.IO.SetClipboardTextFn)
|
||||||
|
g.IO.SetClipboardTextFn(g.IO.ClipboardUserData, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* ImGui::GetVersion()
|
const char* ImGui::GetVersion()
|
||||||
@ -4677,15 +4680,18 @@ bool ImGui::IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool c
|
|||||||
int ImGui::GetKeyIndex(ImGuiKey imgui_key)
|
int ImGui::GetKeyIndex(ImGuiKey imgui_key)
|
||||||
{
|
{
|
||||||
IM_ASSERT(imgui_key >= 0 && imgui_key < ImGuiKey_COUNT);
|
IM_ASSERT(imgui_key >= 0 && imgui_key < ImGuiKey_COUNT);
|
||||||
return GImGui->IO.KeyMap[imgui_key];
|
ImGuiContext& g = *GImGui;
|
||||||
|
return g.IO.KeyMap[imgui_key];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note that imgui doesn't know the semantic of each entry of io.KeysDown[]. Use your own indices/enums according to how your back-end/engine stored them into io.KeysDown[]!
|
// Note that imgui doesn't know the semantic of each entry of io.KeysDown[]. Use your own indices/enums according to how your back-end/engine stored them into io.KeysDown[]!
|
||||||
bool ImGui::IsKeyDown(int user_key_index)
|
bool ImGui::IsKeyDown(int user_key_index)
|
||||||
{
|
{
|
||||||
if (user_key_index < 0) return false;
|
if (user_key_index < 0)
|
||||||
IM_ASSERT(user_key_index >= 0 && user_key_index < IM_ARRAYSIZE(GImGui->IO.KeysDown));
|
return false;
|
||||||
return GImGui->IO.KeysDown[user_key_index];
|
ImGuiContext& g = *GImGui;
|
||||||
|
IM_ASSERT(user_key_index >= 0 && user_key_index < IM_ARRAYSIZE(g.IO.KeysDown));
|
||||||
|
return g.IO.KeysDown[user_key_index];
|
||||||
}
|
}
|
||||||
|
|
||||||
int ImGui::CalcTypematicPressedRepeatAmount(float t, float t_prev, float repeat_delay, float repeat_rate)
|
int ImGui::CalcTypematicPressedRepeatAmount(float t, float t_prev, float repeat_delay, float repeat_rate)
|
||||||
@ -5315,40 +5321,6 @@ ImVec2 ImGui::CalcWindowExpectedSize(ImGuiWindow* window)
|
|||||||
return CalcSizeAfterConstraint(window, CalcSizeAutoFit(window, size_contents));
|
return CalcSizeAfterConstraint(window, CalcSizeAutoFit(window, size_contents));
|
||||||
}
|
}
|
||||||
|
|
||||||
static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window, bool snap_on_edges)
|
|
||||||
{
|
|
||||||
ImGuiContext& g = *GImGui;
|
|
||||||
ImVec2 scroll = window->Scroll;
|
|
||||||
if (window->ScrollTarget.x < FLT_MAX)
|
|
||||||
{
|
|
||||||
float cr_x = window->ScrollTargetCenterRatio.x;
|
|
||||||
float target_x = window->ScrollTarget.x;
|
|
||||||
if (snap_on_edges && cr_x <= 0.0f && target_x <= window->WindowPadding.x)
|
|
||||||
target_x = 0.0f;
|
|
||||||
else if (snap_on_edges && cr_x >= 1.0f && target_x >= window->ContentSize.x + window->WindowPadding.x + GImGui->Style.ItemSpacing.x)
|
|
||||||
target_x = window->ContentSize.x + window->WindowPadding.x * 2.0f;
|
|
||||||
scroll.x = target_x - cr_x * window->InnerRect.GetWidth();
|
|
||||||
}
|
|
||||||
if (window->ScrollTarget.y < FLT_MAX)
|
|
||||||
{
|
|
||||||
// 'snap_on_edges' allows for a discontinuity at the edge of scrolling limits to take account of WindowPadding so that scrolling to make the last item visible scroll far enough to see the padding.
|
|
||||||
float cr_y = window->ScrollTargetCenterRatio.y;
|
|
||||||
float target_y = window->ScrollTarget.y;
|
|
||||||
if (snap_on_edges && cr_y <= 0.0f && target_y <= window->WindowPadding.y)
|
|
||||||
target_y = 0.0f;
|
|
||||||
if (snap_on_edges && cr_y >= 1.0f && target_y >= window->ContentSize.y + window->WindowPadding.y + g.Style.ItemSpacing.y)
|
|
||||||
target_y = window->ContentSize.y + window->WindowPadding.y * 2.0f;
|
|
||||||
scroll.y = target_y - cr_y * window->InnerRect.GetHeight();
|
|
||||||
}
|
|
||||||
scroll = ImMax(scroll, ImVec2(0.0f, 0.0f));
|
|
||||||
if (!window->Collapsed && !window->SkipItems)
|
|
||||||
{
|
|
||||||
scroll.x = ImMin(scroll.x, window->ScrollMax.x);
|
|
||||||
scroll.y = ImMin(scroll.y, window->ScrollMax.y);
|
|
||||||
}
|
|
||||||
return scroll;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ImGuiCol GetWindowBgColorIdxFromFlags(ImGuiWindowFlags flags)
|
static ImGuiCol GetWindowBgColorIdxFromFlags(ImGuiWindowFlags flags)
|
||||||
{
|
{
|
||||||
if (flags & (ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_Popup))
|
if (flags & (ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_Popup))
|
||||||
@ -6285,7 +6257,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
// Inner rectangle
|
// Inner rectangle
|
||||||
// Not affected by window border size. Used by:
|
// Not affected by window border size. Used by:
|
||||||
// - InnerClipRect
|
// - InnerClipRect
|
||||||
// - NavScrollToBringItemIntoView()
|
// - ScrollToBringRectIntoView()
|
||||||
// - NavUpdatePageUpPageDown()
|
// - NavUpdatePageUpPageDown()
|
||||||
// - Scrollbar()
|
// - Scrollbar()
|
||||||
window->InnerRect.Min.x = window->Pos.x;
|
window->InnerRect.Min.x = window->Pos.x;
|
||||||
@ -6781,7 +6753,7 @@ void ImGui::PushMultiItemsWidths(int components, float w_full)
|
|||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
ImGuiWindow* window = g.CurrentWindow;
|
ImGuiWindow* window = g.CurrentWindow;
|
||||||
const ImGuiStyle& style = GImGui->Style;
|
const ImGuiStyle& style = g.Style;
|
||||||
const float w_item_one = ImMax(1.0f, (float)(int)((w_full - (style.ItemInnerSpacing.x) * (components-1)) / (float)components));
|
const float w_item_one = ImMax(1.0f, (float)(int)((w_full - (style.ItemInnerSpacing.x) * (components-1)) / (float)components));
|
||||||
const float w_item_last = ImMax(1.0f, (float)(int)(w_full - (w_item_one + style.ItemInnerSpacing.x) * (components-1)));
|
const float w_item_last = ImMax(1.0f, (float)(int)(w_full - (w_item_one + style.ItemInnerSpacing.x) * (components-1)));
|
||||||
window->DC.ItemWidthStack.push_back(w_item_last);
|
window->DC.ItemWidthStack.push_back(w_item_last);
|
||||||
@ -7626,93 +7598,6 @@ void ImGui::SetCursorScreenPos(const ImVec2& pos)
|
|||||||
window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, window->DC.CursorPos);
|
window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, window->DC.CursorPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
float ImGui::GetScrollX()
|
|
||||||
{
|
|
||||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
|
||||||
return window->Scroll.x;
|
|
||||||
}
|
|
||||||
|
|
||||||
float ImGui::GetScrollY()
|
|
||||||
{
|
|
||||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
|
||||||
return window->Scroll.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
float ImGui::GetScrollMaxX()
|
|
||||||
{
|
|
||||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
|
||||||
return window->ScrollMax.x;
|
|
||||||
}
|
|
||||||
|
|
||||||
float ImGui::GetScrollMaxY()
|
|
||||||
{
|
|
||||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
|
||||||
return window->ScrollMax.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImGui::SetScrollX(float scroll_x)
|
|
||||||
{
|
|
||||||
ImGuiWindow* window = GetCurrentWindow();
|
|
||||||
window->ScrollTarget.x = scroll_x;
|
|
||||||
window->ScrollTargetCenterRatio.x = 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImGui::SetScrollY(float scroll_y)
|
|
||||||
{
|
|
||||||
ImGuiWindow* window = GetCurrentWindow();
|
|
||||||
window->ScrollTarget.y = scroll_y;
|
|
||||||
window->ScrollTargetCenterRatio.y = 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImGui::SetScrollX(ImGuiWindow* window, float new_scroll_x)
|
|
||||||
{
|
|
||||||
window->ScrollTarget.x = new_scroll_x;
|
|
||||||
window->ScrollTargetCenterRatio.x = 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImGui::SetScrollY(ImGuiWindow* window, float new_scroll_y)
|
|
||||||
{
|
|
||||||
window->ScrollTarget.y = new_scroll_y;
|
|
||||||
window->ScrollTargetCenterRatio.y = 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImGui::SetScrollFromPosX(float local_x, float center_x_ratio)
|
|
||||||
{
|
|
||||||
// We store a target position so centering can occur on the next frame when we are guaranteed to have a known window size
|
|
||||||
ImGuiWindow* window = GetCurrentWindow();
|
|
||||||
IM_ASSERT(center_x_ratio >= 0.0f && center_x_ratio <= 1.0f);
|
|
||||||
window->ScrollTarget.x = (float)(int)(local_x + window->Scroll.x);
|
|
||||||
window->ScrollTargetCenterRatio.x = center_x_ratio;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImGui::SetScrollFromPosY(float local_y, float center_y_ratio)
|
|
||||||
{
|
|
||||||
// We store a target position so centering can occur on the next frame when we are guaranteed to have a known window size
|
|
||||||
ImGuiWindow* window = GetCurrentWindow();
|
|
||||||
IM_ASSERT(center_y_ratio >= 0.0f && center_y_ratio <= 1.0f);
|
|
||||||
window->ScrollTarget.y = (float)(int)(local_y + window->Scroll.y);
|
|
||||||
window->ScrollTargetCenterRatio.y = center_y_ratio;
|
|
||||||
}
|
|
||||||
|
|
||||||
// center_x_ratio: 0.0f left of last item, 0.5f horizontal center of last item, 1.0f right of last item.
|
|
||||||
void ImGui::SetScrollHereX(float center_x_ratio)
|
|
||||||
{
|
|
||||||
ImGuiWindow* window = GetCurrentWindow();
|
|
||||||
float target_x = window->DC.LastItemRect.Min.x - window->Pos.x; // Left of last item, in window space
|
|
||||||
float last_item_width = window->DC.LastItemRect.GetWidth();
|
|
||||||
target_x += (last_item_width * center_x_ratio) + (GImGui->Style.ItemSpacing.x * (center_x_ratio - 0.5f) * 2.0f); // Precisely aim before, in the middle or after the last item.
|
|
||||||
SetScrollFromPosX(target_x, center_x_ratio);
|
|
||||||
}
|
|
||||||
|
|
||||||
// center_y_ratio: 0.0f top of last item, 0.5f vertical center of last item, 1.0f bottom of last item.
|
|
||||||
void ImGui::SetScrollHereY(float center_y_ratio)
|
|
||||||
{
|
|
||||||
ImGuiWindow* window = GetCurrentWindow();
|
|
||||||
float target_y = window->DC.CursorPosPrevLine.y - window->Pos.y; // Top of last item, in window space
|
|
||||||
target_y += (window->DC.PrevLineSize.y * center_y_ratio) + (GImGui->Style.ItemSpacing.y * (center_y_ratio - 0.5f) * 2.0f); // Precisely aim above, in the middle or below the last line.
|
|
||||||
SetScrollFromPosY(target_y, center_y_ratio);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImGui::ActivateItem(ImGuiID id)
|
void ImGui::ActivateItem(ImGuiID id)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
@ -7949,6 +7834,167 @@ void ImGui::Unindent(float indent_w)
|
|||||||
window->DC.CursorPos.x = window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x;
|
window->DC.CursorPos.x = window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// [SECTION] SCROLLING
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window, bool snap_on_edges)
|
||||||
|
{
|
||||||
|
ImGuiContext& g = *GImGui;
|
||||||
|
ImVec2 scroll = window->Scroll;
|
||||||
|
if (window->ScrollTarget.x < FLT_MAX)
|
||||||
|
{
|
||||||
|
float cr_x = window->ScrollTargetCenterRatio.x;
|
||||||
|
float target_x = window->ScrollTarget.x;
|
||||||
|
if (snap_on_edges && cr_x <= 0.0f && target_x <= window->WindowPadding.x)
|
||||||
|
target_x = 0.0f;
|
||||||
|
else if (snap_on_edges && cr_x >= 1.0f && target_x >= window->ContentSize.x + window->WindowPadding.x + g.Style.ItemSpacing.x)
|
||||||
|
target_x = window->ContentSize.x + window->WindowPadding.x * 2.0f;
|
||||||
|
scroll.x = target_x - cr_x * (window->SizeFull.x - window->ScrollbarSizes.x);
|
||||||
|
}
|
||||||
|
if (window->ScrollTarget.y < FLT_MAX)
|
||||||
|
{
|
||||||
|
// 'snap_on_edges' allows for a discontinuity at the edge of scrolling limits to take account of WindowPadding so that scrolling to make the last item visible scroll far enough to see the padding.
|
||||||
|
float decoration_up_height = window->TitleBarHeight() + window->MenuBarHeight();
|
||||||
|
float cr_y = window->ScrollTargetCenterRatio.y;
|
||||||
|
float target_y = window->ScrollTarget.y;
|
||||||
|
if (snap_on_edges && cr_y <= 0.0f && target_y <= window->WindowPadding.y)
|
||||||
|
target_y = 0.0f;
|
||||||
|
if (snap_on_edges && cr_y >= 1.0f && target_y >= window->ContentSize.y + window->WindowPadding.y + g.Style.ItemSpacing.y)
|
||||||
|
target_y = window->ContentSize.y + window->WindowPadding.y * 2.0f;
|
||||||
|
scroll.y = target_y - cr_y * (window->SizeFull.y - window->ScrollbarSizes.y - decoration_up_height);
|
||||||
|
}
|
||||||
|
scroll = ImMax(scroll, ImVec2(0.0f, 0.0f));
|
||||||
|
if (!window->Collapsed && !window->SkipItems)
|
||||||
|
{
|
||||||
|
scroll.x = ImMin(scroll.x, window->ScrollMax.x);
|
||||||
|
scroll.y = ImMin(scroll.y, window->ScrollMax.y);
|
||||||
|
}
|
||||||
|
return scroll;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scroll to keep newly navigated item fully into view
|
||||||
|
void ImGui::ScrollToBringRectIntoView(ImGuiWindow* window, const ImRect& item_rect)
|
||||||
|
{
|
||||||
|
ImRect window_rect(window->InnerRect.Min - ImVec2(1, 1), window->InnerRect.Max + ImVec2(1, 1));
|
||||||
|
//GetForegroundDrawList(window)->AddRect(window_rect.Min, window_rect.Max, IM_COL32_WHITE); // [DEBUG]
|
||||||
|
if (window_rect.Contains(item_rect))
|
||||||
|
return;
|
||||||
|
|
||||||
|
ImGuiContext& g = *GImGui;
|
||||||
|
if (window->ScrollbarX && item_rect.Min.x < window_rect.Min.x)
|
||||||
|
SetScrollFromPosX(window, item_rect.Min.x - window->Pos.x + g.Style.ItemSpacing.x, 0.0f);
|
||||||
|
else if (window->ScrollbarX && item_rect.Max.x >= window_rect.Max.x)
|
||||||
|
SetScrollFromPosX(window, item_rect.Max.x - window->Pos.x + g.Style.ItemSpacing.x, 1.0f);
|
||||||
|
if (item_rect.Min.y < window_rect.Min.y)
|
||||||
|
SetScrollFromPosY(window, item_rect.Min.y - window->Pos.y - g.Style.ItemSpacing.y, 0.0f);
|
||||||
|
else if (item_rect.Max.y >= window_rect.Max.y)
|
||||||
|
SetScrollFromPosY(window, item_rect.Max.y - window->Pos.y + g.Style.ItemSpacing.y, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
float ImGui::GetScrollX()
|
||||||
|
{
|
||||||
|
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||||
|
return window->Scroll.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
float ImGui::GetScrollY()
|
||||||
|
{
|
||||||
|
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||||
|
return window->Scroll.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
float ImGui::GetScrollMaxX()
|
||||||
|
{
|
||||||
|
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||||
|
return window->ScrollMax.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
float ImGui::GetScrollMaxY()
|
||||||
|
{
|
||||||
|
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||||
|
return window->ScrollMax.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui::SetScrollX(float scroll_x)
|
||||||
|
{
|
||||||
|
ImGuiWindow* window = GetCurrentWindow();
|
||||||
|
window->ScrollTarget.x = scroll_x;
|
||||||
|
window->ScrollTargetCenterRatio.x = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui::SetScrollY(float scroll_y)
|
||||||
|
{
|
||||||
|
ImGuiWindow* window = GetCurrentWindow();
|
||||||
|
window->ScrollTarget.y = scroll_y;
|
||||||
|
window->ScrollTargetCenterRatio.y = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui::SetScrollX(ImGuiWindow* window, float new_scroll_x)
|
||||||
|
{
|
||||||
|
window->ScrollTarget.x = new_scroll_x;
|
||||||
|
window->ScrollTargetCenterRatio.x = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui::SetScrollY(ImGuiWindow* window, float new_scroll_y)
|
||||||
|
{
|
||||||
|
window->ScrollTarget.y = new_scroll_y;
|
||||||
|
window->ScrollTargetCenterRatio.y = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ImGui::SetScrollFromPosX(ImGuiWindow* window, float local_x, float center_x_ratio)
|
||||||
|
{
|
||||||
|
// We store a target position so centering can occur on the next frame when we are guaranteed to have a known window size
|
||||||
|
IM_ASSERT(center_x_ratio >= 0.0f && center_x_ratio <= 1.0f);
|
||||||
|
window->ScrollTarget.x = (float)(int)(local_x + window->Scroll.x);
|
||||||
|
window->ScrollTargetCenterRatio.x = center_x_ratio;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui::SetScrollFromPosY(ImGuiWindow* window, float local_y, float center_y_ratio)
|
||||||
|
{
|
||||||
|
// We store a target position so centering can occur on the next frame when we are guaranteed to have a known window size
|
||||||
|
IM_ASSERT(center_y_ratio >= 0.0f && center_y_ratio <= 1.0f);
|
||||||
|
const float decoration_up_height = window->TitleBarHeight() + window->MenuBarHeight();
|
||||||
|
local_y -= decoration_up_height;
|
||||||
|
window->ScrollTarget.y = (float)(int)(local_y + window->Scroll.y);
|
||||||
|
window->ScrollTargetCenterRatio.y = center_y_ratio;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui::SetScrollFromPosX(float local_x, float center_x_ratio)
|
||||||
|
{
|
||||||
|
ImGuiContext& g = *GImGui;
|
||||||
|
SetScrollFromPosX(g.CurrentWindow, local_x, center_x_ratio);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui::SetScrollFromPosY(float local_y, float center_y_ratio)
|
||||||
|
{
|
||||||
|
ImGuiContext& g = *GImGui;
|
||||||
|
SetScrollFromPosY(g.CurrentWindow, local_y, center_y_ratio);
|
||||||
|
}
|
||||||
|
|
||||||
|
// center_x_ratio: 0.0f left of last item, 0.5f horizontal center of last item, 1.0f right of last item.
|
||||||
|
void ImGui::SetScrollHereX(float center_x_ratio)
|
||||||
|
{
|
||||||
|
ImGuiContext& g = *GImGui;
|
||||||
|
ImGuiWindow* window = g.CurrentWindow;
|
||||||
|
float target_x = window->DC.LastItemRect.Min.x - window->Pos.x; // Left of last item, in window space
|
||||||
|
float last_item_width = window->DC.LastItemRect.GetWidth();
|
||||||
|
target_x += (last_item_width * center_x_ratio) + (g.Style.ItemSpacing.x * (center_x_ratio - 0.5f) * 2.0f); // Precisely aim before, in the middle or after the last item.
|
||||||
|
SetScrollFromPosX(target_x, center_x_ratio);
|
||||||
|
}
|
||||||
|
|
||||||
|
// center_y_ratio: 0.0f top of last item, 0.5f vertical center of last item, 1.0f bottom of last item.
|
||||||
|
void ImGui::SetScrollHereY(float center_y_ratio)
|
||||||
|
{
|
||||||
|
ImGuiContext& g = *GImGui;
|
||||||
|
ImGuiWindow* window = g.CurrentWindow;
|
||||||
|
float target_y = window->DC.CursorPosPrevLine.y - window->Pos.y; // Top of last item, in window space
|
||||||
|
target_y += (window->DC.PrevLineSize.y * center_y_ratio) + (g.Style.ItemSpacing.y * (center_y_ratio - 0.5f) * 2.0f); // Precisely aim above, in the middle or below the last line.
|
||||||
|
SetScrollFromPosY(target_y, center_y_ratio);
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] TOOLTIPS
|
// [SECTION] TOOLTIPS
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -8486,7 +8532,7 @@ static bool NavScoreItem(ImGuiNavMoveResult* result, ImRect cand)
|
|||||||
if (window->ParentWindow == g.NavWindow)
|
if (window->ParentWindow == g.NavWindow)
|
||||||
{
|
{
|
||||||
IM_ASSERT((window->Flags | g.NavWindow->Flags) & ImGuiWindowFlags_NavFlattened);
|
IM_ASSERT((window->Flags | g.NavWindow->Flags) & ImGuiWindowFlags_NavFlattened);
|
||||||
if (!window->ClipRect.Contains(cand))
|
if (!window->ClipRect.Overlaps(cand))
|
||||||
return false;
|
return false;
|
||||||
cand.ClipWithFull(window->ClipRect); // This allows the scored item to not overlap other candidates in the parent window
|
cand.ClipWithFull(window->ClipRect); // This allows the scored item to not overlap other candidates in the parent window
|
||||||
}
|
}
|
||||||
@ -8859,38 +8905,6 @@ ImVec2 ImGui::GetNavInputAmount2d(ImGuiNavDirSourceFlags dir_sources, ImGuiInput
|
|||||||
return delta;
|
return delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scroll to keep newly navigated item fully into view
|
|
||||||
// NB: We modify rect_rel by the amount we scrolled for, so it is immediately updated.
|
|
||||||
static void NavScrollToBringItemIntoView(ImGuiWindow* window, const ImRect& item_rect)
|
|
||||||
{
|
|
||||||
ImRect window_rect(window->InnerRect.Min - ImVec2(1, 1), window->InnerRect.Max + ImVec2(1, 1));
|
|
||||||
//GetForegroundDrawList(window)->AddRect(window_rect.Min, window_rect.Max, IM_COL32_WHITE); // [DEBUG]
|
|
||||||
if (window_rect.Contains(item_rect))
|
|
||||||
return;
|
|
||||||
|
|
||||||
ImGuiContext& g = *GImGui;
|
|
||||||
if (window->ScrollbarX && item_rect.Min.x < window_rect.Min.x)
|
|
||||||
{
|
|
||||||
window->ScrollTarget.x = item_rect.Min.x - window->Pos.x + window->Scroll.x - g.Style.ItemSpacing.x;
|
|
||||||
window->ScrollTargetCenterRatio.x = 0.0f;
|
|
||||||
}
|
|
||||||
else if (window->ScrollbarX && item_rect.Max.x >= window_rect.Max.x)
|
|
||||||
{
|
|
||||||
window->ScrollTarget.x = item_rect.Max.x - window->Pos.x + window->Scroll.x + g.Style.ItemSpacing.x;
|
|
||||||
window->ScrollTargetCenterRatio.x = 1.0f;
|
|
||||||
}
|
|
||||||
if (item_rect.Min.y < window_rect.Min.y)
|
|
||||||
{
|
|
||||||
window->ScrollTarget.y = item_rect.Min.y - window->Pos.y + window->Scroll.y - g.Style.ItemSpacing.y;
|
|
||||||
window->ScrollTargetCenterRatio.y = 0.0f;
|
|
||||||
}
|
|
||||||
else if (item_rect.Max.y >= window_rect.Max.y)
|
|
||||||
{
|
|
||||||
window->ScrollTarget.y = item_rect.Max.y - window->Pos.y + window->Scroll.y + g.Style.ItemSpacing.y;
|
|
||||||
window->ScrollTargetCenterRatio.y = 1.0f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ImGui::NavUpdate()
|
static void ImGui::NavUpdate()
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
@ -9200,7 +9214,7 @@ static void ImGui::NavUpdateMoveResult()
|
|||||||
if (g.NavLayer == 0)
|
if (g.NavLayer == 0)
|
||||||
{
|
{
|
||||||
ImRect rect_abs = ImRect(result->RectRel.Min + result->Window->Pos, result->RectRel.Max + result->Window->Pos);
|
ImRect rect_abs = ImRect(result->RectRel.Min + result->Window->Pos, result->RectRel.Max + result->Window->Pos);
|
||||||
NavScrollToBringItemIntoView(result->Window, rect_abs);
|
ScrollToBringRectIntoView(result->Window, rect_abs);
|
||||||
|
|
||||||
// Estimate upcoming scroll so we can offset our result position so mouse position can be applied immediately after in NavUpdate()
|
// Estimate upcoming scroll so we can offset our result position so mouse position can be applied immediately after in NavUpdate()
|
||||||
ImVec2 next_scroll = CalcNextScrollFromScrollTargetAndClamp(result->Window, false);
|
ImVec2 next_scroll = CalcNextScrollFromScrollTargetAndClamp(result->Window, false);
|
||||||
@ -9209,7 +9223,7 @@ static void ImGui::NavUpdateMoveResult()
|
|||||||
|
|
||||||
// Also scroll parent window to keep us into view if necessary (we could/should technically recurse back the whole the parent hierarchy).
|
// Also scroll parent window to keep us into view if necessary (we could/should technically recurse back the whole the parent hierarchy).
|
||||||
if (result->Window->Flags & ImGuiWindowFlags_ChildWindow)
|
if (result->Window->Flags & ImGuiWindowFlags_ChildWindow)
|
||||||
NavScrollToBringItemIntoView(result->Window->ParentWindow, ImRect(rect_abs.Min + delta_scroll, rect_abs.Max + delta_scroll));
|
ScrollToBringRectIntoView(result->Window->ParentWindow, ImRect(rect_abs.Min + delta_scroll, rect_abs.Max + delta_scroll));
|
||||||
}
|
}
|
||||||
|
|
||||||
ClearActiveID();
|
ClearActiveID();
|
||||||
|
6
imgui.h
6
imgui.h
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.72
|
// dear imgui, v1.72b
|
||||||
// (headers)
|
// (headers)
|
||||||
|
|
||||||
// See imgui.cpp file for documentation.
|
// See imgui.cpp file for documentation.
|
||||||
@ -47,8 +47,8 @@ Index of this file:
|
|||||||
|
|
||||||
// Version
|
// Version
|
||||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
|
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
|
||||||
#define IMGUI_VERSION "1.72"
|
#define IMGUI_VERSION "1.72b"
|
||||||
#define IMGUI_VERSION_NUM 17200
|
#define IMGUI_VERSION_NUM 17202
|
||||||
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
|
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
|
||||||
#define IMGUI_HAS_VIEWPORT 1 // Viewport WIP branch
|
#define IMGUI_HAS_VIEWPORT 1 // Viewport WIP branch
|
||||||
#define IMGUI_HAS_DOCK 1 // Docking WIP branch
|
#define IMGUI_HAS_DOCK 1 // Docking WIP branch
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.72
|
// dear imgui, v1.72b
|
||||||
// (demo code)
|
// (demo code)
|
||||||
|
|
||||||
// Message to the person tempted to delete this file when integrating Dear ImGui into their code base:
|
// Message to the person tempted to delete this file when integrating Dear ImGui into their code base:
|
||||||
@ -2122,23 +2122,29 @@ static void ShowDemoWindowLayout()
|
|||||||
// Vertical scroll functions
|
// Vertical scroll functions
|
||||||
HelpMarker("Use SetScrollHereY() or SetScrollFromPosY() to scroll to a given vertical position.");
|
HelpMarker("Use SetScrollHereY() or SetScrollFromPosY() to scroll to a given vertical position.");
|
||||||
|
|
||||||
static bool track = true;
|
|
||||||
static int track_item = 50;
|
static int track_item = 50;
|
||||||
|
static bool enable_track = true;
|
||||||
|
static bool enable_extra_decorations = false;
|
||||||
static float scroll_to_off_px = 0.0f;
|
static float scroll_to_off_px = 0.0f;
|
||||||
static float scroll_to_pos_px = 200.0f;
|
static float scroll_to_pos_px = 200.0f;
|
||||||
ImGui::Checkbox("Track", &track);
|
|
||||||
|
ImGui::Checkbox("Decoration", &enable_extra_decorations);
|
||||||
|
ImGui::SameLine();
|
||||||
|
HelpMarker("We expose this for testing because scrolling sometimes had issues with window decoration such as menu-bars.");
|
||||||
|
|
||||||
|
ImGui::Checkbox("Track", &enable_track);
|
||||||
ImGui::PushItemWidth(100);
|
ImGui::PushItemWidth(100);
|
||||||
ImGui::SameLine(140); track |= ImGui::DragInt("##item", &track_item, 0.25f, 0, 99, "Item = %d");
|
ImGui::SameLine(140); enable_track |= ImGui::DragInt("##item", &track_item, 0.25f, 0, 99, "Item = %d");
|
||||||
|
|
||||||
bool scroll_to_off = ImGui::Button("Scroll Offset");
|
bool scroll_to_off = ImGui::Button("Scroll Offset");
|
||||||
ImGui::SameLine(140); scroll_to_off |= ImGui::DragFloat("##off", &scroll_to_off_px, 1.00f, 0, 9999, "+%.0f px");
|
ImGui::SameLine(140); scroll_to_off |= ImGui::DragFloat("##off", &scroll_to_off_px, 1.00f, 0, 9999, "+%.0f px");
|
||||||
|
|
||||||
bool scroll_to_pos = ImGui::Button("Scroll To Pos");
|
bool scroll_to_pos = ImGui::Button("Scroll To Pos");
|
||||||
ImGui::SameLine(140); scroll_to_pos |= ImGui::DragFloat("##pos", &scroll_to_pos_px, 1.00f, 0, 9999, "X/Y = %.0f px");
|
ImGui::SameLine(140); scroll_to_pos |= ImGui::DragFloat("##pos", &scroll_to_pos_px, 1.00f, -10, 9999, "X/Y = %.0f px");
|
||||||
|
|
||||||
ImGui::PopItemWidth();
|
ImGui::PopItemWidth();
|
||||||
|
|
||||||
if (scroll_to_off || scroll_to_pos)
|
if (scroll_to_off || scroll_to_pos)
|
||||||
track = false;
|
enable_track = false;
|
||||||
|
|
||||||
ImGuiStyle& style = ImGui::GetStyle();
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
float child_w = (ImGui::GetContentRegionAvail().x - 4 * style.ItemSpacing.x) / 5;
|
float child_w = (ImGui::GetContentRegionAvail().x - 4 * style.ItemSpacing.x) / 5;
|
||||||
@ -2152,14 +2158,20 @@ static void ShowDemoWindowLayout()
|
|||||||
const char* names[] = { "Top", "25%", "Center", "75%", "Bottom" };
|
const char* names[] = { "Top", "25%", "Center", "75%", "Bottom" };
|
||||||
ImGui::TextUnformatted(names[i]);
|
ImGui::TextUnformatted(names[i]);
|
||||||
|
|
||||||
ImGui::BeginChild(ImGui::GetID((void*)(intptr_t)i), ImVec2(child_w, 200.0f), true, ImGuiWindowFlags_None);
|
ImGuiWindowFlags child_flags = enable_extra_decorations ? ImGuiWindowFlags_MenuBar : 0;
|
||||||
|
ImGui::BeginChild(ImGui::GetID((void*)(intptr_t)i), ImVec2(child_w, 200.0f), true, child_flags);
|
||||||
|
if (ImGui::BeginMenuBar())
|
||||||
|
{
|
||||||
|
ImGui::TextUnformatted("abc");
|
||||||
|
ImGui::EndMenuBar();
|
||||||
|
}
|
||||||
if (scroll_to_off)
|
if (scroll_to_off)
|
||||||
ImGui::SetScrollY(scroll_to_off_px);
|
ImGui::SetScrollY(scroll_to_off_px);
|
||||||
if (scroll_to_pos)
|
if (scroll_to_pos)
|
||||||
ImGui::SetScrollFromPosY(ImGui::GetCursorStartPos().y + scroll_to_pos_px, i * 0.25f);
|
ImGui::SetScrollFromPosY(ImGui::GetCursorStartPos().y + scroll_to_pos_px, i * 0.25f);
|
||||||
for (int item = 0; item < 100; item++)
|
for (int item = 0; item < 100; item++)
|
||||||
{
|
{
|
||||||
if (track && item == track_item)
|
if (enable_track && item == track_item)
|
||||||
{
|
{
|
||||||
ImGui::TextColored(ImVec4(1,1,0,1), "Item %d", item);
|
ImGui::TextColored(ImVec4(1,1,0,1), "Item %d", item);
|
||||||
ImGui::SetScrollHereY(i * 0.25f); // 0.0f:top, 0.5f:center, 1.0f:bottom
|
ImGui::SetScrollHereY(i * 0.25f); // 0.0f:top, 0.5f:center, 1.0f:bottom
|
||||||
@ -2184,14 +2196,15 @@ static void ShowDemoWindowLayout()
|
|||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < 5; i++)
|
||||||
{
|
{
|
||||||
float child_height = ImGui::GetTextLineHeight() + style.ScrollbarSize + style.WindowPadding.y * 2.0f;
|
float child_height = ImGui::GetTextLineHeight() + style.ScrollbarSize + style.WindowPadding.y * 2.0f;
|
||||||
ImGui::BeginChild(ImGui::GetID((void*)(intptr_t)i), ImVec2(-100, child_height), true, ImGuiWindowFlags_HorizontalScrollbar);
|
ImGuiWindowFlags child_flags = ImGuiWindowFlags_HorizontalScrollbar | (enable_extra_decorations ? ImGuiWindowFlags_AlwaysVerticalScrollbar : 0);
|
||||||
|
ImGui::BeginChild(ImGui::GetID((void*)(intptr_t)i), ImVec2(-100, child_height), true, child_flags);
|
||||||
if (scroll_to_off)
|
if (scroll_to_off)
|
||||||
ImGui::SetScrollX(scroll_to_off_px);
|
ImGui::SetScrollX(scroll_to_off_px);
|
||||||
if (scroll_to_pos)
|
if (scroll_to_pos)
|
||||||
ImGui::SetScrollFromPosX(ImGui::GetCursorStartPos().x + scroll_to_pos_px, i * 0.25f);
|
ImGui::SetScrollFromPosX(ImGui::GetCursorStartPos().x + scroll_to_pos_px, i * 0.25f);
|
||||||
for (int item = 0; item < 100; item++)
|
for (int item = 0; item < 100; item++)
|
||||||
{
|
{
|
||||||
if (track && item == track_item)
|
if (enable_track && item == track_item)
|
||||||
{
|
{
|
||||||
ImGui::TextColored(ImVec4(1, 1, 0, 1), "Item %d", item);
|
ImGui::TextColored(ImVec4(1, 1, 0, 1), "Item %d", item);
|
||||||
ImGui::SetScrollHereX(i * 0.25f); // 0.0f:left, 0.5f:center, 1.0f:right
|
ImGui::SetScrollHereX(i * 0.25f); // 0.0f:left, 0.5f:center, 1.0f:right
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.72
|
// dear imgui, v1.72b
|
||||||
// (drawing and font code)
|
// (drawing and font code)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.72
|
// dear imgui, v1.72b
|
||||||
// (internal structures/api)
|
// (internal structures/api)
|
||||||
|
|
||||||
// You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility!
|
// You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility!
|
||||||
@ -374,7 +374,8 @@ enum ImGuiSelectableFlagsPrivate_
|
|||||||
ImGuiSelectableFlags_PressedOnRelease = 1 << 22,
|
ImGuiSelectableFlags_PressedOnRelease = 1 << 22,
|
||||||
ImGuiSelectableFlags_DrawFillAvailWidth = 1 << 23, // FIXME: We may be able to remove this (added in 6251d379 for menus)
|
ImGuiSelectableFlags_DrawFillAvailWidth = 1 << 23, // FIXME: We may be able to remove this (added in 6251d379 for menus)
|
||||||
ImGuiSelectableFlags_AllowItemOverlap = 1 << 24,
|
ImGuiSelectableFlags_AllowItemOverlap = 1 << 24,
|
||||||
ImGuiSelectableFlags_DrawHoveredWhenHeld= 1 << 25 // Always show active when held, even is not hovered. This concept could probably be renamed/formalized somehow.
|
ImGuiSelectableFlags_DrawHoveredWhenHeld= 1 << 25, // Always show active when held, even is not hovered. This concept could probably be renamed/formalized somehow.
|
||||||
|
ImGuiSelectableFlags_SetNavIdOnHover = 1 << 26
|
||||||
};
|
};
|
||||||
|
|
||||||
// Extend ImGuiTreeNodeFlags_
|
// Extend ImGuiTreeNodeFlags_
|
||||||
@ -650,22 +651,23 @@ struct IMGUI_API ImGuiInputTextState
|
|||||||
float CursorAnim; // timer for cursor blink, reset on every user action so the cursor reappears immediately
|
float CursorAnim; // timer for cursor blink, reset on every user action so the cursor reappears immediately
|
||||||
bool CursorFollow; // set when we want scrolling to follow the current cursor position (not always!)
|
bool CursorFollow; // set when we want scrolling to follow the current cursor position (not always!)
|
||||||
bool SelectedAllMouseLock; // after a double-click to select all, we ignore further mouse drags to update selection
|
bool SelectedAllMouseLock; // after a double-click to select all, we ignore further mouse drags to update selection
|
||||||
|
ImGuiInputTextFlags UserFlags; // Temporarily set while we call user's callback
|
||||||
// Temporarily set when active
|
ImGuiInputTextCallback UserCallback; // "
|
||||||
ImGuiInputTextFlags UserFlags;
|
void* UserCallbackData; // "
|
||||||
ImGuiInputTextCallback UserCallback;
|
|
||||||
void* UserCallbackData;
|
|
||||||
|
|
||||||
ImGuiInputTextState() { memset(this, 0, sizeof(*this)); }
|
ImGuiInputTextState() { memset(this, 0, sizeof(*this)); }
|
||||||
|
void ClearText() { CurLenW = CurLenA = 0; TextW[0] = 0; TextA[0] = 0; CursorClamp(); }
|
||||||
void ClearFreeMemory() { TextW.clear(); TextA.clear(); InitialTextA.clear(); }
|
void ClearFreeMemory() { TextW.clear(); TextA.clear(); InitialTextA.clear(); }
|
||||||
|
int GetUndoAvailCount() const { return Stb.undostate.undo_point; }
|
||||||
|
int GetRedoAvailCount() const { return STB_TEXTEDIT_UNDOSTATECOUNT - Stb.undostate.redo_point; }
|
||||||
|
void OnKeyPressed(int key); // Cannot be inline because we call in code in stb_textedit.h implementation
|
||||||
|
|
||||||
|
// Cursor & Selection
|
||||||
void CursorAnimReset() { CursorAnim = -0.30f; } // After a user-input the cursor stays on for a while without blinking
|
void CursorAnimReset() { CursorAnim = -0.30f; } // After a user-input the cursor stays on for a while without blinking
|
||||||
void CursorClamp() { Stb.cursor = ImMin(Stb.cursor, CurLenW); Stb.select_start = ImMin(Stb.select_start, CurLenW); Stb.select_end = ImMin(Stb.select_end, CurLenW); }
|
void CursorClamp() { Stb.cursor = ImMin(Stb.cursor, CurLenW); Stb.select_start = ImMin(Stb.select_start, CurLenW); Stb.select_end = ImMin(Stb.select_end, CurLenW); }
|
||||||
bool HasSelection() const { return Stb.select_start != Stb.select_end; }
|
bool HasSelection() const { return Stb.select_start != Stb.select_end; }
|
||||||
void ClearSelection() { Stb.select_start = Stb.select_end = Stb.cursor; }
|
void ClearSelection() { Stb.select_start = Stb.select_end = Stb.cursor; }
|
||||||
void SelectAll() { Stb.select_start = 0; Stb.cursor = Stb.select_end = CurLenW; Stb.has_preferred_x = 0; }
|
void SelectAll() { Stb.select_start = 0; Stb.cursor = Stb.select_end = CurLenW; Stb.has_preferred_x = 0; }
|
||||||
int GetUndoAvailCount() const { return Stb.undostate.undo_point; }
|
|
||||||
int GetRedoAvailCount() const { return STB_TEXTEDIT_UNDOSTATECOUNT - Stb.undostate.redo_point; }
|
|
||||||
void OnKeyPressed(int key); // Cannot be inline because we call in code in stb_textedit.h implementation
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Windows data saved in imgui.ini file
|
// Windows data saved in imgui.ini file
|
||||||
@ -1660,8 +1662,6 @@ namespace ImGui
|
|||||||
IMGUI_API ImVec2 CalcWindowExpectedSize(ImGuiWindow* window);
|
IMGUI_API ImVec2 CalcWindowExpectedSize(ImGuiWindow* window);
|
||||||
IMGUI_API bool IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent);
|
IMGUI_API bool IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent);
|
||||||
IMGUI_API bool IsWindowNavFocusable(ImGuiWindow* window);
|
IMGUI_API bool IsWindowNavFocusable(ImGuiWindow* window);
|
||||||
IMGUI_API void SetScrollX(ImGuiWindow* window, float new_scroll_x);
|
|
||||||
IMGUI_API void SetScrollY(ImGuiWindow* window, float new_scroll_y);
|
|
||||||
IMGUI_API ImRect GetWindowAllowedExtentRect(ImGuiWindow* window);
|
IMGUI_API ImRect GetWindowAllowedExtentRect(ImGuiWindow* window);
|
||||||
IMGUI_API void SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond = 0);
|
IMGUI_API void SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond = 0);
|
||||||
IMGUI_API void SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond cond = 0);
|
IMGUI_API void SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond cond = 0);
|
||||||
@ -1695,6 +1695,13 @@ namespace ImGui
|
|||||||
IMGUI_API ImGuiWindowSettings* FindOrCreateWindowSettings(const char* name);
|
IMGUI_API ImGuiWindowSettings* FindOrCreateWindowSettings(const char* name);
|
||||||
IMGUI_API ImGuiSettingsHandler* FindSettingsHandler(const char* type_name);
|
IMGUI_API ImGuiSettingsHandler* FindSettingsHandler(const char* type_name);
|
||||||
|
|
||||||
|
// Scrolling
|
||||||
|
IMGUI_API void SetScrollX(ImGuiWindow* window, float new_scroll_x);
|
||||||
|
IMGUI_API void SetScrollY(ImGuiWindow* window, float new_scroll_y);
|
||||||
|
IMGUI_API void SetScrollFromPosX(ImGuiWindow* window, float local_x, float center_x_ratio = 0.5f);
|
||||||
|
IMGUI_API void SetScrollFromPosY(ImGuiWindow* window, float local_y, float center_y_ratio = 0.5f);
|
||||||
|
IMGUI_API void ScrollToBringRectIntoView(ImGuiWindow* window, const ImRect& item_rect);
|
||||||
|
|
||||||
// Basic Accessors
|
// Basic Accessors
|
||||||
inline ImGuiID GetItemID() { ImGuiContext& g = *GImGui; return g.CurrentWindow->DC.LastItemId; }
|
inline ImGuiID GetItemID() { ImGuiContext& g = *GImGui; return g.CurrentWindow->DC.LastItemId; }
|
||||||
inline ImGuiID GetActiveID() { ImGuiContext& g = *GImGui; return g.ActiveId; }
|
inline ImGuiID GetActiveID() { ImGuiContext& g = *GImGui; return g.ActiveId; }
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// dear imgui, v1.72
|
// dear imgui, v1.72b
|
||||||
// (widgets code)
|
// (widgets code)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -3130,7 +3130,7 @@ namespace ImStb
|
|||||||
|
|
||||||
static int STB_TEXTEDIT_STRINGLEN(const STB_TEXTEDIT_STRING* obj) { return obj->CurLenW; }
|
static int STB_TEXTEDIT_STRINGLEN(const STB_TEXTEDIT_STRING* obj) { return obj->CurLenW; }
|
||||||
static ImWchar STB_TEXTEDIT_GETCHAR(const STB_TEXTEDIT_STRING* obj, int idx) { return obj->TextW[idx]; }
|
static ImWchar STB_TEXTEDIT_GETCHAR(const STB_TEXTEDIT_STRING* obj, int idx) { return obj->TextW[idx]; }
|
||||||
static float STB_TEXTEDIT_GETWIDTH(STB_TEXTEDIT_STRING* obj, int line_start_idx, int char_idx) { ImWchar c = obj->TextW[line_start_idx+char_idx]; if (c == '\n') return STB_TEXTEDIT_GETWIDTH_NEWLINE; return GImGui->Font->GetCharAdvance(c) * (GImGui->FontSize / GImGui->Font->FontSize); }
|
static float STB_TEXTEDIT_GETWIDTH(STB_TEXTEDIT_STRING* obj, int line_start_idx, int char_idx) { ImWchar c = obj->TextW[line_start_idx + char_idx]; if (c == '\n') return STB_TEXTEDIT_GETWIDTH_NEWLINE; ImGuiContext& g = *GImGui; return g.Font->GetCharAdvance(c) * (g.FontSize / g.Font->FontSize); }
|
||||||
static int STB_TEXTEDIT_KEYTOTEXT(int key) { return key >= 0x10000 ? 0 : key; }
|
static int STB_TEXTEDIT_KEYTOTEXT(int key) { return key >= 0x10000 ? 0 : key; }
|
||||||
static ImWchar STB_TEXTEDIT_NEWLINE = '\n';
|
static ImWchar STB_TEXTEDIT_NEWLINE = '\n';
|
||||||
static void STB_TEXTEDIT_LAYOUTROW(StbTexteditRow* r, STB_TEXTEDIT_STRING* obj, int line_start_idx)
|
static void STB_TEXTEDIT_LAYOUTROW(StbTexteditRow* r, STB_TEXTEDIT_STRING* obj, int line_start_idx)
|
||||||
@ -5482,13 +5482,16 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
|
|||||||
const bool was_selected = selected;
|
const bool was_selected = selected;
|
||||||
bool hovered, held;
|
bool hovered, held;
|
||||||
bool pressed = ButtonBehavior(bb, id, &hovered, &held, button_flags);
|
bool pressed = ButtonBehavior(bb, id, &hovered, &held, button_flags);
|
||||||
// Hovering selectable with mouse updates NavId accordingly so navigation can be resumed with gamepad/keyboard (this doesn't happen on most widgets)
|
|
||||||
if (pressed || hovered)
|
// Update NavId when clicking or when Hovering (this doesn't happen on most widgets), so navigation can be resumed with gamepad/keyboard
|
||||||
|
if (pressed || (hovered && (flags & ImGuiSelectableFlags_SetNavIdOnHover)))
|
||||||
|
{
|
||||||
if (!g.NavDisableMouseHover && g.NavWindow == window && g.NavLayer == window->DC.NavLayerCurrent)
|
if (!g.NavDisableMouseHover && g.NavWindow == window && g.NavLayer == window->DC.NavLayerCurrent)
|
||||||
{
|
{
|
||||||
g.NavDisableHighlight = true;
|
g.NavDisableHighlight = true;
|
||||||
SetNavID(id, window->DC.NavLayerCurrent);
|
SetNavID(id, window->DC.NavLayerCurrent);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (pressed)
|
if (pressed)
|
||||||
MarkItemEdited(id);
|
MarkItemEdited(id);
|
||||||
|
|
||||||
@ -6190,7 +6193,9 @@ bool ImGui::MenuItem(const char* label, const char* shortcut, bool selected, boo
|
|||||||
ImVec2 pos = window->DC.CursorPos;
|
ImVec2 pos = window->DC.CursorPos;
|
||||||
ImVec2 label_size = CalcTextSize(label, NULL, true);
|
ImVec2 label_size = CalcTextSize(label, NULL, true);
|
||||||
|
|
||||||
ImGuiSelectableFlags flags = ImGuiSelectableFlags_PressedOnRelease | (enabled ? 0 : ImGuiSelectableFlags_Disabled);
|
// We've been using the equivalent of ImGuiSelectableFlags_SetNavIdOnHover on all Selectable() since early Nav system days (commit 43ee5d73),
|
||||||
|
// but I am unsure whether this should be kept at all. For now moved it to be an opt-in feature used by menus only.
|
||||||
|
ImGuiSelectableFlags flags = ImGuiSelectableFlags_PressedOnRelease | ImGuiSelectableFlags_SetNavIdOnHover | (enabled ? 0 : ImGuiSelectableFlags_Disabled);
|
||||||
bool pressed;
|
bool pressed;
|
||||||
if (window->DC.LayoutType == ImGuiLayoutType_Horizontal)
|
if (window->DC.LayoutType == ImGuiLayoutType_Horizontal)
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
dear imgui, v1.72
|
dear imgui, v1.72b
|
||||||
(Font Readme)
|
(Font Readme)
|
||||||
|
|
||||||
---------------------------------------
|
---------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user