GUI: fix inertial scroll when power saving is on
This commit is contained in:
parent
9c7e25f33c
commit
152a95cb40
|
@ -4469,6 +4469,7 @@ void ImGui::NewFrame()
|
||||||
g.FramerateSecPerFrameIdx = (g.FramerateSecPerFrameIdx + 1) % IM_ARRAYSIZE(g.FramerateSecPerFrame);
|
g.FramerateSecPerFrameIdx = (g.FramerateSecPerFrameIdx + 1) % IM_ARRAYSIZE(g.FramerateSecPerFrame);
|
||||||
g.FramerateSecPerFrameCount = ImMin(g.FramerateSecPerFrameCount + 1, IM_ARRAYSIZE(g.FramerateSecPerFrame));
|
g.FramerateSecPerFrameCount = ImMin(g.FramerateSecPerFrameCount + 1, IM_ARRAYSIZE(g.FramerateSecPerFrame));
|
||||||
g.IO.Framerate = (g.FramerateSecPerFrameAccum > 0.0f) ? (1.0f / (g.FramerateSecPerFrameAccum / (float)g.FramerateSecPerFrameCount)) : FLT_MAX;
|
g.IO.Framerate = (g.FramerateSecPerFrameAccum > 0.0f) ? (1.0f / (g.FramerateSecPerFrameAccum / (float)g.FramerateSecPerFrameCount)) : FLT_MAX;
|
||||||
|
g.IO.IsSomethingHappening = false;
|
||||||
|
|
||||||
UpdateViewportsNewFrame();
|
UpdateViewportsNewFrame();
|
||||||
|
|
||||||
|
@ -6961,12 +6962,14 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||||
if (fabs(window->InertialScrollSpeed.x)>0.1f) {
|
if (fabs(window->InertialScrollSpeed.x)>0.1f) {
|
||||||
window->Scroll.x=window->Scroll.x+window->InertialScrollSpeed.x;
|
window->Scroll.x=window->Scroll.x+window->InertialScrollSpeed.x;
|
||||||
window->InertialScrollSpeed.x*=0.95f;
|
window->InertialScrollSpeed.x*=0.95f;
|
||||||
|
g.IO.IsSomethingHappening = true;
|
||||||
} else {
|
} else {
|
||||||
window->InertialScrollSpeed.x=0.0f;
|
window->InertialScrollSpeed.x=0.0f;
|
||||||
}
|
}
|
||||||
if (fabs(window->InertialScrollSpeed.y)>0.1f) {
|
if (fabs(window->InertialScrollSpeed.y)>0.1f) {
|
||||||
window->Scroll.y=window->Scroll.y+window->InertialScrollSpeed.y;
|
window->Scroll.y=window->Scroll.y+window->InertialScrollSpeed.y;
|
||||||
window->InertialScrollSpeed.y*=0.95f;
|
window->InertialScrollSpeed.y*=0.95f;
|
||||||
|
g.IO.IsSomethingHappening = true;
|
||||||
} else {
|
} else {
|
||||||
window->InertialScrollSpeed.y=0.0f;
|
window->InertialScrollSpeed.y=0.0f;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2096,6 +2096,7 @@ struct ImGuiIO
|
||||||
bool WantTextInput; // Mobile/console: when set, you may display an on-screen keyboard. This is set by Dear ImGui when it wants textual keyboard input to happen (e.g. when a InputText widget is active).
|
bool WantTextInput; // Mobile/console: when set, you may display an on-screen keyboard. This is set by Dear ImGui when it wants textual keyboard input to happen (e.g. when a InputText widget is active).
|
||||||
bool WantSetMousePos; // MousePos has been altered, backend should reposition mouse on next frame. Rarely used! Set only when ImGuiConfigFlags_NavEnableSetMousePos flag is enabled.
|
bool WantSetMousePos; // MousePos has been altered, backend should reposition mouse on next frame. Rarely used! Set only when ImGuiConfigFlags_NavEnableSetMousePos flag is enabled.
|
||||||
bool WantSaveIniSettings; // When manual .ini load/save is active (io.IniFilename == NULL), this will be set to notify your application that you can call SaveIniSettingsToMemory() and save yourself. Important: clear io.WantSaveIniSettings yourself after saving!
|
bool WantSaveIniSettings; // When manual .ini load/save is active (io.IniFilename == NULL), this will be set to notify your application that you can call SaveIniSettingsToMemory() and save yourself. Important: clear io.WantSaveIniSettings yourself after saving!
|
||||||
|
bool IsSomethingHappening; // This is set to true when inertial scrolling is happening.
|
||||||
bool NavActive; // Keyboard/Gamepad navigation is currently allowed (will handle ImGuiKey_NavXXX events) = a window is focused and it doesn't use the ImGuiWindowFlags_NoNavInputs flag.
|
bool NavActive; // Keyboard/Gamepad navigation is currently allowed (will handle ImGuiKey_NavXXX events) = a window is focused and it doesn't use the ImGuiWindowFlags_NoNavInputs flag.
|
||||||
bool NavVisible; // Keyboard/Gamepad navigation is visible and allowed (will handle ImGuiKey_NavXXX events).
|
bool NavVisible; // Keyboard/Gamepad navigation is visible and allowed (will handle ImGuiKey_NavXXX events).
|
||||||
float Framerate; // Rough estimate of application framerate, in frame per second. Solely for convenience. Rolling average estimation based on io.DeltaTime over 120 frames.
|
float Framerate; // Rough estimate of application framerate, in frame per second. Solely for convenience. Rolling average estimation based on io.DeltaTime over 120 frames.
|
||||||
|
|
|
@ -3171,6 +3171,11 @@ bool FurnaceGUI::loop() {
|
||||||
if (wantCaptureKeyboard) {
|
if (wantCaptureKeyboard) {
|
||||||
WAKE_UP;
|
WAKE_UP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ImGui::GetIO().IsSomethingHappening) {
|
||||||
|
WAKE_UP;
|
||||||
|
}
|
||||||
|
|
||||||
if (ImGui::GetIO().MouseDown[0] || ImGui::GetIO().MouseDown[1] || ImGui::GetIO().MouseDown[2] || ImGui::GetIO().MouseDown[3] || ImGui::GetIO().MouseDown[4]) {
|
if (ImGui::GetIO().MouseDown[0] || ImGui::GetIO().MouseDown[1] || ImGui::GetIO().MouseDown[2] || ImGui::GetIO().MouseDown[3] || ImGui::GetIO().MouseDown[4]) {
|
||||||
WAKE_UP;
|
WAKE_UP;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue