Updated ImGui.

This commit is contained in:
Branimir Karadžić 2016-06-12 22:18:03 -07:00
parent 98454c19cc
commit a3edffcd5c
3 changed files with 37 additions and 36 deletions

View File

@ -1700,7 +1700,7 @@ ImGuiWindow::ImGuiWindow(const char* name)
Name = ImStrdup(name);
ID = ImHash(name, 0);
IDStack.push_back(ID);
MoveID = GetID("#MOVE");
MoveId = GetID("#MOVE");
Flags = 0;
IndexWithinParent = 0;
@ -1719,7 +1719,7 @@ ImGuiWindow::ImGuiWindow(const char* name)
Collapsed = false;
SkipItems = false;
BeginCount = 0;
PopupID = 0;
PopupId = 0;
AutoFitFramesX = AutoFitFramesY = -1;
AutoFitOnlyGrows = false;
AutoPosLastDirection = -1;
@ -1844,7 +1844,7 @@ void ImGui::ItemSize(const ImRect& bb, float text_offset_y)
bool ImGui::ItemAdd(const ImRect& bb, const ImGuiID* id)
{
ImGuiWindow* window = GetCurrentWindow();
window->DC.LastItemID = id ? *id : 0;
window->DC.LastItemId = id ? *id : 0;
window->DC.LastItemRect = bb;
window->DC.LastItemHoveredAndUsable = window->DC.LastItemHoveredRect = false;
if (IsClippedEx(bb, id, false))
@ -1858,7 +1858,7 @@ bool ImGui::ItemAdd(const ImRect& bb, const ImGuiID* id)
// So that clicking on items with no active id such as Text() still returns true with IsItemHovered()
window->DC.LastItemHoveredRect = true;
if (g.HoveredRootWindow == window->RootWindow)
if (g.ActiveId == 0 || (id && g.ActiveId == *id) || g.ActiveIdAllowOverlap || (g.ActiveId == window->MoveID))
if (g.ActiveId == 0 || (id && g.ActiveId == *id) || g.ActiveIdAllowOverlap || (g.ActiveId == window->MoveId))
if (IsWindowContentHoverable(window))
window->DC.LastItemHoveredAndUsable = true;
}
@ -2137,7 +2137,7 @@ void ImGui::NewFrame()
{
KeepAliveID(g.MovedWindowMoveId);
IM_ASSERT(g.MovedWindow && g.MovedWindow->RootWindow);
IM_ASSERT(g.MovedWindow->RootWindow->MoveID == g.MovedWindowMoveId);
IM_ASSERT(g.MovedWindow->RootWindow->MoveId == g.MovedWindowMoveId);
if (g.IO.MouseDown[0])
{
if (!(g.MovedWindow->Flags & ImGuiWindowFlags_NoMove))
@ -2342,7 +2342,7 @@ static ImGuiIniData* FindWindowSettings(const char* name)
for (int i = 0; i != g.Settings.Size; i++)
{
ImGuiIniData* ini = &g.Settings[i];
if (ini->ID == id)
if (ini->Id == id)
return ini;
}
return NULL;
@ -2353,7 +2353,7 @@ static ImGuiIniData* AddWindowSettings(const char* name)
GImGui->Settings.resize(GImGui->Settings.Size + 1);
ImGuiIniData* ini = &GImGui->Settings.back();
ini->Name = ImStrdup(name);
ini->ID = ImHash(name, 0);
ini->Id = ImHash(name, 0);
ini->Collapsed = false;
ini->Pos = ImVec2(FLT_MAX,FLT_MAX);
ini->Size = ImVec2(0,0);
@ -2584,7 +2584,7 @@ void ImGui::EndFrame()
if (!(g.HoveredWindow->Flags & ImGuiWindowFlags_NoMove))
{
g.MovedWindow = g.HoveredWindow;
g.MovedWindowMoveId = g.HoveredRootWindow->MoveID;
g.MovedWindowMoveId = g.HoveredRootWindow->MoveId;
SetActiveID(g.MovedWindowMoveId, g.HoveredRootWindow);
}
}
@ -3216,7 +3216,7 @@ bool ImGui::IsItemActive()
if (g.ActiveId)
{
ImGuiWindow* window = GetCurrentWindowRead();
return g.ActiveId == window->DC.LastItemID;
return g.ActiveId == window->DC.LastItemId;
}
return false;
}
@ -3247,9 +3247,9 @@ bool ImGui::IsItemVisible()
void ImGui::SetItemAllowOverlap()
{
ImGuiContext& g = *GImGui;
if (g.HoveredId == g.CurrentWindow->DC.LastItemID)
if (g.HoveredId == g.CurrentWindow->DC.LastItemId)
g.HoveredIdAllowOverlap = true;
if (g.ActiveId == g.CurrentWindow->DC.LastItemID)
if (g.ActiveId == g.CurrentWindow->DC.LastItemId)
g.ActiveIdAllowOverlap = true;
}
@ -3317,7 +3317,7 @@ void ImGui::EndTooltip()
static bool IsPopupOpen(ImGuiID id)
{
ImGuiContext& g = *GImGui;
const bool is_open = g.OpenPopupStack.Size > g.CurrentPopupStack.Size && g.OpenPopupStack[g.CurrentPopupStack.Size].PopupID == id;
const bool is_open = g.OpenPopupStack.Size > g.CurrentPopupStack.Size && g.OpenPopupStack[g.CurrentPopupStack.Size].PopupId == id;
return is_open;
}
@ -3334,7 +3334,7 @@ void ImGui::OpenPopupEx(const char* str_id, bool reopen_existing)
ImGuiPopupRef popup_ref = ImGuiPopupRef(id, window, window->GetID("##menus"), g.IO.MousePos); // Tagged as new ref because constructor sets Window to NULL (we are passing the ParentWindow info here)
if (g.OpenPopupStack.Size < current_stack_size + 1)
g.OpenPopupStack.push_back(popup_ref);
else if (reopen_existing || g.OpenPopupStack[current_stack_size].PopupID != id)
else if (reopen_existing || g.OpenPopupStack[current_stack_size].PopupId != id)
{
g.OpenPopupStack.resize(current_stack_size+1);
g.OpenPopupStack[current_stack_size] = popup_ref;
@ -3410,7 +3410,7 @@ void ImGui::CloseCurrentPopup()
{
ImGuiContext& g = *GImGui;
int popup_idx = g.CurrentPopupStack.Size - 1;
if (popup_idx < 0 || popup_idx > g.OpenPopupStack.Size || g.CurrentPopupStack[popup_idx].PopupID != g.OpenPopupStack[popup_idx].PopupID)
if (popup_idx < 0 || popup_idx > g.OpenPopupStack.Size || g.CurrentPopupStack[popup_idx].PopupId != g.OpenPopupStack[popup_idx].PopupId)
return;
while (popup_idx > 0 && g.OpenPopupStack[popup_idx].Window && (g.OpenPopupStack[popup_idx].Window->Flags & ImGuiWindowFlags_ChildMenu))
popup_idx--;
@ -3813,11 +3813,11 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
if (flags & ImGuiWindowFlags_Popup)
{
ImGuiPopupRef& popup_ref = g.OpenPopupStack[g.CurrentPopupStack.Size];
window_was_active &= (window->PopupID == popup_ref.PopupID);
window_was_active &= (window->PopupId == popup_ref.PopupId);
window_was_active &= (window == popup_ref.Window);
popup_ref.Window = window;
g.CurrentPopupStack.push_back(popup_ref);
window->PopupID = popup_ref.PopupID;
window->PopupId = popup_ref.PopupId;
}
const bool window_appearing_after_being_hidden = (window->HiddenFrames == 1);
@ -5316,7 +5316,7 @@ void ImGui::TextUnformatted(const char* text, const char* text_end)
// Lines to render
if (line < text_end)
{
ImRect line_rect(pos, pos + ImVec2(GetWindowWidth(), line_height));
ImRect line_rect(pos, pos + ImVec2(FLT_MAX, line_height));
while (line < text_end)
{
const char* line_end = strchr(line, '\n');
@ -9227,7 +9227,7 @@ static float GetDraggedColumnOffset(int column_index)
ImGuiContext& g = *GImGui;
ImGuiWindow* window = ImGui::GetCurrentWindowRead();
IM_ASSERT(column_index > 0); // We cannot drag column 0. If you get this assert you may have a conflict between the ID of your columns and another widgets.
IM_ASSERT(g.ActiveId == window->DC.ColumnsSetID + ImGuiID(column_index));
IM_ASSERT(g.ActiveId == window->DC.ColumnsSetId + ImGuiID(column_index));
float x = g.IO.MousePos.x - g.ActiveIdClickOffset.x - window->Pos.x;
x = ImClamp(x, ImGui::GetColumnOffset(column_index-1)+g.Style.ColumnsMinSpacing, ImGui::GetColumnOffset(column_index+1)-g.Style.ColumnsMinSpacing);
@ -9244,7 +9244,7 @@ float ImGui::GetColumnOffset(int column_index)
if (g.ActiveId)
{
const ImGuiID column_id = window->DC.ColumnsSetID + ImGuiID(column_index);
const ImGuiID column_id = window->DC.ColumnsSetId + ImGuiID(column_index);
if (g.ActiveId == column_id)
return GetDraggedColumnOffset(column_index);
}
@ -9265,7 +9265,7 @@ void ImGui::SetColumnOffset(int column_index, float offset)
const float t = (offset - window->DC.ColumnsMinX) / (window->DC.ColumnsMaxX - window->DC.ColumnsMinX);
window->DC.ColumnsData[column_index].OffsetNorm = t;
const ImGuiID column_id = window->DC.ColumnsSetID + ImGuiID(column_index);
const ImGuiID column_id = window->DC.ColumnsSetId + ImGuiID(column_index);
window->DC.StateStorage->SetFloat(column_id, t);
}
@ -9316,7 +9316,7 @@ void ImGui::Columns(int columns_count, const char* id, bool border)
for (int i = 1; i < window->DC.ColumnsCount; i++)
{
float x = window->Pos.x + GetColumnOffset(i);
const ImGuiID column_id = window->DC.ColumnsSetID + ImGuiID(i);
const ImGuiID column_id = window->DC.ColumnsSetId + ImGuiID(i);
const ImRect column_rect(ImVec2(x-4,y1),ImVec2(x+4,y2));
if (IsClippedEx(column_rect, &column_id, false))
continue;
@ -9344,7 +9344,7 @@ void ImGui::Columns(int columns_count, const char* id, bool border)
// Differentiate column ID with an arbitrary prefix for cases where users name their columns set the same as another widget.
// In addition, when an identifier isn't explicitly provided we include the number of columns in the hash to make it uniquer.
PushID(0x11223347 + (id ? 0 : columns_count));
window->DC.ColumnsSetID = window->GetID(id ? id : "columns");
window->DC.ColumnsSetId = window->GetID(id ? id : "columns");
PopID();
// Set state for first column
@ -9366,7 +9366,7 @@ void ImGui::Columns(int columns_count, const char* id, bool border)
window->DC.ColumnsData.resize(columns_count + 1);
for (int column_index = 0; column_index < columns_count + 1; column_index++)
{
const ImGuiID column_id = window->DC.ColumnsSetID + ImGuiID(column_index);
const ImGuiID column_id = window->DC.ColumnsSetId + ImGuiID(column_index);
KeepAliveID(column_id);
const float default_t = column_index / (float)window->DC.ColumnsCount;
const float t = window->DC.StateStorage->GetFloat(column_id, default_t); // Cheaply store our floating point value inside the integer (could store an union into the map?)
@ -9681,6 +9681,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
if (!ImGui::TreeNode(window, "%s '%s', %d @ 0x%p", label, window->Name, window->Active || window->WasActive, window))
return;
NodeDrawList(window->DrawList, "DrawList");
ImGui::BulletText("Size: (%.1f,%.1f), SizeContents (%.1f,%.1f)", window->Size.x, window->Size.y, window->SizeContents.x, window->SizeContents.y);
if (window->RootWindow != window) NodeWindow(window->RootWindow, "RootWindow");
if (window->DC.ChildWindows.Size > 0) NodeWindows(window->DC.ChildWindows, "ChildWindows");
ImGui::BulletText("Storage: %d bytes", window->StateStorage.Data.Size * (int)sizeof(ImGuiStorage::Pair));
@ -9701,7 +9702,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
for (int i = 0; i < g.OpenPopupStack.Size; i++)
{
ImGuiWindow* window = g.OpenPopupStack[i].Window;
ImGui::BulletText("PopupID: %08x, Window: '%s'%s%s", g.OpenPopupStack[i].PopupID, window ? window->Name : "NULL", window && (window->Flags & ImGuiWindowFlags_ChildWindow) ? " ChildWindow" : "", window && (window->Flags & ImGuiWindowFlags_ChildMenu) ? " ChildMenu" : "");
ImGui::BulletText("PopupID: %08x, Window: '%s'%s%s", g.OpenPopupStack[i].PopupId, window ? window->Name : "NULL", window && (window->Flags & ImGuiWindowFlags_ChildWindow) ? " ChildWindow" : "", window && (window->Flags & ImGuiWindowFlags_ChildMenu) ? " ChildMenu" : "");
}
ImGui::TreePop();
}

View File

@ -694,9 +694,9 @@ enum ImGuiMouseCursor_
enum ImGuiSetCond_
{
ImGuiSetCond_Always = 1 << 0, // Set the variable
ImGuiSetCond_Once = 1 << 1, // Only set the variable on the first call per runtime session
ImGuiSetCond_FirstUseEver = 1 << 2, // Only set the variable if the window doesn't exist in the .ini file
ImGuiSetCond_Appearing = 1 << 3 // Only set the variable if the window is appearing after being inactive (or the first time)
ImGuiSetCond_Once = 1 << 1, // Set the variable once per runtime session (only the first call with succeed)
ImGuiSetCond_FirstUseEver = 1 << 2, // Set the variable if the window has no saved data (if doesn't exist in the .ini file)
ImGuiSetCond_Appearing = 1 << 3 // Set the variable if the window is appearing after being hidden/inactive (or the first time)
};
struct ImGuiStyle

View File

@ -312,7 +312,7 @@ struct IMGUI_API ImGuiTextEditState
struct ImGuiIniData
{
char* Name;
ImGuiID ID;
ImGuiID Id;
ImVec2 Pos;
ImVec2 Size;
bool Collapsed;
@ -331,13 +331,13 @@ struct ImGuiMouseCursorData
// Storage for current popup stack
struct ImGuiPopupRef
{
ImGuiID PopupID; // Set on OpenPopup()
ImGuiID PopupId; // Set on OpenPopup()
ImGuiWindow* Window; // Resolved on BeginPopup() - may stay unresolved if user never calls OpenPopup()
ImGuiWindow* ParentWindow; // Set on OpenPopup()
ImGuiID ParentMenuSet; // Set on OpenPopup()
ImVec2 MousePosOnOpen; // Copy of mouse position at the time of opening popup
ImGuiPopupRef(ImGuiID id, ImGuiWindow* parent_window, ImGuiID parent_menu_set, const ImVec2& mouse_pos) { PopupID = id; Window = NULL; ParentWindow = parent_window; ParentMenuSet = parent_menu_set; MousePosOnOpen = mouse_pos; }
ImGuiPopupRef(ImGuiID id, ImGuiWindow* parent_window, ImGuiID parent_menu_set, const ImVec2& mouse_pos) { PopupId = id; Window = NULL; ParentWindow = parent_window; ParentMenuSet = parent_menu_set; MousePosOnOpen = mouse_pos; }
};
// Main state for ImGui
@ -522,7 +522,7 @@ struct IMGUI_API ImGuiDrawContext
float PrevLineTextBaseOffset;
float LogLinePosY;
int TreeDepth;
ImGuiID LastItemID;
ImGuiID LastItemId;
ImRect LastItemRect;
bool LastItemHoveredAndUsable; // Item rectangle is hovered, and its window is currently interactable with (not blocked by a popup preventing access to the window)
bool LastItemHoveredRect; // Item rectangle is hovered, but its window may or not be currently interactable with (might be blocked by a popup preventing access to the window)
@ -555,7 +555,7 @@ struct IMGUI_API ImGuiDrawContext
float ColumnsCellMinY;
float ColumnsCellMaxY;
bool ColumnsShowBorders;
ImGuiID ColumnsSetID;
ImGuiID ColumnsSetId;
ImVector<ImGuiColumnData> ColumnsData;
ImGuiDrawContext()
@ -565,7 +565,7 @@ struct IMGUI_API ImGuiDrawContext
CurrentLineTextBaseOffset = PrevLineTextBaseOffset = 0.0f;
LogLinePosY = -1.0f;
TreeDepth = 0;
LastItemID = 0;
LastItemId = 0;
LastItemRect = ImRect(0.0f,0.0f,0.0f,0.0f);
LastItemHoveredAndUsable = LastItemHoveredRect = false;
MenuBarAppending = false;
@ -587,7 +587,7 @@ struct IMGUI_API ImGuiDrawContext
ColumnsStartPosY = 0.0f;
ColumnsCellMinY = ColumnsCellMaxY = 0.0f;
ColumnsShowBorders = true;
ColumnsSetID = 0;
ColumnsSetId = 0;
}
};
@ -606,7 +606,7 @@ struct IMGUI_API ImGuiWindow
ImVec2 SizeContentsExplicit; // Size of contents explicitly set by the user via SetNextWindowContentSize()
ImRect ContentsRegionRect; // Maximum visible content position in window coordinates. ~~ (SizeContentsExplicit ? SizeContentsExplicit : Size - ScrollbarSizes) - CursorStartPos, per axis
ImVec2 WindowPadding; // Window padding at the time of begin. We need to lock it, in particular manipulation of the ShowBorder would have an effect
ImGuiID MoveID; // == window->GetID("#MOVE")
ImGuiID MoveId; // == window->GetID("#MOVE")
ImVec2 Scroll;
ImVec2 ScrollTarget; // target scroll position. stored as cursor position with scrolling canceled out, so the highest point is always 0.0f. (FLT_MAX for no change)
ImVec2 ScrollTargetCenterRatio; // 0.0f = scroll so that target position is at top, 0.5f = scroll so that target position is centered
@ -619,7 +619,7 @@ struct IMGUI_API ImGuiWindow
bool Collapsed; // Set when collapsing window to become only title-bar
bool SkipItems; // == Visible && !Collapsed
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)
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;
bool AutoFitOnlyGrows;
int AutoPosLastDirection;