| 901 | //----------------------------------------------------------------------------- |
| 902 | |
| 903 | static void DemoWindowWidgetsBasic() |
| 904 | { |
| 905 | if (ImGui::TreeNode("Basic")) |
| 906 | { |
| 907 | IMGUI_DEMO_MARKER("Widgets/Basic"); |
| 908 | ImGui::SeparatorText("General"); |
| 909 | |
| 910 | IMGUI_DEMO_MARKER("Widgets/Basic/Button"); |
| 911 | static int clicked = 0; |
| 912 | if (ImGui::Button("Button")) |
| 913 | clicked++; |
| 914 | if (clicked & 1) |
| 915 | { |
| 916 | ImGui::SameLine(); |
| 917 | ImGui::Text("Thanks for clicking me!"); |
| 918 | } |
| 919 | |
| 920 | IMGUI_DEMO_MARKER("Widgets/Basic/Checkbox"); |
| 921 | static bool check = true; |
| 922 | ImGui::Checkbox("checkbox", &check); |
| 923 | |
| 924 | IMGUI_DEMO_MARKER("Widgets/Basic/RadioButton"); |
| 925 | static int e = 0; |
| 926 | ImGui::RadioButton("radio a", &e, 0); ImGui::SameLine(); |
| 927 | ImGui::RadioButton("radio b", &e, 1); ImGui::SameLine(); |
| 928 | ImGui::RadioButton("radio c", &e, 2); |
| 929 | |
| 930 | ImGui::AlignTextToFramePadding(); |
| 931 | ImGui::TextLinkOpenURL("Hyperlink", "https://github.com/ocornut/imgui/wiki/Error-Handling"); |
| 932 | |
| 933 | // Color buttons, demonstrate using PushID() to add unique identifier in the ID stack, and changing style. |
| 934 | IMGUI_DEMO_MARKER("Widgets/Basic/Buttons (Colored)"); |
| 935 | for (int i = 0; i < 7; i++) |
| 936 | { |
| 937 | if (i > 0) |
| 938 | ImGui::SameLine(); |
| 939 | ImGui::PushID(i); |
| 940 | ImGui::PushStyleColor(ImGuiCol_Button, (ImVec4)ImColor::HSV(i / 7.0f, 0.6f, 0.6f)); |
| 941 | ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV(i / 7.0f, 0.7f, 0.7f)); |
| 942 | ImGui::PushStyleColor(ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV(i / 7.0f, 0.8f, 0.8f)); |
| 943 | ImGui::Button("Click"); |
| 944 | ImGui::PopStyleColor(3); |
| 945 | ImGui::PopID(); |
| 946 | } |
| 947 | |
| 948 | // Use AlignTextToFramePadding() to align text baseline to the baseline of framed widgets elements |
| 949 | // (otherwise a Text+SameLine+Button sequence will have the text a little too high by default!) |
| 950 | // See 'Demo->Layout->Text Baseline Alignment' for details. |
| 951 | ImGui::AlignTextToFramePadding(); |
| 952 | ImGui::Text("Hold to repeat:"); |
| 953 | ImGui::SameLine(); |
| 954 | |
| 955 | // Arrow buttons with Repeater |
| 956 | IMGUI_DEMO_MARKER("Widgets/Basic/Buttons (Repeating)"); |
| 957 | static int counter = 0; |
| 958 | float spacing = ImGui::GetStyle().ItemInnerSpacing.x; |
| 959 | ImGui::PushItemFlag(ImGuiItemFlags_ButtonRepeat, true); |
| 960 | if (ImGui::ArrowButton("##left", ImGuiDir_Left)) { counter--; } |
no test coverage detected