|
|
@@ -369,6 +369,10 @@ CODE
|
|
|
When you are not sure about a old symbol or function name, try using the Search/Find function of your IDE to look for comments or references in all imgui files.
|
|
|
You can read releases logs https://github.com/ocornut/imgui/releases for more details.
|
|
|
|
|
|
+ - 2019/10/14 (1.74) - inputs: Fixed a miscalculation in the keyboard/mouse "typematic" repeat delay/rate calculation, used by keys and e.g. repeating mouse buttons as well as the GetKeyPressedAmount() function.
|
|
|
+ if you were using a non-default value for io.KeyRepeatRate (previous default was 0.250), you can add +io.KeyRepeatDelay to it to compensate for the fix.
|
|
|
+ The function was triggering on: 0.0 and (delay+rate*N) where (N>=1). Fixed formula responds to (N>=0). Effectively it made io.KeyRepeatRate behave like it was set to (io.KeyRepeatRate + io.KeyRepeatDelay).
|
|
|
+ If you never altered io.KeyRepeatRate nor used GetKeyPressedAmount() this won't affect you.
|
|
|
- 2019/07/15 (1.72) - removed TreeAdvanceToLabelPos() which is rarely used and only does SetCursorPosX(GetCursorPosX() + GetTreeNodeToLabelSpacing()). Kept redirection function (will obsolete).
|
|
|
- 2019/07/12 (1.72) - renamed ImFontAtlas::CustomRect to ImFontAtlasCustomRect. Kept redirection typedef (will obsolete).
|
|
|
- 2019/06/14 (1.72) - removed redirecting functions/enums names that were marked obsolete in 1.51 (June 2017): ImGuiCol_Column*, ImGuiSetCond_*, IsItemHoveredRect(), IsPosHoveringAnyWindow(), IsMouseHoveringAnyWindow(), IsMouseHoveringWindow(), IMGUI_ONCE_UPON_A_FRAME. Grep this log for details and new names.
|
|
|
@@ -955,9 +959,6 @@ CODE
|
|
|
- tip: you can call Begin() multiple times with the same name during the same frame, it will keep appending to the same window.
|
|
|
this is also useful to set yourself in the context of another window (to get/set other settings)
|
|
|
- tip: you can create widgets without a Begin()/End() block, they will go in an implicit window called "Debug".
|
|
|
- - tip: the ImGuiOnceUponAFrame helper will allow run the block of code only once a frame. You can use it to quickly add custom UI in the middle
|
|
|
- of a deep nested inner loop in your code.
|
|
|
- - tip: you can call Render() multiple times (e.g for VR renders).
|
|
|
- tip: call and read the ShowDemoWindow() code in imgui_demo.cpp for more example of how to use ImGui!
|
|
|
|
|
|
*/
|
|
|
@@ -1211,7 +1212,7 @@ ImGuiIO::ImGuiIO()
|
|
|
MouseDoubleClickMaxDist = 6.0f;
|
|
|
for (int i = 0; i < ImGuiKey_COUNT; i++)
|
|
|
KeyMap[i] = -1;
|
|
|
- KeyRepeatDelay = 0.250f;
|
|
|
+ KeyRepeatDelay = 0.275f;
|
|
|
KeyRepeatRate = 0.050f;
|
|
|
UserData = NULL;
|
|
|
|
|
|
@@ -4407,14 +4408,22 @@ bool ImGui::IsKeyDown(int user_key_index)
|
|
|
return g.IO.KeysDown[user_key_index];
|
|
|
}
|
|
|
|
|
|
-int ImGui::CalcTypematicPressedRepeatAmount(float t, float t_prev, float repeat_delay, float repeat_rate)
|
|
|
+// t0 = previous time (e.g.: g.Time - g.IO.DeltaTime)
|
|
|
+// t1 = current time (e.g.: g.Time)
|
|
|
+// An event is triggered at:
|
|
|
+// t = 0.0f t = repeat_delay, t = repeat_delay + repeat_rate*N
|
|
|
+int ImGui::CalcTypematicRepeatAmount(float t0, float t1, float repeat_delay, float repeat_rate)
|
|
|
{
|
|
|
- if (t == 0.0f)
|
|
|
+ if (t1 == 0.0f)
|
|
|
return 1;
|
|
|
- if (t <= repeat_delay || repeat_rate <= 0.0f)
|
|
|
+ if (t0 >= t1)
|
|
|
return 0;
|
|
|
- const int count = (int)((t - repeat_delay) / repeat_rate) - (int)((t_prev - repeat_delay) / repeat_rate);
|
|
|
- return (count > 0) ? count : 0;
|
|
|
+ if (repeat_rate <= 0.0f)
|
|
|
+ return (t0 < repeat_delay) && (t1 >= repeat_delay);
|
|
|
+ const int count_t0 = (t0 < repeat_delay) ? -1 : (int)((t0 - repeat_delay) / repeat_rate);
|
|
|
+ const int count_t1 = (t1 < repeat_delay) ? -1 : (int)((t1 - repeat_delay) / repeat_rate);
|
|
|
+ const int count = count_t1 - count_t0;
|
|
|
+ return count;
|
|
|
}
|
|
|
|
|
|
int ImGui::GetKeyPressedAmount(int key_index, float repeat_delay, float repeat_rate)
|
|
|
@@ -4424,7 +4433,7 @@ int ImGui::GetKeyPressedAmount(int key_index, float repeat_delay, float repeat_r
|
|
|
return 0;
|
|
|
IM_ASSERT(key_index >= 0 && key_index < IM_ARRAYSIZE(g.IO.KeysDown));
|
|
|
const float t = g.IO.KeysDownDuration[key_index];
|
|
|
- return CalcTypematicPressedRepeatAmount(t, t - g.IO.DeltaTime, repeat_delay, repeat_rate);
|
|
|
+ return CalcTypematicRepeatAmount(t - g.IO.DeltaTime, t, repeat_delay, repeat_rate);
|
|
|
}
|
|
|
|
|
|
bool ImGui::IsKeyPressed(int user_key_index, bool repeat)
|
|
|
@@ -4476,7 +4485,7 @@ bool ImGui::IsMouseClicked(int button, bool repeat)
|
|
|
if (repeat && t > g.IO.KeyRepeatDelay)
|
|
|
{
|
|
|
// FIXME: 2019/05/03: Our old repeat code was wrong here and led to doubling the repeat rate, which made it an ok rate for repeat on mouse hold.
|
|
|
- int amount = CalcTypematicPressedRepeatAmount(t, t - g.IO.DeltaTime, g.IO.KeyRepeatDelay, g.IO.KeyRepeatRate * 0.5f);
|
|
|
+ int amount = CalcTypematicRepeatAmount(t - g.IO.DeltaTime, t, g.IO.KeyRepeatDelay, g.IO.KeyRepeatRate * 0.50f);
|
|
|
if (amount > 0)
|
|
|
return true;
|
|
|
}
|
|
|
@@ -7513,19 +7522,6 @@ void ImGui::OpenPopupEx(ImGuiID id)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-bool ImGui::OpenPopupOnItemClick(const char* str_id, int mouse_button)
|
|
|
-{
|
|
|
- ImGuiWindow* window = GImGui->CurrentWindow;
|
|
|
- if (IsMouseReleased(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup))
|
|
|
- {
|
|
|
- ImGuiID id = str_id ? window->GetID(str_id) : window->DC.LastItemId; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict!
|
|
|
- IM_ASSERT(id != 0); // You cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item)
|
|
|
- OpenPopupEx(id);
|
|
|
- return true;
|
|
|
- }
|
|
|
- return false;
|
|
|
-}
|
|
|
-
|
|
|
void ImGui::ClosePopupsOverWindow(ImGuiWindow* ref_window, bool restore_focus_to_window_under_popup)
|
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
@@ -7695,6 +7691,19 @@ void ImGui::EndPopup()
|
|
|
End();
|
|
|
}
|
|
|
|
|
|
+bool ImGui::OpenPopupOnItemClick(const char* str_id, int mouse_button)
|
|
|
+{
|
|
|
+ ImGuiWindow* window = GImGui->CurrentWindow;
|
|
|
+ if (IsMouseReleased(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup))
|
|
|
+ {
|
|
|
+ ImGuiID id = str_id ? window->GetID(str_id) : window->DC.LastItemId; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict!
|
|
|
+ IM_ASSERT(id != 0); // You cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item)
|
|
|
+ OpenPopupEx(id);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
// This is a helper to handle the simplest case of associating one named popup to one given widget.
|
|
|
// You may want to handle this on user side if you have specific needs (e.g. tweaking IsItemHovered() parameters).
|
|
|
// You can pass a NULL str_id to use the identifier of the last item.
|
|
|
@@ -8183,6 +8192,7 @@ void ImGui::NavInitWindow(ImGuiWindow* window, bool force_reinit)
|
|
|
if (!(window->Flags & ImGuiWindowFlags_NoNavInputs))
|
|
|
if (!(window->Flags & ImGuiWindowFlags_ChildWindow) || (window->Flags & ImGuiWindowFlags_Popup) || (window->NavLastIds[0] == 0) || force_reinit)
|
|
|
init_for_nav = true;
|
|
|
+ //IMGUI_DEBUG_LOG("[Nav] NavInitWindow() init_for_nav=%d, window=\"%s\", layer=%d\n", init_for_nav, window->Name, g.NavLayer);
|
|
|
if (init_for_nav)
|
|
|
{
|
|
|
SetNavID(0, g.NavLayer);
|
|
|
@@ -8232,11 +8242,11 @@ float ImGui::GetNavInputAmount(ImGuiNavInput n, ImGuiInputReadMode mode)
|
|
|
if (mode == ImGuiInputReadMode_Pressed) // Return 1.0f when just pressed, no repeat, ignore analog input.
|
|
|
return (t == 0.0f) ? 1.0f : 0.0f;
|
|
|
if (mode == ImGuiInputReadMode_Repeat)
|
|
|
- return (float)CalcTypematicPressedRepeatAmount(t, t - g.IO.DeltaTime, g.IO.KeyRepeatDelay * 0.80f, g.IO.KeyRepeatRate * 0.80f);
|
|
|
+ return (float)CalcTypematicRepeatAmount(t - g.IO.DeltaTime, t, g.IO.KeyRepeatDelay * 0.72f, g.IO.KeyRepeatRate * 0.80f);
|
|
|
if (mode == ImGuiInputReadMode_RepeatSlow)
|
|
|
- return (float)CalcTypematicPressedRepeatAmount(t, t - g.IO.DeltaTime, g.IO.KeyRepeatDelay * 1.00f, g.IO.KeyRepeatRate * 2.00f);
|
|
|
+ return (float)CalcTypematicRepeatAmount(t - g.IO.DeltaTime, t, g.IO.KeyRepeatDelay * 1.25f, g.IO.KeyRepeatRate * 2.00f);
|
|
|
if (mode == ImGuiInputReadMode_RepeatFast)
|
|
|
- return (float)CalcTypematicPressedRepeatAmount(t, t - g.IO.DeltaTime, g.IO.KeyRepeatDelay * 0.80f, g.IO.KeyRepeatRate * 0.30f);
|
|
|
+ return (float)CalcTypematicRepeatAmount(t - g.IO.DeltaTime, t, g.IO.KeyRepeatDelay * 0.72f, g.IO.KeyRepeatRate * 0.30f);
|
|
|
return 0.0f;
|
|
|
}
|
|
|
|
|
|
@@ -8299,6 +8309,7 @@ static void ImGui::NavUpdate()
|
|
|
if (g.NavInitResultId != 0 && (!g.NavDisableHighlight || g.NavInitRequestFromMove) && g.NavWindow)
|
|
|
{
|
|
|
// Apply result from previous navigation init request (will typically select the first item, unless SetItemDefaultFocus() has been called)
|
|
|
+ //IMGUI_DEBUG_LOG("[Nav] Apply NavInitRequest result: 0x%08X Layer %d in \"%s\"\n", g.NavInitResultId, g.NavLayer, g.NavWindow->Name);
|
|
|
if (g.NavInitRequestFromMove)
|
|
|
SetNavIDWithRectRel(g.NavInitResultId, g.NavLayer, g.NavInitResultRectRel);
|
|
|
else
|
|
|
@@ -8457,6 +8468,7 @@ static void ImGui::NavUpdate()
|
|
|
}
|
|
|
if (g.NavMoveRequest && g.NavId == 0)
|
|
|
{
|
|
|
+ //IMGUI_DEBUG_LOG("[Nav] NavInitRequest from move, window \"%s\", layer=%d\n", g.NavWindow->Name, g.NavLayer);
|
|
|
g.NavInitRequest = g.NavInitRequestFromMove = true;
|
|
|
g.NavInitResultId = 0;
|
|
|
g.NavDisableHighlight = false;
|