昨天大概跟大家簡述的 ImGui 的基本觀念,今天就帶大家看看一些 ImGui 的元件吧
ImGui::Begin();
// context
ImGui::End();
static bool flag = true;
if(flag) {
if(ImGui::Begin("Close Window", &flag)) {
}
ImGui::End();
}
if (ImGui::BeginMainMenuBar())
{
if (ImGui::BeginMenu("File"))
{
if (ImGui::MenuItem("Quit", "Alt+F4")) break;
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Edit"))
{
if( ImGui::MenuItem("TODO") ){
//do something
}
ImGui::EndMenu();
}
ImGui::EndMainMenuBar();
}
ImGui::Text("Text");
ImGui::TextDisabled("Disabled text");
ImGui::Text("haha%d", 123);
ImGui::TextColored(ImVec4(255, 0, 0, 255), "red");
ImGui::TextColored(ImVec4(0, 255, 0, 255), "blue");
ImGui::TextColored(ImVec4(0, 0, 255, 255), "green");
ImGui::TextColored(ImVec4(128, 128, 128, 255), "grey");
ImGui::BulletText("aaa");
ImGui::BulletText("bbb");
ImGui::BulletText("ccc");
if(ImGui::Button("I am a Button")) {
// Something happen when Button click
}
ImGui::PushStyleColor(ImGuiCol_Button, (ImVec4)ImColor::HSV(0.0f, 0.6f, 0.6f));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV(0.0f, 0.7f, 0.7f));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV(0.0f, 0.8f, 0.8f));
ImGui::Button("Red");
ImGui::PopStyleColor(3);
ImGui::ArrowButton("##Left", ImGuiDir_Left);
ImGui::ArrowButton("##Right", ImGuiDir_Right);
static bool flag = false;
if(ImGui::Checkbox("FirstBox", &flag))
// do something
if(flag)
ImGui::Text("the box has been checked");
ImGui::End();
static int select = -1;
ImGui::RadioButton("Zero", &select, 0); ImGui::SameLine();
ImGui::RadioButton("One", &select, 1); ImGui::SameLine();
ImGui::RadioButton("Two", &select, 2);
if(select >= 0)
{
ImGui::Text("You Select %d\n", select);
}
static float x = 0.f;
static float y = 0.f;
static int radius = 0;
ImGui::SliderFloat("x",&x,0.f,1080.f);
ImGui::SliderFloat("y",&y,0.f,720.f);
ImGui::SliderInt("Size",&radius,0,100);