From c17a1508c6501587bb0dacde86152a088aa9c4af Mon Sep 17 00:00:00 2001 From: Simon Hirsig Date: Fri, 30 Oct 2015 13:02:47 +0100 Subject: [PATCH] proper row button for listings and some filter changes --- item_search_frame.lua | 0 list.lua | 76 ++++++++++++++++++++++++------------------- search_frame.lua | 45 +++++++------------------ search_frame.xml | 74 ++++++++++++++++++++--------------------- 4 files changed, 88 insertions(+), 107 deletions(-) create mode 100644 item_search_frame.lua diff --git a/item_search_frame.lua b/item_search_frame.lua new file mode 100644 index 0000000..e69de29 diff --git a/list.lua b/list.lua index 25c7e70..f19f9c7 100644 --- a/list.lua +++ b/list.lua @@ -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 \ No newline at end of file +end diff --git a/search_frame.lua b/search_frame.lua index f76f1e7..df6d68d 100644 --- a/search_frame.lua +++ b/search_frame.lua @@ -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 diff --git a/search_frame.xml b/search_frame.xml index ebfacb1..254c001 100644 --- a/search_frame.xml +++ b/search_frame.xml @@ -220,7 +220,7 @@ - + @@ -232,49 +232,45 @@ - - + + + - UIDropDownMenu_Initialize(this, AuxBuyTooltipDropDown_Initialize) + getglobal(this:GetName()..'Label'):SetText('Tooltip') + this:SetWidth(110) - - - - + + + + + + + getglobal(this:GetName()..'Label'):SetText('Tooltip') + this:SetWidth(110) + + + AuxBuyTooltipButton_OnClick(this) + + + + + + + + + getglobal(this:GetName()..'Label'):SetText('Tooltip') + this:SetWidth(110) + + + AuxBuyTooltipButton_OnClick(this) + + +