Browse Source

Added option for imguiColorWheel to respect or ignore indentation.

Dario Manesku 11 years ago
parent
commit
fbe9ecce12
2 changed files with 9 additions and 6 deletions
  1. 8 5
      examples/common/imgui/imgui.cpp
  2. 1 1
      examples/common/imgui/imgui.h

+ 8 - 5
examples/common/imgui/imgui.cpp

@@ -146,6 +146,7 @@ struct Imgui
 		, m_scrollRight(0)
 		, m_scrollRight(0)
 		, m_scrollAreaTop(0)
 		, m_scrollAreaTop(0)
 		, m_scrollAreaWidth(0)
 		, m_scrollAreaWidth(0)
+		, m_scrollAreaX(0)
 		, m_scrollVal(NULL)
 		, m_scrollVal(NULL)
 		, m_focusTop(0)
 		, m_focusTop(0)
 		, m_focusBottom(0)
 		, m_focusBottom(0)
@@ -393,8 +394,9 @@ struct Imgui
 		m_scrollRight = _x + _width - SCROLL_AREA_PADDING * 3;
 		m_scrollRight = _x + _width - SCROLL_AREA_PADDING * 3;
 		m_scrollVal = _scroll;
 		m_scrollVal = _scroll;
 
 
-		m_scrollAreaTop = m_widgetY - AREA_HEADER;
+		m_scrollAreaX = _x;
 		m_scrollAreaWidth = _width;
 		m_scrollAreaWidth = _width;
+		m_scrollAreaTop = m_widgetY - AREA_HEADER;
 
 
 		m_focusTop = _y - AREA_HEADER;
 		m_focusTop = _y - AREA_HEADER;
 		m_focusBottom = _y - AREA_HEADER + _height;
 		m_focusBottom = _y - AREA_HEADER + _height;
@@ -1568,7 +1570,7 @@ struct Imgui
 		_u = 1.0f - _v - _w;
 		_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)
 		if (NULL == m_nvg)
 		{
 		{
@@ -1583,7 +1585,7 @@ struct Imgui
 		const int32_t height = m_scrollAreaWidth - COLOR_WHEEL_PADDING;
 		const int32_t height = m_scrollAreaWidth - COLOR_WHEEL_PADDING;
 		const float heightf = float(height);
 		const float heightf = float(height);
 		const float widthf = float(m_scrollAreaWidth - COLOR_WHEEL_PADDING);
 		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);
 		const float yy = float(m_widgetY);
 
 
 		m_widgetY += height + DEFAULT_SPACING;
 		m_widgetY += height + DEFAULT_SPACING;
@@ -1840,6 +1842,7 @@ struct Imgui
 	int32_t m_scrollRight;
 	int32_t m_scrollRight;
 	int32_t m_scrollAreaTop;
 	int32_t m_scrollAreaTop;
 	int32_t m_scrollAreaWidth;
 	int32_t m_scrollAreaWidth;
+	int32_t m_scrollAreaX;
 	int32_t* m_scrollVal;
 	int32_t* m_scrollVal;
 	int32_t m_focusTop;
 	int32_t m_focusTop;
 	int32_t m_focusBottom;
 	int32_t m_focusBottom;
@@ -2007,7 +2010,7 @@ int imguiReserve(int _y)
 	return yy;
 	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);
 }
 }

+ 1 - 1
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);
 void imguiDrawRect(float _x, float _y, float _w, float _h, uint32_t _argb);
 
 
 int imguiReserve(int _y);
 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
 #endif // IMGUI_H_HEADER_GUARD