mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-19 06:26:35 +00:00
Merge branch 'master' into navigation
This commit is contained in:
commit
919fc548ad
31
imgui.cpp
31
imgui.cpp
@ -5062,14 +5062,13 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFl
|
|||||||
{
|
{
|
||||||
// Retrieve settings from .ini file
|
// Retrieve settings from .ini file
|
||||||
// Use SetWindowPos() or SetNextWindowPos() with the appropriate condition flag to change the initial position of a window.
|
// Use SetWindowPos() or SetNextWindowPos() with the appropriate condition flag to change the initial position of a window.
|
||||||
window->PosFloat = ImVec2(60, 60);
|
window->Pos = window->PosFloat = ImVec2(60, 60);
|
||||||
window->Pos = ImVec2((float)(int)window->PosFloat.x, (float)(int)window->PosFloat.y);
|
|
||||||
|
|
||||||
if (ImGuiWindowSettings* settings = ImGui::FindWindowSettings(window->ID))
|
if (ImGuiWindowSettings* settings = ImGui::FindWindowSettings(window->ID))
|
||||||
{
|
{
|
||||||
SetWindowConditionAllowFlags(window, ImGuiCond_FirstUseEver, false);
|
SetWindowConditionAllowFlags(window, ImGuiCond_FirstUseEver, false);
|
||||||
window->PosFloat = settings->Pos;
|
window->PosFloat = settings->Pos;
|
||||||
window->Pos = ImVec2((float)(int)window->PosFloat.x, (float)(int)window->PosFloat.y);
|
window->Pos = ImFloor(window->PosFloat);
|
||||||
window->Collapsed = settings->Collapsed;
|
window->Collapsed = settings->Collapsed;
|
||||||
if (ImLengthSqr(settings->Size) > 0.00001f)
|
if (ImLengthSqr(settings->Size) > 0.00001f)
|
||||||
size = settings->Size;
|
size = settings->Size;
|
||||||
@ -5381,6 +5380,13 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
window->LastFrameActive = current_frame;
|
window->LastFrameActive = current_frame;
|
||||||
window->IDStack.resize(1);
|
window->IDStack.resize(1);
|
||||||
|
|
||||||
|
// Lock window rounding, border size and rounding so that altering the border sizes for children doesn't have side-effects.
|
||||||
|
window->WindowRounding = (flags & ImGuiWindowFlags_ChildWindow) ? style.ChildRounding : ((flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiWindowFlags_Modal)) ? style.PopupRounding : style.WindowRounding;
|
||||||
|
window->WindowBorderSize = (flags & ImGuiWindowFlags_ChildWindow) ? style.ChildBorderSize : ((flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiWindowFlags_Modal)) ? style.PopupBorderSize : style.WindowBorderSize;
|
||||||
|
window->WindowPadding = style.WindowPadding;
|
||||||
|
if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & (ImGuiWindowFlags_AlwaysUseWindowPadding | ImGuiWindowFlags_Popup)) && window->WindowBorderSize == 0.0f)
|
||||||
|
window->WindowPadding = ImVec2(0.0f, (flags & ImGuiWindowFlags_MenuBar) ? style.WindowPadding.y : 0.0f);
|
||||||
|
|
||||||
// Setup draw list and outer clipping rectangle
|
// Setup draw list and outer clipping rectangle
|
||||||
window->DrawList->Clear();
|
window->DrawList->Clear();
|
||||||
window->DrawList->Flags = (g.Style.AntiAliasedLines ? ImDrawListFlags_AntiAliasedLines : 0) | (g.Style.AntiAliasedFill ? ImDrawListFlags_AntiAliasedFill : 0);
|
window->DrawList->Flags = (g.Style.AntiAliasedLines ? ImDrawListFlags_AntiAliasedLines : 0) | (g.Style.AntiAliasedFill ? ImDrawListFlags_AntiAliasedFill : 0);
|
||||||
@ -5396,7 +5402,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
// Popup first latch mouse position, will position itself when it appears next frame
|
// Popup first latch mouse position, will position itself when it appears next frame
|
||||||
window->AutoPosLastDirection = ImGuiDir_None;
|
window->AutoPosLastDirection = ImGuiDir_None;
|
||||||
if ((flags & ImGuiWindowFlags_Popup) != 0 && !window_pos_set_by_api)
|
if ((flags & ImGuiWindowFlags_Popup) != 0 && !window_pos_set_by_api)
|
||||||
window->PosFloat = g.CurrentPopupStack.back().OpenPopupPos;
|
window->Pos = window->PosFloat = g.CurrentPopupStack.back().OpenPopupPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collapse window by double-clicking on title bar
|
// Collapse window by double-clicking on title bar
|
||||||
@ -5438,15 +5444,6 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lock window rounding, border size and rounding so that altering the border sizes for children doesn't have side-effects.
|
|
||||||
window->WindowRounding = (flags & ImGuiWindowFlags_ChildWindow) ? style.ChildRounding : ((flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiWindowFlags_Modal)) ? style.PopupRounding : style.WindowRounding;
|
|
||||||
window->WindowBorderSize = (flags & ImGuiWindowFlags_ChildWindow) ? style.ChildBorderSize : ((flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiWindowFlags_Modal)) ? style.PopupBorderSize : style.WindowBorderSize;
|
|
||||||
window->WindowPadding = style.WindowPadding;
|
|
||||||
if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & (ImGuiWindowFlags_AlwaysUseWindowPadding | ImGuiWindowFlags_Popup)) && window->WindowBorderSize == 0.0f)
|
|
||||||
window->WindowPadding = ImVec2(0.0f, (flags & ImGuiWindowFlags_MenuBar) ? style.WindowPadding.y : 0.0f);
|
|
||||||
const float window_rounding = window->WindowRounding;
|
|
||||||
const float window_border_size = window->WindowBorderSize;
|
|
||||||
|
|
||||||
// Calculate auto-fit size, handle automatic resize
|
// Calculate auto-fit size, handle automatic resize
|
||||||
const ImVec2 size_auto_fit = CalcSizeAutoFit(window, window->SizeContents);
|
const ImVec2 size_auto_fit = CalcSizeAutoFit(window, window->SizeContents);
|
||||||
ImVec2 size_full_modified(FLT_MAX, FLT_MAX);
|
ImVec2 size_full_modified(FLT_MAX, FLT_MAX);
|
||||||
@ -5551,7 +5548,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
window->PosFloat = ImMin(window->PosFloat, g.IO.DisplaySize - padding);
|
window->PosFloat = ImMin(window->PosFloat, g.IO.DisplaySize - padding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
window->Pos = ImVec2((float)(int)window->PosFloat.x, (float)(int)window->PosFloat.y);
|
window->Pos = ImFloor(window->PosFloat);
|
||||||
|
|
||||||
// Default item width. Make it proportional to window size if window manually resizes
|
// Default item width. Make it proportional to window size if window manually resizes
|
||||||
if (window->Size.x > 0.0f && !(flags & ImGuiWindowFlags_Tooltip) && !(flags & ImGuiWindowFlags_AlwaysAutoResize))
|
if (window->Size.x > 0.0f && !(flags & ImGuiWindowFlags_Tooltip) && !(flags & ImGuiWindowFlags_AlwaysAutoResize))
|
||||||
@ -5589,6 +5586,8 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
window->DrawList->AddRectFilled(fullscreen_rect.Min, fullscreen_rect.Max, GetColorU32(ImGuiCol_ModalWindowDarkening, g.ModalWindowDarkeningRatio));
|
window->DrawList->AddRectFilled(fullscreen_rect.Min, fullscreen_rect.Max, GetColorU32(ImGuiCol_ModalWindowDarkening, g.ModalWindowDarkeningRatio));
|
||||||
|
|
||||||
// Draw window + handle manual resize
|
// Draw window + handle manual resize
|
||||||
|
const float window_rounding = window->WindowRounding;
|
||||||
|
const float window_border_size = window->WindowBorderSize;
|
||||||
ImRect title_bar_rect = window->TitleBarRect();
|
ImRect title_bar_rect = window->TitleBarRect();
|
||||||
const bool window_is_focused = want_focus || (g.NavWindow && window->RootNonPopupWindow == g.NavWindow->RootNonPopupWindow);
|
const bool window_is_focused = want_focus || (g.NavWindow && window->RootNonPopupWindow == g.NavWindow->RootNonPopupWindow);
|
||||||
if (window->Collapsed)
|
if (window->Collapsed)
|
||||||
@ -5697,7 +5696,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
}
|
}
|
||||||
if (pos_target.x != FLT_MAX)
|
if (pos_target.x != FLT_MAX)
|
||||||
{
|
{
|
||||||
window->Pos = window->PosFloat = ImVec2((float)(int)pos_target.x, (float)(int)pos_target.y);
|
window->Pos = window->PosFloat = ImFloor(pos_target);
|
||||||
MarkIniSettingsDirty(window);
|
MarkIniSettingsDirty(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6565,7 +6564,7 @@ static void SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond)
|
|||||||
// Set
|
// Set
|
||||||
const ImVec2 old_pos = window->Pos;
|
const ImVec2 old_pos = window->Pos;
|
||||||
window->PosFloat = pos;
|
window->PosFloat = pos;
|
||||||
window->Pos = ImVec2((float)(int)window->PosFloat.x, (float)(int)window->PosFloat.y);
|
window->Pos = ImFloor(pos);
|
||||||
window->DC.CursorPos += (window->Pos - old_pos); // As we happen to move the window while it is being appended to (which is a bad idea - will smear) let's at least offset the cursor
|
window->DC.CursorPos += (window->Pos - old_pos); // As we happen to move the window while it is being appended to (which is a bad idea - will smear) let's at least offset the cursor
|
||||||
window->DC.CursorMaxPos += (window->Pos - old_pos); // And more importantly we need to adjust this so size calculation doesn't get affected.
|
window->DC.CursorMaxPos += (window->Pos - old_pos); // And more importantly we need to adjust this so size calculation doesn't get affected.
|
||||||
}
|
}
|
||||||
|
@ -136,8 +136,8 @@ static inline int ImMin(int lhs, int rhs)
|
|||||||
static inline int ImMax(int lhs, int rhs) { return lhs >= rhs ? lhs : rhs; }
|
static inline int ImMax(int lhs, int rhs) { return lhs >= rhs ? lhs : rhs; }
|
||||||
static inline float ImMin(float lhs, float rhs) { return lhs < rhs ? lhs : rhs; }
|
static inline float ImMin(float lhs, float rhs) { return lhs < rhs ? lhs : rhs; }
|
||||||
static inline float ImMax(float lhs, float rhs) { return lhs >= rhs ? lhs : rhs; }
|
static inline float ImMax(float lhs, float rhs) { return lhs >= rhs ? lhs : rhs; }
|
||||||
static inline ImVec2 ImMin(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(ImMin(lhs.x,rhs.x), ImMin(lhs.y,rhs.y)); }
|
static inline ImVec2 ImMin(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x < rhs.x ? lhs.x : rhs.x, lhs.y < rhs.y ? lhs.y : rhs.y); }
|
||||||
static inline ImVec2 ImMax(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(ImMax(lhs.x,rhs.x), ImMax(lhs.y,rhs.y)); }
|
static inline ImVec2 ImMax(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x >= rhs.x ? lhs.x : rhs.x, lhs.y >= rhs.y ? lhs.y : rhs.y); }
|
||||||
static inline int ImClamp(int v, int mn, int mx) { return (v < mn) ? mn : (v > mx) ? mx : v; }
|
static inline int ImClamp(int v, int mn, int mx) { return (v < mn) ? mn : (v > mx) ? mx : v; }
|
||||||
static inline float ImClamp(float v, float mn, float mx) { return (v < mn) ? mn : (v > mx) ? mx : v; }
|
static inline float ImClamp(float v, float mn, float mx) { return (v < mn) ? mn : (v > mx) ? mx : v; }
|
||||||
static inline ImVec2 ImClamp(const ImVec2& f, const ImVec2& mn, ImVec2 mx) { return ImVec2(ImClamp(f.x,mn.x,mx.x), ImClamp(f.y,mn.y,mx.y)); }
|
static inline ImVec2 ImClamp(const ImVec2& f, const ImVec2& mn, ImVec2 mx) { return ImVec2(ImClamp(f.x,mn.x,mx.x), ImClamp(f.y,mn.y,mx.y)); }
|
||||||
@ -303,7 +303,8 @@ struct IMGUI_API ImRect
|
|||||||
void Expand(const float amount) { Min.x -= amount; Min.y -= amount; Max.x += amount; Max.y += amount; }
|
void Expand(const float amount) { Min.x -= amount; Min.y -= amount; Max.x += amount; Max.y += amount; }
|
||||||
void Expand(const ImVec2& amount) { Min.x -= amount.x; Min.y -= amount.y; Max.x += amount.x; Max.y += amount.y; }
|
void Expand(const ImVec2& amount) { Min.x -= amount.x; Min.y -= amount.y; Max.x += amount.x; Max.y += amount.y; }
|
||||||
void Translate(const ImVec2& v) { Min.x += v.x; Min.y += v.y; Max.x += v.x; Max.y += v.y; }
|
void Translate(const ImVec2& v) { Min.x += v.x; Min.y += v.y; Max.x += v.x; Max.y += v.y; }
|
||||||
void ClipWith(const ImRect& r) { if (Min.x < r.Min.x) Min.x = r.Min.x; if (Min.y < r.Min.y) Min.y = r.Min.y; if (Max.x > r.Max.x) Max.x = r.Max.x; if (Max.y > r.Max.y) Max.y = r.Max.y; }
|
void ClipWith(const ImRect& r) { Min = ImMax(Min, r.Min); Max = ImMin(Max, r.Max); } // Simple version, may lead to an inverted rectangle, which is fine for Contains/Overlaps test but not for display.
|
||||||
|
void ClipWithFull(const ImRect& r) { Min = ImClamp(Min, r.Min, r.Max); Max = ImClamp(Max, r.Min, r.Max); } // Full version, ensure both points are fully clipped.
|
||||||
void Floor() { Min.x = (float)(int)Min.x; Min.y = (float)(int)Min.y; Max.x = (float)(int)Max.x; Max.y = (float)(int)Max.y; }
|
void Floor() { Min.x = (float)(int)Min.x; Min.y = (float)(int)Min.y; Max.x = (float)(int)Max.x; Max.y = (float)(int)Max.y; }
|
||||||
void FixInverted() { if (Min.x > Max.x) ImSwap(Min.x, Max.x); if (Min.y > Max.y) ImSwap(Min.y, Max.y); }
|
void FixInverted() { if (Min.x > Max.x) ImSwap(Min.x, Max.x); if (Min.y > Max.y) ImSwap(Min.y, Max.y); }
|
||||||
bool IsFinite() const { return Min.x != FLT_MAX; }
|
bool IsFinite() const { return Min.x != FLT_MAX; }
|
||||||
|
Loading…
Reference in New Issue
Block a user