Home | History | Annotate | Download | only in viewer
      1 /*
      2 * Copyright 2017 Google Inc.
      3 *
      4 * Use of this source code is governed by a BSD-style license that can be
      5 * found in the LICENSE file.
      6 */
      7 
      8 #ifndef ImGuiLayer_DEFINED
      9 #define ImGuiLayer_DEFINED
     10 
     11 #include "SkPaint.h"
     12 #include "SkTArray.h"
     13 #include "sk_app/Window.h"
     14 #include "imgui.h"
     15 
     16 class ImGuiLayer : public sk_app::Window::Layer {
     17 public:
     18     ImGuiLayer();
     19 
     20     typedef std::function<void(SkCanvas*)> SkiaWidgetFunc;
     21     void skiaWidget(const ImVec2& size, SkiaWidgetFunc func);
     22 
     23     void onAttach(sk_app::Window* window) override;
     24     void onPrePaint() override;
     25     void onPaint(SkCanvas* canvas) override;
     26     bool onMouse(int x, int y, sk_app::Window::InputState state, uint32_t modifiers) override;
     27     bool onMouseWheel(float delta, uint32_t modifiers) override;
     28     bool onKey(sk_app::Window::Key key, sk_app::Window::InputState state, uint32_t modifiers) override;
     29     bool onChar(SkUnichar c, uint32_t modifiers) override;
     30 
     31 private:
     32     sk_app::Window* fWindow;
     33     SkPaint fFontPaint;
     34     SkTArray<SkiaWidgetFunc> fSkiaWidgetFuncs;
     35 };
     36 
     37 #endif
     38