From 804bd01b01c3372e685e95ef3cbb9acc1f96adc2 Mon Sep 17 00:00:00 2001 From: bkaradzic Date: Sat, 18 Jan 2014 20:07:00 -0800 Subject: [PATCH] Added imguiChoose function. --- examples/common/imgui/imgui.cpp | 14 ++++++++++++++ examples/common/imgui/imgui.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/examples/common/imgui/imgui.cpp b/examples/common/imgui/imgui.cpp index 5035de2ac..11112d846 100644 --- a/examples/common/imgui/imgui.cpp +++ b/examples/common/imgui/imgui.cpp @@ -1513,6 +1513,20 @@ bool imguiSlider(const char* _text, int32_t* _val, int32_t _vmin, int32_t _vmax, return result; } +uint32_t imguiChooseUseMacroInstead(uint32_t _selected, const char* _first, ...) +{ + uint32_t ii = 0; + for (const char** str = &_first; *str != NULL; ++str, ++ii) + { + if (imguiCheck(*str, ii == _selected) ) + { + _selected = ii; + } + } + + return _selected; +} + void imguiDrawText(int32_t _x, int32_t _y, ImguiTextAlign::Enum _align, const char* _text, uint32_t _argb) { s_imgui.drawText(_x, _y, _align, _text, _argb); diff --git a/examples/common/imgui/imgui.h b/examples/common/imgui/imgui.h index 24a652b02..e93e73fa8 100644 --- a/examples/common/imgui/imgui.h +++ b/examples/common/imgui/imgui.h @@ -72,6 +72,9 @@ 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); +uint32_t imguiChooseUseMacroInstead(uint32_t _selected, const char* _first, ...); +#define imguiChoose(...) imguiChooseUseMacroInstead(__VA_ARGS__, NULL) + void imguiDrawText(int _x, int _y, ImguiTextAlign::Enum _align, const char* _text, uint32_t _argb); void imguiDrawLine(float _x0, float _y0, float _x1, float _y1, float _r, uint32_t _argb); void imguiDrawRoundedRect(float _x, float _y, float _w, float _h, float _r, uint32_t _argb);