Brian Osman | d67e518 | 2017-12-08 16:46:09 -0500 | [diff] [blame] | 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(); |
Brian Osman | 7197e05 | 2018-06-29 14:30:48 -0400 | [diff] [blame^] | 19 | ~ImGuiLayer() override; |
Brian Osman | d67e518 | 2017-12-08 16:46:09 -0500 | [diff] [blame] | 20 | |
| 21 | typedef std::function<void(SkCanvas*)> SkiaWidgetFunc; |
| 22 | void skiaWidget(const ImVec2& size, SkiaWidgetFunc func); |
| 23 | |
| 24 | void onAttach(sk_app::Window* window) override; |
| 25 | void onPrePaint() override; |
| 26 | void onPaint(SkCanvas* canvas) override; |
| 27 | bool onMouse(int x, int y, sk_app::Window::InputState state, uint32_t modifiers) override; |
| 28 | bool onMouseWheel(float delta, uint32_t modifiers) override; |
| 29 | bool onKey(sk_app::Window::Key key, sk_app::Window::InputState state, uint32_t modifiers) override; |
| 30 | bool onChar(SkUnichar c, uint32_t modifiers) override; |
| 31 | |
| 32 | private: |
| 33 | sk_app::Window* fWindow; |
| 34 | SkPaint fFontPaint; |
| 35 | SkTArray<SkiaWidgetFunc> fSkiaWidgetFuncs; |
| 36 | }; |
| 37 | |
| 38 | #endif |