1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-12-01 02:37:24 +01:00

Merge branch 'master' into navigation

# Conflicts:
#	imgui_internal.h
This commit is contained in:
omar 2017-12-13 22:09:08 +01:00
commit cc3192f347
4 changed files with 272 additions and 184 deletions

315
imgui.cpp
View File

@ -664,8 +664,6 @@
// Forward Declarations // Forward Declarations
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
static float GetDraggedColumnOffset(int column_index);
static bool IsKeyPressedMap(ImGuiKey key, bool repeat = true); static bool IsKeyPressedMap(ImGuiKey key, bool repeat = true);
static ImFont* GetDefaultFont(); static ImFont* GetDefaultFont();
@ -1787,8 +1785,8 @@ static void SetCursorPosYAndSetupDummyPrevLine(float pos_y, float line_height)
ImGuiWindow* window = ImGui::GetCurrentWindow(); ImGuiWindow* window = ImGui::GetCurrentWindow();
window->DC.CursorPosPrevLine.y = window->DC.CursorPos.y - line_height; // Setting those fields so that SetScrollHere() can properly function after the end of our clipper usage. window->DC.CursorPosPrevLine.y = window->DC.CursorPos.y - line_height; // Setting those fields so that SetScrollHere() can properly function after the end of our clipper usage.
window->DC.PrevLineHeight = (line_height - GImGui->Style.ItemSpacing.y); // If we end up needing more accurate data (to e.g. use SameLine) we may as well make the clipper have a fourth step to let user process and display the last item in their list. window->DC.PrevLineHeight = (line_height - GImGui->Style.ItemSpacing.y); // If we end up needing more accurate data (to e.g. use SameLine) we may as well make the clipper have a fourth step to let user process and display the last item in their list.
if (window->DC.ColumnsCount > 1) if (window->DC.ColumnsSet)
window->DC.ColumnsCellMinY = window->DC.CursorPos.y; // Setting this so that cell Y position are set properly window->DC.ColumnsSet->CellMinY = window->DC.CursorPos.y; // Setting this so that cell Y position are set properly
} }
// Use case A: Begin() called from constructor with items_height<0, then called again from Sync() in StepNo 1 // Use case A: Begin() called from constructor with items_height<0, then called again from Sync() in StepNo 1
@ -4834,9 +4832,9 @@ static bool BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, b
ImVec2 size = ImFloor(size_arg); ImVec2 size = ImFloor(size_arg);
const int auto_fit_axises = ((size.x == 0.0f) ? (1 << ImGuiAxis_X) : 0x00) | ((size.y == 0.0f) ? (1 << ImGuiAxis_Y) : 0x00); const int auto_fit_axises = ((size.x == 0.0f) ? (1 << ImGuiAxis_X) : 0x00) | ((size.y == 0.0f) ? (1 << ImGuiAxis_Y) : 0x00);
if (size.x <= 0.0f) if (size.x <= 0.0f)
size.x = ImMax(content_avail.x, 4.0f) - fabsf(size.x); // Arbitrary minimum zero-ish child size of 4.0f (0.0f causing too much issues) size.x = ImMax(content_avail.x + size.x, 4.0f); // Arbitrary minimum child size (0.0f causing too much issues)
if (size.y <= 0.0f) if (size.y <= 0.0f)
size.y = ImMax(content_avail.y, 4.0f) - fabsf(size.y); size.y = ImMax(content_avail.y + size.y, 4.0f);
const float backup_border_size = g.Style.ChildBorderSize; const float backup_border_size = g.Style.ChildBorderSize;
if (!border) if (!border)
@ -5770,11 +5768,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
window->DC.ItemFlagsStack.resize(0); window->DC.ItemFlagsStack.resize(0);
window->DC.ItemWidthStack.resize(0); window->DC.ItemWidthStack.resize(0);
window->DC.TextWrapPosStack.resize(0); window->DC.TextWrapPosStack.resize(0);
window->DC.ColumnsCurrent = 0; window->DC.ColumnsSet = NULL;
window->DC.ColumnsCount = 1;
window->DC.ColumnsStartPosY = window->DC.CursorPos.y;
window->DC.ColumnsStartMaxPosX = window->DC.CursorMaxPos.x;
window->DC.ColumnsCellMinY = window->DC.ColumnsCellMaxY = window->DC.ColumnsStartPosY;
window->DC.TreeDepth = 0; window->DC.TreeDepth = 0;
window->DC.StateStorage = &window->StateStorage; window->DC.StateStorage = &window->StateStorage;
window->DC.GroupStack.resize(0); window->DC.GroupStack.resize(0);
@ -5946,7 +5940,7 @@ void ImGui::End()
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow; ImGuiWindow* window = g.CurrentWindow;
if (window->DC.ColumnsCount != 1) // close columns set if any is open if (window->DC.ColumnsSet != NULL)
EndColumns(); EndColumns();
PopClipRect(); // inner window clip rectangle PopClipRect(); // inner window clip rectangle
@ -5983,8 +5977,10 @@ void ImGui::Scrollbar(ImGuiLayoutType direction)
const ImRect window_rect = window->Rect(); const ImRect window_rect = window->Rect();
const float border_size = window->WindowBorderSize; const float border_size = window->WindowBorderSize;
ImRect bb = horizontal ImRect bb = horizontal
? ImRect(window->InnerRect.Min.x, window_rect.Max.y - style.ScrollbarSize, window->InnerRect.Max.x, window_rect.Max.y - border_size) ? ImRect(window->Pos.x + border_size, window_rect.Max.y - style.ScrollbarSize, window_rect.Max.x - other_scrollbar_size_w - border_size, window_rect.Max.y - border_size)
: ImRect(window_rect.Max.x - style.ScrollbarSize, window->InnerRect.Min.y, window_rect.Max.x - border_size, window->InnerRect.Max.y); : ImRect(window_rect.Max.x - style.ScrollbarSize, window->Pos.y + border_size, window_rect.Max.x - border_size, window_rect.Max.y - other_scrollbar_size_w - border_size);
if (!horizontal)
bb.Min.y += window->TitleBarHeight() + ((window->Flags & ImGuiWindowFlags_MenuBar) ? window->MenuBarHeight() : 0.0f);
if (bb.GetWidth() <= 0.0f || bb.GetHeight() <= 0.0f) if (bb.GetWidth() <= 0.0f || bb.GetHeight() <= 0.0f)
return; return;
@ -6488,13 +6484,13 @@ bool ImGui::IsWindowFocused(ImGuiFocusedFlags flags)
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
IM_ASSERT(g.CurrentWindow); // Not inside a Begin()/End() IM_ASSERT(g.CurrentWindow); // Not inside a Begin()/End()
switch (flags & (ImGuiFocusedFlags_RootWindow | ImGuiHoveredFlags_ChildWindows)) switch (flags & (ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows))
{ {
case ImGuiFocusedFlags_RootWindow | ImGuiHoveredFlags_ChildWindows: case ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows:
return g.NavWindow && g.CurrentWindow->RootWindow == g.NavWindow->RootWindow; return g.NavWindow && g.CurrentWindow->RootWindow == g.NavWindow->RootWindow;
case ImGuiFocusedFlags_RootWindow: case ImGuiFocusedFlags_RootWindow:
return g.CurrentWindow->RootWindow == g.NavWindow; return g.CurrentWindow->RootWindow == g.NavWindow;
case ImGuiHoveredFlags_ChildWindows: case ImGuiFocusedFlags_ChildWindows:
return g.NavWindow && IsWindowChildOf(g.NavWindow, g.CurrentWindow); return g.NavWindow && IsWindowChildOf(g.NavWindow, g.CurrentWindow);
default: default:
return g.CurrentWindow == g.NavWindow; return g.CurrentWindow == g.NavWindow;
@ -6710,8 +6706,8 @@ ImVec2 ImGui::GetContentRegionMax()
{ {
ImGuiWindow* window = GetCurrentWindowRead(); ImGuiWindow* window = GetCurrentWindowRead();
ImVec2 mx = window->ContentsRegionRect.Max; ImVec2 mx = window->ContentsRegionRect.Max;
if (window->DC.ColumnsCount != 1) if (window->DC.ColumnsSet)
mx.x = GetColumnOffset(window->DC.ColumnsCurrent + 1) - window->WindowPadding.x; mx.x = GetColumnOffset(window->DC.ColumnsSet->Current + 1) - window->WindowPadding.x;
return mx; return mx;
} }
@ -10451,7 +10447,7 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style; const ImGuiStyle& style = g.Style;
if ((flags & ImGuiSelectableFlags_SpanAllColumns) && window->DC.ColumnsCount > 1) // FIXME-OPT: Avoid if vertically clipped. if ((flags & ImGuiSelectableFlags_SpanAllColumns) && window->DC.ColumnsSet) // FIXME-OPT: Avoid if vertically clipped.
PopClipRect(); PopClipRect();
ImGuiID id = window->GetID(label); ImGuiID id = window->GetID(label);
@ -10482,7 +10478,7 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
bb_with_spacing.Max.y += spacing_D; bb_with_spacing.Max.y += spacing_D;
if (!ItemAdd(bb_with_spacing, (flags & ImGuiSelectableFlags_Disabled) ? 0 : id)) if (!ItemAdd(bb_with_spacing, (flags & ImGuiSelectableFlags_Disabled) ? 0 : id))
{ {
if ((flags & ImGuiSelectableFlags_SpanAllColumns) && window->DC.ColumnsCount > 1) if ((flags & ImGuiSelectableFlags_SpanAllColumns) && window->DC.ColumnsSet)
PushColumnClipRect(); PushColumnClipRect();
return false; return false;
} }
@ -10513,7 +10509,7 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
RenderNavHighlight(bb_with_spacing, id, ImGuiNavHighlightFlags_TypeThin); RenderNavHighlight(bb_with_spacing, id, ImGuiNavHighlightFlags_TypeThin);
} }
if ((flags & ImGuiSelectableFlags_SpanAllColumns) && window->DC.ColumnsCount > 1) if ((flags & ImGuiSelectableFlags_SpanAllColumns) && window->DC.ColumnsSet)
{ {
PushColumnClipRect(); PushColumnClipRect();
bb_with_spacing.Max.x -= (GetContentRegionMax().x - max_x); bb_with_spacing.Max.x -= (GetContentRegionMax().x - max_x);
@ -11724,7 +11720,7 @@ void ImGui::Separator()
} }
// Horizontal Separator // Horizontal Separator
if (window->DC.ColumnsCount > 1) if (window->DC.ColumnsSet)
PopClipRect(); PopClipRect();
float x1 = window->Pos.x; float x1 = window->Pos.x;
@ -11736,7 +11732,7 @@ void ImGui::Separator()
ItemSize(ImVec2(0.0f, 0.0f)); // NB: we don't provide our width so that it doesn't get feed back into AutoFit, we don't provide height to not alter layout. ItemSize(ImVec2(0.0f, 0.0f)); // NB: we don't provide our width so that it doesn't get feed back into AutoFit, we don't provide height to not alter layout.
if (!ItemAdd(bb, 0)) if (!ItemAdd(bb, 0))
{ {
if (window->DC.ColumnsCount > 1) if (window->DC.ColumnsSet)
PushColumnClipRect(); PushColumnClipRect();
return; return;
} }
@ -11746,10 +11742,10 @@ void ImGui::Separator()
if (g.LogEnabled) if (g.LogEnabled)
LogRenderedText(NULL, IM_NEWLINE "--------------------------------"); LogRenderedText(NULL, IM_NEWLINE "--------------------------------");
if (window->DC.ColumnsCount > 1) if (window->DC.ColumnsSet)
{ {
PushColumnClipRect(); PushColumnClipRect();
window->DC.ColumnsCellMinY = window->DC.CursorPos.y; window->DC.ColumnsSet->CellMinY = window->DC.CursorPos.y;
} }
} }
@ -11962,29 +11958,30 @@ void ImGui::NewLine()
void ImGui::NextColumn() void ImGui::NextColumn()
{ {
ImGuiWindow* window = GetCurrentWindow(); ImGuiWindow* window = GetCurrentWindow();
if (window->SkipItems || window->DC.ColumnsCount <= 1) if (window->SkipItems || window->DC.ColumnsSet == NULL)
return; return;
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
PopItemWidth(); PopItemWidth();
PopClipRect(); PopClipRect();
window->DC.ColumnsCellMaxY = ImMax(window->DC.ColumnsCellMaxY, window->DC.CursorPos.y); ImGuiColumnsSet* columns = window->DC.ColumnsSet;
if (++window->DC.ColumnsCurrent < window->DC.ColumnsCount) columns->CellMaxY = ImMax(columns->CellMaxY, window->DC.CursorPos.y);
if (++columns->Current < columns->Count)
{ {
// Columns 1+ cancel out IndentX // Columns 1+ cancel out IndentX
window->DC.ColumnsOffsetX = GetColumnOffset(window->DC.ColumnsCurrent) - window->DC.IndentX + g.Style.ItemSpacing.x; window->DC.ColumnsOffsetX = GetColumnOffset(columns->Current) - window->DC.IndentX + g.Style.ItemSpacing.x;
window->DrawList->ChannelsSetCurrent(window->DC.ColumnsCurrent); window->DrawList->ChannelsSetCurrent(columns->Current);
} }
else else
{ {
window->DC.ColumnsCurrent = 0;
window->DC.ColumnsOffsetX = 0.0f; window->DC.ColumnsOffsetX = 0.0f;
window->DC.ColumnsCellMinY = window->DC.ColumnsCellMaxY; columns->Current = 0;
columns->CellMinY = columns->CellMaxY;
window->DrawList->ChannelsSetCurrent(0); window->DrawList->ChannelsSetCurrent(0);
} }
window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.IndentX + window->DC.ColumnsOffsetX); window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.IndentX + window->DC.ColumnsOffsetX);
window->DC.CursorPos.y = window->DC.ColumnsCellMinY; window->DC.CursorPos.y = columns->CellMinY;
window->DC.CurrentLineHeight = 0.0f; window->DC.CurrentLineHeight = 0.0f;
window->DC.CurrentLineTextBaseOffset = 0.0f; window->DC.CurrentLineTextBaseOffset = 0.0f;
@ -11995,38 +11992,38 @@ void ImGui::NextColumn()
int ImGui::GetColumnIndex() int ImGui::GetColumnIndex()
{ {
ImGuiWindow* window = GetCurrentWindowRead(); ImGuiWindow* window = GetCurrentWindowRead();
return window->DC.ColumnsCurrent; return window->DC.ColumnsSet ? window->DC.ColumnsSet->Current : 0;
} }
int ImGui::GetColumnsCount() int ImGui::GetColumnsCount()
{ {
ImGuiWindow* window = GetCurrentWindowRead(); ImGuiWindow* window = GetCurrentWindowRead();
return window->DC.ColumnsCount; return window->DC.ColumnsSet ? window->DC.ColumnsSet->Count : 1;
} }
static float OffsetNormToPixels(ImGuiWindow* window, float offset_norm) static float OffsetNormToPixels(const ImGuiColumnsSet* columns, float offset_norm)
{ {
return offset_norm * (window->DC.ColumnsMaxX - window->DC.ColumnsMinX); return offset_norm * (columns->MaxX - columns->MinX);
} }
static float PixelsToOffsetNorm(ImGuiWindow* window, float offset) static float PixelsToOffsetNorm(const ImGuiColumnsSet* columns, float offset)
{ {
return (offset - window->DC.ColumnsMinX) / (window->DC.ColumnsMaxX - window->DC.ColumnsMinX); return (offset - columns->MinX) / (columns->MaxX - columns->MinX);
} }
static float GetDraggedColumnOffset(int column_index) static float GetDraggedColumnOffset(ImGuiColumnsSet* columns, int column_index)
{ {
// Active (dragged) column always follow mouse. The reason we need this is that dragging a column to the right edge of an auto-resizing // Active (dragged) column always follow mouse. The reason we need this is that dragging a column to the right edge of an auto-resizing
// window creates a feedback loop because we store normalized positions. So while dragging we enforce absolute positioning. // window creates a feedback loop because we store normalized positions. So while dragging we enforce absolute positioning.
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow; ImGuiWindow* window = g.CurrentWindow;
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(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 == columns->ID + ImGuiID(column_index));
float x = g.IO.MousePos.x - g.ActiveIdClickOffset.x - window->Pos.x; float x = g.IO.MousePos.x - g.ActiveIdClickOffset.x - window->Pos.x;
x = ImMax(x, ImGui::GetColumnOffset(column_index-1) + g.Style.ColumnsMinSpacing); x = ImMax(x, ImGui::GetColumnOffset(column_index - 1) + g.Style.ColumnsMinSpacing);
if ((window->DC.ColumnsFlags & ImGuiColumnsFlags_NoPreserveWidths)) if ((columns->Flags & ImGuiColumnsFlags_NoPreserveWidths))
x = ImMin(x, ImGui::GetColumnOffset(column_index+1) - g.Style.ColumnsMinSpacing); x = ImMin(x, ImGui::GetColumnOffset(column_index + 1) - g.Style.ColumnsMinSpacing);
return x; return x;
} }
@ -12034,128 +12031,174 @@ static float GetDraggedColumnOffset(int column_index)
float ImGui::GetColumnOffset(int column_index) float ImGui::GetColumnOffset(int column_index)
{ {
ImGuiWindow* window = GetCurrentWindowRead(); ImGuiWindow* window = GetCurrentWindowRead();
ImGuiColumnsSet* columns = window->DC.ColumnsSet;
IM_ASSERT(columns != NULL);
if (column_index < 0) if (column_index < 0)
column_index = window->DC.ColumnsCurrent; column_index = columns->Current;
IM_ASSERT(column_index < columns->Columns.Size);
/* /*
if (g.ActiveId) if (g.ActiveId)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
const ImGuiID column_id = window->DC.ColumnsSetId + ImGuiID(column_index); const ImGuiID column_id = columns->ColumnsSetId + ImGuiID(column_index);
if (g.ActiveId == column_id) if (g.ActiveId == column_id)
return GetDraggedColumnOffset(column_index); return GetDraggedColumnOffset(columns, column_index);
} }
*/ */
IM_ASSERT(column_index < window->DC.ColumnsData.Size); const float t = columns->Columns[column_index].OffsetNorm;
const float t = window->DC.ColumnsData[column_index].OffsetNorm; const float x_offset = ImLerp(columns->MinX, columns->MaxX, t);
const float x_offset = ImLerp(window->DC.ColumnsMinX, window->DC.ColumnsMaxX, t);
return x_offset; return x_offset;
} }
void ImGui::SetColumnOffset(int column_index, float offset) static float GetColumnWidthEx(ImGuiColumnsSet* columns, int column_index, bool before_resize = false)
{ {
ImGuiContext& g = *GImGui;
ImGuiWindow* window = GetCurrentWindow();
if (column_index < 0) if (column_index < 0)
column_index = window->DC.ColumnsCurrent; column_index = columns->Current;
IM_ASSERT(column_index < window->DC.ColumnsData.Size); float offset_norm;
if (before_resize)
const bool preserve_width = !(window->DC.ColumnsFlags & ImGuiColumnsFlags_NoPreserveWidths) && (column_index < window->DC.ColumnsCount-1); offset_norm = columns->Columns[column_index + 1].OffsetNormBeforeResize - columns->Columns[column_index].OffsetNormBeforeResize;
const float width = preserve_width ? GetColumnWidth(column_index) : 0.0f; else
offset_norm = columns->Columns[column_index + 1].OffsetNorm - columns->Columns[column_index].OffsetNorm;
if (!(window->DC.ColumnsFlags & ImGuiColumnsFlags_NoForceWithinWindow)) return OffsetNormToPixels(columns, offset_norm);
offset = ImMin(offset, window->DC.ColumnsMaxX - g.Style.ColumnsMinSpacing * (window->DC.ColumnsCount - column_index));
const float offset_norm = PixelsToOffsetNorm(window, offset);
const ImGuiID column_id = window->DC.ColumnsSetId + ImGuiID(column_index);
window->DC.StateStorage->SetFloat(column_id, offset_norm);
window->DC.ColumnsData[column_index].OffsetNorm = offset_norm;
if (preserve_width)
SetColumnOffset(column_index + 1, offset + ImMax(g.Style.ColumnsMinSpacing, width));
} }
float ImGui::GetColumnWidth(int column_index) float ImGui::GetColumnWidth(int column_index)
{ {
ImGuiWindow* window = GetCurrentWindowRead(); ImGuiWindow* window = GetCurrentWindowRead();
if (column_index < 0) ImGuiColumnsSet* columns = window->DC.ColumnsSet;
column_index = window->DC.ColumnsCurrent; IM_ASSERT(columns != NULL);
return OffsetNormToPixels(window, window->DC.ColumnsData[column_index+1].OffsetNorm - window->DC.ColumnsData[column_index].OffsetNorm); if (column_index < 0)
column_index = columns->Current;
return OffsetNormToPixels(columns, columns->Columns[column_index + 1].OffsetNorm - columns->Columns[column_index].OffsetNorm);
}
void ImGui::SetColumnOffset(int column_index, float offset)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
ImGuiColumnsSet* columns = window->DC.ColumnsSet;
IM_ASSERT(columns != NULL);
if (column_index < 0)
column_index = columns->Current;
IM_ASSERT(column_index < columns->Columns.Size);
const bool preserve_width = !(columns->Flags & ImGuiColumnsFlags_NoPreserveWidths) && (column_index < columns->Count-1);
const float width = preserve_width ? GetColumnWidthEx(columns, column_index, columns->IsBeingResized) : 0.0f;
if (!(columns->Flags & ImGuiColumnsFlags_NoForceWithinWindow))
offset = ImMin(offset, columns->MaxX - g.Style.ColumnsMinSpacing * (columns->Count - column_index));
columns->Columns[column_index].OffsetNorm = PixelsToOffsetNorm(columns, offset);
if (preserve_width)
SetColumnOffset(column_index + 1, offset + ImMax(g.Style.ColumnsMinSpacing, width));
} }
void ImGui::SetColumnWidth(int column_index, float width) void ImGui::SetColumnWidth(int column_index, float width)
{ {
ImGuiWindow* window = GetCurrentWindowRead(); ImGuiWindow* window = GetCurrentWindowRead();
if (column_index < 0) ImGuiColumnsSet* columns = window->DC.ColumnsSet;
column_index = window->DC.ColumnsCurrent; IM_ASSERT(columns != NULL);
SetColumnOffset(column_index+1, GetColumnOffset(column_index) + width); if (column_index < 0)
column_index = columns->Current;
SetColumnOffset(column_index + 1, GetColumnOffset(column_index) + width);
} }
void ImGui::PushColumnClipRect(int column_index) void ImGui::PushColumnClipRect(int column_index)
{ {
ImGuiWindow* window = GetCurrentWindowRead(); ImGuiWindow* window = GetCurrentWindowRead();
ImGuiColumnsSet* columns = window->DC.ColumnsSet;
if (column_index < 0) if (column_index < 0)
column_index = window->DC.ColumnsCurrent; column_index = columns->Current;
PushClipRect(window->DC.ColumnsData[column_index].ClipRect.Min, window->DC.ColumnsData[column_index].ClipRect.Max, false); PushClipRect(columns->Columns[column_index].ClipRect.Min, columns->Columns[column_index].ClipRect.Max, false);
} }
void ImGui::BeginColumns(const char* id, int columns_count, ImGuiColumnsFlags flags) static ImGuiColumnsSet* FindOrAddColumnsSet(ImGuiWindow* window, ImGuiID id)
{
for (int n = 0; n < window->ColumnsStorage.Size; n++)
if (window->ColumnsStorage[n].ID == id)
return &window->ColumnsStorage[n];
window->ColumnsStorage.push_back(ImGuiColumnsSet());
ImGuiColumnsSet* columns = &window->ColumnsStorage.back();
columns->ID = id;
return columns;
}
void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlags flags)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
ImGuiWindow* window = GetCurrentWindow(); ImGuiWindow* window = GetCurrentWindow();
IM_ASSERT(columns_count > 1); IM_ASSERT(columns_count > 1);
IM_ASSERT(window->DC.ColumnsCount == 1); // Nested columns are currently not supported IM_ASSERT(window->DC.ColumnsSet == NULL); // Nested columns are currently not supported
// Differentiate column ID with an arbitrary prefix for cases where users name their columns set the same as another widget. // 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. // 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)); PushID(0x11223347 + (str_id ? 0 : columns_count));
window->DC.ColumnsSetId = window->GetID(id ? id : "columns"); ImGuiID id = window->GetID(str_id ? str_id : "columns");
PopID(); PopID();
// Set state for first column // Acquire storage for the columns set
window->DC.ColumnsCurrent = 0; ImGuiColumnsSet* columns = FindOrAddColumnsSet(window, id);
window->DC.ColumnsCount = columns_count; IM_ASSERT(columns->ID == id);
window->DC.ColumnsFlags = flags; columns->Current = 0;
columns->Count = columns_count;
columns->Flags = flags;
window->DC.ColumnsSet = columns;
// Set state for first column
const float content_region_width = (window->SizeContentsExplicit.x != 0.0f) ? (window->SizeContentsExplicit.x) : (window->Size.x -window->ScrollbarSizes.x); const float content_region_width = (window->SizeContentsExplicit.x != 0.0f) ? (window->SizeContentsExplicit.x) : (window->Size.x -window->ScrollbarSizes.x);
window->DC.ColumnsMinX = window->DC.IndentX - g.Style.ItemSpacing.x; // Lock our horizontal range columns->MinX = window->DC.IndentX - g.Style.ItemSpacing.x; // Lock our horizontal range
//window->DC.ColumnsMaxX = content_region_width - window->Scroll.x -((window->Flags & ImGuiWindowFlags_NoScrollbar) ? 0 : g.Style.ScrollbarSize);// - window->WindowPadding().x; //column->ColumnsMaxX = content_region_width - window->Scroll.x -((window->Flags & ImGuiWindowFlags_NoScrollbar) ? 0 : g.Style.ScrollbarSize);// - window->WindowPadding().x;
window->DC.ColumnsMaxX = content_region_width - window->Scroll.x; columns->MaxX = content_region_width - window->Scroll.x;
window->DC.ColumnsStartPosY = window->DC.CursorPos.y; columns->StartPosY = window->DC.CursorPos.y;
window->DC.ColumnsStartMaxPosX = window->DC.CursorMaxPos.x; columns->StartMaxPosX = window->DC.CursorMaxPos.x;
window->DC.ColumnsCellMinY = window->DC.ColumnsCellMaxY = window->DC.CursorPos.y; columns->CellMinY = columns->CellMaxY = window->DC.CursorPos.y;
window->DC.ColumnsOffsetX = 0.0f; window->DC.ColumnsOffsetX = 0.0f;
window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.IndentX + window->DC.ColumnsOffsetX); window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.IndentX + window->DC.ColumnsOffsetX);
// Cache column offsets // Initialize defaults
window->DC.ColumnsData.resize(columns_count + 1); columns->IsFirstFrame = (columns->Columns.Size == 0);
for (int column_index = 0; column_index < columns_count + 1; column_index++) if (columns->Columns.Size == 0)
{ {
const ImGuiID column_id = window->DC.ColumnsSetId + ImGuiID(column_index); columns->Columns.reserve(columns_count + 1);
KeepAliveID(column_id); for (int n = 0; n < columns_count + 1; n++)
const float default_t = column_index / (float)window->DC.ColumnsCount; {
float t = window->DC.StateStorage->GetFloat(column_id, default_t); ImGuiColumnData column;
if (!(window->DC.ColumnsFlags & ImGuiColumnsFlags_NoForceWithinWindow)) column.OffsetNorm = n / (float)columns_count;
t = ImMin(t, PixelsToOffsetNorm(window, window->DC.ColumnsMaxX - g.Style.ColumnsMinSpacing * (window->DC.ColumnsCount - column_index))); columns->Columns.push_back(column);
window->DC.ColumnsData[column_index].OffsetNorm = t; }
}
IM_ASSERT(columns->Columns.Size == columns_count + 1);
for (int n = 0; n < columns_count + 1; n++)
{
// Clamp
ImGuiColumnData* column = &columns->Columns[n];
float t = column->OffsetNorm;
if (!(columns->Flags & ImGuiColumnsFlags_NoForceWithinWindow))
t = ImMin(t, PixelsToOffsetNorm(columns, columns->MaxX - g.Style.ColumnsMinSpacing * (columns->Count - n)));
column->OffsetNorm = t;
if (n == columns_count)
continue;
// Compute clipping rectangles
float clip_x1 = ImFloor(0.5f + window->Pos.x + GetColumnOffset(n) - 1.0f);
float clip_x2 = ImFloor(0.5f + window->Pos.x + GetColumnOffset(n + 1) - 1.0f);
column->ClipRect = ImRect(clip_x1, -FLT_MAX, clip_x2, +FLT_MAX);
column->ClipRect.ClipWith(window->ClipRect);
} }
// Cache clipping rectangles window->DrawList->ChannelsSplit(columns->Count);
for (int column_index = 0; column_index < columns_count; column_index++)
{
float clip_x1 = ImFloor(0.5f + window->Pos.x + GetColumnOffset(column_index) - 1.0f);
float clip_x2 = ImFloor(0.5f + window->Pos.x + GetColumnOffset(column_index + 1) - 1.0f);
window->DC.ColumnsData[column_index].ClipRect = ImRect(clip_x1, -FLT_MAX, clip_x2, +FLT_MAX);
window->DC.ColumnsData[column_index].ClipRect.ClipWith(window->ClipRect);
}
window->DrawList->ChannelsSplit(window->DC.ColumnsCount);
PushColumnClipRect(); PushColumnClipRect();
PushItemWidth(GetColumnWidth() * 0.65f); PushItemWidth(GetColumnWidth() * 0.65f);
} }
@ -12164,34 +12207,37 @@ void ImGui::EndColumns()
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
ImGuiWindow* window = GetCurrentWindow(); ImGuiWindow* window = GetCurrentWindow();
IM_ASSERT(window->DC.ColumnsCount > 1); ImGuiColumnsSet* columns = window->DC.ColumnsSet;
IM_ASSERT(columns != NULL);
PopItemWidth(); PopItemWidth();
PopClipRect(); PopClipRect();
window->DrawList->ChannelsMerge(); window->DrawList->ChannelsMerge();
window->DC.ColumnsCellMaxY = ImMax(window->DC.ColumnsCellMaxY, window->DC.CursorPos.y); columns->CellMaxY = ImMax(columns->CellMaxY, window->DC.CursorPos.y);
window->DC.CursorPos.y = window->DC.ColumnsCellMaxY; window->DC.CursorPos.y = columns->CellMaxY;
if (!(window->DC.ColumnsFlags & ImGuiColumnsFlags_GrowParentContentsSize)) if (!(columns->Flags & ImGuiColumnsFlags_GrowParentContentsSize))
window->DC.CursorMaxPos.x = ImMax(window->DC.ColumnsStartMaxPosX, window->DC.ColumnsMaxX); // Restore cursor max pos, as columns don't grow parent window->DC.CursorMaxPos.x = ImMax(columns->StartMaxPosX, columns->MaxX); // Restore cursor max pos, as columns don't grow parent
// Draw columns borders and handle resize // Draw columns borders and handle resize
if (!(window->DC.ColumnsFlags & ImGuiColumnsFlags_NoBorder) && !window->SkipItems) bool is_being_resized = false;
if (!(columns->Flags & ImGuiColumnsFlags_NoBorder) && !window->SkipItems)
{ {
const float y1 = window->DC.ColumnsStartPosY; const float y1 = columns->StartPosY;
const float y2 = window->DC.CursorPos.y; const float y2 = window->DC.CursorPos.y;
int dragging_column = -1; int dragging_column = -1;
for (int i = 1; i < window->DC.ColumnsCount; i++) for (int n = 1; n < columns->Count; n++)
{ {
float x = window->Pos.x + GetColumnOffset(i); float x = window->Pos.x + GetColumnOffset(n);
const ImGuiID column_id = window->DC.ColumnsSetId + ImGuiID(i); const ImGuiID column_id = columns->ID + ImGuiID(n);
const float column_hw = 4.0f; // Half-width for interaction const float column_hw = 4.0f; // Half-width for interaction
const ImRect column_rect(ImVec2(x - column_hw, y1), ImVec2(x + column_hw, y2)); const ImRect column_rect(ImVec2(x - column_hw, y1), ImVec2(x + column_hw, y2));
KeepAliveID(column_id);
if (IsClippedEx(column_rect, column_id, false)) if (IsClippedEx(column_rect, column_id, false))
continue; continue;
bool hovered = false, held = false; bool hovered = false, held = false;
if (!(window->DC.ColumnsFlags & ImGuiColumnsFlags_NoResize)) if (!(columns->Flags & ImGuiColumnsFlags_NoResize))
{ {
ButtonBehavior(column_rect, column_id, &hovered, &held); ButtonBehavior(column_rect, column_id, &hovered, &held);
if (hovered || held) if (hovered || held)
@ -12199,11 +12245,10 @@ void ImGui::EndColumns()
if (held && g.ActiveIdIsJustActivated) if (held && g.ActiveIdIsJustActivated)
g.ActiveIdClickOffset.x -= column_hw; // Store from center of column line (we used a 8 wide rect for columns clicking). This is used by GetDraggedColumnOffset(). g.ActiveIdClickOffset.x -= column_hw; // Store from center of column line (we used a 8 wide rect for columns clicking). This is used by GetDraggedColumnOffset().
if (held) if (held)
dragging_column = i; dragging_column = n;
} }
// Draw column // Draw column (we clip the Y boundaries CPU side because very long triangles are mishandled by some GPU drivers.)
// We clip the Y boundaries CPU side because very long triangles are mishandled by some GPU drivers.
const ImU32 col = GetColorU32(held ? ImGuiCol_SeparatorActive : hovered ? ImGuiCol_SeparatorHovered : ImGuiCol_Separator); const ImU32 col = GetColorU32(held ? ImGuiCol_SeparatorActive : hovered ? ImGuiCol_SeparatorHovered : ImGuiCol_Separator);
const float xi = (float)(int)x; const float xi = (float)(int)x;
window->DrawList->AddLine(ImVec2(xi, ImMax(y1 + 1.0f, window->ClipRect.Min.y)), ImVec2(xi, ImMin(y2, window->ClipRect.Max.y)), col); window->DrawList->AddLine(ImVec2(xi, ImMax(y1 + 1.0f, window->ClipRect.Min.y)), ImVec2(xi, ImMin(y2, window->ClipRect.Max.y)), col);
@ -12212,27 +12257,27 @@ void ImGui::EndColumns()
// Apply dragging after drawing the column lines, so our rendered lines are in sync with how items were displayed during the frame. // Apply dragging after drawing the column lines, so our rendered lines are in sync with how items were displayed during the frame.
if (dragging_column != -1) if (dragging_column != -1)
{ {
float x = GetDraggedColumnOffset(dragging_column); if (!columns->IsBeingResized)
for (int n = 0; n < columns->Count + 1; n++)
columns->Columns[n].OffsetNormBeforeResize = columns->Columns[n].OffsetNorm;
columns->IsBeingResized = is_being_resized = true;
float x = GetDraggedColumnOffset(columns, dragging_column);
SetColumnOffset(dragging_column, x); SetColumnOffset(dragging_column, x);
} }
} }
columns->IsBeingResized = is_being_resized;
window->DC.ColumnsSetId = 0; window->DC.ColumnsSet = NULL;
window->DC.ColumnsCurrent = 0;
window->DC.ColumnsCount = 1;
window->DC.ColumnsFlags = 0;
window->DC.ColumnsData.resize(0);
window->DC.ColumnsOffsetX = 0.0f; window->DC.ColumnsOffsetX = 0.0f;
window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.IndentX + window->DC.ColumnsOffsetX); window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.IndentX + window->DC.ColumnsOffsetX);
} }
// [2017/08: This is currently the only public API, while we are working on making BeginColumns/EndColumns user-facing] // [2017/12: This is currently the only public API, while we are working on making BeginColumns/EndColumns user-facing]
void ImGui::Columns(int columns_count, const char* id, bool border) void ImGui::Columns(int columns_count, const char* id, bool border)
{ {
ImGuiWindow* window = GetCurrentWindow(); ImGuiWindow* window = GetCurrentWindow();
IM_ASSERT(columns_count >= 1); IM_ASSERT(columns_count >= 1);
if (window->DC.ColumnsSet != NULL && window->DC.ColumnsSet->Count != columns_count)
if (window->DC.ColumnsCount != columns_count && window->DC.ColumnsCount != 1)
EndColumns(); EndColumns();
ImGuiColumnsFlags flags = (border ? 0 : ImGuiColumnsFlags_NoBorder); ImGuiColumnsFlags flags = (border ? 0 : ImGuiColumnsFlags_NoBorder);

View File

@ -135,10 +135,12 @@ namespace ImGui
IMGUI_API void EndFrame(); // ends the ImGui frame. automatically called by Render(), so most likely don't need to ever call that yourself directly. If you don't need to render you may call EndFrame() but you'll have wasted CPU already. If you don't need to render, better to not create any imgui windows instead! IMGUI_API void EndFrame(); // ends the ImGui frame. automatically called by Render(), so most likely don't need to ever call that yourself directly. If you don't need to render you may call EndFrame() but you'll have wasted CPU already. If you don't need to render, better to not create any imgui windows instead!
IMGUI_API void Shutdown(); IMGUI_API void Shutdown();
// Demo/Debug/Info // Demo, Debug, Informations
IMGUI_API void ShowTestWindow(bool* p_open = NULL); // create demo/test window. demonstrate most ImGui features. call this to learn about the library! try to make it always available in your application! IMGUI_API void ShowTestWindow(bool* p_open = NULL); // create demo/test window. demonstrate most ImGui features. call this to learn about the library! try to make it always available in your application!
IMGUI_API void ShowMetricsWindow(bool* p_open = NULL); // create metrics window. display ImGui internals: draw commands (with individual draw calls and vertices), window list, basic internal state, etc. IMGUI_API void ShowMetricsWindow(bool* p_open = NULL); // create metrics window. display ImGui internals: draw commands (with individual draw calls and vertices), window list, basic internal state, etc.
IMGUI_API void ShowStyleEditor(ImGuiStyle* ref = NULL); // add style editor block (not a window). you can pass in a reference ImGuiStyle structure to compare to, revert to and save to (else it uses the default style) IMGUI_API void ShowStyleEditor(ImGuiStyle* ref = NULL); // add style editor block (not a window). you can pass in a reference ImGuiStyle structure to compare to, revert to and save to (else it uses the default style)
IMGUI_API bool ShowStyleSelector(const char* label);
IMGUI_API void ShowFontSelector(const char* label);
IMGUI_API void ShowUserGuide(); // add basic help/info block (not a window): how to manipulate ImGui as a end-user (mouse/keyboard controls). IMGUI_API void ShowUserGuide(); // add basic help/info block (not a window): how to manipulate ImGui as a end-user (mouse/keyboard controls).
// Window // Window

View File

@ -1941,6 +1941,41 @@ void ImGui::ShowTestWindow(bool* p_open)
ImGui::End(); ImGui::End();
} }
bool ImGui::ShowStyleSelector(const char* label)
{
static int style_idx = 0;
if (ImGui::Combo(label, &style_idx, "Classic\0Dark\0Light\0"))
{
switch (style_idx)
{
case 0: ImGui::StyleColorsClassic(); break;
case 1: ImGui::StyleColorsDark(); break;
case 2: ImGui::StyleColorsLight(); break;
}
return true;
}
return false;
}
void ImGui::ShowFontSelector(const char* label)
{
ImGuiIO& io = ImGui::GetIO();
ImFont* font_current = ImGui::GetFont();
if (ImGui::BeginCombo(label, font_current->GetDebugName()))
{
for (int n = 0; n < io.Fonts->Fonts.Size; n++)
if (ImGui::Selectable(io.Fonts->Fonts[n]->GetDebugName(), io.Fonts->Fonts[n] == font_current))
io.FontDefault = io.Fonts->Fonts[n];
ImGui::EndCombo();
}
ImGui::SameLine();
ShowHelpMarker(
"- Load additional fonts with io.Fonts->AddFontFromFileTTF().\n"
"- The font atlas is built when calling io.Fonts->GetTexDataAsXXXX() or io.Fonts->Build().\n"
"- Read FAQ and documentation in extra_fonts/ for more details.\n"
"- If you need to add/remove fonts at runtime (e.g. for DPI change), do it before calling NewFrame().");
}
void ImGui::ShowStyleEditor(ImGuiStyle* ref) void ImGui::ShowStyleEditor(ImGuiStyle* ref)
{ {
// You can pass in a reference ImGuiStyle structure to compare to, revert to and save to (else it compares to an internally stored reference) // You can pass in a reference ImGuiStyle structure to compare to, revert to and save to (else it compares to an internally stored reference)
@ -1957,18 +1992,9 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.50f); ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.50f);
// Default Styles Selector if (ImGui::ShowStyleSelector("Colors##Selector"))
static int style_idx = 0;
if (ImGui::Combo("Colors##Selector", &style_idx, "Classic\0Dark\0Light\0"))
{
switch (style_idx)
{
case 0: ImGui::StyleColorsClassic(); break;
case 1: ImGui::StyleColorsDark(); break;
case 2: ImGui::StyleColorsLight(); break;
}
ref_saved_style = style; ref_saved_style = style;
} ImGui::ShowFontSelector("Fonts##Selector");
// Simplified Settings // Simplified Settings
if (ImGui::SliderFloat("FrameRounding", &style.FrameRounding, 0.0f, 12.0f, "%.0f")) if (ImGui::SliderFloat("FrameRounding", &style.FrameRounding, 0.0f, 12.0f, "%.0f"))
@ -2088,7 +2114,6 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
} }
bool fonts_opened = ImGui::TreeNode("Fonts", "Fonts (%d)", ImGui::GetIO().Fonts->Fonts.Size); bool fonts_opened = ImGui::TreeNode("Fonts", "Fonts (%d)", ImGui::GetIO().Fonts->Fonts.Size);
ImGui::SameLine(); ShowHelpMarker("Tip: Load fonts with io.Fonts->AddFontFromFileTTF()\nbefore calling io.Fonts->GetTex* functions.");
if (fonts_opened) if (fonts_opened)
{ {
ImFontAtlas* atlas = ImGui::GetIO().Fonts; ImFontAtlas* atlas = ImGui::GetIO().Fonts;

View File

@ -204,7 +204,7 @@ enum ImGuiColumnsFlags_
ImGuiColumnsFlags_NoResize = 1 << 1, // Disable resizing columns when clicking on the dividers ImGuiColumnsFlags_NoResize = 1 << 1, // Disable resizing columns when clicking on the dividers
ImGuiColumnsFlags_NoPreserveWidths = 1 << 2, // Disable column width preservation when adjusting columns ImGuiColumnsFlags_NoPreserveWidths = 1 << 2, // Disable column width preservation when adjusting columns
ImGuiColumnsFlags_NoForceWithinWindow = 1 << 3, // Disable forcing columns to fit within window ImGuiColumnsFlags_NoForceWithinWindow = 1 << 3, // Disable forcing columns to fit within window
ImGuiColumnsFlags_GrowParentContentsSize= 1 << 4, // (WIP) Restore pre-1.51 behavior of extending the parent window contents size but _without affecting the columns width at all_. Will eventually remove. ImGuiColumnsFlags_GrowParentContentsSize= 1 << 4 // (WIP) Restore pre-1.51 behavior of extending the parent window contents size but _without affecting the columns width at all_. Will eventually remove.
}; };
enum ImGuiSelectableFlagsPrivate_ enum ImGuiSelectableFlagsPrivate_
@ -349,14 +349,6 @@ struct ImGuiGroupData
bool AdvanceCursor; bool AdvanceCursor;
}; };
// Per column data for Columns()
struct ImGuiColumnData
{
float OffsetNorm; // Column start offset, normalized 0.0 (far left) -> 1.0 (far right)
ImRect ClipRect;
//float IndentX;
};
// Simple column measurement currently used for MenuItem() only. This is very short-sighted/throw-away code and NOT a generic helper. // Simple column measurement currently used for MenuItem() only. This is very short-sighted/throw-away code and NOT a generic helper.
struct IMGUI_API ImGuiSimpleColumns struct IMGUI_API ImGuiSimpleColumns
{ {
@ -429,16 +421,56 @@ struct ImGuiMouseCursorData
// Storage for current popup stack // Storage for current popup stack
struct ImGuiPopupRef 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* Window; // Resolved on BeginPopup() - may stay unresolved if user never calls OpenPopup()
ImGuiWindow* ParentWindow; // Set on OpenPopup() ImGuiWindow* ParentWindow; // Set on OpenPopup()
ImGuiID ParentMenuSet; // Set on OpenPopup() ImGuiID ParentMenuSet; // Set on OpenPopup()
ImVec2 PopupPosOnOpen; // Preferred popup position (typically == MousePosOnOpen when using mouse) ImVec2 PopupPosOnOpen; // Preferred popup position (typically == MousePosOnOpen when using mouse)
ImVec2 MousePosOnOpen; // Copy of mouse position at the time of opening popup ImVec2 MousePosOnOpen; // Copy of mouse position at the time of opening popup
ImGuiPopupRef(ImGuiID id, ImGuiWindow* parent_window, ImGuiID parent_menu_set, const ImVec2& popup_pos, const ImVec2& mouse_pos) { PopupId = id; Window = NULL; ParentWindow = parent_window; ParentMenuSet = parent_menu_set; PopupPosOnOpen = popup_pos; MousePosOnOpen = mouse_pos; } ImGuiPopupRef(ImGuiID id, ImGuiWindow* parent_window, ImGuiID parent_menu_set, const ImVec2& popup_pos, const ImVec2& mouse_pos) { PopupId = id; Window = NULL; ParentWindow = parent_window; ParentMenuSet = parent_menu_set; PopupPosOnOpen = popup_pos; MousePosOnOpen = mouse_pos; }
}; };
struct ImGuiColumnData
{
float OffsetNorm; // Column start offset, normalized 0.0 (far left) -> 1.0 (far right)
float OffsetNormBeforeResize;
ImRect ClipRect;
ImGuiColumnData() { OffsetNorm = OffsetNormBeforeResize = 0.0f; }
};
struct ImGuiColumnsSet
{
ImGuiID ID;
ImGuiColumnsFlags Flags;
bool IsFirstFrame;
bool IsBeingResized;
int Current;
int Count;
float MinX, MaxX;
float StartPosY;
float StartMaxPosX; // Backup of CursorMaxPos
float CellMinY, CellMaxY;
ImVector<ImGuiColumnData> Columns;
ImGuiColumnsSet() { Clear(); }
void Clear()
{
ID = 0;
Flags = 0;
IsFirstFrame = false;
IsBeingResized = false;
Current = 0;
Count = 1;
MinX = MaxX = 0.0f;
StartPosY = 0.0f;
StartMaxPosX = 0.0f;
CellMinY = CellMaxY = 0.0f;
Columns.clear();
}
};
// Main state for ImGui // Main state for ImGui
struct ImGuiContext struct ImGuiContext
{ {
@ -762,17 +794,7 @@ struct IMGUI_API ImGuiDrawContext
float IndentX; // Indentation / start position from left of window (increased by TreePush/TreePop, etc.) float IndentX; // Indentation / start position from left of window (increased by TreePush/TreePop, etc.)
float GroupOffsetX; float GroupOffsetX;
float ColumnsOffsetX; // Offset to the current column (if ColumnsCurrent > 0). FIXME: This and the above should be a stack to allow use cases like Tree->Column->Tree. Need revamp columns API. float ColumnsOffsetX; // Offset to the current column (if ColumnsCurrent > 0). FIXME: This and the above should be a stack to allow use cases like Tree->Column->Tree. Need revamp columns API.
int ColumnsCurrent; ImGuiColumnsSet* ColumnsSet; // Current columns set
int ColumnsCount;
float ColumnsMinX;
float ColumnsMaxX;
float ColumnsStartPosY;
float ColumnsStartMaxPosX; // Backup of CursorMaxPos
float ColumnsCellMinY;
float ColumnsCellMaxY;
ImGuiColumnsFlags ColumnsFlags;
ImGuiID ColumnsSetId;
ImVector<ImGuiColumnData> ColumnsData;
ImGuiDrawContext() ImGuiDrawContext()
{ {
@ -800,14 +822,7 @@ struct IMGUI_API ImGuiDrawContext
IndentX = 0.0f; IndentX = 0.0f;
GroupOffsetX = 0.0f; GroupOffsetX = 0.0f;
ColumnsOffsetX = 0.0f; ColumnsOffsetX = 0.0f;
ColumnsCurrent = 0; ColumnsSet = NULL;
ColumnsCount = 1;
ColumnsMinX = ColumnsMaxX = 0.0f;
ColumnsStartPosY = 0.0f;
ColumnsStartMaxPosX = 0.0f;
ColumnsCellMinY = ColumnsCellMaxY = 0.0f;
ColumnsFlags = 0;
ColumnsSetId = 0;
} }
}; };
@ -870,6 +885,7 @@ struct IMGUI_API ImGuiWindow
float ItemWidthDefault; float ItemWidthDefault;
ImGuiSimpleColumns MenuColumns; // Simplified columns storage for menu items ImGuiSimpleColumns MenuColumns; // Simplified columns storage for menu items
ImGuiStorage StateStorage; ImGuiStorage StateStorage;
ImVector<ImGuiColumnsSet> ColumnsStorage;
float FontWindowScale; // Scale multiplier per-window float FontWindowScale; // Scale multiplier per-window
ImDrawList* DrawList; ImDrawList* DrawList;
ImGuiWindow* ParentWindow; // If we are a child _or_ popup window, this is pointing to our parent. Otherwise NULL. ImGuiWindow* ParentWindow; // If we are a child _or_ popup window, this is pointing to our parent. Otherwise NULL.
@ -981,8 +997,8 @@ namespace ImGui
IMGUI_API bool IsDragDropPayloadBeingAccepted(); IMGUI_API bool IsDragDropPayloadBeingAccepted();
// FIXME-WIP: New Columns API // FIXME-WIP: New Columns API
IMGUI_API void BeginColumns(const char* id, int count, ImGuiColumnsFlags flags = 0); // setup number of columns. use an identifier to distinguish multiple column sets. close with EndColumns(). IMGUI_API void BeginColumns(const char* str_id, int count, ImGuiColumnsFlags flags = 0); // setup number of columns. use an identifier to distinguish multiple column sets. close with EndColumns().
IMGUI_API void EndColumns(); // close columns IMGUI_API void EndColumns(); // close columns
IMGUI_API void PushColumnClipRect(int column_index = -1); IMGUI_API void PushColumnClipRect(int column_index = -1);
// NB: All position are in absolute pixels coordinates (never using window coordinates internally) // NB: All position are in absolute pixels coordinates (never using window coordinates internally)