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 
     15 #include "imgui.h"
     16 
     17 class ImGuiLayer : public sk_app::Window::Layer {
     18 public:
     19     ImGuiLayer();
     20     ~ImGuiLayer() override;
     21 
     22     typedef std::function<void(SkCanvas*)> SkiaWidgetFunc;
     23     void skiaWidget(const ImVec2& size, SkiaWidgetFunc func);
     24 
     25     void onAttach(sk_app::Window* window) override;
     26     void onPrePaint() override;
     27     void onPaint(SkCanvas* canvas) override;
     28     bool onMouse(int x, int y, sk_app::Window::InputState state, uint32_t modifiers) override;
     29     bool onMouseWheel(float delta, uint32_t modifiers) override;
     30     bool onKey(sk_app::Window::Key key, sk_app::Window::InputState state, uint32_t modifiers) override;
     31     bool onChar(SkUnichar c, uint32_t modifiers) override;
     32 
     33 private:
     34     sk_app::Window* fWindow;
     35     SkPaint fFontPaint;
     36     SkTArray<SkiaWidgetFunc> fSkiaWidgetFuncs;
     37 };
     38 
     39 #endif
     40