From 762c423b4295d1354b746ce2f3d726c6104da004 Mon Sep 17 00:00:00 2001 From: Dario Manesku Date: Mon, 11 Aug 2014 21:28:39 +0100 Subject: [PATCH] Added optional parameter for imguiButton(). --- examples/common/imgui/imgui.cpp | 32 ++++++++++++++++++++++---------- examples/common/imgui/imgui.h | 2 +- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/examples/common/imgui/imgui.cpp b/examples/common/imgui/imgui.cpp index 9dc868b9..e4eaea6e 100644 --- a/examples/common/imgui/imgui.cpp +++ b/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) diff --git a/examples/common/imgui/imgui.h b/examples/common/imgui/imgui.h index 5e789173..17d0f776 100644 --- a/examples/common/imgui/imgui.h +++ b/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);