From 6e69a02906c12313ca41cd04d47bcb0e8fe0c0af Mon Sep 17 00:00:00 2001 From: Dario Manesku Date: Mon, 11 Aug 2014 22:28:22 +0100 Subject: [PATCH] Added optional parameter for imguiInput(). --- 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 b0036d45..b0b4970e 100644 --- a/examples/common/imgui/imgui.cpp +++ b/examples/common/imgui/imgui.cpp @@ -1057,7 +1057,7 @@ struct Imgui return res; } - void input(const char* _label, char* _str, uint32_t _len, bool _enabled) + void input(const char* _label, char* _str, uint32_t _len, bool _enabled, int32_t _r) { m_widgetId++; const uint16_t id = (m_areaId << 8) | m_widgetId; @@ -1112,13 +1112,25 @@ struct Imgui const bool over = enabled && inRect(xx, yy, width, height); inputLogic(id, over); - drawRoundedRect( (float)xx - , (float)yy - , (float)width - , (float)height - , (float)BUTTON_HEIGHT / 5 - 1 - , isActiveInputField(id)?imguiRGBA(255,196,0,255):imguiRGBA(128,128,128,96) - ); + if (0 == _r) + { + drawRect( (float)xx + , (float)yy + , (float)width + , (float)height + , isActiveInputField(id)?imguiRGBA(255,196,0,255):imguiRGBA(128,128,128,96) + ); + } + else + { + drawRoundedRect( (float)xx + , (float)yy + , (float)width + , (float)height + , (float)_r + , isActiveInputField(id)?imguiRGBA(255,196,0,255):imguiRGBA(128,128,128,96) + ); + } drawText(xx + 6 , yy + BUTTON_HEIGHT / 2 + TEXT_HEIGHT / 2 @@ -2600,9 +2612,9 @@ bool imguiSlider(const char* _text, int32_t& _val, int32_t _vmin, int32_t _vmax, return result; } -void imguiInput(const char* _label, char* _str, uint32_t _len, bool _enabled) +void imguiInput(const char* _label, char* _str, uint32_t _len, bool _enabled, int32_t _r) { - s_imgui.input(_label, _str, _len, _enabled); + s_imgui.input(_label, _str, _len, _enabled, _r); } uint8_t imguiTabsUseMacroInstead(uint8_t _selected, bool _enabled, ...) diff --git a/examples/common/imgui/imgui.h b/examples/common/imgui/imgui.h index 3363e852..6e7d4614 100644 --- a/examples/common/imgui/imgui.h +++ b/examples/common/imgui/imgui.h @@ -107,7 +107,7 @@ void imguiLabel(bool _enabled, const char* _format, ...); void imguiValue(const char* _text); bool imguiSlider(const char* _text, float& _val, float _vmin, float _vmax, float _vinc, bool _enabled = true); bool imguiSlider(const char* _text, int32_t& _val, int32_t _vmin, int32_t _vmax, bool _enabled = true); -void imguiInput(const char* _label, char* _str, uint32_t _len, bool _enabled = true); +void imguiInput(const char* _label, char* _str, uint32_t _len, bool _enabled = true, int32_t _r = 4); uint8_t imguiTabsUseMacroInstead(uint8_t _selected, bool _enabled, ...); uint8_t imguiTabsUseMacroInstead(uint8_t _selected, bool _enabled, int32_t _height, int32_t _r, ...);