ImGui实现Button高亮

ImGui实现Button高亮


记录下在ImGui中实现Button高亮的操作,跟着官方demo走没看到具体的实现方式,想着渲染是不断进行的,让下一帧绘制上次选择的状态。结果如下:

请添加图片描述

部分代码;

            char label[10];
			static int nRecordClick = -1;
			bool bpop = false;
			for (int n = 0; n < 7; n++)
			{
    
    
				ImGui::SameLine();
				if (n == nRecordClick)
				{
    
    
					ImGui::PushStyleColor(ImGuiCol_Button, (ImVec4)ImColor::HSV(0 / 7.0f, 0.6f, 0.6f));
					ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV(0 / 7.0f, 0.7f, 0.7f));
					ImGui::PushStyleColor(ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV(0 / 7.0f, 0.8f, 0.8f));
					bpop = true;
				}
				sprintf(label, "Button %d", n);
				if (ImGui::Button(label))
				{
    
    
					nRecordClick = n;
				}
				if (bpop)
				{
    
    
					ImGui::PopStyleColor(3);
					bpop = false;
				}
			}

猜你喜欢

转载自blog.csdn.net/weixin_44478077/article/details/128205041
今日推荐