replace Ace3v with Ace3 ElvUI-TBC version

or easy tracking of code difference
This commit is contained in:
Pinya
2018-07-21 13:20:39 +03:00
parent bb867629d5
commit 332d53e7f6
59 changed files with 1975 additions and 2496 deletions
@@ -2,13 +2,12 @@
Slider Widget
Graphical Slider, like, for Range values.
-------------------------------------------------------------------------------]]
local Type, Version = "Slider", 21
local Type, Version = "Slider", 20
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
-- Lua APIs
local min, max, floor = math.min, math.max, math.floor
local format, gsub = string.format, string.gsub
local tonumber, pairs = tonumber, pairs
-- WoW APIs
@@ -25,7 +24,7 @@ Support functions
local function UpdateText(self)
local value = self.value or 0
if self.ispercent then
self.editbox:SetText(format("%s%%", floor(value * 1000 + 0.5) / 10))
self.editbox:SetText(("%s%%"):format(floor(value * 1000 + 0.5) / 10))
else
self.editbox:SetText(floor(value * 100 + 0.5) / 100)
end
@@ -34,8 +33,8 @@ end
local function UpdateLabels(self)
local min, max = (self.min or 0), (self.max or 100)
if self.ispercent then
self.lowtext:SetText(format("%s%%", (min * 100)))
self.hightext:SetText(format("%s%%", (max * 100)))
self.lowtext:SetFormattedText("%s%%", (min * 100))
self.hightext:SetFormattedText("%s%%", (max * 100))
else
self.lowtext:SetText(min)
self.hightext:SetText(max)
@@ -45,30 +44,26 @@ end
--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function Control_OnEnter()
this.obj:Fire("OnEnter")
local function Control_OnEnter(frame)
frame.obj:Fire("OnEnter")
end
local function Control_OnLeave()
this.obj:Fire("OnLeave")
local function Control_OnLeave(frame)
frame.obj:Fire("OnLeave")
end
local function Frame_OnMouseDown()
this.obj.slider:EnableMouseWheel(true)
local function Frame_OnMouseDown(frame)
frame.obj.slider:EnableMouseWheel(true)
AceGUI:ClearFocus()
end
local function Slider_OnValueChanged()
local self = this.obj
if not this.setup then
local newvalue = this:GetValue()
if self.step and self.step > 0 then
local min_value = self.min or 0
newvalue = floor((newvalue - min_value) / self.step + 0.5) * self.step + min_value
end
local function Slider_OnValueChanged(frame)
local self = frame.obj
if not frame.setup then
local newvalue = frame:GetValue()
if newvalue ~= self.value and not self.disabled then
self.value = newvalue
self:Fire("OnValueChanged", 1, newvalue)
self:Fire("OnValueChanged", newvalue)
end
if self.value then
UpdateText(self)
@@ -76,16 +71,16 @@ local function Slider_OnValueChanged()
end
end
local function Slider_OnMouseUp()
local self = this.obj
self:Fire("OnMouseUp", 1, self.value)
local function Slider_OnMouseUp(frame)
local self = frame.obj
self:Fire("OnMouseUp", self.value)
end
local function Slider_OnMouseWheel()
local self = this.obj
local function Slider_OnMouseWheel(frame, v)
local self = frame.obj
if not self.disabled then
local value = self.value
if arg1 > 0 then
if v > 0 then
value = min(value + (self.step or 1), self.max)
else
value = max(value - (self.step or 1), self.min)
@@ -94,15 +89,15 @@ local function Slider_OnMouseWheel()
end
end
local function EditBox_OnEscapePressed()
this:ClearFocus()
local function EditBox_OnEscapePressed(frame)
frame:ClearFocus()
end
local function EditBox_OnEnterPressed()
local self = this.obj
local value = this:GetText()
local function EditBox_OnEnterPressed(frame)
local self = frame.obj
local value = frame:GetText()
if self.ispercent then
value = gsub(value, '%%', '')
value = value:gsub('%%', '')
value = tonumber(value) / 100
else
value = tonumber(value)
@@ -111,16 +106,16 @@ local function EditBox_OnEnterPressed()
if value then
PlaySound("igMainMenuOptionCheckBoxOn")
self.slider:SetValue(value)
self:Fire("OnMouseUp", 1, value)
self:Fire("OnMouseUp", value)
end
end
local function EditBox_OnEnter()
this:SetBackdropBorderColor(0.5, 0.5, 0.5, 1)
local function EditBox_OnEnter(frame)
frame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1)
end
local function EditBox_OnLeave()
this:SetBackdropBorderColor(0.3, 0.3, 0.3, 0.8)
local function EditBox_OnLeave(frame)
frame:SetBackdropBorderColor(0.3, 0.3, 0.3, 0.8)
end
--[[-----------------------------------------------------------------------------
@@ -222,9 +217,9 @@ local function Constructor()
frame:SetScript("OnMouseDown", Frame_OnMouseDown)
local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
label:SetPoint("TOPLEFT",0,0)
label:SetPoint("TOPRIGHT",0,0)
label:SetJustifyH("CENTER",0,0)
label:SetPoint("TOPLEFT")
label:SetPoint("TOPRIGHT")
label:SetJustifyH("CENTER")
label:SetHeight(15)
local slider = CreateFrame("Slider", nil, frame)