| 830 | //----------------------------------------------------------------------------- |
| 831 | |
| 832 | static void DemoWindowWidgetsBasic() |
| 833 | { |
| 834 | if (ImGui::TreeNode("Basic")) |
| 835 | { |
| 836 | IMGUI_DEMO_MARKER("Widgets/Basic"); |
| 837 | ImGui::SeparatorText("General"); |
| 838 | |
| 839 | IMGUI_DEMO_MARKER("Widgets/Basic/Button"); |
| 840 | static int clicked = 0; |
| 841 | if (ImGui::Button("Button")) |
| 842 | clicked++; |
| 843 | if (clicked & 1) |
| 844 | { |
| 845 | ImGui::SameLine(); |
| 846 | ImGui::Text("Thanks for clicking me!"); |
| 847 | } |
| 848 | |
| 849 | IMGUI_DEMO_MARKER("Widgets/Basic/Checkbox"); |
| 850 | static bool check = true; |
| 851 | ImGui::Checkbox("checkbox", &check); |
| 852 | |
| 853 | IMGUI_DEMO_MARKER("Widgets/Basic/RadioButton"); |
| 854 | static int e = 0; |
| 855 | ImGui::RadioButton("radio a", &e, 0); ImGui::SameLine(); |
| 856 | ImGui::RadioButton("radio b", &e, 1); ImGui::SameLine(); |
| 857 | ImGui::RadioButton("radio c", &e, 2); |
| 858 | |
| 859 | ImGui::AlignTextToFramePadding(); |
| 860 | ImGui::TextLinkOpenURL("Hyperlink", "https://github.com/ocornut/imgui/wiki/Error-Handling"); |
| 861 | |
| 862 | // Color buttons, demonstrate using PushID() to add unique identifier in the ID stack, and changing style. |
| 863 | IMGUI_DEMO_MARKER("Widgets/Basic/Buttons (Colored)"); |
| 864 | for (int i = 0; i < 7; i++) |
| 865 | { |
| 866 | if (i > 0) |
| 867 | ImGui::SameLine(); |
| 868 | ImGui::PushID(i); |
| 869 | ImGui::PushStyleColor(ImGuiCol_Button, (ImVec4)ImColor::HSV(i / 7.0f, 0.6f, 0.6f)); |
| 870 | ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV(i / 7.0f, 0.7f, 0.7f)); |
| 871 | ImGui::PushStyleColor(ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV(i / 7.0f, 0.8f, 0.8f)); |
| 872 | ImGui::Button("Click"); |
| 873 | ImGui::PopStyleColor(3); |
| 874 | ImGui::PopID(); |
| 875 | } |
| 876 | |
| 877 | // Use AlignTextToFramePadding() to align text baseline to the baseline of framed widgets elements |
| 878 | // (otherwise a Text+SameLine+Button sequence will have the text a little too high by default!) |
| 879 | // See 'Demo->Layout->Text Baseline Alignment' for details. |
| 880 | ImGui::AlignTextToFramePadding(); |
| 881 | ImGui::Text("Hold to repeat:"); |
| 882 | ImGui::SameLine(); |
| 883 | |
| 884 | // Arrow buttons with Repeater |
| 885 | IMGUI_DEMO_MARKER("Widgets/Basic/Buttons (Repeating)"); |
| 886 | static int counter = 0; |
| 887 | float spacing = ImGui::GetStyle().ItemInnerSpacing.x; |
| 888 | ImGui::PushItemFlag(ImGuiItemFlags_ButtonRepeat, true); |
| 889 | if (ImGui::ArrowButton("##left", ImGuiDir_Left)) { counter--; } |
no test coverage detected