Jelajahi Sumber

Added optional parameter for imguiButton().

Dario Manesku 11 tahun lalu
induk
melakukan
762c423b42
2 mengubah file dengan 23 tambahan dan 11 penghapusan
  1. 22 10
      examples/common/imgui/imgui.cpp
  2. 1 1
      examples/common/imgui/imgui.h

+ 22 - 10
examples/common/imgui/imgui.cpp

@@ -845,7 +845,7 @@ struct Imgui
 		m_insideCurrentScroll = false;
 	}
 
-	bool button(const char* _text, bool _enabled)
+	bool button(const char* _text, bool _enabled, int32_t _r)
 	{
 		m_widgetId++;
 		uint16_t id = (m_areaId << 8) | m_widgetId;
@@ -860,13 +860,25 @@ struct Imgui
 		bool over = enabled	&& inRect(xx, yy, width, height);
 		bool res = buttonLogic(id, over);
 
-		drawRoundedRect( (float)xx
-			, (float)yy
-			, (float)width
-			, (float)height
-			, (float)BUTTON_HEIGHT / 2 - 1
-			, imguiRGBA(128, 128, 128, isActive(id) ? 196 : 96)
-			);
+		if (0 == _r)
+		{
+			drawRect( (float)xx
+				, (float)yy
+				, (float)width
+				, (float)height
+				, imguiRGBA(128, 128, 128, isActive(id) ? 196 : 96)
+				);
+		}
+		else
+		{
+			drawRoundedRect( (float)xx
+				, (float)yy
+				, (float)width
+				, (float)height
+				, (float)_r
+				, imguiRGBA(128, 128, 128, isActive(id) ? 196 : 96)
+				);
+		}
 
 		if (enabled)
 		{
@@ -2498,9 +2510,9 @@ void imguiSeparatorLine(uint16_t _height)
 	s_imgui.separatorLine(_height);
 }
 
-bool imguiButton(const char* _text, bool _enabled)
+bool imguiButton(const char* _text, bool _enabled, int32_t _r)
 {
-	return s_imgui.button(_text, _enabled);
+	return s_imgui.button(_text, _enabled, _r);
 }
 
 bool imguiItem(const char* _text, bool _enabled)

+ 1 - 1
examples/common/imgui/imgui.h

@@ -98,7 +98,7 @@ void imguiUnindent(uint16_t _width = 16);
 void imguiSeparator(uint16_t _height = 12);
 void imguiSeparatorLine(uint16_t _height = 12);
 
-bool imguiButton(const char* _text, bool _enabled = true);
+bool imguiButton(const char* _text, bool _enabled = true, int32_t _r = 9);
 bool imguiItem(const char* _text, bool _enabled = true);
 bool imguiCheck(const char* _text, bool _checked, bool _enabled = true);
 bool imguiCollapse(const char* _text, const char* _subtext, bool _checked, bool _enabled = true);