Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When a SortTable is resized, now the width of the columns and the num… #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion widgets/ScrollTable.lua
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ local methods = {
end

cell:SetHeight(rowHeight);
cell:SetWidth(self.columns[j].width);
Jakobud marked this conversation as resolved.
Show resolved Hide resolved

cell.text:SetPoint('TOP', cell, 'TOP', 0, 0);
cell.text:SetPoint('BOTTOM', cell, 'BOTTOM', 0, 0);
Expand Down Expand Up @@ -652,6 +651,26 @@ local methods = {
end
end
end

-- When SortTable changes size, resize columns proportionally to their initial width
self:SetScript("OnSizeChanged", function(self, width, height)
local tableWidth = self:GetWidth();
local tableHeight = self:GetHeight();

-- Determine total width of columns
local total = 0;
for i=1, #self.columns do
total = total + self.columns[i].width;
end

-- Adjust all column widths proportionally
for i=1, #self.columns do
self.columns[i]:SetWidth(self.columns[i].width/total*tableWidth);
end

-- Set the number of displayed rows according to the new height
self:SetDisplayRows(math.floor(tableHeight/self.rowHeight), self.rowHeight);
end);
end,
};

Expand Down