Commit 2f2a2663 authored by w4t's avatar w4t

enables Combo with vector<string>

parent 2f79f688
Pipeline #61 canceled with stages
...@@ -756,3 +756,20 @@ void ofxImGui::AddImage(ofTexture& texture, const ofVec2f& size) ...@@ -756,3 +756,20 @@ void ofxImGui::AddImage(ofTexture& texture, const ofVec2f& size)
ImTextureID textureID = (ImTextureID)(uintptr_t)texture.texData.textureID; ImTextureID textureID = (ImTextureID)(uintptr_t)texture.texData.textureID;
ImGui::Image(textureID, size); ImGui::Image(textureID, size);
} }
//--------------------------------------------------------------
static auto vector_getter = [](void* vec, int idx, const char** out_text)
{
auto& vector = *static_cast<std::vector<std::string>*>(vec);
if (idx < 0 || idx >= static_cast<int>(vector.size())) { return false; }
*out_text = vector.at(idx).c_str();
return true;
};
//--------------------------------------------------------------
bool ofxImGui::VectorCombo(const char* label, int* currIndex, std::vector<std::string>& values)
{
if (values.empty()) { return false; }
return ImGui::Combo(label, currIndex, vector_getter,
static_cast<void*>(&values), values.size());
}
\ No newline at end of file
#pragma once #pragma once
//#include "ofGLBaseTypes.h" #include "ofGLBaseTypes.h"
#include "ofParameter.h" #include "ofParameter.h"
#include "ofRectangle.h" #include "ofRectangle.h"
#include "ofTexture.h" #include "ofTexture.h"
//#include "ofGLBaseTypes.h"
#include "ofBaseTypes.h" #include "ofBaseTypes.h"
#include "imgui.h" #include "imgui.h"
...@@ -12,6 +11,8 @@ static const int kImGuiMargin = 10; ...@@ -12,6 +11,8 @@ static const int kImGuiMargin = 10;
namespace ofxImGui namespace ofxImGui
{ {
bool VectorCombo(const char* label, int* currIndex, std::vector<std::string>& values);
struct WindowOpen struct WindowOpen
{ {
std::stack<std::vector<std::string>> usedNames; std::stack<std::vector<std::string>> usedNames;
......
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