Viewer: Add ability to pause timer from GUI and keyboard

Bug: skia:
Change-Id: I1e4991c996cadcdee928efdbc10fc3d7ac820045
Reviewed-on: https://skia-review.googlesource.com/c/182813
Auto-Submit: Brian Osman <brianosman@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Florin Malita <fmalita@chromium.org>
This commit is contained in:
Brian Osman 2019-01-10 09:40:58 -05:00 committed by Skia Commit-Bot
parent ccb0a307c1
commit 207d410d3b

View File

@ -478,6 +478,9 @@ Viewer::Viewer(int argc, char** argv, void* platformData)
this->updateTitle();
fWindow->inval();
});
fCommands.addCommand('a', "Transform", "Toggle Animation", [this]() {
fAnimTimer.togglePauseResume();
});
fCommands.addCommand('u', "GUI", "Zoom UI", [this]() {
fZoomUI = !fZoomUI;
fStatsLayer.setDisplayScale(fZoomUI ? 2.0f : 1.0f);
@ -1847,6 +1850,13 @@ void Viewer::drawImGui() {
// Allow direct editing of gamut
ImGui_Primaries(&fColorSpacePrimaries, &fImGuiGamutPaint);
}
if (ImGui::CollapsingHeader("Animation")) {
bool isPaused = fAnimTimer.isPaused();
if (ImGui::Checkbox("Pause", &isPaused)) {
fAnimTimer.togglePauseResume();
}
}
}
if (paramsChanged) {
fDeferredActions.push_back([=]() {