Exposing optional imguiButton() color parameter.

This commit is contained in:
Dario Manesku 2014-08-12 12:20:00 +01:00
parent d64a62866a
commit 677ef2d6c5
2 changed files with 12 additions and 6 deletions

View file

@ -885,7 +885,7 @@ struct Imgui
m_insideCurrentScroll = false; m_insideCurrentScroll = false;
} }
bool button(const char* _text, bool _enabled, int32_t _r) bool button(const char* _text, bool _enabled, uint32_t _rgb0, int32_t _r)
{ {
m_widgetId++; m_widgetId++;
uint16_t id = (m_areaId << 8) | m_widgetId; uint16_t id = (m_areaId << 8) | m_widgetId;
@ -900,13 +900,15 @@ struct Imgui
bool over = enabled && inRect(xx, yy, width, height); bool over = enabled && inRect(xx, yy, width, height);
bool res = buttonLogic(id, over); bool res = buttonLogic(id, over);
const uint32_t rgb0 = _rgb0&0x00ffffff;
if (0 == _r) if (0 == _r)
{ {
drawRect( (float)xx drawRect( (float)xx
, (float)yy , (float)yy
, (float)width , (float)width
, (float)height , (float)height
, imguiRGBA(128, 128, 128, isActive(id) ? 196 : 96) , rgb0 | imguiRGBA(0, 0, 0, isActive(id) ? 196 : 96)
); );
} }
else else
@ -916,7 +918,7 @@ struct Imgui
, (float)width , (float)width
, (float)height , (float)height
, (float)_r , (float)_r
, imguiRGBA(128, 128, 128, isActive(id) ? 196 : 96) , rgb0 | imguiRGBA(0, 0, 0, isActive(id) ? 196 : 96)
); );
} }
@ -2568,9 +2570,9 @@ void imguiSeparatorLine(uint16_t _height)
s_imgui.separatorLine(_height); s_imgui.separatorLine(_height);
} }
bool imguiButton(const char* _text, bool _enabled, int32_t _r) bool imguiButton(const char* _text, bool _enabled, uint32_t _rgb0, int32_t _r)
{ {
return s_imgui.button(_text, _enabled, _r); return s_imgui.button(_text, _enabled, _rgb0, _r);
} }
bool imguiItem(const char* _text, bool _enabled) bool imguiItem(const char* _text, bool _enabled)

View file

@ -45,6 +45,10 @@
#define IMGUI_BUTTON_R 9 #define IMGUI_BUTTON_R 9
#endif //IMGUI_BUTTON_R #endif //IMGUI_BUTTON_R
#ifndef IMGUI_BUTTON_RGB0
#define IMGUI_BUTTON_RGB0 imguiRGBA(128, 128, 128, 0)
#endif //IMGUI_BUTTON_RGB0
#ifndef IMGUI_INPUT_R #ifndef IMGUI_INPUT_R
#define IMGUI_INPUT_R 4 #define IMGUI_INPUT_R 4
#endif //IMGUI_INPUT_R #endif //IMGUI_INPUT_R
@ -124,7 +128,7 @@ void imguiUnindent(uint16_t _width = IMGUI_INDENT_VALUE);
void imguiSeparator(uint16_t _height = IMGUI_SEPARATOR_VALUE); void imguiSeparator(uint16_t _height = IMGUI_SEPARATOR_VALUE);
void imguiSeparatorLine(uint16_t _height = IMGUI_SEPARATOR_VALUE); void imguiSeparatorLine(uint16_t _height = IMGUI_SEPARATOR_VALUE);
bool imguiButton(const char* _text, bool _enabled = true, int32_t _r = IMGUI_BUTTON_R); bool imguiButton(const char* _text, bool _enabled = true, uint32_t _rgb0 = IMGUI_BUTTON_RGB0, int32_t _r = IMGUI_BUTTON_R);
bool imguiItem(const char* _text, bool _enabled = true); bool imguiItem(const char* _text, bool _enabled = true);
bool imguiCheck(const char* _text, bool _checked, 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); bool imguiCollapse(const char* _text, const char* _subtext, bool _checked, bool _enabled = true);