Comments, demo

This commit is contained in:
omar 2018-08-23 13:37:06 +02:00
parent 0810d57819
commit 3612885dea
2 changed files with 16 additions and 8 deletions

View File

@ -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. 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 // 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 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 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? IMGUI_API bool IsItemFocused(); // is the last item focused for keyboard/gamepad navigation?

View File

@ -1275,19 +1275,20 @@ void ImGui::ShowDemoWindow(bool* p_open)
ImGui::TreePop(); 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. // 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). // (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 int item_type = 1;
static bool b = false; static bool b = false;
static float col4f[4] = { 1.0f, 0.5, 0.0f, 1.0f }; static float col4f[4] = { 1.0f, 0.5, 0.0f, 1.0f };
ImGui::RadioButton("Text", &item_type, 0); ImGui::SameLine(); ImGui::RadioButton("Text", &item_type, 0);
ImGui::RadioButton("Button", &item_type, 1); ImGui::SameLine(); ImGui::RadioButton("Button", &item_type, 1);
ImGui::RadioButton("CheckBox", &item_type, 2); ImGui::SameLine(); ImGui::RadioButton("CheckBox", &item_type, 2);
ImGui::RadioButton("SliderFloat", &item_type, 3); ImGui::SameLine(); ImGui::RadioButton("SliderFloat", &item_type, 3);
ImGui::RadioButton("ColorEdit4", &item_type, 4); ImGui::SameLine(); ImGui::RadioButton("ColorEdit4", &item_type, 4);
ImGui::RadioButton("ListBox", &item_type, 5); ImGui::RadioButton("ListBox", &item_type, 5);
ImGui::Separator();
bool ret = false; bool ret = false;
if (item_type == 0) { ImGui::Text("ITEM: Text"); } // Testing text items with no identifier/interaction 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 if (item_type == 1) { ret = ImGui::Button("ITEM: Button"); } // Testing button
@ -1307,7 +1308,10 @@ void ImGui::ShowDemoWindow(bool* p_open)
"IsItemEdited() = %d\n" "IsItemEdited() = %d\n"
"IsItemDeactivated() = %d\n" "IsItemDeactivated() = %d\n"
"IsItemDeactivatedEdit() = %d\n" "IsItemDeactivatedEdit() = %d\n"
"IsItemVisible() = %d\n", "IsItemVisible() = %d\n"
"GetItemRectMin() = (%.1f, %.1f)\n"
"GetItemRectMax() = (%.1f, %.1f)\n"
"GetItemRectSize() = (%.1f, %.1f)",
ret, ret,
ImGui::IsItemFocused(), ImGui::IsItemFocused(),
ImGui::IsItemHovered(), ImGui::IsItemHovered(),
@ -1319,7 +1323,10 @@ void ImGui::ShowDemoWindow(bool* p_open)
ImGui::IsItemEdited(), ImGui::IsItemEdited(),
ImGui::IsItemDeactivated(), ImGui::IsItemDeactivated(),
ImGui::IsItemDeactivatedAfterEdit(), 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; static bool embed_all_inside_a_child_window = false;