iPlug2 - C++ Audio Plug-in Framework
IGraphicsImGui.h
1 /*
2  ==============================================================================
3 
4  This file is part of the iPlug 2 library. Copyright (C) the iPlug 2 developers.
5 
6  See LICENSE.txt for more info.
7 
8  ==============================================================================
9 */
10 
11 
12 #pragma once
13 
14 #if defined IGRAPHICS_IMGUI
15 #include "imgui.h"
16 #include "IGraphicsStructs.h"
17 
18 BEGIN_IPLUG_NAMESPACE
19 BEGIN_IGRAPHICS_NAMESPACE
20 
21 class IGraphics;
22 
23 class ImGuiRenderer
24 {
25 public:
26  ImGuiRenderer(IGraphics* pGraphics, std::function<void(IGraphics*)> drawFunc, std::function<void()> setupFunc);
27  ~ImGuiRenderer();
28 
30  void Init();
31 
33  void Destroy();
34 
36  void NewFrame();
37 
39  void DoFrame();
40 
41  bool OnMouseDown(float x, float y, const IMouseMod &mod);
42  bool OnMouseUp(float x, float y, const IMouseMod &mod);
43  bool OnMouseWheel(float x, float y, const IMouseMod &mod, float delta);
44  void OnMouseMove(float x, float y, const IMouseMod &mod);
45  bool OnKeyDown(float x, float y, const IKeyPress &key);
46  bool OnKeyUp(float x, float y, const IKeyPress &key);
47 
48  std::function<void(IGraphics*)> GetDrawFunc()
49  {
50  return mDrawFunc;
51  }
52 
53  #ifdef IGRAPHICS_SKIA
54  SkPaint fFontPaint;
55  #endif
56 
57 private:
58  ImGuiContext* mCtx = nullptr;
59  IGraphics* mGraphics;
60  std::function<void(IGraphics*)> mDrawFunc = nullptr;
61  friend IGraphics;
62 };
63 
64 END_IGRAPHICS_NAMESPACE
65 END_IPLUG_NAMESPACE
66 
67 #endif
Used to manage mouse modifiers i.e.
The lowest level base class of an IGraphics context.
Definition: IGraphics.h:86
Used for key press info, such as ASCII representation, virtual key (mapped to win32 codes) and modifi...
Definition: IPlugStructs.h:612