From 3612885deaa7b1f659f3e9f62fd74702daddab32 Mon Sep 17 00:00:00 2001 From: omar Date: Thu, 23 Aug 2018 13:37:06 +0200 Subject: [PATCH] Comments, demo --- imgui.h | 1 + imgui_demo.cpp | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/imgui.h b/imgui.h index 7c50c186..f901f73e 100644 --- a/imgui.h +++ b/imgui.h @@ -516,6 +516,7 @@ namespace ImGui IMGUI_API void SetKeyboardFocusHere(int offset = 0); // focus keyboard on the next widget. Use positive 'offset' to access sub components of a multiple component widget. Use -1 to access previous widget. // Utilities + // See Demo Window under "Widgets->Querying Status" for an interactive visualization of many of those functions. IMGUI_API bool IsItemHovered(ImGuiHoveredFlags flags = 0); // is the last item hovered? (and usable, aka not blocked by a popup, etc.). See ImGuiHoveredFlags for more options. IMGUI_API bool IsItemActive(); // is the last item active? (e.g. button being held, text field being edited. This will continuously return true while holding mouse button on an item. Items that don't interact will always return false) IMGUI_API bool IsItemFocused(); // is the last item focused for keyboard/gamepad navigation? diff --git a/imgui_demo.cpp b/imgui_demo.cpp index 03119b2b..d9959c3e 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -1275,19 +1275,20 @@ void ImGui::ShowDemoWindow(bool* p_open) ImGui::TreePop(); } - if (ImGui::TreeNode("Active, Focused and Hovered Tests")) + if (ImGui::TreeNode("Querying Status (Active/Focused/Hovered etc.)")) { // Display the value of IsItemHovered() and other common item state functions. Note that the flags can be combined. // (because BulletText is an item itself and that would affect the output of IsItemHovered() we pass all state in a single call to simplify the code). static int item_type = 1; static bool b = false; static float col4f[4] = { 1.0f, 0.5, 0.0f, 1.0f }; - ImGui::RadioButton("Text", &item_type, 0); ImGui::SameLine(); - ImGui::RadioButton("Button", &item_type, 1); ImGui::SameLine(); - ImGui::RadioButton("CheckBox", &item_type, 2); ImGui::SameLine(); - ImGui::RadioButton("SliderFloat", &item_type, 3); ImGui::SameLine(); - ImGui::RadioButton("ColorEdit4", &item_type, 4); ImGui::SameLine(); + ImGui::RadioButton("Text", &item_type, 0); + ImGui::RadioButton("Button", &item_type, 1); + ImGui::RadioButton("CheckBox", &item_type, 2); + ImGui::RadioButton("SliderFloat", &item_type, 3); + ImGui::RadioButton("ColorEdit4", &item_type, 4); ImGui::RadioButton("ListBox", &item_type, 5); + ImGui::Separator(); bool ret = false; if (item_type == 0) { ImGui::Text("ITEM: Text"); } // Testing text items with no identifier/interaction if (item_type == 1) { ret = ImGui::Button("ITEM: Button"); } // Testing button @@ -1307,7 +1308,10 @@ void ImGui::ShowDemoWindow(bool* p_open) "IsItemEdited() = %d\n" "IsItemDeactivated() = %d\n" "IsItemDeactivatedEdit() = %d\n" - "IsItemVisible() = %d\n", + "IsItemVisible() = %d\n" + "GetItemRectMin() = (%.1f, %.1f)\n" + "GetItemRectMax() = (%.1f, %.1f)\n" + "GetItemRectSize() = (%.1f, %.1f)", ret, ImGui::IsItemFocused(), ImGui::IsItemHovered(), @@ -1319,7 +1323,10 @@ void ImGui::ShowDemoWindow(bool* p_open) ImGui::IsItemEdited(), ImGui::IsItemDeactivated(), ImGui::IsItemDeactivatedAfterEdit(), - ImGui::IsItemVisible() + ImGui::IsItemVisible(), + ImGui::GetItemRectMin().x, ImGui::GetItemRectMin().y, + ImGui::GetItemRectMax().x, ImGui::GetItemRectMax().y, + ImGui::GetItemRectSize().x, ImGui::GetItemRectSize().y ); static bool embed_all_inside_a_child_window = false;