Commit 7a8e1c40 authored by w4t's avatar w4t

AddValues can now use DragXXX components if no range is provided

parent b815013f
......@@ -641,7 +641,14 @@ bool ofxImGui::AddValues(const std::string& name, std::vector<glm::tvec2<int>>&
for (size_t i = 0; i < values.size(); ++i)
{
const auto iname = name + " " + ofToString(i);
result |= ImGui::SliderInt2(GetUniqueName(iname), glm::value_ptr(values[i]), minValue, maxValue);
if (minValue == 0 && maxValue == 0)
{
result |= ImGui::DragInt2(GetUniqueName(iname), glm::value_ptr(values[i]));
}
else
{
result |= ImGui::SliderInt2(GetUniqueName(iname), glm::value_ptr(values[i]), minValue, maxValue);
}
}
return result;
}
......@@ -653,7 +660,14 @@ bool ofxImGui::AddValues(const std::string& name, std::vector<glm::tvec3<int>>&
for (size_t i = 0; i < values.size(); ++i)
{
const auto iname = name + " " + ofToString(i);
result |= ImGui::SliderInt3(GetUniqueName(iname), glm::value_ptr(values[i]), minValue, maxValue);
if (minValue == 0 && maxValue == 0)
{
result |= ImGui::DragInt3(GetUniqueName(iname), glm::value_ptr(values[i]));
}
else
{
result |= ImGui::SliderInt3(GetUniqueName(iname), glm::value_ptr(values[i]), minValue, maxValue);
}
}
return result;
}
......@@ -665,7 +679,14 @@ bool ofxImGui::AddValues(const std::string& name, std::vector<glm::tvec4<int>>&
for (size_t i = 0; i < values.size(); ++i)
{
const auto iname = name + " " + ofToString(i);
result |= ImGui::SliderInt4(GetUniqueName(iname), glm::value_ptr(values[i]), minValue, maxValue);
if (minValue == 0 && maxValue == 0)
{
result |= ImGui::DragInt4(GetUniqueName(iname), glm::value_ptr(values[i]));
}
else
{
result |= ImGui::SliderInt4(GetUniqueName(iname), glm::value_ptr(values[i]), minValue, maxValue);
}
}
return result;
}
......@@ -677,7 +698,14 @@ bool ofxImGui::AddValues(const std::string& name, std::vector<glm::vec2>& values
for (size_t i = 0; i < values.size(); ++i)
{
const auto iname = name + " " + ofToString(i);
result |= ImGui::SliderFloat2(GetUniqueName(iname), glm::value_ptr(values[i]), minValue, maxValue);
if (minValue == 0 && maxValue == 0)
{
result |= ImGui::DragFloat2(GetUniqueName(iname), glm::value_ptr(values[i]));
}
else
{
result |= ImGui::SliderFloat2(GetUniqueName(iname), glm::value_ptr(values[i]), minValue, maxValue);
}
}
return result;
}
......@@ -689,7 +717,14 @@ bool ofxImGui::AddValues(const std::string& name, std::vector<glm::vec3>& values
for (size_t i = 0; i < values.size(); ++i)
{
const auto iname = name + " " + ofToString(i);
result |= ImGui::SliderFloat3(GetUniqueName(iname), glm::value_ptr(values[i]), minValue, maxValue);
if (minValue == 0 && maxValue == 0)
{
result |= ImGui::DragFloat3(GetUniqueName(iname), glm::value_ptr(values[i]));
}
else
{
result |= ImGui::SliderFloat3(GetUniqueName(iname), glm::value_ptr(values[i]), minValue, maxValue);
}
}
return result;
}
......@@ -701,7 +736,14 @@ bool ofxImGui::AddValues(const std::string& name, std::vector<glm::vec4>& values
for (size_t i = 0; i < values.size(); ++i)
{
const auto iname = name + " " + ofToString(i);
result |= ImGui::SliderFloat4(GetUniqueName(iname), glm::value_ptr(values[i]), minValue, maxValue);
if (minValue == 0 && maxValue == 0)
{
result |= ImGui::DragFloat4(GetUniqueName(iname), glm::value_ptr(values[i]));
}
else
{
result |= ImGui::SliderFloat4(GetUniqueName(iname), glm::value_ptr(values[i]), minValue, maxValue);
}
}
return result;
}
......@@ -715,7 +757,14 @@ bool ofxImGui::AddValues(const std::string& name, std::vector<ofVec2f>& values,
for (size_t i = 0; i < values.size(); ++i)
{
const auto iname = name + " " + ofToString(i);
result |= ImGui::SliderFloat2(GetUniqueName(iname), values[i].getPtr(), minValue, maxValue);
if (minValue == 0 && maxValue == 0)
{
result |= ImGui::DragFloat2(GetUniqueName(iname), values[i].getPtr());
}
else
{
result |= ImGui::SliderFloat2(GetUniqueName(iname), values[i].getPtr(), minValue, maxValue);
}
}
return result;
}
......@@ -727,7 +776,14 @@ bool ofxImGui::AddValues(const std::string& name, std::vector<ofVec3f>& values,
for (size_t i = 0; i < values.size(); ++i)
{
const auto iname = name + " " + ofToString(i);
result |= ImGui::SliderFloat3(GetUniqueName(iname), values[i].getPtr(), minValue, maxValue);
if (minValue == 0 && maxValue == 0)
{
result |= ImGui::DragFloat3(GetUniqueName(iname), values[i].getPtr());
}
else
{
result |= ImGui::SliderFloat3(GetUniqueName(iname), values[i].getPtr(), minValue, maxValue);
}
}
return result;
}
......@@ -739,7 +795,14 @@ bool ofxImGui::AddValues(const std::string& name, std::vector<ofVec4f>& values,
for (size_t i = 0; i < values.size(); ++i)
{
const auto iname = name + " " + ofToString(i);
result |= ImGui::SliderFloat4(GetUniqueName(iname), values[i].getPtr(), minValue, maxValue);
if (minValue == 0 && maxValue == 0)
{
result |= ImGui::DragFloat4(GetUniqueName(iname), values[i].getPtr());
}
else
{
result |= ImGui::SliderFloat4(GetUniqueName(iname), values[i].getPtr(), minValue, maxValue);
}
}
return result;
}
......
......@@ -72,6 +72,11 @@ namespace ImGui {
IMGUI_API void TextWrapped(std::string const& text);
IMGUI_API void LabelText(const char* label, std::string const& text);
IMGUI_API void BulletText(std::string const& text);
IMGUI_API void Image(const ofBaseHasTexture& image, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), const ImVec4& tint_col = ImVec4(1,1,1,1), const ImVec4& border_col = ImVec4(0,0,0,0));
IMGUI_API bool ImageButton(const ofBaseHasTexture& image, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), int frame_padding = -1, const ImVec4& bg_col = ImVec4(0,0,0,0), const ImVec4& tint_col = ImVec4(1,1,1,1)); // <0 frame_padding uses default frame padding settings. 0 for no padding
IMGUI_API void Image(const ofTexture& texture, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), const ImVec4& tint_col = ImVec4(1,1,1,1), const ImVec4& border_col = ImVec4(0,0,0,0));
IMGUI_API bool ImageButton(const ofTexture& texture, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), int frame_padding = -1, const ImVec4& bg_col = ImVec4(0,0,0,0), const ImVec4& tint_col = ImVec4(1,1,1,1)); // <0 frame_padding uses default frame padding settings. 0 for no padding
}
namespace ofxImGui
......@@ -157,18 +162,18 @@ namespace ofxImGui
#endif
#if OF_VERSION_MINOR >= 10
bool AddValues(const std::string& name, std::vector<glm::ivec2>& values, int minValue, int maxValue);
bool AddValues(const std::string& name, std::vector<glm::ivec3>& values, int minValue, int maxValue);
bool AddValues(const std::string& name, std::vector<glm::ivec4>& values, int minValue, int maxValue);
bool AddValues(const std::string& name, std::vector<glm::ivec2>& values, int minValue = 0, int maxValue = 0);
bool AddValues(const std::string& name, std::vector<glm::ivec3>& values, int minValue = 0, int maxValue = 0);
bool AddValues(const std::string& name, std::vector<glm::ivec4>& values, int minValue = 0, int maxValue = 0);
bool AddValues(const std::string& name, std::vector<glm::vec2>& values, float minValue, float maxValue);
bool AddValues(const std::string& name, std::vector<glm::vec3>& values, float minValue, float maxValue);
bool AddValues(const std::string& name, std::vector<glm::vec4>& values, float minValue, float maxValue);
bool AddValues(const std::string& name, std::vector<glm::vec2>& values, float minValue = 0, float maxValue = 0);
bool AddValues(const std::string& name, std::vector<glm::vec3>& values, float minValue = 0, float maxValue = 0);
bool AddValues(const std::string& name, std::vector<glm::vec4>& values, float minValue = 0, float maxValue = 0);
#endif
bool AddValues(const std::string& name, std::vector<ofVec2f>& values, float minValue, float maxValue);
bool AddValues(const std::string& name, std::vector<ofVec3f>& values, float minValue, float maxValue);
bool AddValues(const std::string& name, std::vector<ofVec4f>& values, float minValue, float maxValue);
bool AddValues(const std::string& name, std::vector<ofVec2f>& values, float minValue = 0, float maxValue = 0);
bool AddValues(const std::string& name, std::vector<ofVec3f>& values, float minValue = 0, float maxValue = 0);
bool AddValues(const std::string& name, std::vector<ofVec4f>& values, float minValue = 0, float maxValue = 0);
template<typename DataType>
bool AddValues(const std::string& name, std::vector<DataType>& values, DataType minValue, DataType maxValue);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment