From d25990487ea74868aae88d6dd7c840e6908d85f8 Mon Sep 17 00:00:00 2001 From: Dario Manesku Date: Mon, 6 Oct 2014 06:29:03 +0200 Subject: [PATCH] Added return value for imguiCube(). --- examples/common/imgui/imgui.cpp | 20 +++++++++++++++----- examples/common/imgui/imgui.h | 2 +- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/examples/common/imgui/imgui.cpp b/examples/common/imgui/imgui.cpp index c0b2ca03..df39f137 100644 --- a/examples/common/imgui/imgui.cpp +++ b/examples/common/imgui/imgui.cpp @@ -1619,10 +1619,10 @@ struct Imgui imageChannel(_image, _channel, _lod, int32_t(width), int32_t(height), _align); } - void cubeMap(bgfx::TextureHandle _cubemap, float _lod, bool _cross, ImguiAlign::Enum _align) + bool cubeMap(bgfx::TextureHandle _cubemap, float _lod, bool _cross, ImguiAlign::Enum _align) { - uint32_t numVertices = 14; - uint32_t numIndices = 36; + const uint32_t numVertices = 14; + const uint32_t numIndices = 36; if (bgfx::checkAvailTransientBuffers(numVertices, PosNormalVertex::ms_decl, numIndices) ) { bgfx::TransientVertexBuffer tvb; @@ -1692,6 +1692,8 @@ struct Imgui indices += quad(indices, 10, 12, 13, 11); } + const uint32_t id = getId(); + Area& area = getCurrentArea(); int32_t xx; int32_t width; @@ -1717,6 +1719,10 @@ struct Imgui const int32_t yy = area.m_widgetY; area.m_widgetY += height + DEFAULT_SPACING; + const bool enabled = isEnabled(m_areaId); + const bool over = enabled && inRect(xx, yy, width, height); + const bool res = buttonLogic(id, over); + const float scale = float(width/2); float mtx[16]; @@ -1734,7 +1740,11 @@ struct Imgui ); setCurrentScissor(); bgfx::submit(m_view); + + return res; } + + return false; } bool collapse(const char* _text, const char* _subtext, bool _checked, bool _enabled) @@ -3271,9 +3281,9 @@ void imguiImageChannel(bgfx::TextureHandle _image, uint8_t _channel, float _lod, s_imgui.imageChannel(_image, _channel, _lod, _width, _aspect, _align); } -void imguiCube(bgfx::TextureHandle _cubemap, float _lod, bool _cross, ImguiAlign::Enum _align) +bool imguiCube(bgfx::TextureHandle _cubemap, float _lod, bool _cross, ImguiAlign::Enum _align) { - s_imgui.cubeMap(_cubemap, _lod, _cross, _align); + return s_imgui.cubeMap(_cubemap, _lod, _cross, _align); } float imguiGetTextLength(const char* _text, ImguiFontHandle _handle) diff --git a/examples/common/imgui/imgui.h b/examples/common/imgui/imgui.h index f33c0599..e7761aa4 100644 --- a/examples/common/imgui/imgui.h +++ b/examples/common/imgui/imgui.h @@ -178,7 +178,7 @@ void imguiImage(bgfx::TextureHandle _image, float _lod, int32_t _width, int32_t void imguiImage(bgfx::TextureHandle _image, float _lod, float _scale, float _aspect, ImguiAlign::Enum _align = ImguiAlign::LeftIndented, bool _originBottomLeft = false); void imguiImageChannel(bgfx::TextureHandle _image, uint8_t _channel, float _lod, int32_t _width, int32_t _height, ImguiAlign::Enum _align = ImguiAlign::LeftIndented); void imguiImageChannel(bgfx::TextureHandle _image, uint8_t _channel, float _lod, float _scale, float _aspect, ImguiAlign::Enum _align = ImguiAlign::LeftIndented); -void imguiCube(bgfx::TextureHandle _cubemap, float _lod = 0.0f, bool _cross = true, ImguiAlign::Enum _align = ImguiAlign::LeftIndented); +bool imguiCube(bgfx::TextureHandle _cubemap, float _lod = 0.0f, bool _cross = true, ImguiAlign::Enum _align = ImguiAlign::LeftIndented); float imguiGetTextLength(const char* _text, ImguiFontHandle _handle); bool imguiMouseOverArea();