1 /* 2 * DISTRHO Plugin Framework (DPF) 3 * Copyright (C) 2021 Jean Pierre Cimalando <jp-dev@inbox.ru> 4 * 5 * Permission to use, copy, modify, and/or distribute this software for any purpose with 6 * or without fee is hereby granted, provided that the above copyright notice and this 7 * permission notice appear in all copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD 10 * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN 11 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 12 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER 13 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 */ 16 17 #pragma once 18 19 #include "TopLevelWidget.hpp" 20 #include "Color.hpp" 21 22 #ifndef DGL_OPENGL 23 # error ImGUI is only available in OpenGL mode 24 #endif 25 26 START_NAMESPACE_DGL 27 28 /** 29 ImGui user interface class. 30 */ 31 class ImGuiUI : public TopLevelWidget, 32 public IdleCallback { 33 public: 34 ImGuiUI(Window& windowToMapTo); 35 ~ImGuiUI() override; 36 void setBackgroundColor(Color color); 37 void setRepaintInterval(int intervalMs); 38 39 protected: 40 virtual void onImGuiDisplay() = 0; 41 42 virtual void onDisplay() override; 43 virtual bool onKeyboard(const KeyboardEvent& event) override; 44 virtual bool onSpecial(const SpecialEvent& event) override; 45 virtual bool onMouse(const MouseEvent& event) override; 46 virtual bool onMotion(const MotionEvent& event) override; 47 virtual bool onScroll(const ScrollEvent& event) override; 48 virtual void onResize(const ResizeEvent& event) override; 49 virtual void idleCallback() override; 50 51 private: 52 struct Impl; 53 Impl* fImpl; 54 }; 55 56 END_NAMESPACE_DGL 57