mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-18 06:06:35 +00:00
ColumnsStartX include window->Scroll.x to simplify code (#246)
This commit is contained in:
parent
8edbdb9775
commit
f128a8bce1
24
imgui.cpp
24
imgui.cpp
@ -1579,7 +1579,7 @@ void ImGui::ItemSize(const ImVec2& size, float text_offset_y)
|
||||
const float line_height = ImMax(window->DC.CurrentLineHeight, size.y);
|
||||
const float text_base_offset = ImMax(window->DC.CurrentLineTextBaseOffset, text_offset_y);
|
||||
window->DC.CursorPosPrevLine = ImVec2(window->DC.CursorPos.x + size.x, window->DC.CursorPos.y);
|
||||
window->DC.CursorPos = ImVec2((float)(int)(window->Pos.x - window->Scroll.x + window->DC.ColumnsStartX + window->DC.ColumnsOffsetX), (float)(int)(window->DC.CursorPos.y + line_height + g.Style.ItemSpacing.y));
|
||||
window->DC.CursorPos = ImVec2((float)(int)(window->Pos.x + window->DC.ColumnsStartX + window->DC.ColumnsOffsetX), (float)(int)(window->DC.CursorPos.y + line_height + g.Style.ItemSpacing.y));
|
||||
window->DC.CursorMaxPos.x = ImMax(window->DC.CursorMaxPos.x, window->DC.CursorPosPrevLine.x);
|
||||
window->DC.CursorMaxPos.y = ImMax(window->DC.CursorMaxPos.y, window->DC.CursorPos.y);
|
||||
|
||||
@ -3851,16 +3851,16 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_
|
||||
}
|
||||
|
||||
// Setup drawing context
|
||||
window->DC.ColumnsStartX = window->WindowPadding.x;
|
||||
window->DC.ColumnsStartX = 0.0f + window->WindowPadding.x - window->Scroll.x;
|
||||
window->DC.ColumnsOffsetX = 0.0f;
|
||||
window->DC.CursorStartPos = window->Pos - window->Scroll + ImVec2(window->DC.ColumnsStartX + window->DC.ColumnsOffsetX, window->TitleBarHeight() + window->MenuBarHeight() + window->WindowPadding.y);
|
||||
window->DC.CursorStartPos = window->Pos + ImVec2(window->DC.ColumnsStartX + window->DC.ColumnsOffsetX, window->TitleBarHeight() + window->MenuBarHeight() + window->WindowPadding.y - window->Scroll.y);
|
||||
window->DC.CursorPos = window->DC.CursorStartPos;
|
||||
window->DC.CursorPosPrevLine = window->DC.CursorPos;
|
||||
window->DC.CursorMaxPos = window->DC.CursorStartPos;
|
||||
window->DC.CurrentLineHeight = window->DC.PrevLineHeight = 0.0f;
|
||||
window->DC.CurrentLineTextBaseOffset = window->DC.PrevLineTextBaseOffset = 0.0f;
|
||||
window->DC.MenuBarAppending = false;
|
||||
window->DC.MenuBarOffsetX = ImMax(window->DC.ColumnsStartX, style.ItemSpacing.x);
|
||||
window->DC.MenuBarOffsetX = ImMax(window->WindowPadding.x, style.ItemSpacing.x);
|
||||
window->DC.LogLinePosY = window->DC.CursorPos.y - 9999.0f;
|
||||
window->DC.ChildWindows.resize(0);
|
||||
window->DC.LayoutType = ImGuiLayoutType_Vertical;
|
||||
@ -8454,7 +8454,7 @@ void ImGui::BeginGroup()
|
||||
group_data.BackupLogLinePosY = window->DC.LogLinePosY;
|
||||
group_data.AdvanceCursor = true;
|
||||
|
||||
window->DC.ColumnsStartX = window->DC.CursorPos.x - window->Pos.x + window->Scroll.x;
|
||||
window->DC.ColumnsStartX = window->DC.CursorPos.x - window->Pos.x;
|
||||
window->DC.CursorMaxPos = window->DC.CursorPos;
|
||||
window->DC.CurrentLineHeight = 0.0f;
|
||||
window->DC.LogLinePosY = window->DC.CursorPos.y - 9999.0f;
|
||||
@ -8537,7 +8537,7 @@ void ImGui::NextColumn()
|
||||
window->DC.ColumnsCellMaxY = ImMax(window->DC.ColumnsCellMaxY, window->DC.CursorPos.y);
|
||||
if (++window->DC.ColumnsCurrent < window->DC.ColumnsCount)
|
||||
{
|
||||
window->DC.ColumnsOffsetX = ImGui::GetColumnOffset(window->DC.ColumnsCurrent) - window->DC.ColumnsStartX + window->Scroll.x + g.Style.ItemSpacing.x;
|
||||
window->DC.ColumnsOffsetX = ImGui::GetColumnOffset(window->DC.ColumnsCurrent) - window->DC.ColumnsStartX + g.Style.ItemSpacing.x;
|
||||
window->DrawList->ChannelsSetCurrent(window->DC.ColumnsCurrent);
|
||||
}
|
||||
else
|
||||
@ -8547,7 +8547,7 @@ void ImGui::NextColumn()
|
||||
window->DC.ColumnsCellMinY = window->DC.ColumnsCellMaxY;
|
||||
window->DrawList->ChannelsSetCurrent(0);
|
||||
}
|
||||
window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.ColumnsStartX - window->Scroll.x + window->DC.ColumnsOffsetX);
|
||||
window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.ColumnsStartX + window->DC.ColumnsOffsetX);
|
||||
window->DC.CursorPos.y = window->DC.ColumnsCellMinY;
|
||||
window->DC.CurrentLineHeight = 0.0f;
|
||||
window->DC.CurrentLineTextBaseOffset = 0.0f;
|
||||
@ -8603,7 +8603,7 @@ float ImGui::GetColumnOffset(int column_index)
|
||||
const float t = window->DC.ColumnsOffsetsT[column_index];
|
||||
|
||||
const float content_region_width = window->SizeContentsExplicit.x ? window->SizeContentsExplicit.x : window->Size.x;
|
||||
const float min_x = window->DC.ColumnsStartX - window->Scroll.x;
|
||||
const float min_x = window->DC.ColumnsStartX;
|
||||
const float max_x = content_region_width - window->Scroll.x - ((window->Flags & ImGuiWindowFlags_NoScrollbar) ? 0 : g.Style.ScrollbarSize);// - window->WindowPadding().x;
|
||||
const float x = min_x + t * (max_x - min_x);
|
||||
return (float)(int)x;
|
||||
@ -8620,7 +8620,7 @@ void ImGui::SetColumnOffset(int column_index, float offset)
|
||||
const ImGuiID column_id = window->DC.ColumnsSetID + ImGuiID(column_index);
|
||||
|
||||
const float content_region_width = window->SizeContentsExplicit.x ? window->SizeContentsExplicit.x : window->Size.x;
|
||||
const float min_x = window->DC.ColumnsStartX - window->Scroll.x;
|
||||
const float min_x = window->DC.ColumnsStartX;
|
||||
const float max_x = content_region_width - window->Scroll.x - ((window->Flags & ImGuiWindowFlags_NoScrollbar) ? 0 : g.Style.ScrollbarSize);// - window->WindowPadding().x;
|
||||
const float t = (offset - min_x) / (max_x - min_x);
|
||||
window->DC.StateStorage->SetFloat(column_id, t);
|
||||
@ -8709,7 +8709,7 @@ void ImGui::Columns(int columns_count, const char* id, bool border)
|
||||
window->DC.ColumnsStartPos = window->DC.CursorPos;
|
||||
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->Scroll.x + window->DC.ColumnsStartX + window->DC.ColumnsOffsetX);
|
||||
window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.ColumnsStartX + window->DC.ColumnsOffsetX);
|
||||
|
||||
if (window->DC.ColumnsCount != 1)
|
||||
{
|
||||
@ -8740,7 +8740,7 @@ void ImGui::Indent()
|
||||
ImGuiState& g = *GImGui;
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
window->DC.ColumnsStartX += g.Style.IndentSpacing;
|
||||
window->DC.CursorPos.x = window->Pos.x - window->Scroll.x + window->DC.ColumnsStartX + window->DC.ColumnsOffsetX;
|
||||
window->DC.CursorPos.x = window->Pos.x + window->DC.ColumnsStartX + window->DC.ColumnsOffsetX;
|
||||
}
|
||||
|
||||
void ImGui::Unindent()
|
||||
@ -8748,7 +8748,7 @@ void ImGui::Unindent()
|
||||
ImGuiState& g = *GImGui;
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
window->DC.ColumnsStartX -= g.Style.IndentSpacing;
|
||||
window->DC.CursorPos.x = window->Pos.x - window->Scroll.x + window->DC.ColumnsStartX + window->DC.ColumnsOffsetX;
|
||||
window->DC.CursorPos.x = window->Pos.x + window->DC.ColumnsStartX + window->DC.ColumnsOffsetX;
|
||||
}
|
||||
|
||||
void ImGui::TreePush(const char* str_id)
|
||||
|
@ -128,7 +128,7 @@ void ImGui::ShowTestWindow(bool* opened)
|
||||
static float bg_alpha = 0.65f;
|
||||
|
||||
// Demonstrate the various window flags. Typically you would just use the default.
|
||||
ImGuiWindowFlags window_flags = 0;
|
||||
ImGuiWindowFlags window_flags = ImGuiWindowFlags_HorizontalScrollbar;
|
||||
if (no_titlebar) window_flags |= ImGuiWindowFlags_NoTitleBar;
|
||||
if (!no_border) window_flags |= ImGuiWindowFlags_ShowBorders;
|
||||
if (no_resize) window_flags |= ImGuiWindowFlags_NoResize;
|
||||
|
Loading…
Reference in New Issue
Block a user