blob: 4b10fc7970091c59c007f61cadeede8696eeb00d [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"
Hal Canary8a001442018-09-19 11:31:27 -040014
Brian Osmand67e5182017-12-08 16:46:09 -050015#include "imgui.h"
16
17class ImGuiLayer : public sk_app::Window::Layer {
18public:
19 ImGuiLayer();
Brian Osman7197e052018-06-29 14:30:48 -040020 ~ImGuiLayer() override;
Brian Osmand67e5182017-12-08 16:46:09 -050021
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
33private:
34 sk_app::Window* fWindow;
35 SkPaint fFontPaint;
36 SkTArray<SkiaWidgetFunc> fSkiaWidgetFuncs;
37};
38
39#endif