mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-26 13:37:00 +00:00
Changed ImGui::GetTime() return value from float to double to avoid accumulating floating point imprecisions over time.
This commit is contained in:
parent
ec76009bc4
commit
e07f5d4c78
@ -38,6 +38,7 @@ Breaking Changes:
|
|||||||
- Removed per-window ImGuiWindowFlags_ResizeFromAnySide beta flag in favor `io.OptResizeWindowsFromEdges=true` to enable the feature globally. (#1495)
|
- Removed per-window ImGuiWindowFlags_ResizeFromAnySide beta flag in favor `io.OptResizeWindowsFromEdges=true` to enable the feature globally. (#1495)
|
||||||
The feature is not currently enabled by default because it is not satisfying enough.
|
The feature is not currently enabled by default because it is not satisfying enough.
|
||||||
- Style: Renamed ImGuiCol_ModalWindowDarkening to ImGuiCol_ModalWindowDimBg for consistency with other features. Kept redirection enum (will obsolete).
|
- Style: Renamed ImGuiCol_ModalWindowDarkening to ImGuiCol_ModalWindowDimBg for consistency with other features. Kept redirection enum (will obsolete).
|
||||||
|
- Changed ImGui::GetTime() return value from float to double to avoid accumulating floating point imprecisions over time.
|
||||||
|
|
||||||
Other Changes:
|
Other Changes:
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@
|
|||||||
io.MouseDown[1] = my_mouse_buttons[1];
|
io.MouseDown[1] = my_mouse_buttons[1];
|
||||||
|
|
||||||
// Call NewFrame(), after this point you can use ImGui::* functions anytime
|
// Call NewFrame(), after this point you can use ImGui::* functions anytime
|
||||||
// (So you want to try calling Newframe() as early as you can in your mainloop to be able to use imgui everywhere)
|
// (So you want to try calling NewFrame() as early as you can in your mainloop to be able to use imgui everywhere)
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
|
|
||||||
// Most of your application code here
|
// Most of your application code here
|
||||||
@ -305,6 +305,7 @@
|
|||||||
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.
|
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.
|
You can read releases logs https://github.com/ocornut/imgui/releases for more details.
|
||||||
|
|
||||||
|
- 2017/07/22 (1.63) - changed ImGui::GetTime() return value from float to double to avoid accumulating floating point imprecisions over time.
|
||||||
- 2018/07/08 (1.63) - style: renamed ImGuiCol_ModalWindowDarkening to ImGuiCol_ModalWindowDimBg for consistency with other features. Kept redirection enum (will obsolete).
|
- 2018/07/08 (1.63) - style: renamed ImGuiCol_ModalWindowDarkening to ImGuiCol_ModalWindowDimBg for consistency with other features. Kept redirection enum (will obsolete).
|
||||||
- 2018/07/06 (1.63) - removed per-window ImGuiWindowFlags_ResizeFromAnySide beta flag in favor of a global io.OptResizeWindowsFromEdges to enable the feature.
|
- 2018/07/06 (1.63) - removed per-window ImGuiWindowFlags_ResizeFromAnySide beta flag in favor of a global io.OptResizeWindowsFromEdges to enable the feature.
|
||||||
- 2018/06/06 (1.62) - renamed GetGlyphRangesChinese() to GetGlyphRangesChineseFull() to distinguish other variants and discourage using the full set.
|
- 2018/06/06 (1.62) - renamed GetGlyphRangesChinese() to GetGlyphRangesChineseFull() to distinguish other variants and discourage using the full set.
|
||||||
@ -2907,7 +2908,7 @@ ImDrawData* ImGui::GetDrawData()
|
|||||||
return g.DrawData.Valid ? &g.DrawData : NULL;
|
return g.DrawData.Valid ? &g.DrawData : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
float ImGui::GetTime()
|
double ImGui::GetTime()
|
||||||
{
|
{
|
||||||
return GImGui->Time;
|
return GImGui->Time;
|
||||||
}
|
}
|
||||||
@ -3667,7 +3668,7 @@ static void ImGui::UpdateMouseInputs()
|
|||||||
g.IO.MouseDoubleClicked[i] = false;
|
g.IO.MouseDoubleClicked[i] = false;
|
||||||
if (g.IO.MouseClicked[i])
|
if (g.IO.MouseClicked[i])
|
||||||
{
|
{
|
||||||
if (g.Time - g.IO.MouseClickedTime[i] < g.IO.MouseDoubleClickTime)
|
if ((float)(g.Time - g.IO.MouseClickedTime[i]) < g.IO.MouseDoubleClickTime)
|
||||||
{
|
{
|
||||||
ImVec2 delta_from_click_pos = IsMousePosValid(&g.IO.MousePos) ? (g.IO.MousePos - g.IO.MouseClickedPos[i]) : ImVec2(0.0f, 0.0f);
|
ImVec2 delta_from_click_pos = IsMousePosValid(&g.IO.MousePos) ? (g.IO.MousePos - g.IO.MouseClickedPos[i]) : ImVec2(0.0f, 0.0f);
|
||||||
if (ImLengthSqr(delta_from_click_pos) < g.IO.MouseDoubleClickMaxDist * g.IO.MouseDoubleClickMaxDist)
|
if (ImLengthSqr(delta_from_click_pos) < g.IO.MouseDoubleClickMaxDist * g.IO.MouseDoubleClickMaxDist)
|
||||||
@ -3808,6 +3809,7 @@ void ImGui::NewFrame()
|
|||||||
g.TooltipOverrideCount = 0;
|
g.TooltipOverrideCount = 0;
|
||||||
g.WindowsActiveCount = 0;
|
g.WindowsActiveCount = 0;
|
||||||
|
|
||||||
|
// Setup current font and draw list
|
||||||
SetCurrentFont(GetDefaultFont());
|
SetCurrentFont(GetDefaultFont());
|
||||||
IM_ASSERT(g.Font->IsLoaded());
|
IM_ASSERT(g.Font->IsLoaded());
|
||||||
g.DrawListSharedData.ClipRectFullscreen = ImVec4(0.0f, 0.0f, g.IO.DisplaySize.x, g.IO.DisplaySize.y);
|
g.DrawListSharedData.ClipRectFullscreen = ImVec4(0.0f, 0.0f, g.IO.DisplaySize.x, g.IO.DisplaySize.y);
|
||||||
|
4
imgui.h
4
imgui.h
@ -525,7 +525,7 @@ namespace ImGui
|
|||||||
IMGUI_API void SetItemAllowOverlap(); // allow last item to be overlapped by a subsequent item. sometimes useful with invisible buttons, selectables, etc. to catch unused area.
|
IMGUI_API void SetItemAllowOverlap(); // allow last item to be overlapped by a subsequent item. sometimes useful with invisible buttons, selectables, etc. to catch unused area.
|
||||||
IMGUI_API bool IsRectVisible(const ImVec2& size); // test if rectangle (of given size, starting from cursor position) is visible / not clipped.
|
IMGUI_API bool IsRectVisible(const ImVec2& size); // test if rectangle (of given size, starting from cursor position) is visible / not clipped.
|
||||||
IMGUI_API bool IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max); // test if rectangle (in screen space) is visible / not clipped. to perform coarse clipping on user's side.
|
IMGUI_API bool IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max); // test if rectangle (in screen space) is visible / not clipped. to perform coarse clipping on user's side.
|
||||||
IMGUI_API float GetTime();
|
IMGUI_API double GetTime();
|
||||||
IMGUI_API int GetFrameCount();
|
IMGUI_API int GetFrameCount();
|
||||||
IMGUI_API ImDrawList* GetOverlayDrawList(); // this draw list will be the last rendered one, useful to quickly draw overlays shapes/text
|
IMGUI_API ImDrawList* GetOverlayDrawList(); // this draw list will be the last rendered one, useful to quickly draw overlays shapes/text
|
||||||
IMGUI_API ImDrawListSharedData* GetDrawListSharedData(); // you may use this when creating your own ImDrawList instances
|
IMGUI_API ImDrawListSharedData* GetDrawListSharedData(); // you may use this when creating your own ImDrawList instances
|
||||||
@ -1162,7 +1162,7 @@ struct ImGuiIO
|
|||||||
|
|
||||||
ImVec2 MousePosPrev; // Previous mouse position temporary storage (nb: not for public use, set to MousePos in NewFrame())
|
ImVec2 MousePosPrev; // Previous mouse position temporary storage (nb: not for public use, set to MousePos in NewFrame())
|
||||||
ImVec2 MouseClickedPos[5]; // Position at time of clicking
|
ImVec2 MouseClickedPos[5]; // Position at time of clicking
|
||||||
float MouseClickedTime[5]; // Time of last click (used to figure out double-click)
|
double MouseClickedTime[5]; // Time of last click (used to figure out double-click)
|
||||||
bool MouseClicked[5]; // Mouse button went from !Down to Down
|
bool MouseClicked[5]; // Mouse button went from !Down to Down
|
||||||
bool MouseDoubleClicked[5]; // Has mouse button been double-clicked?
|
bool MouseDoubleClicked[5]; // Has mouse button been double-clicked?
|
||||||
bool MouseReleased[5]; // Mouse button went from Down to !Down
|
bool MouseReleased[5]; // Mouse button went from Down to !Down
|
||||||
|
@ -819,7 +819,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
|||||||
// Tip: If your float aren't contiguous but part of a structure, you can pass a pointer to your first float and the sizeof() of your structure in the Stride parameter.
|
// Tip: If your float aren't contiguous but part of a structure, you can pass a pointer to your first float and the sizeof() of your structure in the Stride parameter.
|
||||||
static float values[90] = { 0 };
|
static float values[90] = { 0 };
|
||||||
static int values_offset = 0;
|
static int values_offset = 0;
|
||||||
static float refresh_time = 0.0f;
|
static double refresh_time = 0.0;
|
||||||
if (!animate || refresh_time == 0.0f)
|
if (!animate || refresh_time == 0.0f)
|
||||||
refresh_time = ImGui::GetTime();
|
refresh_time = ImGui::GetTime();
|
||||||
while (refresh_time < ImGui::GetTime()) // Create dummy data at fixed 60 hz rate for the demo
|
while (refresh_time < ImGui::GetTime()) // Create dummy data at fixed 60 hz rate for the demo
|
||||||
@ -3020,8 +3020,8 @@ static void ShowExampleAppLog(bool* p_open)
|
|||||||
static ExampleAppLog log;
|
static ExampleAppLog log;
|
||||||
|
|
||||||
// Demo: add random items (unless Ctrl is held)
|
// Demo: add random items (unless Ctrl is held)
|
||||||
static float last_time = -1.0f;
|
static double last_time = -1.0;
|
||||||
float time = ImGui::GetTime();
|
double time = ImGui::GetTime();
|
||||||
if (time - last_time >= 0.20f && !ImGui::GetIO().KeyCtrl)
|
if (time - last_time >= 0.20f && !ImGui::GetIO().KeyCtrl)
|
||||||
{
|
{
|
||||||
const char* random_words[] = { "system", "info", "warning", "error", "fatal", "notice", "log" };
|
const char* random_words[] = { "system", "info", "warning", "error", "fatal", "notice", "log" };
|
||||||
|
@ -616,7 +616,7 @@ struct ImGuiContext
|
|||||||
float FontBaseSize; // (Shortcut) == IO.FontGlobalScale * Font->Scale * Font->FontSize. Base text height.
|
float FontBaseSize; // (Shortcut) == IO.FontGlobalScale * Font->Scale * Font->FontSize. Base text height.
|
||||||
ImDrawListSharedData DrawListSharedData;
|
ImDrawListSharedData DrawListSharedData;
|
||||||
|
|
||||||
float Time;
|
double Time;
|
||||||
int FrameCount;
|
int FrameCount;
|
||||||
int FrameCountEnded;
|
int FrameCountEnded;
|
||||||
int FrameCountRendered;
|
int FrameCountRendered;
|
||||||
|
Loading…
Reference in New Issue
Block a user