mirror of
https://github.com/Drezil/imgui.git
synced 2025-01-11 16:26:35 +00:00
Columns: Fixed offset rounding leading to SetColumnOffset() being destructive when ImGuiColumnsFlags_NoPreserveWidths flag is not set. (#913, #125)
This commit is contained in:
parent
3bf2af23e6
commit
a511b00226
@ -9952,7 +9952,7 @@ static float GetDraggedColumnOffset(int column_index)
|
|||||||
if ((window->DC.ColumnsFlags & ImGuiColumnsFlags_NoPreserveWidths))
|
if ((window->DC.ColumnsFlags & 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 (float)(int)x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
float ImGui::GetColumnOffset(int column_index)
|
float ImGui::GetColumnOffset(int column_index)
|
||||||
@ -9972,7 +9972,7 @@ float ImGui::GetColumnOffset(int column_index)
|
|||||||
IM_ASSERT(column_index < window->DC.ColumnsData.Size);
|
IM_ASSERT(column_index < window->DC.ColumnsData.Size);
|
||||||
const float t = window->DC.ColumnsData[column_index].OffsetNorm;
|
const float t = window->DC.ColumnsData[column_index].OffsetNorm;
|
||||||
const float x_offset = ImLerp(window->DC.ColumnsMinX, window->DC.ColumnsMaxX, t);
|
const float x_offset = ImLerp(window->DC.ColumnsMinX, window->DC.ColumnsMaxX, t);
|
||||||
return (float)(int)x_offset;
|
return x_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::SetColumnOffset(int column_index, float offset)
|
void ImGui::SetColumnOffset(int column_index, float offset)
|
||||||
@ -9988,7 +9988,7 @@ void ImGui::SetColumnOffset(int column_index, float offset)
|
|||||||
const float width = preserve_width ? GetColumnWidth(column_index) : 0.0f;
|
const float width = preserve_width ? GetColumnWidth(column_index) : 0.0f;
|
||||||
|
|
||||||
if (!(window->DC.ColumnsFlags & ImGuiColumnsFlags_NoForceWithinWindow))
|
if (!(window->DC.ColumnsFlags & ImGuiColumnsFlags_NoForceWithinWindow))
|
||||||
offset = ImMin((float)(int)offset, window->DC.ColumnsMaxX - g.Style.ColumnsMinSpacing * (window->DC.ColumnsCount - column_index));
|
offset = ImMin(offset, window->DC.ColumnsMaxX - g.Style.ColumnsMinSpacing * (window->DC.ColumnsCount - column_index));
|
||||||
const float offset_norm = PixelsToOffsetNorm(window, offset);
|
const float offset_norm = PixelsToOffsetNorm(window, offset);
|
||||||
|
|
||||||
const ImGuiID column_id = window->DC.ColumnsSetId + ImGuiID(column_index);
|
const ImGuiID column_id = window->DC.ColumnsSetId + ImGuiID(column_index);
|
||||||
|
2
imgui.h
2
imgui.h
@ -237,7 +237,7 @@ namespace ImGui
|
|||||||
IMGUI_API int GetColumnIndex(); // get current column index
|
IMGUI_API int GetColumnIndex(); // get current column index
|
||||||
IMGUI_API float GetColumnWidth(int column_index = -1); // get column width (in pixels). pass -1 to use current column
|
IMGUI_API float GetColumnWidth(int column_index = -1); // get column width (in pixels). pass -1 to use current column
|
||||||
IMGUI_API void SetColumnWidth(int column_index, float width); // set column width (in pixels). pass -1 to use current column
|
IMGUI_API void SetColumnWidth(int column_index, float width); // set column width (in pixels). pass -1 to use current column
|
||||||
IMGUI_API float GetColumnOffset(int column_index = -1); // get position of column line (in pixels, from the left side of the contents region). pass -1 to use current column, otherwise 0..GetColumnsCount() inclusive. column 0 is usually 0.0f and not resizable unless you call this
|
IMGUI_API float GetColumnOffset(int column_index = -1); // get position of column line (in pixels, from the left side of the contents region). pass -1 to use current column, otherwise 0..GetColumnsCount() inclusive. column 0 is typically 0.0f
|
||||||
IMGUI_API void SetColumnOffset(int column_index, float offset_x); // set position of column line (in pixels, from the left side of the contents region). pass -1 to use current column
|
IMGUI_API void SetColumnOffset(int column_index, float offset_x); // set position of column line (in pixels, from the left side of the contents region). pass -1 to use current column
|
||||||
IMGUI_API int GetColumnsCount();
|
IMGUI_API int GetColumnsCount();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user