From 374d160234a5dd433f133cd9c32566b251d96f34 Mon Sep 17 00:00:00 2001 From: ocornut Date: Sun, 31 May 2015 12:55:12 +0100 Subject: [PATCH] BeginPopupContextWindow() in_empty_space_only -> !also_over_items (#126)+ comments Sorry if you used this parameter already. --- imgui.cpp | 14 +++++++------- imgui.h | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 90983bc6d..faa55c336 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3180,26 +3180,26 @@ void ImGui::EndPopup() ImGui::PopStyleVar(); } -bool ImGui::BeginPopupContextItem(const char* str_id, int button) +bool ImGui::BeginPopupContextItem(const char* str_id, int mouse_button) { - if (ImGui::IsItemHovered() && ImGui::IsMouseClicked(button)) + if (ImGui::IsItemHovered() && ImGui::IsMouseClicked(mouse_button)) ImGui::OpenPopup(str_id); return ImGui::BeginPopup(str_id); } -bool ImGui::BeginPopupContextWindow(bool in_empty_space_only, const char* str_id, int button) +bool ImGui::BeginPopupContextWindow(bool also_over_items, const char* str_id, int mouse_button) { if (!str_id) str_id = "window_context_menu"; - if (ImGui::IsMouseHoveringWindow() && ImGui::IsMouseClicked(button)) - if (!in_empty_space_only || !ImGui::IsAnyItemHovered()) + if (ImGui::IsMouseHoveringWindow() && ImGui::IsMouseClicked(mouse_button)) + if (also_over_items || !ImGui::IsAnyItemHovered()) ImGui::OpenPopup(str_id); return ImGui::BeginPopup(str_id); } -bool ImGui::BeginPopupContextVoid(const char* str_id, int button) +bool ImGui::BeginPopupContextVoid(const char* str_id, int mouse_button) { if (!str_id) str_id = "void_context_menu"; - if (!ImGui::IsMouseHoveringAnyWindow() && ImGui::IsMouseClicked(button)) + if (!ImGui::IsMouseHoveringAnyWindow() && ImGui::IsMouseClicked(mouse_button)) ImGui::OpenPopup(str_id); return ImGui::BeginPopup(str_id); } diff --git a/imgui.h b/imgui.h index 617ec6f01..9326956ca 100644 --- a/imgui.h +++ b/imgui.h @@ -170,9 +170,9 @@ namespace ImGui // Popup IMGUI_API void OpenPopup(const char* str_id); // mark popup as open. popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level). close childs popups if any. will close popup when user click outside, or activate a pressable item, or CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block. IMGUI_API bool BeginPopup(const char* str_id); // return true if popup if opened and start outputting to it. only call EndPopup() if BeginPopup() returned true! - IMGUI_API bool BeginPopupContextItem(const char* str_id, int button = 1); // open popup when clicked on last item - IMGUI_API bool BeginPopupContextWindow(bool in_empty_space_only = false, const char* str_id = "window_context_menu", int button = 1); // open popup when clicked on current window - IMGUI_API bool BeginPopupContextVoid(const char* str_id = "void_context_menu", int button = 1); // open popup when clicked in void (no window) + IMGUI_API bool BeginPopupContextItem(const char* str_id, int mouse_button = 1); // open and begin popup when clicked on last item + IMGUI_API bool BeginPopupContextWindow(bool also_over_items = true, const char* str_id = NULL, int mouse_button = 1); // open and begin popup when clicked on current window + IMGUI_API bool BeginPopupContextVoid(const char* str_id = NULL, int mouse_button = 1); // open and begin popup when clicked in void (no window) IMGUI_API void EndPopup(); IMGUI_API void CloseCurrentPopup(); // close the popup we have begin-ed into. clicking on a MenuItem or Selectable automatically close the current popup. @@ -315,7 +315,7 @@ namespace ImGui IMGUI_API void EndMenuBar(); IMGUI_API bool BeginMenu(const char* label, bool enabled = true); // create a sub-menu entry. only call EndMenu() if this returns true! IMGUI_API void EndMenu(); - IMGUI_API bool MenuItem(const char* label, const char* shortcut = NULL, bool selected = false, bool enabled = true); // return true when activated. shortcuts are displayed for convenience but not processed by ImGui + IMGUI_API bool MenuItem(const char* label, const char* shortcut = NULL, bool selected = false, bool enabled = true); // return true when activated. shortcuts are displayed for convenience but not processed by ImGui at the moment IMGUI_API bool MenuItem(const char* label, const char* shortcut, bool* p_selected, bool enabled = true); // return true when activated + toggle (*p_selected) if p_selected != NULL // Widgets: Value() Helpers. Output single value in "name: value" format (tip: freely declare more in your code to handle your types. you can add functions to the ImGui namespace)