Additional UI overlay widget creation functions

This commit is contained in:
saschawillems 2017-10-31 11:52:48 +01:00
parent 0907e3c680
commit 3b11701eb2
2 changed files with 23 additions and 1 deletions

View file

@ -1,3 +1,4 @@
#include "VulkanUIOverlay.h"
/*
* UI overlay class using ImGui
*
@ -563,6 +564,14 @@ namespace vks
return ImGui::Checkbox(caption, value);
}
bool UIOverlay::checkBox(const char *caption, int32_t *value)
{
bool val = (*value == 1);
bool res = ImGui::Checkbox(caption, &val);
*value = val;
return res;
}
bool UIOverlay::inputFloat(const char *caption, float *value, float step, uint32_t precision)
{
return ImGui::InputFloat(caption, value, step, step * 10.0f, precision);
@ -574,6 +583,11 @@ namespace vks
return false;
}
bool UIOverlay::sliderInt(const char* caption, int32_t* value, int32_t min, int32_t max)
{
return ImGui::SliderInt(caption, value, min, max);
}
bool UIOverlay::comboBox(const char *caption, int32_t *itemindex, std::vector<std::string> items)
{
if (items.empty()) {
@ -587,6 +601,11 @@ namespace vks
return ImGui::Combo(caption, itemindex, &charitems[0], static_cast<uint32_t>(charitems.size()), 4);
}
bool UIOverlay::button(const char *caption)
{
return ImGui::Button(caption);
}
void UIOverlay::text(const char *formatstr, ...)
{
va_list args;

View file

@ -89,9 +89,12 @@ namespace vks
bool header(const char* caption);
bool checkBox(const char* caption, bool* value);
bool checkBox(const char* caption, int32_t* value);
bool inputFloat(const char* caption, float* value, float step, uint32_t precision);
bool sliderFloat(const char* caption, float* value, float min, float max);
bool sliderInt(const char* caption, int32_t* value, int32_t min, int32_t max);
bool comboBox(const char* caption, int32_t* itemindex, std::vector<std::string> items);
void text(const char* formatstr, ...);
bool button(const char* caption);
void text(const char* formatstr, ...);
};
}