search control changes
This commit is contained in:
@@ -561,6 +561,7 @@ end
|
||||
|
||||
do
|
||||
local editbox = CreateFrame'EditBox'
|
||||
editbox:SetAutoFocus(false)
|
||||
function public.clear_focus()
|
||||
editbox:SetFocus()
|
||||
editbox:ClearFocus()
|
||||
|
||||
+59
-54
@@ -35,24 +35,9 @@ frame.saved.autobuy:SetPoint('BOTTOMLEFT', 0, 0)
|
||||
frame.saved.recent = gui.panel(frame.saved)
|
||||
frame.saved.recent:SetPoint('TOPLEFT', frame.saved.favorite, 'TOPRIGHT', 2.5, 0)
|
||||
frame.saved.recent:SetPoint('BOTTOMRIGHT', 0, 0)
|
||||
do
|
||||
local btn = gui.checkbutton(frame)
|
||||
btn:SetPoint('TOPLEFT', 5, -8)
|
||||
btn:SetWidth(90)
|
||||
btn:SetHeight(25)
|
||||
btn:SetText'Real Time'
|
||||
btn:SetScript('OnClick', function()
|
||||
this:SetChecked(not this:GetChecked())
|
||||
this = first_page_input
|
||||
first_page_input:GetScript('OnTextChanged')()
|
||||
this = last_page_input
|
||||
last_page_input:GetScript('OnTextChanged')()
|
||||
end)
|
||||
private.real_time_button = btn
|
||||
end
|
||||
do
|
||||
local btn = gui.button(frame, 25)
|
||||
btn:SetPoint('LEFT', real_time_button, 'RIGHT', 4, 0)
|
||||
btn:SetPoint('TOPLEFT', 5, -8)
|
||||
btn:SetWidth(30)
|
||||
btn:SetHeight(25)
|
||||
btn:SetText'<'
|
||||
@@ -68,6 +53,64 @@ do
|
||||
btn:SetScript('OnClick', next_search)
|
||||
private.next_button = btn
|
||||
end
|
||||
do
|
||||
local btn = gui.button(frame, gui.font_size.small)
|
||||
btn:SetHeight(25)
|
||||
btn:SetWidth(60)
|
||||
btn:SetText(color.label.enabled'Range:')
|
||||
btn:SetScript('OnClick', function()
|
||||
update_real_time(true)
|
||||
end)
|
||||
private.range_button = btn
|
||||
end
|
||||
do
|
||||
local btn = gui.button(frame, gui.font_size.small)
|
||||
btn:SetHeight(25)
|
||||
btn:SetWidth(60)
|
||||
btn:Hide()
|
||||
btn:SetText(color.label.enabled'Real Time')
|
||||
btn:SetScript('OnClick', function()
|
||||
update_real_time(false)
|
||||
end)
|
||||
private.real_time_button = btn
|
||||
end
|
||||
do
|
||||
local function change()
|
||||
local page = tonumber(this:GetText())
|
||||
local valid_input = page and tostring(max(1, page)) or ''
|
||||
if this:GetText() ~= valid_input then
|
||||
this:SetText(valid_input)
|
||||
end
|
||||
end
|
||||
do
|
||||
local editbox = gui.editbox(range_button)
|
||||
editbox:SetPoint('LEFT', range_button, 'RIGHT', 4, 0)
|
||||
editbox:SetWidth(40)
|
||||
editbox:SetHeight(25)
|
||||
editbox:SetAlignment'CENTER'
|
||||
editbox:SetNumeric(true)
|
||||
editbox:SetScript('OnTabPressed', function() last_page_input:SetFocus() end)
|
||||
editbox.enter = execute
|
||||
editbox.change = change
|
||||
local label = gui.label(editbox, gui.font_size.medium)
|
||||
label:SetPoint('LEFT', editbox, 'RIGHT', 0, 0)
|
||||
label:SetTextColor(color.label.enabled())
|
||||
label:SetText'-'
|
||||
private.first_page_input = editbox
|
||||
end
|
||||
do
|
||||
local editbox = gui.editbox(range_button)
|
||||
editbox:SetPoint('LEFT', first_page_input, 'RIGHT', 5.8, 0)
|
||||
editbox:SetWidth(40)
|
||||
editbox:SetHeight(25)
|
||||
editbox:SetAlignment'CENTER'
|
||||
editbox:SetNumeric(true)
|
||||
editbox:SetScript('OnTabPressed', function() first_page_input:SetFocus() end)
|
||||
editbox.enter = execute
|
||||
editbox.change = change
|
||||
private.last_page_input = editbox
|
||||
end
|
||||
end
|
||||
do
|
||||
local btn = gui.button(frame)
|
||||
btn:SetPoint('TOPRIGHT', -5, -8)
|
||||
@@ -100,43 +143,6 @@ do
|
||||
end)
|
||||
private.resume_button = btn
|
||||
end
|
||||
do
|
||||
local function change()
|
||||
local page = tonumber(this:GetText())
|
||||
local valid_input = page and tostring(max(1, page)) or ''
|
||||
if this:GetText() ~= valid_input then
|
||||
this:SetText(valid_input)
|
||||
end
|
||||
end
|
||||
do
|
||||
local editbox = gui.editbox(frame)
|
||||
editbox:SetPoint('RIGHT', start_button, 'LEFT', -4, 0)
|
||||
editbox:SetWidth(40)
|
||||
editbox:SetHeight(25)
|
||||
editbox:SetAlignment'CENTER'
|
||||
editbox:SetNumeric(true)
|
||||
editbox:SetScript('OnTabPressed', function() first_page_input:SetFocus() end)
|
||||
editbox.enter = execute
|
||||
editbox.change = change
|
||||
private.last_page_input = editbox
|
||||
end
|
||||
do
|
||||
local editbox = gui.editbox(frame)
|
||||
editbox:SetPoint('RIGHT', last_page_input, 'LEFT', -5.8, 0)
|
||||
editbox:SetWidth(40)
|
||||
editbox:SetHeight(25)
|
||||
editbox:SetAlignment'CENTER'
|
||||
editbox:SetNumeric(true)
|
||||
editbox:SetScript('OnTabPressed', function() last_page_input:SetFocus() end)
|
||||
editbox.enter = execute
|
||||
editbox.change = change
|
||||
local label = gui.label(editbox, gui.font_size.medium)
|
||||
label:SetPoint('LEFT', editbox, 'RIGHT', 0, 0)
|
||||
label:SetTextColor(color.label.enabled())
|
||||
label:SetText'-'
|
||||
private.first_page_input = editbox
|
||||
end
|
||||
end
|
||||
do
|
||||
local editbox = gui.editbox(frame)
|
||||
editbox:EnableMouse(1)
|
||||
@@ -145,7 +151,6 @@ do
|
||||
return queries and join(map(copy(queries), function(query) return query.prettified end), ';') or color.red(str)
|
||||
end
|
||||
editbox.complete = completion.complete_filter
|
||||
editbox:SetPoint('RIGHT', first_page_input, 'LEFT', -4, 0)
|
||||
editbox:SetHeight(25)
|
||||
editbox.char = function()
|
||||
this:complete()
|
||||
|
||||
+25
-13
@@ -9,6 +9,18 @@ function LOAD()
|
||||
new_search()
|
||||
end
|
||||
|
||||
function private.update_real_time(enable)
|
||||
if enable then
|
||||
range_button:Hide()
|
||||
real_time_button:Show()
|
||||
search_box:SetPoint('LEFT', real_time_button, 'RIGHT', 4, 0)
|
||||
else
|
||||
real_time_button:Hide()
|
||||
range_button:Show()
|
||||
search_box:SetPoint('LEFT', last_page_input, 'RIGHT', 4, 0)
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
local searches = t
|
||||
local search_index = 1
|
||||
@@ -37,20 +49,23 @@ do
|
||||
end
|
||||
if search_index == getn(searches) then
|
||||
next_button:Hide()
|
||||
search_box:SetPoint('LEFT', previous_button, 'RIGHT', 4, 0)
|
||||
range_button:SetPoint('LEFT', previous_button, 'RIGHT', 4, 0)
|
||||
real_time_button:SetPoint('LEFT', previous_button, 'RIGHT', 4, 0)
|
||||
else
|
||||
next_button:Show()
|
||||
search_box:SetPoint('LEFT', next_button, 'RIGHT', 4, 0)
|
||||
range_button:SetPoint('LEFT', next_button, 'RIGHT', 4, 0)
|
||||
real_time_button:SetPoint('LEFT', next_button, 'RIGHT', 4, 0)
|
||||
end
|
||||
update_real_time(searches[search_index].real_time)
|
||||
update_start_stop()
|
||||
update_continuation()
|
||||
end
|
||||
|
||||
function private.new_search(filter_string, first_page, last_page)
|
||||
function private.new_search(filter_string, first_page, last_page, real_time)
|
||||
while getn(searches) > search_index do
|
||||
tremove(searches)
|
||||
end
|
||||
local search = T('records', t, 'filter_string', filter_string, 'first_page', first_page, 'last_page', last_page)
|
||||
local search = T('records', t, 'filter_string', filter_string, 'first_page', first_page, 'last_page', last_page, 'real_time', real_time)
|
||||
tinsert(searches, search)
|
||||
if getn(searches) > 5 then
|
||||
tremove(searches, 1)
|
||||
@@ -93,10 +108,10 @@ end
|
||||
function private.update_continuation()
|
||||
if current_search.continuation then
|
||||
resume_button:Show()
|
||||
last_page_input:SetPoint('RIGHT', resume_button, 'LEFT', -4, 0)
|
||||
search_box:SetPoint('RIGHT', resume_button, 'LEFT', -4, 0)
|
||||
else
|
||||
resume_button:Hide()
|
||||
last_page_input:SetPoint('RIGHT', start_button, 'LEFT', -4, 0)
|
||||
search_box:SetPoint('RIGHT', start_button, 'LEFT', -4, 0)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -273,7 +288,7 @@ function public.execute(resume, real_time)
|
||||
if resume then
|
||||
real_time = current_search.real_time
|
||||
elseif real_time == nil then
|
||||
real_time = real_time_button:GetChecked()
|
||||
real_time = real_time_button:IsShown()
|
||||
end
|
||||
|
||||
if resume then
|
||||
@@ -300,9 +315,9 @@ function public.execute(resume, real_time)
|
||||
if resume then
|
||||
current_search.table:SetSelectedRecord()
|
||||
else
|
||||
if filter_string ~= current_search.filter_string then
|
||||
if filter_string ~= current_search.filter_string or first_page ~= current_search.first_page or last_page ~= current_search.last_page or real_time ~= current_search.real_time then
|
||||
if current_search.filter_string then
|
||||
new_search(filter_string, first_page, last_page)
|
||||
new_search(filter_string, first_page, last_page, real_time)
|
||||
else
|
||||
current_search.filter_string = filter_string
|
||||
end
|
||||
@@ -310,13 +325,10 @@ function public.execute(resume, real_time)
|
||||
else
|
||||
current_search.records = t
|
||||
current_search.table:SetDatabase(current_search.records)
|
||||
if current_search.real_time ~= real_time then
|
||||
current_search.table:Reset()
|
||||
end
|
||||
end
|
||||
current_search.first_page = first_page
|
||||
current_search.last_page = last_page
|
||||
current_search.real_time = real_time_button:GetChecked()
|
||||
current_search.real_time = real_time
|
||||
current_search.auto_buy_validator = auto_buy_validator
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user