void onImgButtonClick(void*);
ofxImGui::Gui gui;
int btnNum;
GLuint img2;
ofTexture image2;
ofxImGui::Gui gui2;
bool flag;
img1 = gui.loadTexture(image, "ground.jpg"); // 导入图片
ImVec2 buttonSize(108, 24); // 设置图片宽高
ImTextureID textureID = (ImTextureID)img1;
ImGui::ImageButton(textureID, buttonSize, ImVec2(0, 0), ImVec2(1, 1), 0); // 设置一个图片按钮,不支持圆角
bool pressed = ImGui::IsItemClicked(); // 定义是否点击的变量
if (pressed)
{ // 点击事件
onImgButtonClick(this);
}
ImGui::SameLine(0, 2.0f);
if (flag)
{
img2 = gui2.loadTexture(image2, "girl.jpg");
ImVec4 buttonColor2(1.0f, 1.0f, 1.0f, 0.5f); // 按钮颜色,opacity透明度
ImGui::ImageButton((ImTextureID)img2, ImVec2(108, 24), ImVec2(0, 0), ImVec2(1, 1), 0); // 设置一个图片按钮,不支持圆角
ImGui::Button("悬浮按钮", ImVec2(108, 24));
}
else
{
img2 = gui2.loadTexture(image2, "ground.jpg");
ImTextureID textureID2 = (ImTextureID)img2;
ImVec4 buttonColor2(1.0f, 1.0f, 1.0f, 0.5f); // 按钮颜色,opacity透明度
ImGui::ImageButton(textureID2, ImVec2(108, 24), ImVec2(0, 0), ImVec2(1, 1), 0); // 设置一个图片按钮,不支持圆角
}
void StoreGUIZew::onImgButtonClick(void *userdata)
{
cout << "成功" << endl;
flag = !flag;
}