Viewer: backspace jumps directly to the slide picker

Bug: skia:
Change-Id: I8107358e49ef20bf26ddf6a6dbb21efc07f167e7
Reviewed-on: https://skia-review.googlesource.com/71460
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Brian Osman 2017-11-14 15:32:20 -05:00 committed by Skia Commit-Bot
parent 76589f9b9b
commit fce09c5c72
2 changed files with 23 additions and 0 deletions

View File

@ -265,6 +265,7 @@ Viewer::Viewer(int argc, char** argv, void* platformData)
, fDisplayStats(false)
, fRefresh(false)
, fShowImGuiDebugWindow(false)
, fShowSlidePicker(false)
, fShowImGuiTestWindow(false)
, fShowZoomWindow(false)
, fLastImage(nullptr)
@ -336,6 +337,18 @@ Viewer::Viewer(int argc, char** argv, void* platformData)
this->fShowImGuiDebugWindow = !this->fShowImGuiDebugWindow;
fWindow->inval();
});
// Command to jump directly to the slide picker and give it focus
fCommands.addCommand('/', "GUI", "Jump to slide picker", [this]() {
this->fShowImGuiDebugWindow = true;
this->fShowSlidePicker = true;
fWindow->inval();
});
// Alias that to Backspace, to match SampleApp
fCommands.addCommand(Window::Key::kBack, "Backspace", "GUI", "Jump to slide picker", [this]() {
this->fShowImGuiDebugWindow = true;
this->fShowSlidePicker = true;
fWindow->inval();
});
fCommands.addCommand('g', "GUI", "Toggle GUI Demo", [this]() {
this->fShowImGuiTestWindow = !this->fShowImGuiTestWindow;
fWindow->inval();
@ -1218,11 +1231,20 @@ void Viewer::drawImGui(SkCanvas* canvas) {
}
}
if (fShowSlidePicker) {
ImGui::SetNextTreeNodeOpen(true);
}
if (ImGui::CollapsingHeader("Slide")) {
static ImGuiTextFilter filter;
static ImVector<const char*> filteredSlideNames;
static ImVector<int> filteredSlideIndices;
if (fShowSlidePicker) {
ImGui::SetKeyboardFocusHere();
fShowSlidePicker = false;
}
filter.Draw();
filteredSlideNames.clear();
filteredSlideIndices.clear();

View File

@ -78,6 +78,7 @@ private:
SkPaint fImGuiFontPaint;
SkPaint fImGuiGamutPaint;
bool fShowImGuiDebugWindow;
bool fShowSlidePicker;
bool fShowImGuiTestWindow;
bool fShowZoomWindow;