blob: d9e1571b602e35dc5fd18e0e21cc6b34306d98a9 [file] [log] [blame]
Brian Osmand67e5182017-12-08 16:46:09 -05001/*
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
16class ImGuiLayer : public sk_app::Window::Layer {
17public:
18 ImGuiLayer();
Brian Osman7197e052018-06-29 14:30:48 -040019 ~ImGuiLayer() override;
Brian Osmand67e5182017-12-08 16:46:09 -050020
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
32private:
33 sk_app::Window* fWindow;
34 SkPaint fFontPaint;
35 SkTArray<SkiaWidgetFunc> fSkiaWidgetFuncs;
36};
37
38#endif