diff options
-rw-r--r-- | DEPS | 2 | ||||
-rw-r--r-- | tools/viewer/ImGuiLayer.cpp | 5 | ||||
-rw-r--r-- | tools/viewer/ImGuiLayer.h | 1 | ||||
-rw-r--r-- | tools/viewer/Viewer.cpp | 7 |
4 files changed, 11 insertions, 4 deletions
@@ -15,7 +15,7 @@ deps = { "third_party/externals/googletest" : "https://android.googlesource.com/platform/external/googletest@dd43b9998e9a44a579a7aba6c1309407d1a5ed95", "third_party/externals/harfbuzz" : "https://skia.googlesource.com/third_party/harfbuzz.git@1.4.2", "third_party/externals/icu" : "https://chromium.googlesource.com/chromium/deps/icu.git@ec9c1133693148470ffe2e5e53576998e3650c1d", - "third_party/externals/imgui" : "https://skia.googlesource.com/external/github.com/ocornut/imgui.git@6384eee34f08cb7eab8d835043e1738e4adcdf75", + "third_party/externals/imgui" : "https://skia.googlesource.com/external/github.com/ocornut/imgui.git@00418d13e369bf53cc4b8f817eb10b8ce65f0904", # TODO: remove jsoncpp after migrating clients to SkJSON "third_party/externals/jsoncpp" : "https://chromium.googlesource.com/external/github.com/open-source-parsers/jsoncpp.git@1.0.0", "third_party/externals/libjpeg-turbo" : "https://skia.googlesource.com/external/github.com/libjpeg-turbo/libjpeg-turbo.git@26f109290dc4ffc9c522d9f5d5a7d5d1ee2c0e0a", diff --git a/tools/viewer/ImGuiLayer.cpp b/tools/viewer/ImGuiLayer.cpp index e55ac9c9c6..fe55a61279 100644 --- a/tools/viewer/ImGuiLayer.cpp +++ b/tools/viewer/ImGuiLayer.cpp @@ -22,6 +22,7 @@ using namespace sk_app; ImGuiLayer::ImGuiLayer() { // ImGui initialization: + ImGui::CreateContext(); ImGuiIO& io = ImGui::GetIO(); // Keymap... @@ -59,6 +60,10 @@ ImGuiLayer::ImGuiLayer() { io.Fonts->TexID = &fFontPaint; } +ImGuiLayer::~ImGuiLayer() { + ImGui::DestroyContext(); +} + void ImGuiLayer::onAttach(Window* window) { fWindow = window; } diff --git a/tools/viewer/ImGuiLayer.h b/tools/viewer/ImGuiLayer.h index 1cefcd4097..d9e1571b60 100644 --- a/tools/viewer/ImGuiLayer.h +++ b/tools/viewer/ImGuiLayer.h @@ -16,6 +16,7 @@ class ImGuiLayer : public sk_app::Window::Layer { public: ImGuiLayer(); + ~ImGuiLayer() override; typedef std::function<void(SkCanvas*)> SkiaWidgetFunc; void skiaWidget(const ImVec2& size, SkiaWidgetFunc func); diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp index 3675cc4fe2..81c1851783 100644 --- a/tools/viewer/Viewer.cpp +++ b/tools/viewer/Viewer.cpp @@ -1418,13 +1418,13 @@ static bool ImGui_DragQuad(SkPoint* pts) { void Viewer::drawImGui() { // Support drawing the ImGui demo window. Superfluous, but gives a good idea of what's possible if (fShowImGuiTestWindow) { - ImGui::ShowTestWindow(&fShowImGuiTestWindow); + ImGui::ShowDemoWindow(&fShowImGuiTestWindow); } if (fShowImGuiDebugWindow) { // We have some dynamic content that sizes to fill available size. If the scroll bar isn't // always visible, we can end up in a layout feedback loop. - ImGui::SetNextWindowSize(ImVec2(400, 400), ImGuiSetCond_FirstUseEver); + ImGui::SetNextWindowSize(ImVec2(400, 400), ImGuiCond_FirstUseEver); DisplayParams params = fWindow->getRequestedDisplayParams(); bool paramsChanged = false; if (ImGui::Begin("Tools", &fShowImGuiDebugWindow, @@ -1827,7 +1827,8 @@ void Viewer::drawImGui() { } if (fShowZoomWindow && fLastImage) { - if (ImGui::Begin("Zoom", &fShowZoomWindow, ImVec2(200, 200))) { + ImGui::SetNextWindowSize(ImVec2(200, 200), ImGuiCond_FirstUseEver); + if (ImGui::Begin("Zoom", &fShowZoomWindow)) { static int zoomFactor = 8; if (ImGui::Button("<<")) { zoomFactor = SkTMax(zoomFactor / 2, 4); |