mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-16 20:07:18 +01:00
Internal: Storing flags for NextWindowData so that we can clear everything with a single write and remove dummy condition fields.
This commit is contained in:
parent
0b485f12d7
commit
36e714a459
38
imgui.cpp
38
imgui.cpp
@ -4636,7 +4636,7 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFl
|
|||||||
static ImVec2 CalcSizeAfterConstraint(ImGuiWindow* window, ImVec2 new_size)
|
static ImVec2 CalcSizeAfterConstraint(ImGuiWindow* window, ImVec2 new_size)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
if (g.NextWindowData.SizeConstraintCond != 0)
|
if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSizeConstraint)
|
||||||
{
|
{
|
||||||
// Using -1,-1 on either X/Y axis to preserve the current size.
|
// Using -1,-1 on either X/Y axis to preserve the current size.
|
||||||
ImRect cr = g.NextWindowData.SizeConstraintRect;
|
ImRect cr = g.NextWindowData.SizeConstraintRect;
|
||||||
@ -4993,13 +4993,12 @@ void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar
|
|||||||
{
|
{
|
||||||
ImU32 bg_col = GetColorU32(GetWindowBgColorIdxFromFlags(flags));
|
ImU32 bg_col = GetColorU32(GetWindowBgColorIdxFromFlags(flags));
|
||||||
float alpha = 1.0f;
|
float alpha = 1.0f;
|
||||||
if (g.NextWindowData.BgAlphaCond != 0)
|
if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasBgAlpha)
|
||||||
alpha = g.NextWindowData.BgAlphaVal;
|
alpha = g.NextWindowData.BgAlphaVal;
|
||||||
if (alpha != 1.0f)
|
if (alpha != 1.0f)
|
||||||
bg_col = (bg_col & ~IM_COL32_A_MASK) | (IM_F32_TO_INT8_SAT(alpha) << IM_COL32_A_SHIFT);
|
bg_col = (bg_col & ~IM_COL32_A_MASK) | (IM_F32_TO_INT8_SAT(alpha) << IM_COL32_A_SHIFT);
|
||||||
window->DrawList->AddRectFilled(window->Pos + ImVec2(0, window->TitleBarHeight()), window->Pos + window->Size, bg_col, window_rounding, (flags & ImGuiWindowFlags_NoTitleBar) ? ImDrawCornerFlags_All : ImDrawCornerFlags_Bot);
|
window->DrawList->AddRectFilled(window->Pos + ImVec2(0, window->TitleBarHeight()), window->Pos + window->Size, bg_col, window_rounding, (flags & ImGuiWindowFlags_NoTitleBar) ? ImDrawCornerFlags_All : ImDrawCornerFlags_Bot);
|
||||||
}
|
}
|
||||||
g.NextWindowData.BgAlphaCond = 0;
|
|
||||||
|
|
||||||
// Title bar
|
// Title bar
|
||||||
if (!(flags & ImGuiWindowFlags_NoTitleBar))
|
if (!(flags & ImGuiWindowFlags_NoTitleBar))
|
||||||
@ -5130,7 +5129,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
const bool window_just_created = (window == NULL);
|
const bool window_just_created = (window == NULL);
|
||||||
if (window_just_created)
|
if (window_just_created)
|
||||||
{
|
{
|
||||||
ImVec2 size_on_first_use = (g.NextWindowData.SizeCond != 0) ? g.NextWindowData.SizeVal : ImVec2(0.0f, 0.0f); // Any condition flag will do since we are creating a new window here.
|
ImVec2 size_on_first_use = (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSize) ? g.NextWindowData.SizeVal : ImVec2(0.0f, 0.0f); // Any condition flag will do since we are creating a new window here.
|
||||||
window = CreateNewWindow(name, size_on_first_use, flags);
|
window = CreateNewWindow(name, size_on_first_use, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5194,7 +5193,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
// Process SetNextWindow***() calls
|
// Process SetNextWindow***() calls
|
||||||
bool window_pos_set_by_api = false;
|
bool window_pos_set_by_api = false;
|
||||||
bool window_size_x_set_by_api = false, window_size_y_set_by_api = false;
|
bool window_size_x_set_by_api = false, window_size_y_set_by_api = false;
|
||||||
if (g.NextWindowData.PosCond)
|
if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasPos)
|
||||||
{
|
{
|
||||||
window_pos_set_by_api = (window->SetWindowPosAllowFlags & g.NextWindowData.PosCond) != 0;
|
window_pos_set_by_api = (window->SetWindowPosAllowFlags & g.NextWindowData.PosCond) != 0;
|
||||||
if (window_pos_set_by_api && ImLengthSqr(g.NextWindowData.PosPivotVal) > 0.00001f)
|
if (window_pos_set_by_api && ImLengthSqr(g.NextWindowData.PosPivotVal) > 0.00001f)
|
||||||
@ -5210,13 +5209,13 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
SetWindowPos(window, g.NextWindowData.PosVal, g.NextWindowData.PosCond);
|
SetWindowPos(window, g.NextWindowData.PosVal, g.NextWindowData.PosCond);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (g.NextWindowData.SizeCond)
|
if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSize)
|
||||||
{
|
{
|
||||||
window_size_x_set_by_api = (window->SetWindowSizeAllowFlags & g.NextWindowData.SizeCond) != 0 && (g.NextWindowData.SizeVal.x > 0.0f);
|
window_size_x_set_by_api = (window->SetWindowSizeAllowFlags & g.NextWindowData.SizeCond) != 0 && (g.NextWindowData.SizeVal.x > 0.0f);
|
||||||
window_size_y_set_by_api = (window->SetWindowSizeAllowFlags & g.NextWindowData.SizeCond) != 0 && (g.NextWindowData.SizeVal.y > 0.0f);
|
window_size_y_set_by_api = (window->SetWindowSizeAllowFlags & g.NextWindowData.SizeCond) != 0 && (g.NextWindowData.SizeVal.y > 0.0f);
|
||||||
SetWindowSize(window, g.NextWindowData.SizeVal, g.NextWindowData.SizeCond);
|
SetWindowSize(window, g.NextWindowData.SizeVal, g.NextWindowData.SizeCond);
|
||||||
}
|
}
|
||||||
if (g.NextWindowData.ContentSizeCond)
|
if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasContentSize)
|
||||||
{
|
{
|
||||||
// Adjust passed "client size" to become a "window size"
|
// Adjust passed "client size" to become a "window size"
|
||||||
window->SizeContentsExplicit = g.NextWindowData.ContentSizeVal;
|
window->SizeContentsExplicit = g.NextWindowData.ContentSizeVal;
|
||||||
@ -5227,9 +5226,9 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
{
|
{
|
||||||
window->SizeContentsExplicit = ImVec2(0.0f, 0.0f);
|
window->SizeContentsExplicit = ImVec2(0.0f, 0.0f);
|
||||||
}
|
}
|
||||||
if (g.NextWindowData.CollapsedCond)
|
if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasCollapsed)
|
||||||
SetWindowCollapsed(window, g.NextWindowData.CollapsedVal, g.NextWindowData.CollapsedCond);
|
SetWindowCollapsed(window, g.NextWindowData.CollapsedVal, g.NextWindowData.CollapsedCond);
|
||||||
if (g.NextWindowData.FocusCond)
|
if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasFocus)
|
||||||
FocusWindow(window);
|
FocusWindow(window);
|
||||||
if (window->Appearing)
|
if (window->Appearing)
|
||||||
SetWindowConditionAllowFlags(window, ImGuiCond_Appearing, false);
|
SetWindowConditionAllowFlags(window, ImGuiCond_Appearing, false);
|
||||||
@ -5607,7 +5606,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
window->WriteAccessed = false;
|
window->WriteAccessed = false;
|
||||||
|
|
||||||
window->BeginCount++;
|
window->BeginCount++;
|
||||||
g.NextWindowData.Clear();
|
g.NextWindowData.ClearFlags();
|
||||||
|
|
||||||
if (flags & ImGuiWindowFlags_ChildWindow)
|
if (flags & ImGuiWindowFlags_ChildWindow)
|
||||||
{
|
{
|
||||||
@ -6397,6 +6396,7 @@ void ImGui::SetNextWindowPos(const ImVec2& pos, ImGuiCond cond, const ImVec2& pi
|
|||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags.
|
IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags.
|
||||||
|
g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasPos;
|
||||||
g.NextWindowData.PosVal = pos;
|
g.NextWindowData.PosVal = pos;
|
||||||
g.NextWindowData.PosPivotVal = pivot;
|
g.NextWindowData.PosPivotVal = pivot;
|
||||||
g.NextWindowData.PosCond = cond ? cond : ImGuiCond_Always;
|
g.NextWindowData.PosCond = cond ? cond : ImGuiCond_Always;
|
||||||
@ -6406,6 +6406,7 @@ void ImGui::SetNextWindowSize(const ImVec2& size, ImGuiCond cond)
|
|||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags.
|
IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags.
|
||||||
|
g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasSize;
|
||||||
g.NextWindowData.SizeVal = size;
|
g.NextWindowData.SizeVal = size;
|
||||||
g.NextWindowData.SizeCond = cond ? cond : ImGuiCond_Always;
|
g.NextWindowData.SizeCond = cond ? cond : ImGuiCond_Always;
|
||||||
}
|
}
|
||||||
@ -6413,7 +6414,7 @@ void ImGui::SetNextWindowSize(const ImVec2& size, ImGuiCond cond)
|
|||||||
void ImGui::SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& size_max, ImGuiSizeCallback custom_callback, void* custom_callback_user_data)
|
void ImGui::SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& size_max, ImGuiSizeCallback custom_callback, void* custom_callback_user_data)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
g.NextWindowData.SizeConstraintCond = ImGuiCond_Always;
|
g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasSizeConstraint;
|
||||||
g.NextWindowData.SizeConstraintRect = ImRect(size_min, size_max);
|
g.NextWindowData.SizeConstraintRect = ImRect(size_min, size_max);
|
||||||
g.NextWindowData.SizeCallback = custom_callback;
|
g.NextWindowData.SizeCallback = custom_callback;
|
||||||
g.NextWindowData.SizeCallbackUserData = custom_callback_user_data;
|
g.NextWindowData.SizeCallbackUserData = custom_callback_user_data;
|
||||||
@ -6422,14 +6423,15 @@ void ImGui::SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& s
|
|||||||
void ImGui::SetNextWindowContentSize(const ImVec2& size)
|
void ImGui::SetNextWindowContentSize(const ImVec2& size)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
|
g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasContentSize;
|
||||||
g.NextWindowData.ContentSizeVal = size; // In Begin() we will add the size of window decorations (title bar, menu etc.) to that to form a SizeContents value.
|
g.NextWindowData.ContentSizeVal = size; // In Begin() we will add the size of window decorations (title bar, menu etc.) to that to form a SizeContents value.
|
||||||
g.NextWindowData.ContentSizeCond = ImGuiCond_Always;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::SetNextWindowCollapsed(bool collapsed, ImGuiCond cond)
|
void ImGui::SetNextWindowCollapsed(bool collapsed, ImGuiCond cond)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags.
|
IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags.
|
||||||
|
g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasCollapsed;
|
||||||
g.NextWindowData.CollapsedVal = collapsed;
|
g.NextWindowData.CollapsedVal = collapsed;
|
||||||
g.NextWindowData.CollapsedCond = cond ? cond : ImGuiCond_Always;
|
g.NextWindowData.CollapsedCond = cond ? cond : ImGuiCond_Always;
|
||||||
}
|
}
|
||||||
@ -6437,14 +6439,14 @@ void ImGui::SetNextWindowCollapsed(bool collapsed, ImGuiCond cond)
|
|||||||
void ImGui::SetNextWindowFocus()
|
void ImGui::SetNextWindowFocus()
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
g.NextWindowData.FocusCond = ImGuiCond_Always; // Using a Cond member for consistency (may transition all of them to single flag set for fast Clear() op)
|
g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasFocus;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::SetNextWindowBgAlpha(float alpha)
|
void ImGui::SetNextWindowBgAlpha(float alpha)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
|
g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasBgAlpha;
|
||||||
g.NextWindowData.BgAlphaVal = alpha;
|
g.NextWindowData.BgAlphaVal = alpha;
|
||||||
g.NextWindowData.BgAlphaCond = ImGuiCond_Always; // Using a Cond member for consistency (may transition all of them to single flag set for fast Clear() op)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: This is in window space (not screen space!). We should try to obsolete all those functions.
|
// FIXME: This is in window space (not screen space!). We should try to obsolete all those functions.
|
||||||
@ -7144,7 +7146,7 @@ bool ImGui::BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags)
|
|||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
if (!IsPopupOpen(id))
|
if (!IsPopupOpen(id))
|
||||||
{
|
{
|
||||||
g.NextWindowData.Clear(); // We behave like Begin() and need to consume those values
|
g.NextWindowData.ClearFlags(); // We behave like Begin() and need to consume those values
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7166,7 +7168,7 @@ bool ImGui::BeginPopup(const char* str_id, ImGuiWindowFlags flags)
|
|||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
if (g.OpenPopupStack.Size <= g.BeginPopupStack.Size) // Early out for performance
|
if (g.OpenPopupStack.Size <= g.BeginPopupStack.Size) // Early out for performance
|
||||||
{
|
{
|
||||||
g.NextWindowData.Clear(); // We behave like Begin() and need to consume those values
|
g.NextWindowData.ClearFlags(); // We behave like Begin() and need to consume those values
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
flags |= ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings;
|
flags |= ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings;
|
||||||
@ -7182,13 +7184,13 @@ bool ImGui::BeginPopupModal(const char* name, bool* p_open, ImGuiWindowFlags fla
|
|||||||
const ImGuiID id = window->GetID(name);
|
const ImGuiID id = window->GetID(name);
|
||||||
if (!IsPopupOpen(id))
|
if (!IsPopupOpen(id))
|
||||||
{
|
{
|
||||||
g.NextWindowData.Clear(); // We behave like Begin() and need to consume those values
|
g.NextWindowData.ClearFlags(); // We behave like Begin() and need to consume those values
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Center modal windows by default
|
// Center modal windows by default
|
||||||
// FIXME: Should test for (PosCond & window->SetWindowPosAllowFlags) with the upcoming window.
|
// FIXME: Should test for (PosCond & window->SetWindowPosAllowFlags) with the upcoming window.
|
||||||
if (g.NextWindowData.PosCond == 0)
|
if ((g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasPos) == 0)
|
||||||
SetNextWindowPos(g.IO.DisplaySize * 0.5f, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
|
SetNextWindowPos(g.IO.DisplaySize * 0.5f, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
|
||||||
|
|
||||||
flags |= ImGuiWindowFlags_Popup | ImGuiWindowFlags_Modal | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoSavedSettings;
|
flags |= ImGuiWindowFlags_Popup | ImGuiWindowFlags_Modal | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoSavedSettings;
|
||||||
|
@ -71,7 +71,7 @@ struct ImGuiInputTextState; // Internal state of the currently focused/e
|
|||||||
struct ImGuiItemHoveredDataBackup; // Backup and restore IsItemHovered() internal data
|
struct ImGuiItemHoveredDataBackup; // Backup and restore IsItemHovered() internal data
|
||||||
struct ImGuiMenuColumns; // Simple column measurement, currently used for MenuItem() only
|
struct ImGuiMenuColumns; // Simple column measurement, currently used for MenuItem() only
|
||||||
struct ImGuiNavMoveResult; // Result of a directional navigation move query result
|
struct ImGuiNavMoveResult; // Result of a directional navigation move query result
|
||||||
struct ImGuiNextWindowData; // Storage for SetNexWindow** functions
|
struct ImGuiNextWindowData; // Storage for SetNextWindow** functions
|
||||||
struct ImGuiPopupData; // Storage for current popup stack
|
struct ImGuiPopupData; // Storage for current popup stack
|
||||||
struct ImGuiSettingsHandler; // Storage for one type registered in the .ini file
|
struct ImGuiSettingsHandler; // Storage for one type registered in the .ini file
|
||||||
struct ImGuiStyleMod; // Stacked style modifier, backup of modified data so we can restore it
|
struct ImGuiStyleMod; // Stacked style modifier, backup of modified data so we can restore it
|
||||||
@ -82,17 +82,18 @@ struct ImGuiWindowTempData; // Temporary storage for one window (that's
|
|||||||
struct ImGuiWindowSettings; // Storage for window settings stored in .ini file (we keep one of those even if the actual window wasn't instanced during this session)
|
struct ImGuiWindowSettings; // Storage for window settings stored in .ini file (we keep one of those even if the actual window wasn't instanced during this session)
|
||||||
|
|
||||||
// Use your programming IDE "Go to definition" facility on the names of the center columns to find the actual flags/enum lists.
|
// Use your programming IDE "Go to definition" facility on the names of the center columns to find the actual flags/enum lists.
|
||||||
typedef int ImGuiLayoutType; // -> enum ImGuiLayoutType_ // Enum: Horizontal or vertical
|
typedef int ImGuiLayoutType; // -> enum ImGuiLayoutType_ // Enum: Horizontal or vertical
|
||||||
typedef int ImGuiButtonFlags; // -> enum ImGuiButtonFlags_ // Flags: for ButtonEx(), ButtonBehavior()
|
typedef int ImGuiButtonFlags; // -> enum ImGuiButtonFlags_ // Flags: for ButtonEx(), ButtonBehavior()
|
||||||
typedef int ImGuiDragFlags; // -> enum ImGuiDragFlags_ // Flags: for DragBehavior()
|
typedef int ImGuiDragFlags; // -> enum ImGuiDragFlags_ // Flags: for DragBehavior()
|
||||||
typedef int ImGuiItemFlags; // -> enum ImGuiItemFlags_ // Flags: for PushItemFlag()
|
typedef int ImGuiItemFlags; // -> enum ImGuiItemFlags_ // Flags: for PushItemFlag()
|
||||||
typedef int ImGuiItemStatusFlags; // -> enum ImGuiItemStatusFlags_ // Flags: for DC.LastItemStatusFlags
|
typedef int ImGuiItemStatusFlags; // -> enum ImGuiItemStatusFlags_ // Flags: for DC.LastItemStatusFlags
|
||||||
typedef int ImGuiNavHighlightFlags; // -> enum ImGuiNavHighlightFlags_ // Flags: for RenderNavHighlight()
|
typedef int ImGuiNavHighlightFlags; // -> enum ImGuiNavHighlightFlags_ // Flags: for RenderNavHighlight()
|
||||||
typedef int ImGuiNavDirSourceFlags; // -> enum ImGuiNavDirSourceFlags_ // Flags: for GetNavInputAmount2d()
|
typedef int ImGuiNavDirSourceFlags; // -> enum ImGuiNavDirSourceFlags_ // Flags: for GetNavInputAmount2d()
|
||||||
typedef int ImGuiNavMoveFlags; // -> enum ImGuiNavMoveFlags_ // Flags: for navigation requests
|
typedef int ImGuiNavMoveFlags; // -> enum ImGuiNavMoveFlags_ // Flags: for navigation requests
|
||||||
typedef int ImGuiSeparatorFlags; // -> enum ImGuiSeparatorFlags_ // Flags: for Separator() - internal
|
typedef int ImGuiNextWindowDataFlags; // -> enum ImGuiNextWindowDataFlags_// Flags: for SetNextWindowXXX() functions
|
||||||
typedef int ImGuiSliderFlags; // -> enum ImGuiSliderFlags_ // Flags: for SliderBehavior()
|
typedef int ImGuiSeparatorFlags; // -> enum ImGuiSeparatorFlags_ // Flags: for SeparatorEx()
|
||||||
typedef int ImGuiTextFlags; // -> enum ImGuiTextFlags_ // Flags: for TextEx()
|
typedef int ImGuiSliderFlags; // -> enum ImGuiSliderFlags_ // Flags: for SliderBehavior()
|
||||||
|
typedef int ImGuiTextFlags; // -> enum ImGuiTextFlags_ // Flags: for TextEx()
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// STB libraries includes
|
// STB libraries includes
|
||||||
@ -743,44 +744,38 @@ struct ImGuiNavMoveResult
|
|||||||
void Clear() { ID = SelectScopeId = 0; Window = NULL; DistBox = DistCenter = DistAxial = FLT_MAX; RectRel = ImRect(); }
|
void Clear() { ID = SelectScopeId = 0; Window = NULL; DistBox = DistCenter = DistAxial = FLT_MAX; RectRel = ImRect(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum ImGuiNextWindowDataFlags_
|
||||||
|
{
|
||||||
|
ImGuiNextWindowDataFlags_None = 0,
|
||||||
|
ImGuiNextWindowDataFlags_HasPos = 1 << 0,
|
||||||
|
ImGuiNextWindowDataFlags_HasSize = 1 << 1,
|
||||||
|
ImGuiNextWindowDataFlags_HasContentSize = 1 << 2,
|
||||||
|
ImGuiNextWindowDataFlags_HasCollapsed = 1 << 3,
|
||||||
|
ImGuiNextWindowDataFlags_HasSizeConstraint = 1 << 4,
|
||||||
|
ImGuiNextWindowDataFlags_HasFocus = 1 << 5,
|
||||||
|
ImGuiNextWindowDataFlags_HasBgAlpha = 1 << 6
|
||||||
|
};
|
||||||
|
|
||||||
// Storage for SetNexWindow** functions
|
// Storage for SetNexWindow** functions
|
||||||
struct ImGuiNextWindowData
|
struct ImGuiNextWindowData
|
||||||
{
|
{
|
||||||
ImGuiCond PosCond;
|
ImGuiNextWindowDataFlags Flags;
|
||||||
ImGuiCond SizeCond;
|
ImGuiCond PosCond;
|
||||||
ImGuiCond ContentSizeCond;
|
ImGuiCond SizeCond;
|
||||||
ImGuiCond CollapsedCond;
|
ImGuiCond CollapsedCond;
|
||||||
ImGuiCond SizeConstraintCond;
|
ImVec2 PosVal;
|
||||||
ImGuiCond FocusCond;
|
ImVec2 PosPivotVal;
|
||||||
ImGuiCond BgAlphaCond;
|
ImVec2 SizeVal;
|
||||||
ImVec2 PosVal;
|
ImVec2 ContentSizeVal;
|
||||||
ImVec2 PosPivotVal;
|
bool CollapsedVal;
|
||||||
ImVec2 SizeVal;
|
ImRect SizeConstraintRect;
|
||||||
ImVec2 ContentSizeVal;
|
ImGuiSizeCallback SizeCallback;
|
||||||
bool CollapsedVal;
|
void* SizeCallbackUserData;
|
||||||
ImRect SizeConstraintRect;
|
float BgAlphaVal;
|
||||||
ImGuiSizeCallback SizeCallback;
|
ImVec2 MenuBarOffsetMinVal; // This is not exposed publicly, so we don't clear it.
|
||||||
void* SizeCallbackUserData;
|
|
||||||
float BgAlphaVal;
|
ImGuiNextWindowData() { memset(this, 0, sizeof(*this)); }
|
||||||
ImVec2 MenuBarOffsetMinVal; // This is not exposed publicly, so we don't clear it.
|
inline void ClearFlags() { Flags = ImGuiNextWindowDataFlags_None; }
|
||||||
|
|
||||||
ImGuiNextWindowData()
|
|
||||||
{
|
|
||||||
PosCond = SizeCond = ContentSizeCond = CollapsedCond = SizeConstraintCond = FocusCond = BgAlphaCond = 0;
|
|
||||||
PosVal = PosPivotVal = SizeVal = ImVec2(0.0f, 0.0f);
|
|
||||||
ContentSizeVal = ImVec2(0.0f, 0.0f);
|
|
||||||
CollapsedVal = false;
|
|
||||||
SizeConstraintRect = ImRect();
|
|
||||||
SizeCallback = NULL;
|
|
||||||
SizeCallbackUserData = NULL;
|
|
||||||
BgAlphaVal = FLT_MAX;
|
|
||||||
MenuBarOffsetMinVal = ImVec2(0.0f, 0.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Clear()
|
|
||||||
{
|
|
||||||
PosCond = SizeCond = ContentSizeCond = CollapsedCond = SizeConstraintCond = FocusCond = BgAlphaCond = 0;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -1350,8 +1350,8 @@ bool ImGui::BeginCombo(const char* label, const char* preview_value, ImGuiComboF
|
|||||||
{
|
{
|
||||||
// Always consume the SetNextWindowSizeConstraint() call in our early return paths
|
// Always consume the SetNextWindowSizeConstraint() call in our early return paths
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
ImGuiCond backup_next_window_size_constraint = g.NextWindowData.SizeConstraintCond;
|
bool has_window_size_constraint = (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSizeConstraint) != 0;
|
||||||
g.NextWindowData.SizeConstraintCond = 0;
|
g.NextWindowData.Flags &= ~ImGuiNextWindowDataFlags_HasSizeConstraint;
|
||||||
|
|
||||||
ImGuiWindow* window = GetCurrentWindow();
|
ImGuiWindow* window = GetCurrentWindow();
|
||||||
if (window->SkipItems)
|
if (window->SkipItems)
|
||||||
@ -1403,9 +1403,9 @@ bool ImGui::BeginCombo(const char* label, const char* preview_value, ImGuiComboF
|
|||||||
if (!popup_open)
|
if (!popup_open)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (backup_next_window_size_constraint)
|
if (has_window_size_constraint)
|
||||||
{
|
{
|
||||||
g.NextWindowData.SizeConstraintCond = backup_next_window_size_constraint;
|
g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasSizeConstraint;
|
||||||
g.NextWindowData.SizeConstraintRect.Min.x = ImMax(g.NextWindowData.SizeConstraintRect.Min.x, w);
|
g.NextWindowData.SizeConstraintRect.Min.x = ImMax(g.NextWindowData.SizeConstraintRect.Min.x, w);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1495,7 +1495,7 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi
|
|||||||
items_getter(data, *current_item, &preview_value);
|
items_getter(data, *current_item, &preview_value);
|
||||||
|
|
||||||
// The old Combo() API exposed "popup_max_height_in_items". The new more general BeginCombo() API doesn't have/need it, but we emulate it here.
|
// The old Combo() API exposed "popup_max_height_in_items". The new more general BeginCombo() API doesn't have/need it, but we emulate it here.
|
||||||
if (popup_max_height_in_items != -1 && !g.NextWindowData.SizeConstraintCond)
|
if (popup_max_height_in_items != -1 && !(g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSizeConstraint))
|
||||||
SetNextWindowSizeConstraints(ImVec2(0,0), ImVec2(FLT_MAX, CalcMaxPopupHeightFromItemCount(popup_max_height_in_items)));
|
SetNextWindowSizeConstraints(ImVec2(0,0), ImVec2(FLT_MAX, CalcMaxPopupHeightFromItemCount(popup_max_height_in_items)));
|
||||||
|
|
||||||
if (!BeginCombo(label, preview_value, ImGuiComboFlags_None))
|
if (!BeginCombo(label, preview_value, ImGuiComboFlags_None))
|
||||||
|
Loading…
Reference in New Issue
Block a user