From 103f0c2ab0c9c4c54d168b98a86bc10d0dac0449 Mon Sep 17 00:00:00 2001 From: assiduous Date: Thu, 30 Jan 2020 19:38:22 -0800 Subject: Renamed .h -> .hpp where appropriate --- Imgui/interface/ImGuiImplAndroid.h | 67 ------------------ Imgui/interface/ImGuiImplAndroid.hpp | 67 ++++++++++++++++++ Imgui/interface/ImGuiImplDiligent.h | 76 -------------------- Imgui/interface/ImGuiImplDiligent.hpp | 76 ++++++++++++++++++++ Imgui/interface/ImGuiImplIOS.h | 65 ----------------- Imgui/interface/ImGuiImplIOS.hpp | 65 +++++++++++++++++ Imgui/interface/ImGuiImplLinuxX11.h | 64 ----------------- Imgui/interface/ImGuiImplLinuxX11.hpp | 64 +++++++++++++++++ Imgui/interface/ImGuiImplLinuxXCB.h | 71 ------------------- Imgui/interface/ImGuiImplLinuxXCB.hpp | 71 +++++++++++++++++++ Imgui/interface/ImGuiImplMacOS.h | 67 ------------------ Imgui/interface/ImGuiImplMacOS.hpp | 67 ++++++++++++++++++ Imgui/interface/ImGuiImplUWP.h | 70 ------------------ Imgui/interface/ImGuiImplUWP.hpp | 70 ++++++++++++++++++ Imgui/interface/ImGuiImplWin32.h | 59 ---------------- Imgui/interface/ImGuiImplWin32.hpp | 59 ++++++++++++++++ Imgui/interface/ImGuiUtils.h | 129 ---------------------------------- Imgui/interface/ImGuiUtils.hpp | 129 ++++++++++++++++++++++++++++++++++ 18 files changed, 668 insertions(+), 668 deletions(-) delete mode 100644 Imgui/interface/ImGuiImplAndroid.h create mode 100644 Imgui/interface/ImGuiImplAndroid.hpp delete mode 100644 Imgui/interface/ImGuiImplDiligent.h create mode 100644 Imgui/interface/ImGuiImplDiligent.hpp delete mode 100644 Imgui/interface/ImGuiImplIOS.h create mode 100644 Imgui/interface/ImGuiImplIOS.hpp delete mode 100644 Imgui/interface/ImGuiImplLinuxX11.h create mode 100644 Imgui/interface/ImGuiImplLinuxX11.hpp delete mode 100644 Imgui/interface/ImGuiImplLinuxXCB.h create mode 100644 Imgui/interface/ImGuiImplLinuxXCB.hpp delete mode 100644 Imgui/interface/ImGuiImplMacOS.h create mode 100644 Imgui/interface/ImGuiImplMacOS.hpp delete mode 100644 Imgui/interface/ImGuiImplUWP.h create mode 100644 Imgui/interface/ImGuiImplUWP.hpp delete mode 100644 Imgui/interface/ImGuiImplWin32.h create mode 100644 Imgui/interface/ImGuiImplWin32.hpp delete mode 100644 Imgui/interface/ImGuiUtils.h create mode 100644 Imgui/interface/ImGuiUtils.hpp (limited to 'Imgui/interface') diff --git a/Imgui/interface/ImGuiImplAndroid.h b/Imgui/interface/ImGuiImplAndroid.h deleted file mode 100644 index 05d53e7..0000000 --- a/Imgui/interface/ImGuiImplAndroid.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2019-2020 Diligent Graphics LLC - * Copyright 2015-2019 Egor Yusov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once - -#include -#include - -#include "ImGuiImplDiligent.h" - -namespace Diligent -{ - -class ImGuiImplAndroid final : public ImGuiImplDiligent -{ -public: - ImGuiImplAndroid(IRenderDevice* pDevice, - TEXTURE_FORMAT BackBufferFmt, - TEXTURE_FORMAT DepthBufferFmt, - Uint32 DisplayWidht, - Uint32 DisplayHeight, - Uint32 InitialVertexBufferSize = ImGuiImplDiligent::DefaultInitialVBSize, - Uint32 InitialIndexBufferSize = ImGuiImplDiligent::DefaultInitialIBSize); - ~ImGuiImplAndroid(); - - // clang-format off - ImGuiImplAndroid (const ImGuiImplAndroid&) = delete; - ImGuiImplAndroid ( ImGuiImplAndroid&&) = delete; - ImGuiImplAndroid& operator = (const ImGuiImplAndroid&) = delete; - ImGuiImplAndroid& operator = ( ImGuiImplAndroid&&) = delete; - // clang-format on - - virtual void NewFrame() override final; - - bool BeginDrag(float x, float y); - bool DragMove(float x, float y); - bool EndDrag(); - -private: - std::chrono::time_point m_LastTimestamp = {}; -}; - -} // namespace Diligent diff --git a/Imgui/interface/ImGuiImplAndroid.hpp b/Imgui/interface/ImGuiImplAndroid.hpp new file mode 100644 index 0000000..6a0fc5d --- /dev/null +++ b/Imgui/interface/ImGuiImplAndroid.hpp @@ -0,0 +1,67 @@ +/* + * Copyright 2019-2020 Diligent Graphics LLC + * Copyright 2015-2019 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include +#include + +#include "ImGuiImplDiligent.hpp" + +namespace Diligent +{ + +class ImGuiImplAndroid final : public ImGuiImplDiligent +{ +public: + ImGuiImplAndroid(IRenderDevice* pDevice, + TEXTURE_FORMAT BackBufferFmt, + TEXTURE_FORMAT DepthBufferFmt, + Uint32 DisplayWidht, + Uint32 DisplayHeight, + Uint32 InitialVertexBufferSize = ImGuiImplDiligent::DefaultInitialVBSize, + Uint32 InitialIndexBufferSize = ImGuiImplDiligent::DefaultInitialIBSize); + ~ImGuiImplAndroid(); + + // clang-format off + ImGuiImplAndroid (const ImGuiImplAndroid&) = delete; + ImGuiImplAndroid ( ImGuiImplAndroid&&) = delete; + ImGuiImplAndroid& operator = (const ImGuiImplAndroid&) = delete; + ImGuiImplAndroid& operator = ( ImGuiImplAndroid&&) = delete; + // clang-format on + + virtual void NewFrame() override final; + + bool BeginDrag(float x, float y); + bool DragMove(float x, float y); + bool EndDrag(); + +private: + std::chrono::time_point m_LastTimestamp = {}; +}; + +} // namespace Diligent diff --git a/Imgui/interface/ImGuiImplDiligent.h b/Imgui/interface/ImGuiImplDiligent.h deleted file mode 100644 index 542e76f..0000000 --- a/Imgui/interface/ImGuiImplDiligent.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2019-2020 Diligent Graphics LLC - * Copyright 2015-2019 Egor Yusov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once - -#include -#include "../../../DiligentCore/Primitives/interface/BasicTypes.h" - -namespace Diligent -{ - -struct IRenderDevice; -struct IDeviceContext; -enum TEXTURE_FORMAT : Uint16; - -class ImGuiImplDiligent_Internal; - -class ImGuiImplDiligent -{ -public: - static constexpr Uint32 DefaultInitialVBSize = 1024; - static constexpr Uint32 DefaultInitialIBSize = 2048; - - ImGuiImplDiligent(IRenderDevice* pDevice, - TEXTURE_FORMAT BackBufferFmt, - TEXTURE_FORMAT DepthBufferFmt, - Uint32 InitialVertexBufferSize = DefaultInitialVBSize, - Uint32 InitialIndexBufferSize = DefaultInitialIBSize); - virtual ~ImGuiImplDiligent(); - - // clang-format off - ImGuiImplDiligent (const ImGuiImplDiligent&) = delete; - ImGuiImplDiligent ( ImGuiImplDiligent&&) = delete; - ImGuiImplDiligent& operator = (const ImGuiImplDiligent&) = delete; - ImGuiImplDiligent& operator = ( ImGuiImplDiligent&&) = delete; - // clang-format on - - virtual void NewFrame(); - virtual void EndFrame(); - virtual void Render(IDeviceContext* pCtx); - - // Use if you want to reset your rendering device without losing ImGui state. - void InvalidateDeviceObjects(); - void CreateDeviceObjects(); - - void UpdateFontsTexture(); - -private: - std::unique_ptr m_pImpl; -}; - -} // namespace Diligent diff --git a/Imgui/interface/ImGuiImplDiligent.hpp b/Imgui/interface/ImGuiImplDiligent.hpp new file mode 100644 index 0000000..542e76f --- /dev/null +++ b/Imgui/interface/ImGuiImplDiligent.hpp @@ -0,0 +1,76 @@ +/* + * Copyright 2019-2020 Diligent Graphics LLC + * Copyright 2015-2019 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include +#include "../../../DiligentCore/Primitives/interface/BasicTypes.h" + +namespace Diligent +{ + +struct IRenderDevice; +struct IDeviceContext; +enum TEXTURE_FORMAT : Uint16; + +class ImGuiImplDiligent_Internal; + +class ImGuiImplDiligent +{ +public: + static constexpr Uint32 DefaultInitialVBSize = 1024; + static constexpr Uint32 DefaultInitialIBSize = 2048; + + ImGuiImplDiligent(IRenderDevice* pDevice, + TEXTURE_FORMAT BackBufferFmt, + TEXTURE_FORMAT DepthBufferFmt, + Uint32 InitialVertexBufferSize = DefaultInitialVBSize, + Uint32 InitialIndexBufferSize = DefaultInitialIBSize); + virtual ~ImGuiImplDiligent(); + + // clang-format off + ImGuiImplDiligent (const ImGuiImplDiligent&) = delete; + ImGuiImplDiligent ( ImGuiImplDiligent&&) = delete; + ImGuiImplDiligent& operator = (const ImGuiImplDiligent&) = delete; + ImGuiImplDiligent& operator = ( ImGuiImplDiligent&&) = delete; + // clang-format on + + virtual void NewFrame(); + virtual void EndFrame(); + virtual void Render(IDeviceContext* pCtx); + + // Use if you want to reset your rendering device without losing ImGui state. + void InvalidateDeviceObjects(); + void CreateDeviceObjects(); + + void UpdateFontsTexture(); + +private: + std::unique_ptr m_pImpl; +}; + +} // namespace Diligent diff --git a/Imgui/interface/ImGuiImplIOS.h b/Imgui/interface/ImGuiImplIOS.h deleted file mode 100644 index f558f5c..0000000 --- a/Imgui/interface/ImGuiImplIOS.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2019-2020 Diligent Graphics LLC - * Copyright 2015-2019 Egor Yusov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once - -#include -#include "ImGuiImplDiligent.h" - -namespace Diligent -{ - -class ImGuiImplIOS final : public ImGuiImplDiligent -{ -public: - ImGuiImplIOS(IRenderDevice* pDevice, - TEXTURE_FORMAT BackBufferFmt, - TEXTURE_FORMAT DepthBufferFmt, - Uint32 DisplayWidth, - Uint32 DisplayHeight, - Uint32 InitialVertexBufferSize = ImGuiImplDiligent::DefaultInitialVBSize, - Uint32 InitialIndexBufferSize = ImGuiImplDiligent::DefaultInitialIBSize); - ~ImGuiImplIOS(); - - // clang-format off - ImGuiImplIOS (const ImGuiImplIOS&) = delete; - ImGuiImplIOS ( ImGuiImplIOS&&) = delete; - ImGuiImplIOS& operator = (const ImGuiImplIOS&) = delete; - ImGuiImplIOS& operator = ( ImGuiImplIOS&&) = delete; - // clang-format on - - virtual void NewFrame() override final; - virtual void Render(IDeviceContext* pCtx) override final; - void SetDisplaySize(Uint32 DisplayWidth, Uint32 DisplayHeight); - bool OnTouchEvent(float x, float y, bool IsActive); - -private: - std::mutex m_Mtx; - double m_Time = 0.0; -}; - -} // namespace Diligent diff --git a/Imgui/interface/ImGuiImplIOS.hpp b/Imgui/interface/ImGuiImplIOS.hpp new file mode 100644 index 0000000..0f53f68 --- /dev/null +++ b/Imgui/interface/ImGuiImplIOS.hpp @@ -0,0 +1,65 @@ +/* + * Copyright 2019-2020 Diligent Graphics LLC + * Copyright 2015-2019 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include +#include "ImGuiImplDiligent.hpp" + +namespace Diligent +{ + +class ImGuiImplIOS final : public ImGuiImplDiligent +{ +public: + ImGuiImplIOS(IRenderDevice* pDevice, + TEXTURE_FORMAT BackBufferFmt, + TEXTURE_FORMAT DepthBufferFmt, + Uint32 DisplayWidth, + Uint32 DisplayHeight, + Uint32 InitialVertexBufferSize = ImGuiImplDiligent::DefaultInitialVBSize, + Uint32 InitialIndexBufferSize = ImGuiImplDiligent::DefaultInitialIBSize); + ~ImGuiImplIOS(); + + // clang-format off + ImGuiImplIOS (const ImGuiImplIOS&) = delete; + ImGuiImplIOS ( ImGuiImplIOS&&) = delete; + ImGuiImplIOS& operator = (const ImGuiImplIOS&) = delete; + ImGuiImplIOS& operator = ( ImGuiImplIOS&&) = delete; + // clang-format on + + virtual void NewFrame() override final; + virtual void Render(IDeviceContext* pCtx) override final; + void SetDisplaySize(Uint32 DisplayWidth, Uint32 DisplayHeight); + bool OnTouchEvent(float x, float y, bool IsActive); + +private: + std::mutex m_Mtx; + double m_Time = 0.0; +}; + +} // namespace Diligent diff --git a/Imgui/interface/ImGuiImplLinuxX11.h b/Imgui/interface/ImGuiImplLinuxX11.h deleted file mode 100644 index e582e9d..0000000 --- a/Imgui/interface/ImGuiImplLinuxX11.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2019-2020 Diligent Graphics LLC - * Copyright 2015-2019 Egor Yusov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once - -#include -#include - -#include "ImGuiImplDiligent.h" - -namespace Diligent -{ - -class ImGuiImplLinuxX11 final : public ImGuiImplDiligent -{ -public: - ImGuiImplLinuxX11(IRenderDevice* pDevice, - TEXTURE_FORMAT BackBufferFmt, - TEXTURE_FORMAT DepthBufferFmt, - Uint32 DisplayWidht, - Uint32 DisplayHeight, - Uint32 InitialVertexBufferSize = ImGuiImplDiligent::DefaultInitialVBSize, - Uint32 InitialIndexBufferSize = ImGuiImplDiligent::DefaultInitialIBSize); - ~ImGuiImplLinuxX11(); - - // clang-format off - ImGuiImplLinuxX11 (const ImGuiImplLinuxX11&) = delete; - ImGuiImplLinuxX11 ( ImGuiImplLinuxX11&&) = delete; - ImGuiImplLinuxX11& operator = (const ImGuiImplLinuxX11&) = delete; - ImGuiImplLinuxX11& operator = ( ImGuiImplLinuxX11&&) = delete; - // clang-format on - - bool HandleXEvent(XEvent* event); - virtual void NewFrame() override final; - -private: - std::chrono::time_point m_LastTimestamp = {}; -}; - -} // namespace Diligent diff --git a/Imgui/interface/ImGuiImplLinuxX11.hpp b/Imgui/interface/ImGuiImplLinuxX11.hpp new file mode 100644 index 0000000..df073f2 --- /dev/null +++ b/Imgui/interface/ImGuiImplLinuxX11.hpp @@ -0,0 +1,64 @@ +/* + * Copyright 2019-2020 Diligent Graphics LLC + * Copyright 2015-2019 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include +#include + +#include "ImGuiImplDiligent.hpp" + +namespace Diligent +{ + +class ImGuiImplLinuxX11 final : public ImGuiImplDiligent +{ +public: + ImGuiImplLinuxX11(IRenderDevice* pDevice, + TEXTURE_FORMAT BackBufferFmt, + TEXTURE_FORMAT DepthBufferFmt, + Uint32 DisplayWidht, + Uint32 DisplayHeight, + Uint32 InitialVertexBufferSize = ImGuiImplDiligent::DefaultInitialVBSize, + Uint32 InitialIndexBufferSize = ImGuiImplDiligent::DefaultInitialIBSize); + ~ImGuiImplLinuxX11(); + + // clang-format off + ImGuiImplLinuxX11 (const ImGuiImplLinuxX11&) = delete; + ImGuiImplLinuxX11 ( ImGuiImplLinuxX11&&) = delete; + ImGuiImplLinuxX11& operator = (const ImGuiImplLinuxX11&) = delete; + ImGuiImplLinuxX11& operator = ( ImGuiImplLinuxX11&&) = delete; + // clang-format on + + bool HandleXEvent(XEvent* event); + virtual void NewFrame() override final; + +private: + std::chrono::time_point m_LastTimestamp = {}; +}; + +} // namespace Diligent diff --git a/Imgui/interface/ImGuiImplLinuxXCB.h b/Imgui/interface/ImGuiImplLinuxXCB.h deleted file mode 100644 index 92e612f..0000000 --- a/Imgui/interface/ImGuiImplLinuxXCB.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2019-2020 Diligent Graphics LLC - * Copyright 2015-2019 Egor Yusov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once - -#include -#include - -#include "ImGuiImplDiligent.h" - -struct _XCBKeySymbols; - -namespace Diligent -{ - -class ImGuiImplLinuxXCB final : public ImGuiImplDiligent -{ -public: - ImGuiImplLinuxXCB(xcb_connection_t* connection, - IRenderDevice* pDevice, - TEXTURE_FORMAT BackBufferFmt, - TEXTURE_FORMAT DepthBufferFmt, - Uint32 DisplayWidht, - Uint32 DisplayHeight, - Uint32 InitialVertexBufferSize = ImGuiImplDiligent::DefaultInitialVBSize, - Uint32 InitialIndexBufferSize = ImGuiImplDiligent::DefaultInitialIBSize); - ~ImGuiImplLinuxXCB(); - - // clang-format off - ImGuiImplLinuxXCB (const ImGuiImplLinuxXCB&) = delete; - ImGuiImplLinuxXCB ( ImGuiImplLinuxXCB&&) = delete; - ImGuiImplLinuxXCB& operator = (const ImGuiImplLinuxXCB&) = delete; - ImGuiImplLinuxXCB& operator = ( ImGuiImplLinuxXCB&&) = delete; - // clang-format on - - bool HandleXCBEvent(xcb_generic_event_t* event); - virtual void NewFrame() override final; - -private: - void HandleKeyEvent(xcb_key_release_event_t* event); - - _XCBKeySymbols* m_syms = nullptr; - - std::chrono::time_point m_LastTimestamp = {}; -}; - -} // namespace Diligent diff --git a/Imgui/interface/ImGuiImplLinuxXCB.hpp b/Imgui/interface/ImGuiImplLinuxXCB.hpp new file mode 100644 index 0000000..ef0b725 --- /dev/null +++ b/Imgui/interface/ImGuiImplLinuxXCB.hpp @@ -0,0 +1,71 @@ +/* + * Copyright 2019-2020 Diligent Graphics LLC + * Copyright 2015-2019 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include +#include + +#include "ImGuiImplDiligent.hpp" + +struct _XCBKeySymbols; + +namespace Diligent +{ + +class ImGuiImplLinuxXCB final : public ImGuiImplDiligent +{ +public: + ImGuiImplLinuxXCB(xcb_connection_t* connection, + IRenderDevice* pDevice, + TEXTURE_FORMAT BackBufferFmt, + TEXTURE_FORMAT DepthBufferFmt, + Uint32 DisplayWidht, + Uint32 DisplayHeight, + Uint32 InitialVertexBufferSize = ImGuiImplDiligent::DefaultInitialVBSize, + Uint32 InitialIndexBufferSize = ImGuiImplDiligent::DefaultInitialIBSize); + ~ImGuiImplLinuxXCB(); + + // clang-format off + ImGuiImplLinuxXCB (const ImGuiImplLinuxXCB&) = delete; + ImGuiImplLinuxXCB ( ImGuiImplLinuxXCB&&) = delete; + ImGuiImplLinuxXCB& operator = (const ImGuiImplLinuxXCB&) = delete; + ImGuiImplLinuxXCB& operator = ( ImGuiImplLinuxXCB&&) = delete; + // clang-format on + + bool HandleXCBEvent(xcb_generic_event_t* event); + virtual void NewFrame() override final; + +private: + void HandleKeyEvent(xcb_key_release_event_t* event); + + _XCBKeySymbols* m_syms = nullptr; + + std::chrono::time_point m_LastTimestamp = {}; +}; + +} // namespace Diligent diff --git a/Imgui/interface/ImGuiImplMacOS.h b/Imgui/interface/ImGuiImplMacOS.h deleted file mode 100644 index 082d68f..0000000 --- a/Imgui/interface/ImGuiImplMacOS.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2019-2020 Diligent Graphics LLC - * Copyright 2015-2019 Egor Yusov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once - -#include -#include "ImGuiImplDiligent.h" - -@class NSEvent; -@class NSView; - -namespace Diligent -{ - -class ImGuiImplMacOS final : public ImGuiImplDiligent -{ -public: - ImGuiImplMacOS(IRenderDevice* _Nonnull pDevice, - TEXTURE_FORMAT BackBufferFmt, - TEXTURE_FORMAT DepthBufferFmt, - Uint32 DisplayWidth, - Uint32 DisplayHeight, - Uint32 InitialVertexBufferSize = ImGuiImplDiligent::DefaultInitialVBSize, - Uint32 InitialIndexBufferSize = ImGuiImplDiligent::DefaultInitialIBSize); - ~ImGuiImplMacOS(); - - // clang-format off - ImGuiImplMacOS (const ImGuiImplMacOS&) = delete; - ImGuiImplMacOS ( ImGuiImplMacOS&&) = delete; - ImGuiImplMacOS& operator = (const ImGuiImplMacOS&) = delete; - ImGuiImplMacOS& operator = ( ImGuiImplMacOS&&) = delete; - // clang-format on - - virtual void NewFrame()override final; - virtual void Render(IDeviceContext* _Nonnull pCtx)override final; - bool HandleOSXEvent(NSEvent* _Nonnull event, NSView* _Nonnull view); - void SetDisplaySize(Uint32 DisplayWidth, Uint32 DisplayHeight); - -private: - std::mutex m_Mtx; -}; - -} diff --git a/Imgui/interface/ImGuiImplMacOS.hpp b/Imgui/interface/ImGuiImplMacOS.hpp new file mode 100644 index 0000000..dc63de5 --- /dev/null +++ b/Imgui/interface/ImGuiImplMacOS.hpp @@ -0,0 +1,67 @@ +/* + * Copyright 2019-2020 Diligent Graphics LLC + * Copyright 2015-2019 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include +#include "ImGuiImplDiligent.hpp" + +@class NSEvent; +@class NSView; + +namespace Diligent +{ + +class ImGuiImplMacOS final : public ImGuiImplDiligent +{ +public: + ImGuiImplMacOS(IRenderDevice* _Nonnull pDevice, + TEXTURE_FORMAT BackBufferFmt, + TEXTURE_FORMAT DepthBufferFmt, + Uint32 DisplayWidth, + Uint32 DisplayHeight, + Uint32 InitialVertexBufferSize = ImGuiImplDiligent::DefaultInitialVBSize, + Uint32 InitialIndexBufferSize = ImGuiImplDiligent::DefaultInitialIBSize); + ~ImGuiImplMacOS(); + + // clang-format off + ImGuiImplMacOS (const ImGuiImplMacOS&) = delete; + ImGuiImplMacOS ( ImGuiImplMacOS&&) = delete; + ImGuiImplMacOS& operator = (const ImGuiImplMacOS&) = delete; + ImGuiImplMacOS& operator = ( ImGuiImplMacOS&&) = delete; + // clang-format on + + virtual void NewFrame() override final; + virtual void Render(IDeviceContext* _Nonnull pCtx) override final; + bool HandleOSXEvent(NSEvent* _Nonnull event, NSView* _Nonnull view); + void SetDisplaySize(Uint32 DisplayWidth, Uint32 DisplayHeight); + +private: + std::mutex m_Mtx; +}; + +} // namespace Diligent diff --git a/Imgui/interface/ImGuiImplUWP.h b/Imgui/interface/ImGuiImplUWP.h deleted file mode 100644 index 9927016..0000000 --- a/Imgui/interface/ImGuiImplUWP.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2019-2020 Diligent Graphics LLC - * Copyright 2015-2019 Egor Yusov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once - -#include -#include "ImGuiImplDiligent.h" - -namespace Diligent -{ - -class ImGuiImplUWP final : public ImGuiImplDiligent -{ -public: - ImGuiImplUWP(IRenderDevice* pDevice, - TEXTURE_FORMAT BackBufferFmt, - TEXTURE_FORMAT DepthBufferFmt, - Uint32 DisplayWidth, - Uint32 DisplayHeight, - Uint32 InitialVertexBufferSize = ImGuiImplDiligent::DefaultInitialVBSize, - Uint32 InitialIndexBufferSize = ImGuiImplDiligent::DefaultInitialIBSize); - ~ImGuiImplUWP(); - - // clang-format off - ImGuiImplUWP (const ImGuiImplUWP&) = delete; - ImGuiImplUWP ( ImGuiImplUWP&&) = delete; - ImGuiImplUWP& operator = (const ImGuiImplUWP&) = delete; - ImGuiImplUWP& operator = ( ImGuiImplUWP&&) = delete; - // clang-format on - - virtual void NewFrame() override final; - - void SetDisplaySize(Uint32 DisplayWidth, Uint32 DisplayHeight) - { - m_DisplayWidth = DisplayWidth; - m_DisplayHeight = DisplayHeight; - } - -private: - INT64 m_Time = 0; - INT64 m_TicksPerSecond = 0; - Uint32 m_DisplayWidth = 0; - Uint32 m_DisplayHeight = 0; -}; - -} // namespace Diligent diff --git a/Imgui/interface/ImGuiImplUWP.hpp b/Imgui/interface/ImGuiImplUWP.hpp new file mode 100644 index 0000000..e3197f7 --- /dev/null +++ b/Imgui/interface/ImGuiImplUWP.hpp @@ -0,0 +1,70 @@ +/* + * Copyright 2019-2020 Diligent Graphics LLC + * Copyright 2015-2019 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include +#include "ImGuiImplDiligent.hpp" + +namespace Diligent +{ + +class ImGuiImplUWP final : public ImGuiImplDiligent +{ +public: + ImGuiImplUWP(IRenderDevice* pDevice, + TEXTURE_FORMAT BackBufferFmt, + TEXTURE_FORMAT DepthBufferFmt, + Uint32 DisplayWidth, + Uint32 DisplayHeight, + Uint32 InitialVertexBufferSize = ImGuiImplDiligent::DefaultInitialVBSize, + Uint32 InitialIndexBufferSize = ImGuiImplDiligent::DefaultInitialIBSize); + ~ImGuiImplUWP(); + + // clang-format off + ImGuiImplUWP (const ImGuiImplUWP&) = delete; + ImGuiImplUWP ( ImGuiImplUWP&&) = delete; + ImGuiImplUWP& operator = (const ImGuiImplUWP&) = delete; + ImGuiImplUWP& operator = ( ImGuiImplUWP&&) = delete; + // clang-format on + + virtual void NewFrame() override final; + + void SetDisplaySize(Uint32 DisplayWidth, Uint32 DisplayHeight) + { + m_DisplayWidth = DisplayWidth; + m_DisplayHeight = DisplayHeight; + } + +private: + INT64 m_Time = 0; + INT64 m_TicksPerSecond = 0; + Uint32 m_DisplayWidth = 0; + Uint32 m_DisplayHeight = 0; +}; + +} // namespace Diligent diff --git a/Imgui/interface/ImGuiImplWin32.h b/Imgui/interface/ImGuiImplWin32.h deleted file mode 100644 index 2fd760a..0000000 --- a/Imgui/interface/ImGuiImplWin32.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2019-2020 Diligent Graphics LLC - * Copyright 2015-2019 Egor Yusov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once - -#include -#include "ImGuiImplDiligent.h" - -namespace Diligent -{ - -class ImGuiImplWin32 final : public ImGuiImplDiligent -{ -public: - ImGuiImplWin32(HWND hWnd, - IRenderDevice* pDevice, - TEXTURE_FORMAT BackBufferFmt, - TEXTURE_FORMAT DepthBufferFmt, - Uint32 InitialVertexBufferSize = ImGuiImplDiligent::DefaultInitialVBSize, - Uint32 InitialIndexBufferSize = ImGuiImplDiligent::DefaultInitialIBSize); - ~ImGuiImplWin32(); - - LRESULT Win32_ProcHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); - - // clang-format off - ImGuiImplWin32 (const ImGuiImplWin32&) = delete; - ImGuiImplWin32 ( ImGuiImplWin32&&) = delete; - ImGuiImplWin32& operator = (const ImGuiImplWin32&) = delete; - ImGuiImplWin32& operator = ( ImGuiImplWin32&&) = delete; - // clang-format on - - virtual void NewFrame() override final; -}; - -} // namespace Diligent diff --git a/Imgui/interface/ImGuiImplWin32.hpp b/Imgui/interface/ImGuiImplWin32.hpp new file mode 100644 index 0000000..3249bb1 --- /dev/null +++ b/Imgui/interface/ImGuiImplWin32.hpp @@ -0,0 +1,59 @@ +/* + * Copyright 2019-2020 Diligent Graphics LLC + * Copyright 2015-2019 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include +#include "ImGuiImplDiligent.hpp" + +namespace Diligent +{ + +class ImGuiImplWin32 final : public ImGuiImplDiligent +{ +public: + ImGuiImplWin32(HWND hWnd, + IRenderDevice* pDevice, + TEXTURE_FORMAT BackBufferFmt, + TEXTURE_FORMAT DepthBufferFmt, + Uint32 InitialVertexBufferSize = ImGuiImplDiligent::DefaultInitialVBSize, + Uint32 InitialIndexBufferSize = ImGuiImplDiligent::DefaultInitialIBSize); + ~ImGuiImplWin32(); + + LRESULT Win32_ProcHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); + + // clang-format off + ImGuiImplWin32 (const ImGuiImplWin32&) = delete; + ImGuiImplWin32 ( ImGuiImplWin32&&) = delete; + ImGuiImplWin32& operator = (const ImGuiImplWin32&) = delete; + ImGuiImplWin32& operator = ( ImGuiImplWin32&&) = delete; + // clang-format on + + virtual void NewFrame() override final; +}; + +} // namespace Diligent diff --git a/Imgui/interface/ImGuiUtils.h b/Imgui/interface/ImGuiUtils.h deleted file mode 100644 index 3c2f68f..0000000 --- a/Imgui/interface/ImGuiUtils.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright 2019-2020 Diligent Graphics LLC - * Copyright 2015-2019 Egor Yusov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once - -#include -#include - -#include "../../ThirdParty/imgui/imgui.h" -#include "../../ThirdParty/imgui/imgui_internal.h" - -namespace Diligent -{ - -class ImGuiScopedDisabler -{ -public: - explicit ImGuiScopedDisabler(bool Disable, float AlphaScale = 0.25f) : - m_IsDisabled{Disable} - { - if (m_IsDisabled) - { - ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); - ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * AlphaScale); - } - } - - ~ImGuiScopedDisabler() - { - if (m_IsDisabled) - { - ImGui::PopItemFlag(); - ImGui::PopStyleVar(); - } - } - -private: - const bool m_IsDisabled; -}; - -} // namespace Diligent - -namespace ImGui -{ - -template -inline bool Checkbox(const char* label, T* v) -{ - bool b = *v != 0; - - auto pressed = Checkbox(label, &b); - if (pressed) - *v = b ? 1 : 0; - return pressed; -} - -inline void HelpMarker(const char* desc, bool IsSameLine = true, const char* marker = "(?)") -{ - if (IsSameLine) - SameLine(); - - TextDisabled("%s", marker); - if (IsItemHovered()) - { - BeginTooltip(); - PushTextWrapPos(GetFontSize() * 35.0f); - TextUnformatted(desc); - PopTextWrapPos(); - EndTooltip(); - } -} - -template ::is_integer>::type> -bool SliderIntT(const char* label, T* v, int v_min, int v_max, const char* format = "%d") -{ - int i = static_cast(*v); - - auto value_changed = ImGui::SliderInt(label, &i, v_min, v_max, format); - if (value_changed) - *v = static_cast(i); - return value_changed; -} - -template -bool Combo(const char* label, T* current_item, const std::pair items[], int items_count, int popup_max_height_in_items = -1) -{ - int item_idx = 0; - while (item_idx < items_count && items[item_idx].first != *current_item) - ++item_idx; - if (item_idx >= items_count) - { - UNEXPECTED("Current item was not found in the items list"); - return false; - } - std::vector names(items_count); - for (int i = 0; i < items_count; ++i) - names[i] = items[i].second; - auto value_changed = Combo(label, &item_idx, names.data(), items_count, popup_max_height_in_items); - if (value_changed) - *current_item = items[item_idx].first; - - return value_changed; -} - -} // namespace ImGui diff --git a/Imgui/interface/ImGuiUtils.hpp b/Imgui/interface/ImGuiUtils.hpp new file mode 100644 index 0000000..3c2f68f --- /dev/null +++ b/Imgui/interface/ImGuiUtils.hpp @@ -0,0 +1,129 @@ +/* + * Copyright 2019-2020 Diligent Graphics LLC + * Copyright 2015-2019 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include +#include + +#include "../../ThirdParty/imgui/imgui.h" +#include "../../ThirdParty/imgui/imgui_internal.h" + +namespace Diligent +{ + +class ImGuiScopedDisabler +{ +public: + explicit ImGuiScopedDisabler(bool Disable, float AlphaScale = 0.25f) : + m_IsDisabled{Disable} + { + if (m_IsDisabled) + { + ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); + ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * AlphaScale); + } + } + + ~ImGuiScopedDisabler() + { + if (m_IsDisabled) + { + ImGui::PopItemFlag(); + ImGui::PopStyleVar(); + } + } + +private: + const bool m_IsDisabled; +}; + +} // namespace Diligent + +namespace ImGui +{ + +template +inline bool Checkbox(const char* label, T* v) +{ + bool b = *v != 0; + + auto pressed = Checkbox(label, &b); + if (pressed) + *v = b ? 1 : 0; + return pressed; +} + +inline void HelpMarker(const char* desc, bool IsSameLine = true, const char* marker = "(?)") +{ + if (IsSameLine) + SameLine(); + + TextDisabled("%s", marker); + if (IsItemHovered()) + { + BeginTooltip(); + PushTextWrapPos(GetFontSize() * 35.0f); + TextUnformatted(desc); + PopTextWrapPos(); + EndTooltip(); + } +} + +template ::is_integer>::type> +bool SliderIntT(const char* label, T* v, int v_min, int v_max, const char* format = "%d") +{ + int i = static_cast(*v); + + auto value_changed = ImGui::SliderInt(label, &i, v_min, v_max, format); + if (value_changed) + *v = static_cast(i); + return value_changed; +} + +template +bool Combo(const char* label, T* current_item, const std::pair items[], int items_count, int popup_max_height_in_items = -1) +{ + int item_idx = 0; + while (item_idx < items_count && items[item_idx].first != *current_item) + ++item_idx; + if (item_idx >= items_count) + { + UNEXPECTED("Current item was not found in the items list"); + return false; + } + std::vector names(items_count); + for (int i = 0; i < items_count; ++i) + names[i] = items[i].second; + auto value_changed = Combo(label, &item_idx, names.data(), items_count, popup_max_height_in_items); + if (value_changed) + *current_item = items[item_idx].first; + + return value_changed; +} + +} // namespace ImGui -- cgit v1.2.3