mirror of
https://github.com/shadps4-emu/ext-imgui.git
synced 2024-11-27 12:11:34 +00:00
Columns: minor tidying up while investigating severe issues with indenting within columns (#414)
This commit is contained in:
parent
58b23b4785
commit
807d4ff92c
13
imgui.cpp
13
imgui.cpp
@ -3970,8 +3970,8 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_
|
||||
window->DC.ColorEditMode = ImGuiColorEditMode_UserSelect;
|
||||
window->DC.ColumnsCurrent = 0;
|
||||
window->DC.ColumnsCount = 1;
|
||||
window->DC.ColumnsStartPos = window->DC.CursorPos;
|
||||
window->DC.ColumnsCellMinY = window->DC.ColumnsCellMaxY = window->DC.ColumnsStartPos.y;
|
||||
window->DC.ColumnsStartPosY = window->DC.CursorPos.y;
|
||||
window->DC.ColumnsCellMinY = window->DC.ColumnsCellMaxY = window->DC.ColumnsStartPosY;
|
||||
window->DC.TreeDepth = 0;
|
||||
window->DC.StateStorage = &window->StateStorage;
|
||||
window->DC.GroupStack.resize(0);
|
||||
@ -4695,6 +4695,7 @@ void ImGui::SetNextWindowFocus()
|
||||
}
|
||||
|
||||
// In window space (not screen space!)
|
||||
// FIXME-OPT: Could cache and maintain it (pretty much only change on columns change)
|
||||
ImVec2 ImGui::GetContentRegionMax()
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindowRead();
|
||||
@ -8752,7 +8753,7 @@ int ImGui::GetColumnsCount()
|
||||
static float GetDraggedColumnOffset(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
|
||||
// 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.
|
||||
ImGuiState& 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.
|
||||
@ -8784,7 +8785,7 @@ float ImGui::GetColumnOffset(int column_index)
|
||||
|
||||
const float content_region_width = window->SizeContentsExplicit.x ? window->SizeContentsExplicit.x : window->Size.x;
|
||||
const float min_x = window->DC.IndentX;
|
||||
const float max_x = content_region_width - window->Scroll.x - ((window->Flags & ImGuiWindowFlags_NoScrollbar) ? 0 : g.Style.ScrollbarSize);// - window->WindowPadding().x;
|
||||
const float max_x = content_region_width - window->Scroll.x - ((window->Flags & ImGuiWindowFlags_NoScrollbar) ? 0.0f : window->ScrollbarSizes.x);// - window->WindowPadding().x;
|
||||
const float x = min_x + t * (max_x - min_x);
|
||||
return (float)(int)x;
|
||||
}
|
||||
@ -8849,7 +8850,7 @@ void ImGui::Columns(int columns_count, const char* id, bool border)
|
||||
// Draw columns borders and handle resize at the time of "closing" a columns set
|
||||
if (window->DC.ColumnsCount != columns_count && window->DC.ColumnsCount != 1 && window->DC.ColumnsShowBorders && !window->SkipItems)
|
||||
{
|
||||
const float y1 = window->DC.ColumnsStartPos.y;
|
||||
const float y1 = window->DC.ColumnsStartPosY;
|
||||
const float y2 = window->DC.CursorPos.y;
|
||||
for (int i = 1; i < window->DC.ColumnsCount; i++)
|
||||
{
|
||||
@ -8887,7 +8888,7 @@ void ImGui::Columns(int columns_count, const char* id, bool border)
|
||||
window->DC.ColumnsCurrent = 0;
|
||||
window->DC.ColumnsCount = columns_count;
|
||||
window->DC.ColumnsShowBorders = border;
|
||||
window->DC.ColumnsStartPos = window->DC.CursorPos;
|
||||
window->DC.ColumnsStartPosY = window->DC.CursorPos.y;
|
||||
window->DC.ColumnsCellMinY = window->DC.ColumnsCellMaxY = window->DC.CursorPos.y;
|
||||
window->DC.ColumnsOffsetX = 0.0f;
|
||||
window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.IndentX + window->DC.ColumnsOffsetX);
|
||||
|
@ -1288,8 +1288,9 @@ void ImGui::ShowTestWindow(bool* opened)
|
||||
ImGui::Spacing();
|
||||
|
||||
// Tree items
|
||||
ImGui::Text("Tree items:");
|
||||
ImGui::Columns(2, "tree items");
|
||||
ImGui::Text("Tree items:");
|
||||
ImGui::SameLine(); ShowHelpMarker("Whole tree inside single cell");
|
||||
ImGui::Columns(2, "tree items");
|
||||
ImGui::Separator();
|
||||
if (ImGui::TreeNode("Hello")) { ImGui::BulletText("Sailor"); ImGui::TreePop(); } ImGui::NextColumn();
|
||||
if (ImGui::TreeNode("Bonjour")) { ImGui::BulletText("Marin"); ImGui::TreePop(); } ImGui::NextColumn();
|
||||
|
@ -536,7 +536,7 @@ struct IMGUI_API ImGuiDrawContext
|
||||
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;
|
||||
int ColumnsCount;
|
||||
ImVec2 ColumnsStartPos;
|
||||
float ColumnsStartPosY;
|
||||
float ColumnsCellMinY;
|
||||
float ColumnsCellMaxY;
|
||||
bool ColumnsShowBorders;
|
||||
@ -568,7 +568,7 @@ struct IMGUI_API ImGuiDrawContext
|
||||
ColumnsOffsetX = 0.0f;
|
||||
ColumnsCurrent = 0;
|
||||
ColumnsCount = 1;
|
||||
ColumnsStartPos = ImVec2(0.0f, 0.0f);
|
||||
ColumnsStartPosY = 0.0f;
|
||||
ColumnsCellMinY = ColumnsCellMaxY = 0.0f;
|
||||
ColumnsShowBorders = true;
|
||||
ColumnsSetID = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user