From 116f2179a40555af70ee93223bfb77739e421f1a Mon Sep 17 00:00:00 2001 From: Dario Manesku Date: Sun, 23 Nov 2014 00:44:38 +0100 Subject: [PATCH] Adding _size parameter for imguiColorWheel. --- examples/common/imgui/imgui.cpp | 30 ++++++++++++++++-------------- examples/common/imgui/imgui.h | 4 ++-- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/examples/common/imgui/imgui.cpp b/examples/common/imgui/imgui.cpp index ff474564f..fe56dbfc0 100644 --- a/examples/common/imgui/imgui.cpp +++ b/examples/common/imgui/imgui.cpp @@ -2684,25 +2684,27 @@ struct Imgui } } - void colorWheelWidget(float _rgb[3], bool _respectIndentation, bool _enabled) + void colorWheelWidget(float _rgb[3], bool _respectIndentation, float _size, bool _enabled) { const uint32_t wheelId = getId(); const uint32_t triangleId = getId(); Area& area = getCurrentArea(); - const int32_t height = area.m_contentWidth - COLOR_WHEEL_PADDING; - const float heightf = float(height); - const float widthf = float(area.m_contentWidth - COLOR_WHEEL_PADDING); - const float xx = float( (_respectIndentation ? area.m_widgetX-SCROLL_AREA_PADDING : area.m_contentX) + COLOR_WHEEL_PADDING/2); - const float yy = float(area.m_widgetY); - area.m_widgetY += height + DEFAULT_SPACING; + const float areaX = float(_respectIndentation ? area.m_widgetX : area.m_contentX); + const float areaW = float(_respectIndentation ? area.m_widgetW : area.m_contentWidth); - const float ro = (widthf < heightf ? widthf : heightf) * 0.5f - 5.0f; // radiusOuter. - const float rd = 20.0f; // radiusDelta. + const float width = areaW*_size; + const float xx = areaX + areaW*0.5f; + const float yy = float(area.m_widgetY) + width*0.5f; + const float center[2] = { xx, yy }; + + area.m_widgetY += int32_t(width) + DEFAULT_SPACING; + + const float ro = width*0.5f - 5.0f; // radiusOuter. + const float rd = _size*25.0f; // radiusDelta. const float ri = ro - rd; // radiusInner. const float aeps = 0.5f / ro; // Half a pixel arc length in radians (2pi cancels out). - const float center[2] = { xx + widthf*0.5f, yy + heightf*0.5f }; const float cmx = float(m_mx) - center[0]; const float cmy = float(m_my) - center[1]; @@ -3321,12 +3323,12 @@ uint32_t imguiChooseUseMacroInstead(uint32_t _selected, ...) return _selected; } -void imguiColorWheel(float _rgb[3], bool _respectIndentation, bool _enabled) +void imguiColorWheel(float _rgb[3], bool _respectIndentation, float _size, bool _enabled) { - s_imgui.colorWheelWidget(_rgb, _respectIndentation, _enabled); + s_imgui.colorWheelWidget(_rgb, _respectIndentation, _size, _enabled); } -void imguiColorWheel(const char* _text, float _rgb[3], bool& _activated, bool _enabled) +void imguiColorWheel(const char* _text, float _rgb[3], bool& _activated, float _size, bool _enabled) { char buf[128]; bx::snprintf(buf, sizeof(buf), "[RGB %-2.2f %-2.2f %-2.2f]" @@ -3342,7 +3344,7 @@ void imguiColorWheel(const char* _text, float _rgb[3], bool& _activated, bool _e if (_activated) { - imguiColorWheel(_rgb, false, _enabled); + imguiColorWheel(_rgb, false, _size, _enabled); } } diff --git a/examples/common/imgui/imgui.h b/examples/common/imgui/imgui.h index a09ade4ed..f9f1fb77c 100644 --- a/examples/common/imgui/imgui.h +++ b/examples/common/imgui/imgui.h @@ -174,8 +174,8 @@ uint8_t imguiTabs(uint8_t _selected, bool _enabled, ImguiAlign::Enum _align, int uint32_t imguiChooseUseMacroInstead(uint32_t _selected, ...); #define imguiChoose(...) imguiChooseUseMacroInstead(__VA_ARGS__, NULL) -void imguiColorWheel(float _rgb[3], bool _respectIndentation = false, bool _enabled = true); -void imguiColorWheel(const char* _str, float _rgb[3], bool& _activated, bool _enabled = true); +void imguiColorWheel(float _rgb[3], bool _respectIndentation = false, float _size = 0.8f, bool _enabled = true); +void imguiColorWheel(const char* _str, float _rgb[3], bool& _activated, float _size = 0.8f, bool _enabled = true); bool imguiImage(bgfx::TextureHandle _image, float _lod, int32_t _width, int32_t _height, ImguiAlign::Enum _align = ImguiAlign::LeftIndented, bool _enabled = true, bool _originBottomLeft = false); bool imguiImage(bgfx::TextureHandle _image, float _lod, float _scale, float _aspect, ImguiAlign::Enum _align = ImguiAlign::LeftIndented, bool _enabled = true, bool _originBottomLeft = false);