mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
parent
78320aa633
commit
3a31a75e3b
124
imgui.cpp
124
imgui.cpp
@ -1743,7 +1743,7 @@ static void SetCursorPosYAndSetupDummyPrevLine(float pos_y, float line_height)
|
|||||||
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.ColumnsSet)
|
if (window->DC.ColumnsSet)
|
||||||
window->DC.ColumnsSet->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
|
||||||
@ -5731,7 +5731,7 @@ ImVec2 ImGui::GetContentRegionMax()
|
|||||||
ImGuiWindow* window = GetCurrentWindowRead();
|
ImGuiWindow* window = GetCurrentWindowRead();
|
||||||
ImVec2 mx = window->ContentsRegionRect.Max;
|
ImVec2 mx = window->ContentsRegionRect.Max;
|
||||||
if (window->DC.ColumnsSet)
|
if (window->DC.ColumnsSet)
|
||||||
mx.x = GetColumnOffset(window->DC.ColumnsSet->ColumnsCurrent + 1) - window->WindowPadding.x;
|
mx.x = GetColumnOffset(window->DC.ColumnsSet->Current + 1) - window->WindowPadding.x;
|
||||||
return mx;
|
return mx;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -10571,7 +10571,7 @@ void ImGui::Separator()
|
|||||||
if (window->DC.ColumnsSet)
|
if (window->DC.ColumnsSet)
|
||||||
{
|
{
|
||||||
PushColumnClipRect();
|
PushColumnClipRect();
|
||||||
window->DC.ColumnsSet->ColumnsCellMinY = window->DC.CursorPos.y;
|
window->DC.ColumnsSet->CellMinY = window->DC.CursorPos.y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -10792,22 +10792,22 @@ void ImGui::NextColumn()
|
|||||||
PopClipRect();
|
PopClipRect();
|
||||||
|
|
||||||
ImGuiColumnsSet* columns = window->DC.ColumnsSet;
|
ImGuiColumnsSet* columns = window->DC.ColumnsSet;
|
||||||
columns->ColumnsCellMaxY = ImMax(columns->ColumnsCellMaxY, window->DC.CursorPos.y);
|
columns->CellMaxY = ImMax(columns->CellMaxY, window->DC.CursorPos.y);
|
||||||
if (++columns->ColumnsCurrent < columns->ColumnsCount)
|
if (++columns->Current < columns->Count)
|
||||||
{
|
{
|
||||||
// Columns 1+ cancel out IndentX
|
// Columns 1+ cancel out IndentX
|
||||||
window->DC.ColumnsOffsetX = GetColumnOffset(columns->ColumnsCurrent) - window->DC.IndentX + g.Style.ItemSpacing.x;
|
window->DC.ColumnsOffsetX = GetColumnOffset(columns->Current) - window->DC.IndentX + g.Style.ItemSpacing.x;
|
||||||
window->DrawList->ChannelsSetCurrent(columns->ColumnsCurrent);
|
window->DrawList->ChannelsSetCurrent(columns->Current);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
window->DC.ColumnsOffsetX = 0.0f;
|
window->DC.ColumnsOffsetX = 0.0f;
|
||||||
columns->ColumnsCurrent = 0;
|
columns->Current = 0;
|
||||||
columns->ColumnsCellMinY = columns->ColumnsCellMaxY;
|
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 = columns->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;
|
||||||
|
|
||||||
@ -10818,23 +10818,23 @@ void ImGui::NextColumn()
|
|||||||
int ImGui::GetColumnIndex()
|
int ImGui::GetColumnIndex()
|
||||||
{
|
{
|
||||||
ImGuiWindow* window = GetCurrentWindowRead();
|
ImGuiWindow* window = GetCurrentWindowRead();
|
||||||
return window->DC.ColumnsSet ? window->DC.ColumnsSet->ColumnsCurrent : 0;
|
return window->DC.ColumnsSet ? window->DC.ColumnsSet->Current : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ImGui::GetColumnsCount()
|
int ImGui::GetColumnsCount()
|
||||||
{
|
{
|
||||||
ImGuiWindow* window = GetCurrentWindowRead();
|
ImGuiWindow* window = GetCurrentWindowRead();
|
||||||
return window->DC.ColumnsSet ? window->DC.ColumnsSet->ColumnsCount : 1;
|
return window->DC.ColumnsSet ? window->DC.ColumnsSet->Count : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static float OffsetNormToPixels(const ImGuiColumnsSet* columns, float offset_norm)
|
static float OffsetNormToPixels(const ImGuiColumnsSet* columns, float offset_norm)
|
||||||
{
|
{
|
||||||
return offset_norm * (columns->ColumnsMaxX - columns->ColumnsMinX);
|
return offset_norm * (columns->MaxX - columns->MinX);
|
||||||
}
|
}
|
||||||
|
|
||||||
static float PixelsToOffsetNorm(const ImGuiColumnsSet* columns, float offset)
|
static float PixelsToOffsetNorm(const ImGuiColumnsSet* columns, float offset)
|
||||||
{
|
{
|
||||||
return (offset - columns->ColumnsMinX) / (columns->ColumnsMaxX - columns->ColumnsMinX);
|
return (offset - columns->MinX) / (columns->MaxX - columns->MinX);
|
||||||
}
|
}
|
||||||
|
|
||||||
static float GetDraggedColumnOffset(ImGuiColumnsSet* columns, int column_index)
|
static float GetDraggedColumnOffset(ImGuiColumnsSet* columns, int column_index)
|
||||||
@ -10844,11 +10844,11 @@ static float GetDraggedColumnOffset(ImGuiColumnsSet* columns, int column_index)
|
|||||||
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 == columns->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 ((columns->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;
|
||||||
@ -10861,7 +10861,7 @@ float ImGui::GetColumnOffset(int column_index)
|
|||||||
IM_ASSERT(columns != NULL);
|
IM_ASSERT(columns != NULL);
|
||||||
|
|
||||||
if (column_index < 0)
|
if (column_index < 0)
|
||||||
column_index = columns->ColumnsCurrent;
|
column_index = columns->Current;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (g.ActiveId)
|
if (g.ActiveId)
|
||||||
@ -10873,9 +10873,9 @@ float ImGui::GetColumnOffset(int column_index)
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
IM_ASSERT(column_index < columns->ColumnsData.Size);
|
IM_ASSERT(column_index < columns->Columns.Size);
|
||||||
const float t = columns->ColumnsData[column_index].OffsetNorm;
|
const float t = columns->Columns[column_index].OffsetNorm;
|
||||||
const float x_offset = ImLerp(columns->ColumnsMinX, columns->ColumnsMaxX, t);
|
const float x_offset = ImLerp(columns->MinX, columns->MaxX, t);
|
||||||
return x_offset;
|
return x_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -10887,20 +10887,20 @@ void ImGui::SetColumnOffset(int column_index, float offset)
|
|||||||
IM_ASSERT(columns != NULL);
|
IM_ASSERT(columns != NULL);
|
||||||
|
|
||||||
if (column_index < 0)
|
if (column_index < 0)
|
||||||
column_index = columns->ColumnsCurrent;
|
column_index = columns->Current;
|
||||||
|
|
||||||
IM_ASSERT(column_index < columns->ColumnsData.Size);
|
IM_ASSERT(column_index < columns->Columns.Size);
|
||||||
|
|
||||||
const bool preserve_width = !(columns->ColumnsFlags & ImGuiColumnsFlags_NoPreserveWidths) && (column_index < columns->ColumnsCount-1);
|
const bool preserve_width = !(columns->Flags & ImGuiColumnsFlags_NoPreserveWidths) && (column_index < columns->Count-1);
|
||||||
const float width = preserve_width ? GetColumnWidth(column_index) : 0.0f;
|
const float width = preserve_width ? GetColumnWidth(column_index) : 0.0f;
|
||||||
|
|
||||||
if (!(columns->ColumnsFlags & ImGuiColumnsFlags_NoForceWithinWindow))
|
if (!(columns->Flags & ImGuiColumnsFlags_NoForceWithinWindow))
|
||||||
offset = ImMin(offset, columns->ColumnsMaxX - g.Style.ColumnsMinSpacing * (columns->ColumnsCount - column_index));
|
offset = ImMin(offset, columns->MaxX - g.Style.ColumnsMinSpacing * (columns->Count - column_index));
|
||||||
const float offset_norm = PixelsToOffsetNorm(columns, offset);
|
const float offset_norm = PixelsToOffsetNorm(columns, offset);
|
||||||
|
|
||||||
const ImGuiID column_id = columns->ColumnsSetId + ImGuiID(column_index);
|
const ImGuiID column_id = columns->ID + ImGuiID(column_index);
|
||||||
window->DC.StateStorage->SetFloat(column_id, offset_norm);
|
window->DC.StateStorage->SetFloat(column_id, offset_norm);
|
||||||
columns->ColumnsData[column_index].OffsetNorm = offset_norm;
|
columns->Columns[column_index].OffsetNorm = offset_norm;
|
||||||
|
|
||||||
if (preserve_width)
|
if (preserve_width)
|
||||||
SetColumnOffset(column_index + 1, offset + ImMax(g.Style.ColumnsMinSpacing, width));
|
SetColumnOffset(column_index + 1, offset + ImMax(g.Style.ColumnsMinSpacing, width));
|
||||||
@ -10913,8 +10913,8 @@ float ImGui::GetColumnWidth(int column_index)
|
|||||||
IM_ASSERT(columns != NULL);
|
IM_ASSERT(columns != NULL);
|
||||||
|
|
||||||
if (column_index < 0)
|
if (column_index < 0)
|
||||||
column_index = columns->ColumnsCurrent;
|
column_index = columns->Current;
|
||||||
return OffsetNormToPixels(columns, columns->ColumnsData[column_index+1].OffsetNorm - columns->ColumnsData[column_index].OffsetNorm);
|
return OffsetNormToPixels(columns, columns->Columns[column_index+1].OffsetNorm - columns->Columns[column_index].OffsetNorm);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::SetColumnWidth(int column_index, float width)
|
void ImGui::SetColumnWidth(int column_index, float width)
|
||||||
@ -10924,7 +10924,7 @@ void ImGui::SetColumnWidth(int column_index, float width)
|
|||||||
IM_ASSERT(columns != NULL);
|
IM_ASSERT(columns != NULL);
|
||||||
|
|
||||||
if (column_index < 0)
|
if (column_index < 0)
|
||||||
column_index = columns->ColumnsCurrent;
|
column_index = columns->Current;
|
||||||
SetColumnOffset(column_index+1, GetColumnOffset(column_index) + width);
|
SetColumnOffset(column_index+1, GetColumnOffset(column_index) + width);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -10933,20 +10933,20 @@ void ImGui::PushColumnClipRect(int column_index)
|
|||||||
ImGuiWindow* window = GetCurrentWindowRead();
|
ImGuiWindow* window = GetCurrentWindowRead();
|
||||||
ImGuiColumnsSet* columns = window->DC.ColumnsSet;
|
ImGuiColumnsSet* columns = window->DC.ColumnsSet;
|
||||||
if (column_index < 0)
|
if (column_index < 0)
|
||||||
column_index = columns->ColumnsCurrent;
|
column_index = columns->Current;
|
||||||
|
|
||||||
PushClipRect(columns->ColumnsData[column_index].ClipRect.Min, columns->ColumnsData[column_index].ClipRect.Max, false);
|
PushClipRect(columns->Columns[column_index].ClipRect.Min, columns->Columns[column_index].ClipRect.Max, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ImGuiColumnsSet* FindOrAddColumnsSet(ImGuiWindow* window, ImGuiID id)
|
static ImGuiColumnsSet* FindOrAddColumnsSet(ImGuiWindow* window, ImGuiID id)
|
||||||
{
|
{
|
||||||
for (int n = 0; n < window->DC.ColumnsSets.Size; n++)
|
for (int n = 0; n < window->DC.ColumnsSets.Size; n++)
|
||||||
if (window->DC.ColumnsSets[n].ColumnsSetId == id)
|
if (window->DC.ColumnsSets[n].ID == id)
|
||||||
return &window->DC.ColumnsSets[n];
|
return &window->DC.ColumnsSets[n];
|
||||||
|
|
||||||
window->DC.ColumnsSets.push_back(ImGuiColumnsSet());
|
window->DC.ColumnsSets.push_back(ImGuiColumnsSet());
|
||||||
ImGuiColumnsSet* columns = &window->DC.ColumnsSets.back();
|
ImGuiColumnsSet* columns = &window->DC.ColumnsSets.back();
|
||||||
columns->ColumnsSetId = id;
|
columns->ID = id;
|
||||||
return columns;
|
return columns;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -10965,35 +10965,35 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlag
|
|||||||
PopID();
|
PopID();
|
||||||
|
|
||||||
ImGuiColumnsSet* columns = FindOrAddColumnsSet(window, id);
|
ImGuiColumnsSet* columns = FindOrAddColumnsSet(window, id);
|
||||||
IM_ASSERT(columns->ColumnsSetId == id);
|
IM_ASSERT(columns->ID == id);
|
||||||
window->DC.ColumnsSet = columns;
|
window->DC.ColumnsSet = columns;
|
||||||
|
|
||||||
// Set state for first column
|
// Set state for first column
|
||||||
columns->ColumnsCurrent = 0;
|
columns->Current = 0;
|
||||||
columns->ColumnsCount = columns_count;
|
columns->Count = columns_count;
|
||||||
columns->ColumnsFlags = flags;
|
columns->Flags = flags;
|
||||||
|
|
||||||
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);
|
||||||
columns->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
|
||||||
//column->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;
|
||||||
columns->ColumnsMaxX = content_region_width - window->Scroll.x;
|
columns->MaxX = content_region_width - window->Scroll.x;
|
||||||
columns->ColumnsStartPosY = window->DC.CursorPos.y;
|
columns->StartPosY = window->DC.CursorPos.y;
|
||||||
columns->ColumnsStartMaxPosX = window->DC.CursorMaxPos.x;
|
columns->StartMaxPosX = window->DC.CursorMaxPos.x;
|
||||||
columns->ColumnsCellMinY = columns->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
|
// Cache column offsets
|
||||||
columns->ColumnsData.resize(columns_count + 1);
|
columns->Columns.resize(columns_count + 1);
|
||||||
for (int column_index = 0; column_index < columns_count + 1; column_index++)
|
for (int column_index = 0; column_index < columns_count + 1; column_index++)
|
||||||
{
|
{
|
||||||
const ImGuiID column_id = columns->ColumnsSetId + ImGuiID(column_index);
|
const ImGuiID column_id = columns->ID + ImGuiID(column_index);
|
||||||
KeepAliveID(column_id);
|
KeepAliveID(column_id);
|
||||||
const float default_t = column_index / (float)columns_count;
|
const float default_t = column_index / (float)columns_count;
|
||||||
float t = window->DC.StateStorage->GetFloat(column_id, default_t);
|
float t = window->DC.StateStorage->GetFloat(column_id, default_t);
|
||||||
if (!(columns->ColumnsFlags & ImGuiColumnsFlags_NoForceWithinWindow))
|
if (!(columns->Flags & ImGuiColumnsFlags_NoForceWithinWindow))
|
||||||
t = ImMin(t, PixelsToOffsetNorm(columns, columns->ColumnsMaxX - g.Style.ColumnsMinSpacing * (columns->ColumnsCount - column_index)));
|
t = ImMin(t, PixelsToOffsetNorm(columns, columns->MaxX - g.Style.ColumnsMinSpacing * (columns->Count - column_index)));
|
||||||
columns->ColumnsData[column_index].OffsetNorm = t;
|
columns->Columns[column_index].OffsetNorm = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cache clipping rectangles
|
// Cache clipping rectangles
|
||||||
@ -11001,11 +11001,11 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlag
|
|||||||
{
|
{
|
||||||
float clip_x1 = ImFloor(0.5f + window->Pos.x + GetColumnOffset(column_index) - 1.0f);
|
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);
|
float clip_x2 = ImFloor(0.5f + window->Pos.x + GetColumnOffset(column_index + 1) - 1.0f);
|
||||||
columns->ColumnsData[column_index].ClipRect = ImRect(clip_x1, -FLT_MAX, clip_x2, +FLT_MAX);
|
columns->Columns[column_index].ClipRect = ImRect(clip_x1, -FLT_MAX, clip_x2, +FLT_MAX);
|
||||||
columns->ColumnsData[column_index].ClipRect.ClipWith(window->ClipRect);
|
columns->Columns[column_index].ClipRect.ClipWith(window->ClipRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
window->DrawList->ChannelsSplit(columns->ColumnsCount);
|
window->DrawList->ChannelsSplit(columns->Count);
|
||||||
PushColumnClipRect();
|
PushColumnClipRect();
|
||||||
PushItemWidth(GetColumnWidth() * 0.65f);
|
PushItemWidth(GetColumnWidth() * 0.65f);
|
||||||
}
|
}
|
||||||
@ -11021,28 +11021,28 @@ void ImGui::EndColumns()
|
|||||||
PopClipRect();
|
PopClipRect();
|
||||||
window->DrawList->ChannelsMerge();
|
window->DrawList->ChannelsMerge();
|
||||||
|
|
||||||
columns->ColumnsCellMaxY = ImMax(columns->ColumnsCellMaxY, window->DC.CursorPos.y);
|
columns->CellMaxY = ImMax(columns->CellMaxY, window->DC.CursorPos.y);
|
||||||
window->DC.CursorPos.y = columns->ColumnsCellMaxY;
|
window->DC.CursorPos.y = columns->CellMaxY;
|
||||||
if (!(columns->ColumnsFlags & ImGuiColumnsFlags_GrowParentContentsSize))
|
if (!(columns->Flags & ImGuiColumnsFlags_GrowParentContentsSize))
|
||||||
window->DC.CursorMaxPos.x = ImMax(columns->ColumnsStartMaxPosX, columns->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 (!(columns->ColumnsFlags & ImGuiColumnsFlags_NoBorder) && !window->SkipItems)
|
if (!(columns->Flags & ImGuiColumnsFlags_NoBorder) && !window->SkipItems)
|
||||||
{
|
{
|
||||||
const float y1 = columns->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 < columns->ColumnsCount; i++)
|
for (int i = 1; i < columns->Count; i++)
|
||||||
{
|
{
|
||||||
float x = window->Pos.x + GetColumnOffset(i);
|
float x = window->Pos.x + GetColumnOffset(i);
|
||||||
const ImGuiID column_id = columns->ColumnsSetId + ImGuiID(i);
|
const ImGuiID column_id = columns->ID + ImGuiID(i);
|
||||||
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));
|
||||||
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 (!(columns->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)
|
||||||
@ -11068,7 +11068,7 @@ void ImGui::EndColumns()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
columns->ColumnsData.resize(0);
|
columns->Columns.resize(0);
|
||||||
window->DC.ColumnsSet = NULL;
|
window->DC.ColumnsSet = NULL;
|
||||||
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);
|
||||||
@ -11080,7 +11080,7 @@ 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->ColumnsCount != columns_count)
|
if (window->DC.ColumnsSet != NULL && window->DC.ColumnsSet->Count != columns_count)
|
||||||
EndColumns();
|
EndColumns();
|
||||||
|
|
||||||
ImGuiColumnsFlags flags = (border ? 0 : ImGuiColumnsFlags_NoBorder);
|
ImGuiColumnsFlags flags = (border ? 0 : ImGuiColumnsFlags_NoBorder);
|
||||||
|
@ -421,30 +421,28 @@ struct ImGuiColumnData
|
|||||||
|
|
||||||
struct ImGuiColumnsSet
|
struct ImGuiColumnsSet
|
||||||
{
|
{
|
||||||
int ColumnsCurrent;
|
ImGuiID ID;
|
||||||
int ColumnsCount;
|
ImGuiColumnsFlags Flags;
|
||||||
float ColumnsMinX;
|
int Current;
|
||||||
float ColumnsMaxX;
|
int Count;
|
||||||
float ColumnsStartPosY;
|
float MinX, MaxX;
|
||||||
float ColumnsStartMaxPosX; // Backup of CursorMaxPos
|
float StartPosY;
|
||||||
float ColumnsCellMinY;
|
float StartMaxPosX; // Backup of CursorMaxPos
|
||||||
float ColumnsCellMaxY;
|
float CellMinY, CellMaxY;
|
||||||
ImGuiColumnsFlags ColumnsFlags;
|
ImVector<ImGuiColumnData> Columns;
|
||||||
ImGuiID ColumnsSetId;
|
|
||||||
ImVector<ImGuiColumnData> ColumnsData;
|
|
||||||
|
|
||||||
ImGuiColumnsSet() { Clear(); }
|
ImGuiColumnsSet() { Clear(); }
|
||||||
void Clear()
|
void Clear()
|
||||||
{
|
{
|
||||||
ColumnsCurrent = 0;
|
ID = 0;
|
||||||
ColumnsCount = 1;
|
Flags = 0;
|
||||||
ColumnsMinX = ColumnsMaxX = 0.0f;
|
Current = 0;
|
||||||
ColumnsStartPosY = 0.0f;
|
Count = 1;
|
||||||
ColumnsStartMaxPosX = 0.0f;
|
MinX = MaxX = 0.0f;
|
||||||
ColumnsCellMinY = ColumnsCellMaxY = 0.0f;
|
StartPosY = 0.0f;
|
||||||
ColumnsFlags = 0;
|
StartMaxPosX = 0.0f;
|
||||||
ColumnsSetId = 0;
|
CellMinY = CellMaxY = 0.0f;
|
||||||
ColumnsData.clear();
|
Columns.clear();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user