Popups: Exposing a little more of popups internals in imgui_internals.h

This commit is contained in:
omar 2017-09-25 12:52:06 +02:00
parent 3dd3d0b248
commit 0a5fb24f10
2 changed files with 9 additions and 9 deletions

View File

@ -623,10 +623,8 @@ static void MarkIniSettingsDirty(ImGuiWindow* window);
static ImRect GetVisibleRect();
static bool BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags);
static void CloseInactivePopups();
static void ClosePopupToLevel(int remaining);
static void ClosePopup(ImGuiID id);
static ImGuiWindow* GetFrontMostModalRootWindow();
static ImVec2 FindBestPopupWindowPos(const ImVec2& base_pos, const ImVec2& size, int* last_dir, const ImRect& rect_to_avoid);
@ -3531,9 +3529,9 @@ static void ClosePopupToLevel(int remaining)
g.OpenPopupStack.resize(remaining);
}
static void ClosePopup(ImGuiID id)
void ImGui::ClosePopup(ImGuiID id)
{
if (!ImGui::IsPopupOpen(id))
if (!IsPopupOpen(id))
return;
ImGuiContext& g = *GImGui;
ClosePopupToLevel(g.OpenPopupStack.Size - 1);
@ -3559,17 +3557,17 @@ static inline void ClearSetNextWindowData()
g.SetNextWindowSizeConstraint = g.SetNextWindowFocus = false;
}
static bool BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags)
bool ImGui::BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
if (!ImGui::IsPopupOpen(id))
if (!IsPopupOpen(id))
{
ClearSetNextWindowData(); // We behave like Begin() and need to consume those values
return false;
}
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
ImGuiWindowFlags flags = extra_flags|ImGuiWindowFlags_Popup|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_AlwaysAutoResize;
char name[20];
@ -3578,11 +3576,11 @@ static bool BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags)
else
ImFormatString(name, IM_ARRAYSIZE(name), "##popup_%08x", id); // Not recycling, so we can close/open during the same frame
bool is_open = ImGui::Begin(name, NULL, flags);
bool is_open = Begin(name, NULL, flags);
if (!(window->Flags & ImGuiWindowFlags_ShowBorders))
g.CurrentWindow->Flags &= ~ImGuiWindowFlags_ShowBorders;
if (!is_open) // NB: is_open can be 'false' when the popup is completely clipped (e.g. zero size display)
ImGui::EndPopup();
EndPopup();
return is_open;
}

View File

@ -774,7 +774,9 @@ namespace ImGui
IMGUI_API void PopItemFlag();
IMGUI_API void OpenPopupEx(ImGuiID id, bool reopen_existing);
IMGUI_API void ClosePopup(ImGuiID id);
IMGUI_API bool IsPopupOpen(ImGuiID id);
IMGUI_API bool BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags);
IMGUI_API int CalcTypematicPressedRepeatAmount(float t, float t_prev, float repeat_delay, float repeat_rate);