From fbe9ecce12e826435d6ccbdaa35836c8bca3b403 Mon Sep 17 00:00:00 2001 From: Dario Manesku Date: Mon, 23 Jun 2014 06:52:49 +0100 Subject: [PATCH] Added option for imguiColorWheel to respect or ignore indentation. --- examples/common/imgui/imgui.cpp | 13 ++++++++----- examples/common/imgui/imgui.h | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/examples/common/imgui/imgui.cpp b/examples/common/imgui/imgui.cpp index 62804d41..b15a1673 100644 --- a/examples/common/imgui/imgui.cpp +++ b/examples/common/imgui/imgui.cpp @@ -146,6 +146,7 @@ struct Imgui , m_scrollRight(0) , m_scrollAreaTop(0) , m_scrollAreaWidth(0) + , m_scrollAreaX(0) , m_scrollVal(NULL) , m_focusTop(0) , m_focusBottom(0) @@ -393,8 +394,9 @@ struct Imgui m_scrollRight = _x + _width - SCROLL_AREA_PADDING * 3; m_scrollVal = _scroll; - m_scrollAreaTop = m_widgetY - AREA_HEADER; + m_scrollAreaX = _x; m_scrollAreaWidth = _width; + m_scrollAreaTop = m_widgetY - AREA_HEADER; m_focusTop = _y - AREA_HEADER; m_focusBottom = _y - AREA_HEADER + _height; @@ -1568,7 +1570,7 @@ struct Imgui _u = 1.0f - _v - _w; } - void colorWheelWidget(float _color[3], bool _enabled = true) + void colorWheelWidget(float _color[3], bool _respectIndentation, bool _enabled) { if (NULL == m_nvg) { @@ -1583,7 +1585,7 @@ struct Imgui const int32_t height = m_scrollAreaWidth - COLOR_WHEEL_PADDING; const float heightf = float(height); const float widthf = float(m_scrollAreaWidth - COLOR_WHEEL_PADDING); - const float xx = float(m_widgetX - SCROLL_AREA_PADDING + COLOR_WHEEL_PADDING/2); + const float xx = float( (_respectIndentation ? m_widgetX-SCROLL_AREA_PADDING : m_scrollAreaX) + COLOR_WHEEL_PADDING/2); const float yy = float(m_widgetY); m_widgetY += height + DEFAULT_SPACING; @@ -1840,6 +1842,7 @@ struct Imgui int32_t m_scrollRight; int32_t m_scrollAreaTop; int32_t m_scrollAreaWidth; + int32_t m_scrollAreaX; int32_t* m_scrollVal; int32_t m_focusTop; int32_t m_focusBottom; @@ -2007,7 +2010,7 @@ int imguiReserve(int _y) return yy; } -void imguiColorWheel(float _color[3], bool _enabled) +void imguiColorWheel(float _color[3], bool _respectIndentation, bool _enabled) { - s_imgui.colorWheelWidget(_color, _enabled); + s_imgui.colorWheelWidget(_color, _respectIndentation, _enabled); } diff --git a/examples/common/imgui/imgui.h b/examples/common/imgui/imgui.h index cbff6eb2..502f71e7 100644 --- a/examples/common/imgui/imgui.h +++ b/examples/common/imgui/imgui.h @@ -83,6 +83,6 @@ void imguiDrawRoundedRect(float _x, float _y, float _w, float _h, float _r, uint void imguiDrawRect(float _x, float _y, float _w, float _h, uint32_t _argb); int imguiReserve(int _y); -void imguiColorWheel(float _color[3], bool _enabled = true); +void imguiColorWheel(float _color[3], bool _respectIndentation = false, bool _enabled = true); #endif // IMGUI_H_HEADER_GUARD