Merged miscellaneous small stuff (from nav/dock branches).
This commit is contained in:
parent
b174fcc9af
commit
7c7a7baf76
29
imgui.cpp
29
imgui.cpp
@ -1826,7 +1826,6 @@ ImGuiWindow::ImGuiWindow(const char* name)
|
||||
ID = ImHash(name, 0);
|
||||
IDStack.push_back(ID);
|
||||
Flags = 0;
|
||||
OrderWithinParent = 0;
|
||||
PosFloat = Pos = ImVec2(0.0f, 0.0f);
|
||||
Size = SizeFull = ImVec2(0.0f, 0.0f);
|
||||
SizeContents = SizeContentsExplicit = ImVec2(0.0f, 0.0f);
|
||||
@ -1845,6 +1844,8 @@ ImGuiWindow::ImGuiWindow(const char* name)
|
||||
SkipItems = false;
|
||||
Appearing = false;
|
||||
CloseButton = false;
|
||||
BeginOrderWithinParent = -1;
|
||||
BeginOrderWithinContext = -1;
|
||||
BeginCount = 0;
|
||||
PopupId = 0;
|
||||
AutoFitFramesX = AutoFitFramesY = -1;
|
||||
@ -2271,7 +2272,7 @@ void ImGui::NewFrame()
|
||||
|
||||
// Initialize on first frame
|
||||
if (!g.Initialized)
|
||||
ImGui::Initialize();
|
||||
Initialize();
|
||||
|
||||
SetCurrentFont(GetDefaultFont());
|
||||
IM_ASSERT(g.Font->IsLoaded());
|
||||
@ -2279,6 +2280,7 @@ void ImGui::NewFrame()
|
||||
g.Time += g.IO.DeltaTime;
|
||||
g.FrameCount += 1;
|
||||
g.TooltipOverrideCount = 0;
|
||||
g.WindowsActiveCount = 0;
|
||||
g.OverlayDrawList.Clear();
|
||||
g.OverlayDrawList.PushTextureID(g.IO.Fonts->TexID);
|
||||
g.OverlayDrawList.PushClipRectFullScreen();
|
||||
@ -2497,8 +2499,8 @@ void ImGui::NewFrame()
|
||||
|
||||
// Create implicit window - we will only render it if the user has added something to it.
|
||||
// We don't use "Debug" to avoid colliding with user trying to create a "Debug" window with custom flags.
|
||||
ImGui::SetNextWindowSize(ImVec2(400,400), ImGuiCond_FirstUseEver);
|
||||
ImGui::Begin("Debug##Default");
|
||||
SetNextWindowSize(ImVec2(400,400), ImGuiCond_FirstUseEver);
|
||||
Begin("Debug##Default");
|
||||
}
|
||||
|
||||
static void* SettingsHandlerWindow_ReadOpen(ImGuiContext&, const char* name)
|
||||
@ -2785,7 +2787,7 @@ static int ChildWindowComparer(const void* lhs, const void* rhs)
|
||||
return d;
|
||||
if (int d = (a->Flags & ImGuiWindowFlags_Tooltip) - (b->Flags & ImGuiWindowFlags_Tooltip))
|
||||
return d;
|
||||
return (a->OrderWithinParent - b->OrderWithinParent);
|
||||
return (a->BeginOrderWithinParent - b->BeginOrderWithinParent);
|
||||
}
|
||||
|
||||
static void AddWindowToSortedBuffer(ImVector<ImGuiWindow*>& out_sorted_windows, ImGuiWindow* window)
|
||||
@ -3359,7 +3361,7 @@ void ImGui::CalcListClipping(int items_count, float items_height, int* out_items
|
||||
static ImGuiWindow* FindHoveredWindow(ImVec2 pos)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
for (int i = g.Windows.Size-1; i >= 0; i--)
|
||||
for (int i = g.Windows.Size - 1; i >= 0; i--)
|
||||
{
|
||||
ImGuiWindow* window = g.Windows[i];
|
||||
if (!window->Active)
|
||||
@ -3598,7 +3600,8 @@ bool ImGui::IsItemClicked(int mouse_button)
|
||||
|
||||
bool ImGui::IsAnyItemHovered()
|
||||
{
|
||||
return GImGui->HoveredId != 0 || GImGui->HoveredIdPreviousFrame != 0;
|
||||
ImGuiContext& g = *GImGui;
|
||||
return g.HoveredId != 0 || g.HoveredIdPreviousFrame != 0;
|
||||
}
|
||||
|
||||
bool ImGui::IsAnyItemActive()
|
||||
@ -3914,8 +3917,9 @@ bool ImGui::BeginPopupContextItem(const char* str_id, int mouse_button)
|
||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||
ImGuiID id = str_id ? window->GetID(str_id) : window->DC.LastItemId; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict!
|
||||
IM_ASSERT(id != 0); // However, you cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item)
|
||||
if (IsMouseClicked(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup))
|
||||
OpenPopupEx(id, true);
|
||||
if (IsMouseClicked(mouse_button))
|
||||
if (IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup))
|
||||
OpenPopupEx(id, true);
|
||||
return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize);
|
||||
}
|
||||
|
||||
@ -4448,7 +4452,8 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
// window->RootNavWindow = window->RootNavWindow->ParentWindow;
|
||||
|
||||
window->Active = true;
|
||||
window->OrderWithinParent = 0;
|
||||
window->BeginOrderWithinParent = 0;
|
||||
window->BeginOrderWithinContext = g.WindowsActiveCount++;
|
||||
window->BeginCount = 0;
|
||||
window->ClipRect = ImVec4(-FLT_MAX,-FLT_MAX,+FLT_MAX,+FLT_MAX);
|
||||
window->LastFrameActive = current_frame;
|
||||
@ -4570,7 +4575,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
// Position child window
|
||||
if (flags & ImGuiWindowFlags_ChildWindow)
|
||||
{
|
||||
window->OrderWithinParent = parent_window->DC.ChildWindows.Size;
|
||||
window->BeginOrderWithinParent = parent_window->DC.ChildWindows.Size;
|
||||
parent_window->DC.ChildWindows.push_back(window);
|
||||
}
|
||||
if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Popup) && !window_pos_set_by_api)
|
||||
@ -6685,6 +6690,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
|
||||
button_flags |= ImGuiButtonFlags_PressedOnDragDropHold;
|
||||
if (flags & ImGuiTreeNodeFlags_OpenOnDoubleClick)
|
||||
button_flags |= ImGuiButtonFlags_PressedOnDoubleClick | ((flags & ImGuiTreeNodeFlags_OpenOnArrow) ? ImGuiButtonFlags_PressedOnClickRelease : 0);
|
||||
|
||||
bool hovered, held, pressed = ButtonBehavior(interact_bb, id, &hovered, &held, button_flags);
|
||||
if (pressed && !(flags & ImGuiTreeNodeFlags_Leaf))
|
||||
{
|
||||
@ -6774,7 +6780,6 @@ bool ImGui::CollapsingHeader(const char* label, bool* p_open, ImGuiTreeNodeFlags
|
||||
ImGuiContext& g = *GImGui;
|
||||
float button_sz = g.FontSize * 0.5f;
|
||||
ImGuiItemHoveredDataBackup last_item_backup;
|
||||
last_item_backup.Backup();
|
||||
if (CloseButton(window->GetID((void*)(intptr_t)(id+1)), ImVec2(ImMin(window->DC.LastItemRect.Max.x, window->ClipRect.Max.x) - g.Style.FramePadding.x - button_sz, window->DC.LastItemRect.Min.y + g.Style.FramePadding.y + button_sz), button_sz))
|
||||
*p_open = false;
|
||||
last_item_backup.Restore();
|
||||
|
4
imgui.h
4
imgui.h
@ -79,8 +79,8 @@ typedef int ImGuiMouseCursor; // enum: a mouse cursor identifier
|
||||
typedef int ImGuiStyleVar; // enum: a variable identifier for styling // enum ImGuiStyleVar_
|
||||
typedef int ImDrawCornerFlags; // flags: for ImDrawList::AddRect*() etc. // enum ImDrawCornerFlags_
|
||||
typedef int ImGuiColorEditFlags; // flags: for ColorEdit*(), ColorPicker*() // enum ImGuiColorEditFlags_
|
||||
typedef int ImGuiDragDropFlags; // flags: for *DragDrop*() // enum ImGuiDragDropFlags_
|
||||
typedef int ImGuiColumnsFlags; // flags: for *Columns*() // enum ImGuiColumnsFlags_
|
||||
typedef int ImGuiDragDropFlags; // flags: for *DragDrop*() // enum ImGuiDragDropFlags_
|
||||
typedef int ImGuiComboFlags; // flags: for BeginCombo() // enum ImGuiComboFlags_
|
||||
typedef int ImGuiFocusedFlags; // flags: for IsWindowFocused() // enum ImGuiFocusedFlags_
|
||||
typedef int ImGuiHoveredFlags; // flags: for IsItemHovered() etc. // enum ImGuiHoveredFlags_
|
||||
@ -627,7 +627,7 @@ enum ImGuiHoveredFlags_
|
||||
ImGuiHoveredFlags_RootWindow = 1 << 1, // IsWindowHovered() only: Test from root window (top most parent of the current hierarchy)
|
||||
ImGuiHoveredFlags_AllowWhenBlockedByPopup = 1 << 2, // Return true even if a popup window is normally blocking access to this item/window
|
||||
//ImGuiHoveredFlags_AllowWhenBlockedByModal = 1 << 3, // Return true even if a modal popup window is normally blocking access to this item/window. FIXME-TODO: Unavailable yet.
|
||||
ImGuiHoveredFlags_AllowWhenBlockedByActiveItem = 1 << 4, // Return true even if an active item is blocking access to this item/window
|
||||
ImGuiHoveredFlags_AllowWhenBlockedByActiveItem = 1 << 4, // Return true even if an active item is blocking access to this item/window. Useful for Drag and Drop patterns.
|
||||
ImGuiHoveredFlags_AllowWhenOverlapped = 1 << 5, // Return true even if the position is overlapped by another window
|
||||
ImGuiHoveredFlags_RectOnly = ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem | ImGuiHoveredFlags_AllowWhenOverlapped
|
||||
};
|
||||
|
@ -183,7 +183,7 @@ enum ImGuiButtonFlags_
|
||||
ImGuiButtonFlags_AllowItemOverlap = 1 << 6, // require previous frame HoveredId to either match id or be null before being usable, use along with SetItemAllowOverlap()
|
||||
ImGuiButtonFlags_DontClosePopups = 1 << 7, // disable automatically closing parent popup on press // [UNUSED]
|
||||
ImGuiButtonFlags_Disabled = 1 << 8, // disable interactions
|
||||
ImGuiButtonFlags_AlignTextBaseLine = 1 << 9, // vertically align button to match text baseline (ButtonEx() only)
|
||||
ImGuiButtonFlags_AlignTextBaseLine = 1 << 9, // vertically align button to match text baseline - ButtonEx() only // FIXME: Should be removed and handled by SmallButton(), not possible currently because of DC.CursorPosPrevLine
|
||||
ImGuiButtonFlags_NoKeyModifiers = 1 << 10, // disable interaction if a key modifier is held
|
||||
ImGuiButtonFlags_NoHoldingActiveID = 1 << 11, // don't set ActiveId while holding the mouse (ImGuiButtonFlags_PressedOnClick only)
|
||||
ImGuiButtonFlags_PressedOnDragDropHold = 1 << 12 // press when held into while we are drag and dropping another item (used by e.g. tree nodes, collapsing headers)
|
||||
@ -207,8 +207,8 @@ enum ImGuiColumnsFlags_
|
||||
enum ImGuiSelectableFlagsPrivate_
|
||||
{
|
||||
// NB: need to be in sync with last value of ImGuiSelectableFlags_
|
||||
ImGuiSelectableFlags_Menu = 1 << 3,
|
||||
ImGuiSelectableFlags_MenuItem = 1 << 4,
|
||||
ImGuiSelectableFlags_Menu = 1 << 3, // -> PressedOnClick
|
||||
ImGuiSelectableFlags_MenuItem = 1 << 4, // -> PressedOnRelease
|
||||
ImGuiSelectableFlags_Disabled = 1 << 5,
|
||||
ImGuiSelectableFlags_DrawFillAvailWidth = 1 << 6
|
||||
};
|
||||
@ -439,6 +439,7 @@ struct ImGuiContext
|
||||
ImVector<ImGuiWindow*> WindowsSortBuffer;
|
||||
ImVector<ImGuiWindow*> CurrentWindowStack;
|
||||
ImGuiStorage WindowsById;
|
||||
int WindowsActiveCount;
|
||||
ImGuiWindow* CurrentWindow; // Being drawn into
|
||||
ImGuiWindow* NavWindow; // Nav/focused window for navigation
|
||||
ImGuiWindow* HoveredWindow; // Will catch mouse inputs
|
||||
@ -550,6 +551,7 @@ struct ImGuiContext
|
||||
Time = 0.0f;
|
||||
FrameCount = 0;
|
||||
FrameCountEnded = FrameCountRendered = -1;
|
||||
WindowsActiveCount = 0;
|
||||
CurrentWindow = NULL;
|
||||
NavWindow = NULL;
|
||||
HoveredWindow = NULL;
|
||||
@ -723,7 +725,6 @@ struct IMGUI_API ImGuiWindow
|
||||
char* Name;
|
||||
ImGuiID ID; // == ImHash(Name)
|
||||
ImGuiWindowFlags Flags; // See enum ImGuiWindowFlags_
|
||||
int OrderWithinParent; // Order within immediate parent window, if we are a child window. Otherwise 0.
|
||||
ImVec2 PosFloat;
|
||||
ImVec2 Pos; // Position rounded-up to nearest pixel
|
||||
ImVec2 Size; // Current size (==SizeFull or collapsed title bar size)
|
||||
@ -748,6 +749,8 @@ struct IMGUI_API ImGuiWindow
|
||||
bool SkipItems; // Set when items can safely be all clipped (e.g. window not visible or collapsed)
|
||||
bool Appearing; // Set during the frame where the window is appearing (or re-appearing)
|
||||
bool CloseButton; // Set when the window has a close button (p_open != NULL)
|
||||
int BeginOrderWithinParent; // Order within immediate parent window, if we are a child window. Otherwise 0.
|
||||
int BeginOrderWithinContext; // Order within entire imgui context. This is mostly used for debugging submission order related issues.
|
||||
int BeginCount; // Number of Begin() during the current frame (generally 0 or 1, 1+ if appending via multiple Begin/End pairs)
|
||||
ImGuiID PopupId; // ID in the popup stack when this window is used as a popup/menu (because we use generic Name/ID for recycling)
|
||||
int AutoFitFramesX, AutoFitFramesY;
|
||||
@ -809,8 +812,9 @@ struct ImGuiItemHoveredDataBackup
|
||||
ImRect LastItemRect;
|
||||
bool LastItemRectHoveredRect;
|
||||
|
||||
void Backup() { ImGuiWindow* window = GImGui->CurrentWindow; LastItemId = window->DC.LastItemId; LastItemRect = window->DC.LastItemRect; LastItemRectHoveredRect = window->DC.LastItemRectHoveredRect; }
|
||||
void Restore() { ImGuiWindow* window = GImGui->CurrentWindow; window->DC.LastItemId = LastItemId; window->DC.LastItemRect = LastItemRect; window->DC.LastItemRectHoveredRect = LastItemRectHoveredRect; }
|
||||
ImGuiItemHoveredDataBackup() { Backup(); }
|
||||
void Backup() { ImGuiWindow* window = GImGui->CurrentWindow; LastItemId = window->DC.LastItemId; LastItemRect = window->DC.LastItemRect; LastItemRectHoveredRect = window->DC.LastItemRectHoveredRect; }
|
||||
void Restore() const { ImGuiWindow* window = GImGui->CurrentWindow; window->DC.LastItemId = LastItemId; window->DC.LastItemRect = LastItemRect; window->DC.LastItemRectHoveredRect = LastItemRectHoveredRect; }
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user