bugfix, filter display improvement
This commit is contained in:
@@ -111,7 +111,7 @@ function public.VARIABLES_LOADED()
|
|||||||
btn:SetWidth(65)
|
btn:SetWidth(65)
|
||||||
btn:SetHeight(24)
|
btn:SetHeight(24)
|
||||||
btn:SetText('Close')
|
btn:SetText('Close')
|
||||||
btn:SetScript('OnClick', m._(m.frame.hide, m.frame))
|
btn:SetScript('OnClick', m._(m.frame.Hide, m.frame))
|
||||||
public.close_button = btn
|
public.close_button = btn
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
+25
-7
@@ -521,7 +521,7 @@ end
|
|||||||
|
|
||||||
function private.blizzard_level(str)
|
function private.blizzard_level(str)
|
||||||
if tonumber(str) then
|
if tonumber(str) then
|
||||||
return aux.util.round(max(1, min(60, tonumber(str))))
|
return aux.util.round(aux.util.bound(1, 60, tonumber(str)))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -911,21 +911,39 @@ do
|
|||||||
|
|
||||||
function private.update_filter_display()
|
function private.update_filter_display()
|
||||||
text = aux.filter.indented_post_query_string(m.post_components)
|
text = aux.filter.indented_post_query_string(m.post_components)
|
||||||
m.filter_display:SetWidth(m.filter_display_width())
|
m.filter_display:SetWidth(m.filter_display_size())
|
||||||
|
m.set_filter_display_offset()
|
||||||
m.filter_display:SetText(text)
|
m.filter_display:SetText(text)
|
||||||
end
|
end
|
||||||
|
|
||||||
function private.filter_display_width()
|
function private.filter_display_size()
|
||||||
local widest_line = 0
|
local font, font_size = m.filter_display:GetFont()
|
||||||
|
m.filter_display.measure:SetFont(font, font_size)
|
||||||
|
local lines = 0
|
||||||
|
local width = 0
|
||||||
|
|
||||||
for line in string.gfind(text, '<p>(.-)</p>') do
|
for line in string.gfind(text, '<p>(.-)</p>') do
|
||||||
m.filter_display.measure:SetFont(m.filter_display:GetFont())
|
lines = lines + 1
|
||||||
m.filter_display.measure:SetText(line)
|
m.filter_display.measure:SetText(line)
|
||||||
widest_line = max(widest_line, m.filter_display.measure:GetStringWidth())
|
width = max(width, m.filter_display.measure:GetStringWidth())
|
||||||
end
|
end
|
||||||
return widest_line
|
|
||||||
|
return width, lines*font_size
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function private.set_filter_display_offset(x_offset, y_offset)
|
||||||
|
local scroll_frame = m.filter_display:GetParent()
|
||||||
|
x_offset, y_offset = x_offset or scroll_frame:GetHorizontalScroll(), y_offset or scroll_frame:GetVerticalScroll()
|
||||||
|
local width, height = m.filter_display_size()
|
||||||
|
local x_lower_bound = min(0, scroll_frame:GetWidth() - width - 2)
|
||||||
|
local x_upper_bound = 0
|
||||||
|
local y_lower_bound = 0
|
||||||
|
local y_upper_bound = max(0, height - scroll_frame:GetHeight() + 2)
|
||||||
|
scroll_frame:SetHorizontalScroll(aux.util.bound(x_lower_bound, x_upper_bound, x_offset))
|
||||||
|
scroll_frame:SetVerticalScroll(aux.util.bound(y_lower_bound, y_upper_bound, y_offset))
|
||||||
|
end
|
||||||
|
|
||||||
function private.new_recent_search(filter_string, prettified)
|
function private.new_recent_search(filter_string, prettified)
|
||||||
tinsert(aux_recent_searches, 1, {
|
tinsert(aux_recent_searches, 1, {
|
||||||
filter_string = filter_string,
|
filter_string = filter_string,
|
||||||
|
|||||||
@@ -535,7 +535,7 @@ function private.create_frames()
|
|||||||
scroll_frame:EnableMouseWheel(true)
|
scroll_frame:EnableMouseWheel(true)
|
||||||
scroll_frame:SetScript('OnMouseWheel', function()
|
scroll_frame:SetScript('OnMouseWheel', function()
|
||||||
local child = this:GetScrollChild()
|
local child = this:GetScrollChild()
|
||||||
child:SetFont('p', [[Fonts\ARIALN.TTF]], max(10, min(26, aux.util.select(2, child:GetFont()) + arg1*2)))
|
child:SetFont('p', [[Fonts\ARIALN.TTF]], aux.util.bound(10, 26, aux.util.select(2, child:GetFont()) + arg1*2))
|
||||||
m.update_filter_display()
|
m.update_filter_display()
|
||||||
end)
|
end)
|
||||||
scroll_frame:RegisterForDrag('LeftButton')
|
scroll_frame:RegisterForDrag('LeftButton')
|
||||||
@@ -548,8 +548,8 @@ function private.create_frames()
|
|||||||
local new_x_offset = this.x_offset + x - this.x
|
local new_x_offset = this.x_offset + x - this.x
|
||||||
local new_y_offset = this.y_offset + y - this.y
|
local new_y_offset = this.y_offset + y - this.y
|
||||||
|
|
||||||
this:SetHorizontalScroll(min(0, max((this:GetWidth() - m.filter_display_width())*m.filter_display:GetScale() - 2, new_x_offset - this.x_extra)))
|
m.set_filter_display_offset(new_x_offset - this.x_extra, new_y_offset - this.y_extra)
|
||||||
this:SetVerticalScroll(max(0, new_y_offset - this.y_extra))
|
|
||||||
this.x_extra = max(this.x_extra, new_x_offset)
|
this.x_extra = max(this.x_extra, new_x_offset)
|
||||||
this.y_extra = min(this.y_extra, new_y_offset)
|
this.y_extra = min(this.y_extra, new_y_offset)
|
||||||
end)
|
end)
|
||||||
|
|||||||
+8
-1
@@ -1,5 +1,9 @@
|
|||||||
local m, public, private = aux.module'util'
|
local m, public, private = aux.module'util'
|
||||||
|
|
||||||
|
function public.bound(lower_bound, upper_bound, number)
|
||||||
|
return max(lower_bound, min(upper_bound, number))
|
||||||
|
end
|
||||||
|
|
||||||
function public.size(t)
|
function public.size(t)
|
||||||
local x = 0
|
local x = 0
|
||||||
for _ in t do
|
for _ in t do
|
||||||
@@ -33,7 +37,10 @@ function public.values(t)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function public.select(i, ...)
|
function public.select(i, ...)
|
||||||
return arg[i]
|
for _=1,i-1 do
|
||||||
|
tremove(arg, 1)
|
||||||
|
end
|
||||||
|
return unpack(arg)
|
||||||
end
|
end
|
||||||
|
|
||||||
function public.eq(t1, t2)
|
function public.eq(t1, t2)
|
||||||
|
|||||||
Reference in New Issue
Block a user