Commit b815013f authored by w4t's avatar w4t

Added Image/ImageButton support for ofTexture and ofBaseHasTexture

parent a733d3e5
......@@ -1083,6 +1083,14 @@ namespace ImGui {
}
return false;
}
IMGUI_API bool ColorEdit3(const char * label, ofFloatColor * color, ImGuiColorEditFlags flags) {
float temp[3] = { color->r, color->g, color->b };
if (ColorEdit3(label, temp, flags)) {
color->set(temp[0], temp[1], temp[2]);
return true;
}
return false;
}
IMGUI_API bool ColorEdit4(const char * label, ofColor * color, ImGuiColorEditFlags flags) {
float temp[4] = { color->r, color->g, color->b, color->a };
if (ColorEdit4(label, temp, flags)) {
......@@ -1091,6 +1099,14 @@ namespace ImGui {
}
return false;
}
IMGUI_API bool ColorEdit4(const char * label, ofFloatColor * color, ImGuiColorEditFlags flags) {
float temp[4] = { color->r, color->g, color->b, color->a };
if (ColorEdit4(label, temp, flags)) {
color->set(temp[0], temp[1], temp[2], temp[3]);
return true;
}
return false;
}
IMGUI_API bool ColorPicker3(const char * label, ofColor * color, ImGuiColorEditFlags flags) {
float temp[3] = { color->r, color->g, color->b };
if (ColorPicker3(label, temp, flags)) {
......@@ -1099,6 +1115,14 @@ namespace ImGui {
}
return false;
}
IMGUI_API bool ColorPicker3(const char * label, ofFloatColor * color, ImGuiColorEditFlags flags) {
float temp[3] = { color->r, color->g, color->b };
if (ColorPicker3(label, temp, flags)) {
color->set(temp[0], temp[1], temp[2]);
return true;
}
return false;
}
IMGUI_API bool ColorPicker4(const char * label, ofColor * color, ImGuiColorEditFlags flags, const ofColor * ref_col) {
float temp[4] = { color->r, color->g, color->b, color->a };
if (ref_col) {
......@@ -1113,7 +1137,54 @@ namespace ImGui {
}
return false;
}
IMGUI_API bool ColorPicker4(const char * label, ofFloatColor * color, ImGuiColorEditFlags flags, const ofFloatColor * ref_col) {
float temp[4] = { color->r, color->g, color->b, color->a };
if (ref_col) {
float ref[4] = { ref_col->r, ref_col->g, ref_col->b, ref_col->a };
if (ColorPicker4(label, temp, flags, ref)) {
color->set(temp[0], temp[1], temp[2], temp[3]);
return true;
}
} else if (ColorPicker4(label, temp, flags, nullptr)) {
color->set(temp[0], temp[1], temp[2], temp[3]);
return true;
}
return false;
}
IMGUI_API bool ColorButton(const char * desc_id, ofColor const & col, ImGuiColorEditFlags flags, ImVec2 size) {
return ColorButton(desc_id, ImVec4(col.r, col.g, col.b, col.a), flags, size);
}
IMGUI_API bool ColorButton(const char * desc_id, ofFloatColor const & col, ImGuiColorEditFlags flags, ImVec2 size) {
return ColorButton(desc_id, ImVec4(col.r, col.g, col.b, col.a), flags, size);
}
IMGUI_API void Text(std::string const & text) {
TextUnformatted(text.c_str());
}
IMGUI_API void TextColored(ImVec4 const & col, std::string const & text) {
TextColored(col, "%s", text.c_str());
}
IMGUI_API void TextDisabled(std::string const & text) {
TextDisabled("%s", text.c_str());
}
IMGUI_API void TextWrapped(std::string const & text) {
TextWrapped("%s", text.c_str());
}
IMGUI_API void LabelText(const char * label, std::string const & text) {
LabelText(label, "%s", text.c_str());
}
IMGUI_API void BulletText(std::string const & text) {
BulletText("%s", text.c_str());
}
IMGUI_API void Image(const ofBaseHasTexture& image, const ImVec2& size, const ImVec2 & uv0, const ImVec2 & uv1, const ImVec4 & tint_col, const ImVec4 & border_col) {
Image(image.getTexture(), size, uv0, uv1, tint_col, border_col);
}
IMGUI_API bool ImageButton(const ofBaseHasTexture& image, const ImVec2& size, const ImVec2 & uv0, const ImVec2 & uv1, int frame_padding, const ImVec4 & bg_col, const ImVec4 & tint_col) {
return ImageButton(image.getTexture(), size, uv0, uv1, frame_padding, bg_col, tint_col);
}
IMGUI_API void Image(const ofTexture& texture, const ImVec2 & size, const ImVec2 & uv0, const ImVec2 & uv1, const ImVec4 & tint_col, const ImVec4 & border_col) {
Image((ImTextureID)texture.getTextureData().textureID, size, uv0, uv1, tint_col, border_col);
}
IMGUI_API bool ImageButton(const ofTexture& texture, const ImVec2 & size, const ImVec2 & uv0, const ImVec2 & uv1, int frame_padding, const ImVec4 & bg_col, const ImVec4 & tint_col) {
return ImageButton((ImTextureID)texture.getTextureData().textureID, size, uv0, uv1, frame_padding, bg_col, tint_col);
}
}
\ No newline at end of file
......@@ -57,10 +57,21 @@ namespace ImGui {
IMGUI_API bool VSliderInt(const ImVec2& size, ofParameter<int>& v, int v_min, int v_max, const char* format = "%d");
IMGUI_API bool VSliderInt(const char* label, const ImVec2& size, ofParameter<int>* v, int v_min, int v_max, const char* format = "%d");
IMGUI_API bool ColorEdit3(const char* label, ofColor *color, ImGuiColorEditFlags flags = 0);
IMGUI_API bool ColorEdit3(const char* label, ofFloatColor *color, ImGuiColorEditFlags flags = 0);
IMGUI_API bool ColorEdit4(const char* label, ofColor *color, ImGuiColorEditFlags flags = 0);
IMGUI_API bool ColorEdit4(const char* label, ofFloatColor *color, ImGuiColorEditFlags flags = 0);
IMGUI_API bool ColorPicker3(const char* label, ofColor *color, ImGuiColorEditFlags flags = 0);
IMGUI_API bool ColorPicker3(const char* label, ofFloatColor *color, ImGuiColorEditFlags flags = 0);
IMGUI_API bool ColorPicker4(const char* label, ofColor *color, ImGuiColorEditFlags flags = 0, const ofColor* ref_col = NULL);
IMGUI_API bool ColorPicker4(const char* label, ofFloatColor *color, ImGuiColorEditFlags flags = 0, const ofFloatColor* ref_col = NULL);
IMGUI_API bool ColorButton(const char* desc_id, ofColor const& col, ImGuiColorEditFlags flags = 0, ImVec2 size = ImVec2(0,0)); // display a colored square/button, hover for details, return true when pressed.
IMGUI_API bool ColorButton(const char* desc_id, ofFloatColor const& col, ImGuiColorEditFlags flags = 0, ImVec2 size = ImVec2(0,0)); // display a colored square/button, hover for details, return true when pressed.
IMGUI_API void Text(std::string const& text);
IMGUI_API void TextColored(ImVec4 const& col, std::string const& text);
IMGUI_API void TextDisabled(std::string const& text);
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);
}
namespace ofxImGui
......
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