diff options
Diffstat (limited to '3rdparty/bgfx/examples/common/imgui/imgui.h')
-rw-r--r-- | 3rdparty/bgfx/examples/common/imgui/imgui.h | 69 |
1 files changed, 62 insertions, 7 deletions
diff --git a/3rdparty/bgfx/examples/common/imgui/imgui.h b/3rdparty/bgfx/examples/common/imgui/imgui.h index cb0622319ef..e85b9d3a16a 100644 --- a/3rdparty/bgfx/examples/common/imgui/imgui.h +++ b/3rdparty/bgfx/examples/common/imgui/imgui.h @@ -26,11 +26,13 @@ #ifndef IMGUI_H_HEADER_GUARD #define IMGUI_H_HEADER_GUARD -#include <bgfx.h> +#include <bgfx/bgfx.h> #include <ocornut-imgui/imgui.h> +#include <ocornut-imgui/imgui_wm.h> -#define IMGUI_MBUT_LEFT 0x01 -#define IMGUI_MBUT_RIGHT 0x02 +#define IMGUI_MBUT_LEFT 0x01 +#define IMGUI_MBUT_RIGHT 0x02 +#define IMGUI_MBUT_MIDDLE 0x04 /// For custom values, define these macros before including imgui.h @@ -206,12 +208,65 @@ bool imguiMouseOverArea(); namespace ImGui { +#define IMGUI_FLAGS_NONE UINT16_C(0x0000) +#define IMGUI_FLAGS_ALPHA_BLEND UINT16_C(0x0001) + + // Helper function for passing bgfx::TextureHandle to ImGui::Image. + inline void Image(bgfx::TextureHandle _handle + , uint16_t _flags + , const ImVec2& _size + , const ImVec2& _uv0 = ImVec2(0.0f, 0.0f) + , const ImVec2& _uv1 = ImVec2(1.0f, 1.0f) + , const ImVec4& _tintCol = ImVec4(1.0f, 1.0f, 1.0f, 1.0f) + , const ImVec4& _borderCol = ImVec4(0.0f, 0.0f, 0.0f, 0.0f) + ) + { + union { struct { uint16_t flags; bgfx::TextureHandle handle; } s; ImTextureID ptr; } texture; + texture.s.flags = _flags; + texture.s.handle = _handle; + Image(texture.ptr, _size, _uv0, _uv1, _tintCol, _borderCol); + } + // Helper function for passing bgfx::TextureHandle to ImGui::Image. - inline void Image(bgfx::TextureHandle _handle, const ImVec2& _size, const ImVec2& _uv0 = ImVec2(0, 0), const ImVec2& _uv1 = ImVec2(1, 1), const ImVec4& _tint_col = ImVec4(1, 1, 1, 1), const ImVec4& _border_col = ImVec4(0, 0, 0, 0)) + inline void Image(bgfx::TextureHandle _handle + , const ImVec2& _size + , const ImVec2& _uv0 = ImVec2(0.0f, 0.0f) + , const ImVec2& _uv1 = ImVec2(1.0f, 1.0f) + , const ImVec4& _tintCol = ImVec4(1.0f, 1.0f, 1.0f, 1.0f) + , const ImVec4& _borderCol = ImVec4(0.0f, 0.0f, 0.0f, 0.0f) + ) + { + Image(_handle, IMGUI_FLAGS_ALPHA_BLEND, _size, _uv0, _uv1, _tintCol, _borderCol); + } + + // Helper function for passing bgfx::TextureHandle to ImGui::ImageButton. + inline bool ImageButton(bgfx::TextureHandle _handle + , uint16_t _flags + , const ImVec2& _size + , const ImVec2& _uv0 = ImVec2(0.0f, 0.0f) + , const ImVec2& _uv1 = ImVec2(1.0f, 1.0f) + , int _framePadding = -1 + , const ImVec4& _bgCol = ImVec4(0.0f, 0.0f, 0.0f, 0.0f) + , const ImVec4& _tintCol = ImVec4(1.0f, 1.0f, 1.0f, 1.0f) + ) + { + union { struct { uint16_t flags; bgfx::TextureHandle handle; } s; ImTextureID ptr; } texture; + texture.s.flags = _flags; + texture.s.handle = _handle; + return ImageButton(texture.ptr, _size, _uv0, _uv1, _framePadding, _bgCol, _tintCol); + } + + // Helper function for passing bgfx::TextureHandle to ImGui::ImageButton. + inline bool ImageButton(bgfx::TextureHandle _handle + , const ImVec2& _size + , const ImVec2& _uv0 = ImVec2(0.0f, 0.0f) + , const ImVec2& _uv1 = ImVec2(1.0f, 1.0f) + , int _framePadding = -1 + , const ImVec4& _bgCol = ImVec4(0.0f, 0.0f, 0.0f, 0.0f) + , const ImVec4& _tintCol = ImVec4(1.0f, 1.0f, 1.0f, 1.0f) + ) { - union { bgfx::TextureHandle handle; ImTextureID ptr; } texture; - texture.handle = _handle; - Image(texture.ptr, _size, _uv0, _uv1, _tint_col, _border_col); + return ImageButton(_handle, IMGUI_FLAGS_ALPHA_BLEND, _size, _uv0, _uv1, _framePadding, _bgCol, _tintCol); } } // namespace ImGui |