mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-24 00:26:36 +00:00
Merge various minor things (supposedly harmless) from Navigation branch into Master to reduce differences. Some code in NewFrame() has been moved around. (#787)
This commit is contained in:
parent
ee42fae468
commit
1f1e63f705
55
imgui.cpp
55
imgui.cpp
@ -751,25 +751,21 @@ ImGuiIO::ImGuiIO()
|
||||
IniSavingRate = 5.0f;
|
||||
IniFilename = "imgui.ini";
|
||||
LogFilename = "imgui_log.txt";
|
||||
Fonts = &GImDefaultFontAtlas;
|
||||
FontGlobalScale = 1.0f;
|
||||
FontDefault = NULL;
|
||||
DisplayFramebufferScale = ImVec2(1.0f, 1.0f);
|
||||
MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
|
||||
MousePosPrev = ImVec2(-FLT_MAX, -FLT_MAX);
|
||||
MouseDoubleClickTime = 0.30f;
|
||||
MouseDoubleClickMaxDist = 6.0f;
|
||||
MouseDragThreshold = 6.0f;
|
||||
for (int i = 0; i < IM_ARRAYSIZE(MouseDownDuration); i++)
|
||||
MouseDownDuration[i] = MouseDownDurationPrev[i] = -1.0f;
|
||||
for (int i = 0; i < IM_ARRAYSIZE(KeysDownDuration); i++)
|
||||
KeysDownDuration[i] = KeysDownDurationPrev[i] = -1.0f;
|
||||
for (int i = 0; i < ImGuiKey_COUNT; i++)
|
||||
KeyMap[i] = -1;
|
||||
KeyRepeatDelay = 0.250f;
|
||||
KeyRepeatRate = 0.050f;
|
||||
UserData = NULL;
|
||||
|
||||
Fonts = &GImDefaultFontAtlas;
|
||||
FontGlobalScale = 1.0f;
|
||||
FontDefault = NULL;
|
||||
FontAllowUserScaling = false;
|
||||
DisplayFramebufferScale = ImVec2(1.0f, 1.0f);
|
||||
DisplayVisibleMin = DisplayVisibleMax = ImVec2(0.0f, 0.0f);
|
||||
|
||||
// User functions
|
||||
RenderDrawListsFn = NULL;
|
||||
MemAllocFn = malloc;
|
||||
@ -780,6 +776,13 @@ ImGuiIO::ImGuiIO()
|
||||
ImeSetInputScreenPosFn = ImeSetInputScreenPosFn_DefaultImpl;
|
||||
ImeWindowHandle = NULL;
|
||||
|
||||
// Input (NB: we already have memset zero the entire structure)
|
||||
MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
|
||||
MousePosPrev = ImVec2(-FLT_MAX, -FLT_MAX);
|
||||
MouseDragThreshold = 6.0f;
|
||||
for (int i = 0; i < IM_ARRAYSIZE(MouseDownDuration); i++) MouseDownDuration[i] = MouseDownDurationPrev[i] = -1.0f;
|
||||
for (int i = 0; i < IM_ARRAYSIZE(KeysDownDuration); i++) KeysDownDuration[i] = KeysDownDurationPrev[i] = -1.0f;
|
||||
|
||||
// Set OS X style defaults based on __APPLE__ compile time flag
|
||||
#ifdef __APPLE__
|
||||
OSXBehaviors = true;
|
||||
@ -1768,14 +1771,13 @@ ImGuiWindow::ImGuiWindow(const char* name)
|
||||
Name = ImStrdup(name);
|
||||
ID = ImHash(name, 0);
|
||||
IDStack.push_back(ID);
|
||||
MoveId = GetID("#MOVE");
|
||||
|
||||
Flags = 0;
|
||||
OrderWithinParent = 0;
|
||||
PosFloat = Pos = ImVec2(0.0f, 0.0f);
|
||||
Size = SizeFull = ImVec2(0.0f, 0.0f);
|
||||
SizeContents = SizeContentsExplicit = ImVec2(0.0f, 0.0f);
|
||||
WindowPadding = ImVec2(0.0f, 0.0f);
|
||||
MoveId = GetID("#MOVE");
|
||||
Scroll = ImVec2(0.0f, 0.0f);
|
||||
ScrollTarget = ImVec2(FLT_MAX, FLT_MAX);
|
||||
ScrollTargetCenterRatio = ImVec2(0.5f, 0.5f);
|
||||
@ -2156,6 +2158,20 @@ void ImGui::NewFrame()
|
||||
g.RenderDrawData.CmdLists = NULL;
|
||||
g.RenderDrawData.CmdListsCount = g.RenderDrawData.TotalVtxCount = g.RenderDrawData.TotalIdxCount = 0;
|
||||
|
||||
// Clear reference to active widget if the widget isn't alive anymore
|
||||
g.HoveredIdPreviousFrame = g.HoveredId;
|
||||
g.HoveredId = 0;
|
||||
g.HoveredIdAllowOverlap = false;
|
||||
if (!g.ActiveIdIsAlive && g.ActiveIdPreviousFrame == g.ActiveId && g.ActiveId != 0)
|
||||
ClearActiveID();
|
||||
g.ActiveIdPreviousFrame = g.ActiveId;
|
||||
g.ActiveIdIsAlive = false;
|
||||
g.ActiveIdIsJustActivated = false;
|
||||
// Update keyboard input state
|
||||
memcpy(g.IO.KeysDownDurationPrev, g.IO.KeysDownDuration, sizeof(g.IO.KeysDownDuration));
|
||||
for (int i = 0; i < IM_ARRAYSIZE(g.IO.KeysDown); i++)
|
||||
g.IO.KeysDownDuration[i] = g.IO.KeysDown[i] ? (g.IO.KeysDownDuration[i] < 0.0f ? 0.0f : g.IO.KeysDownDuration[i] + g.IO.DeltaTime) : -1.0f;
|
||||
|
||||
// Update mouse input state
|
||||
// If mouse just appeared or disappeared (usually denoted by -FLT_MAX component, but in reality we test for -256000.0f) we cancel out movement in MouseDelta
|
||||
if (IsMousePosValid(&g.IO.MousePos) && IsMousePosValid(&g.IO.MousePosPrev))
|
||||
@ -2190,9 +2206,6 @@ void ImGui::NewFrame()
|
||||
g.IO.MouseDragMaxDistanceSqr[i] = ImMax(g.IO.MouseDragMaxDistanceSqr[i], ImLengthSqr(g.IO.MousePos - g.IO.MouseClickedPos[i]));
|
||||
}
|
||||
}
|
||||
memcpy(g.IO.KeysDownDurationPrev, g.IO.KeysDownDuration, sizeof(g.IO.KeysDownDuration));
|
||||
for (int i = 0; i < IM_ARRAYSIZE(g.IO.KeysDown); i++)
|
||||
g.IO.KeysDownDuration[i] = g.IO.KeysDown[i] ? (g.IO.KeysDownDuration[i] < 0.0f ? 0.0f : g.IO.KeysDownDuration[i] + g.IO.DeltaTime) : -1.0f;
|
||||
|
||||
// Calculate frame-rate for the user, as a purely luxurious feature
|
||||
g.FramerateSecPerFrameAccum += g.IO.DeltaTime - g.FramerateSecPerFrame[g.FramerateSecPerFrameIdx];
|
||||
@ -2200,16 +2213,6 @@ void ImGui::NewFrame()
|
||||
g.FramerateSecPerFrameIdx = (g.FramerateSecPerFrameIdx + 1) % IM_ARRAYSIZE(g.FramerateSecPerFrame);
|
||||
g.IO.Framerate = 1.0f / (g.FramerateSecPerFrameAccum / (float)IM_ARRAYSIZE(g.FramerateSecPerFrame));
|
||||
|
||||
// Clear reference to active widget if the widget isn't alive anymore
|
||||
g.HoveredIdPreviousFrame = g.HoveredId;
|
||||
g.HoveredId = 0;
|
||||
g.HoveredIdAllowOverlap = false;
|
||||
if (!g.ActiveIdIsAlive && g.ActiveIdPreviousFrame == g.ActiveId && g.ActiveId != 0)
|
||||
ClearActiveID();
|
||||
g.ActiveIdPreviousFrame = g.ActiveId;
|
||||
g.ActiveIdIsAlive = false;
|
||||
g.ActiveIdIsJustActivated = false;
|
||||
|
||||
// Handle user moving window with mouse (at the beginning of the frame to avoid input lag or sheering). Only valid for root windows.
|
||||
if (g.MovedWindowMoveId && g.MovedWindowMoveId == g.ActiveId)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user