From 1fb245c581e79def12815dc7970ebb61310138ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D1=9F=D0=B8=D1=9B?= Date: Fri, 2 Apr 2021 12:51:59 -0700 Subject: [PATCH] Cleanup. --- examples/common/imgui/imgui.cpp | 16 ++++++++++++++++ examples/common/imgui/imgui.h | 19 +++++++------------ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/examples/common/imgui/imgui.cpp b/examples/common/imgui/imgui.cpp index 5dda5ea59..d6913b8af 100644 --- a/examples/common/imgui/imgui.cpp +++ b/examples/common/imgui/imgui.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include "imgui.h" #include "../bgfx_utils.h" @@ -443,6 +444,21 @@ namespace ImGui { PushFont(s_ctx.m_font[_font]); } + + void PushEnabled(bool _enabled) + { + extern void PushItemFlag(int option, bool enabled); + PushItemFlag(ImGuiItemFlags_Disabled, !_enabled); + PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * (_enabled ? 1.0f : 0.5f) ); + } + + void PopEnabled() + { + extern void PopItemFlag(); + PopItemFlag(); + PopStyleVar(); + } + } // namespace ImGui BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4505); // error C4505: '' : unreferenced local function has been removed diff --git a/examples/common/imgui/imgui.h b/examples/common/imgui/imgui.h index 0106e5cc0..c79d39f13 100644 --- a/examples/common/imgui/imgui.h +++ b/examples/common/imgui/imgui.h @@ -41,6 +41,7 @@ namespace ImGui #define IMGUI_FLAGS_NONE UINT8_C(0x00) #define IMGUI_FLAGS_ALPHA_BLEND UINT8_C(0x01) + /// inline ImTextureID toId(bgfx::TextureHandle _handle, uint8_t _flags, uint8_t _mip) { union { struct { bgfx::TextureHandle handle; uint8_t flags; uint8_t mip; } s; ImTextureID id; } tex; @@ -104,11 +105,13 @@ namespace ImGui return ImageButton(_handle, IMGUI_FLAGS_ALPHA_BLEND, 0, _size, _uv0, _uv1, _framePadding, _bgCol, _tintCol); } + /// inline void NextLine() { SetCursorPosY(GetCursorPosY() + GetTextLineHeightWithSpacing() ); } + /// inline bool MouseOverArea() { return false @@ -119,19 +122,11 @@ namespace ImGui ; } - inline void PushEnabled(bool _enabled) - { - extern void PushItemFlag(int option, bool enabled); - PushItemFlag(1<<2 /*ImGuiItemFlags_Disabled*/, !_enabled); - PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * (_enabled ? 1.0f : 0.5f) ); - } + /// + void PushEnabled(bool _enabled); - inline void PopEnabled() - { - extern void PopItemFlag(); - PopItemFlag(); - PopStyleVar(); - } + /// + void PopEnabled(); } // namespace ImGui