proper row button for listings and some filter changes

This commit is contained in:
Simon Hirsig
2015-10-30 13:02:47 +01:00
parent a89775e393
commit c17a1508c6
4 changed files with 88 additions and 107 deletions
View File
+42 -34
View File
@@ -48,7 +48,7 @@ function Aux.sheet.render(sheet)
sheet.row_setter(row, datum)
end
for j, column in sheet.columns do
local cell = row[j]
local cell = row.cells[j]
if datum then
column.cell_setter(cell, datum)
cell:Show()
@@ -147,41 +147,49 @@ function Aux.sheet.create(frame, columns, sort_order, row_setter, on_cell_click,
local max_height = content:GetHeight()
local total_height = 16
while total_height + 14 < max_height do
local row = {}
for i = 1,getn(columns) do
local cell = CreateFrame('Button', nil, content)
cell:SetPoint('TOPLEFT', labels[i], 'BOTTOMLEFT', 0, -((row_index-1) * 14))
cell:SetPoint('TOPRIGHT', labels[i], 'BOTTOMRIGHT', 0, -((row_index-1) * 14))
cell:RegisterForClicks("LeftButtonDown", "RightButtonDown")
if getn(columns) > 0 then
local row = CreateFrame('Button', nil, content)
row:SetPoint('TOPLEFT', labels[1], 'BOTTOMLEFT', 0, -((row_index-1) * 14))
row:SetPoint('TOPRIGHT', labels[getn(columns)], 'BOTTOMRIGHT', 0, -((row_index-1) * 14))
row:RegisterForClicks("LeftButtonDown", "RightButtonDown")
row:SetHeight(14)
row.cells = {}
cell:SetHeight(14)
local row_index, column_index = row_index, i
cell:SetScript("OnClick", function() if sheet.on_cell_click then sheet.on_cell_click(sheet, row_index, column_index) end end)
cell:SetScript("OnEnter", function() if sheet.on_cell_enter then sheet.on_cell_enter(sheet, row_index, column_index) end end)
cell:SetScript("OnLeave", function() if sheet.on_cell_leave then sheet.on_cell_leave(sheet, row_index, column_index) end end)
for i = 1,getn(columns) do
local cell = CreateFrame('Button', nil, content)
cell:SetPoint('TOPLEFT', labels[i], 'BOTTOMLEFT', 0, -((row_index-1) * 14))
cell:SetPoint('TOPRIGHT', labels[i], 'BOTTOMRIGHT', 0, -((row_index-1) * 14))
cell:RegisterForClicks("LeftButtonDown", "RightButtonDown")
cell:SetHeight(14)
local row_index, column_index = row_index, i
cell:SetScript("OnClick", function() if sheet.on_cell_click then sheet.on_cell_click(sheet, row_index, column_index) end end)
cell:SetScript("OnEnter", function() if sheet.on_cell_enter then sheet.on_cell_enter(sheet, row_index, column_index) end end)
cell:SetScript("OnLeave", function() if sheet.on_cell_leave then sheet.on_cell_leave(sheet, row_index, column_index) end end)
columns[i].cell_initializer(cell)
columns[i].cell_initializer(cell)
row.cells[i] = cell
end
row[i] = cell
local color_texture = row:CreateTexture()
color_texture:SetPoint('TOPLEFT', row, 'TOPLEFT', 0, 0)
color_texture:SetPoint('BOTTOMRIGHT', row, 'BOTTOMRIGHT', 0, 1)
color_texture:SetTexture(1, 1, 1)
row.color_texture = color_texture
local highlight = row:CreateTexture()
highlight:SetPoint('TOPLEFT', row 'TOPLEFT', 0, 0)
highlight:SetPoint('BOTTOMRIGHT', row, 'BOTTOMRIGHT', 0, 1)
highlight:SetAlpha(0)
highlight:SetTexture(0.8, 0.6, 0)
row.highlight = highlight
rows[row_index] = row
row_index = row_index + 1
total_height = total_height + 14
end
local color_texture = content:CreateTexture()
color_texture:SetPoint('TOPLEFT', row[1], 'TOPLEFT', 0, 0)
color_texture:SetPoint('BOTTOMRIGHT', row[getn(columns)], 'BOTTOMRIGHT', 0, 1)
color_texture:SetTexture(1, 1, 1)
row.color_texture = color_texture
local highlight = content:CreateTexture()
highlight:SetPoint('TOPLEFT', row[1], 'TOPLEFT', 0, 0)
highlight:SetPoint('BOTTOMRIGHT', row[getn(columns)], 'BOTTOMRIGHT', 0, 1)
highlight:SetAlpha(0)
highlight:SetTexture(0.8, 0.6, 0)
row.highlight = highlight
rows[row_index] = row
row_index = row_index + 1
total_height = total_height + 14
end
content:SetWidth(total_width)
@@ -210,7 +218,7 @@ function Aux.list.row_comparator(sheet)
for _, sort_info in ipairs(sheet.sort_order) do
local column = sort_info.column
if column.comparator then
local ordering = column.comparator(row1, row2)
local ordering = column.comparator(row1.cells, row2.cells)
if ordering ~= Aux.util.EQ then
return sort_info.sort_ascending and ordering or Aux.util.invert_order(ordering)
end
@@ -268,4 +276,4 @@ function Aux.list.sort(sheet, column_index)
Aux.util.merge_sort(sheet.data, Aux.list.row_comparator(sheet))
Aux.sheet.render(sheet)
end
end
+11 -34
View File
@@ -506,9 +506,10 @@ function public.set_filter(filter)
AuxBuyMinLevel,
AuxBuyMaxLevel,
AuxBuyUsableCheckButton,
AuxBuyTooltipInputBox,
AuxBuyTooltipArrow,
AuxBuyTooltipButton,
AuxBuyFiltersTooltipInputBox1,
AuxBuyFiltersTooltipInputBox2,
AuxBuyFiltersTooltipInputBox3,
AuxBuyFiltersTooltipInputBox4,
}
private.filter = filter
if filter == ITEM then
@@ -542,7 +543,13 @@ function Aux.buy.SearchButton_onclick()
refresh = true
local category = UIDropDownMenu_GetSelectedValue(AuxBuyCategoryDropDown)
local tooltip_patterns = Aux.util.set_to_array(tooltip_patterns)
local tooltip_patterns = {}
for i=1,4 do
local tooltip_pattern = getglobal('AuxBuyFiltersTooltipInputBox'..i):GetText()
if tooltip_pattern ~= '' then
tinsert(tooltip_patterns, tooltip_pattern)
end
end
search_query = {
name = AuxBuyNameInputBox:GetText(),
@@ -886,33 +893,3 @@ function AuxBuyQualityDropDown_Initialize()
end
end
function AuxBuyTooltipButton_OnClick()
local pattern = AuxBuyTooltipInputBox:GetText()
if pattern ~= '' then
Aux.util.set_add(tooltip_patterns, pattern)
if DropDownList1:IsVisible() then
Aux.buy.toggle_tooltip_dropdown()
end
Aux.buy.toggle_tooltip_dropdown()
end
AuxBuyTooltipInputBox:SetText('')
end
function AuxBuyTooltipDropDown_Initialize()
for pattern, _ in tooltip_patterns do
UIDropDownMenu_AddButton{
text = pattern,
value = pattern,
func = AuxBuyTooltipDropDown_OnClick,
notCheckable = true,
}
end
end
function AuxBuyTooltipDropDown_OnClick()
Aux.util.set_remove(tooltip_patterns, this.value)
end
function Aux.buy.toggle_tooltip_dropdown()
ToggleDropDownMenu(1, nil, AuxBuyTooltipDropDown, AuxBuyTooltipInputBox, -12, 4)
end
+35 -39
View File
@@ -220,7 +220,7 @@
</Layers>
</CheckButton>
<EditBox name="AuxBuyTooltipInputBox" autoFocus="false" inherits="AuxInputBoxTemplate">
<EditBox name="$parentTooltipInputBox1" autoFocus="false" inherits="AuxInputBoxTemplate">
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="15" y="-216"/></Offset></Anchor></Anchors>
<Scripts>
<OnLoad>
@@ -232,49 +232,45 @@
</OnEnterPressed>
</Scripts>
</EditBox>
<Frame name="AuxBuyTooltipDropDown" inherits="UIDropDownMenuTemplate" hidden="true">
<EditBox name="$parentTooltipInputBox2" autoFocus="false" inherits="AuxInputBoxTemplate">
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="15" y="-246"/></Offset></Anchor></Anchors>
<Scripts>
<OnLoad>
UIDropDownMenu_Initialize(this, AuxBuyTooltipDropDown_Initialize)
getglobal(this:GetName()..'Label'):SetText('Tooltip')
this:SetWidth(110)
</OnLoad>
</Scripts>
</Frame>
<Button name="AuxBuyTooltipArrow">
<Size><AbsDimension x="24" y="24"/></Size>
<Anchors><Anchor point="LEFT" relativePoint="RIGHT" relativeTo="AuxBuyTooltipInputBox"><Offset><AbsDimension x="-4" y="0"/></Offset></Anchor></Anchors>
<Scripts>
<OnClick>
Aux.buy.toggle_tooltip_dropdown()
PlaySound("igMainMenuOptionCheckBoxOn")
</OnClick>
</Scripts>
<NormalTexture name="$parentNormalTexture" file="Interface\ChatFrame\UI-ChatIcon-ScrollDown-Up">
<Size><AbsDimension x="24" y="24"/></Size>
<Anchors><Anchor point="RIGHT"/></Anchors>
</NormalTexture>
<PushedTexture name="$parentPushedTexture" file="Interface\ChatFrame\UI-ChatIcon-ScrollDown-Down">
<Size><AbsDimension x="24" y="24"/></Size>
<Anchors><Anchor point="RIGHT"/></Anchors>
</PushedTexture>
<DisabledTexture name="$parentDisabledTexture" file="Interface\ChatFrame\UI-ChatIcon-ScrollDown-Disabled">
<Size><AbsDimension x="24" y="24"/></Size>
<Anchors><Anchor point="RIGHT"/></Anchors>
</DisabledTexture>
<HighlightTexture name="$parentHighlightTexture" file="Interface\Buttons\UI-Common-MouseHilight" alphaMode="ADD">
<Size><AbsDimension x="24" y="24"/></Size>
<Anchors><Anchor point="RIGHT"/></Anchors>
</HighlightTexture>
</Button>
<Button name="AuxBuyTooltipButton" inherits="UIPanelButtonTemplate" text="+">
<Size><AbsDimension x="22" y="22"/></Size>
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="143" y="-216"/></Offset></Anchor></Anchors>
<Scripts>
<OnClick>
<OnEnterPressed>
AuxBuyTooltipButton_OnClick(this)
</OnClick>
</OnEnterPressed>
</Scripts>
</Button>
</EditBox>
<EditBox name="$parentTooltipInputBox3" autoFocus="false" inherits="AuxInputBoxTemplate">
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="15" y="-276"/></Offset></Anchor></Anchors>
<Scripts>
<OnLoad>
getglobal(this:GetName()..'Label'):SetText('Tooltip')
this:SetWidth(110)
</OnLoad>
<OnEnterPressed>
AuxBuyTooltipButton_OnClick(this)
</OnEnterPressed>
</Scripts>
</EditBox>
<EditBox name="$parentTooltipInputBox4" autoFocus="false" inherits="AuxInputBoxTemplate">
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="15" y="-306"/></Offset></Anchor></Anchors>
<Scripts>
<OnLoad>
getglobal(this:GetName()..'Label'):SetText('Tooltip')
this:SetWidth(110)
</OnLoad>
<OnEnterPressed>
AuxBuyTooltipButton_OnClick(this)
</OnEnterPressed>
</Scripts>
</EditBox>
<Button name="AuxBuySearchButton" inherits="UIPanelButtonTemplate" text="Search">
<Size><AbsDimension x="90" y="26"/></Size>